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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations