Package org.libreplan.business.common.exceptions

Examples of org.libreplan.business.common.exceptions.ValidationException$BasedOnConstraintViolation


        Map<Integer, Capacity> capacitiesPerDays = getCapacitiesPerDays(
                workingWeek.hoursPerDays, parent);
        try {
            calendarData.updateCapacitiesPerDay(capacitiesPerDays);
        } catch (IllegalArgumentException e) {
            throw new ValidationException(e.getMessage());
        }

        return calendarData;
    }
View Full Code Here


                    result.put(day, capacity);

                } catch (IllegalArgumentException e) {

                    throw new ValidationException("a day is not valid");

                } catch (NullPointerException e) {

                    throw new ValidationException("a day is null");
                }
            }
        }

        return result;
View Full Code Here

    private static void validateQueueElement(
            LimitingResourceQueueElement queueElement) {
        if ((queueElement.getStartDate() == null)
                || (queueElement.getEndDate() == null)) {
            throw new ValidationException(_("Invalid queue element"));
        }
    }
View Full Code Here

        List<LabelDTO> labelDTOs = labelTypeDTO.labels;
        for (LabelDTO labelDTO : labelDTOs) {

            /* Step 1.1: requires each label DTO to have a code. */
            if (StringUtils.isBlank(labelDTO.code)) {
                throw new ValidationException("missing code in a label");
            }

            try {
                Label label = labelType.getLabelByCode(labelDTO.code);
                label.updateUnvalidated(StringUtils.trim(labelDTO.name));
View Full Code Here

    private static void checkOrderElementDTOCode(
            OrderElementDTO orderElementDTO,
            String instance) {
        if (orderElementDTO.code == null) {
            throw new ValidationException(MessageFormat.format(
                    "{0}: code not found", instance));
        }
    }
View Full Code Here

                        try {
                            criterionRequirable
                                .addCriterionRequirement(DirectCriterionRequirement
                                        .create(criterion));
                        } catch (IllegalStateException e) {
                            throw new ValidationException(e.getMessage());
                        }
                    }
                } else { // criterionRequirementDTO instanceof
                    // IndirectCriterionRequirementDTO
                    IndirectCriterionRequirement indirectCriterionRequirement = getIndirectCriterionRequirementByCriterion(
                            criterionRequirable, criterion);
                    if (indirectCriterionRequirement != null) {
                        indirectCriterionRequirement
                                .setValid(((IndirectCriterionRequirementDTO) criterionRequirementDTO).valid);
                    }
                }
            } else {
                if (criterionRequirementDTO.name == null
                        || criterionRequirementDTO.type == null) {
                    throw new ValidationException(
                            "the criterion format is incorrect");
                } else {
                    throw new ValidationException("the criterion "
                        + criterionRequirementDTO.name + " which type is "
                        + criterionRequirementDTO.type + " not found");
                }
            }
        }
View Full Code Here

        if (configuration.isLabels()) {
            for (LabelReferenceDTO labelDTO : orderElementDTO.labels) {
                try {
                orderElement.addLabel(LabelReferenceConverter.toEntity(labelDTO));
                } catch (InstanceNotFoundException e) {
                    throw new ValidationException("Label " + labelDTO.code
                            + " not found.");
                }
            }
        }
