Search in sources :

Example 26 with SearchCriteriaBuilder

use of com.qcadoo.model.api.search.SearchCriteriaBuilder in project mes by qcadoo.

the class TechnologyProductComponentsDataProvider method createGenerationModeBaseCriteria.

private SearchCriteriaBuilder createGenerationModeBaseCriteria(final String modelName, final String tocFieldName, final String productFieldName, final TechnologyId technologyId) {
    DataDefinition dd = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, modelName);
    SearchCriteriaBuilder opicCriteria = dd.find();
    opicCriteria.createCriteria(tocFieldName, "toc_alias", JoinType.INNER).createCriteria(TechnologyOperationComponentFields.TECHNOLOGY, "tech_alias", JoinType.INNER).add(idEq(technologyId.get()));
    opicCriteria.createCriteria(productFieldName, "prod_alias", JoinType.INNER).add(eq(ProductFieldsTG.FROM_GENERATOR, true));
    return opicCriteria;
}
Also used : SearchCriteriaBuilder(com.qcadoo.model.api.search.SearchCriteriaBuilder) DataDefinition(com.qcadoo.model.api.DataDefinition)

Example 27 with SearchCriteriaBuilder

use of com.qcadoo.model.api.search.SearchCriteriaBuilder in project mes by qcadoo.

the class TechnologyProductComponentsDataProvider method findOutputs.

public List<Entity> findOutputs(final TechnologyId technologyId, final Optional<OutputProductComponentId> excludedComponentId, boolean generationMode) {
    SearchCriteriaBuilder scb = null;
    if (generationMode) {
        scb = createGenerationModeBaseCriteria(TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT, OperationProductOutComponentFields.OPERATION_COMPONENT, OperationProductOutComponentFields.PRODUCT, technologyId);
    } else {
        scb = createBaseCriteria(TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT, OperationProductOutComponentFields.OPERATION_COMPONENT, OperationProductOutComponentFields.PRODUCT, technologyId);
    }
    excludedComponentId.map(OutputProductComponentId::get).map(SearchRestrictions::idNe).ifPresent(scb::add);
    return scb.list().getEntities();
}
Also used : SearchCriteriaBuilder(com.qcadoo.model.api.search.SearchCriteriaBuilder) OutputProductComponentId(com.qcadoo.mes.technologiesGenerator.domain.OutputProductComponentId)

Example 28 with SearchCriteriaBuilder

use of com.qcadoo.model.api.search.SearchCriteriaBuilder in project mes by qcadoo.

the class TechnologyProductComponentsDataProvider method createBaseCriteria.

private SearchCriteriaBuilder createBaseCriteria(final String modelName, final String tocFieldName, final String productFieldName, final TechnologyId technologyId) {
    DataDefinition dd = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, modelName);
    SearchCriteriaBuilder opicCriteria = dd.find();
    opicCriteria.createCriteria(tocFieldName, "toc_alias", JoinType.INNER).createCriteria(TechnologyOperationComponentFields.TECHNOLOGY, "tech_alias", JoinType.INNER).add(idEq(technologyId.get()));
    opicCriteria.createCriteria(productFieldName, "prod_alias", JoinType.INNER).add(eq(ProductFields.ENTITY_TYPE, ProductFamilyElementType.PRODUCTS_FAMILY.getStringValue()));
    return opicCriteria;
}
Also used : SearchCriteriaBuilder(com.qcadoo.model.api.search.SearchCriteriaBuilder) DataDefinition(com.qcadoo.model.api.DataDefinition)

Example 29 with SearchCriteriaBuilder

use of com.qcadoo.model.api.search.SearchCriteriaBuilder in project mes by qcadoo.

the class TechnologyStructureTreeDataProvider method prepareExistingNodeSearchCriteria.

