Package org.libreplan.business.workreports.entities

Examples of org.libreplan.business.workreports.entities.WorkReportLine


     * Append a {@link Textbox} effort to {@link Row}
     *
     * @param row
     */
    private void appendEffortDuration(Row row) {
        WorkReportLine workReportLine = (WorkReportLine) row.getValue();
        Textbox effort = new Textbox();
        effort.setConstraint(new Constraint() {

            @Override
            public void validate(Component comp, Object value)
View Full Code Here


     * Append Selectbox of @{link TypeOfWorkHours} to row
     *
     * @param row
     */
    private void appendHoursType(final Row row) {
        final WorkReportLine workReportLine = (WorkReportLine) row.getValue();
        final Listbox lbHoursType = new Listbox();
        lbHoursType.setMold("select");
        lbHoursType.setModel(allHoursType);
        lbHoursType.renderAll();
        lbHoursType.applyProperties();

        if (lbHoursType.getItems().isEmpty()) {
            row.appendChild(lbHoursType);
            return;
        }

        // First time is rendered, select first item
        TypeOfWorkHours type = workReportLine.getTypeOfWorkHours();
        if (workReportLine.isNewObject() && type == null) {
            Listitem item = lbHoursType.getItemAtIndex(0);
            item.setSelected(true);
            setHoursType(workReportLine, item);
        } else {
            // If workReportLine has a type, select item with that type
View Full Code Here

                    _("Please, select an item"));
        }
    }

    private void appendCode(final Row row) {
        final WorkReportLine line = (WorkReportLine) row.getValue();
        final Textbox code = new Textbox();
        code.setDisabled(getWorkReport().isCodeAutogenerated());
        code.applyProperties();

         if (line.getCode() != null) {
             code.setValue(line.getCode());
         }

        code.addEventListener("onChange", new EventListener() {
            @Override
            public void onEvent(Event event) {
                final WorkReportLine line = (WorkReportLine) row.getValue();
                line.setCode(code.getValue());
            }
        });
        row.appendChild(code);
    }
View Full Code Here

        });
        row.appendChild(code);
    }

    private void appendFinished(final Row row) {
        final WorkReportLine line = (WorkReportLine) row.getValue();

        Checkbox finished = Util.bind(new Checkbox(), new Getter<Boolean>() {
            @Override
            public Boolean get() {
                return line.isFinished();
            }
        }, new Setter<Boolean>() {
            @Override
            public void set(Boolean value) {
                line.setFinished(BooleanUtils.isTrue(value));
            }
        });

        if (!line.isFinished()
                && workReportModel.isFinished(line.getOrderElement())) {
            finished.setDisabled(true);
        }

        row.appendChild(finished);
    }
View Full Code Here

    private static WorkReportLine toEntity(WorkReportLineDTO workReportLineDTO,
            WorkReport workReport)
            throws InstanceNotFoundException {

        WorkReportLine workReportLine = WorkReportLine.create(workReport);

        // Mandatory fields
        workReportLine.setCode(workReportLineDTO.code);
        workReportLine.setEffort(EffortDuration
                .parseFromFormattedString(workReportLineDTO.numHours));

        if (workReportLineDTO.typeOfWorkHours != null) {
            try {
                TypeOfWorkHours typeOfWorkHours = Registry
                        .getTypeOfWorkHoursDAO().findUniqueByCode(
                                workReportLineDTO.typeOfWorkHours);
                workReportLine.setTypeOfWorkHours(typeOfWorkHours);
            } catch (InstanceNotFoundException e) {
                throw new ValidationException(
                        "There is no type of work hours with this code");
            }
        }

        // Optional fields
        if (workReportLineDTO.date != null) {
            workReportLine
                    .setDate(DateConverter.toDate(workReportLineDTO.date));
        }

        bindingStrategy.assignOrderElementsToWorkReportLine(workReportLine,
                bindingStrategy.getOrderElementsBound(workReportLineDTO));

        if (workReportLineDTO.resource != null) {
            try {
                Resource resource = Registry.getResourceDAO().findByCode(
                        workReportLineDTO.resource);
                workReportLine.setResource(resource);
            } catch (InstanceNotFoundException e) {
                workReportLine.setResource(null);
                throw new ValidationException(
                        "There is no resource with this code");
            }
        }

        if (workReportLineDTO.clockStart != null) {
            workReportLine.setClockStart(DateConverter
                    .toLocalTime(workReportLineDTO.clockStart));
        }
        if (workReportLineDTO.clockFinish != null) {
            workReportLine.setClockFinish(DateConverter
                    .toLocalTime(workReportLineDTO.clockFinish));
        }

        if (workReportLineDTO.labels != null
                && !workReportLineDTO.labels.isEmpty()) {
            workReportLine.setLabels(LabelReferenceConverter
                    .toEntity(workReportLineDTO.labels));
        }

        if (workReportLineDTO.descriptionValues != null) {
            workReportLine
                    .setDescriptionValues(toEntity(workReportLineDTO.descriptionValues));
        }

        return workReportLine;
    }
