From bdc88dd0517288eddb1d0e87d2f279339a672b66 Mon Sep 17 00:00:00 2001 From: Rene Krenn Date: Fri, 2 Feb 2024 15:54:20 +0100 Subject: [PATCH] filter staff status entries by "employee" flag - dao impl --- .../StaffStatusEntryCollisionFinder.java | 3 ++- .../ctsms/domain/StaffStatusEntryDaoImpl.java | 24 ++++++++++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/org/phoenixctms/ctsms/adapt/StaffStatusEntryCollisionFinder.java b/core/src/main/java/org/phoenixctms/ctsms/adapt/StaffStatusEntryCollisionFinder.java index fc17c98dbe57..c048c404c4c2 100644 --- a/core/src/main/java/org/phoenixctms/ctsms/adapt/StaffStatusEntryCollisionFinder.java +++ b/core/src/main/java/org/phoenixctms/ctsms/adapt/StaffStatusEntryCollisionFinder.java @@ -36,7 +36,8 @@ protected boolean equals(StaffStatusEntryInVO in, StaffStatusEntry existing) { @Override protected Collection getCollidingItems( StaffStatusEntryInVO in, Staff root) { - return staffStatusEntryDao.findByStaffInterval(in.getStaffId(), CommonUtil.dateToTimestamp(in.getStart()), CommonUtil.dateToTimestamp(in.getStop()), false, null, null); + return staffStatusEntryDao.findByStaffInterval(in.getStaffId(), CommonUtil.dateToTimestamp(in.getStart()), CommonUtil.dateToTimestamp(in.getStop()), false, null, null, + null); } @Override diff --git a/core/src/main/java/org/phoenixctms/ctsms/domain/StaffStatusEntryDaoImpl.java b/core/src/main/java/org/phoenixctms/ctsms/domain/StaffStatusEntryDaoImpl.java index 15610d7908e2..a700ddd25f81 100644 --- a/core/src/main/java/org/phoenixctms/ctsms/domain/StaffStatusEntryDaoImpl.java +++ b/core/src/main/java/org/phoenixctms/ctsms/domain/StaffStatusEntryDaoImpl.java @@ -36,7 +36,7 @@ private org.hibernate.Criteria createStatusEntryCriteria() { @Override protected Collection handleFindByDepartmentCategoryInterval( Long departmentId, Long staffCategoryId, Timestamp from, - Timestamp to, Boolean staffActive, Boolean allocatable, Boolean hideAvailability) + Timestamp to, Boolean staffActive, Boolean employee, Boolean allocatable, Boolean hideAvailability) throws Exception { Criteria statusEntryCriteria = createStatusEntryCriteria(); CriteriaUtil.applyStopOpenIntervalCriterion(statusEntryCriteria, from, to, null); @@ -49,7 +49,7 @@ protected Collection handleFindByDepartmentCategoryInterval( typeCriteria.add(Restrictions.eq("hideAvailability", hideAvailability.booleanValue())); } } - if (departmentId != null || staffCategoryId != null || allocatable != null) { + if (departmentId != null || staffCategoryId != null || allocatable != null || employee != null) { Criteria staffCriteria = statusEntryCriteria.createCriteria("staff", CriteriaSpecification.INNER_JOIN); if (departmentId != null) { staffCriteria.add(Restrictions.eq("department.id", departmentId.longValue())); @@ -60,6 +60,9 @@ protected Collection handleFindByDepartmentCategoryInterval( if (allocatable != null) { staffCriteria.add(Restrictions.eq("allocatable", allocatable.booleanValue())); } + if (employee != null) { + staffCriteria.add(Restrictions.eq("employee", employee.booleanValue())); + } } return statusEntryCriteria.list(); } @@ -78,7 +81,7 @@ protected Collection handleFindByStaff(Long staffId, @Override protected Collection handleFindByStaffInterval( - Long staffId, Timestamp from, Timestamp to, Boolean staffActive, Boolean allocatable, Boolean hideAvailability) + Long staffId, Timestamp from, Timestamp to, Boolean staffActive, Boolean employee, Boolean allocatable, Boolean hideAvailability) throws Exception { Criteria statusEntryCriteria = createStatusEntryCriteria(); CriteriaUtil.applyStopOpenIntervalCriterion(statusEntryCriteria, from, to, null); @@ -94,8 +97,14 @@ protected Collection handleFindByStaffInterval( if (staffId != null) { statusEntryCriteria.add(Restrictions.eq("staff.id", staffId.longValue())); } - if (allocatable != null) { - statusEntryCriteria.createCriteria("staff", CriteriaSpecification.INNER_JOIN).add(Restrictions.eq("allocatable", allocatable.booleanValue())); + if (allocatable != null || employee != null) { + Criteria staffCriteria = statusEntryCriteria.createCriteria("staff", CriteriaSpecification.INNER_JOIN); + if (allocatable != null) { + staffCriteria.add(Restrictions.eq("allocatable", allocatable.booleanValue())); + } + if (employee != null) { + staffCriteria.add(Restrictions.eq("employee", employee.booleanValue())); + } } return statusEntryCriteria.list(); } @@ -103,7 +112,7 @@ protected Collection handleFindByStaffInterval( @Override protected Collection handleFindStaffStatus(Timestamp now, Long staffId, Long departmentId, Long staffCategoryId, - Boolean staffActive, Boolean hideAvailability, PSFVO psf) throws Exception { + Boolean staffActive, Boolean employee, Boolean hideAvailability, PSFVO psf) throws Exception { Criteria statusEntryCriteria = createStatusEntryCriteria(); SubCriteriaMap criteriaMap = new SubCriteriaMap(StaffStatusEntry.class, statusEntryCriteria); if (staffId != null) { @@ -115,6 +124,9 @@ protected Collection handleFindStaffStatus(Timestamp now, if (staffCategoryId != null) { criteriaMap.createCriteria("staff").add(Restrictions.eq("category.id", staffCategoryId.longValue())); } + if (employee != null) { + criteriaMap.createCriteria("staff").add(Restrictions.eq("employee", employee.booleanValue())); + } if (staffActive != null) { criteriaMap.createCriteria("type").add(Restrictions.eq("staffActive", staffActive.booleanValue())); }