List of usage examples for org.apache.commons.collections4 CollectionUtils isNotEmpty
public static boolean isNotEmpty(final Collection<?> coll)
From source file:org.kuali.coeus.common.committee.impl.lookup.CommitteeLookupableHelperServiceImplBase.java
protected List<CMT> getUniqueList(List<CMT> committees) { final List<CMT> uniqueResults = new ArrayList<>(); final List<String> committeeIds = new ArrayList<>(); if (CollectionUtils.isNotEmpty(committees)) { Collections.sort(committees, Collections.reverseOrder()); committees.stream().filter(committee -> !committeeIds.contains(committee.getCommitteeId())) .forEach(committee -> { committee.getCommitteeChair(); uniqueResults.add(committee); committeeIds.add(committee.getCommitteeId()); });/*from w w w .jav a 2 s. c om*/ } return uniqueResults; }
From source file:org.kuali.coeus.common.committee.impl.lookup.keyvalue.CommitteeIdByUnitValuesFinderBase.java
public void initializeKeyValueList() { // get the initial list of all valid committees; some of them will be filtered out by the logic below Collection<CMT> candidateCommittees = getCandidateCommittees(); if (CollectionUtils.isNotEmpty(candidateCommittees)) { if (isSaved()) { //Use the lead unit of the protocol to determine committees getProtocolUnitIds();/*from www. j ava2 s . co m*/ for (CMT committee : candidateCommittees) { if (StringUtils.equalsIgnoreCase(committee.getCommitteeDocument().getDocStatusCode(), "F") && unitIds.contains(committee.getHomeUnit().getUnitNumber())) { keyValues.add( new ConcreteKeyValue(committee.getCommitteeId(), committee.getCommitteeName())); } } } else { // we check the current user's authorization to assign committees String principalId = GlobalVariables.getUserSession().getPerson().getPrincipalId(); for (CMT candidateCommittee : candidateCommittees) { if (isCurrentUserAuthorizedToAssignThisCommittee(principalId, candidateCommittee) || candidateCommittee.getCommitteeId().equals(getCurrentCommitteeId())) { keyValues.add(new ConcreteKeyValue(candidateCommittee.getCommitteeId(), candidateCommittee.getCommitteeName())); } } } Collections.sort(keyValues, new KeyValueComparator()); } // set the init flag this.initialized = true; }
From source file:org.kuali.coeus.common.committee.impl.lookup.keyvalue.CommitteeIdByUnitValuesFinderServiceImplBase.java
@Override public Collection<CMT> getAssignmentCommittees(String protocolLeadUnit, String docRouteStatus, String currentCommitteeId) { Collection<CMT> assignmentCommittees = new ArrayList<CMT>(); // get the initial list of all valid committees; some of them will be filtered out by the logic below Collection<CMT> candidateCommittees = getCandidateCommittees(); if (CollectionUtils.isNotEmpty(candidateCommittees)) { if (isSaved(docRouteStatus)) { //Use the lead unit of the protocol to determine committees Set<String> unitIds = getProtocolUnitIds(protocolLeadUnit); for (CMT committee : candidateCommittees) { if (StringUtils.equalsIgnoreCase(committee.getCommitteeDocument().getDocStatusCode(), "F") && unitIds.contains(committee.getHomeUnit().getUnitNumber())) { assignmentCommittees.add(committee); }//from w w w. ja va 2 s . co m } } else { // we check the current user's authorization to assign committees String principalId = GlobalVariables.getUserSession().getPerson().getPrincipalId(); for (CMT committee : candidateCommittees) { if (isCurrentUserAuthorizedToAssignThisCommittee(principalId, committee) || committee.getCommitteeId().equals(currentCommitteeId)) { assignmentCommittees.add(committee); } } } } return assignmentCommittees; }
From source file:org.kuali.coeus.common.committee.impl.lookup.keyvalue.CommitteeIdValuesFinderBase.java
/** * This method will return the list of all highest-sequence number committee instances. * Will always return non-null (but possibly empty) collection. */// www . jav a2 s . co m public List<CommitteeBase> getActiveCommittees() { Map<String, String> criteria = new HashMap<String, String>(); criteria.put(COMMITTEE_TYPE_CODE, getCommitteeTypeCodeHook()); ArrayList<CommitteeBase> returnCommitteeList = new ArrayList<CommitteeBase>(); Collection<? extends CommitteeBase> committees = this.getBusinessObjectService() .findMatching(getCommitteeBOClassHook(), criteria); // sort and iterate through to get only the latest instances if (CollectionUtils.isNotEmpty(committees)) { List<String> committeeIds = new ArrayList<String>(); // only the active ones Collections.sort((List<CommitteeBase>) committees, Collections.reverseOrder()); for (CommitteeBase committee : committees) { if (!committeeIds.contains(committee.getCommitteeId())) { returnCommitteeList.add(committee); committeeIds.add(committee.getCommitteeId()); } } } return returnCommitteeList; }
From source file:org.kuali.coeus.common.committee.impl.lookup.keyvalue.CommitteeIdValuesFinderBase.java
/** * @return the list of <key, value> pairs of committees. The first entry is always <"", "select:">. *//*from w ww . j a va 2 s . c om*/ @Override public List<KeyValue> getKeyValues() { List<KeyValue> keyValues = new ArrayList<KeyValue>(); // only the active ones Collection<CommitteeBase> committees = this.getActiveCommittees(); if (CollectionUtils.isNotEmpty(committees)) { // get the exclusion list List<String> excludedCommitteeIds = getExcludedCommitteeIds(); for (CommitteeBase committee : committees) { if (!excludedCommitteeIds.contains(committee.getCommitteeId())) { keyValues.add(new ConcreteKeyValue(committee.getCommitteeId(), committee.getCommitteeName())); } } sort(keyValues, new KeyValueComparator()); } keyValues.add(0, new ConcreteKeyValue("", "select")); return keyValues; }
From source file:org.kuali.coeus.common.committee.impl.lookup.keyvalue.CommitteeIdValuesFinderBase.java
private List<String> getExcludedCommitteeIds() { List<String> committeeIds = new ArrayList<String>(); if (CollectionUtils.isNotEmpty(correspondenceTemplates)) { for (ProtocolCorrespondenceTemplateBase correspondenceTemplate : correspondenceTemplates) { committeeIds.add(correspondenceTemplate.getCommitteeId()); }// ww w. j a v a2 s . c om } return committeeIds; }
From source file:org.kuali.coeus.common.committee.impl.rules.CommitteeDocumentRuleBase.java
/** * This method will check if all the research areas that have been added to a committee member as 'area of expertise' are indeed active. * It is declared public because it will be invoked from the action class for committee members as well. * @param document// www .j a v a 2 s. c om * @return */ public boolean checkResearchAreasForCommitteeMember(CommitteeMembershipBase committeeMember, int membershipIndex) { boolean inactiveFound = false; StringBuffer inactiveResearchAreaIndices = new StringBuffer(); List<CommitteeMembershipExpertiseBase> cmes = committeeMember.getMembershipExpertise(); // iterate over all the research areas for this committee member looking for inactive research areas if (CollectionUtils.isNotEmpty(cmes)) { int raIndex = 0; for (CommitteeMembershipExpertiseBase cme : cmes) { if (cme.getResearchArea() != null && !(cme.getResearchArea().isActive())) { inactiveFound = true; inactiveResearchAreaIndices.append(raIndex).append(SEPERATOR); } raIndex++; } } // if we found any inactive research areas in the above loop, report as a single error key suffixed by the list of indices of the inactive areas if (inactiveFound) { String committeeMemberInactiveAreasOfExpertiseErrorPropertyKey = String .format(PROPERTY_NAME_INACTIVE_AREAS_OF_EXPERTISE_PREFIX, membershipIndex) + SEPERATOR + inactiveResearchAreaIndices.toString(); reportError(committeeMemberInactiveAreasOfExpertiseErrorPropertyKey, KeyConstants.ERROR_COMMITTEE_MEMBERSHIP_EXPERTISE_INACTIVE); } return !inactiveFound; }
From source file:org.kuali.coeus.common.committee.impl.rules.CommitteeDocumentRuleBase.java
/** * This method will check if all the research areas that have been added to the committee are indeed active. * It is declared public because it will be invoked from the action class for committee as well. * @param document//from w w w . j av a2 s . com * @return */ public boolean validateCommitteeResearchAreas(CommitteeBase committee) { boolean inactiveFound = false; StringBuffer inactiveResearchAreaIndices = new StringBuffer(); // iterate over all the research areas for the committee BO looking for inactive research areas List<CommitteeResearchAreaBase> cras = committee.getCommitteeResearchAreas(); if (CollectionUtils.isNotEmpty(cras)) { int raIndex = 0; for (CommitteeResearchAreaBase cra : cras) { if (!(cra.getResearchAreas().isActive())) { inactiveFound = true; inactiveResearchAreaIndices.append(raIndex).append(SEPERATOR); } raIndex++; } } // if we found any inactive research areas in the above loop, report as a single error key suffixed by the list of indices of the inactive areas if (inactiveFound) { String committeeResearchAreaInactiveErrorPropertyKey = INACTIVE_RESEARCH_AREAS_PREFIX + SEPERATOR + inactiveResearchAreaIndices.toString(); KcServiceLocator.getService(ErrorReporter.class).reportError( committeeResearchAreaInactiveErrorPropertyKey, KeyConstants.ERROR_COMMITTEE_RESEARCH_AREA_INACTIVE); } return !inactiveFound; }
From source file:org.kuali.coeus.common.committee.impl.service.impl.CommitteeScheduleServiceImplBase.java
@Override public void addSchedule(ScheduleData scheduleData, CMT committee) throws ParseException { List<Date> dates = null; Date dtEnd = null;/*from w w w. j a v a 2s .co m*/ int frequency = 0; int day = 0; CronSpecialChars[] weekdays = null; CronSpecialChars weekOfMonth = null; CronSpecialChars dayOfWeek = null; CronSpecialChars month = null; Time24HrFmt time = getTime24hFmt(scheduleData.getScheduleStartDate(), scheduleData.getTime().findMinutes()); Date dt = scheduleData.getScheduleStartDate(); StyleKey key = StyleKey.valueOf(scheduleData.getRecurrenceType()); switch (key) { case NEVER: dates = scheduleService.getScheduledDates(dt, dt, time, null); break; case DAILY: DailyScheduleDetails.optionValues dailyoption = DailyScheduleDetails.optionValues .valueOf(scheduleData.getDailySchedule().getDayOption()); switch (dailyoption) { case XDAY: dtEnd = scheduleData.getDailySchedule().getScheduleEndDate(); day = scheduleData.getDailySchedule().getDay(); dates = scheduleService.getIntervalInDaysScheduledDates(dt, dtEnd, time, day); break; case WEEKDAY: dtEnd = scheduleData.getDailySchedule().getScheduleEndDate(); weekdays = ScheduleData.convertToWeekdays(scheduleData.getDailySchedule().getDaysOfWeek()); ScheduleSequence scheduleSequence = new WeekScheduleSequenceDecorator( new TrimDatesScheduleSequenceDecorator(new DefaultScheduleSequence()), 1, weekdays.length); dates = scheduleService.getScheduledDates(dt, dtEnd, time, weekdays, scheduleSequence); break; } break; case WEEKLY: dtEnd = scheduleData.getWeeklySchedule().getScheduleEndDate(); if (CollectionUtils.isNotEmpty(scheduleData.getWeeklySchedule().getDaysOfWeek())) { weekdays = ScheduleData.convertToWeekdays(scheduleData.getWeeklySchedule().getDaysOfWeek() .toArray(new String[scheduleData.getWeeklySchedule().getDaysOfWeek().size()])); } ScheduleSequence scheduleSequence = new WeekScheduleSequenceDecorator( new TrimDatesScheduleSequenceDecorator(new DefaultScheduleSequence()), scheduleData.getWeeklySchedule().getWeek(), weekdays.length); dates = scheduleService.getScheduledDates(dt, dtEnd, time, weekdays, scheduleSequence); break; case MONTHLY: MonthlyScheduleDetails.optionValues monthOption = MonthlyScheduleDetails.optionValues .valueOf(scheduleData.getMonthlySchedule().getMonthOption()); switch (monthOption) { case XDAYANDXMONTH: dtEnd = scheduleData.getMonthlySchedule().getScheduleEndDate(); day = scheduleData.getMonthlySchedule().getDay(); frequency = scheduleData.getMonthlySchedule().getOption1Month(); dates = scheduleService.getScheduledDates(dt, dtEnd, time, day, frequency, null); break; case XDAYOFWEEKANDXMONTH: dtEnd = scheduleData.getMonthlySchedule().getScheduleEndDate(); weekOfMonth = ScheduleData .getWeekOfMonth(scheduleData.getMonthlySchedule().getSelectedMonthsWeek()); dayOfWeek = ScheduleData.getDayOfWeek(scheduleData.getMonthlySchedule().getSelectedDayOfWeek()); frequency = scheduleData.getMonthlySchedule().getOption2Month(); dates = scheduleService.getScheduledDates(dt, dtEnd, time, dayOfWeek, weekOfMonth, frequency, null); break; } break; case YEARLY: YearlyScheduleDetails.yearOptionValues yearOption = YearlyScheduleDetails.yearOptionValues .valueOf(scheduleData.getYearlySchedule().getYearOption()); switch (yearOption) { case XDAY: dtEnd = scheduleData.getYearlySchedule().getScheduleEndDate(); month = ScheduleData.getMonthOfWeek(scheduleData.getYearlySchedule().getSelectedOption1Month()); day = scheduleData.getYearlySchedule().getDay(); frequency = scheduleData.getYearlySchedule().getOption1Year(); dates = scheduleService.getScheduledDates(dt, dtEnd, time, month, day, frequency, null); break; case CMPLX: dtEnd = scheduleData.getYearlySchedule().getScheduleEndDate(); weekOfMonth = ScheduleData.getWeekOfMonth(scheduleData.getYearlySchedule().getSelectedMonthsWeek()); dayOfWeek = ScheduleData.getDayOfWeek(scheduleData.getYearlySchedule().getSelectedDayOfWeek()); month = ScheduleData.getMonthOfWeek(scheduleData.getYearlySchedule().getSelectedOption2Month()); frequency = scheduleData.getYearlySchedule().getOption2Year(); dates = scheduleService.getScheduledDates(dt, dtEnd, time, weekOfMonth, dayOfWeek, month, frequency, null); break; } break; } List<java.sql.Date> skippedDates = new ArrayList<java.sql.Date>(); scheduleData.setDatesInConflict(skippedDates); addScheduleDatesToCommittee(dates, committee, scheduleData.getPlace(), skippedDates); }
From source file:org.kuali.coeus.common.committee.impl.service.impl.CommitteeServiceImplBase.java
@Override public List<CS> mergeCommitteeSchedule(String committeeId) { Map<String, Object> fieldValues = new HashMap<String, Object>(); fieldValues.put(COMMITTEE_ID, committeeId); List<CMT> committees = (List<CMT>) getBusinessObjectService().findMatching(getCommitteeBOClassHook(), fieldValues);/*ww w .ja v a 2s .c om*/ Collections.sort(committees); CMT newCommittee = committees.get(committees.size() - 1); CMT oldCommittee = committees.get(committees.size() - 2); List<CS> newMasterSchedules = new ArrayList<CS>(); List<CS> oldMasterSchedules = oldCommittee.getCommitteeSchedules(); List<CS> newSchedules = newCommittee.getCommitteeSchedules(); // remove the to-be-retained old schedules and new schedules from the old master list and the new master list // respectively, and combine these removed schedules to create the new master list. if (CollectionUtils.isNotEmpty(newSchedules) || CollectionUtils.isNotEmpty(oldMasterSchedules)) { newMasterSchedules = createNewMasterScheduleList(newSchedules, oldMasterSchedules); // delete the remaining old master schedule list and the remaining new schedule list getBusinessObjectService().delete(oldMasterSchedules); getBusinessObjectService().delete(newSchedules); } return newMasterSchedules; }