Package ca.uhn.fhir.model.api

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


    bundle.getPublished().setToCurrentTimeInLocalTimeZone();
    bundle.getLinkBase().setValue(theServerBase);
    bundle.getLinkSelf().setValue(theCompleteUrl);

    for (IResource next : theResult) {
      BundleEntry entry = new BundleEntry();
      bundle.getEntries().add(entry);

      entry.setResource(next);

      RuntimeResourceDefinition def = getContext().getResourceDefinition(next);

      if (next.getId() != null && StringUtils.isNotBlank(next.getId().getValue())) {
        entry.getId().setValue(next.getId().getValue());
        entry.getTitle().setValue(def.getName() + " " + next.getId().getValue());

        StringBuilder b = new StringBuilder();
        b.append(theServerBase);
        b.append('/');
        b.append(def.getName());
        b.append('/');
        String resId = next.getId().getValue();
        b.append(resId);

        /*
         * If this is a history operation, we add the version of the
         * resource to the self link to indicate the version
         */
        if (getResourceOperationType() == RestfulOperationTypeEnum.HISTORY_INSTANCE || getResourceOperationType() == RestfulOperationTypeEnum.HISTORY_TYPE || getSystemOperationType() == RestfulOperationSystemEnum.HISTORY_SYSTEM) {
          IdDt versionId = getIdFromMetadataOrNullIfNone(next.getResourceMetadata(), ResourceMetadataKeyEnum.VERSION_ID);
          if (versionId != null) {
            b.append('/');
            b.append(Constants.PARAM_HISTORY);
            b.append('/');
            b.append(versionId.getValue());
          } else {
            throw new InternalErrorException("Server did not provide a VERSION_ID in the resource metadata for resource with ID " + resId);
          }
        }

        InstantDt published = getInstantFromMetadataOrNullIfNone(next.getResourceMetadata(), ResourceMetadataKeyEnum.PUBLISHED);
        if (published == null) {
          entry.getPublished().setToCurrentTimeInLocalTimeZone();
        } else {
          entry.setPublished(published);
        }

        InstantDt updated = getInstantFromMetadataOrNullIfNone(next.getResourceMetadata(), ResourceMetadataKeyEnum.UPDATED);
        if (updated != null) {
          entry.setUpdated(updated);
        }

        boolean haveQ = false;
        if (thePrettyPrint) {
          b.append('?').append(Constants.PARAM_PRETTY).append("=true");
          haveQ = true;
        }
        if (theResponseEncoding == EncodingUtil.JSON) {
          if (!haveQ) {
            b.append('?');
            haveQ = true;
          } else {
            b.append('&');
          }
          b.append(Constants.PARAM_FORMAT).append("=json");
        }
        if (theNarrativeMode != NarrativeModeEnum.NORMAL) {
          b.append(Constants.PARAM_NARRATIVE).append("=").append(theNarrativeMode.name().toLowerCase());
        }
        entry.getLinkSelf().setValue(b.toString());
      }
    }

    bundle.getTotalResults().setValue(theResult.size());

View Full Code Here


    private BundleEntry myEntry;
    private Class<? extends IResource> myResourceType;

    public AtomEntryState(Bundle theInstance, Class<? extends IResource> theResourceType) {
      super(null);
      myEntry = new BundleEntry();
      myResourceType = theResourceType;
      theInstance.getEntries().add(myEntry);
    }
View Full Code Here

    private BundleEntry myEntry;
    private Class<? extends IResource> myResourceType;

    public AtomEntryState(Bundle theInstance, Class<? extends IResource> theResourceType) {
      super(null);
      myEntry = new BundleEntry();
      myResourceType = theResourceType;
      theInstance.getEntries().add(myEntry);
    }
View Full Code Here

    bundle.getPublished().setToCurrentTimeInLocalTimeZone();
    bundle.getLinkBase().setValue(theServerBase);
    bundle.getLinkSelf().setValue(theCompleteUrl);

    for (IResource next : theResult) {
      BundleEntry entry = new BundleEntry();
      bundle.getEntries().add(entry);

      entry.setResource(next);
      TagList list = (TagList) next.getResourceMetadata().get(ResourceMetadataKeyEnum.TAG_LIST);
      if (list != null) {
        for (Tag tag : list) {
          if (StringUtils.isNotBlank(tag.getTerm())) {
            entry.addCategory().setTerm(tag.getTerm()).setLabel(tag.getLabel()).setScheme(tag.getScheme());
          }
        }
      }

      RuntimeResourceDefinition def = getContext().getResourceDefinition(next);

      if (next.getId() != null && StringUtils.isNotBlank(next.getId().getValue())) {
        entry.getId().setValue(next.getId().getValue());
        entry.getTitle().setValue(def.getName() + " " + next.getId().getValue());

        StringBuilder b = new StringBuilder();
        b.append(theServerBase);
        b.append('/');
        b.append(def.getName());
        b.append('/');
        String resId = next.getId().getValue();
        b.append(resId);

        /*
         * If this is a history operation, we add the version of the
         * resource to the self link to indicate the version
         */
        if (getResourceOperationType() == RestfulOperationTypeEnum.HISTORY_INSTANCE || getResourceOperationType() == RestfulOperationTypeEnum.HISTORY_TYPE || getSystemOperationType() == RestfulOperationSystemEnum.HISTORY_SYSTEM) {
          IdDt versionId = getIdFromMetadataOrNullIfNone(next.getResourceMetadata(), ResourceMetadataKeyEnum.VERSION_ID);
          if (versionId != null) {
            b.append('/');
            b.append(Constants.PARAM_HISTORY);
            b.append('/');
            b.append(versionId.getValue());
          } else {
            throw new InternalErrorException("Server did not provide a VERSION_ID in the resource metadata for resource with ID " + resId);
          }
        }

        InstantDt published = getInstantFromMetadataOrNullIfNone(next.getResourceMetadata(), ResourceMetadataKeyEnum.PUBLISHED);
        if (published == null) {
          entry.getPublished().setToCurrentTimeInLocalTimeZone();
        } else {
          entry.setPublished(published);
        }

        InstantDt updated = getInstantFromMetadataOrNullIfNone(next.getResourceMetadata(), ResourceMetadataKeyEnum.UPDATED);
        if (updated != null) {
          entry.setUpdated(updated);
        }

        TagList tagList = getTagListFromMetadataOrNullIfNone(next.getResourceMetadata(), ResourceMetadataKeyEnum.TAG_LIST);
        if (tagList != null) {
          for (Tag nextTag : tagList) {
            entry.addCategory(nextTag);
          }
        }

        boolean haveQ = false;
        if (thePrettyPrint) {
          b.append('?').append(Constants.PARAM_PRETTY).append("=true");
          haveQ = true;
        }
        if (theResponseEncoding == EncodingEnum.JSON) {
          if (!haveQ) {
            b.append('?');
            haveQ = true;
          } else {
            b.append('&');
          }
          b.append(Constants.PARAM_FORMAT).append("=json");
        }
        if (theNarrativeMode != NarrativeModeEnum.NORMAL) {
          b.append(Constants.PARAM_NARRATIVE).append("=").append(theNarrativeMode.name().toLowerCase());
        }
        entry.getLinkSelf().setValue(b.toString());
      }
    }

    bundle.getTotalResults().setValue(theResult.size());

