Search in sources :

Example 1 with EXPOSED_AGGREGATE_NOT_PART_OF_UPSTREAM_CONTEXT

use of org.contextmapper.dsl.validation.ValidationMessages.EXPOSED_AGGREGATE_NOT_PART_OF_UPSTREAM_CONTEXT in project context-mapper-dsl by ContextMapper.

the class ContextMapSemanticsValidator method validateThatExposedAggregateIsPartOfUpstreamContext.

@Check
public void validateThatExposedAggregateIsPartOfUpstreamContext(final ContextMap map) {
    for (Relationship rel : map.getRelationships()) {
        if (rel instanceof UpstreamDownstreamRelationship) {
            UpstreamDownstreamRelationship relationship = (UpstreamDownstreamRelationship) rel;
            BoundedContext upstreamContext = ((UpstreamDownstreamRelationship) relationship).getUpstream();
            int aggregateRefIndex = 0;
            for (Aggregate aggregate : relationship.getUpstreamExposedAggregates()) {
                List<String> aggregates = upstreamContext.getAggregates().stream().map(a -> a.getName()).collect(Collectors.toList());
                for (SculptorModule module : upstreamContext.getModules()) {
                    aggregates.addAll(module.getAggregates().stream().map(b -> b.getName()).collect(Collectors.toList()));
                }
                if (!aggregates.contains(aggregate.getName()))
                    error(String.format(EXPOSED_AGGREGATE_NOT_PART_OF_UPSTREAM_CONTEXT, aggregate.getName(), upstreamContext.getName()), relationship, UPSTREAM_DOWNSTREAM_RELATIONSHIP__UPSTREAM_EXPOSED_AGGREGATES, aggregateRefIndex);
                aggregateRefIndex++;
            }
        }
    }
}
Also used : CONTEXT_MAP__TYPE(org.contextmapper.dsl.contextMappingDSL.ContextMappingDSLPackage.Literals.CONTEXT_MAP__TYPE) SymmetricRelationship(org.contextmapper.dsl.contextMappingDSL.SymmetricRelationship) Aggregate(org.contextmapper.dsl.contextMappingDSL.Aggregate) ORGANIZATIONAL(org.contextmapper.dsl.contextMappingDSL.ContextMapType.ORGANIZATIONAL) SYMMETRIC_RELATIONSHIP__PARTICIPANT2(org.contextmapper.dsl.contextMappingDSL.ContextMappingDSLPackage.Literals.SYMMETRIC_RELATIONSHIP__PARTICIPANT2) SYMMETRIC_RELATIONSHIP__PARTICIPANT1(org.contextmapper.dsl.contextMappingDSL.ContextMappingDSLPackage.Literals.SYMMETRIC_RELATIONSHIP__PARTICIPANT1) BoundedContextType(org.contextmapper.dsl.contextMappingDSL.BoundedContextType) UpstreamDownstreamRelationship(org.contextmapper.dsl.contextMappingDSL.UpstreamDownstreamRelationship) Relationship(org.contextmapper.dsl.contextMappingDSL.Relationship) EReference(org.eclipse.emf.ecore.EReference) Check(org.eclipse.xtext.validation.Check) TEAM(org.contextmapper.dsl.contextMappingDSL.BoundedContextType.TEAM) EXPOSED_AGGREGATE_NOT_PART_OF_UPSTREAM_CONTEXT(org.contextmapper.dsl.validation.ValidationMessages.EXPOSED_AGGREGATE_NOT_PART_OF_UPSTREAM_CONTEXT) ORGANIZATIONAL_MAP_DOES_NOT_CONTAIN_TEAM(org.contextmapper.dsl.validation.ValidationMessages.ORGANIZATIONAL_MAP_DOES_NOT_CONTAIN_TEAM) RELATIONSHIP_CONTEXT_NOT_ON_MAP_ERROR_MESSAGE(org.contextmapper.dsl.validation.ValidationMessages.RELATIONSHIP_CONTEXT_NOT_ON_MAP_ERROR_MESSAGE) UPSTREAM_DOWNSTREAM_RELATIONSHIP__UPSTREAM(org.contextmapper.dsl.contextMappingDSL.ContextMappingDSLPackage.Literals.UPSTREAM_DOWNSTREAM_RELATIONSHIP__UPSTREAM) Collectors(java.util.stream.Collectors) SYSTEM_LANDSCAPE_MAP_CONTAINS_TEAM(org.contextmapper.dsl.validation.ValidationMessages.SYSTEM_LANDSCAPE_MAP_CONTAINS_TEAM) List(java.util.List) CONTEXT_MAP__BOUNDED_CONTEXTS(org.contextmapper.dsl.contextMappingDSL.ContextMappingDSLPackage.Literals.CONTEXT_MAP__BOUNDED_CONTEXTS) UPSTREAM_DOWNSTREAM_RELATIONSHIP__DOWNSTREAM(org.contextmapper.dsl.contextMappingDSL.ContextMappingDSLPackage.Literals.UPSTREAM_DOWNSTREAM_RELATIONSHIP__DOWNSTREAM) UPSTREAM_DOWNSTREAM_RELATIONSHIP__UPSTREAM_EXPOSED_AGGREGATES(org.contextmapper.dsl.contextMappingDSL.ContextMappingDSLPackage.Literals.UPSTREAM_DOWNSTREAM_RELATIONSHIP__UPSTREAM_EXPOSED_AGGREGATES) SculptorModule(org.contextmapper.dsl.contextMappingDSL.SculptorModule) SYSTEM_LANDSCAPE(org.contextmapper.dsl.contextMappingDSL.ContextMapType.SYSTEM_LANDSCAPE) EValidatorRegistrar(org.eclipse.xtext.validation.EValidatorRegistrar) ContextMap(org.contextmapper.dsl.contextMappingDSL.ContextMap) BoundedContext(org.contextmapper.dsl.contextMappingDSL.BoundedContext) AbstractDeclarativeValidator(org.eclipse.xtext.validation.AbstractDeclarativeValidator) SymmetricRelationship(org.contextmapper.dsl.contextMappingDSL.SymmetricRelationship) UpstreamDownstreamRelationship(org.contextmapper.dsl.contextMappingDSL.UpstreamDownstreamRelationship) Relationship(org.contextmapper.dsl.contextMappingDSL.Relationship) SculptorModule(org.contextmapper.dsl.contextMappingDSL.SculptorModule) BoundedContext(org.contextmapper.dsl.contextMappingDSL.BoundedContext) Aggregate(org.contextmapper.dsl.contextMappingDSL.Aggregate) UpstreamDownstreamRelationship(org.contextmapper.dsl.contextMappingDSL.UpstreamDownstreamRelationship) Check(org.eclipse.xtext.validation.Check)

