Java Code Examples for org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo#getStartEntitySet()
The following examples show how to use
org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo#getStartEntitySet() .
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: CarODataSingleProcessor.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@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(); }
Example 2
Source File: MyODataSingleProcessor.java From wildfly-camel with Apache License 2.0 | 5 votes |
@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(); }