Package org.libreplan.business.resources.entities

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


        }
        return false;
    }

    private boolean acceptCriterion(FilterPair filter, TaskElement taskElement) {
        Criterion filterCriterion = (Criterion) filter.getValue();
        return existCriterionInTaskElementResourceAllocations(filterCriterion,
                taskElement);
    }
View Full Code Here


    @Override
    public Criterion find(Criterion criterion) throws InstanceNotFoundException {
        if (criterion.getId() != null) {
            return super.find(criterion.getId());
        }
        Criterion result = findUniqueByNameAndType(criterion);

        return result;
    }
View Full Code Here

    }

    @Override
    public void removeByNameAndType(Criterion criterion) {
        try {
            Criterion reloaded = findUniqueByNameAndType(criterion);
            remove(reloaded.getId());
        } catch (InstanceNotFoundException ex) {
            throw new RuntimeException(ex);
        }
    }
View Full Code Here

        }
    }

    private void ensureCriterionExists(String criterionName,
            CriterionType criterionType) {
        Criterion criterion = Criterion.createPredefined(criterionName,
                criterionType);
        if (!criterionDAO.existsPredefinedCriterion(criterion)) {
            int numberOfDigits = getNumberOfDigitsCode();
            criterionType.setGenerateCode(criterion, numberOfDigits);
            criterionDAO.save(criterion);
View Full Code Here

    private void initializeCriterionSatisfactions(
            Set<CriterionSatisfaction> criterionsSatisfaction) {
        Set<CriterionType> types = new HashSet<CriterionType>();
        for (CriterionSatisfaction criterionSatisfaction : criterionsSatisfaction) {
            Criterion criterion = criterionSatisfaction.getCriterion();
            initializeCriterion(criterion);

            if (!types.contains(criterionSatisfaction.getCriterion().getType())) {
                types.add(criterionSatisfaction.getCriterion().getType());
                reattachCriterionType(criterionSatisfaction.getCriterion()
View Full Code Here

    private boolean sameCriterion(CriterionSatisfactionDTO otherSatisfaction,
            CriterionSatisfactionDTO satisfaction) {
        if (otherSatisfaction.getCriterionWithItsType() == null){
            return false;
        }
        Criterion otherCriterion = otherSatisfaction.getCriterionWithItsType()
                .getCriterion();
        return otherCriterion.getId().equals(
                satisfaction.getCriterionWithItsType().getCriterion().getId());
    }
View Full Code Here

    }

    private void updateSatisfaction(CriterionSatisfactionDTO satisfactionDTO) {
        CriterionSatisfaction satisfaction = satisfactionDTO
                .getCriterionSatisfaction();
        Criterion newCriterion = satisfactionDTO.getCriterionWithItsType()
                .getCriterion();
        satisfaction.setCriterion(newCriterion);
        satisfaction.setStartDate(satisfactionDTO.getStart());
        satisfaction.setEndDate(satisfactionDTO.getEnd());
    }
View Full Code Here

        updateDTOs();
    }

    private void validateDTOs() throws ValidationException {
        for (CriterionSatisfactionDTO satisfactionDTO : getWithCriterionAssignedDTOs()) {
            Criterion criterion = satisfactionDTO.getCriterionWithItsType()
                    .getCriterion();
            if (checkSameCriterionAndSameInterval(satisfactionDTO)) {
                throw new IllegalStateException(_("The {0} can not be assigned to this resource. Its interval overlaps with other criterion", criterion.getName()));
            }
            if (checkNotAllowSimultaneousCriterionsPerResource(satisfactionDTO)) {
                throw new IllegalStateException(_("The {0} is not valid. Other value exists from the same criterion type", criterion.getName()));
            }
        }
    }
View Full Code Here

        // Create a new list of Criterion satisfaction
        Set<CriterionSatisfaction> newList = new HashSet<CriterionSatisfaction>();
        for (CriterionSatisfactionDTO satisfactionDTO : getWithCriterionAssignedDTOs()) {
            CriterionSatisfaction satisfaction;
            if (satisfactionDTO.isNewObject()) {
                Criterion criterion = satisfactionDTO.getCriterionWithItsType()
                        .getCriterion();
                Interval interval = satisfactionDTO.getInterval();
                satisfaction = CriterionSatisfaction.create(criterion,
                        resource, interval);
View Full Code Here

        }
        throw new RuntimeException("Could not find the criterion " + criterion);
    }

    public void saveCriterionSatisfaction() {
        Criterion choosenCriterion = getChoosenCriterion();
        CriterionWithItsType criterionWithItsType = fromCriterionToType
                .get(choosenCriterion);
        satisfactionEdited.setCriterion(choosenCriterion);
        AddingSatisfactionResult addSatisfaction = workerModel.addSatisfaction(
                criterionWithItsType.getType(), originalSatisfaction,
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.