use of com.qcadoo.model.api.search.SearchCriteriaBuilder in project mes by qcadoo.
the class ProductionTrackingDocumentsHelper method fillFromBPCProductIn.
public final Multimap<Long, Entity> fillFromBPCProductIn(final List<Entity> trackingOperationProductInComponents, final Entity order, final Entity technologyOperationComponent, final boolean withComponents) {
SearchCriteriaBuilder scb = getProductionCountingQuantityDD().find().add(SearchRestrictions.belongsTo(ProductionCountingQuantityFields.ORDER, order)).add(SearchRestrictions.eq(ProductionCountingQuantityFields.ROLE, ProductionCountingQuantityRole.USED.getStringValue()));
if (Objects.nonNull(technologyOperationComponent)) {
scb = scb.add(SearchRestrictions.belongsTo(ProductionCountingQuantityFields.TECHNOLOGY_OPERATION_COMPONENT, technologyOperationComponent));
}
List<Entity> productionCountingQuantities = scb.list().getEntities();
Multimap<Long, Entity> groupedRecordInProducts = ArrayListMultimap.create();
for (Entity productionCountingQuantity : productionCountingQuantities) {
Entity warehouse;
if (withComponents && ProductionCountingQuantityTypeOfMaterial.COMPONENT.getStringValue().equals(productionCountingQuantity.getStringField(ProductionCountingQuantityFields.TYPE_OF_MATERIAL))) {
warehouse = productionCountingQuantity.getBelongsToField(ProductionCountingQuantityFields.COMPONENTS_LOCATION);
} else if (ProductionCountingQuantityTypeOfMaterial.INTERMEDIATE.getStringValue().equals(productionCountingQuantity.getStringField(ProductionCountingQuantityFields.TYPE_OF_MATERIAL)) && L_WAREHOUSE.equals(productionCountingQuantity.getStringField(ProductionCountingQuantityFields.PRODUCTION_FLOW))) {
warehouse = productionCountingQuantity.getBelongsToField(ProductionCountingQuantityFields.PRODUCTS_FLOW_LOCATION);
} else {
continue;
}
Entity product = productionCountingQuantity.getBelongsToField(ProductionCountingQuantityFields.PRODUCT);
Entity trackingOperationProductInComponent = findProductionRecordByProduct(trackingOperationProductInComponents, product);
if (Objects.nonNull(trackingOperationProductInComponent)) {
if (!checkIfProductExists(groupedRecordInProducts, warehouse, product)) {
groupedRecordInProducts.put(warehouse.getId(), trackingOperationProductInComponent);
}
}
}
return groupedRecordInProducts;
}
use of com.qcadoo.model.api.search.SearchCriteriaBuilder in project mes by qcadoo.
the class BalanceContextsCleanUpService method getContextIds.
private Collection<Long> getContextIds() {
DataDefinition dataDef = getDataDefinition();
SearchCriteriaBuilder scb = dataDef.find();
scb.setProjection(SearchProjections.alias(SearchProjections.id(), "id"));
List<Long> ids = Lists.newLinkedList();
for (Entity idProjection : scb.list().getEntities()) {
ids.add((Long) idProjection.getField("id"));
}
return ids;
}
use of com.qcadoo.model.api.search.SearchCriteriaBuilder in project mes by qcadoo.
the class ProductionTrackingStatesHelper method findStateChangeEntity.
private Entity findStateChangeEntity(final Entity productionTracking) {
DataDefinition stateChangeDD = dataDefinitionService.get(ProductionCountingConstants.PLUGIN_IDENTIFIER, ProductionCountingConstants.MODEL_PRODUCTION_TRACKING_STATE_CHANGE);
SearchCriteriaBuilder scb = stateChangeDD.find();
scb.add(SearchRestrictions.belongsTo(ProductionTrackingStateChangeFields.PRODUCTION_TRACKING, productionTracking));
scb.add(SearchRestrictions.eq(ProductionTrackingStateChangeFields.STATUS, StateChangeStatus.SUCCESSFUL.getStringValue()));
return scb.setMaxResults(1).uniqueResult();
}
use of com.qcadoo.model.api.search.SearchCriteriaBuilder in project mes by qcadoo.
the class OrderClosingHelperTest method stubSearchCriteriaResults.
private void stubSearchCriteriaResults(final Long... ids) {
SearchCriteriaBuilder scb = mock(SearchCriteriaBuilder.class);
// blind mock of fluent interface
given(scb.add(any(SearchCriterion.class))).willReturn(scb);
given(scb.setProjection(any(SearchProjection.class))).willReturn(scb);
List<Entity> entities = Lists.newArrayList();
for (Long id : ids) {
Entity entity = mock(Entity.class);
given(entity.getField("id")).willReturn(id);
entities.add(entity);
}
SearchResult result = mock(SearchResult.class);
given(result.getEntities()).willReturn(entities);
given(scb.list()).willReturn(result);
given(productionTrackingDD.find()).willReturn(scb);
}
use of com.qcadoo.model.api.search.SearchCriteriaBuilder in project mes by qcadoo.
the class ProductionLinesSearchServiceImpl method findProjections.
private List<Entity> findProjections(final LineSearchMode searchMode, final Long techOrTechGroupId) {
SearchCriteriaBuilder scb = getProductionLineDataDef().find();
scb.setProjection(alias(id(), "id"));
searchMode.appendCriteria(scb, techOrTechGroupId);
return scb.list().getEntities();
}
Aggregations