View Full Code Here

                throw new ValidationException(
                        "missing code in a work report line");
            }

            try {
                WorkReportLine line = workReport
                        .getWorkReportLineByCode(lineDTO.code);
                updateWorkReportLine(line, lineDTO);
            } catch (InstanceNotFoundException e) {
                try {
                    workReport.addWorkReportLine(toEntity(lineDTO, workReport));
View Full Code Here

        return Worker
                .create("Firstname", "Surname", "NIF-" + UUID.randomUUID());
    }

    private WorkReportLine givenBasicWorkReportLine(WorkReport workReport) {
        WorkReportLine workReportLine = WorkReportLine.create(workReport);
        workReportLine.setCode("work-report-line-code-" + UUID.randomUUID());

        return workReportLine;
    }
View Full Code Here

        workReportType.setResourceIsSharedInLines(true);

        WorkReport workReport = givenBasicWorkReport();
        workReport.setWorkReportType(workReportType);

        WorkReportLine workReportLine1 = givenBasicWorkReportLine(workReport);
        workReport.addWorkReportLine(workReportLine1);

        workReport.setDate(new Date());
        workReport.setOrderElement(givenOrderLine());
        workReport.setResource(givenWorker());

        assertNotNull(workReportLine1.getDate());
        assertNotNull(workReportLine1.getOrderElement());
        assertNotNull(workReportLine1.getResource());

        WorkReportLine workReportLine2 = givenBasicWorkReportLine(workReport);
        workReport.addWorkReportLine(workReportLine2);

        assertNotNull(workReportLine2.getDate());
        assertNotNull(workReportLine2.getOrderElement());
        assertNotNull(workReportLine2.getResource());

        workReportLine2.setDate(null);
        workReportLine2.setOrderElement(null);
        workReportLine2.setResource(null);

        assertNotNull(workReportLine2.getDate());
        assertNotNull(workReportLine2.getOrderElement());
        assertNotNull(workReportLine2.getResource());

    }
View Full Code Here

        WorkReportType workReportType = givenBasicWorkReportType();
        workReportType
                .setHoursManagement(HoursManagementEnum.HOURS_CALCULATED_BY_CLOCK);

        WorkReport workReport = WorkReport.create(workReportType);
        WorkReportLine workReportLine = givenBasicWorkReportLine(workReport);

        workReport.addWorkReportLine(workReportLine);

        workReportLine.setEffort(EffortDuration.hours(10));
        assertNull(workReportLine.getEffort());

        LocalTime start = new LocalTime(8, 0);
        LocalTime end = start.plusHours(8);

        workReportLine.setClockStart(start);
        workReportLine.setClockFinish(end);

        assertThat(workReportLine.getEffort(), equalTo(EffortDuration.hours(8)));

        workReportLine.setEffort(EffortDuration.hours(10));

        assertThat(workReportLine.getEffort(), equalTo(EffortDuration.hours(8)));
    }
View Full Code Here

        workReportType
                .setHoursManagement(HoursManagementEnum.HOURS_CALCULATED_BY_CLOCK);

        WorkReport workReport = WorkReport.create(workReportType);

        WorkReportLine workReportLine = givenBasicWorkReportLine(workReport);
        workReport.addWorkReportLine(workReportLine);

        workReportLine.setEffort(EffortDuration.hours(10));
        LocalTime start = new LocalTime(8, 0);
        LocalTime end = start.plusHours(8);

        workReportLine.setClockStart(start);
        workReportLine.setClockFinish(end);

        assertThat(workReportLine.getEffort(), equalTo(EffortDuration.hours(8)));
    }
View Full Code Here

TOP

Related Classes of org.libreplan.business.workreports.entities.WorkReportLine

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.