本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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();
}