Package org.libreplan.business.materials.entities

Examples of org.libreplan.business.materials.entities.UnitType


                .trim(materialDTO.description), materialDTO.defaultPrice,
                materialDTO.disabled);

        if (materialDTO.unitType != null) {
            try {
                UnitType unitType = Registry.getUnitTypeDAO()
                        .findByCodeAnotherTransaction(
                        materialDTO.unitType);
                material.setUnitType(unitType);
            } catch (InstanceNotFoundException e) {
                throw new ValidationException("unit type code not found");
View Full Code Here


    public final static void updateMaterial(Material material,
            MaterialDTO materialDTO) throws ValidationException {
        if (materialDTO.unitType != null) {
            try {
                UnitType type = Registry.getUnitTypeDAO()
                        .findByCodeAnotherTransaction(
                        materialDTO.unitType);
                material.setUnitType(type);
            } catch (InstanceNotFoundException e) {
                throw new ValidationException("unit type code not found");
View Full Code Here

        return getModel().getUnitTypes();
    }

    public void selectUnitType(Component self) {
        Listitem selectedItem = ((Listbox) self).getSelectedItem();
        UnitType unitType = (UnitType) selectedItem.getValue();
        Material material = (Material) ((Row) self.getParent()).getValue();
        material.setUnitType(unitType);
    }
View Full Code Here

     * @author Susana Montes Pedreira <smontes@wirelessgalicia.com>
     */
    public class UnitTypeListRenderer implements ListitemRenderer {
        @Override
        public void render(Listitem listItem, Object data) {
            final UnitType unitType = (UnitType) data;
            listItem.setValue(unitType);

            Listcell listCell = new Listcell(unitType.getMeasure());
            listItem.appendChild(listCell);

            Listbox listbox = listItem.getListbox();
            Component parent = listbox.getParent();

View Full Code Here

        transactionService.runOnTransaction(new IOnTransaction<Void>() {
            @Override
            public Void execute() {
                try {
                    UnitType typeX = unitTypeDAO.findByCode("XXX");
                    assertTrue(typeX.getMeasure().equalsIgnoreCase("measureX"));
                    UnitType typeY = unitTypeDAO.findByCode("YYY");
                    assertTrue(typeY.getMeasure().equalsIgnoreCase("measureY"));
                    unitTypeDAO.flush();
                    sessionFactory.getCurrentSession().evict(typeX);
                    sessionFactory.getCurrentSession().evict(typeY);
                } catch (InstanceNotFoundException e) {
                    throw new RuntimeException(e);
                }
                return null;
            }
        });

        /* Update the measure unit type */
        m1 = new UnitTypeDTO("XXX", "update-measureX");
        m2 = new UnitTypeDTO("YYY", "update-measureY");

        unitTypeDTOs = new ArrayList<UnitTypeDTO>();
        unitTypeDTOs.add(m1);
        unitTypeDTOs.add(m2);

        unitTypeListDTO = createUnitTypeListDTO(m1, m2);

        instanceConstraintViolationsList = unitTypeService
                .addUnitTypes(unitTypeListDTO).instanceConstraintViolationsList;

        assertTrue(instanceConstraintViolationsList.toString(),
                instanceConstraintViolationsList.size() == 0);

        transactionService.runOnTransaction(new IOnTransaction<Void>() {
            @Override
            public Void execute() {
                try {
                    UnitType typeX = unitTypeDAO.findByCode("XXX");
                    assertTrue(typeX.getMeasure().equalsIgnoreCase(
                            "update-measureX"));
                    UnitType typeY = unitTypeDAO.findByCode("YYY");
                    assertTrue(typeY.getMeasure().equalsIgnoreCase(
                            "update-measureY"));
                } catch (InstanceNotFoundException e) {
                    throw new RuntimeException(e);
                }
                return null;
View Full Code Here

    @Transactional
    @Override
    public void loadRequiredData() {
        for (PredefinedUnitTypes predefinedUnitType : PredefinedUnitTypes
                .values()) {
            UnitType type = null;
            try {
                type = unitTypeDAO
                        .findUniqueByNameInAnotherTransaction(predefinedUnitType
                                .getMeasure());
            } catch (InstanceNotFoundException e) {
                type = predefinedUnitType.createUnitType();
                type
                        .setCode(entitySequenceDAO
                                .getNextEntityCodeWithoutTransaction(EntityNameEnum.UNIT_TYPE));
                type.setCodeAutogenerated(true);
                unitTypeDAO.save(type);
            }
            if (predefinedUnitType
                    .equals(PredefinedUnitTypes.defaultUnitType())) {
                defaultUnitType = type;
View Full Code Here

     * @author Susana Montes Pedreira <smontes@wirelessgalicia.com>
     */
    public static class UnitTypeListRenderer implements ListitemRenderer {
        @Override
        public void render(Listitem listItem, Object data) {
            final UnitType unitType = (UnitType) data;
            listItem.setValue(unitType);

            Listcell listCell = new Listcell(unitType.getMeasure());
            listItem.appendChild(listCell);

            Material material = (Material) ((Row) listItem.getListbox()
                    .getParent()).getValue();
            if ((material.getUnitType() != null)
                    && (unitType.getId().equals(material.getUnitType().getId()))) {
                listItem.getListbox().setSelectedItem(listItem);
            }
        }
View Full Code Here

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

        UnitType unitType = (UnitType) getSession().createCriteria(
                UnitType.class).add(
                Restrictions.eq("measure", measure)).uniqueResult();

        if (unitType == null) {
            throw new InstanceNotFoundException(measure, getEntityClass()
View Full Code Here

    @Transactional(readOnly=true)
    public UnitType findByNameCaseInsensitive(String measure)
            throws InstanceNotFoundException {
        Criteria c = getSession().createCriteria(UnitType.class);
        c.add(Restrictions.ilike("measure", measure, MatchMode.EXACT));
        UnitType result = (UnitType) c.uniqueResult();

        if (result == null) {
            throw new InstanceNotFoundException(measure,
                    getEntityClass().getName());
        }
View Full Code Here

    public RowRenderer getUnitTypeRenderer() {

        return new RowRenderer() {
            @Override
            public void render(Row row, Object data) {
                final UnitType unitType = (UnitType) data;

                appendUnitTypeName(row, unitType);
                appendOperations(row, unitType);
                row.addEventListener(Events.ON_CLICK, new EventListener() {
                    @Override
                    public void onEvent(Event event) {
                        goToEditForm(unitType);
                    }
                });
            }

            private void appendUnitTypeName(Row row, UnitType unitType) {
                row.appendChild(new Label(unitType.getMeasure()));
            }

            private void appendOperations(Row row, final UnitType unitType) {
                Hbox hbox = new Hbox();
View Full Code Here

TOP

Related Classes of org.libreplan.business.materials.entities.UnitType

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.