Package org.libreplan.business.common.exceptions

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


    }

    public Label getLabelByCode(String code) throws InstanceNotFoundException {

        if (StringUtils.isBlank(code)) {
            throw new InstanceNotFoundException(code, Label.class.getName());
        }

        for (Label l : labels) {
            if (l.getCode().equalsIgnoreCase(StringUtils.trim(code))) {
                return l;
            }
        }

        throw new InstanceNotFoundException(code, Label.class.getName());

    }
View Full Code Here


        Criteria c = getSession().createCriteria(ExternalCompany.class);
        c.add(Restrictions.eq("name", name));

        ExternalCompany found = (ExternalCompany) c.uniqueResult();
        if (found == null) {
            throw new InstanceNotFoundException(name, ExternalCompany.class.getName());
        }

        return found;
    }
View Full Code Here

        Criteria c = getSession().createCriteria(ExternalCompany.class);
        c.add(Restrictions.eq("nif", nif));

        ExternalCompany found = (ExternalCompany) c.uniqueResult();
        if (found == null) {
            throw new InstanceNotFoundException(nif, ExternalCompany.class.getName());
        }

        return found;
    }
View Full Code Here

        Criteria c = getSession().createCriteria(LabelType.class);
        c.add(Restrictions.eq("name", name));
        LabelType labelType = (LabelType) c.uniqueResult();

        if (labelType == null) {
            throw new InstanceNotFoundException(null, "LabelType");
        }
        return labelType;
    }
View Full Code Here

    public OrderElement findUniqueByCodeAndParent(OrderElement parent,
            String code) throws InstanceNotFoundException {
        List<OrderElement> list = findByCodeAndParent(parent, code);
        if (list.isEmpty() || list.size() > 1) {
            throw new InstanceNotFoundException(code, OrderElement.class
                    .getName());
        }
        return list.get(0);
    }
View Full Code Here

    @Transactional(readOnly = true)
    public OrderElement findByCode(String code)
            throws InstanceNotFoundException {

        if (StringUtils.isBlank(code)) {
            throw new InstanceNotFoundException(null, getEntityClass()
                    .getName());
        }

        OrderElement entity = (OrderElement) getSession().createCriteria(
                getEntityClass())
                .add(
                        Restrictions.eq("infoComponent.code", code.trim())
                                .ignoreCase()).uniqueResult();

        if (entity == null) {
            throw new InstanceNotFoundException(code, getEntityClass()
                    .getName());
        } else {
            return entity;
        }
View Full Code Here

        Criteria c = getSession().createCriteria(OrderElement.class);
        c.add(Restrictions.eq("infoComponent.code", code));

        OrderElement orderElement = (OrderElement) c.uniqueResult();
        if (orderElement == null) {
            throw new InstanceNotFoundException(code, OrderElement.class
                    .getName());
        } else {
            return orderElement;
        }
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    @Override
    public OrderElement findByExternalCode(String code) throws InstanceNotFoundException {

        if (StringUtils.isBlank(code)) {
            throw new InstanceNotFoundException(null, getEntityClass()
                    .getName());
        }

        Criteria c = getSession().createCriteria(OrderElement.class);
        c.add(Restrictions.eq("externalCode", code.trim()).ignoreCase());
        OrderElement entity = (OrderElement) c.uniqueResult();

        if (entity == null) {
            throw new InstanceNotFoundException(code, getEntityClass()
                    .getName());
        } else {
            return entity;
        }
View Full Code Here

    public CriterionSatisfaction getCriterionSatisfactionByCode(String code)
        throws InstanceNotFoundException {

        if (StringUtils.isBlank(code)) {
            throw new InstanceNotFoundException(code,
                 CriterionSatisfaction.class.getName());
        }

        for (CriterionSatisfaction i : criterionSatisfactions) {
            if (i.getCode().equalsIgnoreCase(StringUtils.trim(code))) {
                return i;
            }
        }

        throw new InstanceNotFoundException(code,
            CriterionSatisfaction.class.getName());

    }
View Full Code Here

    public ResourcesCostCategoryAssignment
        getResourcesCostCategoryAssignmentByCode(String code)
        throws InstanceNotFoundException {

        if (StringUtils.isBlank(code)) {
            throw new InstanceNotFoundException(code,
                ResourcesCostCategoryAssignment.class.getName());
        }

        for (ResourcesCostCategoryAssignment i :
            resourcesCostCategoryAssignments) {

            if (i.getCode().equalsIgnoreCase(StringUtils.trim(code))) {
                return i;
            }

        }

        throw new InstanceNotFoundException(code,
            ResourcesCostCategoryAssignment.class.getName());

    }
View Full Code Here

TOP

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

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.