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


Java GetEntitySetUriInfo.getTargetEntitySet方法代码示例

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


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

示例1: readEntitySet

import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo; //导入方法依赖的package包/类
@Override
public ODataResponse readEntitySet(final GetEntitySetUriInfo uriInfo, final String contentType) 
    throws ODataException {

  EdmEntitySet entitySet;

  if (uriInfo.getNavigationSegments().size() == 0) {
    entitySet = uriInfo.getStartEntitySet();

    if (ENTITY_SET_NAME_CARS.equals(entitySet.getName())) {
      return EntityProvider.writeFeed(contentType, entitySet, dataStore.getCars(),
          EntityProviderWriteProperties.serviceRoot(getContext().getPathInfo().getServiceRoot()).build());
    } else if (ENTITY_SET_NAME_MANUFACTURERS.equals(entitySet.getName())) {
      return EntityProvider.writeFeed(contentType, entitySet, dataStore.getManufacturers(),
          EntityProviderWriteProperties.serviceRoot(getContext().getPathInfo().getServiceRoot()).build());
    }

    throw new ODataNotFoundException(ODataNotFoundException.ENTITY);

  } else if (uriInfo.getNavigationSegments().size() == 1) {
    // navigation first level, simplified example for illustration purposes only
    entitySet = uriInfo.getTargetEntitySet();

    if (ENTITY_SET_NAME_CARS.equals(entitySet.getName())) {
      int manufacturerKey = getKeyValue(uriInfo.getKeyPredicates().get(0));

      List<Map<String, Object>> cars = new ArrayList<Map<String, Object>>();
      cars.addAll(dataStore.getCarsFor(manufacturerKey));

      return EntityProvider.writeFeed(contentType, entitySet, cars, EntityProviderWriteProperties.serviceRoot(
          getContext().getPathInfo().getServiceRoot()).build());
    }

    throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
  }

  throw new ODataNotImplementedException();
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:39,代码来源:CarODataSingleProcessor.java

示例2: readEntitySet

import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo; //导入方法依赖的package包/类
@Override
public ODataResponse readEntitySet(GetEntitySetUriInfo uriInfo, String contentType) throws ODataException {

    EdmEntitySet entitySet;

    if (uriInfo.getNavigationSegments().size() == 0) {
        entitySet = uriInfo.getStartEntitySet();

        if (ENTITY_SET_NAME_CARS.equals(entitySet.getName())) {
            return EntityProvider.writeFeed(contentType, entitySet, dataStore.getCars(), EntityProviderWriteProperties.serviceRoot(getContext().getPathInfo().getServiceRoot()).build());
        } else if (ENTITY_SET_NAME_MANUFACTURERS.equals(entitySet.getName())) {
            return EntityProvider.writeFeed(contentType, entitySet, dataStore.getManufacturers(), EntityProviderWriteProperties.serviceRoot(getContext().getPathInfo().getServiceRoot()).build());
        }

        throw new ODataNotFoundException(ODataNotFoundException.ENTITY);

    } else if (uriInfo.getNavigationSegments().size() == 1) {
        //navigation first level, simplified example for illustration purposes only
        entitySet = uriInfo.getTargetEntitySet();

        if (ENTITY_SET_NAME_CARS.equals(entitySet.getName())) {
            int manufacturerKey = getKeyValue(uriInfo.getKeyPredicates().get(0));

            List<Map<String, Object>> cars = new ArrayList<>();
            cars.addAll(dataStore.getCarsFor(manufacturerKey));

            return EntityProvider.writeFeed(contentType, entitySet, cars, EntityProviderWriteProperties.serviceRoot(getContext().getPathInfo().getServiceRoot()).build());
        }

        throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
    }

    throw new ODataNotImplementedException();
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:35,代码来源:MyODataSingleProcessor.java

示例3: 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

示例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,代码行数:77,代码来源:ListsProcessor.java


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