Package org.libreplan.business.common.exceptions

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


        Criteria c = getSession().createCriteria(Profile.class);
        c.add(Restrictions.eq("profileName", profileName).ignoreCase());
        Profile profile = (Profile) c.uniqueResult();

        if (profile == null) {
            throw new InstanceNotFoundException(profileName,
                Profile.class.getName());
        } else {
            return profile;
        }
View Full Code Here


    @Override
    @Transactional(readOnly = true)
    public Scenario findByName(String name) throws InstanceNotFoundException {
        if (StringUtils.isBlank(name)) {
            throw new InstanceNotFoundException(null, Scenario.class.getName());
        }

        Scenario scenario = (Scenario) getSession().createCriteria(
                Scenario.class).add(
                Restrictions.eq("name", name.trim()).ignoreCase())
                .uniqueResult();

        if (scenario == null) {
            throw new InstanceNotFoundException(name, Scenario.class.getName());
        } else {
            return scenario;
        }

    }
View Full Code Here

        Criteria criteria = getSession().createCriteria(Worker.class);
        criteria.add(Restrictions.eq("nif", nif.trim()).ignoreCase());

        List<Worker> list = criteria.list();
        if (list.size() != 1) {
            throw new InstanceNotFoundException(nif, Worker.class.getName());
        }

        return list.get(0);
    }
View Full Code Here

    public Criterion findUniqueByNameAndType(Criterion criterion) throws InstanceNotFoundException {
        List<Criterion> list = findByNameAndType(criterion);

        if (list.size() != 1) {
            throw new InstanceNotFoundException(criterion, Criterion.class
                    .getName());
        }

        return list.get(0);
    }
View Full Code Here

    public final static Label toEntity(LabelReferenceDTO labelReferenceDTO)
            throws InstanceNotFoundException {
        // FIXME review if this check could be moved to findByCode at
        // IntegrationEntityDAO
        if (labelReferenceDTO.code == null) {
            throw new InstanceNotFoundException(null, Label.class.getName());
        }

        return Registry.getLabelDAO().findByCode(labelReferenceDTO.code);
    }
View Full Code Here

    }

    private Material findUniqueByCode(String code)
            throws InstanceNotFoundException {
        if (code == null) {
            throw new InstanceNotFoundException(null, Material.class.getName());
        }

        Criteria criteria = getSession().createCriteria(Material.class);
        criteria.add(Restrictions.eq("code", code).ignoreCase());

        List<Material> list = criteria.list();
        if (list.size() != 1) {
            throw new InstanceNotFoundException(code, Material.class.getName());
        }
        return list.get(0);
    }
View Full Code Here

        Criteria c = getSession().createCriteria(CostCategory.class).
        add(Restrictions.eq("name", name).ignoreCase());
        CostCategory costCategory = (CostCategory) c.uniqueResult();

        if (costCategory == null) {
            throw new InstanceNotFoundException(name,
                    CostCategory.class.getName());
        } else {
            return costCategory;
        }
    }
View Full Code Here

        Criteria c = getSession().createCriteria(CostCategory.class).add(
                Restrictions.eq("code", code).ignoreCase());
        CostCategory costCategory = (CostCategory) c.uniqueResult();

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

        Criteria c = getSession().createCriteria(CostCategory.class);
        c.add(Restrictions.ilike("name", name, MatchMode.EXACT));
        CostCategory result = (CostCategory) c.uniqueResult();

        if (result == null) {
            throw new InstanceNotFoundException(name,
                    getEntityClass().getName());
        }

        return result;
    }
View Full Code Here

    public DescriptionValue getDescriptionValueByFieldName(String fieldName)
            throws InstanceNotFoundException {

        if (StringUtils.isBlank(fieldName)) {
            throw new InstanceNotFoundException(fieldName,
                    DescriptionValue.class.getName());
        }

        for (DescriptionValue v : this.descriptionValues) {
            if (v.getFieldName().equalsIgnoreCase(StringUtils.trim(fieldName))) {
                return v;
            }
        }

        throw new InstanceNotFoundException(fieldName, DescriptionValue.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.