/** * 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 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 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 boolean isIdPartValidLong() { return isValidLong(getIdPart()); }
@Override public boolean isVersionIdPartValidLong() { return isValidLong(getVersionIdPart()); }
iterator.remove(); } else { IdDt resourceId = new IdDt(next.getResource().getResourceName() + "/EX" + next.getResource().getId().getIdPart()); if (!fullIds.add(resourceId.toUnqualifiedVersionless().getValue())) { ourLog.info("Discarding duplicate resource: " + resourceId.getValue()); iterator.remove(); continue; String idPart = resourceId.getIdPart(); if (idPart != null) { next.getResource().setId(resourceId); for (Iterator<Entry> iterator = bundle.getEntry().iterator(); iterator.hasNext(); ) { Entry next = iterator.next(); if (next.getResource().getId().getIdPart() != null) { String nextId = next.getResource().getId().getValue(); next.getRequest().setMethod(HTTPVerbEnum.PUT); next.getRequest().setUrl(nextId);
@Override public boolean hasIdPart() { return isNotBlank(getIdPart()); }
if (!nextResourceId.hasIdPart()) { if (isNotBlank(nextReqEntry.getFullUrl())) { nextResourceId = new IdDt(nextReqEntry.getFullUrl()); if (nextResourceId.hasIdPart() && nextResourceId.getIdPart().matches("[a-zA-Z]+\\:.*") && !isPlaceholder(nextResourceId)) { throw new InvalidRequestException("Invalid placeholder ID found: " + nextResourceId.getIdPart() + " - Must be of the form 'urn:uuid:[uuid]' or 'urn:oid:[oid]'"); if (nextResourceId.hasIdPart() && !nextResourceId.hasResourceType() && !isPlaceholder(nextResourceId)) { nextResourceId = new IdDt(toResourceName(res.getClass()), nextResourceId.getIdPart()); res.setId(nextResourceId); } else if (nextResourceId.hasResourceType() && nextResourceId.hasIdPart()) { IdDt nextId = nextResourceId.toUnqualifiedVersionless(); if (!theAllIds.add(nextId)) { throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseHapiFhirSystemDao.class, "transactionContainsMultipleWithDuplicateId", nextId)); int status = Constants.STATUS_HTTP_204_NO_CONTENT; if (parts.getResourceId() != null) { DaoMethodOutcome outcome = dao.delete(new IdDt(parts.getResourceType(), parts.getResourceId()), theDeleteConflicts, theRequestDetails); if (outcome.getEntity() != null) { theDeletedResources.add(outcome.getId().toUnqualifiedVersionless()); List<ResourceTable> allDeleted = deleteOutcome.getDeletedEntities(); for (ResourceTable deleted : allDeleted) { theDeletedResources.add(deleted.getIdDt().toUnqualifiedVersionless()); res.setId(new IdDt(parts.getResourceType(), parts.getResourceId())); outcome = resourceDao.update(res, null, false, theRequestDetails); } else {
if (next.getId().isEmpty()) { nextEntry.getRequest().setMethod(HTTPVerbEnum.POST); } else { nextEntry.getRequest().setMethod(HTTPVerbEnum.PUT); if (next.getId().isAbsolute()) { nextEntry.getRequest().setUrl(next.getId()); } else { String resourceType = myContext.getResourceDefinition(next).getName(); nextEntry.getRequest().setUrl(new IdDt(theServerBase, resourceType, next.getId().getIdPart(), next.getId().getVersionIdPart()).getValue());
/** * Sets the value for <b>reference</b> (Relative, internal or absolute URL reference) * * <p> * <b>Definition:</b> * A reference to a location at which the other resource is found. The reference may a relative reference, in which case it is relative to the service base URL, or an absolute URL that resolves to the location where the resource is found. The reference may be version specific or not. If the reference is not to a FHIR RESTful server, then it should be assumed to be version specific. Internal fragment references (start with '#') refer to contained resources * </p> */ public ResourceReferenceDt setReference( String theId) { myReference = new IdDt(theId); return this; }
IdDt id = new IdDt(url); retVal.setResourceType(id.getResourceType()); retVal.setResourceId(id.getIdPart()); retVal.setVersionId(id.getVersionIdPart()); return retVal;
Set<String> containedIds = new HashSet<String>(); for (IResource nextContained : next.getContained().getContainedResources()) { if (nextContained.getId().isEmpty() == false) { containedIds.add(nextContained.getId().getValue()); IResource nextRes = (IResource) nextRef.getResource(); if (nextRes != null) { if (nextRes.getId().hasIdPart()) { if (containedIds.contains(nextRes.getId().getValue())) { if (id.hasResourceType() == false) { String resName = myContext.getResourceDefinition(nextRes).getName(); id = id.withResourceType(resName); if (next.getId().hasBaseUrl()) { entry.setFullUrl(next.getId().getValue());
@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); } } }
@Override public String getValueAsString() { return getValue(); }
@Override public void applyTo(IBaseResource theResouce) { if (theResouce == null) { throw new NullPointerException("theResource can not be null"); } else if (theResouce instanceof IResource) { ((IResource) theResouce).setId(new IdDt(getValue())); } else if (theResouce instanceof IAnyResource) { ((IAnyResource) theResouce).setId(getValue()); } else { throw new IllegalArgumentException("Unknown resource class type, does not implement IResource or extend Resource"); } }
private static void handleTransactionCreateOrUpdateOutcome(Map<IdDt, IdDt> idSubstitutions, Map<IdDt, DaoMethodOutcome> idToPersistedOutcome, IdDt nextResourceId, DaoMethodOutcome outcome, Entry newEntry, String theResourceType, IResource theRes) { IdDt newId = (IdDt) outcome.getId().toUnqualifiedVersionless(); IdDt resourceId = isPlaceholder(nextResourceId) ? nextResourceId : nextResourceId.toUnqualifiedVersionless(); if (newId.equals(resourceId) == false) { idSubstitutions.put(resourceId, newId); if (isPlaceholder(resourceId)) { /* * The correct way for substitution IDs to be is to be with no resource type, but we'll accept the qualified kind too just to be lenient. */ idSubstitutions.put(new IdDt(theResourceType + '/' + resourceId.getValue()), newId); } } idToPersistedOutcome.put(newId, outcome); if (outcome.getCreated().booleanValue()) { newEntry.getResponse().setStatus(toStatusString(Constants.STATUS_HTTP_201_CREATED)); } else { newEntry.getResponse().setStatus(toStatusString(Constants.STATUS_HTTP_200_OK)); } newEntry.getResponse().setLastModified(ResourceMetadataKeyEnum.UPDATED.get(theRes)); }
String headerValue = clHeaders.get(0); if (isNotBlank(headerValue)) { new IdDt(headerValue).applyTo(resource); String headerValue = locationHeaders.get(0); if (isNotBlank(headerValue)) { new IdDt(headerValue).applyTo(resource); IdDt existing = IdDt.of(resource); if (existing == null || existing.isEmpty()) { if (theRequestedId != null) { theRequestedId.withVersion(eTagVersion).applyTo(resource); } else if (existing.hasVersionIdPart() == false) { existing.withVersion(eTagVersion).applyTo(resource); } else if (existing == null || existing.isEmpty()) { if (theRequestedId != null) { theRequestedId.applyTo(resource);
@Override public BaseIdentifierDt getIdentifier() { if(myResource == null) return null; return new IdentifierDt(myResource.getId().getResourceType(), myResource.getId().getIdPart()); }
System.out.println("Got ID: " + id.getValue()); System.out.println("Got ID: " + id.getValue()); System.out.println("Version ID: " + patient.getId().getVersionIdPart()); IBaseOperationOutcome resp = client.delete().resourceById(new IdDt("Patient", "1234")).execute();
private void populateBundleEntryFullUrl(IResource next, Entry entry) { if (next.getId().hasBaseUrl()) { entry.setFullUrl(next.getId().toVersionless().getValue()); } else { if (isNotBlank(myBase) && next.getId().hasIdPart()) { IdDt id = next.getId().toVersionless(); id = id.withServerBase(myBase, myContext.getResourceDefinition(next).getName()); entry.setFullUrl(id.getValue()); } } }