Example usage for org.apache.commons.collections CollectionUtils find

List of usage examples for org.apache.commons.collections CollectionUtils find

Introduction

In this page you can find the example usage for org.apache.commons.collections CollectionUtils find.

Prototype

public static Object find(Collection collection, Predicate predicate) 

Source Link

Document

Finds the first element in the given collection which matches the given predicate.

Usage

From source file:net.sourceforge.fenixedu.domain.Enrolment.java

final public EnrolmentEvaluation getEnrolmentEvaluationByEnrolmentEvaluationTypeAndGrade(
        final EnrolmentEvaluationType evaluationType, final Grade grade) {

    return (EnrolmentEvaluation) CollectionUtils.find(getEvaluationsSet(), new Predicate() {

        @Override// ww w . j a va  2s  .  c o  m
        final public boolean evaluate(Object o) {
            EnrolmentEvaluation enrolmentEvaluation = (EnrolmentEvaluation) o;
            Grade evaluationGrade = enrolmentEvaluation.getGrade();

            return enrolmentEvaluation.getEnrolmentEvaluationType().equals(evaluationType)
                    && evaluationGrade.equals(grade);
        }

    });
}

From source file:com.lp.server.artikel.ejbfac.WebshopItemServiceEjb.java

@Override
public ShopgroupsResult getShopGroupsFindAllChanged(WebshopAuthHeader header, String changedDateTime) {
    if (HelperWebshop.isEmptyString(changedDateTime)) {
        return new ShopgroupsResult(BaseRequestResult.ERROR_NULL_PARAMETER,
                "changedDate == null (or blank/empty)");
    }/*from  w w w  .j  a  va  2s.  co m*/
    Date d = HelperWebshop.parseDateTimeString(changedDateTime);
    if (null == d) {
        return new ShopgroupsResult(BaseRequestResult.ERROR_NULL_PARAMETER,
                "Date == null (or illegal format [" + changedDateTime + "])");
    }

    Timestamp changedStamp = new Timestamp(normalizeDateTime(d).getTime());

    List<ShopgruppeDto> changedShopgruppen = new ArrayList<ShopgruppeDto>();
    try {
        setupSessionParams(header);

        ShopgroupsResult sgResult = new ShopgroupsResult();
        List<Shopgruppewebshop> cl = ShopgruppewebshopQuery.listByWebshopId(em, getWebshopIId());
        for (Shopgruppewebshop shopgruppewebshop : cl) {
            ShopgruppeDto shopGruppeDto = getArtikelFac()
                    .shopgruppeFindByPrimaryKey(shopgruppewebshop.getShopgruppeIId(), webClientDto);

            // Hat sich die Shopgruppe selbst geaendert
            if (shopGruppeDto.getTAendern().after(changedStamp)) {
                changedShopgruppen.add(shopGruppeDto);
                continue;
            }

            // Oder ein Artikel in dieser Gruppe?
            Collection<Artikel> artikelCl = artikelFindByShopgroupIId(shopGruppeDto.getIId(), changedStamp);
            if (artikelCl.size() > 0) {
                changedShopgruppen.add(shopGruppeDto);
                continue;
            }
        }

        for (ShopgruppeDto shopgruppeDto : changedShopgruppen) {
            ShopgruppeDto rootShopDto = findRootShopgruppeDto(shopgruppeDto);
            if (rootShopDto != null) {

                Object o = CollectionUtils.find(sgResult.getShopgroups(),
                        new ShopgruppeIdPredicate(rootShopDto.getIId()));
                if (o == null) {
                    WebshopShopgroup node = buildWebshopgroup(rootShopDto, changedStamp);
                    sgResult.getShopgroups().add(node);
                }
            }
        }

        sgResult.setOkay();
        return sgResult;
    } catch (RemoteException ex) {
        return new ShopgroupsResult(BaseRequestResult.ERROR_RMI_EXCEPTION, ex.getMessage());
    } catch (EJBExceptionLP ex) {
        return new ShopgroupsResult(BaseRequestResult.ERROR_EJB_EXCEPTION + ex.getCode(), ex.getMessage());
    }
}

