Package org.libreplan.ws.resources.api

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


                .getDescription());
    }

    private static CriterionSatisfactionDTO toDTO(
            CriterionSatisfaction criterionSatisfaction) {
        return new CriterionSatisfactionDTO(criterionSatisfaction.getCode(),
                criterionSatisfaction.getCriterion().getType().getName(),
                criterionSatisfaction.getCriterion().getName(), DateConverter
                        .toXMLGregorianCalendar(criterionSatisfaction
                                .getStartDate()), DateConverter
                        .toXMLGregorianCalendar(criterionSatisfaction
View Full Code Here


        /* Create a criterion type. */
        CriterionType ct = createCriterionType(ResourceEnum.MACHINE);

        /* Create a resource DTO. */
        MachineDTO m1 = new MachineDTO("name", "desc");
        CriterionSatisfactionDTO cs1m1 =
            new CriterionSatisfactionDTO(
                ' ' + ct.getName().toUpperCase() // Upper case and blank
                ' ', " C1 ",                        // spaces intentionally
                                                    // added (OK).
                getDate(2001, 1, 1), getDate(2001, 2, 1));
        m1.criterionSatisfactions.add(cs1m1);
        m1.criterionSatisfactions.add(
            new CriterionSatisfactionDTO(ct.getName(), "c2",
                getDate(2001, 1, 1), null));

        MachineDTO m2 = new MachineDTO("name", "desc");
        m2.criterionSatisfactions.add(
            new CriterionSatisfactionDTO(cs1m1.code, ct.getName(), "c1",
                getDate(2001, 1, 1), null)); // Repeated criterion satisfaction
                                             // code (used by another machine).
        m2.criterionSatisfactions.add(
            new CriterionSatisfactionDTO(null, ct.getName(), "c2",
                getDate(2001, 1, 1), null)); // Missing criterion satisfaction
        // code.(autogenerated code)

        MachineDTO m3 = new MachineDTO("name", "desc");
        CriterionSatisfactionDTO cs1m3 =
            new CriterionSatisfactionDTO(ct.getName(), "c1",
                getDate(2001, 1, 1), getDate(2001, 2, 1));
        m3.criterionSatisfactions.add(cs1m3);
        m3.criterionSatisfactions.add(
            new CriterionSatisfactionDTO(
                cs1m3.code, // Repeated criterion satisfaction code in this
                            // machine.
                ct.getName(), "c2",
                getDate(2001, 1, 1), null));

View Full Code Here

        CriterionType ct = createCriterionType(ResourceEnum.MACHINE);

        /* Create a machine DTO. */
        MachineDTO machineDTO = new MachineDTO("name", "desc");
        machineDTO.criterionSatisfactions.add(
            new CriterionSatisfactionDTO(ct.getName() , "c1",
                null, getDate(2001, 1, 1))); // Missing start date.

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

        CriterionType ct = createCriterionType(ResourceEnum.MACHINE);

        /* Create a machine DTO. */
        MachineDTO machineDTO = new MachineDTO("name", "desc");
        machineDTO.criterionSatisfactions.add(
            new CriterionSatisfactionDTO(ct.getName() , "c1",
                getDate(2000, 2, 1), getDate(2000, 1, 1)));

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

        CriterionType workerCt = createCriterionType(ResourceEnum.WORKER);

        /* Create resource DTOs. */
        MachineDTO machineDTO = new MachineDTO("name", "desc");
        machineDTO.criterionSatisfactions.add(
            new CriterionSatisfactionDTO(workerCt.getName() , "c1",
                getDate(2001, 1, 1), null)); // Incorrect type.
        WorkerDTO workerDTO = new WorkerDTO(getUniqueName(), "surname",
                getUniqueName());
        workerDTO.criterionSatisfactions.add(
            new CriterionSatisfactionDTO(machineCt.getName() , "c1",
                getDate(2001, 1, 1), null)); // Incorrect type.

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

        CriterionType ct = createCriterionType();

        /* Create machines DTOs. */
        MachineDTO m1 = new MachineDTO("m1", "desc");
        m1.criterionSatisfactions.add(
            new CriterionSatisfactionDTO("", "X", // Missing criterion type.
                getDate(2001, 1, 1), null));
        MachineDTO m2 = new MachineDTO("m2", "desc");
        m2.criterionSatisfactions.add(
            new CriterionSatisfactionDTO(ct.getName(), // Missing criterion.
                null, getDate(2001, 1, 1), null));

        /* Test. */
        ResourceListDTO resourceDTOs = createResourceListDTO(m1, m2);

View Full Code Here

    public void testAddResourceWithCriterionSatisfactionsWithNonExistentCriterionType() {

        /* Create a machine DTO. */
        MachineDTO machineDTO = new MachineDTO("name", "desc");
        machineDTO.criterionSatisfactions.add(
            new CriterionSatisfactionDTO(getUniqueName() , "c1",
                getDate(2000, 1, 1), null));

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

        CriterionType ct = createCriterionType();

        /* Create a machine DTO. */
        MachineDTO machineDTO = new MachineDTO("name", "desc");
        machineDTO.criterionSatisfactions.add(
            new CriterionSatisfactionDTO(ct.getName(), getUniqueName(),
                getDate(2000, 1, 1), null));

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

        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),
                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);
View Full Code Here

        XMLGregorianCalendar endDate2) {

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

        machineDTO.criterionSatisfactions.add(
            new CriterionSatisfactionDTO(criterionTypeName, criterionName1,
                startDate1, endDate1));
        machineDTO.criterionSatisfactions.add(
            new CriterionSatisfactionDTO(criterionTypeName, criterionName2,
                startDate2, endDate2));

        return machineDTO;

    }
View Full Code Here

TOP

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

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.