@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); }
@Override public boolean isIdPartValidLong() { return isValidLong(getIdPart()); }
@CoverageIgnore public String getIdPart() { return myId.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 void validateResourceType(BaseHasResource theEntity, String theResourceName) { if (!theResourceName.equals(theEntity.getResourceType())) { throw new ResourceNotFoundException( "Resource with ID " + theEntity.getIdDt().getIdPart() + " exists but it is not of type " + theResourceName + ", found resource of type " + theEntity.getResourceType()); } } }
@Override public void run(CommandLine theCommandLine) throws ParseException { String target = theCommandLine.getOptionValue("t"); if (isBlank(target) || (!target.startsWith("ws://") && !target.startsWith("wss://"))) { throw new ParseException("Target (-t) needs to be in the form \"ws://foo\" or \"wss://foo\""); } IdDt subsId = new IdDt(theCommandLine.getOptionValue("i")); WebSocketClient client = new WebSocketClient(); SimpleEchoSocket socket = new SimpleEchoSocket(subsId.getIdPart()); try { client.start(); URI echoUri = new URI(target); ClientUpgradeRequest request = new ClientUpgradeRequest(); ourLog.info("Connecting to : {}", echoUri); client.connect(socket, echoUri, request); while (!myQuit) { Thread.sleep(500L); } ourLog.info("Shutting down websocket client"); } catch (Exception e) { throw new CommandFailureException(e); } finally { try { client.stop(); } catch (Exception e) { ourLog.error("Failure", e); } } }
/** * 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()); }
retVal.setResourceId(id.getIdPart()); retVal.setVersionId(id.getVersionIdPart()); return retVal;
@Override public IdDt toUnqualifiedVersionless() { if (isLocal() || isUrn()) { return new IdDt(getValueAsString()); } return new IdDt(getResourceType(), getIdPart()); }
@Override public IdDt withResourceType(String theResourceName) { if (isLocal() || isUrn()) { return new IdDt(getValueAsString()); } return new IdDt(theResourceName, 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 IdDt 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 IdDt withServerBase(String theServerBase, String theResourceType) { if (isLocal() || isUrn()) { return new IdDt(getValueAsString()); } return new IdDt(theServerBase, theResourceType, getIdPart(), getVersionIdPart()); }
/** * 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); }
ourLog.warn("Unable to find resource {}/{}/_history/{} in database", next.getResourceType(), next.getIdDt().getIdPart(), next.getVersion()); continue;
String idPart = resourceId.getIdPart(); if (idPart != null) { next.getResource().setId(resourceId);
String idPart = resourceId.getIdPart(); if (idPart != null) { next.getResource().setId(resourceId);
} else { String resourceType = myContext.getResourceDefinition(next).getName(); nextEntry.getRequest().setUrl(new IdDt(theServerBase, resourceType, next.getId().getIdPart(), next.getId().getVersionIdPart()).getValue());