Package org.libreplan.business.common.entities

Examples of org.libreplan.business.common.entities.EntitySequence


            @Override
            public void validate(Component comp, Object value)
                    throws WrongValueException {
                Row row = (Row) comp.getParent();
                EntitySequence sequence = (EntitySequence) row.getValue();
                if (!sequence.isAlreadyInUse()) {
                    Integer numberOfDigits = (Integer) value;
                    try {
                        sequence.setNumberOfDigits(numberOfDigits);
                    } catch (IllegalArgumentException e) {
                        throw new WrongValueException(comp, _(
                                "number of digits must be between {0} and {1}",
                                EntitySequence.MIN_NUMBER_OF_DIGITS,
                                EntitySequence.MAX_NUMBER_OF_DIGITS));
View Full Code Here


    }

    @Override
    public EntitySequence getActiveEntitySequence(EntityNameEnum entityName)
            throws InstanceNotFoundException, NonUniqueResultException {
        EntitySequence entitySequence = (EntitySequence) getSession()
                .createCriteria(
                EntitySequence.class).add(
                Restrictions.eq("entityName", entityName)).add(
                Restrictions.eq("active", true)).uniqueResult();
        if (entitySequence == null) {
View Full Code Here

    public String getNextEntityCodeWithoutTransaction(EntityNameEnum entityName) {
        for (int i = 0; i < 5; i++) {
            try {
                String code;
                Integer cont = 0;
                EntitySequence entitySequence = getActiveEntitySequence(entityName);

                do {
                    entitySequence.incrementLastValue();
                    code = entitySequence.getCode();
                    cont++;
                } while (entityName.getIntegrationEntityDAO()
                        .existsByCode(code)
                        && cont < 100);
View Full Code Here

    @Override
    public boolean existOtherActiveSequenceByEntityNameForNewObject(
            EntitySequence entitySequence) {
        Validate.notNull(entitySequence);
        try {
            EntitySequence t = getActiveEntitySequence(entitySequence
                    .getEntityName());
            return (t != null && t != entitySequence);
        } catch (InstanceNotFoundException e) {
            return false;
        } catch (NonUniqueResultException e) {
View Full Code Here

    @Override
    public Integer getNumberOfDigitsCode(EntityNameEnum entityName) {
        int numberOfDigits = 5;
        try {
            EntitySequence entitySequence = getActiveEntitySequence(entityName);
            numberOfDigits = entitySequence.getNumberOfDigits();
        } catch (InstanceNotFoundException e) {
            throw new RuntimeException(e);
        } catch (NonUniqueResultException e) {
            throw new RuntimeException(e);
        }
View Full Code Here

            scenario.addOrder(order, orderVersion);
        }
    }

    private void generateCodes(Order order) {
        EntitySequence entitySequence;
        try {
            entitySequence = entitySequenceDAO
                    .getActiveEntitySequence(EntityNameEnum.ORDER);
            int numberOfDigits = entitySequence.getNumberOfDigits();
            order.generateOrderElementCodes(numberOfDigits);
        } catch (NonUniqueResultException e) {
            throw new ViolationError("",
                    "There are several active project sequences");
        } catch (InstanceNotFoundException e) {
View Full Code Here

TOP

Related Classes of org.libreplan.business.common.entities.EntitySequence

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.