/** * @return {@code >= 0} */ public int getConstraintMatchCount() { return getConstraintMatchSet().size(); }
public String determinePlanningEntityTooltip(Object planningEntity) { Indictment indictment = solutionBusiness.getIndictmentMap().get(planningEntity); if (indictment == null) { return "<html>No indictment</html>"; } StringBuilder s = new StringBuilder("<html>Indictment: ").append(indictment.getScore().toShortString()); for (ConstraintMatch constraintMatch : indictment.getConstraintMatchSet()) { s.append("<br/> ").append(constraintMatch.getConstraintName()) .append(" = ").append(constraintMatch.getScore().toShortString()); } s.append("</html>"); return s.toString(); }
commentString.append("\n").append(indictment.getScore().toShortString()) .append(" total"); Set<ConstraintMatch> constraintMatchSet = indictment.getConstraintMatchSet(); List<String> constraintNameList = constraintMatchSet.stream() .map(ConstraintMatch::getConstraintName).distinct().collect(toList());
.limit(INDICTMENT_LIMIT) .forEach(indictment -> { Set<ConstraintMatch> constraintMatchSet = indictment.getConstraintMatchSet(); scoreExplanation .append(" ").append(indictment.getScore().toShortString())
void nextMeetingAssignmentListCell(List<MeetingAssignment> meetingAssignmentList, Function<MeetingAssignment, String> stringFunction, List<String> filteredConstraintNames) { if (meetingAssignmentList == null) { meetingAssignmentList = Collections.emptyList(); } HardMediumSoftScore score = meetingAssignmentList.stream() .map(indictmentMap::get).filter(Objects::nonNull) .flatMap(indictment -> indictment.getConstraintMatchSet().stream()) // Filter out filtered constraints .filter(constraintMatch -> filteredConstraintNames == null || filteredConstraintNames.contains(constraintMatch.getConstraintName())) .map(constraintMatch -> (HardMediumSoftScore) constraintMatch.getScore()) // Filter out positive constraints .filter(indictmentScore -> !(indictmentScore.getHardScore() >= 0 && indictmentScore.getSoftScore() >= 0)) .reduce(Score::add).orElse(HardMediumSoftScore.ZERO); XSSFCell cell = getXSSFCellOfScore(score); if (!meetingAssignmentList.isEmpty()) { ClientAnchor anchor = creationHelper.createClientAnchor(); anchor.setCol1(cell.getColumnIndex()); anchor.setCol2(cell.getColumnIndex() + 4); anchor.setRow1(currentRow.getRowNum()); anchor.setRow2(currentRow.getRowNum() + 4); Comment comment = currentDrawing.createCellComment(anchor); String commentString = getMeetingAssignmentListString(meetingAssignmentList); comment.setString(creationHelper.createRichTextString(commentString)); cell.setCellComment(comment); } cell.setCellValue(meetingAssignmentList.stream().map(stringFunction).collect(joining("\n"))); currentRow.setHeightInPoints(Math.max(currentRow.getHeightInPoints(), meetingAssignmentList.size() * currentSheet.getDefaultRowHeightInPoints())); }
.map(indictmentMap::get) .filter(Objects::nonNull) .flatMap(indictment -> indictment.getConstraintMatchSet().stream()) commentString.append("\n").append(indictment.getScore().toShortString()) .append(" total"); Set<ConstraintMatch> constraintMatchSet = indictment.getConstraintMatchSet().stream() .filter(constraintMatch -> filteredConstraintNameList == null || filteredConstraintNameList.contains(constraintMatch.getConstraintName()))
public List<RotationViolationPenalty> getRotationViolationPenaltyList(Indictment indictment) { if (indictment == null) { return Collections.emptyList(); } return indictment.getConstraintMatchSet().stream() .filter(cm -> cm.getConstraintPackage().equals(CONSTRAINT_MATCH_PACKAGE) && cm.getConstraintName().equals("Employee is not rotation employee")) .map(cm -> new RotationViolationPenalty((Shift) cm.getJustificationList().get(0), (HardMediumSoftLongScore) cm.getScore())) .collect(Collectors.toList()); }
public List<RequiredSkillViolation> getRequiredSkillViolationList(Indictment indictment) { if (indictment == null) { return Collections.emptyList(); } return indictment.getConstraintMatchSet().stream() .filter(cm -> cm.getConstraintPackage().equals(CONSTRAINT_MATCH_PACKAGE) && cm.getConstraintName().equals("Required skill for a shift")) .map(cm -> new RequiredSkillViolation((Shift) cm.getJustificationList().get(0), (HardMediumSoftLongScore) cm.getScore())) .collect(Collectors.toList()); }
public List<UnassignedShiftPenalty> getUnassignedShiftPenaltyList(Indictment indictment) { if (indictment == null) { return Collections.emptyList(); } return indictment.getConstraintMatchSet().stream() .filter(cm -> cm.getConstraintPackage().equals(CONSTRAINT_MATCH_PACKAGE) && cm.getConstraintName().equals("Assign every shift")) .map(cm -> new UnassignedShiftPenalty((Shift) cm.getJustificationList().get(0), (HardMediumSoftLongScore) cm.getScore())) .collect(Collectors.toList()); } }
public List<UnavailableEmployeeViolation> getUnavailableEmployeeViolationList(Indictment indictment) { if (indictment == null) { return Collections.emptyList(); } return indictment.getConstraintMatchSet().stream() .filter(cm -> cm.getConstraintPackage().equals(CONSTRAINT_MATCH_PACKAGE) && cm.getConstraintName().equals("Unavailable time slot for an employee")) .map(cm -> new UnavailableEmployeeViolation((Shift) cm.getJustificationList().get(0), (EmployeeAvailability) cm.getJustificationList().get(1), (HardMediumSoftLongScore) cm.getScore())) .collect(Collectors.toList()); }
public List<DesiredTimeslotForEmployeeReward> getDesiredTimeslotForEmployeeRewardList(Indictment indictment) { if (indictment == null) { return Collections.emptyList(); } return indictment.getConstraintMatchSet().stream() .filter(cm -> cm.getConstraintPackage().equals(CONSTRAINT_MATCH_PACKAGE) && cm.getConstraintName().equals("Desired time slot for an employee")) .map(cm -> new DesiredTimeslotForEmployeeReward((Shift) cm.getJustificationList().get(0), (EmployeeAvailability) cm.getJustificationList().get(1), (HardMediumSoftLongScore) cm.getScore())) .collect(Collectors.toList()); }
public List<UndesiredTimeslotForEmployeePenalty> getUndesiredTimeslotForEmployeePenaltyList(Indictment indictment) { if (indictment == null) { return Collections.emptyList(); } return indictment.getConstraintMatchSet().stream() .filter(cm -> cm.getConstraintPackage().equals(CONSTRAINT_MATCH_PACKAGE) && cm.getConstraintName().equals("Undesired time slot for an employee")) .map(cm -> new UndesiredTimeslotForEmployeePenalty((Shift) cm.getJustificationList().get(0), (EmployeeAvailability) cm.getJustificationList().get(1), (HardMediumSoftLongScore) cm.getScore())) .collect(Collectors.toList()); }
public String determinePlanningEntityTooltip(Object planningEntity) { Indictment indictment = solutionBusiness.getIndictmentMap().get(planningEntity); if (indictment == null) { return "<html>No indictment</html>"; } StringBuilder s = new StringBuilder("<html>Indictment: ").append(indictment.getScore().toShortString()); for (ConstraintMatch constraintMatch : indictment.getConstraintMatchSet()) { s.append("<br/> ").append(constraintMatch.getConstraintName()) .append(" = ").append(constraintMatch.getScore().toShortString()); } s.append("</html>"); return s.toString(); }
public List<ShiftEmployeeConflict> getShiftEmployeeConflictList(Indictment indictment) { if (indictment == null) { return Collections.emptyList(); } return indictment.getConstraintMatchSet().stream() .filter(cm -> cm.getConstraintPackage().equals(CONSTRAINT_MATCH_PACKAGE) && cm.getConstraintName().equals("At most one shift assignment per day per employee") || cm.getConstraintName().equals( "No 2 shifts within 10 hours from each other")) .map(cm -> new ShiftEmployeeConflict((Shift) cm.getJustificationList().get(0), (Shift) cm.getJustificationList().get(1), (HardMediumSoftLongScore) cm.getScore())) .collect(Collectors.toList()); }
commentString.append("\n").append(indictment.getScore().toShortString()) .append(" total"); Set<ConstraintMatch> constraintMatchSet = indictment.getConstraintMatchSet(); List<String> constraintNameList = constraintMatchSet.stream() .map(ConstraintMatch::getConstraintName).distinct().collect(toList());
.map(indictmentMap::get) .filter(Objects::nonNull) .flatMap(indictment -> indictment.getConstraintMatchSet().stream()) commentString.append("\n").append(indictment.getScore().toShortString()) .append(" total"); Set<ConstraintMatch> constraintMatchSet = indictment.getConstraintMatchSet().stream() .filter(constraintMatch -> filteredConstraintNameList == null || filteredConstraintNameList.contains(constraintMatch.getConstraintName()))
void nextMeetingAssignmentListCell(List<MeetingAssignment> meetingAssignmentList, Function<MeetingAssignment, String> stringFunction, List<String> filteredConstraintNames) { if (meetingAssignmentList == null) { meetingAssignmentList = Collections.emptyList(); } HardMediumSoftScore score = meetingAssignmentList.stream() .map(indictmentMap::get).filter(Objects::nonNull) .flatMap(indictment -> indictment.getConstraintMatchSet().stream()) // Filter out filtered constraints .filter(constraintMatch -> filteredConstraintNames == null || filteredConstraintNames.contains(constraintMatch.getConstraintName())) .map(constraintMatch -> (HardMediumSoftScore) constraintMatch.getScore()) // Filter out positive constraints .filter(indictmentScore -> !(indictmentScore.getHardScore() >= 0 && indictmentScore.getSoftScore() >= 0)) .reduce(Score::add).orElse(HardMediumSoftScore.ZERO); XSSFCell cell = getXSSFCellOfScore(score); if (!meetingAssignmentList.isEmpty()) { ClientAnchor anchor = creationHelper.createClientAnchor(); anchor.setCol1(cell.getColumnIndex()); anchor.setCol2(cell.getColumnIndex() + 4); anchor.setRow1(currentRow.getRowNum()); anchor.setRow2(currentRow.getRowNum() + 4); Comment comment = currentDrawing.createCellComment(anchor); String commentString = getMeetingAssignmentListString(meetingAssignmentList); comment.setString(creationHelper.createRichTextString(commentString)); cell.setCellComment(comment); } cell.setCellValue(meetingAssignmentList.stream().map(stringFunction).collect(joining("\n"))); currentRow.setHeightInPoints(Math.max(currentRow.getHeightInPoints(), meetingAssignmentList.size() * currentSheet.getDefaultRowHeightInPoints())); }