Search in sources :

Example 1 with CommandInvokation

use of org.contextmapper.dsl.contextMappingDSL.CommandInvokation in project context-mapper-dsl by ContextMapper.

the class Flow2SketchMinerConverter method convert.

private SimplifiedFlowStep convert(FlowStep step) {
    Set<Task> froms = Sets.newLinkedHashSet();
    Set<Task> tos = Sets.newLinkedHashSet();
    ToType toType = ToType.XOR;
    if (step instanceof CommandInvokationStep) {
        froms.addAll(((CommandInvokationStep) step).getEvents().stream().map(e -> getOrCreateTask(e.getName(), TaskType.EVENT)).collect(Collectors.toList()));
        if (((CommandInvokationStep) step).getAction() instanceof CommandInvokation) {
            CommandInvokation commandInvokation = (CommandInvokation) ((CommandInvokationStep) step).getAction();
            tos.addAll(commandInvokation.getCommands().stream().map(c -> getOrCreateTask(c.getName(), TaskType.COMMAND)).collect(Collectors.toList()));
            if (commandInvokation instanceof ConcurrentCommandInvokation)
                toType = ToType.AND;
            if (commandInvokation instanceof InclusiveAlternativeCommandInvokation)
                toType = ToType.OR;
        } else if (((CommandInvokationStep) step).getAction() instanceof OperationInvokation) {
            OperationInvokation operationInvokation = (OperationInvokation) ((CommandInvokationStep) step).getAction();
            tos.addAll(operationInvokation.getOperations().stream().map(o -> getOrCreateTask(o.getName(), TaskType.COMMAND)).collect(Collectors.toList()));
            if (operationInvokation instanceof ConcurrentOperationInvokation)
                toType = ToType.AND;
            if (operationInvokation instanceof InclusiveAlternativeOperationInvokation)
                toType = ToType.OR;
        }
    } else if (step instanceof DomainEventProductionStep) {
        DomainEventProductionStep eventStep = (DomainEventProductionStep) step;
        froms.add(createTask4EventProduction(eventStep));
        tos.addAll(eventStep.getEventProduction().getEvents().stream().map(e -> getOrCreateTask(e.getName(), TaskType.EVENT)).collect(Collectors.toList()));
        if (eventStep.getEventProduction() instanceof MultipleEventProduction)
            toType = ToType.AND;
        if (eventStep.getEventProduction() instanceof InclusiveAlternativeEventProduction)
            toType = ToType.OR;
    }
    return new SimplifiedFlowStep(froms, tos, toType);
}
Also used : ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) TaskSequence(org.contextmapper.dsl.generator.sketchminer.model.TaskSequence) StateTransition(org.contextmapper.tactic.dsl.tacticdsl.StateTransition) StringUtils(org.apache.commons.lang3.StringUtils) EitherCommandOrOperation(org.contextmapper.dsl.contextMappingDSL.EitherCommandOrOperation) CommandInvokation(org.contextmapper.dsl.contextMappingDSL.CommandInvokation) Lists(com.google.common.collect.Lists) InclusiveAlternativeOperationInvokation(org.contextmapper.dsl.contextMappingDSL.InclusiveAlternativeOperationInvokation) EcoreUtil2(org.eclipse.xtext.EcoreUtil2) Map(java.util.Map) TaskType(org.contextmapper.dsl.generator.sketchminer.model.TaskType) CommandInvokationStep(org.contextmapper.dsl.contextMappingDSL.CommandInvokationStep) Task(org.contextmapper.dsl.generator.sketchminer.model.Task) ConcurrentCommandInvokation(org.contextmapper.dsl.contextMappingDSL.ConcurrentCommandInvokation) ConcurrentOperationInvokation(org.contextmapper.dsl.contextMappingDSL.ConcurrentOperationInvokation) Application(org.contextmapper.dsl.contextMappingDSL.Application) Iterator(java.util.Iterator) Collection(java.util.Collection) Set(java.util.Set) MultipleEventProduction(org.contextmapper.dsl.contextMappingDSL.MultipleEventProduction) Collectors(java.util.stream.Collectors) Maps(com.google.common.collect.Maps) Sets(com.google.common.collect.Sets) FlowStep(org.contextmapper.dsl.contextMappingDSL.FlowStep) CMLModelObjectsResolvingHelper(org.contextmapper.dsl.cml.CMLModelObjectsResolvingHelper) List(java.util.List) InclusiveAlternativeEventProduction(org.contextmapper.dsl.contextMappingDSL.InclusiveAlternativeEventProduction) OperationInvokation(org.contextmapper.dsl.contextMappingDSL.OperationInvokation) SketchMinerModel(org.contextmapper.dsl.generator.sketchminer.model.SketchMinerModel) DomainEventProductionStep(org.contextmapper.dsl.contextMappingDSL.DomainEventProductionStep) ToType(org.contextmapper.dsl.generator.sketchminer.converter.SimplifiedFlowStep.ToType) Flow(org.contextmapper.dsl.contextMappingDSL.Flow) InclusiveAlternativeCommandInvokation(org.contextmapper.dsl.contextMappingDSL.InclusiveAlternativeCommandInvokation) Task(org.contextmapper.dsl.generator.sketchminer.model.Task) InclusiveAlternativeEventProduction(org.contextmapper.dsl.contextMappingDSL.InclusiveAlternativeEventProduction) InclusiveAlternativeCommandInvokation(org.contextmapper.dsl.contextMappingDSL.InclusiveAlternativeCommandInvokation) MultipleEventProduction(org.contextmapper.dsl.contextMappingDSL.MultipleEventProduction) DomainEventProductionStep(org.contextmapper.dsl.contextMappingDSL.DomainEventProductionStep) ConcurrentOperationInvokation(org.contextmapper.dsl.contextMappingDSL.ConcurrentOperationInvokation) InclusiveAlternativeOperationInvokation(org.contextmapper.dsl.contextMappingDSL.InclusiveAlternativeOperationInvokation) ConcurrentOperationInvokation(org.contextmapper.dsl.contextMappingDSL.ConcurrentOperationInvokation) OperationInvokation(org.contextmapper.dsl.contextMappingDSL.OperationInvokation) CommandInvokation(org.contextmapper.dsl.contextMappingDSL.CommandInvokation) ConcurrentCommandInvokation(org.contextmapper.dsl.contextMappingDSL.ConcurrentCommandInvokation) InclusiveAlternativeCommandInvokation(org.contextmapper.dsl.contextMappingDSL.InclusiveAlternativeCommandInvokation) ToType(org.contextmapper.dsl.generator.sketchminer.converter.SimplifiedFlowStep.ToType) ConcurrentCommandInvokation(org.contextmapper.dsl.contextMappingDSL.ConcurrentCommandInvokation) CommandInvokationStep(org.contextmapper.dsl.contextMappingDSL.CommandInvokationStep) InclusiveAlternativeOperationInvokation(org.contextmapper.dsl.contextMappingDSL.InclusiveAlternativeOperationInvokation)

Aggregations

Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 Sets (com.google.common.collect.Sets)1 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 StringUtils (org.apache.commons.lang3.StringUtils)1 CMLModelObjectsResolvingHelper (org.contextmapper.dsl.cml.CMLModelObjectsResolvingHelper)1 Application (org.contextmapper.dsl.contextMappingDSL.Application)1 CommandInvokation (org.contextmapper.dsl.contextMappingDSL.CommandInvokation)1 CommandInvokationStep (org.contextmapper.dsl.contextMappingDSL.CommandInvokationStep)1 ConcurrentCommandInvokation (org.contextmapper.dsl.contextMappingDSL.ConcurrentCommandInvokation)1 ConcurrentOperationInvokation (org.contextmapper.dsl.contextMappingDSL.ConcurrentOperationInvokation)1 ContextMappingModel (org.contextmapper.dsl.contextMappingDSL.ContextMappingModel)1 DomainEventProductionStep (org.contextmapper.dsl.contextMappingDSL.DomainEventProductionStep)1 EitherCommandOrOperation (org.contextmapper.dsl.contextMappingDSL.EitherCommandOrOperation)1 Flow (org.contextmapper.dsl.contextMappingDSL.Flow)1