Package ca.uhn.fhir.model.api

Examples of ca.uhn.fhir.model.api.IResource


 
  @Override
  public void invokeServer(RestfulServer theServer, Request theRequest, HttpServletResponse theResponse) throws BaseServerResponseException, IOException {
    EncodingUtil encoding = BaseMethodBinding.determineResponseEncoding(theRequest.getServletRequest(), theRequest.getParameters());
    IParser parser = encoding.newParser(getContext());
    IResource resource = parser.parseResource(theRequest.getInputReader());

    Object[] params = new Object[getParameters().size()];
    for (int i = 0; i < getParameters().size(); i++) {
      IParameter param = getParameters().get(i);
      if (param == null) {
View Full Code Here


    return myResourceName;
  }

  @Override
  public BaseClientInvocation invokeClient(Object[] theArgs) throws InternalErrorException {
    IResource resource = (IResource) theArgs[myResourceParameterIndex];
    if (resource == null) {
      throw new NullPointerException("Resource can not be null");
    }

    RuntimeResourceDefinition def = getContext().getResourceDefinition(resource);
View Full Code Here

        }
      }
      break;
    }
    case RESOURCE: {
      IResource resource = parser.parseResource(theResponseReader);
      switch (getMethodReturnType()) {
      case BUNDLE:
        return Bundle.withSingleResource(resource);
      case LIST_OF_RESOURCES:
        return Collections.singletonList(resource);
View Full Code Here

  }

  @Override
  public List<IResource> invokeServer(Object theResourceProvider, IdDt theId, IdDt theVersionId, Map<String, String[]> theParameterValues) throws InvalidRequestException,
      InternalErrorException {
    IResource conf;
    try {
      conf = (Conformance) getMethod().invoke(theResourceProvider);
    } catch (Exception e) {
      throw new InternalErrorException("Failed to call access method", e);
    }
View Full Code Here

    return new HttpGetClientInvocation("metadata");
  }

  @Override
  public IBundleProvider invokeServer(Request theRequest, Object[] theMethodParams) throws BaseServerResponseException {
    IResource conf = (IResource) invokeServerMethod(theMethodParams);
    return new SimpleBundleProvider(conf);
  }
View Full Code Here

        eventWriter.writeEnd();
      }

      writeAuthor(nextEntry, eventWriter);

      IResource resource = nextEntry.getResource();
      if (resource != null && !resource.isEmpty()) {
        RuntimeResourceDefinition resDef = myContext.getResourceDefinition(resource);
        encodeResourceToJsonStreamWriter(resDef, resource, eventWriter, "content", false);
      }

      eventWriter.writeEnd(); // entry object
View Full Code Here

    }
   
    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

    return myResourceName;
  }

  @Override
  public BaseHttpClientInvocation invokeClient(Object[] theArgs) throws InternalErrorException {
    IResource resource = (IResource) theArgs[myResourceParameterIndex];
    if (resource == null) {
      throw new NullPointerException("Resource can not be null");
    }

    BaseHttpClientInvocation retVal = createClientInvocation(theArgs, resource);
View Full Code Here

      id = new IdDt(entry.getLinkSelf().getValue());
    } else {
      id = entry.getId();
    }

    IResource resource = entry.getResource();
    if (resource == null && id != null && isNotBlank(id.getResourceType())) {
      String resourceType = id.getResourceType();
      RuntimeResourceDefinition def = myContext.getResourceDefinition(resourceType);
      if (def == null) {
        throw new DataFormatException("Entry references unknown resource type: " + resourceType);
      }
      resource = def.newInstance();
      resource.setId(id);
      entry.setResource(resource);
    }

    if (resource != null) {
      resource.getResourceMetadata().put(ResourceMetadataKeyEnum.DELETED_AT, entry.getDeletedAt());
      resource.getResourceMetadata().put(ResourceMetadataKeyEnum.VERSION_ID, id);
    }
  }
View Full Code Here

        throw new IllegalStateException("Return type of " + IBundleProvider.class.getSimpleName() + " is not supported in clients");
      }
      break;
    }
    case RESOURCE: {
      IResource resource;
      if (myResourceType != null) {
        resource = parser.parseResource(myResourceType, theResponseReader);
      } else {
        resource = parser.parseResource(theResponseReader);
      }

      List<String> lmHeaders = theHeaders.get(Constants.HEADER_LAST_MODIFIED_LOWERCASE);
      if (lmHeaders != null && lmHeaders.size() > 0 && StringUtils.isNotBlank(lmHeaders.get(0))) {
        String headerValue = lmHeaders.get(0);
        Date headerDateValue;
        try {
          headerDateValue = DateUtils.parseDate(headerValue);
          InstantDt lmValue = new InstantDt(headerDateValue);
          resource.getResourceMetadata().put(ResourceMetadataKeyEnum.UPDATED, lmValue);
        } catch (Exception e) {
          ourLog.warn("Unable to parse date string '{}'. Error is: {}", headerValue, e.toString());
        }
      }
View Full Code Here

TOP

Related Classes of ca.uhn.fhir.model.api.IResource

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.