Example usage for org.joda.time DateTime getDayOfMonth

List of usage examples for org.joda.time DateTime getDayOfMonth

Introduction

In this page you can find the example usage for org.joda.time DateTime getDayOfMonth.

Prototype

public int getDayOfMonth() 

Source Link

Document

Get the day of month field value.

Usage

From source file:net.sourceforge.fenixedu.domain.reports.RaidesPhdReportFile.java

License:Open Source License

private void reportRaidesGraduate(Spreadsheet spreadsheet, PhdIndividualProgramProcess process,
        ExecutionYear executionYear) {//from w w w.  j  a  v a2s.  c om
    final Row row = spreadsheet.addRow();
    final Person graduate = process.getPerson();
    final PersonalInformationBean personalInformationBean = process.getPersonalInformationBean(executionYear);
    final Registration registration = process.getRegistration();
    final boolean concluded = process.isConcluded();
    final LocalDate conclusionDate = process.getConclusionDate();

    if (registration != null && !registration.isBolonha()) {
        return;
    }

    YearMonthDay registrationConclusionDate = registration != null
            ? registration.getLastStudentCurricularPlan().getCycle(CycleType.THIRD_CYCLE).getConclusionDate()
            : null;

    if (registration != null && registrationConclusionDate == null) {
        registrationConclusionDate = registration.getLastStudentCurricularPlan()
                .calculateConclusionDate(CycleType.THIRD_CYCLE);
    }

    row.setCell(String.valueOf(registration != null && !registration.isCanceled()));

    // Ciclo
    row.setCell(CycleType.THIRD_CYCLE.getDescription());

    // Concludo
    row.setCell(String.valueOf(process.isConcluded()));

    // Mdia do Ciclo
    String grade = concluded ? process.getFinalGrade().getLocalizedName() : "n/a";
    if (concluded && registration != null && registration.isConcluded()) {
        grade += " " + registration.getLastStudentCurricularPlan().getCycle(CycleType.THIRD_CYCLE)
                .getCurriculum(registrationConclusionDate.toDateTimeAtMidnight()).getAverage().toPlainString();
    }
    row.setCell(grade);

    // Data de concluso
    row.setCell(conclusionDate != null ? conclusionDate.toString("dd-MM-yyyy") : "");

    // Data de Incio
    row.setCell(process.getCandidacyDate().toString("dd-MM-yyyy"));

    // N de aluno
    row.setCell(process.getStudent().getNumber());

    // Tipo Identificao
    row.setCell(graduate.getIdDocumentType().getLocalizedName());

    // N de Identificao
    row.setCell(graduate.getDocumentIdNumber());

    // Dgitos de Controlo
    row.setCell(graduate.getIdentificationDocumentExtraDigitValue());

    // Verso Doc. Identificao
    row.setCell(graduate.getIdentificationDocumentSeriesNumberValue());

    // Nome
    row.setCell(registration != null ? registration.getName()
            : process.getPerson() != null ? process.getPerson().getName() : "n/a");

    // Sexo
    row.setCell(graduate.getGender().toString());

    // Data de Nascimento
    row.setCell(graduate.getDateOfBirthYearMonthDay() != null
            ? graduate.getDateOfBirthYearMonthDay().toString("dd-MM-yyyy")
            : "n/a");

    // Pas de Nascimento
    row.setCell(graduate.getCountryOfBirth() != null ? graduate.getCountryOfBirth().getName() : "n/a");

    // Pas de Nacionalidade
    row.setCell(graduate.getCountry() != null ? graduate.getCountry().getName() : "n/a");

    // Sigla programa doutoral
    row.setCell(process.getPhdProgram().getAcronym());

    // Programa doutoral
    row.setCell(process.getPhdProgram().getName().getContent());

    // Tipo Curso
    row.setCell(registration != null ? registration.getDegreeType().getLocalizedName() : "n/a");

    // Nome Curso
    row.setCell(registration != null ? registration.getDegree().getNameI18N().getContent() : "n/a");

    // Sigla Curso
    row.setCell(registration != null ? registration.getDegree().getSigla() : "n/a");

    // Ramo (caso se aplique)
    row.setCell("no determinvel");

    if (registration != null) {
        // N de anos lectivos de inscrio no Curso actual
        row.setCell(calculateNumberOfEnrolmentYears(registration, executionYear));

        // ltimo ano em que esteve inscrito
        row.setCell(registration.getLastEnrolmentExecutionYear() != null
                ? registration.getLastEnrolmentExecutionYear().getName()
                : "");
    } else {
        row.setCell("n/a");
        row.setCell("n/a");
    }

    // estabelecimento do habl anterior compl (se o aluno ingressou por uma via
    // diferente CNA, e deve ser IST caso o aluno tenha estado matriculado noutro curso do IST)
    row.setCell(personalInformationBean.getInstitution() != null
            ? personalInformationBean.getInstitution().getName()
            : "");

    // curso habl anterior compl (se o aluno ingressou por uma via diferente CNA, e
    // deve ser IST caso o aluno tenha estado matriculado noutro curso do IST)
    row.setCell(personalInformationBean.getDegreeDesignation());

    // Estado Civil
    row.setCell(personalInformationBean.getMaritalStatus() != null
            ? personalInformationBean.getMaritalStatus().toString()
            : process.getPerson().getMaritalStatus().toString());

    // Pas de Residncia Permanente
    if (personalInformationBean.getCountryOfResidence() != null) {
        row.setCell(personalInformationBean.getCountryOfResidence().getName());
    } else {
        row.setCell(process.getStudent().getPerson().getCountryOfResidence() != null
                ? process.getStudent().getPerson().getCountryOfResidence().getName()
                : "");
    }

    // Distrito de Residncia Permanente
    if (personalInformationBean.getDistrictSubdivisionOfResidence() != null) {
        row.setCell(personalInformationBean.getDistrictSubdivisionOfResidence().getDistrict().getName());
    } else {
        row.setCell(process.getStudent().getPerson().getDistrictOfResidence());
    }

    // Concelho de Residncia Permanente
    if (personalInformationBean.getDistrictSubdivisionOfResidence() != null) {
        row.setCell(personalInformationBean.getDistrictSubdivisionOfResidence().getName());
    } else {
        row.setCell(process.getStudent().getPerson().getDistrictSubdivisionOfResidence());
    }

    // Deslocado da Residncia Permanente
    if (personalInformationBean.getDislocatedFromPermanentResidence() != null) {
        row.setCell(personalInformationBean.getDislocatedFromPermanentResidence().toString());
    } else {
        row.setCell("");
    }

    // Nvel de Escolaridade do Pai
    if (personalInformationBean.getFatherSchoolLevel() != null) {
        row.setCell(personalInformationBean.getFatherSchoolLevel().getName());
    } else {
        row.setCell("");
    }

    // Nvel de Escolaridade da Me
    if (personalInformationBean.getMotherSchoolLevel() != null) {
        row.setCell(personalInformationBean.getMotherSchoolLevel().getName());
    } else {
        row.setCell("");
    }

    // Condio perante a situao na profisso/Ocupao do Pai
    if (personalInformationBean.getFatherProfessionalCondition() != null) {
        row.setCell(personalInformationBean.getFatherProfessionalCondition().getName());
    } else {
        row.setCell("");
    }

    // Condio perante a situao na profisso/Ocupao da Me
    if (personalInformationBean.getMotherProfessionalCondition() != null) {
        row.setCell(personalInformationBean.getMotherProfessionalCondition().getName());
    } else {
        row.setCell("");
    }

    // Profisso do Pai
    if (personalInformationBean.getFatherProfessionType() != null) {
        row.setCell(personalInformationBean.getFatherProfessionType().getName());
    } else {
        row.setCell("");
    }

    // Profisso da Me
    if (personalInformationBean.getMotherProfessionType() != null) {
        row.setCell(personalInformationBean.getMotherProfessionType().getName());
    } else {
        row.setCell("");
    }

    // Profisso do Aluno
    if (personalInformationBean.getProfessionType() != null) {
        row.setCell(personalInformationBean.getProfessionType().getName());
    } else {
        row.setCell("");
    }

    // Data preenchimento dados RAIDES
    if (personalInformationBean.getLastModifiedDate() != null) {
        DateTime dateTime = personalInformationBean.getLastModifiedDate();
        row.setCell(dateTime.getYear() + "-" + dateTime.getMonthOfYear() + "-" + dateTime.getDayOfMonth());
    } else {
        row.setCell("");
    }

    // Estatuto de Trabalhador Estudante introduzido pelo aluno
    if (personalInformationBean.getProfessionalCondition() != null) {
        row.setCell(personalInformationBean.getProfessionalCondition().getName());
    } else {
        row.setCell("");
    }

    // Bolseiro (info. RAIDES)
    if (personalInformationBean.getGrantOwnerType() != null) {
        row.setCell(personalInformationBean.getGrantOwnerType().getName());
    } else {
        row.setCell("");
    }

    // Bolseiro (info. oficial)
    boolean sasFound = false;
    for (StudentStatute statute : process.getStudent().getStudentStatutesSet()) {
        if (statute.getStatuteType() == StudentStatuteType.SAS_GRANT_OWNER
                && statute.isValidInExecutionPeriod(executionYear.getFirstExecutionPeriod())) {
            sasFound = true;
            break;
        }
    }
    row.setCell(String.valueOf(sasFound));

    // Grau Precedente
    row.setCell(personalInformationBean.getPrecedentSchoolLevel() != null
            ? personalInformationBean.getPrecedentSchoolLevel().getName()
            : "");

    // grau habl anterior compl
    row.setCell(personalInformationBean.getSchoolLevel() != null
            ? personalInformationBean.getSchoolLevel().getName()
            : "");

    // outro grau habl anterior compl
    row.setCell(personalInformationBean.getOtherSchoolLevel() != null
            ? personalInformationBean.getOtherSchoolLevel()
            : "");

    // Pas de Habilitao Anterior Completa
    row.setCell(personalInformationBean.getCountryWhereFinishedPreviousCompleteDegree() != null
            ? personalInformationBean.getCountryWhereFinishedPreviousCompleteDegree().getName()
            : "");

    // Pas de Habilitao do 12 ano ou equivalente
    row.setCell(personalInformationBean.getCountryWhereFinishedHighSchoolLevel() != null
            ? personalInformationBean.getCountryWhereFinishedHighSchoolLevel().getName()
            : "");

    // Ano de concluso da habilitao anterior completa
    row.setCell(personalInformationBean.getConclusionYear());

    // Nota de concluso da habilitao anterior completa
    row.setCell(
            personalInformationBean.getConclusionGrade() != null ? personalInformationBean.getConclusionGrade()
                    : "");

    // N inscries no curso preced. (conta uma por cada ano)
    row.setCell(personalInformationBean.getNumberOfPreviousYearEnrolmentsInPrecedentDegree() != null
            ? personalInformationBean.getNumberOfPreviousYearEnrolmentsInPrecedentDegree().toString()
            : "");

    // Durao do programa de mobilidade
    row.setCell(personalInformationBean.getMobilityProgramDuration() != null ? BundleUtil
            .getString(Bundle.ENUMERATION, personalInformationBean.getMobilityProgramDuration().name()) : "");

    // Tipo de Estabelecimento Frequentado no Ensino Secundrio
    if (personalInformationBean.getHighSchoolType() != null) {
        row.setCell(personalInformationBean.getHighSchoolType().getName());
    } else {
        row.setCell("");
    }

    double totalEctsConcludedUntilPreviousYear = 0d;
    if (registration != null) {

        // Total de ECTS inscritos no total do ano
        double totalCreditsEnrolled = 0d;
        for (Enrolment enrollment : registration.getLastStudentCurricularPlan()
                .getEnrolmentsByExecutionYear(executionYear)) {
            totalCreditsEnrolled += enrollment.getEctsCredits();
        }
        row.setCell(totalCreditsEnrolled);

        // Total de ECTS concludos at ao fim do ano lectivo anterior (1
        // Semestre do ano lectivo actual) ao que se
        // referem os dados (neste caso at ao fim de 2008) no curso actual
        for (final CycleCurriculumGroup cycleCurriculumGroup : registration.getLastStudentCurricularPlan()
                .getInternalCycleCurriculumGrops()) {

            // We can use current year because only the first semester has
            // occured
            totalEctsConcludedUntilPreviousYear += cycleCurriculumGroup.getCreditsConcluded(executionYear);
        }
        row.setCell(totalEctsConcludedUntilPreviousYear);

        // N ECTS equivalncia/substituio/dispensa
        double totalCreditsDismissed = 0d;
        for (Credits credits : registration.getLastStudentCurricularPlan().getCreditsSet()) {
            if (credits.isEquivalence()) {
                totalCreditsDismissed += credits.getEnrolmentsEcts();
            }
        }
        row.setCell(totalCreditsDismissed);

    } else {
        row.setCell("n/a");
        row.setCell("n/a");
        row.setCell("n/a");
    }

    if (registration != null) {
        // Total de ECTS necessrios para a concluso
        if (concluded) {
            row.setCell(0);
        } else {
            row.setCell(registration.getLastStudentCurricularPlan().getRoot().getDefaultEcts(executionYear)
                    - totalEctsConcludedUntilPreviousYear);
        }
    } else {
        row.setCell("n/a");
    }

    // Se alunos de Doutoramento, inscrito na Parte Curricular?
    if (registration != null && registration.isDEA()) {
        row.setCell(String.valueOf(registration.getLastStudentCurricularPlan().hasEnrolments(executionYear)));
    } else {
        row.setCell("not PhD");
    }

    row.setCell(process.getPhdStudentNumber());

    // ist id dos orientadores
    int count = 0;
    StringBuilder guidings = new StringBuilder();
    for (PhdParticipant phdParticipant : process.getGuidingsSet()) {
        if (phdParticipant.isInternal()) {
            if (count > 0) {
                guidings.append(";");
            }
            guidings.append(((InternalPhdParticipant) phdParticipant).getPerson().getIstUsername());
            count++;
        }
    }
    row.setCell(guidings.toString());

    // ist id dos co-orientadores
    int countAssistantGuidings = 0;
    StringBuilder assistantGuidings = new StringBuilder();
    for (PhdParticipant phdParticipant : process.getAssistantGuidingsSet()) {
        if (phdParticipant.isInternal()) {
            if (countAssistantGuidings > 0) {
                assistantGuidings.append(";");
            }
            assistantGuidings.append(((InternalPhdParticipant) phdParticipant).getPerson().getIstUsername());
            countAssistantGuidings++;
        }
    }
    row.setCell(assistantGuidings.toString());

    // Nome do Orientador Externo
    int countExternalGuidings = 0;
    StringBuilder externalGuidingNames = new StringBuilder();
    for (PhdParticipant phdParticipant : process.getGuidingsSet()) {
        if (!phdParticipant.isInternal()) {
            if (countExternalGuidings > 0) {
                externalGuidingNames.append(";");
            }
            externalGuidingNames.append(((ExternalPhdParticipant) phdParticipant).getName());
            externalGuidingNames.append(" (");
            externalGuidingNames.append(((ExternalPhdParticipant) phdParticipant).getInstitution());
            externalGuidingNames.append(")");
            countExternalGuidings++;
        }
    }
    row.setCell(externalGuidingNames.toString());

    // Nome do Co-Orientador Externo
    int countExternalAssistantGuidings = 0;
    StringBuilder externalAssistantGuidingNames = new StringBuilder();
    for (PhdParticipant phdParticipant : process.getAssistantGuidingsSet()) {
        if (!phdParticipant.isInternal()) {
            if (countExternalAssistantGuidings > 0) {
                externalAssistantGuidingNames.append(";");
            }
            externalAssistantGuidingNames.append(((ExternalPhdParticipant) phdParticipant).getName());
            externalAssistantGuidingNames.append(" (");
            externalAssistantGuidingNames.append(((ExternalPhdParticipant) phdParticipant).getInstitution());
            externalAssistantGuidingNames.append(")");
            countExternalAssistantGuidings++;
        }
    }
    row.setCell(externalAssistantGuidingNames.toString());

    PhdProgramProcessState lastActiveState = process.getMostRecentState();
    row.setCell(lastActiveState != null ? lastActiveState.getType().getLocalizedName() : "n/a");

    if (process.getCollaborationType() != null) {
        row.setCell(process.getCollaborationType().getLocalizedName());
    } else {
        row.setCell("n/a");
    }

    if (process.getCandidacyDate() != null) {
        row.setCell(process.getCandidacyDate().toString("dd/MM/yyyy"));
    } else {
        row.setCell("n/a");
    }

    if (process.getCandidacyProcess().getWhenRatified() != null) {
        row.setCell(process.getCandidacyDate().toString("dd/MM/yyyy"));
    } else {
        row.setCell("n/a");
    }

    if (process.getWhenStartedStudies() != null) {
        row.setCell(process.getWhenStartedStudies().toString("dd/MM/yyyy"));
    } else {
        row.setCell("n/a");
    }

    if (process.getThesisProcess() != null && process.getThesisProcess().getDiscussionDate() != null) {
        row.setCell(process.getThesisProcess().getDiscussionDate().toString("dd/MM/yyyy"));
    } else {
        row.setCell("n/a");
    }

    // Tipo de Acordo (AFA, AM, ERASMUS, etc)
    row.setCell(registration != null
            ? registration.getRegistrationProtocol() != null ? registration.getRegistrationProtocol().getCode()
                    : ""
            : "");

    // Data de Apresentao Pblica da CAT
    if (process.getSeminarProcess() != null && process.getSeminarProcess().getPresentationDate() != null) {
        row.setCell(process.getSeminarProcess().getPresentationDate().toString("dd/MM/yyyy"));
    } else {
        row.setCell("n/a");
    }
}