From source file:net.sourceforge.fenixedu.domain.candidacyProcess.IndividualCandidacy.java

private void editFormationEntry(List<FormationBean> formationConcludedBeanList,
        List<Formation> formationsToBeRemovedList, final Formation formation) {
    FormationBean bean = (FormationBean) CollectionUtils.find(formationConcludedBeanList, new Predicate() {
        @Override/*  www .  ja  v a  2 s. co  m*/
        public boolean evaluate(Object arg0) {
            FormationBean bean = (FormationBean) arg0;
            return bean.getFormation() == formation;
        }
    });

    if (bean == null) {
        formationsToBeRemovedList.add(formation);
    } else {
        formation.edit(bean);
    }
}

From source file:net.sourceforge.fenixedu.domain.Enrolment.java

final public EnrolmentEvaluation getEnrolmentEvaluationByEnrolmentEvaluationStateAndType(
        final EnrolmentEvaluationState state, final EnrolmentEvaluationType type) {
    return (EnrolmentEvaluation) CollectionUtils.find(getEvaluationsSet(), new Predicate() {

        @Override/*from   w  w  w.java2s  . c o m*/
        final public boolean evaluate(Object o) {
            EnrolmentEvaluation enrolmentEvaluation = (EnrolmentEvaluation) o;
            return (enrolmentEvaluation.getEnrolmentEvaluationState().equals(state)
                    && enrolmentEvaluation.getEnrolmentEvaluationType().equals(type));
        }

    });
}

From source file:net.sourceforge.fenixedu.presentationTier.TagLib.sop.examsMapNew.ExamsMapRenderer.java

