当前位置: 首页>>代码示例>>Java>>正文


Java GetEntitySetUriInfo.getSkip方法代码示例

本文整理汇总了Java中org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo.getSkip方法的典型用法代码示例。如果您正苦于以下问题:Java GetEntitySetUriInfo.getSkip方法的具体用法?Java GetEntitySetUriInfo.getSkip怎么用?Java GetEntitySetUriInfo.getSkip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo的用法示例。


在下文中一共展示了GetEntitySetUriInfo.getSkip方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getInlineCountForNonFilterQueryEntitySet

import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo; //导入方法依赖的package包/类
private static Integer getInlineCountForNonFilterQueryEntitySet(final List<Map<String, Object>> edmEntityList,
    final GetEntitySetUriInfo resultsView) {
  // when $skip and/or $top is present with $inlinecount, first get the total count
  Integer count = null;
  if (resultsView.getInlineCount() == InlineCount.ALLPAGES) {
    if (resultsView.getSkip() != null || resultsView.getTop() != null) {
      count = edmEntityList.size();
      // Now update the list
      if (resultsView.getSkip() != null) {
        // Index checks to avoid IndexOutOfBoundsException
        if (resultsView.getSkip() > edmEntityList.size()) {
          edmEntityList.clear();
          return count;
        }
        edmEntityList.subList(0, resultsView.getSkip()).clear();
      }
      if (resultsView.getTop() != null && resultsView.getTop() >= 0 && resultsView.getTop() < edmEntityList.size()) {
        final List<Map<String, Object>> edmEntitySubList =
            new ArrayList<Map<String, Object>>(edmEntityList.subList(0, resultsView.getTop()));
        edmEntityList.retainAll(edmEntitySubList);
      }
    }
  }// Inlinecount of None is handled by default - null
  return count;
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:26,代码来源:ODataJPAResponseBuilderDefault.java

示例2: handlePaging

import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo; //导入方法依赖的package包/类
private List<Object> handlePaging(final List<Object> result, final GetEntitySetUriInfo uriParserResultView) {
  if (result == null) {
    return null;
  }
  JPAPageBuilder pageBuilder = new JPAPageBuilder();
  pageBuilder.pageSize(oDataJPAContext.getPageSize())
      .entities(result)
      .skipToken(uriParserResultView.getSkipToken());

  // $top/$skip with $inlinecount case handled in response builder to avoid multiple DB call
  if (uriParserResultView.getSkip() != null && uriParserResultView.getInlineCount() == null) {
    pageBuilder.skip(uriParserResultView.getSkip().intValue());
  }

  if (uriParserResultView.getTop() != null && uriParserResultView.getInlineCount() == null) {
    pageBuilder.top(uriParserResultView.getTop().intValue());
  }

  JPAPage page = pageBuilder.build();
  oDataJPAContext.setPaging(page);

  return page.getPagedEntities();
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:24,代码来源:JPAProcessorImpl.java

示例3: getSkip

import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo; //导入方法依赖的package包/类
protected int getSkip(GetEntitySetUriInfo uriInfo) {
  if (uriInfo.getSkip() != null) {
    return uriInfo.getSkip();
  } else {
    return 0;
  }
}
 
开发者ID:SAP,项目名称:SAPJamWorkPatternJIRAIntegration,代码行数:8,代码来源:BaseProcessor.java

示例4: readEntitySet

import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo; //导入方法依赖的package包/类
@Override
public ODataResponse readEntitySet(final GetEntitySetUriInfo uriInfo, final String contentType)
    throws ODataException {
  ArrayList<Object> data = new ArrayList<Object>();
  try {
    data.addAll((List<?>) retrieveData(
        uriInfo.getStartEntitySet(),
        uriInfo.getKeyPredicates(),
        uriInfo.getFunctionImport(),
        mapFunctionParameters(uriInfo.getFunctionImportParameters()),
        uriInfo.getNavigationSegments()));
  } catch (final ODataNotFoundException e) {
    data.clear();
  }

  final EdmEntitySet entitySet = uriInfo.getTargetEntitySet();
  final InlineCount inlineCountType = uriInfo.getInlineCount();
  final Integer count = applySystemQueryOptions(
      entitySet,
      data,
      uriInfo.getFilter(),
      inlineCountType,
      uriInfo.getOrderBy(),
      uriInfo.getSkipToken(),
      uriInfo.getSkip(),
      uriInfo.getTop());

  ODataContext context = getContext();
  String nextLink = null;

  // Limit the number of returned entities and provide a "next" link
  // if there are further entities.
  // Almost all system query options in the current request must be carried
  // over to the URI for the "next" link, with the exception of $skiptoken
  // and $skip.
  if (data.size() > SERVER_PAGING_SIZE) {
    if (uriInfo.getOrderBy() == null
        && uriInfo.getSkipToken() == null
        && uriInfo.getSkip() == null
        && uriInfo.getTop() == null) {
      sortInDefaultOrder(entitySet, data);
    }

    nextLink = context.getPathInfo().getServiceRoot().relativize(context.getPathInfo().getRequestUri()).toString();
    nextLink = percentEncodeNextLink(nextLink);
    nextLink += (nextLink.contains("?") ? "&" : "?")
        + "$skiptoken=" + getSkipToken(entitySet, data.get(SERVER_PAGING_SIZE));

    while (data.size() > SERVER_PAGING_SIZE) {
      data.remove(SERVER_PAGING_SIZE);
    }
  }

  final EdmEntityType entityType = entitySet.getEntityType();
  List<Map<String, Object>> values = new ArrayList<Map<String, Object>>();
  for (final Object entryData : data) {
    values.add(getStructuralTypeValueMap(entryData, entityType));
  }

  final EntityProviderWriteProperties feedProperties = EntityProviderWriteProperties
      .serviceRoot(context.getPathInfo().getServiceRoot())
      .inlineCountType(inlineCountType)
      .inlineCount(count)
      .expandSelectTree(UriParser.createExpandSelectTree(uriInfo.getSelect(), uriInfo.getExpand()))
      .callbacks(getCallbacks(data, entityType))
      .nextLink(nextLink)
      .build();

  final int timingHandle = context.startRuntimeMeasurement("EntityProvider", "writeFeed");
  final ODataResponse response = EntityProvider.writeFeed(contentType, entitySet, values, feedProperties);

  context.stopRuntimeMeasurement(timingHandle);

  return ODataResponse.fromResponse(response).build();
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:76,代码来源:ListsProcessor.java

示例5: getEntityProviderProperties

import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo; //导入方法依赖的package包/类
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) {
    if ((resultsView.getSkip() != null || resultsView.getTop() != null)) {
      // when $skip and/or $top is present with $inlinecount
      count = getInlineCountForNonFilterQueryEntitySet(edmEntityList, resultsView);
    } else {
      // In all other cases
      count = resultsView.getInlineCount() == InlineCount.ALLPAGES ? edmEntityList.size() : null;
    }
  }

  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();
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:59,代码来源:ODataJPAResponseBuilderDefault.java

示例6: readEntitySet

import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo; //导入方法依赖的package包/类
@Override
public ODataResponse readEntitySet(final GetEntitySetUriInfo uriInfo, final String contentType)
    throws ODataException {
  ArrayList<Object> data = new ArrayList<Object>();
  try {
    data.addAll((List<?>) retrieveData(
        uriInfo.getStartEntitySet(),
        uriInfo.getKeyPredicates(),
        uriInfo.getFunctionImport(),
        mapFunctionParameters(uriInfo.getFunctionImportParameters()),
        uriInfo.getNavigationSegments()));
  } catch (final ODataNotFoundException e) {
    data.clear();
  }

  final EdmEntitySet entitySet = uriInfo.getTargetEntitySet();
  final InlineCount inlineCountType = uriInfo.getInlineCount();
  final Integer count = applySystemQueryOptions(
      entitySet,
      data,
      uriInfo.getFilter(),
      inlineCountType,
      uriInfo.getOrderBy(),
      uriInfo.getSkipToken(),
      uriInfo.getSkip(),
      uriInfo.getTop());

  ODataContext context = getContext();
  String nextLink = null;

  // Limit the number of returned entities and provide a "next" link
  // if there are further entities.
  // Almost all system query options in the current request must be carried
  // over to the URI for the "next" link, with the exception of $skiptoken
  // and $skip.
  if (data.size() > SERVER_PAGING_SIZE) {
    if (uriInfo.getOrderBy() == null
        && uriInfo.getSkipToken() == null
        && uriInfo.getSkip() == null
        && uriInfo.getTop() == null) {
      sortInDefaultOrder(entitySet, data);
    }

    nextLink = context.getPathInfo().getServiceRoot().relativize(context.getPathInfo().getRequestUri()).toString();
    nextLink = percentEncodeNextLink(nextLink);

    nextLink += (nextLink.contains("?") ? "&" : "?")
        + "$skiptoken=" + getSkipToken(entitySet, data.get(SERVER_PAGING_SIZE));

    while (data.size() > SERVER_PAGING_SIZE) {
      data.remove(SERVER_PAGING_SIZE);
    }
  }

  final EdmEntityType entityType = entitySet.getEntityType();
  List<Map<String, Object>> values = new ArrayList<Map<String, Object>>();
  for (final Object entryData : data) {
    values.add(getStructuralTypeValueMap(entryData, entityType));
  }

  final EntityProviderWriteProperties feedProperties = EntityProviderWriteProperties
      .serviceRoot(context.getPathInfo().getServiceRoot())
      .inlineCountType(inlineCountType)
      .inlineCount(count)
      .expandSelectTree(UriParser.createExpandSelectTree(uriInfo.getSelect(), uriInfo.getExpand()))
      .callbacks(getCallbacks(data, entityType))
      .nextLink(nextLink)
      .build();

  final int timingHandle = context.startRuntimeMeasurement("EntityProvider", "writeFeed");
  final ODataResponse response = EntityProvider.writeFeed(contentType, entitySet, values, feedProperties);

  context.stopRuntimeMeasurement(timingHandle);

  return ODataResponse.fromResponse(response).build();
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:77,代码来源:ListsProcessor.java


注:本文中的org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo.getSkip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。