Skip to content

Commit

Permalink
filter staff status entries by "employee" flag - dao impl
Browse files Browse the repository at this point in the history
  • Loading branch information
rkrenn committed Feb 2, 2024
1 parent be76f74 commit bdc88dd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ protected boolean equals(StaffStatusEntryInVO in, StaffStatusEntry existing) {
@Override
protected Collection<StaffStatusEntry> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private org.hibernate.Criteria createStatusEntryCriteria() {
@Override
protected Collection<StaffStatusEntry> 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);
Expand All @@ -49,7 +49,7 @@ protected Collection<StaffStatusEntry> 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()));
Expand All @@ -60,6 +60,9 @@ protected Collection<StaffStatusEntry> handleFindByDepartmentCategoryInterval(
if (allocatable != null) {
staffCriteria.add(Restrictions.eq("allocatable", allocatable.booleanValue()));
}
if (employee != null) {
staffCriteria.add(Restrictions.eq("employee", employee.booleanValue()));
}
}
return statusEntryCriteria.list();
}
Expand All @@ -78,7 +81,7 @@ protected Collection<StaffStatusEntry> handleFindByStaff(Long staffId,

@Override
protected Collection<StaffStatusEntry> 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);
Expand All @@ -94,16 +97,22 @@ protected Collection<StaffStatusEntry> 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();
}

@Override
protected Collection<StaffStatusEntry> 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) {
Expand All @@ -115,6 +124,9 @@ protected Collection<StaffStatusEntry> 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()));
}
Expand Down

0 comments on commit bdc88dd

Please sign in to comment.