Search in sources :

Example 1 with ProductionCountingQuantityRole

use of com.qcadoo.mes.basicProductionCounting.constants.ProductionCountingQuantityRole in project mes by qcadoo.

the class TrackingOperationComponentBuilder method fromOperationProductComponentHolder.

public Entity fromOperationProductComponentHolder(final OperationProductComponentHolder operationProductComponentHolder) {
    String modelName = operationProductComponentHolder.getEntityType().getStringValue();
    ProductionCountingQuantityRole role;
    String typeOfMaterial = operationProductComponentHolder.getProductMaterialType().getStringValue();
    if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(modelName)) {
        role = ProductionCountingQuantityRole.USED;
    } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(modelName)) {
        role = ProductionCountingQuantityRole.PRODUCED;
    } else {
        throw new IllegalArgumentException(String.format("Unsupported operation component type: %s", modelName));
    }
    Entity product = operationProductComponentHolder.getProduct();
    Entity operationProductComponent = fromProduct(product, role, typeOfMaterial);
    Long productionCountingQuantityId = operationProductComponentHolder.getProductionCountingQuantityId();
    if (Objects.nonNull(productionCountingQuantityId)) {
        Entity productionCountingQuantity = dataDefinitionService.get(BasicProductionCountingConstants.PLUGIN_IDENTIFIER, BasicProductionCountingConstants.MODEL_PRODUCTION_COUNTING_QUANTITY).get(productionCountingQuantityId);
        if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(modelName)) {
            Entity replacement = productionCountingQuantity.getBelongsToField(ProductionCountingQuantityFields.REPLACEMENT_TO);
            if (Objects.nonNull(replacement)) {
                operationProductComponent.setField(TrackingOperationProductInComponentFields.REPLACEMENT_TO, replacement.getId());
            }
        } else {
            moveAttributesFromPCQ(operationProductComponent, productionCountingQuantity);
        }
    }
    return operationProductComponent;
}
Also used : Entity(com.qcadoo.model.api.Entity) ProductionCountingQuantityRole(com.qcadoo.mes.basicProductionCounting.constants.ProductionCountingQuantityRole)

Example 2 with ProductionCountingQuantityRole

use of com.qcadoo.mes.basicProductionCounting.constants.ProductionCountingQuantityRole in project mes by qcadoo.

the class TrackingOperationComponentBuilder method fromProductionCountingQuantity.

public Entity fromProductionCountingQuantity(final Entity productionCountingQuantity) {
    Entity product = productionCountingQuantity.getBelongsToField(ProductionCountingQuantityFields.PRODUCT);
    String roleString = productionCountingQuantity.getStringField(ProductionCountingQuantityFields.ROLE);
    ProductionCountingQuantityRole role = ProductionCountingQuantityRole.parseString(roleString);
    String typeOfMaterial = productionCountingQuantity.getStringField(ProductionCountingQuantityFields.TYPE_OF_MATERIAL);
    return fromProduct(product, role, typeOfMaterial);
}
Also used : Entity(com.qcadoo.model.api.Entity) ProductionCountingQuantityRole(com.qcadoo.mes.basicProductionCounting.constants.ProductionCountingQuantityRole)

Example 3 with ProductionCountingQuantityRole

use of com.qcadoo.mes.basicProductionCounting.constants.ProductionCountingQuantityRole in project mes by qcadoo.

the class TrackingOperationComponentBuilder method fromOperationProductComponent.

public Entity fromOperationProductComponent(final Entity operationProductComponent) {
    String modelName = operationProductComponent.getDataDefinition().getName();
    String productFieldName;
    ProductionCountingQuantityRole role;
    if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(modelName)) {
        productFieldName = OperationProductInComponentFields.PRODUCT;
        role = ProductionCountingQuantityRole.USED;
    } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(modelName)) {
        productFieldName = OperationProductOutComponentFields.PRODUCT;
        role = ProductionCountingQuantityRole.PRODUCED;
    } else {
        throw new IllegalArgumentException(String.format("Unsupported operation component type: %s", modelName));
    }
    Entity product = operationProductComponent.getBelongsToField(productFieldName);
    return fromProduct(product, role, null);
}
Also used : Entity(com.qcadoo.model.api.Entity) ProductionCountingQuantityRole(com.qcadoo.mes.basicProductionCounting.constants.ProductionCountingQuantityRole)

Aggregations

ProductionCountingQuantityRole (com.qcadoo.mes.basicProductionCounting.constants.ProductionCountingQuantityRole)3 Entity (com.qcadoo.model.api.Entity)3