use of com.qcadoo.model.api.search.SearchDisjunction in project qcadoo by qcadoo.
the class GridComponentFilterUtils method createStringCriterion.
private static SearchCriterion createStringCriterion(GridComponentFilterOperator filterOperator, String data, String field) {
switch(filterOperator) {
case EQ:
case LE:
case GE:
return SearchRestrictions.eq(field, data);
case CN:
return SearchRestrictions.ilike(field, data, SearchMatchMode.ANYWHERE);
case BW:
return SearchRestrictions.ilike(field, data, SearchMatchMode.START);
case EW:
return SearchRestrictions.ilike(field, data, SearchMatchMode.END);
case IN:
Collection<String> values = parseListValue(data);
return SearchRestrictions.inIgnoringCase(field, values);
case CIN:
SearchDisjunction disjunction = SearchRestrictions.disjunction();
parseListValue(data).forEach(value -> disjunction.add(SearchRestrictions.ilike(field, value, SearchMatchMode.ANYWHERE)));
return disjunction;
case NE:
case GT:
case LT:
return SearchRestrictions.ne(field, data);
case ISNULL:
return SearchRestrictions.isNull(field);
default:
throw new IllegalStateException("Unknown filter operator");
}
}
use of com.qcadoo.model.api.search.SearchDisjunction in project mes by qcadoo.
the class OrdersForSubproductsGenerationService method getCoveragProductsForTOC.
public List<Entity> getCoveragProductsForTOC(final Entity toc, final Entity materialRequirementCoverage) {
SearchCriteriaBuilder scb = dataDefinitionService.get(MaterialRequirementCoverageForOrderConstans.PLUGIN_IDENTIFIER, MaterialRequirementCoverageForOrderConstans.MODEL_COVERAGE_PRODUCT).find();
scb.add(SearchRestrictions.belongsTo(CoverageProductFields.COVERAGE_FOR_ORDER, MaterialRequirementCoverageForOrderConstans.PLUGIN_IDENTIFIER, MaterialRequirementCoverageForOrderConstans.MODEL_COVERAGE_FOR_ORDER, materialRequirementCoverage.getId()));
scb.add(SearchRestrictions.eq(CoverageProductFields.STATE, CoverageProductState.LACK.getStringValue()));
scb.add(SearchRestrictions.eq(CoverageProductFields.PRODUCT_TYPE, ProductType.INTERMEDIATE.getStringValue()));
SearchDisjunction sd = SearchRestrictions.disjunction();
for (Entity product : getInputProducts(toc)) {
sd.add(SearchRestrictions.belongsTo(CoverageProductFields.PRODUCT, product));
}
scb.add(sd);
return scb.list().getEntities();
}
use of com.qcadoo.model.api.search.SearchDisjunction in project mes by qcadoo.
the class ChangeoverNormsSearchServiceImpl method getTechnologiesRestrictions.
private SearchCriterion getTechnologiesRestrictions(final Long fromTechnologyId, final Long fromTechnologyGroupId, final Long toTechnologyId, final Long toTechnologyGroupId) {
SearchCriterion matchTechnologies = getPairRestriction(LineChangeoverNormsFields.FROM_TECHNOLOGY, fromTechnologyId, LineChangeoverNormsFields.TO_TECHNOLOGY, toTechnologyId);
SearchCriterion matchTechnologyGroups = getPairRestriction(LineChangeoverNormsFields.FROM_TECHNOLOGY_GROUP, fromTechnologyGroupId, LineChangeoverNormsFields.TO_TECHNOLOGY_GROUP, toTechnologyGroupId);
Preconditions.checkArgument(matchTechnologies != null || matchTechnologyGroups != null, "you have to provide pair of technologies or pair of technology groups.");
SearchDisjunction disjunction = SearchRestrictions.disjunction();
if (matchTechnologies != null) {
disjunction.add(matchTechnologies);
}
if (matchTechnologyGroups != null) {
disjunction.add(matchTechnologyGroups);
}
return disjunction;
}
use of com.qcadoo.model.api.search.SearchDisjunction in project qcadoo by qcadoo.
the class MenuAdministrationService method addRestrictionToCategoriesGrid.
public void addRestrictionToCategoriesGrid(final ViewDefinitionState viewDefinitionState) {
GridComponent categoriesGrid = (GridComponent) viewDefinitionState.getComponentByReference(QcadooViewConstants.L_GRID);
categoriesGrid.setCustomRestriction(new CustomRestriction() {
@Override
public void addRestriction(final SearchCriteriaBuilder searchCriteriaBuilder) {
SearchDisjunction disjunction = SearchRestrictions.disjunction();
for (String[] category : HIDDEN_CATEGORIES) {
disjunction.add(SearchRestrictions.and(SearchRestrictions.eq(MenuCategoryFields.PLUGIN_IDENTIFIER, category[0]), SearchRestrictions.eq(MenuCategoryFields.NAME, category[1])));
}
searchCriteriaBuilder.add(SearchRestrictions.not(disjunction));
}
});
}
Aggregations