Example usage for org.joda.time LocalDate toDateTimeAtStartOfDay

List of usage examples for org.joda.time LocalDate toDateTimeAtStartOfDay

Introduction

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

Prototype

public DateTime toDateTimeAtStartOfDay() 

Source Link

Document

Converts this LocalDate to a full datetime at the earliest valid time for the date using the default time zone.

Usage

From source file:org.zilverline.jodatime.FixedDate.java

License:Apache License

public FixedDate(LocalDate fixDateOn) {
    this.fixDateOn = fixDateOn.toDateTimeAtStartOfDay();
}

From source file:org.zkoss.ganttz.DatesMapperOnInterval.java

License:Open Source License

private Fraction getProportion(LocalDate date) {
    return getProportion(date.toDateTimeAtStartOfDay());
}

From source file:org.zkoss.ganttz.timetracker.zoom.TimeTrackerState.java

License:Open Source License

private Collection<DetailItem> createDetails(Interval interval, Iterator<LocalDate> datesGenerator,
        IDetailItemCreator detailItemCreator) {

    List<DetailItem> result = new ArrayList<>();
    LocalDate current = interval.getStart();
    LocalDate end = interval.getFinish();

    while (current.isBefore(end)) {
        result.add(detailItemCreator.create(current.toDateTimeAtStartOfDay()));
        assert datesGenerator.hasNext();
        current = datesGenerator.next();
    }/*  w  ww .j a  va  2s.co  m*/

    return result;
}

From source file:org.zkoss.ganttz.timetracker.zoom.TimeTrackerState.java

License:Open Source License

private Interval calculateForAtLeastMinimum(Interval atLeastMinimum) {
    LocalDate start = round(atLeastMinimum.getStart(), true);
    LocalDate finish = round(atLeastMinimum.getFinish(), false);

    return new Interval(start.toDateTimeAtStartOfDay().toDate(), finish.toDateTimeAtStartOfDay().toDate());
}

From source file:Parsers.ExcelParser.java

License:Open Source License

