Search in sources :

Example 21 with EntityList

use of com.qcadoo.model.api.EntityList in project mes by qcadoo.

the class MrpAlgorithmStrategyTSTest method mockEntityListIterator.

private static EntityList mockEntityListIterator(List<Entity> list) {
    EntityList entityList = mock(EntityList.class);
    when(entityList.iterator()).thenReturn(list.iterator());
    return entityList;
}
Also used : EntityList(com.qcadoo.model.api.EntityList)

Example 22 with EntityList

use of com.qcadoo.model.api.EntityList in project mes by qcadoo.

the class TechnologyOperationComponentHooks method copyReferencedTechnologyOperations.

private Entity copyReferencedTechnologyOperations(final Entity node, final Entity technology) {
    Entity copy = node.copy();
    copy.setId(null);
    copy.setField(TechnologyOperationComponentFields.PARENT, null);
    copy.setField(TechnologyOperationComponentFields.TECHNOLOGY, technology);
    for (Entry<String, Object> entry : node.getFields().entrySet()) {
        Object value = entry.getValue();
        if (value instanceof EntityList) {
            EntityList entities = (EntityList) value;
            List<Entity> copies = Lists.newArrayList();
            if (entry.getKey().equals(TechnologyOperationComponentFields.CHILDREN)) {
                for (Entity entity : entities) {
                    copies.add(copyReferencedTechnologyOperations(entity, technology));
                }
            } else {
                for (Entity entity : entities) {
                    Entity fieldCopy = entity.copy();
                    fieldCopy.setId(null);
                    copies.add(fieldCopy);
                }
            }
            copy.setField(entry.getKey(), copies);
        }
    }
    copy.setField("productionCountingQuantities", null);
    copy.setField("productionCountingOperationRuns", null);
    copy.setField("operationalTasks", null);
    copy.setField("operCompTimeCalculations", null);
    copy.setField("barcodeOperationComponents", null);
    return copy;
}
Also used : Entity(com.qcadoo.model.api.Entity) EntityList(com.qcadoo.model.api.EntityList)

Example 23 with EntityList

use of com.qcadoo.model.api.EntityList in project mes by qcadoo.

the class TechnologyValidationService method checkIfConsumesSubOpsProds.

private Set<Entity> checkIfConsumesSubOpsProds(final EntityTree operationComponents) {
    Set<Entity> operations = Sets.newHashSet();
    for (Entity operationComponent : operationComponents) {
        final Entity parent = operationComponent.getBelongsToField(TechnologyOperationComponentFields.PARENT);
        if (Objects.isNull(parent)) {
            continue;
        }
        final EntityList operationProductInComponents = parent.getHasManyField(TechnologyOperationComponentFields.OPERATION_PRODUCT_IN_COMPONENTS);
        final EntityList operationProductOutComponents = operationComponent.getHasManyField(TechnologyOperationComponentFields.OPERATION_PRODUCT_OUT_COMPONENTS);
        if (Objects.isNull(operationProductInComponents)) {
            operations.add(parent);
            continue;
        }
        if (operationProductInComponents.isEmpty()) {
            operations.add(parent);
            continue;
        }
        if (Objects.isNull(operationProductOutComponents)) {
            operations.add(operationComponent);
            continue;
        }
        if (operationProductOutComponents.isEmpty()) {
            operations.add(operationComponent);
            continue;
        }
        if (!checkIfAtLeastOneCommonElement(operationProductOutComponents, operationProductInComponents)) {
            operations.add(operationComponent);
        }
    }
    return operations;
}
Also used : Entity(com.qcadoo.model.api.Entity) EntityList(com.qcadoo.model.api.EntityList)

Example 24 with EntityList

use of com.qcadoo.model.api.EntityList in project mes by qcadoo.

the class ProductStructureTreeService method findQuantityOfProductInOperation.

private BigDecimal findQuantityOfProductInOperation(final Entity technologyInputProductType, final Entity product, final Entity operation) {
    EntityList operationProductOutComponents = operation.getHasManyField(TechnologyOperationComponentFields.OPERATION_PRODUCT_OUT_COMPONENTS);
    Entity operationProductOutComponent = operationProductOutComponents.find().add(SearchRestrictions.belongsTo(OperationProductOutComponentFields.PRODUCT, product)).setMaxResults(1).uniqueResult();
    if (Objects.nonNull(operationProductOutComponent)) {
        return operationProductOutComponent.getDecimalField(ProductStructureTreeNodeFields.QUANTITY);
    }
    EntityList operationProductInComponents = operation.getHasManyField(TechnologyOperationComponentFields.OPERATION_PRODUCT_IN_COMPONENTS);
    operationProductOutComponent = operationProductInComponents.find().add(SearchRestrictions.belongsTo(OperationProductInComponentFields.TECHNOLOGY_INPUT_PRODUCT_TYPE, technologyInputProductType)).add(SearchRestrictions.belongsTo(OperationProductInComponentFields.PRODUCT, product)).setMaxResults(1).uniqueResult();
    if (Objects.nonNull(operationProductOutComponent)) {
        return operationProductOutComponent.getDecimalField(ProductStructureTreeNodeFields.QUANTITY);
    }
    return null;
}
Also used : Entity(com.qcadoo.model.api.Entity) EntityList(com.qcadoo.model.api.EntityList)

Example 25 with EntityList

use of com.qcadoo.model.api.EntityList in project mes by qcadoo.

the class TechnologyTreeValidationServiceImplTest method mockProductComponentsList.

private EntityList mockProductComponentsList(final Collection<Entity> productComponents) {
    EntityList productComponentsList = mock(EntityList.class);
    given(productComponentsList.iterator()).willReturn(productComponents.iterator());
    given(productComponentsList.isEmpty()).willReturn(productComponents.isEmpty());
    return productComponentsList;
}
Also used : EntityList(com.qcadoo.model.api.EntityList)

Aggregations

EntityList (com.qcadoo.model.api.EntityList)103 Entity (com.qcadoo.model.api.Entity)52 Test (org.junit.Test)27 DataDefinition (com.qcadoo.model.api.DataDefinition)16 SearchCriteriaBuilder (com.qcadoo.model.api.search.SearchCriteriaBuilder)16 Before (org.junit.Before)11 UserFieldsMF (com.qcadoo.mes.materialFlow.constants.UserFieldsMF)10 UserLocationFields (com.qcadoo.mes.materialFlow.constants.UserLocationFields)10 DataDefinitionService (com.qcadoo.model.api.DataDefinitionService)10 SearchRestrictions (com.qcadoo.model.api.search.SearchRestrictions)10 SecurityService (com.qcadoo.security.api.SecurityService)10 QcadooSecurityConstants (com.qcadoo.security.constants.QcadooSecurityConstants)10 Objects (java.util.Objects)10 Set (java.util.Set)10 Collectors (java.util.stream.Collectors)10 Autowired (org.springframework.beans.factory.annotation.Autowired)10 Service (org.springframework.stereotype.Service)10 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)9 BigDecimal (java.math.BigDecimal)9 StateChangeTest (com.qcadoo.mes.states.StateChangeTest)5