Aggregations

List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Aggregate (org.contextmapper.dsl.contextMappingDSL.Aggregate)1 BoundedContext (org.contextmapper.dsl.contextMappingDSL.BoundedContext)1 BoundedContextType (org.contextmapper.dsl.contextMappingDSL.BoundedContextType)1 TEAM (org.contextmapper.dsl.contextMappingDSL.BoundedContextType.TEAM)1 ContextMap (org.contextmapper.dsl.contextMappingDSL.ContextMap)1 ORGANIZATIONAL (org.contextmapper.dsl.contextMappingDSL.ContextMapType.ORGANIZATIONAL)1 SYSTEM_LANDSCAPE (org.contextmapper.dsl.contextMappingDSL.ContextMapType.SYSTEM_LANDSCAPE)1 CONTEXT_MAP__BOUNDED_CONTEXTS (org.contextmapper.dsl.contextMappingDSL.ContextMappingDSLPackage.Literals.CONTEXT_MAP__BOUNDED_CONTEXTS)1 CONTEXT_MAP__TYPE (org.contextmapper.dsl.contextMappingDSL.ContextMappingDSLPackage.Literals.CONTEXT_MAP__TYPE)1 SYMMETRIC_RELATIONSHIP__PARTICIPANT1 (org.contextmapper.dsl.contextMappingDSL.ContextMappingDSLPackage.Literals.SYMMETRIC_RELATIONSHIP__PARTICIPANT1)1 SYMMETRIC_RELATIONSHIP__PARTICIPANT2 (org.contextmapper.dsl.contextMappingDSL.ContextMappingDSLPackage.Literals.SYMMETRIC_RELATIONSHIP__PARTICIPANT2)1 UPSTREAM_DOWNSTREAM_RELATIONSHIP__DOWNSTREAM (org.contextmapper.dsl.contextMappingDSL.ContextMappingDSLPackage.Literals.UPSTREAM_DOWNSTREAM_RELATIONSHIP__DOWNSTREAM)1 UPSTREAM_DOWNSTREAM_RELATIONSHIP__UPSTREAM (org.contextmapper.dsl.contextMappingDSL.ContextMappingDSLPackage.Literals.UPSTREAM_DOWNSTREAM_RELATIONSHIP__UPSTREAM)1 UPSTREAM_DOWNSTREAM_RELATIONSHIP__UPSTREAM_EXPOSED_AGGREGATES (org.contextmapper.dsl.contextMappingDSL.ContextMappingDSLPackage.Literals.UPSTREAM_DOWNSTREAM_RELATIONSHIP__UPSTREAM_EXPOSED_AGGREGATES)1 Relationship (org.contextmapper.dsl.contextMappingDSL.Relationship)1 SculptorModule (org.contextmapper.dsl.contextMappingDSL.SculptorModule)1 SymmetricRelationship (org.contextmapper.dsl.contextMappingDSL.SymmetricRelationship)1 UpstreamDownstreamRelationship (org.contextmapper.dsl.contextMappingDSL.UpstreamDownstreamRelationship)1