Search in sources :

Example 1 with OperationProductKey

use of com.qcadoo.mes.technologiesGenerator.domain.OperationProductKey in project mes by qcadoo.

the class TreeGenerator method getCustomizedTechnologies.

private Map<OperationProductKey, Long> getCustomizedTechnologies(final Entity context, boolean applyCustomized) {
    Map<OperationProductKey, Long> map = Maps.newHashMap();
    if (!applyCustomized) {
        return map;
    }
    List<Entity> nodes = getGeneratorTreeNodeDD().find().add(SearchRestrictions.belongsTo(GeneratorTreeNodeFields.GENERATOR_CONTEXT, context)).add(SearchRestrictions.eq(GeneratorTreeNodeFields.ENTITY_TYPE, TechnologyStructureNodeType.CUSTOMIZED_COMPONENT.getStringValue())).list().getEntities();
    nodes.forEach(node -> {
        OperationProductKey operationProductKey = new OperationProductKey(node.getBelongsToField(GeneratorTreeNodeFields.OPERATION).getId(), node.getBelongsToField(GeneratorTreeNodeFields.PRODUCT).getId());
        map.put(operationProductKey, node.getBelongsToField(GeneratorTreeNodeFields.PRODUCT_TECHNOLOGY).getId());
    });
    return map;
}
Also used : Entity(com.qcadoo.model.api.Entity) OperationProductKey(com.qcadoo.mes.technologiesGenerator.domain.OperationProductKey)

Example 2 with OperationProductKey

use of com.qcadoo.mes.technologiesGenerator.domain.OperationProductKey in project mes by qcadoo.

the class TreeGenerator method performGeneration.

private Either<String, ContextId> performGeneration(final Entity context, final GeneratorSettings settings, boolean applyCustomized) {
    Entity technology = context.getBelongsToField(GeneratorContextFields.TECHNOLOGY);
    TechnologyId technologyId = new TechnologyId(technology.getId());
    ContextId contextId = new ContextId(context.getId());
    Map<OperationProductKey, Long> customizedOperationProductTechnologies = getCustomizedTechnologies(context, applyCustomized);
    Either<String, TechnologyStructureNode> mRoot = tryBuildStructure(settings, technologyId, contextId);
    Either<String, Entity> generationResults = mRoot.flatMap(root -> regenerateNodes(context, root).flatMap(x -> markContextAsGenerated(contextId)));
    if (applyCustomized) {
        updateNodesToCustomized(context, customizedOperationProductTechnologies);
    }
    logResults(generationResults);
    return generationResults.map(Entity::getId).map(ContextId::new);
}
Also used : TechnologyFields(com.qcadoo.mes.technologies.constants.TechnologyFields) DataDefinitionService(com.qcadoo.model.api.DataDefinitionService) GeneratorContextFields(com.qcadoo.mes.technologiesGenerator.constants.GeneratorContextFields) LoggerFactory(org.slf4j.LoggerFactory) TechnologiesGeneratorConstants(com.qcadoo.mes.technologiesGenerator.constants.TechnologiesGeneratorConstants) Autowired(org.springframework.beans.factory.annotation.Autowired) GeneratorSettings(com.qcadoo.mes.technologiesGenerator.GeneratorSettings) TechnologyService(com.qcadoo.mes.technologies.TechnologyService) TechnologyOperationComponentFields(com.qcadoo.mes.technologies.constants.TechnologyOperationComponentFields) TechnologyStructureNode(com.qcadoo.mes.technologiesGenerator.domain.TechnologyStructureNode) TechnologyOperationId(com.qcadoo.mes.technologies.tree.domain.TechnologyOperationId) Service(org.springframework.stereotype.Service) Map(java.util.Map) SizeGroupId(com.qcadoo.mes.technologies.domain.SizeGroupId) Logger(org.slf4j.Logger) OperationProductKey(com.qcadoo.mes.technologiesGenerator.domain.OperationProductKey) SearchRestrictions(com.qcadoo.model.api.search.SearchRestrictions) TechnologyStructureNodeType(com.qcadoo.mes.technologiesGenerator.domain.TechnologyStructureNodeType) TechnologyStructureTreeDataProvider(com.qcadoo.mes.technologiesGenerator.dataProvider.TechnologyStructureTreeDataProvider) 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) GeneratorContextDataProvider(com.qcadoo.mes.technologiesGenerator.dataProvider.GeneratorContextDataProvider) ProductInfo(com.qcadoo.mes.technologiesGenerator.domain.ProductInfo) Either(com.qcadoo.commons.functional.Either) Optional(java.util.Optional) TechnologyId(com.qcadoo.mes.technologies.domain.TechnologyId) TechnologiesConstants(com.qcadoo.mes.technologies.constants.TechnologiesConstants) GeneratorTreeNodeFields(com.qcadoo.mes.technologiesGenerator.constants.GeneratorTreeNodeFields) Transactional(org.springframework.transaction.annotation.Transactional) OperationId(com.qcadoo.mes.technologies.domain.OperationId) Entity(com.qcadoo.model.api.Entity) TechnologyId(com.qcadoo.mes.technologies.domain.TechnologyId) ContextId(com.qcadoo.mes.technologiesGenerator.domain.ContextId) TechnologyStructureNode(com.qcadoo.mes.technologiesGenerator.domain.TechnologyStructureNode) OperationProductKey(com.qcadoo.mes.technologiesGenerator.domain.OperationProductKey)

Aggregations

OperationProductKey (com.qcadoo.mes.technologiesGenerator.domain.OperationProductKey)2 Entity (com.qcadoo.model.api.Entity)2 Maps (com.google.common.collect.Maps)1 Either (com.qcadoo.commons.functional.Either)1 TechnologyService (com.qcadoo.mes.technologies.TechnologyService)1 TechnologiesConstants (com.qcadoo.mes.technologies.constants.TechnologiesConstants)1 TechnologyFields (com.qcadoo.mes.technologies.constants.TechnologyFields)1 TechnologyOperationComponentFields (com.qcadoo.mes.technologies.constants.TechnologyOperationComponentFields)1 OperationId (com.qcadoo.mes.technologies.domain.OperationId)1 SizeGroupId (com.qcadoo.mes.technologies.domain.SizeGroupId)1 TechnologyId (com.qcadoo.mes.technologies.domain.TechnologyId)1 TechnologyInputProductTypeId (com.qcadoo.mes.technologies.domain.TechnologyInputProductTypeId)1 TechnologyOperationId (com.qcadoo.mes.technologies.tree.domain.TechnologyOperationId)1 GeneratorSettings (com.qcadoo.mes.technologiesGenerator.GeneratorSettings)1 GeneratorContextFields (com.qcadoo.mes.technologiesGenerator.constants.GeneratorContextFields)1 GeneratorTreeNodeFields (com.qcadoo.mes.technologiesGenerator.constants.GeneratorTreeNodeFields)1 TechnologiesGeneratorConstants (com.qcadoo.mes.technologiesGenerator.constants.TechnologiesGeneratorConstants)1 GeneratorContextDataProvider (com.qcadoo.mes.technologiesGenerator.dataProvider.GeneratorContextDataProvider)1 TechnologyStructureTreeDataProvider (com.qcadoo.mes.technologiesGenerator.dataProvider.TechnologyStructureTreeDataProvider)1 ContextId (com.qcadoo.mes.technologiesGenerator.domain.ContextId)1