Package org.libreplan.business.common.exceptions

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


        labelType.generateLabelCodes(getNumberOfDigitsCode());
    }

    private void checkLabelTypeUnique() {
        if (!labelTypeDAO.isUnique(labelType)) {
            throw new ValidationException(createInvalidValue(labelType));
        }
    }
View Full Code Here


                    result.add(createInvalidValue(labels.get(j)));
                }
            }
        }
        if (!result.isEmpty()) {
            throw new ValidationException(result);
        }
    }
View Full Code Here

    @Override
    public void thereIsOtherWithSameNameAndType(String name)
            throws ValidationException {
        for (Label label : labelType.getLabels()) {
            if (name.equals(label.getName())) {
                throw new ValidationException(
                        invalidValue(_("Already exists other "
                                + "label with the same name"), "name", name,
                                getLabelType()));
            }
        }
View Full Code Here

    }

    @Override
    public void validateNameNotEmpty(String name) throws ValidationException {
        if (name.isEmpty()) {
            throw new ValidationException(invalidValue(
                    _("The name of the label is empty."),
                    "name", "", getLabelType()));
        }
    }
View Full Code Here

    private static ExpenseSheetLineDTO toDTO(ExpenseSheetLine line) {
        if (line != null) {

            String code = line.getCode();
            if (StringUtils.isBlank(code)) {
                throw new ValidationException(
                        "missing code in the expense sheet line");
            }

            BigDecimal value = line.getValue();
            if (value == null || value.compareTo(BigDecimal.ZERO) < 0) {
                value = BigDecimal.ZERO;
            }
            String resourceCode = null;
            if (line.getResource() != null) {
                resourceCode = line.getResource().getCode();
            }

            String orderElementCode = null;
            if (line.getOrderElement() != null) {
                orderElementCode = line.getOrderElement().getCode();
            } else {
                throw new ValidationException(
                        "missing order element code in a expense sheet line");
            }

            XMLGregorianCalendar date = null;
            if (line.getDate() != null) {
                date = DateConverter.toXMLGregorianCalendar(line.getDate());
            } else {
                throw new ValidationException(
                        "missing date in a expense sheet line");
            }

            return new ExpenseSheetLineDTO(code, line.getConcept(), value,
                    resourceCode, orderElementCode, date);
        } else {
            throw new ValidationException(
                    "the expense sheet line is not initialized");
        }
    }
View Full Code Here

    }

    private static ExpenseSheetLine toEntity(ExpenseSheetLineDTO lineDTO, ExpenseSheet expenseSheet) {
        String code = lineDTO.code;
        if(StringUtils.isBlank(code)){
            throw new ValidationException("missing code expense sheet line");
        }

        BigDecimal value = lineDTO.value;
        String concept = lineDTO.concept;

        LocalDate date = null;
        if (lineDTO.date != null) {
            date = DateConverter.toLocalDate(lineDTO.date);
        }

        String orderElementCode = lineDTO.orderElement;
        OrderElement orderElement = null;
        try{
            orderElement = Registry.getOrderElementDAO().findByCode(
                    orderElementCode);
        }catch (InstanceNotFoundException e) {
            throw new ValidationException(
                    "There is no order element with this code");
        }

        ExpenseSheetLine line = ExpenseSheetLine.create(value, concept, date,
                orderElement);
        line.setExpenseSheet(expenseSheet);
        line.setCode(code);

        if(lineDTO.resource != null){
            String resourceCode = lineDTO.resource;
            try{
                Resource resource = Registry.getResourceDAO().findByCode(resourceCode);
                line.setResource(resource);
            }catch (InstanceNotFoundException e) {
                throw new ValidationException(
                        "There is no resource with this code");
            }
        }

        return line;
View Full Code Here

    public final static void updateExpenseSheet(ExpenseSheet expenseSheet,
            ExpenseSheetDTO expenseSheetDTO) throws ValidationException {

        if (StringUtils.isBlank(expenseSheetDTO.code)) {
            throw new ValidationException("missing code in a expense sheet.");
        }

        if (!StringUtils.isBlank(expenseSheetDTO.description)) {
            expenseSheet.setDescription(expenseSheetDTO.description);
        }
        /*
         * 1: Update the existing expense sheet line or add new expense sheet
         * line.
         */
        for (ExpenseSheetLineDTO lineDTO : expenseSheetDTO.lines) {

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

            ExpenseSheetLine line = expenseSheet
                    .getExpenseSheetLineByCode(lineDTO.code);
View Full Code Here

            try {
                OrderElement orderElement = Registry.getOrderElementDAO()
                        .findUniqueByCode(orderElementCode);
                line.setOrderElement(orderElement);
            } catch (InstanceNotFoundException e) {
                throw new ValidationException("There is no task with this code");
            }
        }

        /* Step 3.1: Update the date. */
        if (lineDTO != null) {
            LocalDate date = DateConverter.toLocalDate(lineDTO.date);
            line.setDate(date);
        }

        /* Step 3.4: Update the resource. */
        if (lineDTO.resource != null) {
            try {
                Resource resource = Registry.getResourceDAO().findByCode(
                        lineDTO.resource);
                line.setResource(resource);
            } catch (InstanceNotFoundException e) {
                throw new ValidationException(
                        "There is no resource with this code");
            }
        }

    }
View Full Code Here

    @Override
    public void confirm() throws ValidationException {
        if (stretchesFunction != null) {
            if (!stretchesFunction.isNoEmptyConstraint()) {
                throw new ValidationException(
                        _("At least one stretch is needed"));
            }
            if (!stretchesFunction.isStretchesOrderConstraint()) {
                throw new ValidationException(
                        _("Some stretch has higher or equal values than the "
                                + "previous stretch"));
            }
            if (!stretchesFunction.isOneHundredPercentConstraint()) {
                throw new ValidationException(
                        _("Last stretch should have 100% for length and amount of work"));
            }
            if (stretchesFunction.isInterpolated()) {
                if (!stretchesFunction.checkHasAtLeastTwoStretches()) {
                    throw new ValidationException(
                            _("There must be at least 2 stretches for doing interpolation"));
                }
            }
            if (originalStretchesFunction != null) {
                originalStretchesFunction
View Full Code Here

                return calendar;

            }
        }

        throw new ValidationException(_("Linked calendar not found"));
    }
View Full Code Here

TOP

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

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.