Package org.libreplan.ws.resources.api

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


        /*
         * Create a resource DTOs. Each resource contains one cost assignment
         * overlapping.
         */
        MachineDTO m1 = createMachineDTOWithTwoCostsAssignments("m1",
                costCategory.getName(), getDate(2000, 1, 1), null, getDate(
                        2000, 2, 1), null);

        MachineDTO m2 = createMachineDTOWithTwoCostsAssignments("m2",
                costCategory.getName(), getDate(2000, 2, 1), null, getDate(
                        2000, 1, 1), getDate(2000, 3, 1));

        MachineDTO m3 = createMachineDTOWithTwoCostsAssignments("m3",
                costCategory.getName(), getDate(2000, 2, 1),
                getDate(2000, 4, 1), getDate(2000, 3, 1), null);

        MachineDTO m4 = createMachineDTOWithTwoCostsAssignments("m4",
                costCategory.getName(), getDate(2000, 2, 1),
                getDate(2000, 5, 1), getDate(2000, 1, 1), getDate(2000, 3, 1));

        MachineDTO m5 = createMachineDTOWithTwoCostsAssignments("m5",
                costCategory.getName(), getDate(2000, 2, 1),
                getDate(2000, 5, 1), getDate(2000, 3, 1), getDate(2000, 4, 1));

        MachineDTO m6 = createMachineDTOWithTwoCostsAssignments("m6",
                costCategory.getName(), getDate(2000, 2, 1),
                getDate(2000, 5, 1), getDate(2000, 4, 1), getDate(2000, 6, 1));

        MachineDTO m7 = createMachineDTOWithTwoCostsAssignments("m7",
                costCategory.getName(), getDate(2000, 2, 1),
                getDate(2000, 5, 1), getDate(2000, 1, 1), getDate(2000, 2, 1));

        MachineDTO m8 = createMachineDTOWithTwoCostsAssignments("m8",
                costCategory.getName(), getDate(2000, 2, 1),
                getDate(2000, 5, 1), getDate(2000, 5, 1), getDate(2000, 6, 1));

        MachineDTO m9 = createMachineDTOWithTwoCostsAssignments("m9",
                costCategory.getName(), getDate(2000, 2, 1),
                getDate(2000, 5, 1), getDate(2000, 2, 1), getDate(2000, 5, 1));

        /* Test. */
        ResourceListDTO resourceDTOs = createResourceListDTO(m1, m2, m3, m4,
                m5, m6, m7, m8, m9);

        assertOneConstraintViolationPerInstance(resourceService
                .addResources(resourceDTOs), resourceDTOs.resources.size());

        for (ResourceDTO r : resourceDTOs.resources) {
            MachineDTO m = (MachineDTO) r;
            assertFalse("Machine " + m.name + " not expected", resourceDAO
                    .existsByCode(((MachineDTO) r).code));
        }

    }
View Full Code Here


        CriterionType ctMachine = createCriterionType(ResourceEnum.MACHINE);
        CriterionType ctWorker = createCriterionType(ResourceEnum.WORKER);
        CostCategory costCategory = createCostCategory();

        /* Create a machine DTO. */
        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),
View Full Code Here

        String criterionName1, XMLGregorianCalendar startDate1,
        XMLGregorianCalendar endDate1,
        String criterionName2, XMLGregorianCalendar startDate2,
        XMLGregorianCalendar endDate2) {

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

        machineDTO.criterionSatisfactions.add(
            new CriterionSatisfactionDTO(criterionTypeName, criterionName1,
                startDate1, endDate1));
        machineDTO.criterionSatisfactions.add(
View Full Code Here

    private MachineDTO createMachineDTOWithTwoCostsAssignments(
        String machineName, String costCategoryName,
        XMLGregorianCalendar startDate1, XMLGregorianCalendar endDate1,
        XMLGregorianCalendar startDate2, XMLGregorianCalendar endDate2) {

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

        machineDTO.resourcesCostCategoryAssignments.add(
            new ResourcesCostCategoryAssignmentDTO(
                costCategoryName, startDate1, endDate1));
        machineDTO.resourcesCostCategoryAssignments.add(
View Full Code Here

TOP

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

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.