Search in sources :

Example 16 with Reference

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);
}
Also used : ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) Aggregate(org.contextmapper.dsl.contextMappingDSL.Aggregate) TacticdslPackage(org.contextmapper.tactic.dsl.tacticdsl.TacticdslPackage) SimpleDomainObject(org.contextmapper.tactic.dsl.tacticdsl.SimpleDomainObject) Set(java.util.Set) CollectionType(org.contextmapper.tactic.dsl.tacticdsl.CollectionType) REFERENCE_IS_AMBIGUOUS(org.contextmapper.dsl.validation.ValidationMessages.REFERENCE_IS_AMBIGUOUS) Collectors(java.util.stream.Collectors) CMLTypeChecker(org.contextmapper.dsl.cml.CMLTypeChecker) Sets(com.google.common.collect.Sets) CMLModelObjectsResolvingHelper(org.contextmapper.dsl.cml.CMLModelObjectsResolvingHelper) PRIMITIVE_ID_TYPE(org.contextmapper.dsl.validation.ValidationMessages.PRIMITIVE_ID_TYPE) Attribute(org.contextmapper.tactic.dsl.tacticdsl.Attribute) List(java.util.List) Entity(org.contextmapper.tactic.dsl.tacticdsl.Entity) EcoreUtil2(org.eclipse.xtext.EcoreUtil2) DOMAIN_OBJECT_NAME_ALREADY_EXISTS(org.contextmapper.dsl.validation.ValidationMessages.DOMAIN_OBJECT_NAME_ALREADY_EXISTS) Subdomain(org.contextmapper.dsl.contextMappingDSL.Subdomain) Reference(org.contextmapper.tactic.dsl.tacticdsl.Reference) Check(org.eclipse.xtext.validation.Check) EValidatorRegistrar(org.eclipse.xtext.validation.EValidatorRegistrar) REFERENCE_TO_NOT_REACHABLE_TYPE(org.contextmapper.dsl.validation.ValidationMessages.REFERENCE_TO_NOT_REACHABLE_TYPE) AbstractDeclarativeValidator(org.eclipse.xtext.validation.AbstractDeclarativeValidator) CMLModelObjectsResolvingHelper(org.contextmapper.dsl.cml.CMLModelObjectsResolvingHelper) SimpleDomainObject(org.contextmapper.tactic.dsl.tacticdsl.SimpleDomainObject) Aggregate(org.contextmapper.dsl.contextMappingDSL.Aggregate) Check(org.eclipse.xtext.validation.Check)

Aggregations

Reference (org.contextmapper.tactic.dsl.tacticdsl.Reference)16 Aggregate (org.contextmapper.dsl.contextMappingDSL.Aggregate)8 Entity (org.contextmapper.tactic.dsl.tacticdsl.Entity)8 BoundedContext (org.contextmapper.dsl.contextMappingDSL.BoundedContext)7 Attribute (org.contextmapper.tactic.dsl.tacticdsl.Attribute)7 List (java.util.List)5 Collectors (java.util.stream.Collectors)5 Set (java.util.Set)4 ContextMappingDSLFactory (org.contextmapper.dsl.contextMappingDSL.ContextMappingDSLFactory)4 ContextMappingModel (org.contextmapper.dsl.contextMappingDSL.ContextMappingModel)4 Subdomain (org.contextmapper.dsl.contextMappingDSL.Subdomain)4 TacticdslFactory (org.contextmapper.tactic.dsl.tacticdsl.TacticdslFactory)4 EcoreUtil2 (org.eclipse.xtext.EcoreUtil2)4 Sets (com.google.common.collect.Sets)3 CMLModelObjectsResolvingHelper (org.contextmapper.dsl.cml.CMLModelObjectsResolvingHelper)3 ContextMapperApplicationException (org.contextmapper.dsl.exception.ContextMapperApplicationException)3 SolverAlgorithm (ch.hsr.servicecutter.solver.SolverAlgorithm)2 Maps (com.google.common.collect.Maps)2 Map (java.util.Map)2 Optional (java.util.Optional)2