Author: mibo
Date: Wed Dec 9 09:34:38 2015
New Revision: 1718786
URL: http://svn.apache.org/viewvc?rev=1718786&view=rev
Log:
Added new links between tutorials
Modified:
olingo/site/trunk/content/doc/odata2/sample-setup.mdtext
olingo/site/trunk/content/doc/odata4/tutorials/action/tutorial_action.mdtext
olingo/site/trunk/content/doc/odata4/tutorials/media/tutorial_media.mdtext
olingo/site/trunk/content/doc/odata4/tutorials/navigation/tutorial_navigation.mdtext
olingo/site/trunk/content/doc/odata4/tutorials/read/tutorial_read.mdtext
olingo/site/trunk/content/doc/odata4/tutorials/readep/tutorial_readep.mdtext
olingo/site/trunk/content/doc/odata4/tutorials/sqo_es/tutorial_sqo_es.mdtext
olingo/site/trunk/content/doc/odata4/tutorials/sqo_f/tutorial_sqo_f.mdtext
olingo/site/trunk/content/doc/odata4/tutorials/sqo_o/tutorial_sqo_o.mdtext
olingo/site/trunk/content/doc/odata4/tutorials/sqo_tcs/tutorial_sqo_tcs.mdtext
olingo/site/trunk/content/doc/odata4/tutorials/write/tutorial_write.mdtext
Modified: olingo/site/trunk/content/doc/odata2/sample-setup.mdtext
URL:
http://svn.apache.org/viewvc/olingo/site/trunk/content/doc/odata2/sample-setup.mdtext?rev=1718786&r1=1718785&r2=1718786&view=diff
==============================================================================
--- olingo/site/trunk/content/doc/odata2/sample-setup.mdtext (original)
+++ olingo/site/trunk/content/doc/odata2/sample-setup.mdtext Wed Dec 9
09:34:38 2015
@@ -18,16 +18,16 @@ Notice: Licensed to the Apache Softwa
# Sample Project Setup
-Olingo has prepared a very simple sample car service that can work as a
starting point for implementing a custom OData service.
+Olingo has prepared a very simple sample car service that can work as a
starting point for implementing a custom OData service.
This service consists of a very simple EDM with two entity sets that are cars
and manufactures and a memory based data provider that is a simple hash map.
-Therefore the project implements a very basic single OData processor
supporting a minimal readonly scenario.
+Therefore the project implements a very basic single OData processor
supporting a minimal readonly scenario.
If build with Maven the build result is a web application (`war` file) which
can be deployed to any JEE compliant web application server (e.g.
[Tomcat](http://tomcat.apache.org)).
---
### Maven Archetype
-Apache Olingo supports Maven archetypes that are a kind of project template
for setting up new projects from scratch.
+Apache Olingo supports Maven archetypes that are a kind of project template
for setting up new projects from scratch.
Currently exists an archetype with an `ODataSingleProcessor` implementation as
`olingo-odata2-sample-cars-service-archetype` and an archetype with an
annotation based `ODataService` implementation as
`olingo-odata2-sample-cars-annotation-archetype`.
To generate the sample project for the `ODataSingleProcessor` implementation
start with:
@@ -54,7 +54,7 @@ To generate the sample project for the `
If an archetype is not available via Maven standard configuration then an
additional parameter
`-DarchetypeRepository=http://repository.apache.org/snapshots` can solve the
issue.
-Based on the Olingo project template Maven will generate a new project with
the specified GAV*) coordinates: `com.sample:my-car-service:1.0.0-SNAPSHOT`.
+Based on the Olingo project template Maven will generate a new project with
the specified GAV*) coordinates: `com.sample:my-car-service:1.0.0-SNAPSHOT`.
GAV coordinates can be freely chosen during generation with the interactive
mode. To enable the interactive mode `-DinteractiveMode` must be set to true or
omitted (to use Maven default setting of `true`).
The result is a new and ready to build Maven project. Switch to
*my-car-service* directory and execute:
@@ -80,22 +80,22 @@ If a Apache Olingo dependency is not ava
â¦
-Maven will build the project with the result **car-service.war** in the Maven
*target* directory which can be deployed to any JEE compliant web application
server.
+Maven will build the project with the result **car-service.war** in the Maven
*target* directory which can be deployed to any JEE compliant web application
server.
To call the deployed and running OData service enter this URI in a browser:
http://localhost:8080/my-car-service/
-Which show a entry page for the generated sample service with links to the
*Metadata* (`$metadata`), *Service Document* and some *sample data* which it
provides.
+Which show a entry page for the generated sample service with links to the
*Metadata* (`$metadata`), *Service Document* and some *sample data* which it
provides.
*) GAV means a Maven groupId, artifactId and version.
### Eclipse IDE Support
-The archetype template supports Eclipse as IDE.
+The archetype template supports Eclipse as IDE.
Additionally to a Maven clean and install it is possible to call the following
Maven goal:
mvn eclipse:clean eclipse:eclipse
-This will generate Eclipse project files including all transitive dependencies
and the web application facet.
-Import the project to Eclipse and it should be recognized as a web application
project.
-Deploy the Eclipse project to a server and it should run as well.
\ No newline at end of file
+This will generate Eclipse project files including all transitive dependencies
and the web application facet.
+Import the project to Eclipse and it should be recognized as a web application
project.
+Deploy the Eclipse project to a server and it should run as well.
Modified:
olingo/site/trunk/content/doc/odata4/tutorials/action/tutorial_action.mdtext
URL:
http://svn.apache.org/viewvc/olingo/site/trunk/content/doc/odata4/tutorials/action/tutorial_action.mdtext?rev=1718786&r1=1718785&r2=1718786&view=diff
==============================================================================
---
olingo/site/trunk/content/doc/odata4/tutorials/action/tutorial_action.mdtext
(original)
+++
olingo/site/trunk/content/doc/odata4/tutorials/action/tutorial_action.mdtext
Wed Dec 9 09:34:38 2015
@@ -588,7 +588,7 @@ To verify that the service has been rese
Further topics to be covered by follow-up tutorials:
* Tutorial OData V4 service part 1: [Read Entity
Collection](/doc/odata4/tutorials/read/tutorial_read.html)
- * Tutorial OData V4 service part 2: [Read Entity, Read
Property](/doc/odata4/tutorials/readep/tutorial_readep.html)
+ * Tutorial OData V4 service part 2: [Read Entity, Read
Property](/doc/odata4/tutorials/readep/tutorial_readep.html)
* Tutorial OData V4 service part 3: [Write (Create, Update, Delete
Entity)](/doc/odata4/tutorials/write/tutorial_write.html)
* Tutorial OData V4 service, part 4:
[Navigation](/doc/odata4/tutorials/navigation/tutorial_navigation.html)
* Tutorial OData V4 service, part 5.1: [System Query Options $top, $skip,
$count (this page)](/doc/odata4/tutorials/sqo_tcs/tutorial_sqo_tcs.html)
@@ -597,7 +597,9 @@ Further topics to be covered by follow-u
* Tutorial OData V4 service, part 5.4: [System Query Options
$filter](/doc/odata4/tutorials/sqo_f/tutorial_sqo_f.html)
* Tutorial ODATA V4 service, part 6: Action and Function Imports
* Tutorial ODATA V4 service, part 7: [Media
Entities](/doc/odata4/tutorials/media/tutorial_media.html)
-
+ * Tutorial OData V4 service, part 8: [Batch Request
support](/doc/odata4/tutorials/batch/tutorial_batch.html)
+ * Tutorial OData V4 service, part 9: [Handling "Deep Insert"
requests](/doc/odata4/tutorials/deep_insert/tutorial_deep_insert.html)
+
### Code and Repository
* [Git Repository](https://git-wip-us.apache.org/repos/asf/olingo-odata4)
* [Guide - To fetch the tutorial
sources](/doc/odata4/tutorials/prerequisites/prerequisites.html)
@@ -607,4 +609,4 @@ Further topics to be covered by follow-u
* [Official OData Homepage](http://odata.org/)
* [OData documentation](http://www.odata.org/documentation/)
- * [Olingo Javadoc](/javadoc/odata4/index.html)
\ No newline at end of file
+ * [Olingo Javadoc](/javadoc/odata4/index.html)
Modified:
olingo/site/trunk/content/doc/odata4/tutorials/media/tutorial_media.mdtext
URL:
http://svn.apache.org/viewvc/olingo/site/trunk/content/doc/odata4/tutorials/media/tutorial_media.mdtext?rev=1718786&r1=1718785&r2=1718786&view=diff
==============================================================================
--- olingo/site/trunk/content/doc/odata4/tutorials/media/tutorial_media.mdtext
(original)
+++ olingo/site/trunk/content/doc/odata4/tutorials/media/tutorial_media.mdtext
Wed Dec 9 09:34:38 2015
@@ -16,7 +16,7 @@ Notice: Licensed to the Apache Softwa
specific language governing permissions and limitations
under the License.
-# How to build an OData Service with Olingo V4
+# How to build an OData Service with Olingo V4
# Part 7: Media Entities
## Introduction
@@ -26,7 +26,7 @@ In the present tutorial, we will impleme
**Note:**
The final source code can be found in the project [git
repository](https://git-wip-us.apache.org/repos/asf/olingo-odata4).
-A detailed description how to checkout the tutorials can be found
[here](/doc/odata4/tutorials/prerequisites/prerequisites.html).
+A detailed description how to checkout the tutorials can be found
[here](/doc/odata4/tutorials/prerequisites/prerequisites.html).
This tutorial can be found in subdirectory /samples/tutorials/p10_media
@@ -55,7 +55,7 @@ In this tutorial we will implement a med
<Property Name="Name" Type="Edm.String"/>
<Property Name="AirDate" Type="Edm.DateTimeOffset"/>
</EntityType>
-
+
<EntityContainer Name="Container">
<EntitySet Name="Advertisements"
EntityType="OData.Demo.Advertisement"/>
</EntityContainer>
@@ -77,7 +77,7 @@ We start with method `DemoEdmProvider.ge
::::java
public CsdlEntityType getEntityType(FullQualifiedName entityTypeName) {
CsdlEntityType entityType = null;
-
+
if (entityTypeName.equals(ET_PRODUCT_FQN)) {
// Definition of entity type Product
// ...
@@ -91,17 +91,17 @@ We start with method `DemoEdmProvider.ge
.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
CsdlProperty airDate = new CsdlProperty().setName("AirDate")
.setType(EdmPrimitiveTypeKind.DateTimeOffset.getFullQualifiedName());
-
+
CsdlPropertyRef propertyRef = new CsdlPropertyRef();
propertyRef.setName("ID");
-
+
entityType = new CsdlEntityType();
entityType.setName(ET_ADVERTISEMENT_NAME);
entityType.setProperties(Arrays.asList(id, name, airDate));
entityType.setKey(Collections.singletonList(propertyRef));
entityType.setHasStream(true); // <- Enable the media entity
stream
}
-
+
return entityType;
}
@@ -111,7 +111,7 @@ Further we have to create a new entity
@Override
public CsdlEntitySet getEntitySet(FullQualifiedName entityContainer,
String entitySetName) {
CsdlEntitySet entitySet = null;
-
+
if (entityContainer.equals(CONTAINER)) {
if (entitySetName.equals(ES_PRODUCTS_NAME)) {
// Definition of entity set Products
@@ -123,7 +123,7 @@ Further we have to create a new entity
entitySet.setType(ET_ADVERTISEMENT_FQN);
}
}
-
+
return entitySet;
}
@@ -131,14 +131,14 @@ And finally announce the entity type and
::::java
@Override
- public List<CsdlSchema> getSchemas() {
+ public List<CsdlSchema> getSchemas() {
// ...
entityTypes.add(getEntityType(ET_ADVERTISEMENT_FQN));
// ...
-
+
return schemas;
}
-
+
public CsdlEntityContainer getEntityContainer() {
// ...
entitySets.add(getEntitySet(CONTAINER, ES_ADVERTISEMENTS_NAME));
@@ -154,7 +154,7 @@ To read the content to a media entity, w
::::java
private static final String MEDIA_PROPERTY_NAME = "$value";
private List<Entity> advertisements;
-
+
public byte[] readMedia(final Entity entity) {
return (byte[]) entity.getProperty(MEDIA_PROPERTY_NAME).asPrimitive();
}
@@ -173,19 +173,19 @@ If a client creates a new media entity,
::::java
public Entity createMediaEntity(final EdmEntityType edmEntityType, final
String mediaContentType, final byte[] data) {
Entity entity = null;
-
+
if(edmEntityType.getName().equals(DemoEdmProvider.ET_ADVERTISEMENT_NAME)) {
entity = new Entity();
entity.addProperty(new Property(null, "ID", ValueType.PRIMITIVE,
UUID.randomUUID()));
entity.addProperty(new Property(null, "Name", ValueType.PRIMITIVE,
null));
entity.addProperty(new Property(null, "AirDate",
ValueType.PRIMITIVE, null));
-
+
entity.setMediaContentType(mediaContentType);
entity.addProperty(new Property(null, MEDIA_PROPERTY_NAME,
ValueType.PRIMITIVE, data));
-
+
advertisements.add(entity);
}
-
+
return entity;
}
@@ -200,9 +200,9 @@ Add an initial set of data to our data s
entity.addProperty(new Property(null, MEDIA_PROPERTY_NAME,
ValueType.PRIMITIVE, "Super content".getBytes()));
entity.setMediaContentType(ContentType.parse("text/plain").toContentTypeString());
advertisements.add(entity);
-
+
entity = new Entity();
- entity.addProperty(new Property(null, "ID", ValueType.PRIMITIVE,
+ entity.addProperty(new Property(null, "ID", ValueType.PRIMITIVE,
UUID.fromString("db2d2186-1c29-4d1e-88ef-a127f521b9c67")));
entity.addProperty(new Property(null, "Name", ValueType.PRIMITIVE,
"Early morning start, need coffee"));
entity.addProperty(new Property(null, "AirDate", ValueType.PRIMITIVE,
Timestamp.valueOf("2000-02-29 00:00:00")));
@@ -225,44 +225,44 @@ Enable the regular entity set for CRUD o
::::java
public EntityCollection readEntitySetData(EdmEntitySet edmEntitySet)
throws ODataApplicationException {
-
+
if (edmEntitySet.getName().equals(DemoEdmProvider.ES_PRODUCTS_NAME)) {
// ...
} else
if(edmEntitySet.getName().equals(DemoEdmProvider.ES_ADVERTISEMENTS_NAME)) {
return getEntityCollection(advertisements);
}
-
+
return null;
}
-
+
public Entity readEntityData(EdmEntitySet edmEntitySet, List<UriParameter>
keyParams)
throws ODataApplicationException {
-
+
EdmEntityType edmEntityType = edmEntitySet.getEntityType();
if (edmEntitySet.getName().equals(DemoEdmProvider.ES_PRODUCTS_NAME)) {
// ...
} else
if(edmEntitySet.getName().equals(DemoEdmProvider.ES_ADVERTISEMENTS_NAME)) {
return getEntity(edmEntityType, keyParams, advertisements);
}
-
+
return null;
}
-
+
public Entity createEntityData(EdmEntitySet edmEntitySet, Entity
entityToCreate) {
-
+
EdmEntityType edmEntityType = edmEntitySet.getEntityType();
if (edmEntitySet.getName().equals(DemoEdmProvider.ES_PRODUCTS_NAME)) {
// ....
} else
if(edmEntitySet.getName().equals(DemoEdmProvider.ES_CATEGORIES_NAME)) {
return createEntity(edmEntityType, entityToCreate, categoryList);
- }
-
+ }
+
return null;
}
-
- public void updateEntityData(EdmEntitySet edmEntitySet, List<UriParameter>
keyParams,
+
+ public void updateEntityData(EdmEntitySet edmEntitySet, List<UriParameter>
keyParams,
Entity updateEntity, HttpMethod httpMethod) throws
ODataApplicationException {
-
+
EdmEntityType edmEntityType = edmEntitySet.getEntityType();
if (edmEntitySet.getName().equals(DemoEdmProvider.ES_PRODUCTS_NAME)) {
// ...
@@ -270,10 +270,10 @@ Enable the regular entity set for CRUD o
updateEntity(edmEntityType, keyParams, updateEntity, httpMethod,
advertisements);
}
}
-
+
public void deleteEntityData(EdmEntitySet edmEntitySet, List<UriParameter>
keyParams)
throws ODataApplicationException {
-
+
EdmEntityType edmEntityType = edmEntitySet.getEntityType();
if (edmEntitySet.getName().equals(DemoEdmProvider.ES_PRODUCTS_NAME)) {
// ...
@@ -292,17 +292,17 @@ The easiest part is to delete an media e
@Override
public void deleteMediaEntity(ODataRequest request, ODataResponse
response, UriInfo uriInfo)
throws ODataApplicationException, ODataLibraryException {
-
+
/*
* In this tutorial, the content of the media entity is stored in a
special property.
* So no additional steps to delete the content of the media entity
are necessary.
- *
+ *
* A real service may store the content on the file system. So we have
to take care to
- * delete external files too.
- *
+ * delete external files too.
+ *
* DELETE request to /Advertisements(ID) will be dispatched to the
deleteEntity(...) method
* DELETE request to /Advertisements(ID)/$value will be dispatched to
the deleteMediaEntity(...) method
- *
+ *
* So it is a good idea handle deletes in a central place.
*/
@@ -316,7 +316,7 @@ Next the creation of media entites is im
public void createMediaEntity(ODataRequest request, ODataResponse
response, UriInfo uriInfo,
ContentType requestFormat, ContentType responseFormat)
throws ODataApplicationException, ODataLibraryException {
-
+
final EdmEntitySet edmEntitySet = Util.getEdmEntitySet(uriInfo);
final byte[] mediaContent =
odata.createFixedFormatDeserializer().binary(request.getBody());
///...
@@ -326,15 +326,15 @@ After that we call the data store to cre
:::java
final Entity entity =
storage.createMediaEntity(edmEntitySet.getEntityType(),
requestFormat.toContentTypeString(),mediaContent);
-
+
final ContextURL contextUrl =
ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build();
final EntitySerializerOptions opts =
EntitySerializerOptions.with().contextURL(contextUrl).build();
final SerializerResult serializerResult =
odata.createSerializer(responseFormat)
.entity(serviceMetadata,
edmEntitySet.getEntityType(), entity, opts);
-
- final String location = request.getRawBaseUri() + '/'
+
+ final String location = request.getRawBaseUri() + '/'
+ odata.createUriHelper().buildCanonicalURL(edmEntitySet,
entity);
-
+
response.setContent(serializerResult.getContent());
response.setStatusCode(HttpStatusCode.CREATED.getStatusCode());
response.setHeader(HttpHeader.LOCATION, location);
@@ -347,23 +347,23 @@ To keep things simple, our scenario do n
@Override
public void readMediaEntity(ODataRequest request, ODataResponse response,
UriInfo uriInfo, ContentType responseFormat)
throws ODataApplicationException, ODataLibraryException {
-
+
// Since our scenario do not contain navigations from media entities.
We can keep things simple and
// check only the first resource path of the URI.
final UriResource firstResoucePart =
uriInfo.getUriResourceParts().get(0);
if(firstResoucePart instanceof UriResourceEntitySet) {
final EdmEntitySet edmEntitySet = Util.getEdmEntitySet(uriInfo);
final UriResourceEntitySet uriResourceEntitySet =
(UriResourceEntitySet) firstResoucePart;
-
+
final Entity entity = storage.readEntityData(edmEntitySet,
uriResourceEntitySet.getKeyPredicates());
if(entity == null) {
throw new ODataApplicationException("Entity not found",
HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
}
-
+
final byte[] mediaContent = storage.readMedia(entity);
final InputStream responseContent =
odata.createFixedFormatSerializer().binary(mediaContent);
-
+
response.setStatusCode(HttpStatusCode.OK.getStatusCode());
response.setContent(responseContent);
response.setHeader(HttpHeader.CONTENT_TYPE,
entity.getMediaContentType());
@@ -374,27 +374,27 @@ To keep things simple, our scenario do n
}
Updating a media entity in our scenario is quite similar to read an entity.
The first step is to analyse the URI, than fetch the entity from data store.
Afer that we call the `updateMediaEntity` method. In our case we do not return
any content. If we would return content, we must return the recently uploaded
content of the media entity ([OData Version 4.0 Part 1:
Protocol](http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part1-protocol/odata-v4.0-errata02-os-part1-protocol-complete.html#_Toc406398338)).
-
+
:::java
@Override
public void updateMediaEntity(ODataRequest request, ODataResponse
response, UriInfo uriInfo,
- ContentType requestFormat, ContentType responseFormat)
+ ContentType requestFormat, ContentType responseFormat)
throws ODataApplicationException, ODataLibraryException {
-
+
final UriResource firstResoucePart =
uriInfo.getUriResourceParts().get(0);
if (firstResoucePart instanceof UriResourceEntitySet) {
final EdmEntitySet edmEntitySet = Util.getEdmEntitySet(uriInfo);
final UriResourceEntitySet uriResourceEntitySet =
(UriResourceEntitySet) firstResoucePart;
-
+
final Entity entity = storage.readEntityData(edmEntitySet,
uriResourceEntitySet.getKeyPredicates());
if (entity == null) {
throw new ODataApplicationException("Entity not found",
HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
}
-
+
final byte[] mediaContent =
odata.createFixedFormatDeserializer().binary(request.getBody());
storage.updateMedia(entity, requestFormat.toContentTypeString(),
mediaContent);
-
+
response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
} else {
throw new ODataApplicationException("Not implemented",
@@ -406,18 +406,18 @@ Updating a media entity in our scenario
After building and deploying the project, we can invoke our OData service.
- * Read media entity set
+ * Read media entity set
**GET**
[http://localhost:8080/DemoService-Media/DemoService.svc/Advertisements](http://localhost:8080/DemoService-Media/DemoService.svc/Advertisments)
- * Read media entity
+ * Read media entity
**GET**
[http://localhost:8080/DemoService-Media/DemoService.svc/Advertisements(f89dee73-af9f-4cd4-b330-db93c25ff3c7)](http://localhost:8080/DemoService-Media/DemoService.svc/Advertisments(f89dee73-af9f-4cd4-b330-db93c25ff3c7))
- * Read media entity content
+ * Read media entity content
**GET**
[http://localhost:8080/DemoService-Media/DemoService.svc/Advertisements(f89dee73-af9f-4cd4-b330-db93c25ff3c7)/$value](http://localhost:8080/DemoService-Media/DemoService.svc/Advertisments(f89dee73-af9f-
4cd4-b330-db93c25ff3c7)/$value)
- * Create a new Media Entity
- **POST**
[http://localhost:8080/DemoService-Media/DemoService.svc/Advertisements
-
+ * Create a new Media Entity
+ **POST**
[http://localhost:8080/DemoService-Media/DemoService.svc/Advertisements
+
Content-Type: image/svg+xml
@@ -431,17 +431,17 @@ Content-Type: image/svg+xml
</svg>
- * Update the content of a media entity
- **PUT**
[http://localhost:8080/DemoService-Media/DemoService.svc/Advertisements(f89dee73-af9f-4cd4-b330-db93c25ff3c7)/$value](http://localhost:8080/DemoService-Media/DemoService.svc/Advertisments(f89dee73-af9f-4cd4-b330-db93c25ff3c7)/$value)
-
+ * Update the content of a media entity
+ **PUT**
[http://localhost:8080/DemoService-Media/DemoService.svc/Advertisements(f89dee73-af9f-4cd4-b330-db93c25ff3c7)/$value](http://localhost:8080/DemoService-Media/DemoService.svc/Advertisments(f89dee73-af9f-4cd4-b330-db93c25ff3c7)/$value)
+
Content-Type: text/plain
::::text
Super super nice content
- * Update the properties of a media entity
-**PUT**
[http://localhost:8080/DemoService-Media/DemoService.svc/Advertisements(f89dee73-af9f-4cd4-b330-db93c25ff3c7)](http://localhost:8080/DemoService-Media/DemoService.svc/Advertisments(f89dee73-af9f-4cd4-b330-db93c25ff3c7))
+ * Update the properties of a media entity
+**PUT**
[http://localhost:8080/DemoService-Media/DemoService.svc/Advertisements(f89dee73-af9f-4cd4-b330-db93c25ff3c7)](http://localhost:8080/DemoService-Media/DemoService.svc/Advertisments(f89dee73-af9f-4cd4-b330-db93c25ff3c7))
Content-Type: application/json
@@ -454,10 +454,10 @@ Content-Type: application/json
- * Delete a media entity
+ * Delete a media entity
**DELETE**
[http://localhost:8080/DemoService-Media/DemoService.svc/Advertisements(f89dee73-af9f-4cd4-b330-db93c25ff3c7)](http://localhost:8080/DemoService-Media/DemoService.svc/Advertisments(f89dee73-af9f-4cd4-b330-db93c25ff3c7))
- * Delete a media entity
+ * Delete a media entity
**DELETE**
[http://localhost:8080/DemoService-Media/DemoService.svc/Advertisements(db2d2186-1c29-4d1e-88ef-127f521b9c67)/$value](http://localhost:8080/DemoService-Media/DemoService.svc/Advertisments(db2d2186-1c29-4d1e-88ef-127f521b9c67)/$value)
# Links
@@ -467,7 +467,7 @@ Content-Type: application/json
Further topics to be covered by follow-up tutorials:
* Tutorial OData V4 service part 1: [Read Entity
Collection](/doc/odata4/tutorials/read/tutorial_read.html)
- * Tutorial OData V4 service part 2: [Read Entity, Read
Property](/doc/odata4/tutorials/readep/tutorial_readep.html)
+ * Tutorial OData V4 service part 2: [Read Entity, Read
Property](/doc/odata4/tutorials/readep/tutorial_readep.html)
* Tutorial OData V4 service part 3: [Write (Create, Update, Delete
Entity)](/doc/odata4/tutorials/write/tutorial_write.html)
* Tutorial OData V4 service, part 4:
[Navigation](/doc/odata4/tutorials/navigation/tutorial_navigation.html)
* Tutorial OData V4 service, part 5.1: [System Query Options $top, $skip,
$count (this page)](/doc/odata4/tutorials/sqo_tcs/tutorial_sqo_tcs.html)
@@ -476,7 +476,9 @@ Further topics to be covered by follow-u
* Tutorial OData V4 service, part 5.4: [System Query Options
$filter](/doc/odata4/tutorials/sqo_f/tutorial_sqo_f.html)
* Tutorial OData V4 service, part 6: [Action and Function
Imports](/doc/odata4/tutorials/action/tutorial_action.html)
* Tutorial OData V4 service, part 7: Media Entities
-
+ * Tutorial OData V4 service, part 8: [Batch Request
support](/doc/odata4/tutorials/batch/tutorial_batch.html)
+ * Tutorial OData V4 service, part 9: [Handling "Deep Insert"
requests](/doc/odata4/tutorials/deep_insert/tutorial_deep_insert.html)
+
### Code and Repository
* [Git Repository](https://git-wip-us.apache.org/repos/asf/olingo-odata4)
* [Guide - To fetch the tutorial
sources](/doc/odata4/tutorials/prerequisites/prerequisites.html)
@@ -486,4 +488,4 @@ Further topics to be covered by follow-u
* [Official OData Homepage](http://odata.org/)
* [OData documentation](http://www.odata.org/documentation/)
- * [Olingo Javadoc](/javadoc/odata4/index.html)
\ No newline at end of file
+ * [Olingo Javadoc](/javadoc/odata4/index.html)
Modified:
olingo/site/trunk/content/doc/odata4/tutorials/navigation/tutorial_navigation.mdtext
URL:
http://svn.apache.org/viewvc/olingo/site/trunk/content/doc/odata4/tutorials/navigation/tutorial_navigation.mdtext?rev=1718786&r1=1718785&r2=1718786&view=diff
==============================================================================
---
olingo/site/trunk/content/doc/odata4/tutorials/navigation/tutorial_navigation.mdtext
(original)
+++
olingo/site/trunk/content/doc/odata4/tutorials/navigation/tutorial_navigation.mdtext
Wed Dec 9 09:34:38 2015
@@ -574,10 +574,10 @@ The following snippet shows the implemen
final String id = request.getRawBaseUri() + "/" +
responseEdmEntitySet.getName();
EntityCollectionSerializerOptions opts =
EntityCollectionSerializerOptions.with().contextURL(contextUrl).id(id).build();
EdmEntityType edmEntityType = responseEdmEntitySet.getEntityType();
-
+
ODataSerializer serializer = odata.createSerializer(responseFormat);
SerializerResult serializerResult =
serializer.entityCollection(this.srvMetadata, edmEntityType,
responseEntityCollection, opts);
-
+
// 4th: configure the response object: set the body, headers and
status code
response.setContent(serializerResult.getContent());
response.setStatusCode(HttpStatusCode.OK.getStatusCode());
@@ -876,13 +876,15 @@ Check the *Links* section for more OData
* Tutorial OData V4 service, part 5.4: [System Query Options
$filter](/doc/odata4/tutorials/sqo_f/tutorial_sqo_f.html)
* Tutorial ODATA V4 service, part 6: [Action and Function
Imports](/doc/odata4/tutorials/action/tutorial_action.html)
* Tutorial ODATA V4 service, part 7: [Media
Entities](/doc/odata4/tutorials/media/tutorial_media.html)
+ * Tutorial OData V4 service, part 8: [Batch Request
support](/doc/odata4/tutorials/batch/tutorial_batch.html)
+ * Tutorial OData V4 service, part 9: [Handling "Deep Insert"
requests](/doc/odata4/tutorials/deep_insert/tutorial_deep_insert.html)
### Code and Repository
* [Git Repository](https://git-wip-us.apache.org/repos/asf/olingo-odata4)
* [Guide - To fetch the tutorial
sources](/doc/odata4/tutorials/prerequisites/prerequisites.html)
* [Demo Service source code as zip file (contains all
tutorials)](http://www.apache.org/dyn/closer.lua/olingo/odata4/4.0.0/DemoService_Tutorial.zip)
-
+
### Further reading
* [Official OData Homepage](http://odata.org/)
@@ -941,4 +943,4 @@ When reaching the point where your OData
}
return (UriResourceNavigation) resourcePaths.get(--navigationCount);
- }
\ No newline at end of file
+ }
Modified:
olingo/site/trunk/content/doc/odata4/tutorials/read/tutorial_read.mdtext
URL:
http://svn.apache.org/viewvc/olingo/site/trunk/content/doc/odata4/tutorials/read/tutorial_read.mdtext?rev=1718786&r1=1718785&r2=1718786&view=diff
==============================================================================
--- olingo/site/trunk/content/doc/odata4/tutorials/read/tutorial_read.mdtext
(original)
+++ olingo/site/trunk/content/doc/odata4/tutorials/read/tutorial_read.mdtext
Wed Dec 9 09:34:38 2015
@@ -770,13 +770,13 @@ We have not elaborated on fetching the a
In our tutorial, to keep the code as simple as possible, we use a little
helper method that delivers some hardcoded entries.
Since we are supposed to deliver the data inside an `EntityCollection`
instance, we create the instance, ask it for the (initially empty) list of
entities and add some new entities to it.
We create the entities and their properties according to what we declared in
our `DemoEdmProvider` class. So we have to take care to provide the correct
names to the new property objects.
-If a client requests the response in [ATOM
format](http://docs.oasis-open.org/odata/odata-atom-format/v4.0/odata-atom-format-v4.0.html),
each entity have to provide it`s own entity id.
+If a client requests the response in [ATOM
format](http://docs.oasis-open.org/odata/odata-atom-format/v4.0/odata-atom-format-v4.0.html),
each entity have to provide it`s own entity id.
The method *createId* allows us to create an id in a convenient way.
- :::java
+ :::java
private EntityCollection getData(EdmEntitySet edmEntitySet){
-
+
EntityCollection productsCollection = new EntityCollection();
// check for which EdmEntitySet the data is requested
if(DemoEdmProvider.ES_PRODUCTS_NAME.equals(edmEntitySet.getName())) {
@@ -812,7 +812,7 @@ The method *createId* allows us to creat
}
**_createId()_**
-
+
:::java
private URI createId(String entitySetName, Object id) {
try {
@@ -1036,7 +1036,7 @@ A detailed description how to checkout t
Further topics to be covered by follow-up tutorials:
* Tutorial OData V4 service part 1: Read Entity Collection
- * Tutorial OData V4 service part 2: [Read Entity, Read
Property](/doc/odata4/tutorials/readep/tutorial_readep.html)
+ * Tutorial OData V4 service part 2: [Read Entity, Read
Property](/doc/odata4/tutorials/readep/tutorial_readep.html)
* Tutorial OData V4 service part 3: [Write (Create, Update, Delete
Entity)](/doc/odata4/tutorials/write/tutorial_write.html)
* Tutorial OData V4 service, part 4:
[Navigation](/doc/odata4/tutorials/navigation/tutorial_navigation.html)
* Tutorial OData V4 service, part 5.1: [System Query Options $top, $skip,
$count (this page)](/doc/odata4/tutorials/sqo_tcs/tutorial_sqo_tcs.html)
@@ -1045,7 +1045,9 @@ Further topics to be covered by follow-u
* Tutorial OData V4 service, part 5.4: [System Query Options
$filter](/doc/odata4/tutorials/sqo_f/tutorial_sqo_f.html)
* Tutorial ODATA V4 service, part 6: [Action and Function
Imports](/doc/odata4/tutorials/action/tutorial_action.html)
* Tutorial ODATA V4 service, part 7: [Media
Entities](/doc/odata4/tutorials/media/tutorial_media.html)
-
+ * Tutorial OData V4 service, part 8: [Batch Request
support](/doc/odata4/tutorials/batch/tutorial_batch.html)
+ * Tutorial OData V4 service, part 9: [Handling "Deep Insert"
requests](/doc/odata4/tutorials/deep_insert/tutorial_deep_insert.html)
+
### Code and Repository
* [Git Repository](https://git-wip-us.apache.org/repos/asf/olingo-odata4)
* [Guide - To fetch the tutorial
sources](/doc/odata4/tutorials/prerequisites/prerequisites.html)
@@ -1055,4 +1057,4 @@ Further topics to be covered by follow-u
* [Official OData Homepage](http://odata.org/)
* [OData documentation](http://www.odata.org/documentation/)
- * [Olingo Javadoc](/javadoc/odata4/index.html)
\ No newline at end of file
+ * [Olingo Javadoc](/javadoc/odata4/index.html)
Modified:
olingo/site/trunk/content/doc/odata4/tutorials/readep/tutorial_readep.mdtext
URL:
http://svn.apache.org/viewvc/olingo/site/trunk/content/doc/odata4/tutorials/readep/tutorial_readep.mdtext?rev=1718786&r1=1718785&r2=1718786&view=diff
==============================================================================
---
olingo/site/trunk/content/doc/odata4/tutorials/readep/tutorial_readep.mdtext
(original)
+++
olingo/site/trunk/content/doc/odata4/tutorials/readep/tutorial_readep.mdtext
Wed Dec 9 09:34:38 2015
@@ -683,15 +683,15 @@ We have to create a Constructor that tak
:::java
public class DemoPrimitiveProcessor implements PrimitiveProcessor {
-
+
private OData odata;
private Storage storage;
private ServiceMetadata serviceMetadata;
-
+
public DemoPrimitiveProcessor(Storage storage) {
this.storage = storage;
}
-
+
public void init(OData odata, ServiceMetadata serviceMetadata) {
this.odata = odata;
this.serviceMetadata = serviceMetadata;
@@ -828,16 +828,18 @@ In the next tutorial ([Part 3: Write](/d
### Tutorials
* Tutorial OData V4 service part 1: [Read Entity
Collection](/doc/odata4/tutorials/read/tutorial_read.html)
- * Tutorial OData V4 service part 2: Read Entity, Read Property
+ * Tutorial OData V4 service part 2: Read Entity, Read Property
* Tutorial OData V4 service part 3: [Write (Create, Update, Delete
Entity)](/doc/odata4/tutorials/write/tutorial_write.html)
* Tutorial OData V4 service, part 4:
[Navigation](/doc/odata4/tutorials/navigation/tutorial_navigation.html)
- * Tutorial OData V4 service, part 5.1: [System Query Options $top, $skip,
$count (this page)](/doc/odata4/tutorials/sqo_tcs/tutorial_sqo_tcs.html)
+ * Tutorial OData V4 service, part 5.1: [System Query Options $top, $skip,
$count (this page)](/doc/odata4/tutorials/sqo_tcs/tutorial_sqo_tcs.html)
* Tutorial OData V4 service, part 5.2: [System Query Options $select,
$expand](/doc/odata4/tutorials/sqo_es/tutorial_sqo_es.html)
* Tutorial OData V4 service, part 5.3: [System Query Options
$orderby](/doc/odata4/tutorials/sqo_o/tutorial_sqo_o.html)
* Tutorial OData V4 service, part 5.4: [System Query Options
$filter](/doc/odata4/tutorials/sqo_f/tutorial_sqo_f.html)
* Tutorial ODATA V4 service, part 6: [Action and Function
Imports](/doc/odata4/tutorials/action/tutorial_action.html)
* Tutorial ODATA V4 service, part 7: [Media
Entities](/doc/odata4/tutorials/media/tutorial_media.html)
-
+ * Tutorial OData V4 service, part 8: [Batch Request
support](/doc/odata4/tutorials/batch/tutorial_batch.html)
+ * Tutorial OData V4 service, part 9: [Handling "Deep Insert"
requests](/doc/odata4/tutorials/deep_insert/tutorial_deep_insert.html)
+
### Code and Repository
* [Git Repository](https://git-wip-us.apache.org/repos/asf/olingo-odata4)
* [Guide - To fetch the tutorial
sources](/doc/odata4/tutorials/prerequisites/prerequisites.html)
@@ -848,4 +850,4 @@ In the next tutorial ([Part 3: Write](/d
* [Official OData Homepage](http://odata.org/)
* [OData documentation](http://www.odata.org/documentation/)
- * [Olingo Javadoc](/javadoc/odata4/index.html)
\ No newline at end of file
+ * [Olingo Javadoc](/javadoc/odata4/index.html)
Modified:
olingo/site/trunk/content/doc/odata4/tutorials/sqo_es/tutorial_sqo_es.mdtext
URL:
http://svn.apache.org/viewvc/olingo/site/trunk/content/doc/odata4/tutorials/sqo_es/tutorial_sqo_es.mdtext?rev=1718786&r1=1718785&r2=1718786&view=diff
==============================================================================
---
olingo/site/trunk/content/doc/odata4/tutorials/sqo_es/tutorial_sqo_es.mdtext
(original)
+++
olingo/site/trunk/content/doc/odata4/tutorials/sqo_es/tutorial_sqo_es.mdtext
Wed Dec 9 09:34:38 2015
@@ -397,7 +397,7 @@ Also, the `expandOption` has to be consi
.contextURL(contextUrl)
.select(selectOption)
.expand(expandOption)
- .id(id)
+ .id(id)
.build();
@@ -501,7 +501,9 @@ In this tutorial we have learned the bas
* Tutorial OData V4 service, part 5.4: [System Query Options
$filter](/doc/odata4/tutorials/sqo_f/tutorial_sqo_f.html)
* Tutorial ODATA V4 service, part 6: [Action and Function
Imports](/doc/odata4/tutorials/action/tutorial_action.html)
* Tutorial ODATA V4 service, part 7: [Media
Entities](/doc/odata4/tutorials/media/tutorial_media.html)
-
+ * Tutorial OData V4 service, part 8: [Batch Request
support](/doc/odata4/tutorials/batch/tutorial_batch.html)
+ * Tutorial OData V4 service, part 9: [Handling "Deep Insert"
requests](/doc/odata4/tutorials/deep_insert/tutorial_deep_insert.html)
+
### Code and Repository
* [Git Repository](https://git-wip-us.apache.org/repos/asf/olingo-odata4)
* [Guide - To fetch the tutorial
sources](/doc/odata4/tutorials/prerequisites/prerequisites.html)
@@ -582,7 +584,7 @@ In this tutorial we have learned the bas
link.setTitle(navPropName);
link.setType(Constants.ENTITY_NAVIGATION_LINK_TYPE);
link.setRel(Constants.NS_ASSOCIATION_LINK_REL + navPropName);
-
+
if(edmNavigationProperty.isCollection()){ // in case of
Categories(1)/$expand=Products
// fetch the data for the $expand (to-many navigation) from backend
// here we get the data for the expand
@@ -627,4 +629,4 @@ In this tutorial we have learned the bas
response.setContent(serializerResult.getContent());
response.setStatusCode(HttpStatusCode.OK.getStatusCode());
response.setHeader(HttpHeader.CONTENT_TYPE,
responseFormat.toContentTypeString());
- }
\ No newline at end of file
+ }
Modified:
olingo/site/trunk/content/doc/odata4/tutorials/sqo_f/tutorial_sqo_f.mdtext
URL:
http://svn.apache.org/viewvc/olingo/site/trunk/content/doc/odata4/tutorials/sqo_f/tutorial_sqo_f.mdtext?rev=1718786&r1=1718785&r2=1718786&view=diff
==============================================================================
--- olingo/site/trunk/content/doc/odata4/tutorials/sqo_f/tutorial_sqo_f.mdtext
(original)
+++ olingo/site/trunk/content/doc/odata4/tutorials/sqo_f/tutorial_sqo_f.mdtext
Wed Dec 9 09:34:38 2015
@@ -556,7 +556,9 @@ In this tutorial we have learned how to
* Tutorial OData V4 service, part 5.4: System Query Options $filter (this
page)
* Tutorial ODATA V4 service, part 6: [Action and Function
Imports](/doc/odata4/tutorials/action/tutorial_action.html)
* Tutorial ODATA V4 service, part 7: [Media
Entities](/doc/odata4/tutorials/media/tutorial_media.html)
-
+ * Tutorial OData V4 service, part 8: [Batch Request
support](/doc/odata4/tutorials/batch/tutorial_batch.html)
+ * Tutorial OData V4 service, part 9: [Handling "Deep Insert"
requests](/doc/odata4/tutorials/deep_insert/tutorial_deep_insert.html)
+
### Code and Repository
* [Git Repository](https://git-wip-us.apache.org/repos/asf/olingo-odata4)
* [Guide - To fetch the tutorial
sources](/doc/odata4/tutorials/prerequisites/prerequisites.html)
Modified:
olingo/site/trunk/content/doc/odata4/tutorials/sqo_o/tutorial_sqo_o.mdtext
URL:
http://svn.apache.org/viewvc/olingo/site/trunk/content/doc/odata4/tutorials/sqo_o/tutorial_sqo_o.mdtext?rev=1718786&r1=1718785&r2=1718786&view=diff
==============================================================================
--- olingo/site/trunk/content/doc/odata4/tutorials/sqo_o/tutorial_sqo_o.mdtext
(original)
+++ olingo/site/trunk/content/doc/odata4/tutorials/sqo_o/tutorial_sqo_o.mdtext
Wed Dec 9 09:34:38 2015
@@ -316,7 +316,9 @@ We have decided to not go for the advanc
* Tutorial OData V4 service, part 5.4: [System Query Options
$filter](/doc/odata4/tutorials/sqo_f/tutorial_sqo_f.html)
* Tutorial ODATA V4 service, part 6: [Action and Function
Imports](/doc/odata4/tutorials/action/tutorial_action.html)
* Tutorial ODATA V4 service, part 7: [Media
Entities](/doc/odata4/tutorials/media/tutorial_media.html)
-
+ * Tutorial OData V4 service, part 8: [Batch Request
support](/doc/odata4/tutorials/batch/tutorial_batch.html)
+ * Tutorial OData V4 service, part 9: [Handling "Deep Insert"
requests](/doc/odata4/tutorials/deep_insert/tutorial_deep_insert.html)
+
### Code and Repository
* [Git Repository](https://git-wip-us.apache.org/repos/asf/olingo-odata4)
* [Guide - To fetch the tutorial
sources](/doc/odata4/tutorials/prerequisites/prerequisites.html)
Modified:
olingo/site/trunk/content/doc/odata4/tutorials/sqo_tcs/tutorial_sqo_tcs.mdtext
URL:
http://svn.apache.org/viewvc/olingo/site/trunk/content/doc/odata4/tutorials/sqo_tcs/tutorial_sqo_tcs.mdtext?rev=1718786&r1=1718785&r2=1718786&view=diff
==============================================================================
---
olingo/site/trunk/content/doc/odata4/tutorials/sqo_tcs/tutorial_sqo_tcs.mdtext
(original)
+++
olingo/site/trunk/content/doc/odata4/tutorials/sqo_tcs/tutorial_sqo_tcs.mdtext
Wed Dec 9 09:34:38 2015
@@ -22,8 +22,8 @@ Notice: Licensed to the Apache Softwa
## Introduction
-In the present tutorial, weâll learn how to implement **system query
options**.
-Query options are used to refine the result of a query.
+In the present tutorial, weâll learn how to implement **system query
options**.
+Query options are used to refine the result of a query.
The [OData V4 specification
document](http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part2-url-conventions/odata-v4.0-errata02-os-part2-url-conventions-complete.html#_Toc406398093)
gives the following definition:
> âSystem query options are query string parameters that control the amount
> and order of the data returned for the resource identified by the URL. The
> names of all system query options are prefixed with a dollar ($)
> character.â
@@ -32,19 +32,19 @@ The [OData V4 specification document](ht
Query options are not part of the resource path, theyâre appended to the URL
after the `?`.
As an example the URL <http://localhost:8080/my/page?example=true> has
*example* as *query option* with the value *true*.
-As an example for a system query option in Odata:
-When querying the list of products, the order of the returned entries is
defaulted by the OData service.
+As an example for a system query option in Odata:
+When querying the list of products, the order of the returned entries is
defaulted by the OData service.
However, the user can change the order of the list by specifying the query
option `$orderby`.
-Examples for system query options that are commonly used:
+Examples for system query options that are commonly used:
- * `$top`
- * `$skip`
- * `$count`
- * `$select`
- * `$orderby`
- * `$filter`
- * `$expand`
+ * `$top`
+ * `$skip`
+ * `$count`
+ * `$select`
+ * `$orderby`
+ * `$filter`
+ * `$expand`
The present tutorial focuses on the first three query options: `$top`, `$skip`
and `$count`
@@ -52,12 +52,12 @@ The present tutorial focuses on the firs
The following example calls are based on our sample service and illustrate the
usage of these 3 query options.
-First, just to remember, the ânormalâ query of the product without query
options:
+First, just to remember, the ânormalâ query of the product without query
options:
<http://localhost:8080/DemoService/DemoService.svc/Products>

-The following URL provides only the first 2 entries and ignores all the rest:
+The following URL provides only the first 2 entries and ignores all the rest:
<http://localhost:8080/DemoService/DemoService.svc/Products?$top=2>

@@ -67,18 +67,18 @@ The following request returns the produc

-The following request returns the total number of products and includes it in
the payload:
+The following request returns the total number of products and includes it in
the payload:
<http://localhost:8080/DemoService/DemoService.svc/Products?$count=true>

-**Note:**
+**Note:**
TThe final source code can be found in the project [git
repository](https://git-wip-us.apache.org/repos/asf/olingo-odata4).
-A detailed description how to checkout the tutorials can be found
[here](/doc/odata4/tutorials/prerequisites/prerequisites.html).
+A detailed description how to checkout the tutorials can be found
[here](/doc/odata4/tutorials/prerequisites/prerequisites.html).
This tutorial can be found in subdirectory
*\samples\tutorials\p5_queryoptions-tcs*
-**Disclaimer:**
+**Disclaimer:**
Again, in the present tutorial, weâll focus only on the relevant
implementation, in order to keep the code small and simple. The sample code
shouldnât be reused for advanced scenarios.
**Table of Contents**
@@ -118,7 +118,7 @@ ___
The system query options weâre focusing on are applied to the entity
collection only (for example, it doesnât make sense to apply a `$top` to a
READ request of a single entity)
-Therefore our implementation for all three query options is done in the class
+Therefore our implementation for all three query options is done in the class
`myservice.mynamespace.service.DemoEntityCollectionProcessor`
The general sequence of the implementation remains unchanged:
@@ -128,7 +128,7 @@ The general sequence of the implementati
3. Serialize
4. Configure the response
-The only difference is that we apply the query options after getting the data
from the backend (our database-mock).
+The only difference is that we apply the query options after getting the data
from the backend (our database-mock).
So the procedure will be:
1. Analyze the URI
@@ -137,59 +137,59 @@ So the procedure will be:
4. Serialize
5. Configure the response
-The following sections describe how such system query options are implemented.
-The procedure will be similar in all 3 cases:
+The following sections describe how such system query options are implemented.
+The procedure will be similar in all 3 cases:
- 1. Get the query option from the UriInfo. If null is returned then nothing
has to be done.
- 1. Get the value from the query option
- 1. Analyze the value
- 1. Modify the EntityCollection
+ 1. Get the query option from the UriInfo. If null is returned then nothing
has to be done.
+ 1. Get the value from the query option
+ 1. Analyze the value
+ 1. Modify the EntityCollection
## 3.1. Implement `$count`
-**Background**
-The `$count` allows users to request a count of the matching resources.
+**Background**
+The `$count` allows users to request a count of the matching resources.
The number will be included with the resources in the response (see screenshot
above).
-The user specifies the `$count` as follows:
-`$count=true`
-`$count=false`
+The user specifies the `$count` as follows:
+`$count=true`
+`$count=false`
If the value of `$count` is set to _false_, then no number is returned, the
same like if `$count` is not specified at all. However, this case has to be
considered in our code as well.
-Note:
-For those who are used to OData V2:
+Note:
+For those who are used to OData V2:
In V2, the query option `$inlinecount` has now been replaced in V4 by
`$count=true`.
-In V2, the `/$count` that was part of the resource path, has now been removed
in V4.
+In V2, the `/$count` that was part of the resource path, has now been removed
in V4.
-Thereâs one more important detail that we have to consider before writing
the code:
-`$count` always returns the original number of entities, without considering
_$top_ and `$skip`.
+Thereâs one more important detail that we have to consider before writing
the code:
+`$count` always returns the original number of entities, without considering
_$top_ and `$skip`.
This is specified by the [OData V4 specification](
-http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part1-protocol/odata-v4.0-errata02-os-part1-protocol-complete.html#_Toc406398308):
-> âThe `$count` system query option ignores any $top, `$skip`, or `$expand`
query options, and returns the total count of results across all pages
including only those results matching any specified `$filter` and $search.â
+http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part1-protocol/odata-v4.0-errata02-os-part1-protocol-complete.html#_Toc406398308):
+> âThe `$count` system query option ignores any $top, `$skip`, or `$expand`
query options, and returns the total count of results across all pages
including only those results matching any specified `$filter` and $search.â
Therefore, in our sample code, the `$count` will be the first to be
implemented, to make sure that the data provided by the backend is not modified
at the moment when we "count" it.
-**Implementation**
-As in the previous tutorials, the data is fetched from the backend.
-It is provided as `EntityCollection` which we can ask for the list of
contained `Entity` instances.
-The size of this genuine list is the relevant information for our `$count`.
-Furthermore, we create a new instance of an `EntityCollection` object, which
will carry the modified list of entities after applying all the query options.
+**Implementation**
+As in the previous tutorials, the data is fetched from the backend.
+It is provided as `EntityCollection` which we can ask for the list of
contained `Entity` instances.
+The size of this genuine list is the relevant information for our `$count`.
+Furthermore, we create a new instance of an `EntityCollection` object, which
will carry the modified list of entities after applying all the query options.
:::java
EntityCollection entityCollection =
storage.readEntitySetData(edmEntitySet);
List<Entity> entityList = entityCollection.getEntities();
EntityCollection returnEntityCollection = new EntityCollection();
-Then we proceed with the 4 steps as described above:
+Then we proceed with the 4 steps as described above:
- 1. Get the query option from the `UriInfo`. If null is returned then nothing
has to be done.
- 1. Get the value from the query option
- 1. Analyze the value
+ 1. Get the query option from the `UriInfo`. If null is returned then nothing
has to be done.
+ 1. Get the value from the query option
+ 1. Analyze the value
1. Modify the `EntityCollection`
And this is the sample code:
@@ -204,13 +204,13 @@ And this is the sample code:
}
-**Note:**
+**Note:**
We donât need to check if the value of the `$count` is incorrect (e.g.
`$count=xxx`), as this is handled by the _Olingo OData V4_ library.
-One additional step has to be considered:
-As we know, if `$count=true` is specified, the structure of the response
payload is different.
-So we have to inform the serializer.that `$count` has to be considered.
-So we have to modify the line of code, where the
`EntityCollectionSerializerOptions` is created:
+One additional step has to be considered:
+As we know, if `$count=true` is specified, the structure of the response
payload is different.
+So we have to inform the serializer.that `$count` has to be considered.
+So we have to modify the line of code, where the
`EntityCollectionSerializerOptions` is created:
:::java
EntityCollectionSerializerOptions opts =
EntityCollectionSerializerOptions.with()
@@ -231,25 +231,25 @@ Furthermore, we have to change the follo
## 3.2. Implement `$skip`
-**Background**
-With the query option `$skip`, the user of an OData service can specify the
number of entries that should be ignored at the beginning of a collection.
+**Background**
+With the query option `$skip`, the user of an OData service can specify the
number of entries that should be ignored at the beginning of a collection.
So if a user specifies `$skip=n` then our OData service has to return the list
of entries starting at position n+1
-One important rule that we have to consider is described by the [OData V4
specification](http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part1-protocol/odata-v4.0-errata02-os-part1-protocol-complete.html#_Toc406398306):
-> âWhere `$top` and `$skip` are used together, `$skip` MUST be applied
before $top, regardless of the order in which they appear in the request.â
+One important rule that we have to consider is described by the [OData V4
specification](http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part1-protocol/odata-v4.0-errata02-os-part1-protocol-complete.html#_Toc406398306):
+> âWhere `$top` and `$skip` are used together, `$skip` MUST be applied
before $top, regardless of the order in which they appear in the request.â
This means for us that we add the code for `$skip` before the code for `$top`.
**Implementation**
-Again we follow the 4 mentioned steps.
-We get the `SkipOption` object from the `UriInfo`.
-If the `SkipOption` is null, then it hasnât been specified by the user.
-Since it is not mandatory to specify any query option, we can ignore the case
of `SkipOption` being null.
-We ask the `SkipOption` object for the value that has been specified by the
user.
-Since the user might give invalid numbers, we have to check that and throw an
exception with HTTP status as âBad Requestâ.
-Then we can do the actual job, which is adapting the backend-data according to
the specified `$skip`.
+Again we follow the 4 mentioned steps.
+We get the `SkipOption` object from the `UriInfo`.
+If the `SkipOption` is null, then it hasnât been specified by the user.
+Since it is not mandatory to specify any query option, we can ignore the case
of `SkipOption` being null.
+We ask the `SkipOption` object for the value that has been specified by the
user.
+Since the user might give invalid numbers, we have to check that and throw an
exception with HTTP status as âBad Requestâ.
+Then we can do the actual job, which is adapting the backend-data according to
the specified `$skip`.
:::java
SkipOption skipOption = uriInfo.getSkipOption();
@@ -267,7 +267,7 @@ Then we can do the actual job, which is
}
}
-After applying the query option, we have the desired set of entities in the
variable `entityList`.
+After applying the query option, we have the desired set of entities in the
variable `entityList`.
Now we have to populate the `EntityCollection` instance, that we created in
the section above, with these entities, before we can pass it to the serializer:
:::java
@@ -278,7 +278,7 @@ Now we have to populate the `EntityColle
## 3.3. Implement $top
-**Background**
+**Background**
With the query option `$top`, the user of an OData service can specify the
maximum number of entries that should be returned, starting from the beginning.
**Implementation**
@@ -367,16 +367,16 @@ So now we can finally have a look at the
// and serialize the content: transform from the EntitySet object to
InputStream
EdmEntityType edmEntityType = edmEntitySet.getEntityType();
ContextURL contextUrl =
ContextURL.with().entitySet(edmEntitySet).build();
-
+
final String id = request.getRawBaseUri() + "/" +
edmEntitySet.getName();
EntityCollectionSerializerOptions opts =
EntityCollectionSerializerOptions.with()
.contextURL(contextUrl)
.id(id)
.count(countOption)
.build();
- SerializerResult serializerResult =
serializer.entityCollection(serviceMetadata, edmEntityType,
+ SerializerResult serializerResult =
serializer.entityCollection(serviceMetadata, edmEntityType,
returnEntityCollection, opts);
-
+
// 5th: configure the response object: set the body, headers and
status code
response.setContent(serializedContent);
response.setStatusCode(HttpStatusCode.OK.getStatusCode());
@@ -387,26 +387,26 @@ So now we can finally have a look at the
# 4. Run the implemented service
-After building and deploying your service to your server, you can try the
following URLs:
+After building and deploying your service to your server, you can try the
following URLs:
- * The full collection, no query option
+ * The full collection, no query option
<http://localhost:8080/DemoService/DemoService.svc/Products>
- * First 2 products only
+ * First 2 products only
<http://localhost:8080/DemoService/DemoService.svc/Products?$top=2>
- * Exclude the first 2 products
+ * Exclude the first 2 products
<http://localhost:8080/DemoService/DemoService.svc/Products?$skip=2>
- * Add the full number of all products to the response payload
+ * Add the full number of all products to the response payload
<http://localhost:8080/DemoService/DemoService.svc/Products?$count=true>
* Combine `$top` and `$skip`
- <http://localhost:8080/DemoService/DemoService.svc/Products?$skip=1&$top=1>
- <http://localhost:8080/DemoService/DemoService.svc/Products?$top=1&$skip=1>
+ <http://localhost:8080/DemoService/DemoService.svc/Products?$skip=1&$top=1>
+ <http://localhost:8080/DemoService/DemoService.svc/Products?$top=1&$skip=1>
Regardless of the order, the result should be the same
- * Combine all 3 query options
+ * Combine all 3 query options
<http://localhost:8080/DemoService/DemoService.svc/Products?$skip=1&$top=1&$count=true>
---
@@ -414,8 +414,8 @@ After building and deploying your servic
# 5. Summary
In this tutorial we have learned how enhance our OData service to support
system query options.
-In a first step, weâve covered `$top`, `$skip` and `$count`.
-More system query options will be treated in the subsequent tutorials.
+In a first step, weâve covered `$top`, `$skip` and `$count`.
+More system query options will be treated in the subsequent tutorials.
---
@@ -432,6 +432,8 @@ More system query options will be treate
* Tutorial OData V4 service, part 5.4: [System Query Options
$filter](/doc/odata4/tutorials/sqo_f/tutorial_sqo_f.html)
* Tutorial ODATA V4 service, part 6: [Action and Function
Imports](/doc/odata4/tutorials/action/tutorial_action.html)
* Tutorial ODATA V4 service, part 7: [Media
Entities](/doc/odata4/tutorials/media/tutorial_media.html)
+ * Tutorial OData V4 service, part 8: [Batch Request
support](/doc/odata4/tutorials/batch/tutorial_batch.html)
+ * Tutorial OData V4 service, part 9: [Handling "Deep Insert"
requests](/doc/odata4/tutorials/deep_insert/tutorial_deep_insert.html)
### Code and Repository
* [Git Repository](https://git-wip-us.apache.org/repos/asf/olingo-odata4)
@@ -442,4 +444,4 @@ More system query options will be treate
* [Official OData Homepage](http://odata.org/)
* [OData documentation](http://www.odata.org/documentation/)
- * [Olingo Javadoc](/javadoc/odata4/index.html)
\ No newline at end of file
+ * [Olingo Javadoc](/javadoc/odata4/index.html)
Modified:
olingo/site/trunk/content/doc/odata4/tutorials/write/tutorial_write.mdtext
URL:
http://svn.apache.org/viewvc/olingo/site/trunk/content/doc/odata4/tutorials/write/tutorial_write.mdtext?rev=1718786&r1=1718785&r2=1718786&view=diff
==============================================================================
--- olingo/site/trunk/content/doc/odata4/tutorials/write/tutorial_write.mdtext
(original)
+++ olingo/site/trunk/content/doc/odata4/tutorials/write/tutorial_write.mdtext
Wed Dec 9 09:34:38 2015
@@ -408,14 +408,16 @@ In the next tutorial (Part 4: Navigation
* Tutorial OData V4 service part 1: [Read Entity
Collection](/doc/odata4/tutorials/read/tutorial_read.html)
* Tutorial OData V4 service part 2: [Read Entity, Read
Property](/doc/odata4/tutorials/readep/tutorial_readep.html)
* Tutorial OData V4 service part 3: Write (Create, Update, Delete Entity
- * Tutorial OData V4 service, part 4:
[Navigation](/doc/odata4/tutorials/navigation/tutorial_navigation.html)
- * Tutorial OData V4 service, part 5.1: [System Query Options $top, $skip,
$count (this page)](/doc/odata4/tutorials/sqo_tcs/tutorial_sqo_tcs.html)
- * Tutorial OData V4 service, part 5.2: [System Query Options $select,
$expand](/doc/odata4/tutorials/sqo_es/tutorial_sqo_es.html)
+ * Tutorial OData V4 service, part 4:
[Navigation](/doc/odata4/tutorials/navigation/tutorial_navigation.html)
+ * Tutorial OData V4 service, part 5.1: [System Query Options $top, $skip,
$count (this page)](/doc/odata4/tutorials/sqo_tcs/tutorial_sqo_tcs.html)
+ * Tutorial OData V4 service, part 5.2: [System Query Options $select,
$expand](/doc/odata4/tutorials/sqo_es/tutorial_sqo_es.html)
* Tutorial OData V4 service, part 5.3: [System Query Options
$orderby](/doc/odata4/tutorials/sqo_o/tutorial_sqo_o.html)
* Tutorial OData V4 service, part 5.4: [System Query Options
$filter](/doc/odata4/tutorials/sqo_f/tutorial_sqo_f.html)
* Tutorial ODATA V4 service, part 6: [Action and Function
Imports](/doc/odata4/tutorials/action/tutorial_action.html)
* Tutorial ODATA V4 service, part 7: [Media
Entities](/doc/odata4/tutorials/media/tutorial_media.html)
-
+ * Tutorial OData V4 service, part 8: [Batch Request
support](/doc/odata4/tutorials/batch/tutorial_batch.html)
+ * Tutorial OData V4 service, part 9: [Handling "Deep Insert"
requests](/doc/odata4/tutorials/deep_insert/tutorial_deep_insert.html)
+
### Code and Repository
* [Git Repository](https://git-wip-us.apache.org/repos/asf/olingo-odata4)
* [Guide - To fetch the tutorial
sources](/doc/odata4/tutorials/prerequisites/prerequisites.html)
@@ -425,4 +427,4 @@ In the next tutorial (Part 4: Navigation
* [Official OData Homepage](http://odata.org/)
* [OData documentation](http://www.odata.org/documentation/)
- * [Olingo Javadoc](/javadoc/odata4/index.html)
\ No newline at end of file
+ * [Olingo Javadoc](/javadoc/odata4/index.html)