Package ca.uhn.fhir.model.primitive

Examples of ca.uhn.fhir.model.primitive.IdDt


    return resp;
  }

  @Override
  public <T extends IResource> T read(Class<T> theType, String theId) {
    return read(theType, new IdDt(theId));
  }
View Full Code Here


    return resp;
  }

  @Override
  public MethodOutcome update(String theId, IResource theResource) {
    return update(new IdDt(theId), theResource);
  }
View Full Code Here

    return resp;
  }

  @Override
  public <T extends IResource> T vread(Class<T> theType, String theId, String theVersionId) {
    return vread(theType, new IdDt(theId), new IdDt(theVersionId));
  }
View Full Code Here

      theWriter.writeEnd();
      break;
    }
    case RESOURCE_REF: {
      ResourceReferenceDt referenceDt = (ResourceReferenceDt) theValue;
      IdDt value = referenceDt.getReference();
      if (theChildName != null) {
        theWriter.writeStartObject(theChildName);
      } else {
        theWriter.writeStartObject();
      }

      String reference = value.getValue();
      if (StringUtils.isBlank(reference)) {
        if (value.getResourceType() != null && StringUtils.isNotBlank(value.getIdPart())) {
          reference = myContext.getResourceDefinition(value.getResourceType()).getName() + '/' + value.getIdPart();
        }
      }

      if (StringUtils.isNotBlank(reference)) {
        theWriter.write("resource", reference);
      }
      if (referenceDt.getDisplay().isEmpty() == false) {
        theWriter.write("display", referenceDt.getDisplay().getValueAsString());
      }
      theWriter.writeEnd();
      break;
    }
    case CONTAINED_RESOURCES: {
      theWriter.writeStartArray(theChildName);
      ContainedDt value = (ContainedDt) theValue;
      for (IResource next : value.getContainedResources()) {
        encodeResourceToJsonStreamWriter(theResDef, next, theWriter, null, true);
      }
      theWriter.writeEnd();
      break;
    }
View Full Code Here

  @Override
  public IBundleProvider invokeServer(Request theRequest, Object[] theMethodParams) throws InvalidRequestException, InternalErrorException {
    theMethodParams[myIdIndex] = theRequest.getId();
    if (myVersionIdIndex != null) {
      theMethodParams[myVersionIdIndex] = new IdDt(theRequest.getVersionId().getVersionIdPart());
    }

    Object response = invokeServerMethod(theMethodParams);

    return toResourceList(response);
View Full Code Here

  }

  @Override
  public HttpGetClientInvocation invokeClient(Object[] theArgs) {
    HttpGetClientInvocation retVal;
    IdDt id = ((IdDt) theArgs[myIdIndex]);
    if (myVersionIdIndex == null) {
      String resourceName = getResourceName();
      retVal = createReadInvocation(id, resourceName);
    } else {
      IdDt vid = ((IdDt) theArgs[myVersionIdIndex]);
      String resourceName = getResourceName();
      retVal = createVReadInvocation(id, vid, resourceName);
    }

    for (int idx = 0; idx < theArgs.length; idx++) {
View Full Code Here

    }

    if (elementId != null) {
      IElement object = (IElement) theState.getObject();
      if (object instanceof IIdentifiableElement) {
        ((IIdentifiableElement) object).setId(new IdDt(elementId));
      } else if (object instanceof IResource) {
        ((IResource) object).setId(new IdDt(elementId));
      }
    }
  }
