Package ca.uhn.fhir.model.api

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


    if (myTagList != null) {
      contents = parser.encodeTagListToString(myTagList);
    } else if (myBundle != null) {
      contents = parser.encodeBundleToString(myBundle);
    } else if (myResources != null) {
      Bundle bundle = RestfulServer.createBundleFromResourceList(myContext, "", myResources, "", "", myResources.size());
      contents = parser.encodeBundleToString(bundle);
    } else {
      contents = parser.encodeResourceToString(myResource);
    }
View Full Code Here


  public Object invokeClient(String theResponseMimeType, Reader theResponseReader, int theResponseStatusCode, Map<String, List<String>> theHeaders) throws IOException {
    IParser parser = createAppropriateParserForParsingResponse(theResponseMimeType, theResponseReader, theResponseStatusCode);

    switch (getReturnType()) {
    case BUNDLE: {
      Bundle bundle;
      if (myResourceType != null) {
        bundle = parser.parseBundle(myResourceType, theResponseReader);
      } else {
        bundle = parser.parseBundle(theResponseReader);
      }
      switch (getMethodReturnType()) {
      case BUNDLE:
        return bundle;
      case LIST_OF_RESOURCES:
        return bundle.toListOfResources();
      case RESOURCE:
        List<IResource> list = bundle.toListOfResources();
        if (list.size() == 0) {
          return null;
        } else if (list.size() == 1) {
          return list.get(0);
        } else {
View Full Code Here

    public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException {
      if (!"feed".equals(theLocalPart)) {
        throw new DataFormatException("Expecting outer element called 'feed', found: " + theLocalPart);
      }

      myInstance = new Bundle();
      push(new AtomState(myInstance, myResourceType));

    }
View Full Code Here

  public Object invokeClient(String theResponseMimeType, Reader theResponseReader, int theResponseStatusCode, Map<String, List<String>> theHeaders) throws IOException {
    IParser parser = createAppropriateParserForParsingResponse(theResponseMimeType, theResponseReader, theResponseStatusCode);

    switch (getReturnType()) {
    case BUNDLE: {
      Bundle bundle;
      if (myResourceType != null) {
        bundle = parser.parseBundle(myResourceType, theResponseReader);
      } else {
        bundle = parser.parseBundle(theResponseReader);
      }
      switch (getMethodReturnType()) {
      case BUNDLE:
        return bundle;
      case LIST_OF_RESOURCES:
        List<IResource> listOfResources;
        if (myResourceListCollectionType != null) {
          listOfResources = new ArrayList<IResource>();
          for (IResource next : bundle.toListOfResources()) {
            if (!myResourceListCollectionType.isAssignableFrom(next.getClass())) {
              ourLog.debug("Not returning resource of type {} because it is not a subclass or instance of {}", next.getClass(), myResourceListCollectionType);
              continue;
            }
            listOfResources.add(next);
          }
        } else {
          listOfResources = bundle.toListOfResources();
        }
        return listOfResources;
      case RESOURCE:
        List<IResource> list = bundle.toListOfResources();
        if (list.size() == 0) {
          return null;
        } else if (list.size() == 1) {
          return list.get(0);
        } else {
View Full Code Here

    HttpServletResponse response = theRequest.getServletResponse();
    IBundleProvider result = invokeServer(theRequest, params);
    switch (getReturnType()) {
    case BUNDLE:

      Bundle bundle = RestfulServer.createBundleFromBundleProvider(theServer, response, result, responseEncoding, theRequest.getFhirServerBase(), theRequest.getCompleteUrl(), prettyPrint, requestIsBrowser, narrativeMode, 0, count, null);

      for (int i = theServer.getInterceptors().size() - 1; i >= 0; i--) {
        IServerInterceptor next = theServer.getInterceptors().get(i);
        boolean continueProcessing = next.outgoingResponse(theRequest, bundle, theRequest.getServletRequest(), theRequest.getServletResponse());
        if (!continueProcessing) {
View Full Code Here

    public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException {
      if (!"feed".equals(theLocalPart)) {
        throw new DataFormatException("Expecting outer element called 'feed', found: " + theLocalPart);
      }

      myInstance = new Bundle();
      push(new AtomState(myInstance, myResourceType));

    }
View Full Code Here

  }

  @Override
  public Object translateQueryParametersIntoServerArgument(Request theRequest, Object theRequestContents) throws InternalErrorException, InvalidRequestException {
    Bundle resource = (Bundle) theRequestContents;
    if (myParamIsBundle) {
      return resource;
    }

    ArrayList<IResource> retVal = new ArrayList<IResource>();
    for (BundleEntry next : resource.getEntries()) {
      if (next.getResource() != null) {
        retVal.add(next.getResource());
      }
    }
View Full Code Here

    parseBundleChildren(object, state);

    state.endingElement();

    Bundle retVal = state.getObject();

    return retVal;
  }
View Full Code Here

    boolean prettyPrint = prettyPrintResponse(theRequest);
    boolean requestIsBrowser = requestIsBrowser(theRequest.getServletRequest());
    NarrativeModeEnum narrativeMode = determineNarrativeMode(theRequest);
    boolean respondGzip = theRequest.isRespondGzip();

    Bundle bundle = createBundleFromBundleProvider(this, theResponse, resultList, responseEncoding, theRequest.getFhirServerBase(), theRequest.getCompleteUrl(), prettyPrint, requestIsBrowser, narrativeMode, start, count, thePagingAction);

    for (int i = getInterceptors().size() - 1; i >= 0; i--) {
      IServerInterceptor next = getInterceptors().get(i);
      boolean continueProcessing = next.outgoingResponse(theRequest, bundle, theRequest.getServletRequest(), theRequest.getServletResponse());
      if (!continueProcessing) {
View Full Code Here

          addProfileToBundleEntry(theServer.getFhirContext(), nextRes);
        }
      }
    }

    Bundle bundle = createBundleFromResourceList(theServer.getFhirContext(), theServer.getServerName(), resourceList, theServerBase, theCompleteUrl, theResult.size());

    bundle.setPublished(theResult.getPublished());

    if (theServer.getPagingProvider() != null) {
      int limit;
      limit = theLimit != null ? theLimit : theServer.getPagingProvider().getDefaultPageSize();
      limit = Math.min(limit, theServer.getPagingProvider().getMaximumPageSize());

      if (searchId != null) {
        if (theOffset + numToReturn < theResult.size()) {
          bundle.getLinkNext().setValue(createPagingLink(theServerBase, searchId, theOffset + numToReturn, numToReturn, theResponseEncoding, thePrettyPrint));
        }
        if (theOffset > 0) {
          int start = Math.max(0, theOffset - limit);
          bundle.getLinkPrevious().setValue(createPagingLink(theServerBase, searchId, start, limit, theResponseEncoding, thePrettyPrint));
        }
      }
    }
    return bundle;
  }
View Full Code Here

TOP

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

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.