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:org.dasein.cloud.azure.platform.AzureSqlDatabaseSupport.java

private String getProductGUID(final DatabaseProduct product) throws CloudException {
    ServerServiceResourceModel.Version versionResult = getSubscriptionVersionProducts();

    ServerServiceResourceModel.Edition edition = (ServerServiceResourceModel.Edition) CollectionUtils
            .find(versionResult.getEditions(), new Predicate() {
                @Override//from  w ww  .  j  a va 2 s.c om
                public boolean evaluate(Object object) {
                    return ((ServerServiceResourceModel.Edition) object).getName()
                            .equalsIgnoreCase(product.getName());
                }
            });

    ServerServiceResourceModel.ServiceLevelObjective serviceLevelObjective = (ServerServiceResourceModel.ServiceLevelObjective) CollectionUtils
            .find(edition.getServiceLevelObjectives(), new Predicate() {
                @Override
                public boolean evaluate(Object object) {
                    return ((ServerServiceResourceModel.ServiceLevelObjective) object).getName()
                            .equalsIgnoreCase(product.getProductSize());
                }
            });

    return serviceLevelObjective.getId();
}

From source file:org.dasein.cloud.azure.tests.compute.vm.AzureVmTest.java

@Test
public void testListVMMakesTheCorrectNumberOfAPICalls() throws CloudException, InternalException {

    ArrayList<HostedServiceModel> hostedServiceModelList = new ArrayList<HostedServiceModel>();
    for (Integer i = 1; i < 20; i++) {
        final HostedServiceModel hostedServiceModel = new HostedServiceModel();
        hostedServiceModel.setServiceName(String.format("HOSTED_SERVICE_%s", i.toString()));
        hostedServiceModel.setUrl("TEST_SERVICE_URL");
        hostedServiceModelList.add(hostedServiceModel);
    }/*from   ww  w .j  ava  2  s  .co  m*/
    HostedServicesModel hostedServicesModel = new HostedServicesModel();
    hostedServicesModel.setHostedServiceModelList(hostedServiceModelList);
    final DaseinObjectToXmlEntity<HostedServicesModel> responseEntity = new DaseinObjectToXmlEntity<HostedServicesModel>(
            hostedServicesModel);

    final CloseableHttpResponse getHttpResponseHostedServicesEntityMock = getHttpResponseMock(
            getStatusLineMock(HttpServletResponse.SC_OK), responseEntity, new Header[] {});
    final CloseableHttpResponse getHttpResponseEmptyEntityMock = getHttpResponseMock(
            getStatusLineMock(HttpServletResponse.SC_OK), null, new Header[] {});

    final String expectedUrl = String.format(HOSTED_SERVICES_URL, ENDPOINT, ACCOUNT_NO);
    final ArrayList<String> actualAPICallUrls = new ArrayList<String>();
    new MockUp<CloseableHttpClient>() {
        @Mock
        public CloseableHttpResponse execute(HttpUriRequest request) throws IOException {
            if (request.getURI().toString().endsWith("hostedservices")) {
                assertGet(request, expectedUrl, new Header[] { new BasicHeader("x-ms-version", "2012-03-01") });
                return getHttpResponseHostedServicesEntityMock;
            } else if (request.getURI().toString().endsWith("embed-detail=true")) {
                Assert.assertNotNull(
                        CollectionUtils.find(Arrays.asList(request.getAllHeaders()), new Predicate() {
                            @Override
                            public boolean evaluate(Object object) {
                                Header actualHeader = (Header) object;
                                return actualHeader.getName() == "x-ms-version"
                                        && actualHeader.getValue() == "2014-05-01";
                            }
                        }));
                actualAPICallUrls.add(request.getURI().toString());
                return getHttpResponseEmptyEntityMock;
            } else {
                Assert.fail("listVirtualMachine method makes an unexpected API call");
                return null;
            }
        }
    };

    AzureVM azureVM = new AzureVM(azureMock);
    Iterable<VirtualMachine> virtualMachines = azureVM.listVirtualMachines();

    Assert.assertNotNull(virtualMachines);
    assertEquals(hostedServicesModel.getHostedServiceModelList().size(), actualAPICallUrls.size());
    for (HostedServiceModel hostedServiceModel : hostedServicesModel.getHostedServiceModelList()) {
        String expectedUrlCall = String.format(HOSTED_SERVICES_SERVICE_EMBEDED_DETAILS_URL, ENDPOINT,
                ACCOUNT_NO, hostedServiceModel.getServiceName());
        assertTrue(actualAPICallUrls.contains(expectedUrlCall));
    }
    assertEquals(0, IteratorUtils.toList(virtualMachines.iterator()).size());
}

From source file:org.dasein.cloud.azurepack.platform.AzurePackDatabaseSupport.java

