Search in sources :

Example 36 with SearchCriteriaBuilder

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));
    }
}
Also used : SearchCriteriaBuilder(com.qcadoo.model.api.search.SearchCriteriaBuilder)

Example 37 with SearchCriteriaBuilder

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));
    }
}
Also used : Entity(com.qcadoo.model.api.Entity) SearchCriteriaBuilder(com.qcadoo.model.api.search.SearchCriteriaBuilder)

Example 38 with SearchCriteriaBuilder

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;
}
Also used : SearchCriteriaBuilder(com.qcadoo.model.api.search.SearchCriteriaBuilder)

Example 39 with SearchCriteriaBuilder

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;
}
Also used : SearchCriteriaBuilder(com.qcadoo.model.api.search.SearchCriteriaBuilder) SearchCriterion(com.qcadoo.model.api.search.SearchCriterion)

Example 40 with SearchCriteriaBuilder

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;
}
Also used : SearchCriteriaBuilder(com.qcadoo.model.api.search.SearchCriteriaBuilder)

Aggregations

SearchCriteriaBuilder (com.qcadoo.model.api.search.SearchCriteriaBuilder)176 Entity (com.qcadoo.model.api.Entity)82 DataDefinition (com.qcadoo.model.api.DataDefinition)26 Autowired (org.springframework.beans.factory.annotation.Autowired)19 Service (org.springframework.stereotype.Service)19 DataDefinitionService (com.qcadoo.model.api.DataDefinitionService)18 EntityList (com.qcadoo.model.api.EntityList)17 SearchRestrictions (com.qcadoo.model.api.search.SearchRestrictions)17 Collectors (java.util.stream.Collectors)17 SearchResult (com.qcadoo.model.api.search.SearchResult)16 SearchCriterion (com.qcadoo.model.api.search.SearchCriterion)14 Objects (java.util.Objects)14 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)11 BigDecimal (java.math.BigDecimal)11 Set (java.util.Set)11 UserFieldsMF (com.qcadoo.mes.materialFlow.constants.UserFieldsMF)10 UserLocationFields (com.qcadoo.mes.materialFlow.constants.UserLocationFields)10 SecurityService (com.qcadoo.security.api.SecurityService)10 QcadooSecurityConstants (com.qcadoo.security.constants.QcadooSecurityConstants)10 CustomRestriction (com.qcadoo.model.api.search.CustomRestriction)8