public void convertToNetwork() throws IOException, InvalidFormatException {

    container = MyFileImporter.container;
    container.setEdgeDefault(EdgeDefault.UNDIRECTED);

    //dealing with the case of dynamic networks!!
    if (MyFileImporter.timeField != null) {
        container.setTimeFormat(TimeFormat.DATETIME);
    }//w ww  .  jav a2  s. co m

    AttributeTable atNodes = container.getAttributeModel().getNodeTable();
    //        AttributeColumn acTest = atNodes.addColumn("type", AttributeType.DYNAMIC_BOOLEAN);
    //        NodeDraft nodeDraft = container.factory().newNodeDraft();
    //        nodeDraft.addTimeInterval("2009-03-01", "2009-03-010");
    //        nodeDraft.setId("0");
    //        nodeDraft.setLabel("test");
    //        nodeDraft.addAttributeValue(acTest, true, "2009-03-02", "2009-03-03", true, true);
    //        nodeDraft.addAttributeValue(acTest, true, "2009-03-04", "2009-03-06", true, true);
    //        container.addNode(nodeDraft);

    String firstDelimiter;
    String secondDelimiter;
    firstDelimiter = Utils.getCharacter(MyFileImporter.firstConnectorDelimiter);
    secondDelimiter = Utils.getCharacter(MyFileImporter.secondConnectorDelimiter);
    boolean oneTypeOfAgent = MyFileImporter.getFirstConnectedAgent()
            .equals(MyFileImporter.getSecondConnectedAgent());

    nbColumnFirstAgent = MyFileImporter.firstConnectedAgentIndex;
    nbColumnSecondAgent = MyFileImporter.secondConnectedAgentIndex;

    Integer lineCounter = 0;

    InputStream inp;
    inp = new FileInputStream(fileName);
    Workbook wb = WorkbookFactory.create(inp);

    Row row;
    Sheet sheet = wb.getSheet(sheetName);
    int startingRow;
    if (MyFileImporter.headersPresent) {
        startingRow = 1;
    } else {
        startingRow = 0;
    }
    Set<String> linesFirstAgent = new HashSet();
    Set<String> linesSecondAgent = new HashSet();

    //        Double earliestTime = 1000000000000d;
    //        Double latestTime = 0d;
    String interval;
    for (int i = startingRow; i <= sheet.getLastRowNum(); i++) {
        interval = null;
        row = sheet.getRow(i);
        if (row == null) {
            break;
        }

        Cell cell = row.getCell(nbColumnFirstAgent);
        if (cell == null) {
            Issue issue = new Issue(
                    "problem with line " + lineCounter + " (empty column "
                            + MyFileImporter.getFirstConnectedAgent() + "). It was skipped in the conversion",
                    Issue.Level.WARNING);
            MyFileImporter.getStaticReport().logIssue(issue);
            continue;
        }

        String firstAgent = null;
        switch (cell.getCellType()) {
        case Cell.CELL_TYPE_BOOLEAN:
            break;
        case Cell.CELL_TYPE_NUMERIC:
            firstAgent = String.valueOf(cell.getNumericCellValue());
            break;
        case Cell.CELL_TYPE_STRING:
            firstAgent = cell.getStringCellValue();
            break;
        case Cell.CELL_TYPE_BLANK:
            break;
        case Cell.CELL_TYPE_ERROR:
            break;
        // CELL_TYPE_FORMULA will never occur
        case Cell.CELL_TYPE_FORMULA:
            break;
        }

        if (firstAgent == null || firstAgent.isEmpty()) {
            Issue issue = new Issue(
                    "problem with line " + lineCounter + " (empty column "
                            + MyFileImporter.getFirstConnectedAgent() + "). It was skipped in the conversion",
                    Issue.Level.WARNING);
            MyFileImporter.getStaticReport().logIssue(issue);
            continue;
        }

        if (MyFileImporter.removeDuplicates) {
            boolean newLine = linesFirstAgent.add(firstAgent);
            if (!newLine) {
                continue;
            }
        }

        String secondAgent = null;

        if (!oneTypeOfAgent) {
            cell = row.getCell(nbColumnSecondAgent);
            if (cell == null) {
                Issue issue = new Issue("problem with line " + lineCounter + " (empty column "
                        + MyFileImporter.getFirstConnectedAgent() + "). It was skipped in the conversion",
                        Issue.Level.WARNING);
                MyFileImporter.getStaticReport().logIssue(issue);
                continue;
            }
            switch (cell.getCellType()) {
            case Cell.CELL_TYPE_BOOLEAN:
                break;
            case Cell.CELL_TYPE_NUMERIC:
                secondAgent = String.valueOf(cell.getNumericCellValue());
                break;
            case Cell.CELL_TYPE_STRING:
                secondAgent = cell.getStringCellValue();
                break;
            case Cell.CELL_TYPE_BLANK:
                break;
            case Cell.CELL_TYPE_ERROR:
                break;
            // CELL_TYPE_FORMULA will never occur
            case Cell.CELL_TYPE_FORMULA:
                break;
            }
            if (secondAgent == null || secondAgent.isEmpty()) {
                Issue issue = new Issue("problem with line " + lineCounter + " (empty column "
                        + MyFileImporter.getSecondConnectedAgent() + "). It was skipped in the conversion",
                        Issue.Level.WARNING);
                MyFileImporter.getStaticReport().logIssue(issue);
                continue;
            }
            if (MyFileImporter.removeDuplicates) {
                boolean newLine = linesSecondAgent.add(secondAgent);
                if (!newLine) {
                    continue;
                }
            }

        }
        lineCounter++;

        String[] firstAgentSplit;
        String[] secondAgentSplit;
        nodesCurrentLine = new HashSet();

        if (firstDelimiter != null) {
            firstAgentSplit = firstAgent.trim().split(firstDelimiter);
        } else {
            firstAgentSplit = new String[1];
            firstAgentSplit[0] = firstAgent;
        }
        for (String node : firstAgentSplit) {
            node = node.trim();
            nodesFirst.add(node);
            nodes.add(node);
            nodesCurrentLine.add(node);
        }

        if (!oneTypeOfAgent) {

            if (secondDelimiter != null) {
                secondAgentSplit = secondAgent.trim().split(secondDelimiter);
            } else {
                secondAgentSplit = new String[1];
                secondAgentSplit[0] = secondAgent;
            }
            for (String node : secondAgentSplit) {
                node = node.trim();
                nodesSecond.add(node);
                nodes.add(node);
                nodesCurrentLine.add(node);
            }
        } else {
            secondAgentSplit = null;
        }

        //detecting the value of the time field
        if (MyFileImporter.timeField != null) {
            cell = row.getCell(MyFileImporter.timeFieldIndex);
            if (cell == null) {
                Issue issue = new Issue("problem with line " + lineCounter + " (empty column "
                        + MyFileImporter.timeField + "). It was skipped in the conversion",
                        Issue.Level.WARNING);
                MyFileImporter.getStaticReport().logIssue(issue);
                continue;
            }
            String timeField = null;

            switch (cell.getCellType()) {
            case Cell.CELL_TYPE_BOOLEAN:
                break;
            case Cell.CELL_TYPE_NUMERIC:
                timeField = String.valueOf(cell.getNumericCellValue()).split("[.,]")[0];
                break;
            case Cell.CELL_TYPE_STRING:
                timeField = cell.getStringCellValue();
                break;
            case Cell.CELL_TYPE_BLANK:
                break;
            case Cell.CELL_TYPE_ERROR:
                break;
            // CELL_TYPE_FORMULA will never occur
            case Cell.CELL_TYPE_FORMULA:
                break;
            }

            if (timeField == null || timeField.isEmpty()) {
                Issue issue = new Issue("problem with line " + lineCounter + " (empty column "
                        + MyFileImporter.timeField + "). It was skipped in the conversion",
                        Issue.Level.WARNING);
                MyFileImporter.getStaticReport().logIssue(issue);
                continue;
            }

            //dealing with the case there is a duration in the time field. Duration: two time stamps separated by a comma
            //getting min and max times
            timeField = timeField.trim();
            timeField = timeField.replaceAll(" ", "");
            Long start = null;
            Long end = null;
            Long time = null;
            LocalDate date;
            try {
                if (timeField.contains(",")) {
                    if (timeField.split(",")[0].split("-").length < 3) {
                        //                            start = DynamicUtilities.getDoubleFromXMLDateString(timeField.split(",")[0] + "-01-01");
                        date = new LocalDate(Integer.valueOf(timeField.split(",")[0]), 01, 01);
                        start = date.toDateTimeAtStartOfDay().getMillis();

                    } else {
                        date = new LocalDate(Integer.valueOf(timeField.split(",")[0].split("-")[0]),
                                Integer.valueOf(timeField.split(",")[0].split("-")[1]),
                                Integer.valueOf(timeField.split(",")[0].split("-")[2]));
                        start = date.toDateTimeAtStartOfDay().getMillis();
                    }
                    //                        if (start < earliestTime) {
                    //                            earliestTime = start;
                    //                        }
                    if (timeField.split(",")[1].split("-").length < 3) {
                        //                            end = DynamicUtilities.getDoubleFromXMLDateString(timeField.split(",")[1] + "-01-01");
                        date = new LocalDate(Integer.valueOf(timeField.split(",")[1]), 01, 01);
                        end = date.toDateTimeAtStartOfDay().getMillis();
                    } else {
                        date = new LocalDate(Integer.valueOf(timeField.split(",")[1].split("-")[0]),
                                Integer.valueOf(timeField.split(",")[1].split("-")[1]),
                                Integer.valueOf(timeField.split(",")[1].split("-")[2]));
                        end = date.toDateTimeAtStartOfDay().getMillis();
                    }
                    //                        if (end > latestTime) {
                    //                            latestTime = end;
                    //                        }
                } else {
                    if (timeField.split("-").length < 3) {
                        //                            time = DynamicUtilities.getDoubleFromXMLDateString(timeField + "-01-01");
                        date = new LocalDate(Integer.valueOf(timeField), 01, 01);
                        time = date.toDateTimeAtStartOfDay().getMillis();
                    } else {
                        date = new LocalDate(Integer.valueOf(timeField.split("-")[0]),
                                Integer.valueOf(timeField.split("-")[1]),
                                Integer.valueOf(timeField.split("-")[2]));
                        time = date.toDateTimeAtStartOfDay().getMillis();
                    }
                    //                        if (time < earliestTime) {
                    //                            earliestTime = time;
                    //                        }
                    //                        if (time > latestTime) {
                    //                            latestTime = time;
                    //                        }

                    if (start != null && end != null && end < start) {
                        Issue issue = new Issue("problem with line " + lineCounter
                                + ": end time can not be earlier than start time. Line was skipped in the conversion.",
                                Issue.Level.WARNING);
                        MyFileImporter.getStaticReport().logIssue(issue);
                        continue;

                    }

                }
            } catch (NumberFormatException e) {
                Issue issue = new Issue(
                        "problem with line " + lineCounter
                                + ": time not formatted correctly. It was skipped in the conversion",
                        Issue.Level.WARNING);
                MyFileImporter.getStaticReport().logIssue(issue);
                continue;
            }

            if (time == null) {
                interval = BigDecimal.valueOf(start).toPlainString() + ","
                        + BigDecimal.valueOf(end).toPlainString();
            } else {
                interval = BigDecimal.valueOf(time).toPlainString() + ","
                        + BigDecimal.valueOf(time).toPlainString();
            }

            for (String n : nodesCurrentLine) {

                Set<String> intervals = nodeAndIntervals.get(n);
                if (intervals == null) {
                    intervals = new TreeSet();
                }
                intervals.add(interval);
                nodeAndIntervals.put(n, intervals);
            }
        }

        //let's find all connections between all the agents in this row
        Utils usefulTools = new Utils();
        String edge;

        if (!MyFileImporter.innerLinksIncluded) {
            for (String x : firstAgentSplit) {
                for (String xx : secondAgentSplit) {
                    if (!(MyFileImporter.removeSelfLoops & x.equals(xx))) {
                        edge = x.trim() + "|" + xx.trim();
                        edges.add(edge);
                        if (interval != null) {
                            Set<String> intervals = edgeAndIntervals.get(edge);
                            if (intervals == null) {
                                intervals = new TreeSet();
                            }
                            intervals.add(interval);
                            edgeAndIntervals.put(edge, intervals);
                        }
                    }
                }
            }
        } else {
            List<String> connections;
            String[] both = ArrayUtils.addAll(firstAgentSplit, secondAgentSplit);
            connections = usefulTools.getListOfLinks(both, MyFileImporter.removeSelfLoops);
            for (String e : connections) {
                edges.add(e);
                if (interval != null) {
                    Set<String> intervals = edgeAndIntervals.get(e);
                    if (intervals == null) {
                        intervals = new TreeSet();
                    }
                    intervals.add(interval);
                    edgeAndIntervals.put(e, intervals);
                }

            }

        }
    }
    NodeDraft node;
    AttributeColumn acFrequency = atNodes.addColumn("frequency", AttributeType.INT);
    AttributeColumn acType = atNodes.addColumn("type", AttributeType.STRING);
    StringBuilder type;
    boolean atLeastOneType = false;

    for (String n : nodes.elementSet()) {
        type = new StringBuilder();
        node = container.factory().newNodeDraft();
        node.setId(n);
        node.setLabel(n);
        node.addAttributeValue(acFrequency, nodes.count(n));
        if (nodesFirst.contains(n)) {
            type.append(MyFileImporter.getFirstConnectedAgent());
            atLeastOneType = true;
        }
        if (nodesSecond.contains(n)) {
            if (atLeastOneType) {
                type.append("; ");
            }
            type.append(MyFileImporter.getSecondConnectedAgent());
        }
        node.addAttributeValue(acType, type);

        if (MyFileImporter.timeField != null) {
            if (nodeAndIntervals.get(n) != null) {
                for (String inter : nodeAndIntervals.get(n)) {
                    LocalDate start = new LocalDate(Long.parseLong(inter.split(",")[0]));
                    LocalDate end = new LocalDate(Long.parseLong(inter.split(",")[1]));
                    node.addTimeInterval(start.toString("yyyy-MM-dd"), end.toString("yyyy-MM-dd"));
                }
            }
        }
        container.addNode(node);
    }

    //loop for edges
    Integer idEdge = 0;
    EdgeDraft edge;
    for (String e : edges.elementSet()) {
        //            System.out.println("edge: " + e);

        String sourceNode = e.split("\\|")[0];
        String targetNode = e.split("\\|")[1];
        edge = container.factory().newEdgeDraft();
        idEdge = idEdge + 1;
        edge.setSource(container.getNode(sourceNode));
        edge.setTarget(container.getNode(targetNode));
        edge.setWeight((float) edges.count(e));
        edge.setId(String.valueOf(idEdge));
        edge.setType(EdgeDraft.EdgeType.UNDIRECTED);
        if (MyFileImporter.timeField != null) {
            if (edgeAndIntervals.get(e) != null) {
                for (String inter : edgeAndIntervals.get(e)) {
                    LocalDate start = new LocalDate(Long.parseLong(inter.split(",")[0]));
                    LocalDate end = new LocalDate(Long.parseLong(inter.split(",")[1]));
                    edge.addTimeInterval(start.toString("yyyy-MM-dd"), end.toString("yyyy-MM-dd"));
                }
            }
        }

        container.addEdge(edge);
    }
}

