Package org.libreplan.business.common.exceptions

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


        try {
        return BaseCalendar.createUnvalidated(baseCalendarDTO.code,
                baseCalendarDTO.name, parent, exceptions, calendarDataVersions);
        } catch (IllegalArgumentException e) {
            throw new ValidationException(e.getMessage());
        }
    }
View Full Code Here


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

        return calendarData;
    }
View Full Code Here

        if (baseCalendarDTO.calendarExceptions != null) {
            for (CalendarExceptionDTO exceptionDTO : baseCalendarDTO.calendarExceptions) {

                if (StringUtils.isBlank(exceptionDTO.code)) {
                    throw new ValidationException(
                            "missing code in a calendar exception");
                }

                if (exceptionDTO.date == null) {
                    throw new ValidationException(
                            "missing date in a calendar exception");
                }
                // find by code
                try {
                    CalendarException exception = baseCalendar
                            .getCalendarExceptionByCode(exceptionDTO.code);
                    update(exception, exceptionDTO);
                } catch (InstanceNotFoundException e) {
                    // find by date
                    CalendarException exception = baseCalendar
                            .getOwnExceptionDay(DateConverter
                                    .toLocalDate(exceptionDTO.date));
                    if (exception != null) {
                        throw new ValidationException(
                                "exception date already exists");
                    } else {
                        try {
                            baseCalendar
                                    .addExceptionDay(toEntity(exceptionDTO));
                        } catch (IllegalArgumentException o) {
                            throw new ValidationException(o.getMessage());
                        }
                    }
                }
            }
        }

        if (baseCalendarDTO.calendarDatas != null) {

            for (CalendarDataDTO calendarDataDTO : baseCalendarDTO.calendarDatas) {

                if (StringUtils.isBlank(calendarDataDTO.code)) {
                    throw new ValidationException(
                            "missing code in a calendar data version");
                }

                // find by code
                try {
                    CalendarData version = baseCalendar
                            .getCalendarDataByCode(calendarDataDTO.code);
                    update(version, calendarDataDTO);
                } catch (InstanceNotFoundException e) {
                    try {
                        baseCalendar.addNewVersion(toEntity(calendarDataDTO));
                    } catch (IllegalArgumentException o) {
                        throw new ValidationException(o.getMessage());
                    }
                }
            }

        }

        BaseCalendar parent = null;
        if (!StringUtils.isBlank(baseCalendarDTO.parent)) {
            try {
                parent = Registry.getBaseCalendarDAO().findByCode(
                        baseCalendarDTO.parent);
            } catch (InstanceNotFoundException e) {
                throw new ValidationException(
                        "The base calendar parent not found");
            }
        }

        baseCalendar.updateUnvalidated(baseCalendarDTO.name, parent);
View Full Code Here

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

        calendarData.updateUnvalidated(expiringDate, parent);

    }
View Full Code Here

                    Capacity capacity = Capacity.create(
                            EffortDuration.hours(hoursPerDayDTO.hours))
                            .overAssignableWithoutLimit();
                    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

        }

        try {
            return Registry.getBaseCalendarDAO().findByCode(parentCode);
        } catch (InstanceNotFoundException e) {
            throw new ValidationException("The base calendar parent not found");
        }
    }
View Full Code Here

        try {
            WorkReportType workReportType = Registry.getWorkReportTypeDAO()
                    .findUniqueByCode(workReportDTO.workReportType);
            workReport.setWorkReportType(workReportType);
        } catch (InstanceNotFoundException e) {
            throw new ValidationException(
                    "There is no type of work report with this code");
        }

        for (WorkReportLineDTO workReportLineDTO : workReportDTO.workReportLines) {
            workReport
                    .addWorkReportLine(toEntity(workReportLineDTO, workReport));
        }

        // Optional fields
        if (workReportDTO.date != null) {
            workReport.setDate(DateConverter.toDate(workReportDTO.date));
        }

        bindingStrategy.assignOrderElementsToWorkReportLine(workReport,
                bindingStrategy.getOrderElementsBound(workReportDTO));

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

        if (workReportDTO.labels != null && !workReportDTO.labels.isEmpty()) {
            try {
                workReport.setLabels(LabelReferenceConverter
                        .toEntity(workReportDTO.labels));
            } catch (InstanceNotFoundException e) {
                throw new ValidationException(MessageFormat.format(
                        "There is no label with this code ",
                        (String) e.getKey()));
            }
        }
View Full Code Here

        }

        try {
            return Registry.getCalendarExceptionTypeDAO().findByCode(typeCode);
        } catch (InstanceNotFoundException e) {
            throw new ValidationException(
                    "The calendar exception type not found");
        }
    }
View Full Code Here

                TypeOfWorkHours typeOfWorkHours = Registry
                        .getTypeOfWorkHoursDAO().findUniqueByCode(
                                workReportLineDTO.typeOfWorkHours);
                workReportLine.setTypeOfWorkHours(typeOfWorkHours);
            } catch (InstanceNotFoundException e) {
                throw new ValidationException(
                        "There is no type of work hours with this code");
            }
        }

        // Optional fields
        if (workReportLineDTO.date != null) {
            workReportLine
                    .setDate(DateConverter.toDate(workReportLineDTO.date));
        }

        bindingStrategy.assignOrderElementsToWorkReportLine(workReportLine,
                bindingStrategy.getOrderElementsBound(workReportLineDTO));

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

        if (workReportLineDTO.clockStart != null) {
View Full Code Here

        String workReportTypeCode = null;
        if (workReport.getWorkReportType() != null) {
            workReportTypeCode = workReport.getWorkReportType()
                    .getCode();
        } else {
            throw new ValidationException(
                    "missing work report code in a work report");
        }

        // Optional fields
        XMLGregorianCalendar date = null;
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.