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;
}
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);
}
Aggregations