use of com.qcadoo.model.api.search.SearchCriteriaBuilder in project mes by qcadoo.
the class MaterialRequirementCoveragesListHooks method addDiscriminatorRestrictionToGrid.
public final void addDiscriminatorRestrictionToGrid(final ViewDefinitionState view) {
GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
grid.setCustomRestriction(new CustomRestriction() {
@Override
public void addRestriction(final SearchCriteriaBuilder searchBuilder) {
searchBuilder.add(SearchRestrictions.eq(MaterialRequirementCoverageFields.SAVED, true));
}
});
}
use of com.qcadoo.model.api.search.SearchCriteriaBuilder in project mes by qcadoo.
the class OrderPackService method getSumQuantityOrderPacksForOrderWithoutPack.
public BigDecimal getSumQuantityOrderPacksForOrderWithoutPack(Entity order, Long orderPackId) {
if (order.getHasManyField(OrderFields.ORDER_PACKS).size() == 1 && orderPackId != null || order.getHasManyField(OrderFields.ORDER_PACKS).isEmpty()) {
return BigDecimal.ZERO;
}
SearchCriteriaBuilder scb = dataDefinitionService.get(OrdersConstants.PLUGIN_IDENTIFIER, OrdersConstants.MODEL_ORDER_PACK).find().add(SearchRestrictions.belongsTo(OrderPackFields.ORDER, order));
if (orderPackId != null) {
scb.add(SearchRestrictions.idNe(orderPackId));
}
scb.setProjection(alias(sum(OrderPackFields.QUANTITY), QNT_SUM_FIELD_NAME)).addOrder(asc(QNT_SUM_FIELD_NAME));
return scb.setMaxResults(1).uniqueResult().getDecimalField(QNT_SUM_FIELD_NAME);
}
use of com.qcadoo.model.api.search.SearchCriteriaBuilder in project mes by qcadoo.
the class OrdersForSubproductsGenerationListeners method getGeneratingMRC.
private Optional<Entity> getGeneratingMRC() {
SearchCriteriaBuilder searchCriteriaBuilder = getMaterialRequirementCoverageDD().find();
searchCriteriaBuilder.add(SearchRestrictions.eq(MaterialRequirementCoverageFields.ORDER_GENERATION_IN_PROGRESS, true));
List<Entity> entities = searchCriteriaBuilder.list().getEntities();
if (entities.isEmpty()) {
return Optional.empty();
} else {
return Optional.of(entities.get(0));
}
}
use of com.qcadoo.model.api.search.SearchCriteriaBuilder in project mes by qcadoo.
the class OrdersForSubproductsGenerationService method hasSubOrders.
public boolean hasSubOrders(final Entity order) {
if (Objects.isNull(order)) {
return false;
}
SearchCriteriaBuilder scb = dataDefinitionService.get(OrdersConstants.PLUGIN_IDENTIFIER, OrdersConstants.MODEL_ORDER).find();
scb.add(SearchRestrictions.belongsTo(OrderFieldsOFSPG.PARENT, order));
scb.setProjection(SearchProjections.alias(SearchProjections.countDistinct("id"), COUNT_ALIAS));
scb.addOrder(SearchOrders.desc(COUNT_ALIAS));
Entity projectionResult = scb.setMaxResults(1).uniqueResult();
Long countValue = (Long) projectionResult.getField(COUNT_ALIAS);
return countValue > 0;
}
use of com.qcadoo.model.api.search.SearchCriteriaBuilder in project mes by qcadoo.
the class ProductionLineScheduleOrderCriteriaModifiers method filterByState.
public void filterByState(final SearchCriteriaBuilder scb, final FilterValueHolder filterValueHolder) {
scb.add(SearchRestrictions.in(OrderFields.STATE, Lists.newArrayList(OrderState.ACCEPTED.getStringValue(), OrderState.PENDING.getStringValue())));
scb.add(SearchRestrictions.eq(L_TYPE_OF_PRODUCTION_RECORDING, L_CUMULATED));
if (filterValueHolder.has(SCHEDULE_PARAMETER)) {
SearchCriteriaBuilder subCriteria = dataDefinitionService.get(OrdersConstants.PLUGIN_IDENTIFIER, OrdersConstants.MODEL_PRODUCTION_LINE_SCHEDULE).findWithAlias(OrdersConstants.MODEL_PRODUCTION_LINE_SCHEDULE).add(SearchRestrictions.idEq(filterValueHolder.getLong(SCHEDULE_PARAMETER))).createAlias(ProductionLineScheduleFields.ORDERS, ProductionLineScheduleFields.ORDERS, JoinType.INNER).add(SearchRestrictions.eqField(ProductionLineScheduleFields.ORDERS + ".id", "this.id")).setProjection(SearchProjections.id());
scb.add(SearchSubqueries.notExists(subCriteria));
}
}
Aggregations