View Full Code Here

  @Override
  public BaseHttpClientInvocation invokeClient(Object[] theArgs) throws InternalErrorException {
    HttpGetClientInvocation retVal;

    IdDt id = null;
    IdDt versionId = null;
    if (myIdParamIndex != null) {
      id = (IdDt) theArgs[myIdParamIndex];
      if (myVersionIdParamIndex != null) {
        versionId = (IdDt) theArgs[myVersionIdParamIndex];
      }
    }

    if (myType != IResource.class) {
      if (id != null) {
        if (versionId != null) {
          retVal = new HttpGetClientInvocation(getResourceName(), id.getIdPart(), Constants.PARAM_HISTORY, versionId.getValue(), Constants.PARAM_TAGS);
        } else if (id.hasVersionIdPart()){
          retVal = new HttpGetClientInvocation(getResourceName(), id.getIdPart(), Constants.PARAM_HISTORY, id.getVersionIdPart(), Constants.PARAM_TAGS);
        } else {
          retVal = new HttpGetClientInvocation(getResourceName(), id.getIdPart(), Constants.PARAM_TAGS);
        }
View Full Code Here

        ourLog.trace("Servlet Path: {}", servletPath);
        ourLog.trace("Request Url: {}", requestUrl);
        ourLog.trace("Context Path: {}", servletContextPath);
      }

      IdDt id = null;
      IdDt versionId = null;
      String operation = null;

      String requestPath = requestFullPath.substring(servletContextPath.length() + servletPath.length());
      if (requestPath.length() > 0 && requestPath.charAt(0) == '/') {
        requestPath = requestPath.substring(1);
      }

      String fhirServerBase;
      fhirServerBase = myServerAddressStrategy.determineServerBase(theRequest);

      if (fhirServerBase.endsWith("/")) {
        fhirServerBase = fhirServerBase.substring(0, fhirServerBase.length() - 1);
      }

      String completeUrl = StringUtils.isNotBlank(theRequest.getQueryString()) ? requestUrl + "?" + theRequest.getQueryString() : requestUrl.toString();

      Map<String, String[]> params = new HashMap<String, String[]>(theRequest.getParameterMap());

      StringTokenizer tok = new StringTokenizer(requestPath, "/");
      if (tok.hasMoreTokens()) {
        resourceName = tok.nextToken();
        if (resourceName.startsWith("_")) {
          operation = resourceName;
          resourceName = null;
        }
      }

      ResourceBinding resourceBinding = null;
      BaseMethodBinding<?> resourceMethod = null;
      if ("metadata".equals(resourceName)) {
        resourceMethod = myServerConformanceMethod;
      } else if (resourceName == null) {
        resourceBinding = myNullResourceBinding;
      } else {
        resourceBinding = myResourceNameToProvider.get(resourceName);
        if (resourceBinding == null) {
          throw new InvalidRequestException("Unknown resource type '" + resourceName + "' - Server knows how to handle: " + myResourceNameToProvider.keySet());
        }
      }

      if (tok.hasMoreTokens()) {
        String nextString = tok.nextToken();
        if (nextString.startsWith("_")) {
          operation = nextString;
        } else {
          id = new IdDt(resourceName, nextString);
        }
      }

      if (tok.hasMoreTokens()) {
        String nextString = tok.nextToken();
        if (nextString.equals(Constants.PARAM_HISTORY)) {
          if (tok.hasMoreTokens()) {
            String versionString = tok.nextToken();
            if (id == null) {
              throw new InvalidRequestException("Don't know how to handle request path: " + requestPath);
            }
            id = new IdDt(resourceName + "/" + id.getIdPart() + "/_history/" + versionString);
            versionId = id;
          } else {
            operation = Constants.PARAM_HISTORY;
          }
        } else if (nextString.startsWith("_")) {
          if (operation != null) {
            throw new InvalidRequestException("URL Path contains two operations (part beginning with _): " + requestPath);
          }
          operation = nextString;
        }
      }

      // Secondary is for things like ..../_tags/_delete
      String secondaryOperation = null;

      while (tok.hasMoreTokens()) {
        String nextString = tok.nextToken();
        if (operation == null) {
          operation = nextString;
        } else if (secondaryOperation == null) {
          secondaryOperation = nextString;
        } else {
          throw new InvalidRequestException("URL path has unexpected token '" + nextString + "' at the end: " + requestPath);
        }
      }

      if (theRequestType == RequestType.PUT && versionId == null) {
        String contentLocation = theRequest.getHeader("Content-Location");
        if (contentLocation != null) {
          versionId = new IdDt(contentLocation);
        }
      }

      // TODO: look for more tokens for version, compartments, etc...
View Full Code Here

      throw new InternalErrorException("Transaction bundle contained " + resources.size() + " entries, but server method response contained " + retVal.size() + " entries (must be the same)");
    }
   
    List<IResource> retResources = retVal.getResources(0, retVal.size());
    for (int i =0; i < resources.size(); i++) {
      IdDt oldId = oldIds.get(i);
      IResource newRes = retResources.get(i);
      if (newRes.getId() == null || newRes.getId().isEmpty()) {
        throw new InternalErrorException("Transaction method returned resource at index " + i + " with no id specified - IResource#setId(IdDt)");
      }
     
      if (oldId != null && !oldId.isEmpty()) {
        if (!oldId.getId().equals(newRes.getId())) {
          newRes.getResourceMetadata().put(ResourceMetadataKeyEnum.PREVIOUS_ID, oldId.getId());
        }
      }
    }
   
    return retVal;
View Full Code Here

TOP

Related Classes of ca.uhn.fhir.model.primitive.IdDt

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.