From source file:pt.ist.fenix.task.updateData.enrolment.UpdateFlunkedState.java

License:Open Source License

private void changeToFlunkedState(final Registration registration) {
    taskLog("Change to Flunk State Registration -> " + registration.getDegreeCurricularPlanName());

    if (registration.getActiveStateType() != RegistrationStateType.FLUNKED) {

        final ExecutionYear executionYear = ExecutionYear.readCurrentExecutionYear();

        LocalDate date = new LocalDate();
        if (!executionYear.containsDate(date)) {
            date = executionYear.getBeginDateYearMonthDay().toLocalDate();
        }//  w w w  .  j a v a 2s.co m
        RegistrationState.createRegistrationState(registration, null, date.toDateTimeAtStartOfDay(),
                RegistrationStateType.FLUNKED);
    }
}

From source file:pt.ist.fenixedu.contracts.domain.personnelSection.contracts.PersonProfessionalData.java

License:Open Source License

public static boolean isTeacherActiveForSemester(Teacher teacher, ExecutionSemester executionSemester) {
    int minimumWorkingDays = 90;
    int activeDays = 0;
    Interval semesterInterval = new Interval(
            executionSemester.getBeginDateYearMonthDay().toLocalDate().toDateTimeAtStartOfDay(),
            executionSemester.getEndDateYearMonthDay().toLocalDate().toDateTimeAtStartOfDay());
    PersonProfessionalData personProfessionalData = teacher.getPerson().getPersonProfessionalData();
    if (personProfessionalData != null) {
        GiafProfessionalData giafProfessionalData = personProfessionalData.getGiafProfessionalData();
        if (giafProfessionalData != null) {
            for (final PersonContractSituation situation : giafProfessionalData
                    .getValidPersonContractSituations()) {
                if (situation.overlaps(semesterInterval) && situation.getProfessionalCategory() != null
                        && situation.getProfessionalCategory().getCategoryType().equals(CategoryType.TEACHER)) {
                    LocalDate beginDate = situation.getBeginDate()
                            .isBefore(semesterInterval.getStart().toLocalDate())
                                    ? semesterInterval.getStart().toLocalDate()
                                    : situation.getBeginDate();
                    LocalDate endDate = situation.getEndDate() == null
                            || situation.getEndDate().isAfter(semesterInterval.getEnd().toLocalDate())
                                    ? semesterInterval.getEnd().toLocalDate()
                                    : situation.getEndDate();
                    int days = new Interval(beginDate.toDateTimeAtStartOfDay(),
                            endDate.toDateTimeAtStartOfDay()).toPeriod(PeriodType.days()).getDays() + 1;
                    activeDays = activeDays + days;
                }//from  w  w  w . ja  v a 2s.c om
            }
        }
    }
    return activeDays >= minimumWorkingDays;
}

