use of org.contextmapper.tactic.dsl.tacticdsl.Reference in project context-mapper-dsl by ContextMapper.
the class DomainObjectValidator method checkForInterBCReferencesThatRequireRelationship.
@Check
public void checkForInterBCReferencesThatRequireRelationship(Reference reference) {
if (reference.getDomainObjectType() == null || !(EcoreUtil2.getRootContainer(reference) instanceof ContextMappingModel))
return;
CMLModelObjectsResolvingHelper helper = new CMLModelObjectsResolvingHelper((ContextMappingModel) EcoreUtil2.getRootContainer(reference));
SimpleDomainObject containingObject = (SimpleDomainObject) reference.eContainer();
Set<String> domainObjectScope = Sets.newHashSet();
for (Aggregate aggregate : helper.resolveAllAccessibleAggregates(helper.resolveBoundedContext(containingObject))) domainObjectScope.addAll(EcoreUtil2.eAllOfType(aggregate, SimpleDomainObject.class).stream().map(o -> o.getName()).collect(Collectors.toSet()));
if (!domainObjectScope.contains(reference.getDomainObjectType().getName()))
warning(String.format(REFERENCE_TO_NOT_REACHABLE_TYPE, reference.getDomainObjectType().getName()), reference, TacticdslPackage.Literals.REFERENCE__DOMAIN_OBJECT_TYPE);
}
Aggregations