@Override public boolean hasIdPart() { return isNotBlank(getIdPart()); }
/** * Returns the unqualified portion of this ID as a big decimal, or * <code>null</code> if the value is null * * @throws NumberFormatException If the value is not a valid BigDecimal */ public BigDecimal getIdPartAsBigDecimal() { String val = getIdPart(); if (isBlank(val)) { return null; } return new BigDecimal(val); }
/** * Returns the unqualified portion of this ID as a {@link Long}, or * <code>null</code> if the value is null * * @throws NumberFormatException If the value is not a valid Long */ @Override public Long getIdPartAsLong() { String val = getIdPart(); if (isBlank(val)) { return null; } return Long.parseLong(val); }
/** * Returns <code>true</code> if the unqualified ID is a valid {@link Long} * value (in other words, it consists only of digits) */ @Override public boolean isIdPartValidLong() { return isValidLong(getIdPart()); }
@Override public boolean isIdPartValid() { String id = getIdPart(); if (StringUtils.isBlank(id)) { return false; } if (id.length() > 64) { return false; } for (int i = 0; i < id.length(); i++) { char nextChar = id.charAt(i); if (nextChar >= 'a' && nextChar <= 'z') { continue; } if (nextChar >= 'A' && nextChar <= 'Z') { continue; } if (nextChar >= '0' && nextChar <= '9') { continue; } if (nextChar == '-' || nextChar == '.') { continue; } return false; } return true; }
public static SpecialElement fromProperty(Property property) { if (property.getStructure().getIdElement().getIdPart().equals("Parameters")) return PARAMETER; if (property.getStructure().getIdElement().getIdPart().equals("Bundle") && property.getName().equals("resource")) return BUNDLE_ENTRY; if (property.getStructure().getIdElement().getIdPart().equals("Bundle") && property.getName().equals("outcome")) return BUNDLE_OUTCOME; if (property.getName().equals("contained")) return CONTAINED; throw new Error("Unknown resource containing a native resource: "+property.getDefinition().getId()); } }
@Read(type = OperationDefinition.class) public OperationDefinition readOperationDefinition(@IdParam IdType theId) { if (theId == null || theId.hasIdPart() == false) { throw new ResourceNotFoundException(theId); } List<OperationMethodBinding> operationBindings = myOperationNameToBindings.get(theId.getIdPart()); if (operationBindings != null && !operationBindings.isEmpty()) { return readOperationDefinitionForOperation(operationBindings); } List<SearchMethodBinding> searchBindings = mySearchNameToBindings.get(theId.getIdPart()); if (searchBindings != null && !searchBindings.isEmpty()) { return readOperationDefinitionForNamedSearch(searchBindings); } throw new ResourceNotFoundException(theId); }
@Override protected void createOrUpdateConceptMap(org.hl7.fhir.r4.model.ConceptMap theConceptMap) { if (isBlank(theConceptMap.getIdElement().getIdPart())) { String matchUrl = "ConceptMap?url=" + UrlUtil.escapeUrlParam(theConceptMap.getUrl()); myConceptMapResourceDao.update(theConceptMap, matchUrl); } else { myConceptMapResourceDao.update(theConceptMap); } }
@Override protected void createOrUpdateValueSet(org.hl7.fhir.r4.model.ValueSet theValueSet) { if (isBlank(theValueSet.getIdElement().getIdPart())) { String matchUrl = "ValueSet?url=" + UrlUtil.escapeUrlParam(theValueSet.getUrl()); myValueSetResourceDao.update(theValueSet, matchUrl); } else { myValueSetResourceDao.update(theValueSet); } }
@Read public Patient read(RequestDetails theRequestDetails, @IdParam IdType theId) { String tenantId = theRequestDetails.getTenantId(); String resourceId = theId.getIdPart(); // Use these two values to fetch the patient return new Patient(); } }
@Override protected IIdType createOrUpdateCodeSystem(org.hl7.fhir.r4.model.CodeSystem theCodeSystemResource) { if (isBlank(theCodeSystemResource.getIdElement().getIdPart())) { String matchUrl = "CodeSystem?url=" + UrlUtil.escapeUrlParam(theCodeSystemResource.getUrl()); return myCodeSystemResourceDao.update(theCodeSystemResource, matchUrl).getId(); } else { return myCodeSystemResourceDao.update(theCodeSystemResource).getId(); } }
@Read() public StructureDefinition getProfileById(ServletRequestDetails theRequest, @IdParam IdType theId) { RuntimeResourceDefinition retVal = myContext.getResourceDefinitionById(theId.getIdPart()); if (retVal==null) { return null; } String serverBase = getServerBase(theRequest); return (StructureDefinition) retVal.toProfile(serverBase); }
/** * Returns true if this IdType matches the given IdType in terms of resource * type and ID, but ignores the URL base */ @SuppressWarnings("deprecation") public boolean equalsIgnoreBase(IdType 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 IdType toUnqualifiedVersionless() { if (isLocal() || isUrn()) { return new IdType(getValueAsString()); } return new IdType(getResourceType(), getIdPart()); }
@Override public IdType withResourceType(String theResourceName) { if (isLocal() || isUrn()) { return new IdType(getValueAsString()); } return new IdType(theResourceName, getIdPart(), getVersionIdPart()); }
@Override public IdType toVersionless() { if (isLocal() || isUrn()) { return new IdType(getValueAsString()); } return new IdType(getBaseUrl(), getResourceType(), getIdPart(), null); }
/** * Returns a new IdType containing this IdType's values but with no server * base URL if one is present in this IdType. For example, if this IdType * contains the ID "http://foo/Patient/1", this method will return a new * IdType containing ID "Patient/1". */ @Override public IdType toUnqualified() { if (isLocal() || isUrn()) { return new IdType(getValueAsString()); } return new IdType(getResourceType(), getIdPart(), getVersionIdPart()); }
/** * Returns a view of this ID as a fully qualified URL, given a server base and * resource name (which will only be used if the ID does not already contain * those respective parts). Essentially, because IdType can contain either a * complete URL or a partial one (or even jut a simple ID), this method may be * used to translate into a complete URL. * * @param theServerBase The server base (e.g. "http://example.com/fhir") * @param theResourceType The resource name (e.g. "Patient") * @return A fully qualified URL for this ID (e.g. * "http://example.com/fhir/Patient/1") */ @Override public IdType withServerBase(String theServerBase, String theResourceType) { if (isLocal() || isUrn()) { return new IdType(getValueAsString()); } return new IdType(theServerBase, theResourceType, getIdPart(), getVersionIdPart()); }
private IIdType bindSimple(WebSocketSession theSession, String theBindString) { IdType id = new IdType(theBindString); if (!id.hasIdPart() || !id.isIdPartValid()) { try { String message = "Invalid bind request - No ID included"; ourLog.warn(message); theSession.close(new CloseStatus(CloseStatus.PROTOCOL_ERROR.getCode(), message)); } catch (IOException e) { handleFailure(e); } return null; } if (id.hasResourceType() == false) { id = id.withResourceType("Subscription"); } try { ActiveSubscription activeSubscription = mySubscriptionRegistry.get(id.getIdPart()); myState = new BoundStaticSubscipriptionState( theSession, activeSubscription); } catch (ResourceNotFoundException e) { try { String message = "Invalid bind request - Unknown subscription: " + id.getValue(); ourLog.warn(message); theSession.close(new CloseStatus(CloseStatus.PROTOCOL_ERROR.getCode(), message)); } catch (IOException e1) { handleFailure(e); } return null; } return id; }
} else { String resourceType = myContext.getResourceDefinition(next).getName(); nextEntry.getRequest().setUrl(new IdType(theServerBase, resourceType, next.getIdElement().getIdPart(), next.getIdElement().getVersionIdPart()).getValue());