From source file:pt.ist.fenixedu.contracts.tasks.UpdateTeacherAuthorizations.java

License:Open Source License

private int getActiveDays(PersonContractSituation situation, Interval semesterInterval) {
    LocalDate beginDate = situation.getBeginDate().isBefore(semesterInterval.getStart().toLocalDate())
            ? semesterInterval.getStart().toLocalDate()
            : situation.getBeginDate();// ww w .  j a v a 2s. c  om
    LocalDate endDate = situation.getEndDate() == null
            || situation.getEndDate().isAfter(semesterInterval.getEnd().toLocalDate())
                    ? semesterInterval.getEnd().toLocalDate()
                    : situation.getEndDate();

    int activeDays = new Interval(beginDate.toDateTimeAtStartOfDay(), endDate.toDateTimeAtStartOfDay())
            .toPeriod(PeriodType.days()).getDays() + 1;
    return activeDays;
}

From source file:pt.ist.fenixedu.teacher.domain.TeacherCredits.java

License:Open Source License

public static double calculateServiceExemptionCredits(Teacher teacher, ExecutionSemester executionSemester) {
    Set<PersonContractSituation> personProfessionalExemptions = PersonContractSituation
            .getValidTeacherServiceExemptions(teacher, executionSemester);
    Interval semesterInterval = new Interval(
            executionSemester.getBeginDateYearMonthDay().toLocalDate().toDateTimeAtStartOfDay(),
            executionSemester.getEndDateYearMonthDay().toLocalDate().toDateTimeAtStartOfDay());
    int lessonsDays = semesterInterval.toPeriod(PeriodType.days()).getDays();

    List<Interval> notYetOverlapedIntervals = new ArrayList<Interval>();
    List<Interval> newIntervals = new ArrayList<Interval>();
    notYetOverlapedIntervals.add(semesterInterval);

    Double mandatoryLessonHours = calculateMandatoryLessonHours(teacher, executionSemester);
    Double maxSneHours = mandatoryLessonHours;
    TeacherService teacherService = TeacherService.getTeacherServiceByExecutionPeriod(teacher,
            executionSemester);//from   ww  w .j  a  va  2s.com
    if (teacherService != null && teacherService.getReductionService() != null) {
        maxSneHours = Math.max(0,
                (mandatoryLessonHours - teacherService.getReductionServiceCredits().doubleValue()));
    }

    for (PersonContractSituation personContractSituation : personProfessionalExemptions) {
        LocalDate exemptionEnd = personContractSituation.getServiceExemptionEndDate() == null
                ? semesterInterval.getEnd().toLocalDate()
                : personContractSituation.getServiceExemptionEndDate();

        Interval exemptionInterval = new Interval(
                personContractSituation.getBeginDate().toDateTimeAtStartOfDay(),
                exemptionEnd.toDateTimeAtStartOfDay());

        PersonProfessionalExemption personProfessionalExemption = personContractSituation
                .getPersonProfessionalExemption();
        if (personContractSituation.countForCredits(semesterInterval)) {
            if (personProfessionalExemption != null) {
                exemptionEnd = personProfessionalExemption.getEndDate() == null
                        ? semesterInterval.getEnd().toLocalDate()
                        : personProfessionalExemption.getEndDate();
                exemptionInterval = new Interval(
                        personProfessionalExemption.getBeginDate().toDateTimeAtStartOfDay(),
                        exemptionEnd.toDateTimeAtStartOfDay());
                if (personProfessionalExemption.getIsSabaticalOrEquivalent()) {
                    if (isSabbaticalForSemester(teacher, exemptionInterval, semesterInterval)) {
                        return maxSneHours;
                    } else {
                        continue;
                    }
                }
            }
            for (Interval notYetOverlapedInterval : notYetOverlapedIntervals) {
                Interval overlapInterval = exemptionInterval.overlap(notYetOverlapedInterval);
                if (overlapInterval != null) {
                    newIntervals.addAll(getNotOverlapedIntervals(overlapInterval, notYetOverlapedInterval));
                } else {
                    newIntervals.add(notYetOverlapedInterval);
                }
            }
            notYetOverlapedIntervals.clear();
            notYetOverlapedIntervals.addAll(newIntervals);
            newIntervals.clear();
        }
    }

    int notOverlapedDays = 0;
    for (Interval interval : notYetOverlapedIntervals) {
        notOverlapedDays += interval.toPeriod(PeriodType.days()).getDays();
    }
    int overlapedDays = lessonsDays - notOverlapedDays;
    Double overlapedPercentage = round(Double.valueOf(overlapedDays) / Double.valueOf(lessonsDays));
    return round(overlapedPercentage * maxSneHours);
}

