コード例 #1
0
  @Override
  public ODataEntitySet getODataEntitySet(final Feed resource, final URI defaultBaseURI) {
    if (LOG.isDebugEnabled()) {
      final StringWriter writer = new StringWriter();
      client.getSerializer().feed(resource, writer);
      writer.flush();
      LOG.debug("Feed -> ODataEntitySet:\n{}", writer.toString());
    }

    final URI base = defaultBaseURI == null ? resource.getBaseURI() : defaultBaseURI;

    final URI next = resource.getNext();

    final ODataEntitySet entitySet =
        next == null
            ? client.getObjectFactory().newEntitySet()
            : client.getObjectFactory().newEntitySet(URIUtils.getURI(base, next.toASCIIString()));

    if (resource.getCount() != null) {
      entitySet.setCount(resource.getCount());
    }

    for (Entry entryResource : resource.getEntries()) {
      entitySet.addEntity(getODataEntity(entryResource));
    }

    return entitySet;
  }
コード例 #2
0
  @Override
  public Feed getFeed(final ODataEntitySet feed, final Class<? extends Feed> reference) {
    final Feed feedResource = ResourceFactory.newFeed(reference);

    feedResource.setCount(feed.getCount());

    final URI next = feed.getNext();
    if (next != null) {
      feedResource.setNext(next);
    }

    for (ODataEntity entity : feed.getEntities()) {
      feedResource.getEntries().add(getEntry(entity, ResourceFactory.entryClassForFeed(reference)));
    }

    return feedResource;
  }