Package org.libreplan.business.workingday

Examples of org.libreplan.business.workingday.EffortDuration


            Resource resource,
            DateAndHour startTime, DateAndHour endsAfter) {

        List<DayAssignment> assignments = new LinkedList<DayAssignment>();
        ResourceCalendar calendar = resource.getCalendar();
        final EffortDuration totalEffort = hours(resourceAllocation
                .getIntendedTotalHours());
        EffortDuration effortAssigned = zero();
        UntilEndAndEffort condition = new UntilEndAndEffort(
                endsAfter.toIntraDayDate(), totalEffort);
        for (PartialDay each : startTime.toIntraDayDate().daysUntil(condition)) {
            EffortDuration effortForDay = EffortDuration.min(
                    calendar.asDurationOn(each,
                    ONE_RESOURCE_PER_DAY), totalEffort);
            DayAssignment dayAssignment = createDayAssignment(
                    resourceAllocation, resource, each.getDate(), effortForDay);
            effortAssigned = effortAssigned.plus(addDayAssignment(assignments,
View Full Code Here


    private static void stripStartAssignments(List<DayAssignment> assignments,
            EffortDuration durationSurplus) {
        ListIterator<DayAssignment> listIterator = assignments.listIterator();
        while (listIterator.hasNext() && durationSurplus.compareTo(zero()) > 0) {
            DayAssignment current = listIterator.next();
            EffortDuration durationTaken = min(durationSurplus,
                    current.getDuration());
            durationSurplus = durationSurplus.minus(durationTaken);
            if (durationTaken.compareTo(current.getDuration()) == 0) {
                listIterator.remove();
            } else {
                listIterator.set(current.withDuration(durationTaken));
            }
        }
View Full Code Here

            DateAndHour endTime) {
        ResourceCalendar calendar = resource.getCalendar();
        List<DayAssignment> result = new ArrayList<DayAssignment>();

        LocalDate date = endTime.getDate();
        EffortDuration totalIntended = hours(resourceAllocation
                .getIntendedTotalHours());

        // Generate last day assignment
        PartialDay firstDay = new PartialDay(IntraDayDate.startOfDay(date),
                IntraDayDate.create(date, hours(endTime.getHour())));
        EffortDuration effortCanAllocate = min(totalIntended,
                calendar.asDurationOn(firstDay, ONE_RESOURCE_PER_DAY));
        if (effortCanAllocate.compareTo(zero()) > 0) {
            DayAssignment dayAssignment = createDayAssignment(
                    resourceAllocation, resource, date, effortCanAllocate);
            totalIntended = totalIntended.minus(addDayAssignment(result,
                    dayAssignment));
        }

        // Generate rest of day assignments
        for (date = date.minusDays(1); totalIntended.compareTo(zero()) > 0; date = date
                .minusDays(1)) {
            EffortDuration duration = min(totalIntended, calendar.asDurationOn(
                    PartialDay.wholeDay(date), ONE_RESOURCE_PER_DAY));
            DayAssignment dayAssigment = createDayAssignment(
                    resourceAllocation, resource, date, duration);
            totalIntended = totalIntended.minus(addDayAssignment(result,
                    dayAssigment));
View Full Code Here

    private Integer totalTasks(List<WorkReportLine> workReportLines) {
        return Integer.valueOf(workReportLines.size());
    }

    private EffortDuration totalHours(List<WorkReportLine> workReportLines) {
        EffortDuration result = EffortDuration.zero();
        for (WorkReportLine each : workReportLines) {
            result = result.plus(each.getEffort());
        }
        return result;
    }
View Full Code Here

            final LocalDate startDate, final LocalDate endDate,
            final Scenario scenario) {

        resourceDAO.reattach(resource);

        EffortDuration totalLoad = EffortDuration.zero(), totalOverload = EffortDuration
                .zero(), totalCapacity = EffortDuration.zero();

        for (Map.Entry<LocalDate, EffortDuration> each : getAllEffortPerDateFor(
                scenario, startDate, endDate, resource).entrySet()) {
            totalLoad = totalLoad.plus(each.getValue());
            totalOverload = addOverload(totalOverload, resource,
                    each.getValue(), each.getKey());
        }

        totalCapacity = calculateTotalCapacity(resource, startDate, endDate);
View Full Code Here

        HashMap<LocalDate, EffortDuration> result = new HashMap<LocalDate, EffortDuration>();

        List<DayAssignment> l = dayAssigmentDAO.getAllFor(scenario, startDate,
                endDate, resource);

        EffortDuration newValue = EffortDuration.zero();
        for (DayAssignment each : l) {
            if (result.containsKey(each.getDay())) {
                newValue = result.get(each.getDay()).plus(each.getDuration());
            } else {
                newValue = each.getDuration();
View Full Code Here

        return resource.getCalendar().getWorkableDuration(startDate, endDate);
    }

    private EffortDuration addOverload(EffortDuration currentOverload,
            Resource resource, EffortDuration loadAtDate, LocalDate date) {
        EffortDuration result;
        EffortDuration capacityAtDay = getCapacityAtDate(resource, date);
        if (capacityAtDay.compareTo(loadAtDate) < 0) {
            result = currentOverload.plus(loadAtDate.minus(capacityAtDay));
        } else {
            result = currentOverload;
        }
View Full Code Here

public class HoursWorkedPerWorkerScriptlet extends JRAbstractScriptlet {

    private Set<HoursWorkedPerResourceDTO> dtos = new HashSet<HoursWorkedPerResourceDTO>();

    public String getEffort() throws JRScriptletException {
        EffortDuration effort = (EffortDuration) this.getFieldValue("effort");
        return effort.toFormattedString();
    }
View Full Code Here

    @Override
    public void afterDetailEval() throws JRScriptletException {
        // We use the set because elements could be processed twice depending on
        // the report
        EffortDuration current = (EffortDuration) this.getFieldValue("effort");
        if (current == null) {
            current = EffortDuration.zero();
        }
        HoursWorkedPerResourceDTO dto = (HoursWorkedPerResourceDTO) this
                .getFieldValue("self");
        if (!dtos.contains(dto)) {
            // The effort of the worker is the sum of all efforts.
            EffortDuration effortWorker = EffortDuration.sum(current,
                    EffortDuration.parseFromFormattedString((String) this
                            .getVariableValue("sumHoursPerWorker")));
            this.setVariableValue("sumHoursPerWorker",
                    effortWorker.toFormattedString());
            // We calculate here the effort for a particular day
            EffortDuration effort = EffortDuration.sum(current, EffortDuration
                    .parseFromFormattedString((String) this
                            .getVariableValue("sumHoursPerDay")));
            this.setVariableValue("sumHoursPerDay", effort.toFormattedString());
            dtos.add(dto);
        }
    }
View Full Code Here

*
*/
public class RealHoursScriptlet extends JRDefaultScriptlet {

    public String getRealHours() throws JRScriptletException {
        EffortDuration effort = (EffortDuration) this
                .getFieldValue("realHours");
        return effort.toFormattedString();
    }
View Full Code Here

TOP

Related Classes of org.libreplan.business.workingday.EffortDuration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.