View Full Code Here

            ConfigurationOrderElementConverter configuration)
            throws ValidationException {

        if (orderElementDTO instanceof OrderLineDTO) {
            if (!(orderElement instanceof OrderLine)) {
                throw new ValidationException(MessageFormat.format(
                        "Task {0}: Task group is incompatible type with {1}",
                        orderElement.getCode(), orderElement.getClass()
                                .getName()));
            }

            if (configuration.isHoursGroups()) {
                for (HoursGroupDTO hoursGroupDTO : ((OrderLineDTO) orderElementDTO).hoursGroups) {
                    if (((OrderLine) orderElement)
                            .containsHoursGroup(hoursGroupDTO.code)) {
                        update(((OrderLine) orderElement)
                                .getHoursGroup(hoursGroupDTO.code),
                                hoursGroupDTO, configuration);
                    } else {
                        ((OrderLine) orderElement)
                                .addHoursGroup(toEntity(
                                hoursGroupDTO, configuration));
                    }
                }
            }
        } else { // orderElementDTO instanceof OrderLineGroupDTO
            if (orderElementDTO instanceof OrderDTO) {
                if (!(orderElement instanceof Order)) {
                    throw new ValidationException(MessageFormat.format(
                            "Task {0}: Project is incompatible type with {1}",
                            orderElement.getCode(), orderElement.getClass()
                                    .getName()));

                }
                Order order = (Order) orderElement;
                orderVersion = order.getOrderVersionFor(Registry
                        .getScenarioManager()
                        .getCurrent());
                order.useSchedulingDataFor(orderVersion);
                Boolean dependenciesConstraintsHavePriority = ((OrderDTO) orderElementDTO).dependenciesConstraintsHavePriority;
                if (dependenciesConstraintsHavePriority != null) {
                    ((Order) orderElement)
                            .setDependenciesConstraintsHavePriority(dependenciesConstraintsHavePriority);
                }

                String calendarName = ((OrderDTO) orderElementDTO).calendarName;
                if (calendarName != null) {
                    if (!((Order) orderElement).getCalendar().getName().equals(
                            calendarName)) {
                        List<BaseCalendar> calendars = Registry
                                .getBaseCalendarDAO()
                                .findByName(
                                        ((OrderDTO) orderElementDTO).calendarName);
                        if (calendars.size() == 1) {
                            ((Order) orderElement)
                                    .setCalendar(calendars.get(0));
                        }
                    }
                }
            } else { // orderElementDTO instanceof OrderLineGroupDTO
                if (!(orderElement instanceof OrderLineGroup)) {
                    throw new ValidationException(
                            MessageFormat
                                    .format("Task {0}: Task group is incompatible type with {1}",
                                            orderElement.getCode(),
                                            orderElement.getClass().getName()));
                }
            }

            for (OrderElementDTO childDTO : ((OrderLineGroupDTO) orderElementDTO).children) {
                if (orderElement.containsOrderElement(childDTO.code)) {
                    update(orderVersion,
                            orderElement.getOrderElement(childDTO.code),
                            childDTO, configuration);
                } else {
                    if (checkConstraintUniqueOrderCode(childDTO)) {
                        throw new ValidationException(
                                MessageFormat.format(
                                        "Task {0}: Duplicate code in DB",
                                        childDTO.code));
                    }
                    if (checkConstraintUniqueHoursGroupCode(childDTO)) {
                        throw new ValidationException(MessageFormat.format(
                                "Hours Group {0}: Duplicate code in DB",
                                childDTO.code));
                    }
                    ((OrderLineGroup) orderElement).add(toEntity(orderVersion,
                            childDTO, configuration));
                }
            }

        }

        if (configuration.isLabels()) {
            for (LabelReferenceDTO labelDTO : orderElementDTO.labels) {
                if (!orderElement.containsLabel(labelDTO.code)) {
                    try {
                        orderElement.addLabel(LabelReferenceConverter
                                .toEntity(labelDTO));
                    } catch (InstanceNotFoundException e) {
                        throw new ValidationException("Label " + labelDTO.code
                                + " not found");
                    } catch (IllegalArgumentException e) {
                        throw new ValidationException(e.getMessage());
                    }
                }
            }
        }
View Full Code Here

    public final static void update(HoursGroup hoursGroup,
            HoursGroupDTO hoursGroupDTO,
            ConfigurationOrderElementConverter configuration) {
        if (!hoursGroup.getCode().equals(hoursGroupDTO.code)) {
            throw new ValidationException(
                    "Not the same hours group, impossible to update");
        }

        if (hoursGroupDTO.workingHours != null) {
            hoursGroup.setWorkingHours(hoursGroupDTO.workingHours);
View Full Code Here

    public final static void update(MaterialAssignment materialAssignment,
            MaterialAssignmentDTO materialAssignmentDTO) {
        if (!materialAssignment.getMaterial().getCode().equals(
                materialAssignmentDTO.materialCode)) {
            throw new ValidationException(
                    "Not the same material, impossible to update");
        }

        if (materialAssignmentDTO.units != null) {
            materialAssignment.setUnits(materialAssignmentDTO.units);
View Full Code Here

TOP

Related Classes of org.libreplan.business.common.exceptions.ValidationException$BasedOnConstraintViolation

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.