Package org.libreplan.business.resources.entities

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


    private static Criterion toEntityWithoutChildren(
        CriterionDTO childDTO, CriterionType criterionType,
        Criterion criterionParent) {

        Criterion criterion = Criterion.createUnvalidated(
            StringUtils.trim(childDTO.code),
            StringUtils.trim(childDTO.name),
            criterionType, criterionParent, childDTO.active);

        return criterion;
View Full Code Here


    @Override
    public void copyIndirectCriterionRequirementsFromOriginalToOrderLineGroupChildren(
            OrderLineGroup orderLineGroup, DirectCriterionRequirement parent) {

        final List<OrderElement> orderElements = orderLineGroup.getChildren();
        final Criterion criterion = parent.getCriterion();
        final Set<IndirectCriterionRequirement> originalIndirectCriterionRequirements = parent
                .getOrigin().getChildren();
        final Map<OrderElementTemplate, Map<Criterion, Boolean>> mapTemplateCriterion =
            createTemplateCriterionMap(originalIndirectCriterionRequirements);
View Full Code Here

            List<Object> results) {

        Map<Criterion, List<GenericResourceAllocation>> result = new HashMap<Criterion, List<GenericResourceAllocation>>();
        for (Object row : results) {
            GenericResourceAllocation allocation = getAllocation(row);
            Criterion criterion = getCriterion(row);
            if (!result.containsKey(criterion)) {
                result.put(criterion,
                        new ArrayList<GenericResourceAllocation>());
            }
            result.get(criterion).add(allocation);
View Full Code Here

            Map<Criterion, List<GenericResourceAllocation>> byCriterion) {
        Map<Criterion, List<GenericResourceAllocation>> toBeMerged = new HashMap<Criterion, List<GenericResourceAllocation>>();

        for (Entry<Criterion, List<GenericResourceAllocation>> each : byCriterion
                .entrySet()) {
            Criterion criterion = each.getKey();
            for (Criterion parent : getParentsFrom(criterion)) {
                List<GenericResourceAllocation> childAllocations = each
                        .getValue();
                addToCriterion(toBeMerged, parent, childAllocations);
            }
View Full Code Here

        return byCriterion;
    }

    private List<Criterion> getParentsFrom(Criterion criterion) {
        List<Criterion> result = new ArrayList<Criterion>();
        Criterion current = criterion.getParent();
        while (current != null) {
            result.add(current);
            current = current.getParent();
        }
        return result;
    }
View Full Code Here

        return true;
    }

    boolean existSameCriterionRequirement(
            CriterionRequirement newRequirement) {
        Criterion criterion = newRequirement.getCriterion();
        for(CriterionRequirement requirement : getCriterionRequirements()){
            if (requirement.getCriterion().equals(criterion)) {
                return true;
            }
        }
View Full Code Here

        final String repeatedName = UUID.randomUUID().toString();
        transactionService.runOnTransaction(new IOnTransaction<Void>() {

            @Override
            public Void execute() {
                Criterion criterion = givenValidCriterionFor(
                        PredefinedCriterionTypes.CATEGORY, repeatedName);
                try {
                    criterionDAO.save(criterion);
                } catch (ValidationException e) {
                    throw new RuntimeException(e);
                }
                return null;
            }
        });
        transactionService.runOnTransaction(new IOnTransaction<Void>() {

            @Override
            public Void execute() {
                try {
                    Criterion criterion2 = givenValidCriterionFor(
                            PredefinedCriterionTypes.CATEGORY, repeatedName);
                    CriterionType type = criterion2.getType();
                    type.getCriterions().add(criterion2);
                    criterionTypeDAO.save(type);
                } catch (ValidationException e) {
                    assertThat(e.getInvalidValues().size(), equalTo(1));
                    // ValidationException is expected
View Full Code Here

                    public Criterion execute() {
                        CriterionType criterionType = CriterionType.create(
                                "test" + UUID.randomUUID(), "");
                        criterionType.setResource(ResourceEnum.WORKER);
                        criterionTypeDAO.save(criterionType);
                        Criterion criterion = Criterion.create("Test"
                                + UUID.randomUUID(), criterionType);

                        try {
                            criterionDAO.save(criterion);
                        } catch (ValidationException e) {
View Full Code Here

        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.
         */
 
View Full Code Here

                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

TOP

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

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.