Example usage for org.joda.time Partial Partial

List of usage examples for org.joda.time Partial Partial

Introduction

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

Prototype

Partial(Partial partial, int[] values) 

Source Link

Document

Constructs a Partial with the specified values.

Usage

From source file:net.sourceforge.fenixedu.applicationTier.Servico.coordinator.tutor.ChangeTutorship.java

License:Open Source License

public List<TutorshipErrorBean> run(String executionDegreeID, List<ChangeTutorshipBean> beans)
        throws FenixServiceException {

    final ExecutionDegree executionDegree = FenixFramework.getDomainObject(executionDegreeID);
    final DegreeCurricularPlan degreeCurricularPlan = executionDegree.getDegreeCurricularPlan();

    List<TutorshipErrorBean> studentsWithErrors = new ArrayList<TutorshipErrorBean>();

    for (ChangeTutorshipBean bean : beans) {
        Tutorship tutorship = bean.getTutorship();

        Partial newTutorshipEndDate = new Partial(
                new DateTimeFieldType[] { DateTimeFieldType.year(), DateTimeFieldType.monthOfYear() },
                new int[] { bean.getTutorshipEndYear(), bean.getTutorshipEndMonth().getNumberOfMonth() });

        if (tutorship.getEndDate() != null && tutorship.getEndDate().isEqual(newTutorshipEndDate)) {
            continue;
        }//w w  w  .j  a  v  a  2s  . co  m

        Registration registration = tutorship.getStudentCurricularPlan().getRegistration();
        Integer studentNumber = registration.getNumber();

        try {
            validateStudentRegistration(registration, executionDegree, degreeCurricularPlan, studentNumber);

            tutorship.setEndDate(newTutorshipEndDate);

        } catch (FenixServiceException ex) {
            studentsWithErrors.add(new TutorshipErrorBean(ex.getMessage(), ex.getArgs()));
        }
    }

    return studentsWithErrors;
}

From source file:net.sourceforge.fenixedu.dataTransferObject.manager.academicCalendarManagement.CalendarEntryBean.java

License:Open Source License

public static Partial getPartialFromString(String date) {
    Integer month = Integer.valueOf(date.substring(0, 2));
    Integer year = Integer.valueOf(date.substring(2));
    return new Partial(new DateTimeFieldType[] { DateTimeFieldType.year(), DateTimeFieldType.monthOfYear() },
            new int[] { year.intValue(), month.intValue() });
}

From source file:net.sourceforge.fenixedu.dataTransferObject.manager.academicCalendarManagement.CalendarEntryBean.java

License:Open Source License

public static Partial getPartialFromYearMonthDay(YearMonthDay day) {
    return new Partial(new DateTimeFieldType[] { DateTimeFieldType.year(), DateTimeFieldType.monthOfYear() },
            new int[] { day.getYear(), day.getMonthOfYear() });
}

From source file:net.sourceforge.fenixedu.dataTransferObject.spaceManager.ViewEventSpaceOccupationsBean.java

License:Open Source License

public ViewEventSpaceOccupationsBean(YearMonthDay day, Space allocatableSpace) {

    setAllocatableSpace(allocatableSpace);

    if (day != null) {
        setYear(new Partial(DateTimeFieldType.year(), day.getYear()));
        setMonth(new Partial(DateTimeFieldType.monthOfYear(), day.getMonthOfYear()));

        YearMonthDay monday = day.toDateTimeAtMidnight().withDayOfWeek(MONDAY_IN_JODA_TIME).toYearMonthDay();
        if ((monday.getMonthOfYear() < day.getMonthOfYear()) || (monday.getYear() < day.getYear())) {
            monday = monday.plusDays(Lesson.NUMBER_OF_DAYS_IN_WEEK);
        }//from   ww w . jav a  2s  .c o  m

        setDay(monday);
    }
}

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

License:Open Source License

public Holiday(final HolidayFactoryCreator creator) {
    this();//  w  ww  .  j  a v a 2 s . c  o m

    final List<DateTimeFieldType> dateTimeFieldTypes = new ArrayList<DateTimeFieldType>();
    final List<Integer> dateTimeFieldValues = new ArrayList<Integer>();
    if (creator.getYear() != null) {
        dateTimeFieldTypes.add(DateTimeFieldType.year());
        dateTimeFieldValues.add(creator.getYear());
    }
    if (creator.getMonthOfYear() != null) {
        dateTimeFieldTypes.add(DateTimeFieldType.monthOfYear());
        dateTimeFieldValues.add(creator.getMonthOfYear());
    }
    if (creator.getDayOfMonth() != null) {
        dateTimeFieldTypes.add(DateTimeFieldType.dayOfMonth());
        dateTimeFieldValues.add(creator.getDayOfMonth());
    }

    final DateTimeFieldType[] dateTimeFieldTypesArray = new DateTimeFieldType[dateTimeFieldTypes.size()];
    final int[] dateTimeFieldValuesArray = new int[dateTimeFieldValues.size()];
    for (int i = 0; i < dateTimeFieldTypes.size(); i++) {
        dateTimeFieldTypesArray[i] = dateTimeFieldTypes.get(i);
        dateTimeFieldValuesArray[i] = dateTimeFieldValues.get(i).intValue();
    }
    final Partial partial = new Partial(dateTimeFieldTypesArray, dateTimeFieldValuesArray);

    setDate(partial);
    setLocality(creator.getLocality());
}

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

License:Open Source License

