public static boolean sameOrOverrides(Feature feature1, Feature feature2) { // TODO add a stricter condition // But it's OK for now as // 1. this method is called only when feature1 and feature2 belong to the same data type hierarchy. // 2. Names are unique within a structure return feature1 == feature2 || feature1.getName().equals(feature2.getName()); }
private void processOverrides(Structure structure, Multimap<String, Feature> inheritedProperties) { for (Feature declaredProperty : structure.getOwnedFeatures()) { if (declaredProperty.isRestriction()) { Iterable<Feature> overriddenPropertyHierarchy = inheritedProperties.get(declaredProperty.getName()); processPropertyOverride(declaredProperty, overriddenPropertyHierarchy); inheritedProperties.removeAll(declaredProperty.getName()); } } }
private Multimap<String, Feature> buildNameToInheritedPropertiesMap(Structure structure) { Multimap<String, Feature> inheritedProperties = LinkedHashMultimap.create(); for (Inheritable next : structure.getSupertypes()) { if (next instanceof Structure) { Structure supertype = (Structure) next; addInheritedProperties(supertype); for (Feature inheritedProperty : supertype.getOwnedFeatures()) { inheritedProperties.put(inheritedProperty.getName(), inheritedProperty); } } } return inheritedProperties; } }
EList<Feature> _ownedFeatures = this.type.getOwnedFeatures(); for (final Feature feature : _ownedFeatures) { boolean _containsKey = this.includedProperties.containsKey(feature.getName()); if (_containsKey) { final EffectiveRealization.ConstrainedFeature constrainedFeature = this.constrainFeature(feature, this.includedProperties.get(feature.getName())); constrainedFeatures.put(feature.getName(), constrainedFeature); Iterable<Feature> _filter = IterableExtensions.<Feature>filter(this.type.getOwnedFeatures(), _function); for (final Feature refProp : _filter) { boolean _containsKey_1 = this.includedProperties.containsKey(refProp.getName()); if (_containsKey_1) { boolean _containsKey_2 = this.nestedRefRealizations.containsKey(refProp.getName()); if (_containsKey_2) { final CompletableFuture<EffectiveRealization> future = new CompletableFuture<EffectiveRealization>(); future.complete(this.nestedRefRealizations.get(refProp.getName())); refRealizationFutures.put(refProp.getName(), future); } else { refRealizationFutures.put(refProp.getName(), this.provider.getPropertyRealization(((ReferenceProperty) refProp)).get());
public String featureId(final ResourceDefinition aResource, final Feature aFeature) { String _name = aResource.getName(); String _plus = (_name + "."); String _name_1 = aFeature.getContainingDataType().getName(); String _plus_1 = (_plus + _name_1); String _plus_2 = (_plus_1 + "."); String _name_2 = aFeature.getName(); return (_plus_2 + _name_2); }
private void checkPropertyRestrictionType(Feature validatedProperty, Collection<FeatureHierarchy> featuresHierarchies) { if (!featuresHierarchies.isEmpty()) { // Empty featuresHierarchies or several hierarchies should // be processed by another validator FeatureHierarchy featureHierarchy = featuresHierarchies.iterator().next(); if (featureHierarchy.getFeatures().size() == 1) { String message = String.format("'%s' restricts a property which does not exist in extended supertypes", validatedProperty.getName()); error(message, validatedProperty, RapidmlPackage.Literals.FEATURE__NAME); } else if (featureHierarchy.getFeatures().size() > 1) { Feature restrictedProperty = featureHierarchy.getFeatures().get(1); checkRestrictionCardinality(validatedProperty, restrictedProperty); if (validatedProperty instanceof PrimitiveProperty) { checkPrimitivePropertyRestrictionType((PrimitiveProperty) validatedProperty, restrictedProperty); } if (validatedProperty instanceof ReferenceProperty) { checkReferencePropertyRestrictionType((ReferenceProperty) validatedProperty, restrictedProperty); } } } }
@Check public void checkIncludedPropertiesDuplicate(ObjectRealization includedProperties) { for (int i = 0; i < includedProperties.getOverriddenPropertyList().size(); i++) { PropertyRealization property = includedProperties.getOverriddenPropertyList().get(i); int excludedIdx = includedProperties.getExcludedProperties().indexOf(property.getBaseProperty()); if (excludedIdx >= 0) { error(NLS.bind(Messages.XtextDslJavaValidator_includedPropsDuplicate, property.getBaseProperty().getName()), includedProperties, RapidmlPackage.Literals.OBJECT_REALIZATION__OVERRIDDEN_PROPERTY_LIST, i); error(NLS.bind(Messages.XtextDslJavaValidator_excludedPropsDuplicate, property.getBaseProperty().getName()), includedProperties, RapidmlPackage.Literals.OBJECT_REALIZATION__EXCLUDED_PROPERTIES, excludedIdx); } } }
@Check public void checkDuplicatePropertyAndInheritedPropertyHierarchies(Structure structure) { Multimap<String, FeatureHierarchy> inheritedFeatures = getInheritedFeaturesMap(structure); for (String inheritedFeatureName : inheritedFeatures.keySet()) { Collection<FeatureHierarchy> featuresForName = inheritedFeatures.get(inheritedFeatureName); checkFeatureNameDuplicates(structure, featuresForName); checkForDuplicateFeatureHierarchies(structure, inheritedFeatureName, featuresForName); } for (Feature property : structure.getOwnedFeatures()) { if (property.isRestriction()) { Collection<FeatureHierarchy> featuresForName = inheritedFeatures.get(property.getName()); checkPropertyRestrictionType(property, featuresForName); } } }
/** * Checks for properties with duplicates names within the same structure and also in the inheritance hierarchy */ private void checkFeatureNameDuplicates(Structure structure, Collection<FeatureHierarchy> featuresForName) { for (FeatureHierarchy hierarchy : featuresForName) { Feature root = hierarchy.getRoot(); if (root.getContainingDataType() == structure && !root.isRestriction() && hierarchy.getFeatures().size() > 1) { Feature inheritedFeature = hierarchy.getFeatures().get(1); error(String.format("Duplicate name: property '%s' is already defined in '%s'", root.getName(), inheritedFeature.getContainingDataType().getName()), root, RapidmlPackage.Literals.FEATURE__NAME); } } }
private EffectiveRealization elaborateRealization(final ObjectRealizationSpec spec, final RealizationRule rule, final RealizationContext context, final boolean nested) { final EffectiveRealization.Builder builder = new EffectiveRealization.Builder(context, rule, this); final Consumer<Map.Entry<Feature, PropertyRealization>> _function = (Map.Entry<Feature, PropertyRealization> it) -> { final Feature feature = it.getKey(); final PropertyRealization propRzn = it.getValue(); builder.includeProperty(feature.getName(), propRzn); if ((((!Objects.equal(propRzn, null)) && Overlay.<Base>of(propRzn.getPropertyType()).isPresent()) && (propRzn.getPropertyType() instanceof ReferencePropertyRealization))) { PropertyTypeRealization _propertyType = propRzn.getPropertyType(); final ReferencePropertyRealization refRzn = ((ReferencePropertyRealization) _propertyType); boolean _isPresent = Overlay.<Base>of(refRzn.getRealization()).isPresent(); if (_isPresent) { final RealizationContext.ReferencePropertyRealizationContext refContext = RealizationContext.of(((ReferenceProperty) feature), context.getResource()); final ObjectRealizationSpec realization = this.resolveRealization(refRzn.getRealization(), refContext); EffectiveRealization _elaborateRealization = this.elaborateRealization(realization, null, refContext, true); builder.addNestedRealization(feature.getName(), ((EffectiveRealization.NestedEffectiveRealization) _elaborateRealization)); } } }; this.resolveProperties(spec.getPropertySet(), context).entrySet().forEach(_function); final Consumer<LinkSpec> _function_1 = (LinkSpec it) -> { builder.addLink(it.getLinkRelation(), this.resolveTarget(it.getTargetResourceType(), context)); }; this.resolveLinks(spec.getLinks(), context).forEach(_function_1); return builder.build(nested); }
private void checkRestrictionCardinality(Feature validatedProperty, Feature overriddenProperty) { if (validatedProperty.getMinOccurs() < overriddenProperty.getMinOccurs() || // (cardinalityMax(validatedProperty.getMaxOccurs()) > cardinalityMax( overriddenProperty.getMaxOccurs()))) { FeatureCardinalities cardinalities = FeatureCardinalities.getFeatureCardinalities(); String message = String.format( "The cardinality of property '%s' is incompatible with inherited property cardinality: '%s' ([%s, %s])", validatedProperty.getName(), cardinalities.getCardinality(overriddenProperty).getLabel(), overriddenProperty.getMinOccurs(), cardinalities.getCardinality(overriddenProperty).getUpperLabel()); error(message, validatedProperty, RapidmlPackage.Literals.ELEMENT__CARDINALITY); } }
private CharSequence getSerializationAttributes(final Feature field) { StringConcatenation _builder = new StringConcatenation(); { boolean _isGenerateJsonSerialization = this.config.isGenerateJsonSerialization(); if (_isGenerateJsonSerialization) { _builder.append("[JsonProperty(\""); String _name = field.getName(); _builder.append(_name); _builder.append("\")]"); _builder.newLineIfNotEmpty(); { boolean _isEnumField = this.isEnumField(field); if (_isEnumField) { _builder.append("[JsonConverter(typeof(StringEnumConverter))]"); } } _builder.newLineIfNotEmpty(); } } return _builder; }
newProperty = newReferenceProperty; newProperty.setName(inheritedProperty.getName()); newProperty.setCardinality(inheritedProperty.getCardinality()); newProperty.setReadOnly(inheritedProperty.isReadOnly());
_builder_2.append(type); _builder_2.append(" "); String _initialUpper = this.nameHelper.initialUpper(field.getName()); _builder_2.append(_initialUpper); _builder_2.append(" { get; set; }");
_builder_2.append(type); _builder_2.append(" "); String _initialUpper = this.nameHelper.initialUpper(field.getName()); _builder_2.append(_initialUpper); _builder_2.append(" { get; set; }");
String _name_1 = feature.getName(); _builder.append(_name_1, " \t\t\t\t\t "); _builder.append("</code>");
String _name = prop.getBaseProperty().getName(); _builder.append(_name, "\t\t"); _builder.append("\'");
_builder.append(indent, " "); _builder.append("em;\">"); String _name = property.getName(); _builder.append(_name, " "); _builder.append("</td>");
_builder.append(" "); _builder.append("<td>"); String _name = includedProperty.getBaseProperty().getName(); _builder.append(_name, " "); _builder.append("</td>");