IScope scope_ReferenceProperty_inverse(final ReferenceProperty referenceProperty, EReference eRef) { final Structure containerType = referenceProperty.getContainingDataType(); Structure referencedType = referenceProperty.getType(); if (referencedType != null) { Iterable<ReferenceProperty> result = referencedType.getReferenceProperties(); result = Iterables.filter(result, new Predicate<ReferenceProperty>() { @Override public boolean apply(ReferenceProperty inverseReference) { return (inverseReference != referenceProperty) && (inverseReference.getType() == containerType); } }); return Scopes.scopeFor(result); } return null; }
@Check public void checkCircularContainment(ReferenceProperty referenceProperty) { if (referenceProperty.isContainment()) { Structure contained = referenceProperty.getType(); checkCircularContainment(Sets.newHashSet(referenceProperty.getContainingDataType()), contained); } }
@Check public void checkContainerReferenceProperty(ReferenceProperty referenceProperty) { if (referenceProperty.isContainer()) { ReferenceProperty inverse = referenceProperty.getInverse(); if (inverse != null && !inverse.isContainment()) { String message = String.format( "The inverse reference property '%s' of the data type '%s' is not a containing reference. An inverse container reference property must specify a containing reference as its inverse.", inverse.getName(), inverse.getContainingDataType().getName()); error(message, RapidmlPackage.Literals.REFERENCE_PROPERTY__CONTAINER); return; } } }
/** * The container keyword must be used on any reference that is the inverse of a containing reference. The container * keyword must not be used on any reference that is not the inverse of a containing reference. */ @Check public void checkContainmentReferenceProperty(ReferenceProperty referenceProperty) { if (referenceProperty.isContainment()) { ReferenceProperty inverse = referenceProperty.getInverse(); if (inverse != null && !inverse.isContainer()) { String message = String.format( "The inverse reference property '%s' of the data type '%s' is not a container reference. An inverse containing reference property must specify a container reference as its inverse.", inverse.getName(), inverse.getContainingDataType().getName()); error(message, RapidmlPackage.Literals.REFERENCE_PROPERTY__CONTAINMENT); } } }
private String getRefTypeName(ReferenceProperty prop) { DataModel thisDataModel = (DataModel) prop.getContainingDataType().eContainer(); ZenModel thisModel = (ZenModel) thisDataModel.eContainer(); Structure refType = prop.getType(); DataModel refDataModel = (DataModel) refType.eContainer(); ZenModel refModel = (ZenModel) refDataModel.eContainer(); if (thisDataModel == refDataModel) { return refType.getName(); } else if (thisModel == refModel) { return String.format("%s.%s", refDataModel.getName(), refType.getName()); } else { return String.format("%s.%s.%s", refModel.getName(), refDataModel.getName(), refType.getName()); } }