protected boolean shouldEncodeResourceId(IBaseResource theResource, EncodeContext theEncodeContext) { boolean retVal = true; if (isOmitResourceId()) { retVal = false; } else { if (myDontEncodeElements != null) { String resourceName = myContext.getResourceDefinition(theResource).getName(); if (myDontEncodeElements.stream().anyMatch(t -> t.equalsPath(resourceName + ".id"))) { retVal = false; } else if (myDontEncodeElements.stream().anyMatch(t -> t.equalsPath("*.id"))) { retVal = false; } else if (theEncodeContext.getResourcePath().size() == 1 && myDontEncodeElements.stream().anyMatch(t -> t.equalsPath("id"))) { retVal = false; } } } return retVal; }
protected boolean shouldAddSubsettedTag(EncodeContext theEncodeContext) { if (isSummaryMode()) { return true; } if (isSuppressNarratives()) { return true; } if (myEncodeElements != null) { if (isEncodeElementsAppliesToChildResourcesOnly() && theEncodeContext.getResourcePath().size() < 2) { return false; } String currentResourceName = theEncodeContext.getResourcePath().get(theEncodeContext.getResourcePath().size() - 1).getName(); if (myEncodeElementsAppliesToResourceTypes == null || myEncodeElementsAppliesToResourceTypes.contains(currentResourceName)) { return true; } } return false; }
private boolean checkIfParentShouldBeEncodedAndBuildPath() { List<ElementsPath> encodeElements = myEncodeElements; String currentResourceName = myEncodeContext.getResourcePath().get(myEncodeContext.getResourcePath().size() - 1).getName(); if (myEncodeElementsAppliesToResourceTypes != null && !myEncodeElementsAppliesToResourceTypes.contains(currentResourceName)) { encodeElements = null; } boolean retVal = checkIfPathMatchesForEncoding(encodeElements, true); /* * We force the meta tag to be encoded even if it's not specified as an element in the * elements filter, specifically because we'll need it in order to automatically add * the SUBSETTED tag */ if (!retVal) { if ("meta".equals(myEncodeContext.getLeafResourcePathFirstField()) && shouldAddSubsettedTag(myEncodeContext)) { // The next element is a child of the <meta> element retVal = true; } else if ("meta".equals(myDef.getElementName()) && shouldAddSubsettedTag(myEncodeContext)) { // The next element is the <meta> element retVal = true; } } return retVal; }
myEncodeContext.pushPath(myDef.getElementName(), false); if (theCheckingForEncodeElements && isEncodeElementsAppliesToChildResourcesOnly() && myEncodeContext.getResourcePath().size() < 2) { retVal = true; } else if (theElements == null) {
private void encodeResourceToJsonStreamWriter(RuntimeResourceDefinition theResDef, IBaseResource theResource, JsonLikeWriter theEventWriter, String theObjectNameOrNull, boolean theContainedResource, EncodeContext theEncodeContext) throws IOException { IIdType resourceId = null; if (StringUtils.isNotBlank(theResource.getIdElement().getIdPart())) { resourceId = theResource.getIdElement(); if (theResource.getIdElement().getValue().startsWith("urn:")) { resourceId = null; } } if (!theContainedResource) { if (!super.shouldEncodeResourceId(theResource, theEncodeContext)) { resourceId = null; } else if (theEncodeContext.getResourcePath().size() == 1 && getEncodeForceResourceId() != null) { resourceId = getEncodeForceResourceId(); } } encodeResourceToJsonStreamWriter(theResDef, theResource, theEventWriter, theObjectNameOrNull, theContainedResource, resourceId, theEncodeContext); }
private void encodeResourceToXmlStreamWriter(IBaseResource theResource, XMLStreamWriter theEventWriter, boolean theIncludedResource, EncodeContext theEncodeContext) throws XMLStreamException, DataFormatException { IIdType resourceId = null; if (StringUtils.isNotBlank(theResource.getIdElement().getIdPart())) { resourceId = theResource.getIdElement(); if (theResource.getIdElement().getValue().startsWith("urn:")) { resourceId = null; } } if (!theIncludedResource) { if (super.shouldEncodeResourceId(theResource, theEncodeContext) == false) { resourceId = null; } else if (theEncodeContext.getResourcePath().size() == 1 && getEncodeForceResourceId() != null) { resourceId = getEncodeForceResourceId(); } } encodeResourceToXmlStreamWriter(theResource, theEventWriter, theIncludedResource, resourceId, theEncodeContext); }