@Nullable
@Override//from   www.  ja va2s. com
public Database getDatabase(final String providerDatabaseId) throws CloudException, InternalException {
    ArrayList<Database> allDatabases = getAllDatabases();

    return (Database) CollectionUtils.find(allDatabases, new Predicate() {
        @Override
        public boolean evaluate(Object object) {
            return ((Database) object).getProviderDatabaseId().equalsIgnoreCase(providerDatabaseId);
        }
    });
}

From source file:org.dentaku.gentaku.cartridge.entity.hibernate.HibernateEntityGenerator.java

protected Stereotype getClassifierStereotype(CorePackage core) {
    Stereotype classifierStereotype = (Stereotype) CollectionUtils.find(core.getStereotype().refAllOfType(),
            new Predicate() {
                public boolean evaluate(Object object) {
                    return ((ModelElementImpl) object).getName().equals("HibernateEntity");
                }/*w w w  .  ja va  2s.c  om*/
            });
    return classifierStereotype;
}

From source file:org.dentaku.gentaku.cartridge.entity.jdo.JDOEntityGenerator.java

protected Stereotype getClassifierStereotype(CorePackage core) {
    Stereotype classifierStereotype = (Stereotype) CollectionUtils.find(core.getStereotype().refAllOfType(),
            new Predicate() {
                public boolean evaluate(Object object) {
                    return ((ModelElementImpl) object).getName().equals("JDOEntity");
                }/*from w w w  .  j a  v  a 2  s .c om*/
            });
    return classifierStereotype;
}

From source file:org.dentaku.services.metadata.Utils.java

public static ClassifierImpl findUmlClass(org.omg.uml.UmlPackage umlPackage, String pkgName,
        final String entityName, boolean create) {
    // set up our superclass package structure
    ModelImpl model = Utils.getModelRoot(umlPackage);
    UmlPackage newPackage = model.getChildPackage(pkgName, create);

    ClassifierImpl result = (ClassifierImpl) CollectionUtils.find(newPackage.getOwnedElement(),
            new Predicate() {
                public boolean evaluate(Object object) {
                    return (object instanceof UmlClass && ((UmlClass) object).getName().equals(entityName));
                }//from  w  w w. j a v  a 2s . c o  m
            });
    // create the entity
    if (result == null) {
        CorePackage core = umlPackage.getCore();
        result = (ClassifierImpl) core.getUmlClass().createUmlClass();
        result.setName(entityName);
        core.getANamespaceOwnedElement().add(newPackage, result);
    }
    return result;
}

From source file:org.dentaku.services.metadata.Utils.java

public static ModelImpl getModelRoot(org.omg.uml.UmlPackage model) {
    ModelImpl m = (ModelImpl) CollectionUtils.find(model.getCore().getNamespace().refAllOfType(),
            new Predicate() {
                public boolean evaluate(Object o) {
                    if (((ModelElementImpl) o).getNamespace() == null)
                        return true;
                    else
                        return false;
                }// ww  w . j  ava2  s  .c o  m
            });
    return m;
}

From source file:org.fao.geonet.kernel.harvest.harvester.fragment.FragmentHarvester.java

/**
 * Get valid category//from  w w  w .  j  a v a  2s. c  o  m
 * @param children
 * @return
 */
private Category getValidCategory(final Collection<String> categIds) {
    return (Category) CollectionUtils.find(localCateg, new Predicate() {

        @Override
        public boolean evaluate(Object object) {

            return categIds.contains(((Category) object).getId());
        }
    });
}

From source file:org.fao.geonet.kernel.mef.Importer.java

/**
 * Map local categories.//from  w  w w  . j  a va 2s.com
 * @param localCategs
 * @param categs
 * @return a local category or null if any.
 */
protected static Category mapLocalCategory(List<Category> localCategs, final Collection<String> categoryNames) {
    return (Category) CollectionUtils.find(localCategs, new Predicate() {

        @Override
        public boolean evaluate(Object object) {
            return categoryNames.contains(((Category) object).getName());
        }
    });
}

From source file:org.fenixedu.academic.servlet.taglib.sop.examsMapNew.ExamsMapRenderer.java

private void renderExecutionCourseListForYear(StringBuilder strBuffer, Integer curricularYear,
        PageContext pageContext) {/*from   w w w . j a v a 2  s . c  om*/
    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 + "'>");

                    String siteUrl = infoExecutionCourse.getExecutionCourse().getSiteUrl();
                    siteUrl = siteUrl == null ? "" : siteUrl;
                    strBuffer.append(GenericChecksumRewriter.NO_CHECKSUM_PREFIX);
                    strBuffer.append("<a href=\"");
                    strBuffer.append(siteUrl);
                    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>");
        }
    }
}