private SearchCriteriaBuilder prepareExistingNodeSearchCriteria(final ContextId contextId) {
    SearchCriteriaBuilder scb = getGeneratorTreeNodeDD().find();
    scb.add(isNotNull(GeneratorTreeNodeFields.PRODUCT_TECHNOLOGY));
    scb.add(isNotNull(GeneratorTreeNodeFields.ORIGINAL_TECHNOLOGY));
    scb.createCriteria(GeneratorTreeNodeFields.GENERATOR_CONTEXT, "generatorContext_alias", JoinType.INNER).add(idEq(contextId.get()));
    scb.add(neField(GeneratorTreeNodeFields.PRODUCT_TECHNOLOGY, GeneratorTreeNodeFields.ORIGINAL_TECHNOLOGY));
    return scb;
}
Also used : SearchCriteriaBuilder(com.qcadoo.model.api.search.SearchCriteriaBuilder)

Example 30 with SearchCriteriaBuilder

use of com.qcadoo.model.api.search.SearchCriteriaBuilder in project mes by qcadoo.

the class TechnologyStructureTreeDataProvider method findExistingCustomizedNodes.

public Map<TechnologyId, Entity> findExistingCustomizedNodes(final ContextId contextId) {
    if (Objects.isNull(contextId)) {
        return ImmutableMap.of();
    }
    SearchCriteriaBuilder scb = prepareExistingNodeSearchCriteria(contextId);
    List<Entity> existingNodes = scb.list().getEntities();
    return ImmutableMap.copyOf(Maps.uniqueIndex(existingNodes, n -> new TechnologyId(n.getBelongsToField(GeneratorTreeNodeFields.ORIGINAL_TECHNOLOGY).getId())));
}
Also used : DataDefinitionService(com.qcadoo.model.api.DataDefinitionService) SearchRestrictions.isNull(com.qcadoo.model.api.search.SearchRestrictions.isNull) OperationProductInComponentId(com.qcadoo.mes.technologies.domain.OperationProductInComponentId) TechnologiesGeneratorConstants(com.qcadoo.mes.technologiesGenerator.constants.TechnologiesGeneratorConstants) Autowired(org.springframework.beans.factory.annotation.Autowired) SearchProjections.id(com.qcadoo.model.api.search.SearchProjections.id) Multimap(com.google.common.collect.Multimap) Multimaps(com.google.common.collect.Multimaps) BigDecimal(java.math.BigDecimal) TechnologyOperationId(com.qcadoo.mes.technologies.tree.domain.TechnologyOperationId) Service(org.springframework.stereotype.Service) ProductId(com.qcadoo.mes.basic.product.domain.ProductId) Map(java.util.Map) SizeGroupId(com.qcadoo.mes.technologies.domain.SizeGroupId) ImmutableMultimap(com.google.common.collect.ImmutableMultimap) ImmutableMap(com.google.common.collect.ImmutableMap) SearchRestrictions.idEq(com.qcadoo.model.api.search.SearchRestrictions.idEq) SearchRestrictions.neField(com.qcadoo.model.api.search.SearchRestrictions.neField) SearchRestrictions.belongsTo(com.qcadoo.model.api.search.SearchRestrictions.belongsTo) SearchRestrictions.isNotNull(com.qcadoo.model.api.search.SearchRestrictions.isNotNull) Collectors(java.util.stream.Collectors) Maps(com.google.common.collect.Maps) ContextId(com.qcadoo.mes.technologiesGenerator.domain.ContextId) DataDefinition(com.qcadoo.model.api.DataDefinition) Objects(java.util.Objects) JoinType(com.qcadoo.model.api.search.JoinType) List(java.util.List) TechnologyInputProductTypeId(com.qcadoo.mes.technologies.domain.TechnologyInputProductTypeId) Entity(com.qcadoo.model.api.Entity) ProductInfo(com.qcadoo.mes.technologiesGenerator.domain.ProductInfo) Optional(java.util.Optional) SearchCriteriaBuilder(com.qcadoo.model.api.search.SearchCriteriaBuilder) TechnologyId(com.qcadoo.mes.technologies.domain.TechnologyId) SearchProjections.alias(com.qcadoo.model.api.search.SearchProjections.alias) GeneratorTreeNodeFields(com.qcadoo.mes.technologiesGenerator.constants.GeneratorTreeNodeFields) OperationId(com.qcadoo.mes.technologies.domain.OperationId) Entity(com.qcadoo.model.api.Entity) SearchCriteriaBuilder(com.qcadoo.model.api.search.SearchCriteriaBuilder) TechnologyId(com.qcadoo.mes.technologies.domain.TechnologyId)

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