private String getTargetResourceId(final ReferenceLink aReferenceLink) { String _xifexpression = null; ResourceDefinition _targetResource = aReferenceLink.getTargetResource(); boolean _tripleEquals = (_targetResource == null); if (_tripleEquals) { _xifexpression = "<undefined>"; } else { _xifexpression = aReferenceLink.getTargetResource().getName(); } return _xifexpression; }
public String getRelValue(final ReferenceLink referenceLink) { LinkRelation _linkRelation = referenceLink.getLinkRelation(); String _name = null; if (_linkRelation!=null) { _name=_linkRelation.getName(); } return _name; }
private boolean usesDefaultObjectRealization(ReferenceLink link) { if (link.getReferenceRealization() == null) { return true; } boolean noInlineLinkDescriptor = (link.getReferenceRealization().getInlineObjectRealization() == null) || (link.getReferenceRealization().getInlineObjectRealization().getAllIncludedProperties().isEmpty()); boolean noLinkDescriptor = (link.getLinkDescriptor() == null) || (link.getLinkDescriptor().getAllIncludedProperties().isEmpty()); return noInlineLinkDescriptor && noLinkDescriptor; }
private void normalizeUserDefinedReferenceLink(final ReferenceLink referenceLink) { maybeSetReferenceRealization(referenceLink); if (TagUtils.getTagWithName(referenceLink.getReferenceRealization().getLinkDescriptor(), TagUtils.GENERATED) .isPresent() && referenceLink.getTargetResource() instanceof ServiceDataResource) { EcoreUtil.remove(referenceLink.getReferenceRealization().getLinkDescriptor()); // This is a fix for JSON Schema generator which otherwise inlines the referenceLink markWithDefaultRealization(referenceLink); NamedLinkDescriptor linkDescriptor = ((ServiceDataResource) referenceLink.getTargetResource()).getDefaultLinkDescriptor(); referenceLink.getReferenceRealization().setProperties(linkDescriptor); } // usesDefaultObjectRealization uses getAllIncludedProperties defined in // referenceTreatmentInlineLinkDescriptorProcessor if (usesDefaultObjectRealization(referenceLink)) { markWithDefaultRealization(referenceLink); } }
private String _generateReferenceTreatment(final ReferenceLink refLink, final List<PropertyRealization> includedProperies, final CycleDetector<ReferenceTreatment> cycleDetector, final Integer indent) { String _xblockexpression = null; final ReferenceElement referencedProperty = refLink.getReferenceElement(); final String cardinality = XDataTypeExtensions.getCardinalityLabel(refLink, includedProperies); StringConcatenation _builder = new StringConcatenation(); _builder.newLine(); _builder.append("<a href=\"#"); String _htmlLink = this.docHelper.htmlLink(refLink.getTargetResource()); _builder.append(_htmlLink); _builder.append("\">"); String _name_1 = refLink.getTargetResource().getName(); _builder.append(_name_1); _builder.append("</a>");
_builder.append(" "); _builder.append("\"referencedResourceId\": \""); String _name_2 = link.getTargetResource().getName(); _builder.append(_name_2, " "); _builder.append("\","); _builder.newLine(); ObjectRealization _linkDescriptor = link.getLinkDescriptor(); boolean _tripleNotEquals = (_linkDescriptor != null); if (_tripleNotEquals) { EList<PropertyRealization> _allIncludedProperties = link.getLinkDescriptor().getAllIncludedProperties(); boolean _hasElements = false; for(final PropertyRealization feature : _allIncludedProperties) {
_builder.newLineIfNotEmpty(); LinkRelation _linkRelation = link.getLinkRelation(); boolean _tripleNotEquals = (_linkRelation != null); if (_tripleNotEquals) { _builder.append(" "); _builder.append("\"linkRelation\": \"rel: "); String _name = link.getLinkRelation().getName(); _builder.append(_name, " "); _builder.append("\","); _builder.newLine(); ObjectRealization _linkDescriptor = link.getLinkDescriptor(); boolean _tripleNotEquals_1 = (_linkDescriptor != null); if (_tripleNotEquals_1) { EList<PropertyRealization> _allIncludedProperties = link.getLinkDescriptor().getAllIncludedProperties(); boolean _hasElements = false; for(final PropertyRealization feature : _allIncludedProperties) {
private Iterable<String> getPathToAtomLink(final ReferenceLink referenceLink, final ServiceDataResource dataResource) { List<String> _xblockexpression = null; { List<String> result = new ArrayList<String>(); String _rootElementName = this.traceHelper.getRootElementName(dataResource); result.add(_rootElementName); Iterable<String> _containmentXpath = this.getContainmentXpath(referenceLink); Iterables.<String>addAll(result, _containmentXpath); Iterable<String> _referenceXpath = this.getReferenceXpath(referenceLink.getReferenceElement()); Iterables.<String>addAll(result, _referenceXpath); _xblockexpression = result; } return _xblockexpression; }
private void generateImplicitCollectionLinks(CollectionResource serviceDataResource, boolean hasRealizationRule) { ServiceDataResource targetResource = resourceFinder.findResource(serviceDataResource.getDataType(), true); boolean useReferenceLinkList = targetResource != null && serviceDataResource.isWithDefaultRealization() && !hasRealizationRule; serviceDataResource .setResourceRealizationKind(useReferenceLinkList ? CollectionRealizationEnum.REFERENCE_LINK_LIST : CollectionRealizationEnum.EMBEDDED_OBJECT_LIST); if (useReferenceLinkList) { ReferenceLink hyperlink = rapidmlFactory.createReferenceLink(); ReferenceTreatmentFactory.maybeSetReferenceRealization(hyperlink); hyperlink.getReferenceRealization().setTargetResource(targetResource); serviceDataResource.getReferenceTreatments().add(hyperlink); if (targetResource.getDefaultLinkDescriptor() != null) { hyperlink.getReferenceRealization().setProperties(targetResource.getDefaultLinkDescriptor()); } else { ObjectRealization linkDescriptor = rapidmlFactory.createObjectRealization(); // set container hyperlink.getReferenceRealization().setInlineObjectRealization(linkDescriptor); // Set by ReferenceTreatmentInlineLinkDescriptorProcessor for user-defined link descriptors hyperlink.getReferenceRealization().setProperties(linkDescriptor); } CollectionReferenceElement collectionReferenceElement = rapidmlFactory.createCollectionReferenceElement(); collectionReferenceElement.setCardinality(new int[] { 0, -1 }); collectionReferenceElement.setDataType(serviceDataResource.getDataType()); hyperlink.setReferenceElement(collectionReferenceElement); serviceDataResource.getReferenceElements().add(collectionReferenceElement); } }
private Iterable<String> getContainmentXpath(final ReferenceLink referenceLink) { final Function1<ReferenceEmbed, ReferenceElement> _function = (ReferenceEmbed it) -> { return it.getReferenceElement(); }; final Function1<ReferenceElement, Iterable<String>> _function_1 = (ReferenceElement it) -> { return this.getContainmentXpath(it); }; return Iterables.<String>concat(ListExtensions.<ReferenceElement, Iterable<String>>map(ListExtensions.<ReferenceEmbed, ReferenceElement>map(referenceLink.getEmbedHierarchy(), _function), _function_1)); }
private String getParameterName(final ReferenceLink referenceLink) { return StringExtensions.toFirstLower(referenceLink.getReferenceElement().getName()); }
private String getLinkURI(final ReferenceTreatment treatment) { String _switchResult = null; boolean _matched = false; if (treatment instanceof ReferenceLink) { _matched=true; _switchResult = this.expressify(((ReferenceLink)treatment).getTargetResource().getURI()); } if (!_matched) { if (treatment instanceof ReferenceEmbed) { _matched=true; _switchResult = null; } } return _switchResult; }
_builder.append("rel: \'"); String _elvis_1 = null; LinkRelation _linkRelation = ((ReferenceLink)treatment).getLinkRelation(); String _name_3 = null; if (_linkRelation!=null) {
private boolean isMultivalued(final ReferenceTreatment treatment) { boolean _xblockexpression = false; { int _maxOccurs = treatment.getReferenceElement().getMaxOccurs(); final boolean propIsMulti = (_maxOccurs < 0); boolean _switchResult = false; boolean _matched = false; if (treatment instanceof ReferenceLink) { _matched=true; _switchResult = (propIsMulti && (((ReferenceLink)treatment).getTargetResource() instanceof ObjectResource)); } if (!_matched) { if (treatment instanceof ReferenceEmbed) { _matched=true; _switchResult = propIsMulti; } } _xblockexpression = _switchResult; } return _xblockexpression; }
private CharSequence generateServiceDataResourceRepresentationParameters(final ServiceDataResource dataResource, final MediaType mediaType) { StringConcatenation _builder = new StringConcatenation(); { Iterable<ReferenceLink> _filter = Iterables.<ReferenceLink>filter(dataResource.getAllReferenceTreatments(), ReferenceLink.class); for(final ReferenceLink referenceLink : _filter) { String _idInTrace = this.traceHelper.getIdInTrace(referenceLink.getTargetResource()); String _plus = (_idInTrace + "Type"); CharSequence _generateRepresentationParameter = this.generateRepresentationParameter(referenceLink, mediaType, _plus, dataResource); _builder.append(_generateRepresentationParameter); _builder.newLineIfNotEmpty(); } } return _builder; }
return Boolean.valueOf((_sourceReference instanceof PropertyReference)); }; Iterable<URIParameter> _filter = IterableExtensions.<URIParameter>filter(link.getTargetResource().getURI().getUriParameters(), _function); boolean _hasElements = false; for(final URIParameter param : _filter) {
_builder.append(" "); _builder.append(" "); ResourceDefinition _targetResource = ((CollectionResource)resource).getReferenceLinks().get(0).getTargetResource(); final ServiceDataResource defResource = ((ServiceDataResource) _targetResource); _builder.newLineIfNotEmpty();