public static void createTutorship(Teacher teacher, StudentCurricularPlan scp, Integer endMonth,
        Integer endYear) {//from  www. j  a  v a2 s  .  c o  m
    LocalDate currentDate = new LocalDate();

    Partial tutorshipStartDate = new Partial(
            new DateTimeFieldType[] { DateTimeFieldType.year(), DateTimeFieldType.monthOfYear() },
            new int[] { currentDate.year().get(), currentDate.monthOfYear().get() });

    Partial tutorshipEndDate = new Partial(
            new DateTimeFieldType[] { DateTimeFieldType.year(), DateTimeFieldType.monthOfYear() },
            new int[] { endYear, endMonth });
    Tutorship tutorship = new Tutorship(teacher, tutorshipStartDate, tutorshipEndDate, scp);

    TutorshipLog tutorshipLog = new TutorshipLog();
    if (scp.getRegistration() != null && scp.getRegistration().getStudentCandidacy() != null
            && scp.getRegistration().getStudentCandidacy().getPlacingOption() != null) {
        switch (scp.getRegistration().getStudentCandidacy().getPlacingOption()) {
        case 1: {
            tutorshipLog.setOptionNumberDegree(Option.ONE);
            break;
        }
        case 2: {
            tutorshipLog.setOptionNumberDegree(Option.TWO);
            break;
        }
        case 3: {
            tutorshipLog.setOptionNumberDegree(Option.THREE);
            break;
        }
        case 4: {
            tutorshipLog.setOptionNumberDegree(Option.FOUR);
            break;
        }
        case 5: {
            tutorshipLog.setOptionNumberDegree(Option.FIVE);
            break;
        }
        case 6: {
            tutorshipLog.setOptionNumberDegree(Option.SIX);
            break;
        }
        default: {
            tutorshipLog.setOptionNumberDegree(null);
        }
        }
    }
    tutorship.setTutorshipLog(tutorshipLog);
}

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

License:Open Source License

public boolean isActive() {
    if (!getStudent().isActive()) {
        return false;
    }//from  w w  w .jav a  2s .  co m
    if (!this.hasEndDate()) {
        return false;
    }

    YearMonthDay currentYearMonthDay = new YearMonthDay();
    Partial currentDate = new Partial(
            new DateTimeFieldType[] { DateTimeFieldType.year(), DateTimeFieldType.monthOfYear() },
            new int[] { currentYearMonthDay.year().get(), currentYearMonthDay.monthOfYear().get() });

    if (getEndDate().isAfter(currentDate)) {
        return true;
    }

    return false;
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.teacher.SummariesManagementDA.java

License:Open Source License

public ActionForward prepareEditSummary(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws FenixServiceException {

    Professorship teacherLogged = ((Professorship) request.getAttribute("loggedTeacherProfessorship"));
    DynaActionForm dynaActionForm = (DynaActionForm) form;
    Summary summary = getSummaryFromParameter(request);

    SummaryType summaryType;//from w ww.j  a va2s  . c  o  m
    if (summary.isExtraSummary()) {
        summaryType = SummaryType.EXTRA_SUMMARY;
        request.setAttribute("notShowLessonPlanningsAndSummaries", Boolean.TRUE);
    } else {
        summaryType = SummaryType.NORMAL_SUMMARY;
    }

    DateTimeFieldType[] dateTimeFieldTypes = { DateTimeFieldType.hourOfDay(),
            DateTimeFieldType.minuteOfHour() };
    HourMinuteSecond time = summary.getSummaryHourHourMinuteSecond();
    int[] timeArray = { time.getHour(), time.getMinuteOfHour() };
    Partial timePartial = new Partial(dateTimeFieldTypes, timeArray);

    SummariesManagementBean bean = new SummariesManagementBean(summary.getTitle(), summary.getSummaryText(),
            summary.getStudentsNumber(), summaryType, summary.getProfessorship(), summary.getTeacherName(),
            summary.getTeacher(), summary.getShift(), summary.getLesson(), summary.getSummaryDateYearMonthDay(),
            summary.getRoom(), timePartial, summary, teacherLogged, summary.getSummaryType(),
            summary.getTaught());

    return goToSummaryManagementPageAgain(mapping, request, dynaActionForm, bean);
}

From source file:net.sourceforge.fenixedu.presentationTier.renderers.providers.MonthsPartialProvider.java

License:Open Source License

@Override
public Object provide(Object source, Object currentValue) {
    List<Partial> result = new ArrayList<Partial>();
    for (int i = 1; i <= 12; i++) {
        result.add(new Partial(DateTimeFieldType.monthOfYear(), i));
    }//from w  w  w. j av  a  2  s  .  c o  m
    return result;
}

From source file:net.sourceforge.fenixedu.presentationTier.renderers.providers.YearsPartialProvider.java

License:Open Source License

@Override
public Object provide(Object source, Object currentValue) {

    List<Partial> result = new ArrayList<Partial>();
    ExecutionYear firstExecutionYear = ExecutionYear.readFirstExecutionYear();

    if (firstExecutionYear != null) {
        ExecutionYear currentExecutionYear = ExecutionYear.readCurrentExecutionYear();
        int firstYear = firstExecutionYear.getBeginDateYearMonthDay().getYear();
        int lastYear = currentExecutionYear.getEndDateYearMonthDay().getYear();
        while (firstYear <= lastYear) {
            result.add(new Partial(DateTimeFieldType.year(), firstYear));
            firstYear++;//from   www  .j  a va 2 s.com
        }
    }

    return result;
}