From source file:pt.ist.fenixedu.teacher.evaluation.domain.TeacherEvaluationInformationBean.java

License:Open Source License

public TeacherEvaluationInformationBean(TeacherEvaluationProcess teacherEvaluationProcess) {
    this.teacherEvaluationProcess = teacherEvaluationProcess;
    if (teacherEvaluationProcess.getEvaluee().getTeacher() != null) {
        LocalDate beginDate = new LocalDate(
                teacherEvaluationProcess.getFacultyEvaluationProcess().getBeginEvaluationYear(), 1, 1);
        LocalDate endDate = new LocalDate(
                teacherEvaluationProcess.getFacultyEvaluationProcess().getEndEvaluationYear(), 12, 31);
        setTeacherAuthorization(teacherEvaluationProcess.getEvaluee().getTeacher()
                .getLatestTeacherAuthorizationInInterval(
                        new Interval(beginDate.toDateTimeAtStartOfDay(), endDate.toDateTimeAtStartOfDay()))
                .orElse(null));//from   w w w  . j  a va  2  s  .c o m

        for (Professorship professorship : getTeacherEvaluationProcess().getEvaluee().getTeacher()
                .getProfessorships()) {
            if (professorship.getExecutionCourse().getExecutionPeriod().getBeginLocalDate()
                    .getYear() >= getTeacherEvaluationProcess().getFacultyEvaluationProcess()
                            .getBeginEvaluationYear()
                    && professorship.getExecutionCourse().getExecutionPeriod().getBeginLocalDate()
                            .getYear() <= getTeacherEvaluationProcess().getFacultyEvaluationProcess()
                                    .getEndEvaluationYear()) {
                professorships
                        .addAll(ProfessorshipEvaluationBean.getProfessorshipEvaluationBeanSet(professorship));
            }
        }

        for (ThesisEvaluationParticipant participant : teacherEvaluationProcess.getEvaluee()
                .getThesisEvaluationParticipantsSet()) {
            Thesis thesis = participant.getThesis();
            if (thesis.isEvaluated() && thesis.hasFinalEnrolmentEvaluation()
                    && thesis.getDiscussed().getYear() >= getTeacherEvaluationProcess()
                            .getFacultyEvaluationProcess().getBeginEvaluationYear()
                    && thesis.getDiscussed().getYear() <= getTeacherEvaluationProcess()
                            .getFacultyEvaluationProcess().getEndEvaluationYear()) {
                if (participant.getType() == ThesisParticipationType.ORIENTATOR
                        || participant.getType() == ThesisParticipationType.COORIENTATOR) {
                    orientations.add(new OrientationBean(participant));
                }
                if (participant.getType() == ThesisParticipationType.VOWEL
                        || participant.getType() == ThesisParticipationType.PRESIDENT) {

                    String descrition = Joiner.on(", ").join(
                            BundleUtil.getString("resources.TeacherEvaluationResources",
                                    participant.getClass().getName() + "."
                                            + ThesisParticipationType.PRESIDENT.name()),
                            participant.getThesis().getTitle(),
                            participant.getThesis().getStudent().getPerson().getName(),
                            participant.getThesis().getStudent().getNumber(),
                            thesis.getDiscussed().toLocalDate().toString());

                    functions.add(new OrientationBean(descrition, thesis.getDiscussed().toLocalDate()));
                }

            }
        }

        for (InternalPhdParticipant internalPhdParticipant : teacherEvaluationProcess.getEvaluee()
                .getInternalParticipantsSet()) {
            LocalDate conclusionDate = internalPhdParticipant.getIndividualProcess().getConclusionDate();
            if (conclusionDate != null
                    && conclusionDate.getYear() >= getTeacherEvaluationProcess().getFacultyEvaluationProcess()
                            .getBeginEvaluationYear()
                    && conclusionDate.getYear() <= getTeacherEvaluationProcess().getFacultyEvaluationProcess()
                            .getEndEvaluationYear()) {
                if (internalPhdParticipant.getProcessForGuiding() != null
                        || internalPhdParticipant.getProcessForAssistantGuiding() != null) {
                    orientations.add(new OrientationBean(internalPhdParticipant));
                }
                ThesisJuryElement thesisJuryElement = getThesisJuryElement(internalPhdParticipant);
                if (thesisJuryElement != null) {
                    String descrition = Joiner.on(", ").join(
                            BundleUtil.getString("resources.TeacherEvaluationResources",
                                    internalPhdParticipant.getClass().getName() + "."
                                            + ThesisParticipationType.PRESIDENT.name()),
                            internalPhdParticipant.getIndividualProcess().getThesisTitle(),
                            internalPhdParticipant.getIndividualProcess().getStudent().getPerson().getName(),
                            internalPhdParticipant.getIndividualProcess().getStudent().getNumber(),
                            internalPhdParticipant.getIndividualProcess().getConclusionDate().toString());

                    functions.add(new OrientationBean(descrition,
                            internalPhdParticipant.getIndividualProcess().getConclusionDate()));
                }
            }
        }

        publications.addAll(
                new SotisPublications().getPublications(getTeacherEvaluationProcess().getEvaluee().getUser(),
                        teacherEvaluationProcess.getFacultyEvaluationProcess().getBeginEvaluationYear(),
                        teacherEvaluationProcess.getFacultyEvaluationProcess().getEndEvaluationYear()));

        for (PersonFunction personFunction : (Collection<PersonFunction>) teacherEvaluationProcess.getEvaluee()
                .getParentAccountabilities(AccountabilityTypeEnum.MANAGEMENT_FUNCTION, PersonFunction.class)) {
            if (personFunction.getBeginDate().getYear() >= getTeacherEvaluationProcess()
                    .getFacultyEvaluationProcess().getBeginEvaluationYear()
                    && personFunction.getBeginDate().getYear() <= getTeacherEvaluationProcess()
                            .getFacultyEvaluationProcess().getEndEvaluationYear()
                    && !personFunction.getFunction().isVirtual()) {
                functions.add(new OrientationBean(personFunction));
            }
        }
    }
}