Package org.libreplan.business.materials.entities

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


    }

    private static Material toEntity(MaterialDTO materialDTO) {

        Material material = Material.createUnvalidated(StringUtils
                .trim(materialDTO.code), StringUtils
                .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


                if (StringUtils.isBlank(materialDTO.code)) {
                    throw new ValidationException("missing code in a material");
                }

                try {
                    Material material = materialCategory
                        .getMaterialByCode(materialDTO.code);
                    updateMaterial(material, materialDTO);
                } catch (InstanceNotFoundException e) {
                    materialCategory.addMaterial(toEntity(materialDTO));
                }
View Full Code Here

    private Set<Material> getSelectedMaterials() {
        Set<Material> result = new HashSet<Material>();

        final Set<Listitem> listitems = lbFoundMaterials.getSelectedItems();
        for (Listitem each: listitems) {
            final Material material = (Material) each.getValue();
            result.add(material);
        }
        return result;
    }
View Full Code Here

    }

    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

                }
                return;
            }

            if (parent instanceof Listcell) {
                Material material = (Material) ((Listitem) (parent.getParent()))
                        .getValue();
                if (isCurrentUnitType(material, unitType)) {
                    listItem.getListbox().setSelectedItem(listItem);
                }
            }
View Full Code Here

    protected abstract Material getMaterial(A assignment);

    private void feedTree(MutableTreeModel<MaterialCategory> tree,
            Collection<? extends A> materialAssignments) {
        for (A each : materialAssignments) {
            final Material material = getMaterial(each);
            addCategory(tree, material.getCategory());
        }
    }
View Full Code Here

    public List<A> getAssignedMaterials(MaterialCategory materialCategory) {
        List<A> result = new ArrayList<A>();
        if (isInitialized()) {
            for (A each : getAssignments()) {
                final Material material = getMaterial(each);
                if (materialCategory == null
                        || materialCategory.getId().equals(
                                material.getCategory().getId())) {
                    result.add(each);
                }
            }
        }
        return result;
View Full Code Here

    @Override
    public BigDecimal getUnits(MaterialCategory materialCategory) {
        BigDecimal result = BigDecimal.ZERO;
        if (isInitialized()) {
            for (A each : getAssignments()) {
                final Material material = getMaterial(each);
                if (materialCategory.equals(material.getCategory())) {
                    result = result.add(getUnits(each));
                }
            }
        }
        return result;
View Full Code Here

    public BigDecimal getPrice(MaterialCategory category) {
        BigDecimal result = new BigDecimal(0);
        if (isInitialized()) {
            for (A each : getAssignments()) {
                final Material material = getMaterial(each);
                if (category.equals(material.getCategory())) {
                    result = result.add(getTotalPrice(each));
                }
            }
        }
        return result;
View Full Code Here

    public BigDecimal getPrice(MaterialCategory materialCategory) {
        BigDecimal result = new BigDecimal(0);
        if (orderElement != null) {
            for (MaterialAssignment materialAssignment : orderElement
                    .getMaterialAssignments()) {
                final Material material = materialAssignment.getMaterial();
                if (materialCategory.equals(material.getCategory())) {
                    result = result.add(materialAssignment.getTotalPrice());
                }
            }
        }
        return result;
View Full Code Here

TOP

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

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.