Package org.libreplan.business.common.entities

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


    @Test
    @Transactional
    public void testCreateEntitySequenceWithNumberOfDigitsNotSpecified() {
        try {
            EntitySequence entitySequence = givenEntitySequence("prefix-"
                    + UUID.randomUUID(), EntityNameEnum.CRITERION, true);
            entitySequence.setNumberOfDigits(null);
            entitySequenceDAO.save(entitySequence);
            fail("It should throw an exception");
        } catch (IllegalArgumentException e) {
            // It should throw an exception
        }
View Full Code Here


    @Test
    @Transactional
    public void testCreateEntitySequenceWithNumberOfDigitsOutRange() {
        try {
            EntitySequence entitySequence = givenEntitySequence("prefix-"
                    + UUID.randomUUID(), EntityNameEnum.CRITERION, true);
            entitySequence.setNumberOfDigits(15);
            entitySequenceDAO.save(entitySequence);
            fail("It should throw an exception");
        } catch (IllegalArgumentException e) {
            // It should throw an exception
        }
View Full Code Here

    }

    @Test
    @Transactional
    public void testCreateTwoActiveEntitySequenceWithTheSameEntityName() {
        EntitySequence entitySequenceA = givenEntitySequence("prefix-"
                + UUID.randomUUID(), EntityNameEnum.CRITERION, true);
        entitySequenceDAO.save(entitySequenceA);
        entitySequenceDAO.flush();
        try {
            EntitySequence entitySequenceB = givenEntitySequence("prefix-"
                    + UUID.randomUUID(), EntityNameEnum.CRITERION, true);
            entitySequenceDAO.save(entitySequenceB);
            fail("Expected ValidationException");
        } catch (ValidationException e) {
        }
View Full Code Here

    }

    @Test
    @Transactional
    public void testCreateTwoEntitySequenceWithTheSameEntityName() {
        EntitySequence entitySequenceA = givenEntitySequence("prefix-"
                + UUID.randomUUID(), EntityNameEnum.LABEL, true);
        entitySequenceDAO.save(entitySequenceA);
        entitySequenceDAO.flush();
        try {
            EntitySequence entitySequenceB = givenEntitySequence("prefix-"
                    + UUID.randomUUID(), EntityNameEnum.LABEL, false);
            entitySequenceDAO.save(entitySequenceB);
        } catch (ValidationException e) {
            fail("It shouldn't throw an exception");
        }
View Full Code Here

    }

    @Test
    @Transactional
    public void testCreateAndRemoveTwoEntitySequenceWithTheSameEntityName() {
        EntitySequence entitySequenceA = givenEntitySequence("prefix-"
                + UUID.randomUUID(), EntityNameEnum.MACHINE, true);
        entitySequenceDAO.save(entitySequenceA);
        try {
            entitySequenceDAO.remove(entitySequenceA.getId());
        } catch (ValidationException e) {
            fail("It shouldn't throw an exception");
        } catch (InstanceNotFoundException o) {
            fail("It shouldn't throw an exception");
        }
        try {
            EntitySequence entitySequenceB = givenEntitySequence("prefix-"
                    + UUID.randomUUID(), EntityNameEnum.MACHINE, true);
            entitySequenceDAO.save(entitySequenceB);
        } catch (ValidationException e) {
            fail("It shouldn't throw an exception");
        }
View Full Code Here

        }
    }

    private EntitySequence givenEntitySequence(String prefix,
            EntityNameEnum entityName, boolean active) {
        EntitySequence entitySequence = EntitySequence.create(prefix,
                entityName);
        entitySequence.setActive(active);
        return entitySequence;
    }
View Full Code Here

    public class EntitySequenceGroupRenderer implements RowRenderer {
        @Override
        public void render(Row row, Object data) {

            EntitySequence entitySequence = (EntitySequence) data;
            final EntityNameEnum entityName = entitySequence.getEntityName();

            row.setValue(entityName);
            row.appendChild(new Label(_("{0} sequences",
                    entityName.getDescription())));

            row.setValue(entitySequence);
            appendActiveRadiobox(row, entitySequence);
            appendPrefixTextbox(row, entitySequence);
            appendNumberOfDigitsInbox(row, entitySequence);
            appendLastValueInbox(row, entitySequence);
            appendOperations(row, entitySequence);

            if (entitySequence.isAlreadyInUse()) {
                row.setTooltiptext(_("Code sequence is already in use and cannot be updated"));
            }

            if ((row.getPreviousSibling() != null)
                    && !((EntitySequence) ((Row) row.getPreviousSibling())
View Full Code Here

    }

    public void addEntitySequence(EntityNameEnum entityName, String prefix,
            Integer digits) {
        List<EntitySequence> sequences = entitySequences.get(entityName);
        EntitySequence entitySequence = EntitySequence.create(prefix,
                entityName, digits);
        if (sequences.isEmpty()) {
            entitySequence.setActive(true);
        }
        sequences.add(entitySequence);
    }
View Full Code Here

    private boolean checkValidEntitySequenceRows() {
        Rows rows = entitySequencesGrid.getRows();
        for (Row row : (List<Row>) rows.getChildren()) {

                EntitySequence seq = (EntitySequence) row.getValue();
                if (seq != null) {
                Textbox prefixBox = (Textbox) row.getChildren().get(2);
                    if (!seq.isAlreadyInUse()) {
                        String errorMessage = this.validPrefix(seq,
                                prefixBox.getValue());
                        if (errorMessage != null) {
                            throw new WrongValueException(prefixBox,
                                    errorMessage);
                        }
                    }

                Intbox digitsBox = (Intbox) row.getChildren().get(3);
                    try {
                        if (!seq.isAlreadyInUse()) {
                            seq.setNumberOfDigits(digitsBox.getValue());
                        }
                    } catch (IllegalArgumentException e) {
                        throw new WrongValueException(digitsBox, _(
                                "number of digits must be between {0} and {1}",
                                EntitySequence.MIN_NUMBER_OF_DIGITS,
View Full Code Here

            @Override
            public void validate(Component comp, Object value)
                    throws WrongValueException {

                Row row = (Row) comp.getParent();
                EntitySequence sequence = (EntitySequence) row.getValue();
                if (!sequence.isAlreadyInUse()) {
                    String errorMessage = validPrefix(sequence, (String) value);
                    if (errorMessage != null) {
                        throw new WrongValueException(comp, errorMessage);
                    }
                }
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.