private void renderExecutionCourseListForYear(StringBuilder strBuffer, Integer curricularYear,
        PageContext pageContext) {/*from   ww w. j a  v  a2  s  .  co 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 + "&ordm; 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&amp;" + PresentationConstants.EXECUTION_COURSE_OID + "="
                            + infoExecutionCourse.getExternalId() + "&amp;"
                            + PresentationConstants.EXECUTION_PERIOD_OID + "="
                            + infoExecutionCourse.getInfoExecutionPeriod().getExternalId() + "&amp;"
                            + PresentationConstants.EXECUTION_DEGREE_OID + "="
                            + examsMap.getInfoExecutionDegree().getExternalId() + "&amp;"
                            + 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("&amp;executionPeriodName="
                                + infoExecutionCourse.getInfoExecutionPeriod().getName());
                        strBuffer.append("&amp;executionYear=" + infoExecutionCourse.getInfoExecutionPeriod()
                                .getInfoExecutionYear().getYear());
                        strBuffer.append("&amp;comment=" + infoExecutionCourse.getComment());
                        strBuffer.append("&amp;method=prepare");
                        strBuffer.append("&amp;indexExecutionCourse=" + i);
                        strBuffer.append("&amp;" + PresentationConstants.EXECUTION_PERIOD_OID + "="
                                + infoExecutionCourse.getInfoExecutionPeriod().getExternalId() + "&amp;"
                                + 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("&amp;executionPeriodName="
                                + infoExecutionCourse.getInfoExecutionPeriod().getName());
                        strBuffer.append("&amp;executionYear=" + infoExecutionCourse.getInfoExecutionPeriod()
                                .getInfoExecutionYear().getYear());
                        strBuffer.append("&amp;method=prepare");
                        strBuffer.append("&amp;indexExecutionCourse=" + i);
                        strBuffer.append("&amp;" + PresentationConstants.EXECUTION_PERIOD_OID + "="
                                + infoExecutionCourse.getInfoExecutionPeriod().getExternalId() + "&amp;"
                                + PresentationConstants.EXECUTION_DEGREE_OID + "="
                                + examsMap.getInfoExecutionDegree().getExternalId() + getCurricularYearsArgs());
                        strBuffer.append("'>");
                        strBuffer.append("Definir coment&aacute;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 + "'>&nbsp;</td>");
                        }
                        if (season2Exam == null && !hasComment) {
                            strBuffer.append("<td colspan='3' class='" + rowClass + "'>&nbsp;</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&amp;" + PresentationConstants.EXECUTION_COURSE_OID + "="
                                        + infoExecutionCourse.getExternalId() + "&amp;"
                                        + PresentationConstants.EXECUTION_PERIOD_OID + "="
                                        + infoExecutionCourse.getInfoExecutionPeriod().getExternalId() + "&amp;"
                                        + PresentationConstants.EXECUTION_DEGREE_OID + "="
                                        + examsMap.getInfoExecutionDegree().getExternalId() + "&amp;"
                                        + PresentationConstants.CURRICULAR_YEAR_OID + "="
                                        + curricularYear.toString() + "&amp;" + PresentationConstants.EXAM_OID
                                        + "=" + season1Exam.getExternalId() + "'>");
                            }

                            if (user.equals("sop")) {
                                strBuffer.append("1&ordf; &Eacute;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&amp;" + PresentationConstants.EXECUTION_COURSE_OID
                                        + "=" + infoExecutionCourse.getExternalId() + "&amp;"
                                        + PresentationConstants.EXECUTION_PERIOD_OID + "="
                                        + infoExecutionCourse.getInfoExecutionPeriod().getExternalId() + "&amp;"
                                        + PresentationConstants.EXECUTION_DEGREE_OID + "="
                                        + examsMap.getInfoExecutionDegree().getExternalId() + "&amp;"
                                        + PresentationConstants.CURRICULAR_YEAR_OID + "="
                                        + curricularYear.toString() + "&amp;" + 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&amp;" + PresentationConstants.EXECUTION_COURSE_OID + "="
                                        + infoExecutionCourse.getExternalId() + "&amp;"
                                        + PresentationConstants.EXECUTION_PERIOD_OID + "="
                                        + infoExecutionCourse.getInfoExecutionPeriod().getExternalId() + "&amp;"
                                        + PresentationConstants.EXECUTION_DEGREE_OID + "="
                                        + examsMap.getInfoExecutionDegree().getExternalId() + "&amp;"
                                        + PresentationConstants.CURRICULAR_YEAR_OID + "="
                                        + curricularYear.toString() + "&amp;" + PresentationConstants.EXAM_OID
                                        + "=" + season2Exam.getExternalId() + "'>");
                            }

                            if (user.equals("sop")) {
                                strBuffer.append("2&ordf; ");
                                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&amp;" + PresentationConstants.EXECUTION_COURSE_OID
                                        + "=" + infoExecutionCourse.getExternalId() + "&amp;"
                                        + PresentationConstants.EXECUTION_PERIOD_OID + "="
                                        + infoExecutionCourse.getInfoExecutionPeriod().getExternalId() + "&amp;"
                                        + PresentationConstants.EXECUTION_DEGREE_OID + "="
                                        + examsMap.getInfoExecutionDegree().getExternalId() + "&amp;"
                                        + PresentationConstants.CURRICULAR_YEAR_OID + "="
                                        + curricularYear.toString() + "&amp;" + 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.sourceforge.fenixedu.presentationTier.Action.teacher.FinalWorkManagementAction.java

@EntryPoint
public ActionForward chooseDegree(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response)/*  w  ww .j  a  v a  2 s. c om*/
        throws FenixActionException, FenixServiceException, IllegalAccessException, InstantiationException {
    final User userView = Authenticate.getUser();

    final DynaActionForm finalWorkForm = (DynaActionForm) form;
    finalWorkForm.set("role", "responsable");
    finalWorkForm.set("responsibleCreditsPercentage", "100");
    finalWorkForm.set("coResponsibleCreditsPercentage", "0");

    final List<InfoExecutionYear> infoExecutionYears = new ArrayList<InfoExecutionYear>();
    for (final ExecutionYear executionYear : ExecutionYear.readNotClosedExecutionYears()) {
        infoExecutionYears.add(InfoExecutionYear.newInfoFromDomain(executionYear));
    }
    request.setAttribute("infoExecutionYears", infoExecutionYears);

    final String executionYear = (String) finalWorkForm.get("executionYear");
    final InfoExecutionYear infoExecutionYear;
    if (StringUtils.isEmpty(executionYear)) {
        infoExecutionYear = InfoExecutionYear.newInfoFromDomain(ExecutionYear.readCurrentExecutionYear());
        if (infoExecutionYear != null) {
            finalWorkForm.set("executionYear", infoExecutionYear.getExternalId().toString());
        }
    } else {
        infoExecutionYear = InfoExecutionYear
                .newInfoFromDomain(FenixFramework.<ExecutionYear>getDomainObject(executionYear));
    }

    final List executionDegreeList = ReadExecutionDegreesByExecutionYearAndDegreeType
            .run(infoExecutionYear.getYear(), null);
    final BeanComparator name = new BeanComparator("infoDegreeCurricularPlan.infoDegree.nome");
    Collections.sort(executionDegreeList, name);
    request.setAttribute("executionDegreeList", executionDegreeList);

    final List<FinalDegreeWorkProposalHeader> finalDegreeWorkProposalHeaders = ReadFinalDegreeWorkProposalHeadersByTeacher
            .run(userView.getPerson());

    final BeanComparator title = new BeanComparator("title");
    Collections.sort(finalDegreeWorkProposalHeaders, title);

    final List<String> selectedProposals = new ArrayList<String>(finalDegreeWorkProposalHeaders.size());
    for (final FinalDegreeWorkProposalHeader header : finalDegreeWorkProposalHeaders) {
        if (header.getGroupAttributedByTeacher() != null) {
            final InfoGroupProposal infoGroupProposal = (InfoGroupProposal) CollectionUtils
                    .find(header.getGroupProposals(), new PREDICATE_FIND_GROUP_PROPOSAL_BY_GROUP(
                            header.getGroupAttributedByTeacher().getExternalId()));
            selectedProposals.add(infoGroupProposal.getExternalId().toString());
        }
    }
    final String[] selectedProposalsAsArray = selectedProposals.toArray(new String[selectedProposals.size()]);

    ModuleConfig moduleConfig = mapping.getModuleConfig();
    final FormBeanConfig fbc2 = moduleConfig.findFormBeanConfig("finalWorkAttributionForm");
    final DynaActionFormClass dafc2 = DynaActionFormClass.createDynaActionFormClass(fbc2);
    final DynaActionForm finalWorkAttributionForm = (DynaActionForm) dafc2.newInstance();
    finalWorkAttributionForm.set("selectedGroupProposals", selectedProposalsAsArray);
    finalWorkForm.set("selectedGroupProposals", selectedProposalsAsArray);
    request.setAttribute("finalWorkAttributionForm", finalWorkAttributionForm);

    request.setAttribute("finalDegreeWorkProposalHeaders", finalDegreeWorkProposalHeaders);

    return mapping.findForward("chooseDegreeForFinalWorkProposal");
}

From source file:module.mailtracking.domain.CorrespondenceEntry.java

public Document getMainDocument() {
    return (Document) CollectionUtils.find(this.getDocumentsSet(), new Predicate() {

        @Override/* w  ww  . j a v a 2 s  .c  o m*/
        public boolean evaluate(Object arg0) {
            return !((Document) arg0).isDocumentDeleted()
                    && DocumentType.MAIN_DOCUMENT.equals(((Document) arg0).getType());
        }

    });
}

From source file:edu.kit.dama.rest.staging.types.TransferTaskContainer.java

/**
 * Set the file tree. This method is used internally in case of a download.
 * Keep in mind, that the file tree set for transfer task containers has to
 * offer a defined structure. It is recommended to perform file tree
 * creation and modifications only by the static methods provided by this
 * class.//from   w ww . j ava 2s .  co m
 *
 * @param pTree The tree to set.
 */
public final void setFileTree(IFileTree pTree) {
    if (pTree == null) {
        throw new IllegalArgumentException("Argument pTree must not be null");
    }

    if (!(pTree instanceof FileTreeImpl)) {
        throw new IllegalArgumentException(
                "Argument pTree must be an instance of edu.kit.dama.staging.entities.FileTreeImpl");
    }

    IDataOrganizationNode dataNode = (IDataOrganizationNode) CollectionUtils
            .find(pTree.getRootNode().getChildren(), new Predicate() {
                @Override
                public boolean evaluate(Object o) {
                    return Constants.STAGING_DATA_FOLDER_NAME.equals(((IDataOrganizationNode) o).getName());
                }
            });

    if (dataNode == null) {
        throw new IllegalArgumentException("Argument pTree has an invalid structure. No '"
                + Constants.STAGING_DATA_FOLDER_NAME + "' node found.");
    }
    IDataOrganizationNode generatedNode = (IDataOrganizationNode) CollectionUtils
            .find(pTree.getRootNode().getChildren(), new Predicate() {
                @Override
                public boolean evaluate(Object o) {
                    return Constants.STAGING_GENERATED_FOLDER_NAME
                            .equals(((IDataOrganizationNode) o).getName());
                }
            });
    if (generatedNode == null) {
        throw new IllegalArgumentException("Argument pTree has an invalid structure. No '"
                + Constants.STAGING_GENERATED_FOLDER_NAME + "' node found.");
    }
    IDataOrganizationNode settingsNode = (IDataOrganizationNode) CollectionUtils
            .find(pTree.getRootNode().getChildren(), new Predicate() {
                @Override
                public boolean evaluate(Object o) {
                    return Constants.STAGING_SETTINGS_FOLDER_NAME.equals(((IDataOrganizationNode) o).getName());
                }
            });
    if (settingsNode == null) {
        throw new IllegalArgumentException("Argument pTree has an invalid structure. No '"
                + Constants.STAGING_SETTINGS_FOLDER_NAME + "' node found.");
    }

    tree = (FileTreeImpl) pTree;
}

From source file:edu.kit.dama.staging.services.impl.download.DownloadInformationServiceLocal.java

private Collection<StagingProcessor> mergeStagingProcessors(Collection<StagingProcessor> assignedProcessors,
        Collection<StagingProcessor> defaultProcessors) {
    LOGGER.debug("Checking default staging processors.");
    if (assignedProcessors == null || assignedProcessors.isEmpty()) {
        //return defaultProcessors (can't be null, so we do not have to check result)
        LOGGER.debug("No staging processors assigned, using only default processors.");
        return defaultProcessors;
    }// w w w  .  j a v a2  s  .  c  o  m

    LOGGER.debug("Adding all assigned processors to result list.");
    List<StagingProcessor> result = new ArrayList<>(assignedProcessors);

    if (defaultProcessors == null || defaultProcessors.isEmpty()) {
        //return assigned processors
        LOGGER.debug("No default processors provided, using only assigned processors.");
        return result;
    }

    LOGGER.debug("Merging {} existing and {} default processor(s)", assignedProcessors.size(),
            defaultProcessors.size());
    for (final StagingProcessor processor : defaultProcessors) {
        LOGGER.debug("Searching for default processor with id {}", processor.getUniqueIdentifier());
        StagingProcessor exists = (StagingProcessor) CollectionUtils.find(assignedProcessors, new Predicate() {

            @Override
            public boolean evaluate(Object o) {
                return Long.compare(((StagingProcessor) o).getId(), processor.getId()) == 0;
            }
        });

        if (exists == null) {
            LOGGER.debug("Default processor with id {} is not assigned, yet. Adding it.", processor.getId());
            //add as it not exists
            result.add(processor);
        }
    }
    return result;
}

From source file:com.algoTrader.CriteriaSearchProperties.java

/**
 * Gets the type of the embedded value given the <code>ownerType</code>
 * and <code>name</code>/*from   ww  w  . j  a va2  s .co  m*/
 *
 * @param properties Map contains the Collection of properties given the ownerType Class
 * @param ownerType the owner of the association.
 * @param name the name of the association end to find.
 * @return the type of the association end.
 */
public static Class getPropertyType(final Map properties, final Class ownerType, final String name) {
    final Collection ends = (Collection) properties.get(ownerType);
    final PropertyType type = (PropertyType) CollectionUtils.find(ends, new Predicate() {
        public boolean evaluate(final Object object) {
            return ((PropertyType) object).name.equals(name);
        }
    });
    return type != null ? type.type : null;
}