Package org.libreplan.business.resources.entities

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


        /* 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

        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

            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

    }

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

        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

    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

    }

    @Override
    public CriterionType findUniqueByName(String name)
            throws InstanceNotFoundException {
        CriterionType result = findByName(name);
        if (result == null) {
              throw new InstanceNotFoundException(name,
                  CriterionType.class.getName());
          }
        return result;
View Full Code Here

    }

    @Override
    public boolean existsOtherCriterionTypeByName(CriterionType criterionType) {
        Validate.notNull(criterionType);
        CriterionType found = findByName(criterionType.getName());
        return found != null && criterionType != found;
    }
View Full Code Here

    }

    @Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW)
    public boolean hasDiferentTypeSaved(Long id, ResourceEnum resource) {
        try {
            CriterionType type = find(id);
            return (!(type.getResource().equals(resource)));
        } catch (InstanceNotFoundException e) {
            return false;
        }
    }
View Full Code Here

TOP

Related Classes of org.libreplan.business.resources.entities.CriterionType

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.