View Full Code Here

    private BundleEntry myEntry;
    private Class<? extends IResource> myResourceType;

    public AtomEntryState(Bundle theInstance, Class<? extends IResource> theResourceType) {
      super(null);
      myEntry = new BundleEntry();
      myResourceType = theResourceType;
      theInstance.getEntries().add(myEntry);
    }
View Full Code Here

    bundle.getPublished().setToCurrentTimeInLocalTimeZone();
    bundle.getLinkBase().setValue(theServerBase);
    bundle.getLinkSelf().setValue(theCompleteUrl);

    for (IResource next : theResult) {
      BundleEntry entry = new BundleEntry();
      bundle.getEntries().add(entry);

      entry.setResource(next);

      RuntimeResourceDefinition def = getContext().getResourceDefinition(next);

      if (next.getId() != null && StringUtils.isNotBlank(next.getId().getValue())) {
        entry.getId().setValue(next.getId().getValue());
        entry.getTitle().setValue(def.getName() + " " + next.getId().getValue());

        StringBuilder b = new StringBuilder();
        b.append(theServerBase);
        b.append('/');
        b.append(def.getName());
        b.append('/');
        String resId = next.getId().getValue();
        b.append(resId);

        /*
         * If this is a history operation, we add the version of the
         * resource to the self link to indicate the version
         */
        if (getResourceOperationType() == RestfulOperationTypeEnum.HISTORY_INSTANCE || getResourceOperationType() == RestfulOperationTypeEnum.HISTORY_TYPE || getSystemOperationType() == RestfulOperationSystemEnum.HISTORY_SYSTEM) {
          IdDt versionId = getIdFromMetadataOrNullIfNone(next.getResourceMetadata(), ResourceMetadataKeyEnum.VERSION_ID);
          if (versionId != null) {
            b.append('/');
            b.append(Constants.PARAM_HISTORY);
            b.append('/');
            b.append(versionId.getValue());
          } else {
            throw new InternalErrorException("Server did not provide a VERSION_ID in the resource metadata for resource with ID " + resId);
          }
        }

        InstantDt published = getInstantFromMetadataOrNullIfNone(next.getResourceMetadata(), ResourceMetadataKeyEnum.PUBLISHED);
        if (published == null) {
          entry.getPublished().setToCurrentTimeInLocalTimeZone();
        } else {
          entry.setPublished(published);
        }

        InstantDt updated = getInstantFromMetadataOrNullIfNone(next.getResourceMetadata(), ResourceMetadataKeyEnum.UPDATED);
        if (updated != null) {
          entry.setUpdated(updated);
        }

        boolean haveQ = false;
        if (thePrettyPrint) {
          b.append('?').append(Constants.PARAM_PRETTY).append("=true");
          haveQ = true;
        }
        if (theResponseEncoding == EncodingUtil.JSON) {
          if (!haveQ) {
            b.append('?');
            haveQ = true;
          } else {
            b.append('&');
          }
          b.append(Constants.PARAM_FORMAT).append("=json");
        }
        if (theNarrativeMode != NarrativeModeEnum.NORMAL) {
          b.append(Constants.PARAM_NARRATIVE).append("=").append(theNarrativeMode.name().toLowerCase());
        }
        entry.getLinkSelf().setValue(b.toString());
      }
    }

    bundle.getTotalResults().setValue(theResult.size());

View Full Code Here

    private BundleEntry myEntry;

    public AtomEntryState(Bundle theInstance) {
      super(null);
      myEntry = new BundleEntry();
      theInstance.getEntries().add(myEntry);
    }
View Full Code Here

    private BundleEntry myEntry;
    private Class<? extends IResource> myResourceType;

    public AtomEntryState(Bundle theInstance, Class<? extends IResource> theResourceType) {
      super(null);
      myEntry = new BundleEntry();
      myResourceType = theResourceType;
      theInstance.getEntries().add(myEntry);
    }
View Full Code Here

TOP

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

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.