Package org.libreplan.business.common.exceptions

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


    public ExpenseSheetLine getExpenseSheetLineByCode(String code)
            throws ValidationException {

        if (StringUtils.isBlank(code)) {
            throw new ValidationException(
                    "missing the code with which find the expense sheet line");
        }

        for (ExpenseSheetLine l : this.expenseSheetLines) {
            if (l.getCode().equalsIgnoreCase(StringUtils.trim(code))) {
View Full Code Here


                MaterialCategory parentCategory = Registry
                        .getMaterialCategoryDAO().findByCode(
                                materialCategoryDTO.parent);
                materialCategory.setParent(parentCategory);
            } catch (InstanceNotFoundException e) {
                throw new ValidationException(
                        "There is no material category with this code");
            }
        }

        return materialCategory;
View Full Code Here

        MaterialCategory materialCategory = toEntityCategory(materialCategoryDTO);

        // find the parent
        if (materialCategoryDTO.parent != null) {
            if (!materialCategoryDTO.parent.equalsIgnoreCase(parent.getCode())) {
                throw new ValidationException("inconsistent parent code.");
            }
        }

        return materialCategory;
View Full Code Here

                UnitType unitType = Registry.getUnitTypeDAO()
                        .findByCodeAnotherTransaction(
                        materialDTO.unitType);
                material.setUnitType(unitType);
            } catch (InstanceNotFoundException e) {
                throw new ValidationException("unit type code not found");
            }
        }

        return material;
View Full Code Here

                && (materialCategory.getParent() != null)
                && (!materialCategory.getParent().getCode().equalsIgnoreCase(
                        materialCategoryDTO.parent)))
                || ((!(materialCategoryDTO.parent == null) && (materialCategory
                        .getParent() == null)))) {
            throw new ValidationException("inconsistent parent code.");
        }

        /*
         * 1: Update basic properties in existing material category and add new
         * materials.
         */
        if (materialCategoryDTO.materials != null) {
            for (MaterialDTO materialDTO : materialCategoryDTO.materials) {

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

                try {
                    Material material = materialCategory
                        .getMaterialByCode(materialDTO.code);
                    updateMaterial(material, materialDTO);
                } catch (InstanceNotFoundException e) {
                    materialCategory.addMaterial(toEntity(materialDTO));
                }
            }
        }

        /*
         * 2: Update basic properties in existing subcategories and add new
         * subcategories.
         */
        if (materialCategoryDTO.subcategories != null) {
            for (MaterialCategoryDTO subcategoryDTO : materialCategoryDTO.subcategories.materialCategoryDTOs) {

                /* Step 2.1 requires each subcategory DTO to have a code. */
                if (StringUtils.isBlank(subcategoryDTO.code)) {
                    throw new ValidationException(
                            "missing code in a subcategory");
                }

                try {
                    MaterialCategory subcategory = materialCategory
View Full Code Here

                UnitType type = Registry.getUnitTypeDAO()
                        .findByCodeAnotherTransaction(
                        materialDTO.unitType);
                material.setUnitType(type);
            } catch (InstanceNotFoundException e) {
                throw new ValidationException("unit type code not found");
            }
        }
        material.updateUnvalidated(StringUtils.trim(materialDTO.description),
                materialDTO.defaultPrice, materialDTO.disabled);
    }
View Full Code Here

    private static CriterionSatisfaction toEntity(
        CriterionSatisfactionDTO criterionSatisfactionDTO, Resource resource) {

        if (StringUtils.isBlank(criterionSatisfactionDTO.criterionTypeName)) {
            throw new ValidationException("criterion type name not specified");
        }

        if (StringUtils.isBlank(criterionSatisfactionDTO.criterionName)) {
            throw new ValidationException("criterion name not specified");
        }

        try {

            return CriterionSatisfaction.createUnvalidated(
View Full Code Here

        } catch (InstanceNotFoundException e) {
                throw new InstanceNotFoundRecoverableErrorException(
                        RESOURCE_CALENDAR_ENTITY_TYPE, e.getKey().toString());
        } catch (MultipleInstancesException e) {
            throw new ValidationException(MessageFormat.format(
                    "there exist multiple resource calendars with name {0}",
                    calendarCode));
        }
    }
View Full Code Here

            }

            if (!StringUtils.isBlank(calendarDTO.code)) {
                calendar.setCode(calendarDTO.code);
            } else {
                throw new ValidationException(
                        "missing code in the resource calendar");
            }

            if (calendarDTO.capacity != null) {
                calendar.setCapacity(calendarDTO.capacity);
View Full Code Here

    private static ResourcesCostCategoryAssignment toEntity(
        ResourcesCostCategoryAssignmentDTO assignmentDTO, Resource resource) {

        if (StringUtils.isBlank(assignmentDTO.costCategoryName)) {
            throw new ValidationException("cost category name not specified");
        }

        try {
            return ResourcesCostCategoryAssignment.createUnvalidated(
                assignmentDTO.code,
View Full Code Here

TOP

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

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.