@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; } } }
@Override public boolean apply(ReferenceProperty inverseReference) { return (inverseReference != referenceProperty) && (inverseReference.getType() == containerType); } });
switch (containment) { case CONTAINING: _switchResult = refProp.isContainment(); break; case NON_CONTAINING: boolean _isContainment = refProp.isContainment(); _switchResult = (!_isContainment); break; case CONTAINER: _switchResult = refProp.isContainer(); break; case NON_CONTAINER: boolean _isContainer = refProp.isContainer(); _switchResult = (!_isContainer); break; case CONTAINMENT: _switchResult = (refProp.isContainer() || refProp.isContainment()); break; case NON_CONTAINMENT: _switchResult = ((!refProp.isContainer()) && (!refProp.isContainment())); break; default:
@Check public void checkCircularContainment(ReferenceProperty referenceProperty) { if (referenceProperty.isContainment()) { Structure contained = referenceProperty.getType(); checkCircularContainment(Sets.newHashSet(referenceProperty.getContainingDataType()), contained); } }
StringConcatenation _builder = new StringConcatenation(); boolean _isContainment = property.isContainment(); if (_isContainment) { _builder.append("containing"); boolean _isContainer = property.isContainer(); if (_isContainer) { _builder.append("container"); String _htmlLink = this.docHelper.htmlLink(property.getType()); _builder.append(_htmlLink); _builder.append("\">"); _builder.newLineIfNotEmpty(); ReferenceProperty _inverse = property.getInverse(); boolean _tripleNotEquals = (_inverse != null); if (_tripleNotEquals) { _builder.append("<br> inverse of <a href=\"#"); String _htmlLink_1 = this.docHelper.htmlLink(property.getType()); _builder.append(_htmlLink_1); _builder.append("\">"); String _name = property.getInverse().getName(); _builder.append(_name); _builder.append("</a>");
ReferenceProperty inheritedReferenceProperty = (ReferenceProperty) inheritedProperty; ReferenceProperty newReferenceProperty = RapidmlFactory.eINSTANCE.createReferenceProperty(); newReferenceProperty.setType(inheritedReferenceProperty.getType()); newReferenceProperty.setContainer(inheritedReferenceProperty.isContainer()); newReferenceProperty.setContainment(inheritedReferenceProperty.isContainment()); newReferenceProperty.setInverse(inheritedReferenceProperty.getInverse()); newProperty = newReferenceProperty;
private void checkReferencePropertyRestrictionType(ReferenceProperty validatedProperty, Feature overriddenProperty) { Structure restrictionType = validatedProperty.getType(); if (overriddenProperty instanceof ReferenceProperty) { Structure overriddenType = ((ReferenceProperty) overriddenProperty).getType(); if (overriddenType == restrictionType) {// same type return; } if (restrictionType.getAllSupertypes().contains(overriddenType)) {// covariance return; } String message = String.format( "The type of property '%s' is incompatible with inherited property type: '%s'", validatedProperty.getName(), overriddenType.getName()); error(message, validatedProperty, RapidmlPackage.Literals.REFERENCE_PROPERTY__TYPE); } }
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; }
/** * The inverse keyword and refProp must be specified on both sides of the inverse pair, and must be consistent such * that if DT1.r specifies DT2.r as its inverse, then DT2.r must specify DT1.r as its inverse. * * @param referenceProperty */ @Check public void checkInverseReferenceProperty(ReferenceProperty referenceProperty) { ReferenceProperty inverse = referenceProperty.getInverse(); if (inverse != null) { ReferenceProperty inverseOfInverse = inverse.getInverse(); if (inverseOfInverse == null) { String message = String.format( "The inverse keyword must be specified on both sides of the inverse pair of '%s' and '%s'", referenceProperty.getName(), inverse.getName()); error(message, RapidmlPackage.Literals.REFERENCE_PROPERTY__INVERSE); return; } if (!referenceProperty.equals(inverseOfInverse)) { String message = String.format( "The inverse keyword and refProp must be consistent on both sides of the inverse pair of '%s' and '%s'", referenceProperty.getName(), inverse.getName()); error(message, RapidmlPackage.Literals.REFERENCE_PROPERTY__INVERSE); } } }
public EList<ReferenceTreatment> buildReferenceTreatmentsList(final EffectiveRealization realization) { final ArrayList<ReferenceTreatment> referenceTreatments = new ArrayList<ReferenceTreatment>(); final Function1<ReferenceProperty, Boolean> _function = (ReferenceProperty it) -> { return Boolean.valueOf(realization.getReferenceRealizations().containsKey(it.getName())); }; final Function1<ReferenceProperty, ReferenceTreatment> _function_1 = (ReferenceProperty refProperty) -> { final EffectiveRealization refRealization = realization.getReferenceRealizations().get(refProperty.getName()); final ReferenceRealization referenceRealization = refRealization.asReferenceRealization(); final ReferenceTreatment referenceTreatment = this.buildReferenceTreatment(referenceRealization); referenceTreatment.setReferenceElement(refProperty); return referenceTreatment; }; final Consumer<ReferenceTreatment> _function_2 = (ReferenceTreatment it) -> { referenceTreatments.add(it); }; IterableExtensions.<ReferenceProperty, ReferenceTreatment>map(IterableExtensions.<ReferenceProperty>filter(realization.getType().getReferenceProperties(), _function), _function_1).forEach(_function_2); return ECollections.<ReferenceTreatment>unmodifiableEList(referenceTreatments); }
private JsonNode createStructureMetadata(Structure struct) { ObjectNode root = newObjectNode(); root.put("name", struct.getName()); ObjectNode fields = root.putObject("fields"); for (PrimitiveProperty prop : struct.getPrimitiveProperties()) { ObjectNode field = fields.putObject(prop.getName()); field.put("name", prop.getName()); field.put("type", prop.getPrimitiveType().getName()); field.put("multi", prop.getMaxOccurs() < 0); } for (ReferenceProperty prop : struct.getReferenceProperties()) { ObjectNode field = fields.putObject(prop.getName()); field.put("name", prop.getName()); field.put("type", "ref"); field.put("multi", prop.getMaxOccurs() < 0); field.put("refType", getRefTypeName(prop)); } return root; }
@Override public boolean apply(ReferenceProperty input) { return input.isContainment(); } };
_builder.append(" "); _builder.append("\"name\": \""); String _name = feature.getName(); _builder.append(_name, " "); _builder.append("\","); _builder.append(" "); _builder.append("\"type\": \""); String _name_1 = feature.getType().getName(); _builder.append(_name_1, " "); _builder.append("\","); String _name_2 = feature.getName(); String _plus_1 = (_plus + _name_2); _builder.append(_plus_1, " ");
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()); } }
ObjectNode propNode = fieldRoot.putObject(prop.getName()); if (refFieldSkeleton != null) { propNode.setAll(refFieldSkeleton);
/** * 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); } } }
@Override public Structure getStructure() { return this.refProp.getType(); }
protected static Set<Structure> getContainmentReferencePropertyTypes(Structure type) { Set<Structure> result = Sets.newHashSet(); for (ReferenceProperty prop : filter(type.getReferenceProperties(), isContainmentReferenceProperty())) { result.add(prop.getType()); } return result; }
public boolean checkAutoLinkableToObject(final ReferenceProperty prop, final Boolean autoLinkable) { if ((autoLinkable == null)) { return true; } boolean _isAutoLinkableToObjectResource = ContextMatcher.isAutoLinkableToObjectResource(prop.getType(), this.context.getApi()); return ((autoLinkable).booleanValue() == _isAutoLinkableToObjectResource); }
public boolean checkAutoLinkableToCollection(final ReferenceProperty prop, final Boolean autoLinkable) { if ((autoLinkable == null)) { return true; } boolean _isAutoLinkableToCollectionResource = ContextMatcher.isAutoLinkableToCollectionResource(prop.getType(), this.context.getApi()); return ((autoLinkable).booleanValue() == _isAutoLinkableToCollectionResource); } }