public String getResourceType() { return myId.getResourceType(); }
@Override String doGetValueAsQueryToken(FhirContext theContext) { if (isBlank(myId.getResourceType())) { return myId.getValue(); // e.g. urn:asdjd or 123 or cid:wieiuru or #1 } else { if (isBlank(getChain())) { return getResourceType() + "/" + myId.getIdPart(); } return myId.getIdPart(); } }
/** * Returns the referenced resource, fetching it <b>if it has not already been loaded</b>. This method invokes the * HTTP client to retrieve the resource unless it has already been loaded, or was a contained resource in which case * it is simply returned. */ public IBaseResource loadResource(IRestfulClient theClient) { if (myResource != null) { return myResource; } IdDt resourceId = getReference(); if (resourceId == null || isBlank(resourceId.getValue())) { throw new IllegalStateException("Reference has no resource ID defined"); } if (isBlank(resourceId.getBaseUrl()) || isBlank(resourceId.getResourceType())) { throw new IllegalStateException("Reference is not complete (must be in the form [baseUrl]/[resource type]/[resource ID]) - Reference is: " + resourceId.getValue()); } String resourceUrl = resourceId.getValue(); ourLog.debug("Loading resource at URL: {}", resourceUrl); RuntimeResourceDefinition definition = theClient.getFhirContext().getResourceDefinition(resourceId.getResourceType()); Class<? extends IBaseResource> resourceType = definition.getImplementingClass(); myResource = theClient.fetchResourceFromUrl(resourceType, resourceUrl); myResource.setId(resourceUrl); return myResource; }
/** * Returns true if this IdDt matches the given IdDt in terms of resource type and ID, but ignores the URL base */ @SuppressWarnings("deprecation") public boolean equalsIgnoreBase(IdDt theId) { if (theId == null) { return false; } if (theId.isEmpty()) { return isEmpty(); } return ObjectUtils.equals(getResourceType(), theId.getResourceType()) && ObjectUtils.equals(getIdPart(), theId.getIdPart()) && ObjectUtils.equals(getVersionIdPart(), theId.getVersionIdPart()); }
@Override public IBaseResource read(UriDt theUrl) { IdDt id = new IdDt(theUrl); String resourceType = id.getResourceType(); if (isBlank(resourceType)) { throw new IllegalArgumentException(myContext.getLocalizer().getMessage(I18N_INCOMPLETE_URI_FOR_READ, theUrl.getValueAsString())); } RuntimeResourceDefinition def = myContext.getResourceDefinition(resourceType); if (def == null) { throw new IllegalArgumentException(myContext.getLocalizer().getMessage(I18N_CANNOT_DETEMINE_RESOURCE_TYPE, theUrl.getValueAsString())); } return read(def.getImplementingClass(), id); }
retVal.setResourceType(id.getResourceType()); retVal.setResourceId(id.getIdPart()); retVal.setVersionId(id.getVersionIdPart());
@Override public List<IBaseResource> toListOfResources() { ArrayList<IBaseResource> retVal = new ArrayList<IBaseResource>(); for (Entry next : myBundle.getEntry()) { if (next.getResource() != null) { retVal.add(next.getResource()); } else if (next.getResponse().getLocationElement().isEmpty() == false) { IdDt id = new IdDt(next.getResponse().getLocation()); String resourceType = id.getResourceType(); if (isNotBlank(resourceType)) { IResource res = (IResource) myContext.getResourceDefinition(resourceType).newInstance(); res.setId(id); retVal.add(res); } } } return retVal; }
@Override public IdDt toUnqualifiedVersionless() { if (isLocal() || isUrn()) { return new IdDt(getValueAsString()); } return new IdDt(getResourceType(), getIdPart()); }
/** * Returns a new IdDt containing this IdDt's values but with no server base URL if one is present in this IdDt. For example, if this IdDt contains the ID "http://foo/Patient/1", this method will * return a new IdDt containing ID "Patient/1". */ @Override public IdDt toUnqualified() { if (isLocal() || isUrn()) { return new IdDt(getValueAsString()); } return new IdDt(getResourceType(), getIdPart(), getVersionIdPart()); }
@Override public IdDt toVersionless() { if (isLocal() || isUrn()) { return new IdDt(getValueAsString()); } return new IdDt(getBaseUrl(), getResourceType(), getIdPart(), null); }
public String getResourceType() { return myId.getResourceType(); }
ActionRequestDetails requestDetails = new ActionRequestDetails(theRequest, idToDelete.getResourceType(), idToDelete); notifyInterceptors(RestOperationTypeEnum.DELETE, requestDetails); ActionRequestDetails requestDetails = new ActionRequestDetails(theRequest, idToDelete.getResourceType(), idToDelete);
@Override String doGetValueAsQueryToken(FhirContext theContext) { if (isBlank(myId.getResourceType())) { return myId.getValue(); // e.g. urn:asdjd or 123 or cid:wieiuru or #1 } else { if (isBlank(getChain())) { return getResourceType() + "/" + myId.getIdPart(); } return myId.getIdPart(); } }
@Override public BaseIdentifierDt getIdentifier() { if(myResource == null) return null; return new IdentifierDt(myResource.getId().getResourceType(), myResource.getId().getIdPart()); }
/** * Returns true if this IdDt matches the given IdDt in terms of resource type and ID, but ignores the URL base */ @SuppressWarnings("deprecation") public boolean equalsIgnoreBase(IdDt theId) { if (theId == null) { return false; } if (theId.isEmpty()) { return isEmpty(); } return ObjectUtils.equals(getResourceType(), theId.getResourceType()) && ObjectUtils.equals(getIdPart(), theId.getIdPart()) && ObjectUtils.equals(getVersionIdPart(), theId.getVersionIdPart()); }
@Override public IBaseResource read(UriDt theUrl) { IdDt id = new IdDt(theUrl); String resourceType = id.getResourceType(); if (isBlank(resourceType)) { throw new IllegalArgumentException(myContext.getLocalizer().getMessage(I18N_INCOMPLETE_URI_FOR_READ, theUrl.getValueAsString())); } RuntimeResourceDefinition def = myContext.getResourceDefinition(resourceType); if (def == null) { throw new IllegalArgumentException(myContext.getLocalizer().getMessage(I18N_CANNOT_DETEMINE_RESOURCE_TYPE, theUrl.getValueAsString())); } return read(def.getImplementingClass(), id); }
@Override public List<IBaseResource> toListOfResources() { ArrayList<IBaseResource> retVal = new ArrayList<IBaseResource>(); for (Entry next : myBundle.getEntry()) { if (next.getResource() != null) { retVal.add(next.getResource()); } else if (next.getResponse().getLocationElement().isEmpty() == false) { IdDt id = new IdDt(next.getResponse().getLocation()); String resourceType = id.getResourceType(); if (isNotBlank(resourceType)) { IResource res = (IResource) myContext.getResourceDefinition(resourceType).newInstance(); res.setId(id); retVal.add(res); } } } return retVal; }
@Override public IdDt toUnqualifiedVersionless() { if (isLocal() || isUrn()) { return new IdDt(getValueAsString()); } return new IdDt(getResourceType(), getIdPart()); }
@Override public IdDt toVersionless() { if (isLocal() || isUrn()) { return new IdDt(getValueAsString()); } return new IdDt(getBaseUrl(), getResourceType(), getIdPart(), null); }
/** * Returns a new IdDt containing this IdDt's values but with no server base URL if one is present in this IdDt. For example, if this IdDt contains the ID "http://foo/Patient/1", this method will * return a new IdDt containing ID "Patient/1". */ @Override public IdDt toUnqualified() { if (isLocal() || isUrn()) { return new IdDt(getValueAsString()); } return new IdDt(getResourceType(), getIdPart(), getVersionIdPart()); }