From source file:net.sourceforge.fenixedu.domain.vigilancy.UnavailablePeriod.java

License:Open Source License

public String getUnavailableAsString() {
    DateTime begin = this.getBeginDate();
    DateTime end = this.getEndDate();

    return String.format("%02d/%02d/%d (%02d:%02d) - %02d/%02d/%d (%02d:%02d): %s", begin.getDayOfMonth(),
            begin.getMonthOfYear(), begin.getYear(), begin.getHourOfDay(), begin.getMinuteOfHour(),
            end.getDayOfMonth(), end.getMonthOfYear(), end.getYear(), end.getHourOfDay(), end.getMinuteOfHour(),
            this.getJustification());
}

From source file:net.sourceforge.fenixedu.domain.vigilancy.Vigilancy.java

License:Open Source License

public YearMonthDay getBeginYearMonthDay() {
    DateTime begin = this.getWrittenEvaluation().getBeginningDateTime();
    YearMonthDay date = new YearMonthDay(begin.getYear(), begin.getMonthOfYear(), begin.getDayOfMonth());
    return date;//from  ww w  . ja v a2s .co m
}

From source file:net.sourceforge.fenixedu.domain.vigilancy.Vigilancy.java

License:Open Source License

public YearMonthDay getEndYearMonthDay() {
    DateTime end = this.getWrittenEvaluation().getEndDateTime();
    YearMonthDay date = new YearMonthDay(end.getYear(), end.getMonthOfYear(), end.getDayOfMonth());
    return date;/*from w w w  .j ava 2  s . c  o m*/
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.operator.SubmitPhotoAction.java

License:Open Source License

public ActionForward photoUpload(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    PhotographUploadBean photo = getRenderedObject();
    RenderUtils.invalidateViewState();//w  w  w  .  ja v  a2  s .co m
    String base64Thumbnail = request.getParameter("encodedThumbnail");
    String base64Image = request.getParameter("encodedPicture");
    if (base64Image != null && base64Thumbnail != null) {
        DateTime now = new DateTime();
        photo.setFilename("mylovelypic_" + now.getYear() + now.getMonthOfYear() + now.getDayOfMonth()
                + now.getHourOfDay() + now.getMinuteOfDay() + now.getSecondOfMinute() + ".png");
        photo.setBase64RawContent(base64Image.split(",")[1]);
        photo.setBase64RawThumbnail(base64Thumbnail.split(",")[1]);
        photo.setContentType(base64Image.split(",")[0].split(":")[1].split(";")[0]);
    }

    ActionMessages actionMessages = new ActionMessages();
    if (photo.getFileInputStream() == null) {
        actionMessages.add("error", new ActionMessage("errors.fileRequired"));
        saveMessages(request, actionMessages);
        return preparePhotoUpload(mapping, actionForm, request, response);
    }

    if (ContentType.getContentType(photo.getContentType()) == null) {
        actionMessages.add("error", new ActionMessage("errors.unsupportedFile"));
        saveMessages(request, actionMessages);
        return preparePhotoUpload(mapping, actionForm, request, response);
    }

    if (photo.getRawSize() > MAX_RAW_SIZE) {
        actionMessages.add("error", new ActionMessage("errors.fileTooLarge"));
        saveMessages(request, actionMessages);
        photo.deleteTemporaryFiles();
        return preparePhotoUpload(mapping, actionForm, request, response);
    }

    try {
        photo.processImage();
    } catch (UnableToProcessTheImage e) {
        actionMessages.add("error", new ActionMessage("errors.unableToProcessImage"));
        saveMessages(request, actionMessages);
        photo.deleteTemporaryFiles();
        return preparePhotoUpload(mapping, actionForm, request, response);
    }

    try {
        updatePersonPhoto(photo);
    } catch (Exception e) {
        actionMessages.add("error", new ActionMessage("errors.unableToSaveImage"));
        saveMessages(request, actionMessages);
        photo.deleteTemporaryFiles();
        return preparePhotoUpload(mapping, actionForm, request, response);
    }

    actionMessages.add("success", new ActionMessage("label.operator.submit.ok", ""));
    saveMessages(request, actionMessages);
    return preparePhotoUpload(mapping, actionForm, request, response);
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.person.UploadPhotoDA.java

License:Open Source License

public ActionForward upload(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    PhotographUploadBean photo = getRenderedObject();
    RenderUtils.invalidateViewState();/*from   w w  w .j  a v a2 s.co m*/
    String base64Thumbnail = request.getParameter("encodedThumbnail");
    String base64Image = request.getParameter("encodedPicture");
    if (base64Image != null && base64Thumbnail != null) {
        DateTime now = new DateTime();
        photo.setFilename("mylovelypic_" + now.getYear() + now.getMonthOfYear() + now.getDayOfMonth()
                + now.getHourOfDay() + now.getMinuteOfDay() + now.getSecondOfMinute() + ".png");
        photo.setBase64RawContent(base64Image.split(",")[1]);
        photo.setBase64RawThumbnail(base64Thumbnail.split(",")[1]);
        photo.setContentType(base64Image.split(",")[0].split(":")[1].split(";")[0]);
    }

    ActionMessages actionMessages = new ActionMessages();
    if (photo.getFileInputStream() == null) {
        actionMessages.add("fileRequired", new ActionMessage("errors.fileRequired"));
        saveMessages(request, actionMessages);
        return prepare(mapping, actionForm, request, response);
    }

    if (ContentType.getContentType(photo.getContentType()) == null) {
        actionMessages.add("fileUnsupported", new ActionMessage("errors.unsupportedFile"));
        saveMessages(request, actionMessages);
        return prepare(mapping, actionForm, request, response);
    }

    if (photo.getRawSize() > MAX_RAW_SIZE) {
        actionMessages.add("fileTooLarge", new ActionMessage("errors.fileTooLarge"));
        saveMessages(request, actionMessages);
        photo.deleteTemporaryFiles();
        return prepare(mapping, actionForm, request, response);
    }

    try {
        photo.processImage();
    } catch (UnableToProcessTheImage e) {
        actionMessages.add("unableToProcessImage", new ActionMessage("errors.unableToProcessImage"));
        saveMessages(request, actionMessages);
        photo.deleteTemporaryFiles();
        return prepare(mapping, actionForm, request, response);
    }
    photo.createTemporaryFiles();

    request.setAttribute("preview", true);
    request.setAttribute("photo", photo);
    return mapping.findForward("confirm");
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.vigilancy.ConvokeManagement.java

License:Open Source License

public ActionForward confirmConvokes(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    Boolean havingVigilantsThatAreTeachers = false;

    ConvokeBean beanWithTeachers = null;

    if (RenderUtils.getViewState("selectVigilantsThatAreTeachers") != null) {
        beanWithTeachers = (ConvokeBean) RenderUtils.getViewState("selectVigilantsThatAreTeachers")
                .getMetaObject().getObject();
    }/*from   w  w  w  .j  a  v a 2 s  .c o m*/

    ConvokeBean beanWithVigilants = (ConvokeBean) RenderUtils.getViewState("selectVigilants").getMetaObject()
            .getObject();

    ConvokeBean beanWithUnavailables = (ConvokeBean) RenderUtils
            .getViewState("selectVigilantsThatAreUnavailable").getMetaObject().getObject();

    List<VigilantWrapper> teachers = null;
    List<VigilantWrapper> vigilants, unavailables;

    if (RenderUtils.getViewState("selectVigilantsThatAreTeachers") != null) {
        teachers = beanWithTeachers.getSelectedTeachers();
    }

    vigilants = beanWithVigilants.getVigilants();
    unavailables = beanWithUnavailables.getSelectedUnavailableVigilants();

    String convokedVigilants = beanWithVigilants.getTeachersAsString();
    String teachersVigilancies = null;

    if (RenderUtils.getViewState("selectVigilantsThatAreTeachers") != null) {
        teachersVigilancies = beanWithTeachers.getVigilantsAsString();
        vigilants.addAll(teachers);
    } else {
        teachersVigilancies = RenderUtils.getResourceString("VIGILANCY_RESOURCES", "label.vigilancy.noone");
    }

    vigilants.addAll(unavailables);
    beanWithVigilants.setVigilants(vigilants);

    String email = RenderUtils.getResourceString("VIGILANCY_RESOURCES", "label.vigilancy.emailConvoke");
    MessageFormat format = new MessageFormat(email);
    WrittenEvaluation evaluation = beanWithVigilants.getWrittenEvaluation();
    DateTime beginDate = evaluation.getBeginningDateTime();
    String date = beginDate.getDayOfMonth() + "/" + beginDate.getMonthOfYear() + "/" + beginDate.getYear();

    String minutes = String.format("%02d", new Object[] { beginDate.getMinuteOfHour() });

    Object[] args = { evaluation.getFullName(), date, beginDate.getHourOfDay(), minutes,
            beanWithVigilants.getRoomsAsString(), teachersVigilancies, convokedVigilants,
            beanWithVigilants.getSelectedVigilantGroup().getRulesLink() };
    beanWithVigilants.setEmailMessage(format.format(args));
    request.setAttribute("bean", beanWithVigilants);
    return mapping.findForward("confirmConvokes");
}

From source file:net.sourceforge.fenixedu.presentationTier.docs.thesis.ThesisJuryReportDocument.java

License:Open Source License

@Override
public void fillGeneric() {
    Thesis thesis = getThesis();//  w  w w .  jav a  2  s .co m
    String discussed;

    if (thesis.getDiscussed() != null) {
        DateTime discussedTime = thesis.getDiscussed();
        discussed = discussedTime.getDayOfMonth() + " / " + discussedTime.getMonthOfYear() + " / "
                + discussedTime.getYear();
    } else {
        discussed = EMPTY_STR;
    }

    addParameter("date", discussed);
    addParameter("grade", neverNull(getThesis().getMark()));
}

From source file:net.sourceforge.fenixedu.presentationTier.TagLib.GanttDiagramTagLib.java

License:Open Source License

private StringBuilder generateGanttDiagramInTimeMode(BigDecimal tableWidth) throws JspException {
    StringBuilder builder = new StringBuilder();

    if (!getEvents().isEmpty()) {
        if (isShowPeriod() && isShowObservations()) {
            builder.append("<table style=\"width:")
                    .append(tableWidth.add(BigDecimal.valueOf(FIXED_COLUMNS_SIZE_EM)))
                    .append("em;\" class=\"tcalendar thlight\">");
        } else {//from   w  ww . j  ava2s .com
            builder.append("<table class=\"tcalendar thlight\">");
        }

        generateHeaders(builder);

        int numberOfUnits = getNumberOfUnits();

        String selectedEvent = getRequest().getParameter(getEventParameter());
        Object selectedEventObject = getRequest().getAttribute(getEventParameter());

        for (GanttDiagramEvent event : getEvents()) {

            String eventUrl = getRequest().getContextPath() + getEventUrl() + "&amp;" + getEventParameter()
                    + "=" + event.getGanttDiagramEventIdentifier();

            if (event.getGanttDiagramEventUrlAddOns() != null) {
                eventUrl = eventUrl.concat(event.getGanttDiagramEventUrlAddOns());
            }

            final MultiLanguageString diagramEventName = event.getGanttDiagramEventName();
            String eventName = diagramEventName == null ? "" : diagramEventName.getContent();
            String paddingStyle = "padding-left:" + event.getGanttDiagramEventOffset() * PADDING_LEFT_MULTIPLIER
                    + "px";

            if (event.getGanttDiagramEventIdentifier().equals(selectedEvent) || (selectedEventObject != null
                    && event.getGanttDiagramEventIdentifier().equals(selectedEventObject.toString()))) {
                builder.append("<tr class=\"selected\">");
            } else {
                builder.append("<tr>");
            }

            if (getViewTypeEnum() == ViewType.YEAR_DAILY) {
                builder.append("<td class=\"padded\">").append("<div class=\"nowrap\">");
                builder.append("<span style=\"").append(paddingStyle).append("\" title=\"").append(eventName)
                        .append("\">");
                builder.append("<a href=\"").append(eventUrl).append("&amp;month=")
                        .append(Month.values()[event.getGanttDiagramEventMonth() - 1].toString()).append("\">")
                        .append(eventName);
            } else {
                builder.append("<td class=\"padded\">")
                        .append("<div style=\"overflow:hidden; width: 14.5em;\" class=\"nowrap\">");
                builder.append("<span style=\"").append(paddingStyle).append("\" title=\"").append(eventName)
                        .append("\">");
                builder.append("<a href=\"").append(eventUrl).append("\">").append(eventName);
            }
            builder.append("</a></span></div></td>");

            for (DateTime day : getGanttDiagramObject().getDays()) {

                int startIndex = 0, endIndex = 0;
                int dayOfMonth = day.getDayOfMonth();
                int monthOfYear = day.getMonthOfYear();
                if (getViewTypeEnum() == ViewType.YEAR_DAILY) {
                    monthOfYear = event.getGanttDiagramEventMonth();
                }
                int year = day.getYear();
                YearMonthDay yearMonthDay = new YearMonthDay(year, monthOfYear, 1);

                isEventToMarkWeekendsAndHolidays = event.isGanttDiagramEventToMarkWeekendsAndHolidays();

                if (!isEventToMarkWeekendsAndHolidays) {
                    builder.append("<td style=\"width: ").append(convertToEm(numberOfUnits))
                            .append("em;\"><div style=\"position: relative;\">");
                }

                if (getViewTypeEnum() == ViewType.YEAR_DAILY) {
                    if (dayOfMonth > yearMonthDay.plusMonths(1).minusDays(1).getDayOfMonth()) {
                        addEmptyDiv(builder);
                        builder.append("</div></td>");
                        continue;
                    }
                }

                specialDiv = false;

                for (Interval interval : event.getGanttDiagramEventSortedIntervals()) {

                    toWrite = null;
                    toMark = true;
                    LocalDate localDate = yearMonthDay.withDayOfMonth(dayOfMonth).toLocalDate();
                    if ((event.getGanttDiagramEventDayType(interval) == DayType.SPECIFIC_DAYS)
                            || (event.getGanttDiagramEventDayType(interval) == DayType.WORKDAY)) {
                        if ((localDate.getDayOfWeek() == SATURDAY_IN_JODA_TIME)
                                || (localDate.getDayOfWeek() == SUNDAY_IN_JODA_TIME)
                                || (Holiday.isHoliday(localDate))) {
                            toMark = false;
                        }
                    }
                    if (isEventToMarkWeekendsAndHolidays) {
                        if (Holiday.isHoliday(localDate)) {
                            toWrite = F;
                        } else if (localDate.getDayOfWeek() == SATURDAY_IN_JODA_TIME) {
                            toWrite = S;
                        } else if (localDate.getDayOfWeek() == SUNDAY_IN_JODA_TIME) {
                            toWrite = D;
                        }
                    }

                    if (interval.getStart().getYear() <= year && interval.getEnd().getYear() >= year) {

                        if (interval.getStart().getYear() < year && interval.getEnd().getYear() > year) {
                            addSpecialDiv(builder, convertToEm(numberOfUnits), EMPTY_UNIT);
                        }
                        // Started in same year and Ended after
                        else if (interval.getStart().getYear() == year && interval.getEnd().getYear() > year) {

                            if (interval.getStart().getMonthOfYear() < monthOfYear) {
                                addSpecialDiv(builder, convertToEm(numberOfUnits), EMPTY_UNIT);

                            } else if (interval.getStart().getMonthOfYear() == monthOfYear) {

                                if (interval.getStart().getDayOfMonth() == dayOfMonth) {
                                    startIndex = calculateTimeOfDay(interval.getStart());
                                    addSpecialDiv(builder, convertToEm(numberOfUnits - (startIndex - 1)),
                                            convertToEm(startIndex - 1));

                                } else if (interval.getStart().getDayOfMonth() < dayOfMonth) {
                                    addSpecialDiv(builder, convertToEm(numberOfUnits), EMPTY_UNIT);
                                }
                            }
                        }
                        // Ended in same year and started before
                        else if (interval.getStart().getYear() < year && interval.getEnd().getYear() == year) {

                            if (interval.getEnd().getMonthOfYear() > monthOfYear) {
                                addSpecialDiv(builder, convertToEm(numberOfUnits), EMPTY_UNIT);

                            } else if (interval.getEnd().getMonthOfYear() == monthOfYear) {

                                if (interval.getEnd().getDayOfMonth() > dayOfMonth) {
                                    addSpecialDiv(builder, convertToEm(numberOfUnits), EMPTY_UNIT);

                                } else if (interval.getEnd().getDayOfMonth() == dayOfMonth) {
                                    endIndex = calculateTimeOfDay(interval.getEnd());
                                    addSpecialDiv(builder, convertToEm(endIndex), EMPTY_UNIT);
                                }
                            }
                        }
                        // Ended and Started In Same Year
                        else if (interval.getStart().getYear() == year && interval.getEnd().getYear() == year) {

                            if (interval.getStart().getMonthOfYear() <= monthOfYear
                                    && interval.getEnd().getMonthOfYear() >= monthOfYear) {

                                if (interval.getStart().getMonthOfYear() == monthOfYear
                                        && interval.getEnd().getMonthOfYear() > monthOfYear) {

                                    if (interval.getStart().getDayOfMonth() == dayOfMonth) {
                                        startIndex = calculateTimeOfDay(interval.getStart());
                                        addSpecialDiv(builder, convertToEm(numberOfUnits - (startIndex - 1)),
                                                convertToEm(startIndex - 1));

                                    } else if (interval.getStart().getDayOfMonth() < dayOfMonth) {
                                        addSpecialDiv(builder, convertToEm(numberOfUnits), EMPTY_UNIT);
                                    }

                                } else if (interval.getStart().getMonthOfYear() < monthOfYear
                                        && interval.getEnd().getMonthOfYear() == monthOfYear) {

                                    if (interval.getEnd().getDayOfMonth() > dayOfMonth) {
                                        addSpecialDiv(builder, convertToEm(numberOfUnits), EMPTY_UNIT);

                                    } else if (interval.getEnd().getDayOfMonth() == dayOfMonth) {
                                        endIndex = calculateTimeOfDay(interval.getEnd());
                                        addSpecialDiv(builder, convertToEm(endIndex), EMPTY_UNIT);
                                    }

                                } else if (interval.getStart().getMonthOfYear() < monthOfYear
                                        && interval.getEnd().getMonthOfYear() > monthOfYear) {
                                    addSpecialDiv(builder, convertToEm(numberOfUnits), EMPTY_UNIT);

                                } else if (interval.getStart().getMonthOfYear() == monthOfYear
                                        && interval.getEnd().getMonthOfYear() == monthOfYear) {

                                    if (interval.getStart().getDayOfMonth() <= dayOfMonth
                                            && interval.getEnd().getDayOfMonth() >= dayOfMonth) {

                                        if (event.isGanttDiagramEventIntervalsLongerThanOneDay()
                                                && (interval.getStart().getDayOfMonth() == dayOfMonth
                                                        || interval.getEnd().getDayOfMonth() > dayOfMonth)) {
                                            startIndex = calculateTimeOfDay(interval.getStart());
                                            addSpecialDiv(builder,
                                                    convertToEm(numberOfUnits - (startIndex - 1)),
                                                    convertToEm(startIndex - 1));
                                        } else if (interval.getStart().getDayOfMonth() == dayOfMonth
                                                && interval.getEnd().getDayOfMonth() > dayOfMonth) {
                                            startIndex = calculateTimeOfDay(interval.getStart());
                                            addSpecialDiv(builder,
                                                    convertToEm(numberOfUnits - (startIndex - 1)),
                                                    convertToEm(startIndex - 1));
                                        }

                                        else if (interval.getStart().getDayOfMonth() < dayOfMonth
                                                && interval.getEnd().getDayOfMonth() == dayOfMonth) {
                                            endIndex = calculateTimeOfDay(interval.getEnd());
                                            addSpecialDiv(builder, convertToEm(endIndex), EMPTY_UNIT);
                                        }

                                        else if (interval.getStart().getDayOfMonth() == dayOfMonth
                                                && interval.getEnd().getDayOfMonth() == dayOfMonth) {

                                            startIndex = calculateTimeOfDay(interval.getStart());
                                            endIndex = calculateTimeOfDay(interval.getEnd());

                                            if (startIndex == endIndex) {
                                                addSpecialDiv(builder, convertToEm(1),
                                                        convertToEm(startIndex - 1));
                                            } else {
                                                addSpecialDiv(builder, convertToEm((endIndex - startIndex) + 1),
                                                        convertToEm(startIndex - 1));
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if (!isEventToMarkWeekendsAndHolidays) {
                    builder.append("</div></td>");
                } else if (!specialDiv) {
                    builder.append("<td class=\"tdnomark\">");
                    if (dayOfMonth <= yearMonthDay.plusMonths(1).minusDays(1).getDayOfMonth()) {
                        LocalDate localDate = yearMonthDay.withDayOfMonth(dayOfMonth).toLocalDate();
                        if (Holiday.isHoliday(localDate)) {
                            builder.append(F);
                        } else if (localDate.getDayOfWeek() == SATURDAY_IN_JODA_TIME) {
                            builder.append("S");
                        } else if (localDate.getDayOfWeek() == SUNDAY_IN_JODA_TIME) {
                            builder.append("D");
                        }
                    }
                    builder.append("</td>");
                }
            }
            if (isShowPeriod()) {
                builder.append("<td class=\"padded smalltxt\" title=\"")
                        .append(event.getGanttDiagramEventPeriod())
                        .append("\"><div style=\"overflow:hidden;\" class=\"nowrap\">")
                        .append(event.getGanttDiagramEventPeriod()).append("</div></td>");
            }
            if (isShowObservations()) {
                builder.append("<td class=\"padded smalltxt\">")
                        .append(event.getGanttDiagramEventObservations()).append("</td>");
            }
            builder.append("</tr>");
        }
        insertNextAndBeforeLinks(builder);
        builder.append("</table>");
    }
    return builder;
}

From source file:net.sourceforge.fenixedu.presentationTier.TagLib.GanttDiagramTagLib.java

License:Open Source License

private StringBuilder generateGanttDiagramInTotalMode(BigDecimal tableWidth) throws JspException {

    StringBuilder builder = new StringBuilder();

    if (!getEvents().isEmpty()) {
        if (isShowPeriod() && isShowObservations()) {
            builder.append("<table style=\"width:")
                    .append(tableWidth.add(BigDecimal.valueOf(FIXED_COLUMNS_SIZE_EM)))
                    .append("em;\" class=\"tcalendar thlight\">");
        } else {// ww  w .ja  va  2  s  .  c om
            builder.append("<table style=\"width:")
                    .append(tableWidth.add(BigDecimal.valueOf(FIXED_COLUMNS_SIZE_EM - 35)))
                    .append("em;\" class=\"tcalendar thlight\">");
        }
        generateHeaders(builder);

        int scale = getScale();

        String selectedEvent = getRequest().getParameter(getEventParameter());
        Object selectedEventObject = getRequest().getAttribute(getEventParameter());

        for (GanttDiagramEvent event : getEvents()) {

            String eventUrl = getRequest().getContextPath() + getEventUrl() + "&amp;" + getEventParameter()
                    + "=" + event.getGanttDiagramEventIdentifier();
            String eventName = event.getGanttDiagramEventName().getContent(getGanttDiagramObject().getLocale());
            String paddingStyle = "padding-left:" + event.getGanttDiagramEventOffset() * PADDING_LEFT_MULTIPLIER
                    + "px";

            if (event.getGanttDiagramEventIdentifier().equals(selectedEvent) || (selectedEventObject != null
                    && event.getGanttDiagramEventIdentifier().equals(selectedEventObject.toString()))) {
                builder.append("<tr class=\"selected\">");
            } else {
                builder.append("<tr>");
            }

            builder.append("<td class=\"padded\">")
                    .append("<div style=\"overflow:hidden; width: 14.5em;\" class=\"nowrap\">");
            builder.append("<span style=\"").append(paddingStyle).append("\" title=\"").append(eventName)
                    .append("\">");
            builder.append("<a href=\"").append(eventUrl).append("\">").append("*").append(eventName);
            builder.append("</a></span></div></td>");

            for (DateTime month : getGanttDiagramObject().getMonths()) {

                DateTime firstDayOfMonth = (month.getDayOfMonth() != 1) ? month.withDayOfMonth(1) : month;
                DateTime lastDayOfMonth = firstDayOfMonth.plusMonths(1).minusDays(1);
                int monthNumberOfDays = Days.daysBetween(firstDayOfMonth, lastDayOfMonth).getDays() + 1;
                BigDecimal entryDays = EMPTY_UNIT, startDay = EMPTY_UNIT;

                builder.append("<td style=\"width: ").append(convertToEm(monthNumberOfDays * scale))
                        .append("em;\"><div style=\"position: relative;\">");

                for (Interval interval : event.getGanttDiagramEventSortedIntervals()) {

                    DateMidnight intervalStart = interval.getStart().toDateMidnight();
                    DateMidnight intervalEnd = interval.getEnd().toDateMidnight();

                    // Started in this month
                    if (intervalStart.getMonthOfYear() == month.getMonthOfYear()
                            && intervalStart.getYear() == month.getYear()) {

                        // Ended in this month
                        if (interval.getEnd().getMonthOfYear() == month.getMonthOfYear()
                                && intervalEnd.getYear() == month.getYear()) {

                            // Started in first day of this month
                            if (intervalStart.getDayOfMonth() == 1) {

                                // Ended in the last day of this month
                                if (intervalEnd.getDayOfMonth() == monthNumberOfDays) {
                                    entryDays = convertToEm(
                                            (Days.daysBetween(intervalStart, lastDayOfMonth).getDays() + 1)
                                                    * scale);
                                    startDay = convertToEm((intervalStart.getDayOfMonth() - 1) * scale);
                                    addSpecialDiv(builder, entryDays, startDay);
                                }

                                // Ended before last day of this month
                                else {
                                    entryDays = convertToEm(
                                            (Days.daysBetween(intervalStart, intervalEnd).getDays() + 1)
                                                    * scale);
                                    startDay = convertToEm((intervalStart.getDayOfMonth() - 1) * scale);
                                    addSpecialDiv(builder, entryDays, startDay);
                                }
                            }

                            // Started after first day of this month
                            else {

                                // Ended in the last day of this month
                                if (intervalEnd.getDayOfMonth() == monthNumberOfDays) {
                                    entryDays = convertToEm(
                                            (Days.daysBetween(intervalStart, lastDayOfMonth).getDays() + 1)
                                                    * scale);
                                    startDay = convertToEm((intervalStart.getDayOfMonth() - 1) * scale);
                                    addSpecialDiv(builder, entryDays, startDay);
                                }

                                // Ended before last day of this month
                                else {
                                    entryDays = convertToEm(
                                            (Days.daysBetween(intervalStart, intervalEnd).getDays() + 1)
                                                    * scale);
                                    startDay = convertToEm((intervalStart.getDayOfMonth() - 1) * scale);
                                    addSpecialDiv(builder, entryDays, startDay);
                                }
                            }
                        }

                        // Ended after this month
                        else {
                            entryDays = convertToEm(
                                    (Days.daysBetween(intervalStart, lastDayOfMonth).getDays() + 1) * scale);
                            startDay = convertToEm((intervalStart.getDayOfMonth() - 1) * scale);
                            addSpecialDiv(builder, entryDays, startDay);
                        }

                        // Not Started in this month
                    } else {

                        // Started before this month
                        if (intervalStart.getYear() < month.getYear()
                                || (intervalStart.getYear() == month.getYear()
                                        && intervalStart.getMonthOfYear() < month.getMonthOfYear())) {

                            // Ended after this month
                            if (intervalEnd.getYear() > month.getYear()
                                    || (intervalEnd.getYear() == month.getYear()
                                            && intervalEnd.getMonthOfYear() > month.getMonthOfYear())) {

                                entryDays = convertToEm(
                                        (Days.daysBetween(firstDayOfMonth, lastDayOfMonth).getDays() + 1)
                                                * scale);
                                startDay = convertToEm((firstDayOfMonth.getDayOfMonth() - 1) * scale);
                                addSpecialDiv(builder, entryDays, startDay);
                            } else {

                                // Ended in this month
                                if (intervalEnd.getMonthOfYear() == month.getMonthOfYear()
                                        && intervalEnd.getYear() == month.getYear()) {
                                    entryDays = convertToEm(
                                            (Days.daysBetween(firstDayOfMonth, intervalEnd).getDays() + 1)
                                                    * scale);
                                    startDay = convertToEm((firstDayOfMonth.getDayOfMonth() - 1) * scale);
                                    addSpecialDiv(builder, entryDays, startDay);
                                }
                            }
                        }
                    }
                }
                builder.append("</div></td>");
            }
            if (isShowPeriod()) {
                builder.append("<td class=\"padded smalltxt\" title=\"")
                        .append(event.getGanttDiagramEventPeriod())
                        .append("\"><div style=\"overflow:hidden;\" class=\"nowrap\">")
                        .append(event.getGanttDiagramEventPeriod()).append("</div></td>");
            }
            if (isShowObservations()) {
                builder.append("<td class=\"padded smalltxt\">")
                        .append(event.getGanttDiagramEventObservations()).append("</td>");
            }
            builder.append("</tr>");
        }

        insertNextAndBeforeLinks(builder);
        builder.append("</table>");
    }
    return builder;
}