use of org.contextmapper.dsl.cml.CMLModelObjectsResolvingHelper in project context-mapper-dsl by ContextMapper.
the class ApplicationFlowSemanticsValidator method commandInvokationMustReferCommandInSameContext.
@Check
public void commandInvokationMustReferCommandInSameContext(final CommandInvokation commandInvokation) {
CMLModelObjectsResolvingHelper helper = new CMLModelObjectsResolvingHelper((ContextMappingModel) EcoreUtil2.getRootContainer(commandInvokation));
BoundedContext currentContext = helper.resolveBoundedContext(commandInvokation);
for (CommandEvent commandEvent : commandInvokation.getCommands()) {
BoundedContext commandContext = helper.resolveBoundedContext((EObject) commandEvent);
if (commandContext == null || !currentContext.getName().equals(commandContext.getName()))
error(String.format(COMMAND_OR_OPERATION_IS_NOT_PART_OF_BOUNDED_CONTEXT, commandEvent.getName(), currentContext.getName()), commandInvokation, ContextMappingDSLPackage.Literals.COMMAND_INVOKATION__COMMANDS, commandInvokation.getCommands().indexOf(commandEvent));
}
}
use of org.contextmapper.dsl.cml.CMLModelObjectsResolvingHelper in project context-mapper-dsl by ContextMapper.
the class TacticDDDOperationsValidator method validateOperationStates.
private void validateOperationStates(EObject operation, StateTransition stateTransition) {
if (stateTransition == null)
return;
CMLModelObjectsResolvingHelper helper = new CMLModelObjectsResolvingHelper((ContextMappingModel) EcoreUtil2.getRootContainer(operation));
Aggregate aggregate = helper.resolveAggregate(operation);
if (aggregate == null)
return;
Set<String> aggregateStates = helper.resolveAggregateStates(aggregate);
for (EnumValue value : stateTransition.getFrom()) {
if (!aggregateStates.contains(value.getName()))
error(String.format(STATE_VALUE_DOES_NOT_BELONG_TO_AGGREGATE, value.getName(), aggregate.getName()), stateTransition, TacticdslPackage.Literals.STATE_TRANSITION__FROM, stateTransition.getFrom().indexOf(value));
}
for (EnumValue value : stateTransition.getTarget().getTo().stream().map(s -> s.getValue()).collect(Collectors.toList())) {
if (!aggregateStates.contains(value.getName()))
error(String.format(STATE_VALUE_DOES_NOT_BELONG_TO_AGGREGATE, value.getName(), aggregate.getName()), stateTransition.getTarget(), TacticdslPackage.Literals.STATE_TRANSITION_TARGET__TO, stateTransition.getTarget().getTo().indexOf(value));
}
}
use of org.contextmapper.dsl.cml.CMLModelObjectsResolvingHelper in project context-mapper-dsl by ContextMapper.
the class MergeAggregatesAction method isApplicable.
@Override
public boolean isApplicable() {
Set<Aggregate> aggregates = getSelectedAggregates();
if (aggregates.isEmpty() || aggregates.size() > 1)
return false;
BoundedContext parentContext = new CMLModelObjectsResolvingHelper(cmlResource.getContextMappingModel()).resolveBoundedContext(aggregates.iterator().next());
return EcoreUtil2.eAllOfType(parentContext, Aggregate.class).size() > 1;
}
use of org.contextmapper.dsl.cml.CMLModelObjectsResolvingHelper in project context-mapper-dsl by ContextMapper.
the class MergeAggregatesAction method getCommand.
@Override
public Command getCommand() {
Aggregate aggregate = getSelectedAggregate();
BoundedContext parentContext = new CMLModelObjectsResolvingHelper(cmlResource.getContextMappingModel()).resolveBoundedContext(aggregate);
List<Object> commandArguments = Lists.newLinkedList();
commandArguments.add(cmlResource.getURI().toString());
commandArguments.add(aggregate.getName());
commandArguments.addAll(EcoreUtil2.eAllOfType(parentContext, Aggregate.class).stream().map(agg -> agg.getName()).filter(name -> !name.equals(aggregate.getName())).collect(Collectors.toSet()));
return new Command("Merge Aggregates", "cml.ar.mergeAggregates.proxy", commandArguments);
}
use of org.contextmapper.dsl.cml.CMLModelObjectsResolvingHelper in project context-mapper-dsl by ContextMapper.
the class ServiceCutterOutputToContextMappingModelConverter method reconstructReference.
private void reconstructReference(DomainObject sourceObject, Reference originalReference, String targetTypeName) {
BoundedContext parentBC = new CMLModelObjectsResolvingHelper(originalModelState).resolveBoundedContext(sourceObject);
if (parentBC == null)
// in case this source object is not part of a Bounded Context
return;
List<DomainObject> targetDomainObjects = EcoreUtil2.eAllOfType(model, DomainObject.class).stream().filter(obj -> obj.getName().equals(targetTypeName)).collect(Collectors.toList());
if (targetDomainObjects.size() == 1) {
Reference reference = TacticdslFactory.eINSTANCE.createReference();
reference.setName(originalReference.getName());
reference.setDomainObjectType(targetDomainObjects.get(0));
reference.setCollectionType(originalReference.getCollectionType());
reference.setDoc(originalReference.getDoc());
sourceObject.getReferences().add(reference);
} else {
sourceObject.setComment("/* Service Cut generator: it was not possible to reconstruct the reference '" + originalReference.getName() + "' from " + sourceObject.getName() + " to " + targetTypeName + ". Please re-create that reference manually. */");
}
}
Aggregations