Java Code Examples for org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties.ODataEntityProviderPropertiesBuilder#build()

The following examples show how to use org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties.ODataEntityProviderPropertiesBuilder#build() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ODataJPAResponseBuilderDefault.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
private static EntityProviderWriteProperties getEntityProviderProperties(final ODataJPAContext odataJPAContext,
    final GetEntityUriInfo resultsView) throws ODataJPARuntimeException {
  ODataEntityProviderPropertiesBuilder entityFeedPropertiesBuilder = null;
  ExpandSelectTreeNode expandSelectTree = null;
  try {
    entityFeedPropertiesBuilder =
        EntityProviderWriteProperties.serviceRoot(odataJPAContext.getODataContext().getPathInfo().getServiceRoot());
    expandSelectTree = UriParser.createExpandSelectTree(resultsView.getSelect(), resultsView.getExpand());
    entityFeedPropertiesBuilder.expandSelectTree(expandSelectTree);
    entityFeedPropertiesBuilder.callbacks(JPAExpandCallBack.getCallbacks(odataJPAContext.getODataContext()
        .getPathInfo().getServiceRoot(), expandSelectTree, resultsView.getExpand()));
  } catch (ODataException e) {
    throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
  }

  return entityFeedPropertiesBuilder.build();
}
 
Example 2
Source File: ODataJPAResponseBuilderDefault.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private static EntityProviderWriteProperties getEntityProviderPropertiesforPost(
    final ODataJPAContext odataJPAContext) throws ODataJPARuntimeException {
  ODataEntityProviderPropertiesBuilder entityFeedPropertiesBuilder = null;
  try {
    entityFeedPropertiesBuilder =
        EntityProviderWriteProperties.serviceRoot(odataJPAContext.getODataContext().getPathInfo().getServiceRoot());
  } catch (ODataException e) {
    throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
  }

  return entityFeedPropertiesBuilder.build();
}
 
Example 3
Source File: JPAExpandCallBack.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private EntityProviderWriteProperties getInlineEntityProviderProperties(final WriteCallbackContext context)
    throws EdmException {
  ODataEntityProviderPropertiesBuilder propertiesBuilder = EntityProviderWriteProperties.serviceRoot(baseUri);
  propertiesBuilder.callbacks(getCallbacks(baseUri, context.getCurrentExpandSelectTreeNode(), expandList));
  propertiesBuilder.expandSelectTree(context.getCurrentExpandSelectTreeNode());
  return propertiesBuilder.build();
}
 
Example 4
Source File: ODataJPAResponseBuilderDefault.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
private static EntityProviderWriteProperties getEntityProviderProperties(final ODataJPAContext odataJPAContext,
    final GetEntitySetUriInfo resultsView, final List<Map<String, Object>> edmEntityList)
    throws ODataJPARuntimeException {
  ODataEntityProviderPropertiesBuilder entityFeedPropertiesBuilder = null;
  ODataContext context = odataJPAContext.getODataContext();

  Integer count = null;
  if (resultsView.getInlineCount() != null) {
     count = getInlineCountForNonFilterQueryEntitySet(edmEntityList, resultsView);
  }

  try {
    PathInfo pathInfo = context.getPathInfo();
    URI serviceRoot = pathInfo.getServiceRoot();

    entityFeedPropertiesBuilder =
        EntityProviderWriteProperties.serviceRoot(pathInfo.getServiceRoot());
    JPAPaging paging = odataJPAContext.getPaging();
    if (odataJPAContext.getPageSize() > 0 && paging != null && paging.getNextPage() > 0) {
      String nextLink =
          serviceRoot.relativize(pathInfo.getRequestUri()).toString();
      nextLink = percentEncodeNextLink(nextLink);
      nextLink += (nextLink != null ? nextLink.contains("?") ? "&" : "?" : "?")
          + "$skiptoken=" + odataJPAContext.getPaging().getNextPage();
      entityFeedPropertiesBuilder.nextLink(nextLink);
    }
    entityFeedPropertiesBuilder.inlineCount(count);
    entityFeedPropertiesBuilder.inlineCountType(resultsView.getInlineCount());
    ExpandSelectTreeNode expandSelectTree =
        UriParser.createExpandSelectTree(resultsView.getSelect(), resultsView.getExpand());

    Map<String, ODataCallback> expandCallBack =
        JPAExpandCallBack.getCallbacks(serviceRoot, expandSelectTree, resultsView.getExpand());

    Map<String, ODataCallback> callBackMap = new HashMap<String, ODataCallback>();
    callBackMap.putAll(expandCallBack);

    String deltaToken = ODataJPATombstoneContext.getDeltaToken();
    if (deltaToken != null) {
      callBackMap.put(TombstoneCallback.CALLBACK_KEY_TOMBSTONE, new JPATombstoneCallBack(serviceRoot.toString(),
          resultsView, deltaToken));
    }

    entityFeedPropertiesBuilder.callbacks(callBackMap);
    entityFeedPropertiesBuilder.expandSelectTree(expandSelectTree);

  } catch (ODataException e) {
    throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
  }

  return entityFeedPropertiesBuilder.build();
}