Search in sources :

Example 1 with ProductInfo

use of com.qcadoo.mes.technologiesGenerator.domain.ProductInfo in project mes by qcadoo.

the class TreeGenerator method buildEntity.

private Entity buildEntity(final TechnologyStructureNode node, final Entity generatorContext, final DataDefinition dataDefinition) {
    ProductInfo productInfo = node.getProductInfo();
    Entity entity = dataDefinition.create();
    setUpChildrenField(node, generatorContext, dataDefinition, entity);
    setBelongsToField(entity, GeneratorTreeNodeFields.GENERATOR_CONTEXT, generatorContext);
    setBelongsToField(entity, GeneratorTreeNodeFields.PRODUCT, productInfo.getProduct().get());
    setUpProductTechnologyFields(entity, productInfo);
    setUpTechnologyInputProductTypeField(entity, productInfo);
    entity.setField(GeneratorTreeNodeFields.DIFFERENT_PRODUCTS_IN_DIFFERENT_SIZES, productInfo.getDifferentProductsInDifferentSizes());
    entity.setField(GeneratorTreeNodeFields.VARIOUS_QUANTITIES_IN_PRODUCTS_BY_SIZE, productInfo.getVariousQuantitiesInProductsBySize());
    setUpOperationField(entity, productInfo);
    setUpDivisionField(entity, productInfo);
    setUpTechnologyGeneratorAndPerformance(entity, productInfo);
    entity.setField(GeneratorTreeNodeFields.QUANTITY, productInfo.getQuantity());
    entity.setField(GeneratorTreeNodeFields.ENTITY_TYPE, node.getType().getStringValue());
    entity.setField(GeneratorTreeNodeFields.UNIT, productInfo.getUnit());
    setUpSizeGroupField(entity, productInfo);
    return entity.getDataDefinition().save(entity);
}
Also used : ProductInfo(com.qcadoo.mes.technologiesGenerator.domain.ProductInfo) Entity(com.qcadoo.model.api.Entity)

Example 2 with ProductInfo

use of com.qcadoo.mes.technologiesGenerator.domain.ProductInfo in project mes by qcadoo.

the class TechnologyStructureTreeDataProvider method buildProductInfo.

private ProductInfo buildProductInfo(final Entity projection, final Map<ProductId, TechnologyId> defaultTechnologies) {
    Optional<OperationProductInComponentId> opicId = Optional.ofNullable((Long) projection.getField("opicId")).map(OperationProductInComponentId::new);
    TechnologyOperationId tocId = new TechnologyOperationId((Long) projection.getField("tocId"));
    Optional<TechnologyOperationId> parentId = Optional.ofNullable((Long) projection.getField("parentId")).map(TechnologyOperationId::new);
    ProductId productId = buildProduct(projection);
    Optional<TechnologyId> prodTechnology = Optional.ofNullable(defaultTechnologies.get(productId));
    Optional<TechnologyInputProductTypeId> technologyInputProductType = Optional.ofNullable((Long) projection.getField("technologyInputProductTypeId")).map(TechnologyInputProductTypeId::new);
    boolean differentProductsInDifferentSizes = projection.getBooleanField("differentProductsInDifferentSizes");
    boolean variousQuantitiesInProductsBySize = projection.getBooleanField("variousQuantitiesInProductsBySize");
    OperationId operation = buildOperation(projection);
    BigDecimal quantity = projection.getDecimalField("quantity");
    boolean isIntermediate = projection.getBooleanField("isIntermediate");
    String givenUnit = projection.getStringField("givenUnit");
    Optional<SizeGroupId> sizeGroup = Optional.ofNullable((Long) projection.getField("sizeGroupId")).map(SizeGroupId::new);
    return new ProductInfo(opicId, tocId, parentId, productId, quantity, prodTechnology, prodTechnology, technologyInputProductType, differentProductsInDifferentSizes, variousQuantitiesInProductsBySize, operation, isIntermediate, givenUnit, sizeGroup);
}
Also used : ProductInfo(com.qcadoo.mes.technologiesGenerator.domain.ProductInfo) TechnologyId(com.qcadoo.mes.technologies.domain.TechnologyId) TechnologyInputProductTypeId(com.qcadoo.mes.technologies.domain.TechnologyInputProductTypeId) TechnologyOperationId(com.qcadoo.mes.technologies.tree.domain.TechnologyOperationId) OperationId(com.qcadoo.mes.technologies.domain.OperationId) ProductId(com.qcadoo.mes.basic.product.domain.ProductId) TechnologyOperationId(com.qcadoo.mes.technologies.tree.domain.TechnologyOperationId) BigDecimal(java.math.BigDecimal) SizeGroupId(com.qcadoo.mes.technologies.domain.SizeGroupId) OperationProductInComponentId(com.qcadoo.mes.technologies.domain.OperationProductInComponentId)

Aggregations

ProductInfo (com.qcadoo.mes.technologiesGenerator.domain.ProductInfo)2 ProductId (com.qcadoo.mes.basic.product.domain.ProductId)1 OperationId (com.qcadoo.mes.technologies.domain.OperationId)1 OperationProductInComponentId (com.qcadoo.mes.technologies.domain.OperationProductInComponentId)1 SizeGroupId (com.qcadoo.mes.technologies.domain.SizeGroupId)1 TechnologyId (com.qcadoo.mes.technologies.domain.TechnologyId)1 TechnologyInputProductTypeId (com.qcadoo.mes.technologies.domain.TechnologyInputProductTypeId)1 TechnologyOperationId (com.qcadoo.mes.technologies.tree.domain.TechnologyOperationId)1 Entity (com.qcadoo.model.api.Entity)1 BigDecimal (java.math.BigDecimal)1