Example usage for org.joda.time YearMonthDay plusYears

List of usage examples for org.joda.time YearMonthDay plusYears

Introduction

In this page you can find the example usage for org.joda.time YearMonthDay plusYears.

Prototype

public YearMonthDay plusYears(int years) 

Source Link

Document

Returns a copy of this date plus the specified number of years.

Usage

From source file:net.sourceforge.fenixedu.domain.student.Student.java

License:Open Source License

public String readActiveStudentInfoForJobBank() {
    ExecutionYear currentExecutionYear = ExecutionYear.readCurrentExecutionYear();
    ExecutionYear previousExecutionYear = currentExecutionYear.getPreviousExecutionYear();
    Set<Registration> registrations = new HashSet<Registration>();
    LocalDate today = new LocalDate();
    for (Registration registration : getRegistrationsSet()) {
        if (registration.isBolonha() && !registration.getDegreeType().equals(DegreeType.EMPTY)) {
            if (registration.hasAnyActiveState(currentExecutionYear)) {
                registrations.add(registration);
            } else {
                RegistrationConclusionBean registrationConclusionBean = new RegistrationConclusionBean(
                        registration);/* w ww  .  j av  a 2 s . c o  m*/
                if (registrationConclusionBean.isConcluded()) {
                    YearMonthDay conclusionDate = registrationConclusionBean.getConclusionDate();
                    if (conclusionDate != null && !conclusionDate.plusYears(1).isBefore(today)) {
                        registrations.add(registration);
                    }
                }
            }
        }
    }
    return getRegistrationsAsJSON(registrations);
}

From source file:net.sourceforge.fenixedu.webServices.jersey.services.JerseyServices.java

License:Open Source License

@GET
@Produces(MediaType.APPLICATION_JSON)// w  ww.  j  a  va 2s  .com
@Path("readActiveStudentInfoForJobBank")
public static String readActiveStudentInfoForJobBank(@QueryParam("username") final String username) {
    final Student student = Person.readPersonByUsername(username).getStudent();
    ExecutionYear currentExecutionYear = ExecutionYear.readCurrentExecutionYear();
    Set<Registration> registrations = new HashSet<Registration>();
    LocalDate today = new LocalDate();
    for (Registration registration : student.getRegistrationsSet()) {
        if (registration.isBolonha() && !registration.getDegreeType().equals(DegreeType.EMPTY)) {
            if (registration.hasAnyActiveState(currentExecutionYear)) {
                registrations.add(registration);
            } else {
                RegistrationConclusionBean registrationConclusionBean = new RegistrationConclusionBean(
                        registration);
                if (registrationConclusionBean.isConcluded()) {
                    YearMonthDay conclusionDate = registrationConclusionBean.getConclusionDate();
                    if (conclusionDate != null && !conclusionDate.plusYears(1).isBefore(today)) {
                        registrations.add(registration);
                    }
                }
            }
        }
    }
    String info = getRegistrationsAsJSON(registrations);
    return student != null ? info : StringUtils.EMPTY;
}

From source file:pt.ist.fenixedu.integration.api.JerseyServices.java

License:Open Source License

@GET
@Produces(MediaType.APPLICATION_JSON)/*from  w ww  .j  a  va  2 s.c om*/
@Path("readActiveStudentInfoForJobBank")
public static String readActiveStudentInfoForJobBank(@QueryParam("username") final String username) {
    final Student student = Person.readPersonByUsername(username).getStudent();
    ExecutionYear currentExecutionYear = ExecutionYear.readCurrentExecutionYear();
    Set<Registration> registrations = new HashSet<Registration>();
    LocalDate today = new LocalDate();
    for (Registration registration : student.getRegistrationsSet()) {
        if (registration.isBolonha() && !registration.getDegreeType().isEmpty()) {
            if (registration.hasAnyActiveState(currentExecutionYear)) {
                registrations.add(registration);
            } else {
                ProgramConclusion.conclusionsFor(registration).forEach(programConclusion -> {
                    RegistrationConclusionBean registrationConclusionBean = new RegistrationConclusionBean(
                            registration, programConclusion);
                    if (registrationConclusionBean.isConcluded()) {
                        YearMonthDay conclusionDate = registrationConclusionBean.getConclusionDate();
                        if (conclusionDate != null && !conclusionDate.plusYears(1).isBefore(today)) {
                            registrations.add(registration);
                        }
                    }
                });
            }
        }
    }
    String info = getRegistrationsAsJSON(registrations);
    return student != null ? info : "";
}

From source file:pt.utl.ist.codeGenerator.database.CreateTestData.java

License:Open Source License

private static String constructExecutionYearString() {
    final YearMonthDay yearMonthDay = new YearMonthDay();
    return yearMonthDay.getMonthOfYear() < 8
            ? constructExecutionYearString(yearMonthDay.minusYears(1), yearMonthDay)
            : constructExecutionYearString(yearMonthDay, yearMonthDay.plusYears(1));
}