List of usage examples for org.joda.time YearMonthDay compareTo
public int compareTo(ReadablePartial other)
From source file:net.sourceforge.fenixedu.domain.student.Registration.java
License:Open Source License
final public YearMonthDay getLastApprovedEnrolmentEvaluationDate() { final SortedSet<Enrolment> enrolments = new TreeSet<Enrolment>( Enrolment.COMPARATOR_BY_LATEST_ENROLMENT_EVALUATION_AND_ID); enrolments.addAll(getApprovedEnrolments()); YearMonthDay internalEnrolmentExamDate = enrolments.isEmpty() ? null : enrolments.last().getLatestEnrolmentEvaluation().getExamDateYearMonthDay(); YearMonthDay externalEnrolmentExamDate = getExternalEnrolmentsSet().isEmpty() ? null : getLastExternalApprovedEnrolmentEvaluationDate(); if (internalEnrolmentExamDate == null && externalEnrolmentExamDate == null) { return null; }/*from w w w.ja v a 2s .co m*/ if (internalEnrolmentExamDate == null) { return externalEnrolmentExamDate; } if (externalEnrolmentExamDate == null) { return internalEnrolmentExamDate; } return internalEnrolmentExamDate.compareTo(externalEnrolmentExamDate) > 1 ? internalEnrolmentExamDate : externalEnrolmentExamDate; }
From source file:pt.ist.fenix.task.exportData.santanderCardGeneration.SantanderBatchFillerWorker.java
License:Open Source License
private Degree getDegree(SantanderBatch batch, Person person) { final Student student = person.getStudent(); if (student == null) { return null; }/* ww w .j av a2 s . co m*/ final DateTime begin = batch.getExecutionYear().getBeginDateYearMonthDay().toDateTimeAtMidnight(); final DateTime end = batch.getExecutionYear().getEndDateYearMonthDay().toDateTimeAtMidnight(); final Set<StudentCurricularPlan> studentCurricularPlans = new HashSet<StudentCurricularPlan>(); StudentCurricularPlan pickedSCP; for (final Registration registration : student.getRegistrationsSet()) { if (!registration.isActive()) { continue; } if (registration.getDegree().isEmpty()) { continue; } final RegistrationProtocol registrationAgreement = registration.getRegistrationProtocol(); if (!registrationAgreement.allowsIDCard()) { continue; } final DegreeType degreeType = registration.getDegreeType(); if (!degreeType.isBolonhaType()) { continue; } for (final StudentCurricularPlan studentCurricularPlan : registration.getStudentCurricularPlansSet()) { if (studentCurricularPlan.isActive()) { if (degreeType == DegreeType.BOLONHA_DEGREE || degreeType == DegreeType.BOLONHA_MASTER_DEGREE || degreeType == DegreeType.BOLONHA_INTEGRATED_MASTER_DEGREE || degreeType == DegreeType.BOLONHA_ADVANCED_SPECIALIZATION_DIPLOMA) { studentCurricularPlans.add(studentCurricularPlan); } else { final RegistrationState registrationState = registration.getActiveState(); if (registrationState != null) { final DateTime dateTime = registrationState.getStateDate(); if (!dateTime.isBefore(begin) && !dateTime.isAfter(end)) { studentCurricularPlans.add(studentCurricularPlan); } } } } } } if (studentCurricularPlans.isEmpty()) { return null; } pickedSCP = Collections.max(studentCurricularPlans, new Comparator<StudentCurricularPlan>() { @Override public int compare(final StudentCurricularPlan o1, final StudentCurricularPlan o2) { final DegreeType degreeType1 = o1.getDegreeType(); final DegreeType degreeType2 = o2.getDegreeType(); if (degreeType1 == degreeType2) { final YearMonthDay yearMonthDay1 = o1.getStartDateYearMonthDay(); final YearMonthDay yearMonthDay2 = o2.getStartDateYearMonthDay(); final int c = yearMonthDay1.compareTo(yearMonthDay2); return c == 0 ? o1.getExternalId().compareTo(o2.getExternalId()) : c; } else { return degreeType1.compareTo(degreeType2); } } }); return pickedSCP.getRegistration().getDegree(); // final String degreeNameForIdCard = degree.getIdCardName(); // if (degreeNameForIdCard == null || degreeNameForIdCard.isEmpty()) { // throw new Error("No degree name for id card specified."); // } // if (degreeNameForIdCard.length() > 50) { // throw new Error("Length of degree name for id card to long: " + degreeNameForIdCard + " has more than 50 characters."); // } // return degreeNameForIdCard; //return pickedSCP.getRegistration().getDegree().getSigla(); }
From source file:pt.ist.fenix.ui.struts.action.koha.ExportUserInfoForKoha.java
License:Open Source License
private static StudentCurricularPlan findMaxStudentCurricularPlan( final Set<StudentCurricularPlan> studentCurricularPlans) { return Collections.max(studentCurricularPlans, new Comparator<StudentCurricularPlan>() { @Override/*from w w w .j a v a 2 s . c o m*/ public int compare(final StudentCurricularPlan o1, final StudentCurricularPlan o2) { final DegreeType degreeType1 = o1.getDegreeType(); final DegreeType degreeType2 = o2.getDegreeType(); if (degreeType1 == degreeType2) { final YearMonthDay yearMonthDay1 = o1.getStartDateYearMonthDay(); final YearMonthDay yearMonthDay2 = o2.getStartDateYearMonthDay(); final int c = yearMonthDay1.compareTo(yearMonthDay2); return c == 0 ? DomainObjectUtil.COMPARATOR_BY_ID.compare(o1, o2) : c; } else { return degreeType1.compareTo(degreeType2); } } }); }
From source file:pt.ist.fenixedu.integration.task.exportData.santanderCardGeneration.SantanderBatchFillerWorker.java
License:Open Source License
private Degree getDegree(SantanderBatch batch, Person person) { final Student student = person.getStudent(); if (student == null) { return null; }//from ww w . j a v a2s. c om final DateTime begin = batch.getExecutionYear().getBeginDateYearMonthDay().toDateTimeAtMidnight(); final DateTime end = batch.getExecutionYear().getEndDateYearMonthDay().toDateTimeAtMidnight(); final Set<StudentCurricularPlan> studentCurricularPlans = new HashSet<StudentCurricularPlan>(); StudentCurricularPlan pickedSCP; for (final Registration registration : student.getRegistrationsSet()) { if (!registration.isActive()) { continue; } if (registration.getDegree().isEmpty()) { continue; } final RegistrationProtocol registrationAgreement = registration.getRegistrationProtocol(); if (!registrationAgreement.allowsIDCard()) { continue; } final DegreeType degreeType = registration.getDegreeType(); if (!degreeType.isBolonhaType()) { continue; } for (final StudentCurricularPlan studentCurricularPlan : registration.getStudentCurricularPlansSet()) { if (studentCurricularPlan.isActive()) { if (degreeType.isBolonhaDegree() || degreeType.isBolonhaMasterDegree() || degreeType.isIntegratedMasterDegree() || degreeType.isAdvancedSpecializationDiploma()) { studentCurricularPlans.add(studentCurricularPlan); } else { final RegistrationState registrationState = registration.getActiveState(); if (registrationState != null) { final DateTime dateTime = registrationState.getStateDate(); if (!dateTime.isBefore(begin) && !dateTime.isAfter(end)) { studentCurricularPlans.add(studentCurricularPlan); } } } } } } if (studentCurricularPlans.isEmpty()) { return null; } pickedSCP = Collections.max(studentCurricularPlans, new Comparator<StudentCurricularPlan>() { @Override public int compare(final StudentCurricularPlan o1, final StudentCurricularPlan o2) { final DegreeType degreeType1 = o1.getDegreeType(); final DegreeType degreeType2 = o2.getDegreeType(); if (degreeType1 == degreeType2) { final YearMonthDay yearMonthDay1 = o1.getStartDateYearMonthDay(); final YearMonthDay yearMonthDay2 = o2.getStartDateYearMonthDay(); final int c = yearMonthDay1.compareTo(yearMonthDay2); return c == 0 ? o1.getExternalId().compareTo(o2.getExternalId()) : c; } else { return degreeType1.compareTo(degreeType2); } } }); return pickedSCP.getRegistration().getDegree(); // final String degreeNameForIdCard = degree.getIdCardName(); // if (degreeNameForIdCard == null || degreeNameForIdCard.isEmpty()) { // throw new Error("No degree name for id card specified."); // } // if (degreeNameForIdCard.length() > 50) { // throw new Error("Length of degree name for id card to long: " + degreeNameForIdCard + " has more than 50 characters."); // } // return degreeNameForIdCard; //return pickedSCP.getRegistration().getDegree().getSigla(); }