use of org.contextmapper.dsl.generator.mdsl.generatorcontext.DownstreamContext in project context-mapper-dsl by ContextMapper.
the class MDSLModelCreator method createClient.
private EndpointClient createClient(DownstreamContext downstreamContext) {
EndpointClient client = new EndpointClient();
client.setName(mdslEncoder.encodeName(downstreamContext.getDownstreamName() + CLIENT_NAME_EXTENSION));
List<String> endpoints = downstreamContext.getConsumedAggregates().stream().map(agg -> agg.getName()).collect(Collectors.toList());
for (String offer : endpoints) {
client.addConsumedOffer(offer);
}
if (!downstreamContext.getDownstreamRoles().isEmpty()) {
String roles = String.join(" and ", downstreamContext.getDownstreamRoles().stream().map(ur -> ur.getName() + " (" + ur.getLiteral() + ")").collect(Collectors.toList()));
client.addComment("Generated from DDD downstream Bounded Context '" + downstreamContext.getDownstreamName() + "' implementing " + roles + ".");
}
if (downstreamContext.getDomainVisionStatement() != null && !"".equals(downstreamContext.getDomainVisionStatement()))
client.setDomainVisionStatement(downstreamContext.getDomainVisionStatement());
return client;
}
use of org.contextmapper.dsl.generator.mdsl.generatorcontext.DownstreamContext in project context-mapper-dsl by ContextMapper.
the class MDSLModelCreator method createServiceSpecification.
private ServiceSpecification createServiceSpecification(String apiName, UpstreamAPIContext context) {
ServiceSpecification specification = new ServiceSpecification();
specification.setName(mdslEncoder.encodeName(apiName));
if (context.getUpstreamRoles().contains(UpstreamRole.OPEN_HOST_SERVICE) && context.getUpstreamRoles().contains(UpstreamRole.PUBLISHED_LANGUAGE)) {
specification.setUsageContext(APIUsageContext.PUBLIC_API);
} else if (context.getUpstreamRoles().contains(UpstreamRole.OPEN_HOST_SERVICE)) {
specification.setUsageContext(APIUsageContext.COMMUNITY_API);
}
if (context.getApplicationLayer() != null) {
specification.addEndpoint(createEndpoint(context.getApplicationLayer(), specification));
for (DomainEvent de : context.getApplicationLayer().getEvents()) {
specification.addEventType(de.getName());
// TODO map data structure, not just name (if present)
}
// add event types for all domain events in all exposed aggregates
for (Aggregate exposedAggregate : context.getExposedAggregates()) {
for (SimpleDomainObject objectInAggregate : exposedAggregate.getDomainObjects()) {
// check type of domain object (entity? event?...?):
if (objectInAggregate instanceof DomainEvent) {
DomainEvent de = (DomainEvent) objectInAggregate;
// TODO make sure names are unique/do not add duplicates
specification.addEventType(de.getName());
}
}
}
for (CommandEvent ce : context.getApplicationLayer().getCommands()) {
specification.addCommandType(ce.getName());
}
EList<Flow> flows = context.getApplicationLayer().getFlows();
for (Flow cmlFlow : flows) {
OrchestrationFlow mdslFlow = new OrchestrationFlow();
mdslFlow.setName(cmlFlow.getName());
for (FlowStep step : cmlFlow.getSteps()) {
mapFlowStep(mdslFlow, step);
}
specification.addFlow(mdslFlow);
}
}
for (Aggregate aggregate : context.getExposedAggregates()) {
specification.addEndpoint(createEndpoint(aggregate, specification));
}
for (DataType dataType : dataTypeCreator.getAllDataTypes()) {
specification.addDataType(dataType);
}
specification.addProvider(createProvider(context, specification.getEndpoints()));
for (DownstreamContext downstreamContext : context.getDownstreamContexts()) {
specification.addClient(createClient(downstreamContext));
}
return specification;
}
Aggregations