List of usage examples for org.apache.commons.collections Predicate Predicate
Predicate
From source file:net.sourceforge.fenixedu.presentationTier.TagLib.sop.examsMapNew.ExamsMapRenderer.java
private void renderExecutionCourseListForYear(StringBuilder strBuffer, Integer curricularYear, PageContext pageContext) {//w w w . j a va 2 s. c o m if (!examsMap.hasExecutionCoursesForGivenCurricularYear(curricularYear)) { strBuffer.append("<i>") .append(getMessageResource(pageContext, "no.execution.courses.for.curricular.year")) .append(curricularYear).append("</i>"); } else { if (user.equals("public")) { strBuffer.append("<table class='tab_exams_details' cellspacing='0'>"); strBuffer.append("<tr><th rowspan='2' width='250' class='ordYear'>"); strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.year")); strBuffer.append(" "); strBuffer.append(curricularYear); strBuffer.append("</th>"); strBuffer.append("<th colspan='3' width='250'>"); strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.times")); strBuffer.append(" 1"); strBuffer.append("</th>"); strBuffer.append("<th colspan='3'>"); strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.times")); strBuffer.append(" 2"); strBuffer.append("</th></tr>"); strBuffer.append("<tr><td class='subheader' width='70'>"); strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.day")); strBuffer.append("</td><td class='subheader' width='50'>"); strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.hour")); strBuffer.append("</td><td class='subheader' width='130'>"); strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.room")); strBuffer.append("</td>"); strBuffer.append("<td class='subheader' width='70'>"); strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.day")); strBuffer.append("</td>" + "<td class='subheader' width='50'>"); strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.hour")); strBuffer.append("</td><td class='subheader' width='130'>"); strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.room")); strBuffer.append("</td></tr>"); } else { strBuffer.append("<strong>"); strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.courseOf")); strBuffer.append(curricularYear + "º ano:</strong>"); } Collections.sort(examsMap.getExecutionCourses(), new BeanComparator("sigla")); String rowClass = "notFirstRow"; // used for CSS style for (int i = 0; i < examsMap.getExecutionCourses().size(); i++) { InfoExecutionCourse infoExecutionCourse = (InfoExecutionCourse) examsMap.getExecutionCourses() .get(i); if (user.equals("sop")) { strBuffer.append("<table border='1' cellspacing='0' cellpadding='3' width='95%'>"); strBuffer.append("<tr>"); } if (i == 0) { rowClass = "firstRow"; } if (infoExecutionCourse.getCurricularYear().equals(curricularYear)) { boolean showCreateExamLink = infoExecutionCourse.getAssociatedInfoExams().size() < 2; if (user.equals("sop")) { strBuffer.append("<td colspan='6'>"); } if (user.equals("public")) { strBuffer.append("<tr valign='top'>"); strBuffer.append("<td class='" + rowClass + "'>"); final Site site = infoExecutionCourse.getExecutionCourse().getSite(); strBuffer.append(GenericChecksumRewriter.NO_CHECKSUM_PREFIX); strBuffer.append("<a href=\"") .append(((HttpServletRequest) pageContext.getRequest()).getContextPath()); strBuffer.append(site.getReversePath()); strBuffer.append("\">"); } else if (showCreateExamLink && user.equals("sop")) { strBuffer.append("<a href='" + addPublicPrefix("showExamsManagement.do") + "?method=createByCourse&" + PresentationConstants.EXECUTION_COURSE_OID + "=" + infoExecutionCourse.getExternalId() + "&" + PresentationConstants.EXECUTION_PERIOD_OID + "=" + infoExecutionCourse.getInfoExecutionPeriod().getExternalId() + "&" + PresentationConstants.EXECUTION_DEGREE_OID + "=" + examsMap.getInfoExecutionDegree().getExternalId() + "&" + PresentationConstants.CURRICULAR_YEAR_OID + "=" + curricularYear.toString() + "'>"); } strBuffer.append(infoExecutionCourse.getSigla()); strBuffer.append(" - "); strBuffer.append(infoExecutionCourse.getNome()); if (user.equals("public")) { strBuffer.append("</a>"); strBuffer.append("</td>"); } boolean hasComment = infoExecutionCourse.getComment() != null && infoExecutionCourse.getComment().length() > 0 && !infoExecutionCourse.getComment().equals(" "); if (hasComment) { if (user.equals("sop")) { strBuffer.append(" : "); strBuffer.append( "<a href='" + addPublicPrefix("defineComment.do") + "?executionCourseCode="); strBuffer.append(infoExecutionCourse.getSigla()); strBuffer.append("&executionPeriodName=" + infoExecutionCourse.getInfoExecutionPeriod().getName()); strBuffer.append("&executionYear=" + infoExecutionCourse.getInfoExecutionPeriod() .getInfoExecutionYear().getYear()); strBuffer.append("&comment=" + infoExecutionCourse.getComment()); strBuffer.append("&method=prepare"); strBuffer.append("&indexExecutionCourse=" + i); strBuffer.append("&" + PresentationConstants.EXECUTION_PERIOD_OID + "=" + infoExecutionCourse.getInfoExecutionPeriod().getExternalId() + "&" + PresentationConstants.EXECUTION_DEGREE_OID + "=" + examsMap.getInfoExecutionDegree().getExternalId() + getCurricularYearsArgs()); strBuffer.append("'>"); } else if (user.equals("public")) { strBuffer.append("<td colspan='6' class='" + rowClass + "'><i>"); } strBuffer.append(infoExecutionCourse.getComment()); if (user.equals("sop")) { strBuffer.append("</a>"); } else if (user.equals("public")) { strBuffer.append("</i></td>"); } } else { if (user.equals("sop")) { strBuffer.append(" : "); strBuffer.append( "<a href='" + addPublicPrefix("defineComment.do") + "?executionCourseCode="); strBuffer.append(infoExecutionCourse.getSigla()); strBuffer.append("&executionPeriodName=" + infoExecutionCourse.getInfoExecutionPeriod().getName()); strBuffer.append("&executionYear=" + infoExecutionCourse.getInfoExecutionPeriod() .getInfoExecutionYear().getYear()); strBuffer.append("&method=prepare"); strBuffer.append("&indexExecutionCourse=" + i); strBuffer.append("&" + PresentationConstants.EXECUTION_PERIOD_OID + "=" + infoExecutionCourse.getInfoExecutionPeriod().getExternalId() + "&" + PresentationConstants.EXECUTION_DEGREE_OID + "=" + examsMap.getInfoExecutionDegree().getExternalId() + getCurricularYearsArgs()); strBuffer.append("'>"); strBuffer.append("Definir comentário"); strBuffer.append("</a>"); } } if (user.equals("sop")) { strBuffer.append("</td>"); strBuffer.append("</tr>"); } if (infoExecutionCourse.getAssociatedInfoExams().isEmpty() && !hasComment) { strBuffer.append("<td colspan='6' align='center' class='" + rowClass + "'>"); strBuffer.append("<i>") .append(getMessageResource(pageContext, "no.exams.for.curricular.year")) .append("</i>"); strBuffer.append("</td>"); } else { // Get 1st season exam InfoExam season1Exam = (InfoExam) CollectionUtils .find(infoExecutionCourse.getAssociatedInfoExams(), new Predicate() { @Override public boolean evaluate(Object obj) { InfoExam infoExam = (InfoExam) obj; return infoExam.getSeason().equals(new Season(Season.SEASON1)); } }); // Get 2nd season exam InfoExam season2Exam = (InfoExam) CollectionUtils .find(infoExecutionCourse.getAssociatedInfoExams(), new Predicate() { @Override public boolean evaluate(Object obj) { InfoExam infoExam = (InfoExam) obj; return infoExam.getSeason().equals(new Season(Season.SEASON2)); } }); if (user.equals("public")) { if (season1Exam == null && !hasComment) { strBuffer.append("<td colspan='3' class='" + rowClass + "'> </td>"); } if (season2Exam == null && !hasComment) { strBuffer.append("<td colspan='3' class='" + rowClass + "'> </td>"); } } if ((season1Exam != null) // && season1Exam.getAssociatedRooms() != null // && season1Exam.getAssociatedRooms().size() > // 0) || (season2Exam != null)) // && season2Exam.getAssociatedRooms() != null // && season2Exam.getAssociatedRooms().size() > 0)) { if (season1Exam != null) { if (user.equals("sop")) { strBuffer.append("<tr>"); strBuffer.append("<td>"); strBuffer.append("<a href='" + addPublicPrefix("showExamsManagement.do") + "?method=edit&" + PresentationConstants.EXECUTION_COURSE_OID + "=" + infoExecutionCourse.getExternalId() + "&" + PresentationConstants.EXECUTION_PERIOD_OID + "=" + infoExecutionCourse.getInfoExecutionPeriod().getExternalId() + "&" + PresentationConstants.EXECUTION_DEGREE_OID + "=" + examsMap.getInfoExecutionDegree().getExternalId() + "&" + PresentationConstants.CURRICULAR_YEAR_OID + "=" + curricularYear.toString() + "&" + PresentationConstants.EXAM_OID + "=" + season1Exam.getExternalId() + "'>"); } if (user.equals("sop")) { strBuffer.append("1ª Época"); strBuffer.append("</a>"); strBuffer.append("</td>"); strBuffer.append("<td>"); strBuffer.append(season1Exam.getDate()); strBuffer.append("<br/>"); strBuffer.append(season1Exam.getBeginningHour()); strBuffer.append("-"); strBuffer.append(season1Exam.getEndHour()); } else if (user.equals("public")) { strBuffer.append("<td class='" + rowClass + "'>"); strBuffer.append(season1Exam.getDate()); strBuffer.append("</td>"); strBuffer.append("<td class='" + rowClass + "'>"); strBuffer.append(season1Exam.getBeginningHour()); strBuffer.append("</td>"); // strBuffer.append("-"); // strBuffer.append(season1Exam.getEndHour()) // ; } if (user.equals("sop")) { strBuffer.append("</td>"); strBuffer.append("<td>"); // Integer numAlunos = // infoExecutionCourse. // getNumberOfAttendingStudents(); Integer numAlunos = season1Exam.getEnrolledStudents(); strBuffer.append(numAlunos); strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.enrolledPupils")); strBuffer.append("</td>"); strBuffer.append("<td>"); strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.lack")); // Obter o num de lugares de exame das salas List roomOccupation = season1Exam.getWrittenEvaluationSpaceOccupations(); int numLugaresSalas = 0; for (int iterRO = 0; iterRO < roomOccupation.size(); iterRO++) { InfoRoomOccupation infoRO = (InfoRoomOccupation) roomOccupation.get(iterRO); numLugaresSalas += infoRO.getInfoRoom().getCapacidadeExame().intValue(); } int numLugaresAPreencher = numAlunos.intValue() - numLugaresSalas; // if (numLugaresAPreencher < 0) // numLugaresAPreencher = 0; strBuffer.append(numLugaresAPreencher); strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.places")); strBuffer.append("</td>"); strBuffer.append("<td>"); } List infoRoomOccupations = season1Exam.getWrittenEvaluationSpaceOccupations(); if (infoRoomOccupations != null && infoRoomOccupations.size() > 0) { if (user.equals("sop")) { strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.rooms")); strBuffer.append("<br/>"); } else if (user.equals("public")) { strBuffer.append("<td class='" + rowClass + "'>"); } for (int iterIRO = 0; iterIRO < infoRoomOccupations.size(); iterIRO++) { InfoRoomOccupation infoRoomOccupation = (InfoRoomOccupation) infoRoomOccupations .get(iterIRO); strBuffer.append(infoRoomOccupation.getInfoRoom().getNome() + "; "); } } else { if (user.equals("sop")) { strBuffer.append("-"); } else if (user.equals("public")) { strBuffer.append("<td class='" + rowClass + "'>"); strBuffer.append("<i>"); strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.noRoomsAttributed")); strBuffer.append("</i>"); } } if (user.equals("sop")) { strBuffer.append("</td>"); strBuffer.append("<td>"); strBuffer.append("<a href='" + addPublicPrefix("showExamsManagement.do") + "?method=delete&" + PresentationConstants.EXECUTION_COURSE_OID + "=" + infoExecutionCourse.getExternalId() + "&" + PresentationConstants.EXECUTION_PERIOD_OID + "=" + infoExecutionCourse.getInfoExecutionPeriod().getExternalId() + "&" + PresentationConstants.EXECUTION_DEGREE_OID + "=" + examsMap.getInfoExecutionDegree().getExternalId() + "&" + PresentationConstants.CURRICULAR_YEAR_OID + "=" + curricularYear.toString() + "&" + PresentationConstants.EXAM_OID + "=" + season1Exam.getExternalId() + "'>"); strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.delete")); strBuffer.append("</a>"); strBuffer.append("</td>"); } } if (season2Exam != null) { if (user.equals("sop")) { strBuffer.append("<tr>"); strBuffer.append("<td>"); strBuffer.append("<a href='" + addPublicPrefix("showExamsManagement.do") + "?method=edit&" + PresentationConstants.EXECUTION_COURSE_OID + "=" + infoExecutionCourse.getExternalId() + "&" + PresentationConstants.EXECUTION_PERIOD_OID + "=" + infoExecutionCourse.getInfoExecutionPeriod().getExternalId() + "&" + PresentationConstants.EXECUTION_DEGREE_OID + "=" + examsMap.getInfoExecutionDegree().getExternalId() + "&" + PresentationConstants.CURRICULAR_YEAR_OID + "=" + curricularYear.toString() + "&" + PresentationConstants.EXAM_OID + "=" + season2Exam.getExternalId() + "'>"); } if (user.equals("sop")) { strBuffer.append("2ª "); strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.times")); strBuffer.append("</a>"); strBuffer.append("</td>"); strBuffer.append("<td>"); strBuffer.append(season2Exam.getDate()); strBuffer.append("<br/>"); strBuffer.append(season2Exam.getBeginningHour()); strBuffer.append("-"); strBuffer.append(season2Exam.getEndHour()); } else if (user.equals("public")) { strBuffer.append("<td class='" + rowClass + "'>"); strBuffer.append(season2Exam.getDate()); strBuffer.append("</td>"); strBuffer.append("<td class='" + rowClass + "'>"); strBuffer.append(season2Exam.getBeginningHour()); strBuffer.append("</td>"); // strBuffer.append("-"); // strBuffer.append(season2Exam.getEndHour()) // ; } if (user.equals("sop")) { strBuffer.append("</td>"); strBuffer.append("<td>"); // Integer numAlunos = // infoExecutionCourse. // getNumberOfAttendingStudents(); Integer numAlunos = season2Exam.getEnrolledStudents(); strBuffer.append(numAlunos); strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.enrolledPupils")); strBuffer.append("</td>"); strBuffer.append("<td>"); strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.lack")); // Obter o num de lugares de exame das salas List roomOccupation = season2Exam.getWrittenEvaluationSpaceOccupations(); int numLugaresSalas = 0; for (int iterRO = 0; iterRO < roomOccupation.size(); iterRO++) { InfoRoomOccupation infoRO = (InfoRoomOccupation) roomOccupation.get(iterRO); numLugaresSalas += infoRO.getInfoRoom().getCapacidadeExame().intValue(); } int numLugaresAPreencher = numAlunos.intValue() - numLugaresSalas; // if (numLugaresAPreencher < 0) // numLugaresAPreencher = 0; strBuffer.append(numLugaresAPreencher); strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.places")); strBuffer.append("</td>"); strBuffer.append("<td>"); } List infoRoomOccupations = season2Exam.getWrittenEvaluationSpaceOccupations(); if (infoRoomOccupations != null && infoRoomOccupations.size() > 0) { if (user.equals("sop")) { strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.rooms") + ":"); strBuffer.append("<br/>"); } else if (user.equals("public")) { strBuffer.append("<td class='" + rowClass + "'>"); } for (int iterIRO = 0; iterIRO < infoRoomOccupations.size(); iterIRO++) { InfoRoomOccupation infoRoomOccupation = (InfoRoomOccupation) infoRoomOccupations .get(iterIRO); strBuffer.append(infoRoomOccupation.getInfoRoom().getNome() + "; "); } if (user.equals("public")) { strBuffer.append("</td>"); } } else { if (user.equals("sop")) { strBuffer.append("-"); } else if (user.equals("public")) { strBuffer.append("<td class='" + rowClass + "'>"); strBuffer.append("<i>"); strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.noRoomsAttributed")); strBuffer.append("</i>"); strBuffer.append("</td>"); } } if (user.equals("sop")) { strBuffer.append("</td>"); strBuffer.append("<td>"); strBuffer.append("<a href='" + addPublicPrefix("showExamsManagement.do") + "?method=delete&" + PresentationConstants.EXECUTION_COURSE_OID + "=" + infoExecutionCourse.getExternalId() + "&" + PresentationConstants.EXECUTION_PERIOD_OID + "=" + infoExecutionCourse.getInfoExecutionPeriod().getExternalId() + "&" + PresentationConstants.EXECUTION_DEGREE_OID + "=" + examsMap.getInfoExecutionDegree().getExternalId() + "&" + PresentationConstants.CURRICULAR_YEAR_OID + "=" + curricularYear.toString() + "&" + PresentationConstants.EXAM_OID + "=" + season2Exam.getExternalId() + "'>"); strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.delete")); strBuffer.append("</a>"); strBuffer.append("</td>"); } } } } if (user.equals("public")) { strBuffer.append("</tr>"); if (rowClass == "firstRow") { rowClass = "notFirstRow"; } } } if (user.equals("sop")) { strBuffer.append("</tr>"); strBuffer.append("</table>"); strBuffer.append("<br />"); } } if (user.equals("public")) { strBuffer.append("</table>"); } } }
From source file:net.jcreate.xkins.Skin.java
/** * Devuelve una Collection de templates con los que contengan el group dado en el skin. * @param groupName/*from w w w .j a v a 2 s . co m*/ * @return */ public Collection findTemplatesByGroup(final String groupName) { return CollectionUtils.select(this.templates.values(), new Predicate() { public boolean evaluate(Object arg0) { String group = ((Template) arg0).getGroup(); return groupName.equals(group); } }); }
From source file:module.mailtracking.domain.CorrespondenceEntry.java
public java.util.List<Document> getActiveDocuments() { java.util.List<Document> associatedDocuments = new java.util.ArrayList<Document>(); CollectionUtils.select(this.getDocumentsSet(), new Predicate() { @Override//w w w .j a va2s.c o m public boolean evaluate(Object arg0) { return DocumentState.ACTIVE.equals(((Document) arg0).getState()); } }, associatedDocuments); return associatedDocuments; }
From source file:com.architexa.diagrams.relo.parts.ReloController.java
public List<ArtifactEditPart> getVisibleNonDerivedArtifactEditParts() { List<ArtifactEditPart> visAEPs = getVisibleArtifactEditParts(); CollectionUtils.filter(visAEPs, new Predicate() { public boolean evaluate(Object elem) { if (((EditPart) elem).getModel() instanceof DerivedArtifact) { return false; }/*from ww w .j ava 2 s. co m*/ return true; } }); return visAEPs; }
From source file:net.sourceforge.fenixedu.domain.candidacyProcess.mobility.MobilityApplicationProcess.java
public List<MobilityIndividualApplicationProcess> getProcessesWithNotViewedAlerts() { List<MobilityIndividualApplicationProcess> processList = new ArrayList<MobilityIndividualApplicationProcess>(); CollectionUtils.select(getChildProcessesSet(), new Predicate() { @Override/*from www. j a v a 2s. com*/ public boolean evaluate(Object arg0) { MobilityIndividualApplicationProcess process = (MobilityIndividualApplicationProcess) arg0; return process.isProcessWithMostRecentAlertMessageNotViewed(); } }, processList); return processList; }
From source file:flex2.compiler.mxml.rep.Model.java
/** * */// w ww . ja v a 2 s. c om @SuppressWarnings("unchecked") protected Iterator<Initializer> bindingFilter(Iterator<? extends Initializer> iter, final boolean include) { return new FilterIterator(iter, new Predicate() { public boolean evaluate(Object object) { return (((Initializer) object).isBinding()) == include; } }); }
From source file:net.sourceforge.fenixedu.domain.candidacyProcess.mobility.MobilityApplicationProcess.java
public List<ErasmusCandidacyProcessReport> getDoneReports() { List<ErasmusCandidacyProcessReport> jobList = new ArrayList<ErasmusCandidacyProcessReport>(); CollectionUtils.select(getErasmusCandidacyProcessReportsSet(), new Predicate() { @Override//from w w w.j a va 2 s.com public boolean evaluate(Object arg0) { return ((QueueJob) arg0).getDone(); } }, jobList); return jobList; }
From source file:net.sourceforge.fenixedu.domain.student.importation.DgesStudentImportationProcess.java
public static List<DgesStudentImportationProcess> readAllJobs(final ExecutionYear executionYear) { List<DgesStudentImportationProcess> jobList = new ArrayList<DgesStudentImportationProcess>(); CollectionUtils.select(executionYear.getDgesBaseProcessSet(), new Predicate() { @Override/* w w w. ja va2 s . c o m*/ public boolean evaluate(Object arg0) { return (arg0 instanceof DgesStudentImportationProcess); } }, jobList); return jobList; }
From source file:com.perceptive.epm.perkolcentral.action.ajax.EmployeeDetailsAction.java
public String executeGetAllEmployeesAtOnce() throws ExceptionWrapper { try {/*from www. j a va 2 s .c om*/ LinkedHashMap<Long, EmployeeBO> employeeLinkedHashMap = new LinkedHashMap<Long, EmployeeBO>(); employeeLinkedHashMap = employeeBL.getAllEmployees(); gridModel = new ArrayList<EmployeeBO>(employeeLinkedHashMap.values()); CollectionUtils.filter(gridModel, new Predicate() { @Override public boolean evaluate(Object o) { return StringUtils.contains(((EmployeeBO) o).getEmployeeName().toLowerCase(), term.toLowerCase()); } }); } catch (Exception ex) { throw new ExceptionWrapper(ex); } return SUCCESS; }
From source file:com.kcs.service.impl.GenerateXml2ServiceImpl.java
private List<Datasetipi> filterChildIpi(final Datasetipi main, List<Datasetipi> childList) { List<Datasetipi> result = new ArrayList<Datasetipi>(); final Predicate predicate = new Predicate() { @Override/*from w w w . j av a 2 s . co m*/ public boolean evaluate(Object o) { if (Utility.isNotNull(o)) { Datasetipi child = (Datasetipi) o; boolean result = (objEquals(main.getCustCode(), child.getCustCode())); return result; } return false; } }; result = (List<Datasetipi>) CollectionUtils.select(childList, predicate); return result; }