Examples of CriterionType


Examples of org.libreplan.business.resources.entities.CriterionType

    @Test
    @Transactional
    public void testAddResourcesWithCriterionSatisfactionsWithMissingNames() {

        /* Create a criterion type. */
        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

Examples of org.libreplan.business.resources.entities.CriterionType

    @Test
    @Transactional
    public void testAddResourceWithCriterionSatisfactionsWithNonExistentCriterion() {

        /* Create a criterion type. */
        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

Examples of org.libreplan.business.resources.entities.CriterionType

    @Test
    @Transactional
    public void testUpdateResources() throws InstanceNotFoundException {

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

Examples of org.libreplan.business.resources.entities.CriterionType

            new IOnTransaction<CriterionType>() {

            @Override
            public CriterionType execute() {

                CriterionType ct = CriterionType.create(getUniqueName(),
                    "desc");
                ct.setAllowSimultaneousCriterionsPerResource(
                    allowSimultaneousCriterionsPerResource);
                ct.setResource(resourceType);
                Criterion c1 = Criterion.create("c1", ct);
                Criterion c2 = Criterion.create("c2", ct);
                ct.getCriterions().add(c1);
                ct.getCriterions().add(c2);
                criterionTypeDAO.save(ct);

                return ct;

            }
View Full Code Here

Examples of org.libreplan.business.resources.entities.CriterionType

        /* Update criterion type and test. */
        assertNoConstraintViolations(criterionService.addCriterionTypes(
            createCriterionTypeListDTO(ctUpdated)));

        CriterionType ctEntity = criterionTypeDAO.findByCode(ct.code);
        assertTrue(ctEntity.getCriterions().size() == 4);

        /* Test criterion hierarchy. */
        Criterion c1Entity = ctEntity.getCriterion(c1.name);
        Criterion c2Entity = ctEntity.getCriterion(c2Updated.name);
        Criterion c2c1Entity = ctEntity.getCriterion(c2c1.name);
        Criterion c3Entity = ctEntity.getCriterion(c3.name);

        assertNull(c1Entity.getParent());
        assertTrue(c1Entity.getChildren().size() == 1);
        assertTrue(c1Entity.getChildren().contains(c2Entity));
        assertTrue(c2Entity.getChildren().size() == 1);
        assertTrue(c2Entity.getChildren().contains(c2c1Entity));
        assertTrue(c2c1Entity.getChildren().size() == 0);
        assertNull(c3Entity.getParent());
        assertTrue(c3Entity.getChildren().size() == 0);

        /*
         * Basic properties in criteria "c1" and "c2", which are contained in
         * "ctUpdated", must not be modified, except c2's name property.
         */
        assertEquals(c1.name, c1Entity.getName());
        assertEquals(c1.active, c1Entity.isActive());

        assertEquals(c2Updated.name, c2Entity.getName());
        assertEquals(c2.active, c2Entity.isActive());

        /*
         * Basic properties values, except description, must be not be
         * modified.
         */
        assertEquals(ct.name, ctEntity.getName());
        assertEquals(ctUpdated.description, ctEntity.getDescription());
        assertEquals(ct.allowHierarchy, ctEntity.allowHierarchy());
        assertEquals(ct.allowSimultaneousCriterionsPerResource,
            ctEntity.isAllowSimultaneousCriterionsPerResource());
        assertEquals(ct.enabled, ctEntity.isEnabled());
        assertEquals(ResourceEnumConverter.fromDTO(ct.resource),
            ctEntity.getResource());

    }
View Full Code Here

Examples of org.libreplan.business.resources.entities.CriterionType

        if (criterionTypeDAO.findAll().isEmpty()) {
            Map<CriterionType, List<String>> typesWithCriterions = getTypesWithCriterions();
            // Insert predefined criterions
            for (Entry<CriterionType, List<String>> entry : typesWithCriterions
                    .entrySet()) {
                CriterionType criterionType = retrieveOrCreate(entry.getKey());
                // Create predefined criterions for criterionType
                for (String criterionName : entry.getValue()) {
                    ensureCriterionExists(criterionName, criterionType);
                }
            }
View Full Code Here

Examples of org.libreplan.business.resources.entities.CriterionType

            Set<Long> idsOfTypesAlreadyAttached,
            List<GenericResourceAllocation> generic) {
        for (GenericResourceAllocation eachGenericAllocation : generic) {
            Set<Criterion> criterions = eachGenericAllocation.getCriterions();
            for (Criterion eachCriterion : criterions) {
                CriterionType type = eachCriterion.getType();
                if (!idsOfTypesAlreadyAttached.contains(type.getId())) {
                    idsOfTypesAlreadyAttached.add(type.getId());
                    criterionTypeDAO.reattachUnmodifiedEntity(type);
                }
            }
        }
    }
View Full Code Here

Examples of org.libreplan.business.resources.entities.CriterionType

    }

    @Override
    @Transactional(readOnly = true)
    public CriterionType getCriterionType(Criterion criterion) {
        CriterionType criterionType = criterion.getType();
        criterionTypeDAO.reattach(criterionType);
        criterionType.getName();
        return criterionType;
    }
View Full Code Here

Examples of org.libreplan.business.resources.entities.CriterionType

        this.state = "";
        this.criterionAndType = "";
        this.setCriterionSatisfaction(criterionSatisfaction);

        Criterion criterion = criterionSatisfaction.getCriterion();
        CriterionType type = criterion.getType();
        this.setCriterionWithItsType(new CriterionWithItsType(type,criterion));
    }
View Full Code Here

Examples of org.libreplan.business.resources.entities.CriterionType

    public List<CriterionWithItsType> getValidCriterions() {
        List<CriterionWithItsType> list = new ArrayList<CriterionWithItsType>();
        for (IndirectCriterionRequirement requirement : getValidIndirectCriterionRequirement()) {
            Criterion criterion = requirement.getCriterion();
            CriterionType type = criterion.getType();
            list.add(new CriterionWithItsType(type, criterion));
        }
        return list;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.