use of com.qcadoo.model.api.search.SearchCriteriaBuilder in project mes by qcadoo.
the class TechnologicalProcessListDetailsCriteriaModifiers method showAssignedTechnologies.
public void showAssignedTechnologies(final SearchCriteriaBuilder scb, final FilterValueHolder filterValue) {
if (filterValue.has(L_TECHNOLOGICAL_PROCESS_LIST_ID)) {
long technologicalProcessListId = filterValue.getLong(L_TECHNOLOGICAL_PROCESS_LIST_ID);
SearchCriteriaBuilder subCriteria = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT).findWithAlias(TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT).createAlias(TechnologiesConstants.MODEL_TECHNOLOGY, TechnologiesConstants.MODEL_TECHNOLOGY, JoinType.INNER).add(SearchRestrictions.eqField(TechnologiesConstants.MODEL_TECHNOLOGY + L_DOT + L_ID, L_THIS_ID)).add(SearchRestrictions.belongsTo(TechnologiesConstants.MODEL_TECHNOLOGICAL_PROCESS_LIST, TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGICAL_PROCESS_LIST, technologicalProcessListId)).setProjection(SearchProjections.id());
scb.add(SearchSubqueries.exists(subCriteria));
} else {
scb.add(SearchRestrictions.idEq(-1));
}
}
use of com.qcadoo.model.api.search.SearchCriteriaBuilder in project mes by qcadoo.
the class TechnologyDetailsCriteriaModifiers method showTechnologicalProcessComponentsAssignedToTOC.
public void showTechnologicalProcessComponentsAssignedToTOC(final SearchCriteriaBuilder scb, final FilterValueHolder filterValue) {
if (filterValue.has(L_TECHNOLOGY_OPERATION_COMPONENT_ID)) {
long technologyOperationComponentId = filterValue.getLong(L_TECHNOLOGY_OPERATION_COMPONENT_ID);
Entity technologyOperationComponent = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT).get(technologyOperationComponentId);
if (technologyOperationComponent != null) {
Entity technologicalProcessList = technologyOperationComponent.getBelongsToField(TechnologiesConstants.MODEL_TECHNOLOGICAL_PROCESS_LIST);
if (technologicalProcessList != null) {
SearchCriteriaBuilder subCriteria = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGICAL_PROCESS_COMPONENT).findWithAlias(TechnologiesConstants.MODEL_TECHNOLOGICAL_PROCESS_COMPONENT).add(SearchRestrictions.eqField(TechnologiesConstants.MODEL_TECHNOLOGICAL_PROCESS_COMPONENT + L_DOT + L_ID, L_THIS_ID)).add(SearchRestrictions.belongsTo(TechnologiesConstants.MODEL_TECHNOLOGICAL_PROCESS_LIST, technologicalProcessList)).setProjection(SearchProjections.id());
scb.add(SearchSubqueries.exists(subCriteria));
} else {
scb.add(SearchRestrictions.idEq(-1));
}
} else {
scb.add(SearchRestrictions.idEq(-1));
}
} else {
scb.add(SearchRestrictions.idEq(-1));
}
}
use of com.qcadoo.model.api.search.SearchCriteriaBuilder in project mes by qcadoo.
the class TimeGapsCleanUpService 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 MainTocOutputProductCriteriaBuilder method create.
public SearchCriteriaBuilder create(final MasterOutputProductCriteria criteria) {
SearchCriteriaBuilder tocScb = getTocDataDefinition().findWithAlias(Aliases.TOC);
applyCriteriaIfPresent(tocScb, criteria.getTocCriteria());
SearchCriteriaBuilder opocScb = tocScb.createCriteria(TechnologyOperationComponentFields.OPERATION_PRODUCT_OUT_COMPONENTS, Aliases.OPERATION_PROD_OUT_COMPONENT, JoinType.INNER);
applyCriteriaIfPresent(opocScb, criteria.getOpocCriteria());
SearchCriteriaBuilder prodScb = opocScb.createCriteria(OperationProductOutComponentFields.PRODUCT, Aliases.OPERATION_OUTPUT_PRODUCT, JoinType.INNER);
applyCriteriaIfPresent(prodScb, criteria.getProdCriteria());
SearchCriteriaBuilder techScb = tocScb.createCriteria(TechnologyOperationComponentFields.TECHNOLOGY, Aliases.TECHNOLOGY, JoinType.INNER);
applyCriteriaIfPresent(techScb, criteria.getTechCriteria());
SearchCriteriaBuilder parentTocScb = tocScb.createCriteria(TechnologyOperationComponentFields.PARENT, Aliases.TOC_PARENT, JoinType.LEFT);
applyCriteriaIfPresent(parentTocScb, criteria.getParentTocCriteria());
SearchCriteriaBuilder parentOpicScb = parentTocScb.createCriteria(TechnologyOperationComponentFields.OPERATION_PRODUCT_IN_COMPONENTS, Aliases.TOC_PARENT_OPIC, JoinType.LEFT);
parentOpicScb.createCriteria(OperationProductInComponentFields.PRODUCT, Aliases.TOC_PARENT_INPUT_PRODUCT, JoinType.LEFT);
applyCriteriaIfPresent(parentOpicScb, criteria.getParentOpicCriteria());
techScb.createCriteria(TechnologyFields.PRODUCT, Aliases.TECHNOLOGY_PRODUCT, JoinType.INNER);
SearchCriterion productIsConsumedByParentOp = eqField(Aliases.OPERATION_OUTPUT_PRODUCT + ".id", Aliases.TOC_PARENT_INPUT_PRODUCT + ".id");
SearchCriterion opIsRootAndItsProductMatchTechProduct = and(isNull(Aliases.TOC + "." + TechnologyOperationComponentFields.PARENT), eqField(Aliases.TECHNOLOGY_PRODUCT + ".id", Aliases.OPERATION_OUTPUT_PRODUCT + ".id"));
tocScb.add(or(productIsConsumedByParentOp, opIsRootAndItsProductMatchTechProduct));
return tocScb;
}
use of com.qcadoo.model.api.search.SearchCriteriaBuilder in project mes by qcadoo.
the class ProductToProductGroupTechnologyValidators method validatesWith.
public boolean validatesWith(final DataDefinition dataDefinition, final Entity entity) {
boolean isNotAlreadyAdded = true;
Long id = entity.getId();
SearchCriteriaBuilder scb = dataDefinition.find().add(SearchRestrictions.belongsTo(ProductToProductGroupFields.FINAL_PRODUCT, entity.getBelongsToField(ProductToProductGroupFields.FINAL_PRODUCT))).add(SearchRestrictions.belongsTo(ProductToProductGroupFields.PRODUCT_FAMILY, entity.getBelongsToField(ProductToProductGroupFields.PRODUCT_FAMILY)));
if (id != null) {
scb.add(SearchRestrictions.idNe(id));
}
if (scb.list().getTotalNumberOfEntities() > 0) {
entity.addGlobalError("technologies.productToProductGroupTechnology.validate.error.bindingAlreadyAdded");
isNotAlreadyAdded = false;
}
return isNotAlreadyAdded;
}
Aggregations