Search in sources :

Example 1 with ContextId

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

the class GeneratorViewListeners method performGeneration.

private Either<String, ContextId> performGeneration(final GeneratorView generatorView, final Entity savedContext, boolean applyCustomized) {
    Either<String, ContextId> generationRes = treeGenerator.generate(savedContext, GeneratorSettings.from(savedContext, parameterService.getParameter()), applyCustomized);
    if (generationRes.isRight()) {
        Entity updatedContext = savedContext.getDataDefinition().get(savedContext.getId());
        generatorView.setFormEntity(updatedContext);
        generatorView.showGenerationSuccessMsg();
    } else {
        generatorView.showErrorMsg("technologiesGenerator.generate.error.problemDuringStructureGeneration");
    }
    return generationRes;
}
Also used : Entity(com.qcadoo.model.api.Entity) ContextId(com.qcadoo.mes.technologiesGenerator.domain.ContextId)

Example 2 with ContextId

use of com.qcadoo.mes.technologiesGenerator.domain.ContextId 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)

Example 3 with ContextId

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

the class GeneratorViewListeners method generateTree.

public void generateTree(final ViewDefinitionState view, final ComponentState eventPerformer, final String[] args) {
    GeneratorView generatorView = GeneratorView.from(view);
    Either<String, ContextId> generationResults = generate(generatorView, false);
    if (generationResults.isRight()) {
        generatorView.showStructureTreeTab();
    }
}
Also used : ContextId(com.qcadoo.mes.technologiesGenerator.domain.ContextId) GeneratorView(com.qcadoo.mes.technologiesGenerator.view.GeneratorView)

Example 4 with ContextId

use of com.qcadoo.mes.technologiesGenerator.domain.ContextId 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

ContextId (com.qcadoo.mes.technologiesGenerator.domain.ContextId)4 Entity (com.qcadoo.model.api.Entity)3 Maps (com.google.common.collect.Maps)2 OperationId (com.qcadoo.mes.technologies.domain.OperationId)2 SizeGroupId (com.qcadoo.mes.technologies.domain.SizeGroupId)2 TechnologyId (com.qcadoo.mes.technologies.domain.TechnologyId)2 TechnologyInputProductTypeId (com.qcadoo.mes.technologies.domain.TechnologyInputProductTypeId)2 TechnologyOperationId (com.qcadoo.mes.technologies.tree.domain.TechnologyOperationId)2 GeneratorTreeNodeFields (com.qcadoo.mes.technologiesGenerator.constants.GeneratorTreeNodeFields)2 TechnologiesGeneratorConstants (com.qcadoo.mes.technologiesGenerator.constants.TechnologiesGeneratorConstants)2 ProductInfo (com.qcadoo.mes.technologiesGenerator.domain.ProductInfo)2 DataDefinition (com.qcadoo.model.api.DataDefinition)2 DataDefinitionService (com.qcadoo.model.api.DataDefinitionService)2 JoinType (com.qcadoo.model.api.search.JoinType)2 List (java.util.List)2 Map (java.util.Map)2 Objects (java.util.Objects)2 Optional (java.util.Optional)2 Collectors (java.util.stream.Collectors)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2