Package org.libreplan.ws.resources.api

Examples of org.libreplan.ws.resources.api.ResourcesCostCategoryAssignmentDTO


                        .toDateTimeAtStartOfDay().toDate();
        Date endDate = (resourcesCostCategoryAssignment.getEndDate() == null) ? null
                : resourcesCostCategoryAssignment.getEndDate()
                        .toDateTimeAtStartOfDay().toDate();

        return new ResourcesCostCategoryAssignmentDTO(
                resourcesCostCategoryAssignment.getCode(),
                resourcesCostCategoryAssignment.getCostCategory().getName(),
                DateConverter.toXMLGregorianCalendar(initDate), DateConverter
                        .toXMLGregorianCalendar(endDate));
    }
View Full Code Here


        /* Create a CostCategory. */
        CostCategory costCategory = createCostCategory();

        /* Create resource DTOs. */
        MachineDTO m1 = new MachineDTO("name", "desc");
        ResourcesCostCategoryAssignmentDTO a1m1 = new ResourcesCostCategoryAssignmentDTO(
                ' ' + costCategory.getName().toUpperCase() + ' ', getDate(2001,
                        1, 1), null);
        m1.resourcesCostCategoryAssignments.add(a1m1);
        m1.resourcesCostCategoryAssignments
                .add(new ResourcesCostCategoryAssignmentDTO(costCategory
                        .getName(), getDate(2000, 1, 1), getDate(2000, 4, 1)));

        MachineDTO m2 = new MachineDTO("name", "desc");
        m2.resourcesCostCategoryAssignments
                .add(new ResourcesCostCategoryAssignmentDTO(a1m1.code,
                        costCategory.getName().toUpperCase(), getDate(2001, 1,
                                1), null)); // Repeated assignment code
        // (used by another machine).
        m2.resourcesCostCategoryAssignments
                .add(new ResourcesCostCategoryAssignmentDTO(null, costCategory
                        .getName().toUpperCase(), getDate(2000, 1, 1), getDate(
                        2000, 4, 1))); // Missing
        // assignment code (autogenerated code).

        MachineDTO m3 = new MachineDTO("name", "desc");
        ResourcesCostCategoryAssignmentDTO a1m3 = new ResourcesCostCategoryAssignmentDTO(
                costCategory.getName(), getDate(2001, 1, 1), null);
        m3.resourcesCostCategoryAssignments.add(a1m3);
        m3.resourcesCostCategoryAssignments
                .add(new ResourcesCostCategoryAssignmentDTO(a1m3.code, // Repeated
                                                                       // assignment
                                                                       // code
                                                                       // in
                                                                       // this
                                                                       // machine.
View Full Code Here

    public void testAddResourcesWithCostAssignmentWithMissingCostCategoryName() {

        /* Create a resource DTO. */
        MachineDTO machineDTO = new MachineDTO("name", "desc");
        machineDTO.resourcesCostCategoryAssignments
                .add(new ResourcesCostCategoryAssignmentDTO("", null, getDate(
                        2000, 1, 1), null));

        /* Test. */
        assertOneConstraintViolation(resourceService
                .addResources(createResourceListDTO(machineDTO)));
View Full Code Here

    public void testAddResourcesWithCostAssignmentWithNonExistentCostCategory() {

        /* Create a resource DTO. */
        MachineDTO machineDTO = new MachineDTO("name", "desc");
        machineDTO.resourcesCostCategoryAssignments
                .add(new ResourcesCostCategoryAssignmentDTO(getUniqueName(),
                        getDate(2000, 1, 1), null));

        /* Test. */
        assertOneRecoverableError(resourceService
                .addResources(createResourceListDTO(machineDTO)));
View Full Code Here

        CostCategory costCategory = createCostCategory();

        /* Create a resource DTO. */
        MachineDTO machineDTO = new MachineDTO("name", "desc");
        machineDTO.resourcesCostCategoryAssignments
                .add(new ResourcesCostCategoryAssignmentDTO(costCategory
                        .getName(), null, // Start date not specified.
                        getDate(2000, 1, 1)));

        /* Test. */
        assertOneConstraintViolation(resourceService
View Full Code Here

        CostCategory costCategory = createCostCategory();

        /* Create a resource DTO. */
        MachineDTO machineDTO = new MachineDTO("name", "desc");
        machineDTO.resourcesCostCategoryAssignments
                .add(new ResourcesCostCategoryAssignmentDTO(costCategory
                        .getName(), getDate(2000, 2, 1), getDate(2000, 1, 1)));

        /* Test. */
        assertOneConstraintViolation(resourceService
                .addResources(createResourceListDTO(machineDTO)));
View Full Code Here

        MachineDTO m1 = new MachineDTO("name", "desc");
        CriterionSatisfactionDTO m1s1 = new CriterionSatisfactionDTO(
                ctMachine
                .getName(), "c1", getDate(2000, 1, 1), getDate(2000, 2, 1));
        m1.criterionSatisfactions.add(m1s1);
        ResourcesCostCategoryAssignmentDTO m1a1 = new ResourcesCostCategoryAssignmentDTO(
                costCategory.getName(), getDate(2000, 1, 1),
                getDate(2000, 2, 1));
        m1.resourcesCostCategoryAssignments.add(m1a1);

        /* Create a worker DTO. */
        String nif = getUniqueName();
        WorkerDTO w1 = new WorkerDTO(getUniqueName(), "surname", nif);
        CriterionSatisfactionDTO w1s1 = new CriterionSatisfactionDTO(
                ctWorker
                .getName(), "c1", getDate(2000, 1, 1), getDate(2000, 2, 1));
        w1.criterionSatisfactions.add(w1s1);
        ResourcesCostCategoryAssignmentDTO w1a1 = new ResourcesCostCategoryAssignmentDTO(
                costCategory.getName(), getDate(2000, 1, 1),
                getDate(2000, 2, 1));
        w1.resourcesCostCategoryAssignments.add(w1a1);

        /* Add resources. */
        assertNoConstraintViolations(resourceService
                .addResources(createResourceListDTO(m1, w1)));

        /*
         * Build DTOs for making the following update: + m1: update name, m1s1's
         * start date, and add a new cost category assignment. + w1: update
         * surname, w1a1's start date, and add a new criterion satisfaction.
         */
        MachineDTO m1Updated = new MachineDTO(m1.code, "name" + "UPDATED", null);
        CriterionSatisfactionDTO m1s1Updated = new CriterionSatisfactionDTO(
                m1s1.code, null, null, getDate(2000, 1, 2), null);
        m1Updated.criterionSatisfactions.add(m1s1Updated);
        ResourcesCostCategoryAssignmentDTO m1a2 = new ResourcesCostCategoryAssignmentDTO(
                costCategory.getName(), getDate(2000, 3, 1),
                getDate(2000, 4, 1));
        m1Updated.resourcesCostCategoryAssignments.add(m1a2);

        WorkerDTO w1Updated = new WorkerDTO(w1.code, null, "surname"
                + "UPDATED", null);
        CriterionSatisfactionDTO w1s2 = new CriterionSatisfactionDTO(
                ctWorker
                .getName(), "c1", getDate(2000, 3, 1), getDate(2000, 4, 1));
        w1Updated.criterionSatisfactions.add(w1s2);
        ResourcesCostCategoryAssignmentDTO w1a1Updated = new ResourcesCostCategoryAssignmentDTO(
                w1a1.code, null, getDate(2000, 2, 1), null);
        w1Updated.resourcesCostCategoryAssignments.add(w1a1Updated);

        /* Update resources and test. */
        assertNoConstraintViolations(resourceService
View Full Code Here

        XMLGregorianCalendar startDate2, XMLGregorianCalendar endDate2) {

        MachineDTO machineDTO = new MachineDTO(machineName, "desc");

        machineDTO.resourcesCostCategoryAssignments.add(
            new ResourcesCostCategoryAssignmentDTO(
                costCategoryName, startDate1, endDate1));
        machineDTO.resourcesCostCategoryAssignments.add(
            new ResourcesCostCategoryAssignmentDTO(
                costCategoryName, startDate2, endDate2));

        return machineDTO;

    }
View Full Code Here

TOP

Related Classes of org.libreplan.ws.resources.api.ResourcesCostCategoryAssignmentDTO

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.