Package ca.uhn.fhir.model.api

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


      for (IResource next : resources) {
        List<ResourceReferenceDt> refs = myContext.newTerser().getAllPopulatedChildElementsOfType(next, ResourceReferenceDt.class);
        for (ResourceReferenceDt nextRef : refs) {
          if (nextRef.isEmpty() == false && nextRef.getReference() != null) {
            IResource target = idToResource.get(nextRef.getReference().getValue());
            if (target != null) {
              nextRef.setResource(target);
            }
          }
        }
View Full Code Here


          if (theElement instanceof ResourceReferenceDt) {
            ResourceReferenceDt nextRef = (ResourceReferenceDt) theElement;
            String ref = nextRef.getReference().getValue();
            if (isNotBlank(ref)) {
              if (ref.startsWith("#")) {
                IResource target = myContainedResources.get(ref.substring(1));
                if (target != null) {
                  nextRef.setResource(target);
                } else {
                  ourLog.warn("Resource contains unknown local ref: " + ref);
                }
View Full Code Here

        if (!nextEntry.getLinkSearch().isEmpty()) {
          writeAtomLink(eventWriter, "search", nextEntry.getLinkSearch());
        }

        IResource resource = nextEntry.getResource();
        if (resource != null && !resource.isEmpty() && !deleted) {
          eventWriter.writeStartElement("content");
          eventWriter.writeAttribute("type", "text/xml");
          encodeResourceToXmlStreamWriter(resource, eventWriter, false);
          eventWriter.writeEndElement(); // content
        } else {
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

      pop();
    }

    @Override
    public void wereBack() {
      IResource res = getCurrentElement();
      assert res != null;
      if (res.getId() == null || res.getId().isEmpty()) {
        ourLog.debug("Discarding contained resource with no ID!");
      } else {
        getPreResourceState().getContainedResources().put(res.getId().getValueAsString(), res);
      }
      getPreResourceState().getCurrentElement().getContained().getContainedResources().add(res);
    }
View Full Code Here

      writeCategories(eventWriter, nextEntry.getCategories());

      writeAuthor(nextEntry, eventWriter);

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

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

      }
    }

    if (theServer.getAddProfileTag() != AddProfileTagEnum.NEVER) {
      for (int i = 0; i < resourceList.size(); i++) {
        IResource nextRes = resourceList.get(i);
        RuntimeResourceDefinition def = theServer.getFhirContext().getResourceDefinition(nextRes);
        if (theServer.getAddProfileTag() == AddProfileTagEnum.ALWAYS || !def.isStandardProfile()) {
          addProfileToBundleEntry(theServer.getFhirContext(), nextRes);
        }
      }
View Full Code Here

      List<ResourceReferenceDt> references = theContext.newTerser().getAllPopulatedChildElementsOfType(next, ResourceReferenceDt.class);
      do {
        List<IResource> addedResourcesThisPass = new ArrayList<IResource>();

        for (ResourceReferenceDt nextRef : references) {
          IResource nextRes = nextRef.getResource();
          if (nextRes != null) {
            if (nextRes.getId().hasIdPart()) {
              IdDt id = nextRes.getId().toVersionless();
              if (id.hasResourceType() == false) {
                String resName = theContext.getResourceDefinition(nextRes).getName();
                id = id.withResourceType(resName);
              }
View Full Code Here

     */
   
    List<IResource> retResources = retVal.getResources(0, retVal.size());
    for (int i = 0; i < retResources.size(); i++) {
      IdDt oldId = oldIds.get(retResources.get(i));
      IResource newRes = retResources.get(i);
      if (newRes.getId() == null || newRes.getId().isEmpty()) {
        if (!(newRes instanceof OperationOutcome)) {
          throw new InternalErrorException("Transaction method returned resource at index " + i + " with no id specified - IResource#setId(IdDt)");
        }
      }

      if (oldId != null && !oldId.isEmpty()) {
        if (!oldId.equals(newRes.getId())) {
          newRes.getResourceMetadata().put(ResourceMetadataKeyEnum.PREVIOUS_ID, oldId);
        }
      }
    }

    return retVal;
View Full Code Here

    return retVal;
  }

  @Override
  public IBundleProvider invokeServer(RequestDetails theRequest, Object[] theMethodParams) throws BaseServerResponseException {
    IResource conf = (IResource) invokeServerMethod(theMethodParams);
    return new SimpleBundleProvider(conf);
  }
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.