Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hide status entries of staff without employee flag #277

Merged
merged 7 commits into from
Feb 2, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,9 @@ protected Collection<StaffStatusEntryOutVO> handleGetCollidingStaffStatusEntries
.findByCourseSorted(courseParticipationStatusEntry.getCourse().getId(), isRelevantForCourseAppointments, false).iterator();
while (it.hasNext()) {
InventoryBooking courseInventoryBooking = it.next();
collidingStaffStatusEntries.addAll(staffStatusEntryDao.findByStaffInterval(staffId, courseInventoryBooking.getStart(), courseInventoryBooking.getStop(), false, null,
false));
collidingStaffStatusEntries
.addAll(staffStatusEntryDao.findByStaffInterval(staffId, courseInventoryBooking.getStart(), courseInventoryBooking.getStop(), false, true, null,
false));
}
staffStatusEntryDao.toStaffStatusEntryOutVOCollection(collidingStaffStatusEntries);
return new ArrayList<StaffStatusEntryOutVO>(collidingStaffStatusEntries);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ protected Collection<StaffStatusEntryOutVO> handleGetCollidingStaffStatusEntries
while (it.hasNext()) {
CourseParticipationStatusEntry courseParticipationStatusEntry = it.next();
collidingStaffStatusEntries.addAll(staffStatusEntryDao.findByStaffInterval(courseParticipationStatusEntry.getStaff().getId(), courseInventoryBooking.getStart(),
courseInventoryBooking.getStop(), false, null, false));
courseInventoryBooking.getStop(), false, true, null, false));
}
staffStatusEntryDao.toStaffStatusEntryOutVOCollection(collidingStaffStatusEntries);
return new ArrayList<StaffStatusEntryOutVO>(collidingStaffStatusEntries);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,8 @@ protected long handlePrepareNotifications(Long departmentId) throws Exception {
}
}
}
Iterator<StaffStatusEntry> staffStatusIt = this.getStaffStatusEntryDao().findStaffStatus(CommonUtil.dateToTimestamp(today), null, departmentId, null, false, null, null)
Iterator<StaffStatusEntry> staffStatusIt = this.getStaffStatusEntryDao()
.findStaffStatus(CommonUtil.dateToTimestamp(today), null, departmentId, null, false, true, null, null)
.iterator();
while (staffStatusIt.hasNext()) {
StaffStatusEntry staffStatusEntry = staffStatusIt.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1311,7 +1311,7 @@ protected Collection<StaffStatusEntryOutVO> handleGetCollidingStaffStatusEntries
Staff staff = dutyRosterTurn.getStaff();
if (staff != null) {
StaffStatusEntryDao staffStatusEntryDao = this.getStaffStatusEntryDao();
collidingStaffStatusEntries = staffStatusEntryDao.findByStaffInterval(staff.getId(), dutyRosterTurn.getStart(), dutyRosterTurn.getStop(), false, true, false);
collidingStaffStatusEntries = staffStatusEntryDao.findByStaffInterval(staff.getId(), dutyRosterTurn.getStart(), dutyRosterTurn.getStop(), false, true, true, false);
staffStatusEntryDao.toStaffStatusEntryOutVOCollection(collidingStaffStatusEntries);
} else {
collidingStaffStatusEntries = new ArrayList<StaffStatusEntryOutVO>();
Expand All @@ -1325,7 +1325,7 @@ protected Collection<StaffStatusEntryOutVO> handleGetCollidingStaffStatusEntries
CheckIDUtil.checkStaffId(staffId, this.getStaffDao());
StaffStatusEntryDao staffStatusEntryDao = this.getStaffStatusEntryDao();
Collection collidingStaffStatusEntries = staffStatusEntryDao
.findByStaffInterval(staffId, CommonUtil.dateToTimestamp(start), CommonUtil.dateToTimestamp(stop), false, true, false);
.findByStaffInterval(staffId, CommonUtil.dateToTimestamp(start), CommonUtil.dateToTimestamp(stop), false, true, true, false);
staffStatusEntryDao.toStaffStatusEntryOutVOCollection(collidingStaffStatusEntries);
return collidingStaffStatusEntries;
}
Expand Down Expand Up @@ -1712,7 +1712,8 @@ protected Collection<StaffStatusEntryOutVO> handleGetStaffStatus(AuthenticationV
CheckIDUtil.checkStaffCategoryId(staffCategoryId, this.getStaffCategoryDao());
}
StaffStatusEntryDao statusEntryDao = this.getStaffStatusEntryDao();
Collection staffStatusEntries = statusEntryDao.findStaffStatus(CommonUtil.dateToTimestamp(now), staffId, departmentId, staffCategoryId, staffActive, hideAvailability, psf);
Collection staffStatusEntries = statusEntryDao.findStaffStatus(CommonUtil.dateToTimestamp(now), staffId, departmentId, staffCategoryId, staffActive, true, hideAvailability,
psf);
statusEntryDao.toStaffStatusEntryOutVOCollection(staffStatusEntries);
return staffStatusEntries;
}
Expand Down Expand Up @@ -1746,7 +1747,7 @@ protected Collection<StaffStatusEntryOutVO> handleGetStaffStatusEntryInterval(
}
StaffStatusEntryDao statusEntryDao = this.getStaffStatusEntryDao();
Collection staffStatusEntries = statusEntryDao.findByDepartmentCategoryInterval(departmentId, staffCategoryId, CommonUtil.dateToTimestamp(from),
CommonUtil.dateToTimestamp(to), null, null, hideAvailability);
CommonUtil.dateToTimestamp(to), null, true, true, hideAvailability);
statusEntryDao.toStaffStatusEntryOutVOCollection(staffStatusEntries);
if (sort) {
staffStatusEntries = new ArrayList(staffStatusEntries);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5537,7 +5537,7 @@ protected Collection<StaffStatusEntryOutVO> handleGetCollidingStaffStatusEntries
Iterator<VisitScheduleItem> it = this.getVisitScheduleItemDao().findExpandedDateMode(visitScheduleItem.getId(), null).iterator();
while (it.hasNext()) {
VisitScheduleItem expanded = it.next();
collidingStaffStatusEntries.addAll(staffStatusEntryDao.findByStaffInterval(staffId, expanded.getStart(), expanded.getStop(), false, true, false));
collidingStaffStatusEntries.addAll(staffStatusEntryDao.findByStaffInterval(staffId, expanded.getStart(), expanded.getStop(), false, true, true, false));
}
staffStatusEntryDao.toStaffStatusEntryOutVOCollection(collidingStaffStatusEntries);
collidingStaffStatusEntries = new ArrayList<StaffStatusEntryOutVO>(collidingStaffStatusEntries);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4663,7 +4663,7 @@ public static void populateShiftDurationSummary(boolean trialBreakDown, ShiftDur
durationSummaryDetail.setStaffStatusEntryDuration(0);
if (!trialBreakDown && staff != null) {
Iterator<StaffStatusEntry> statusEntryIt = staffStatusEntryDao.findByStaffInterval(staff.getId(), CommonUtil.dateToTimestamp(summary.getStart()),
CommonUtil.dateToTimestamp(summary.getStop()), false, null, false).iterator();
CommonUtil.dateToTimestamp(summary.getStop()), false, null, null, false).iterator();
while (statusEntryIt.hasNext()) {
StaffStatusEntry statusEntry = statusEntryIt.next();
Date start = statusEntry.getStart();
Expand Down
Loading
Loading