You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2015/04/04 19:05:24 UTC
[18/50] [abbrv] olingo-odata4 git commit: OLINGO-573: New processing
framework on server side with single interface with TripPin example
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8668b097/lib/server-core-ext/src/test/resources/people.json
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/test/resources/people.json b/lib/server-core-ext/src/test/resources/people.json
new file mode 100644
index 0000000..64699bb
--- /dev/null
+++ b/lib/server-core-ext/src/test/resources/people.json
@@ -0,0 +1,323 @@
+{
+ "value":[
+ {
+ "UserName":"russellwhyte",
+ "FirstName":"Russell",
+ "LastName":"Whyte",
+ "Emails":[
+ "Russell@example.com",
+ "Russell@contoso.com"
+ ],
+ "AddressInfo":[
+ {
+ "Address":"187 Suffolk Ln.",
+ "City":{
+ "CountryRegion":"United States",
+ "Name":"Boise",
+ "Region":"ID"
+ }
+ }
+ ],
+ "Gender":"0",
+ "Concurrency":635585295719432047
+ },
+ {
+ "UserName":"scottketchum",
+ "FirstName":"Scott",
+ "LastName":"Ketchum",
+ "Emails":[
+ "Scott@example.com"
+ ],
+ "AddressInfo":[
+ {
+ "Address":"2817 Milton Dr.",
+ "City":{
+ "CountryRegion":"United States",
+ "Name":"Albuquerque",
+ "Region":"NM"
+ }
+ }
+ ],
+ "Gender":"0",
+ "Concurrency":635585295719432047
+ },
+ {
+ "UserName":"ronaldmundy",
+ "FirstName":"Ronald",
+ "LastName":"Mundy",
+ "Emails":[
+ "Ronald@example.com",
+ "Ronald@contoso.com"
+ ],
+ "AddressInfo":[
+
+ ],
+ "Gender":"0",
+ "Concurrency":635585295719432047
+ },
+ {
+ "UserName":"javieralfred",
+ "FirstName":"Javier",
+ "LastName":"Alfred",
+ "Emails":[
+ "Javier@example.com",
+ "Javier@contoso.com"
+ ],
+ "AddressInfo":[
+ {
+ "Address":"89 Jefferson Way Suite 2",
+ "City":{
+ "CountryRegion":"United States",
+ "Name":"Portland",
+ "Region":"WA"
+ }
+ }
+ ],
+ "Gender":"0",
+ "Concurrency":635585295719432047
+ },
+ {
+ "UserName":"willieashmore",
+ "FirstName":"Willie",
+ "LastName":"Ashmore",
+ "Emails":[
+ "Willie@example.com",
+ "Willie@contoso.com"
+ ],
+ "AddressInfo":[
+
+ ],
+ "Gender":"0",
+ "Concurrency":635585295719432047
+ },
+ {
+ "UserName":"vincentcalabrese",
+ "FirstName":"Vincent",
+ "LastName":"Calabrese",
+ "Emails":[
+ "Vincent@example.com",
+ "Vincent@contoso.com"
+ ],
+ "AddressInfo":[
+ {
+ "Address":"55 Grizzly Peak Rd.",
+ "City":{
+ "CountryRegion":"United States",
+ "Name":"Butte",
+ "Region":"MT"
+ }
+ }
+ ],
+ "Gender":"0",
+ "Concurrency":635585295719432047
+ },
+ {
+ "UserName":"clydeguess",
+ "FirstName":"Clyde",
+ "LastName":"Guess",
+ "Emails":[
+ "Clyde@example.com"
+ ],
+ "AddressInfo":[
+
+ ],
+ "Gender":"0",
+ "Concurrency":635585295719432047
+ },
+ {
+ "UserName":"keithpinckney",
+ "FirstName":"Keith",
+ "LastName":"Pinckney",
+ "Emails":[
+ "Keith@example.com",
+ "Keith@contoso.com"
+ ],
+ "AddressInfo":[
+
+ ],
+ "Gender":"0",
+ "Concurrency":635585295719432047
+ },
+ {
+ "UserName":"marshallgaray",
+ "FirstName":"Marshall",
+ "LastName":"Garay",
+ "Emails":[
+ "Marshall@example.com",
+ "Marshall@contoso.com"
+ ],
+ "AddressInfo":[
+
+ ],
+ "Gender":"0",
+ "Concurrency":635585295719432047
+ },
+ {
+ "UserName":"ryantheriault",
+ "FirstName":"Ryan",
+ "LastName":"Theriault",
+ "Emails":[
+ "Ryan@example.com",
+ "Ryan@contoso.com"
+ ],
+ "AddressInfo":[
+
+ ],
+ "Gender":"0",
+ "Concurrency":635585295719432047
+ },
+ {
+ "UserName":"elainestewart",
+ "FirstName":"Elaine",
+ "LastName":"Stewart",
+ "Emails":[
+ "Elaine@example.com",
+ "Elaine@contoso.com"
+ ],
+ "AddressInfo":[
+
+ ],
+ "Gender":"1",
+ "Concurrency":635585295719432047
+ },
+ {
+ "UserName":"salliesampson",
+ "FirstName":"Sallie",
+ "LastName":"Sampson",
+ "Emails":[
+ "Sallie@example.com",
+ "Sallie@contoso.com"
+ ],
+ "AddressInfo":[
+ {
+ "Address":"87 Polk St. Suite 5",
+ "City":{
+ "CountryRegion":"United States",
+ "Name":"San Francisco",
+ "Region":"CA"
+ }
+ },
+ {
+ "Address":"89 Chiaroscuro Rd.",
+ "City":{
+ "CountryRegion":"United States",
+ "Name":"Portland",
+ "Region":"OR"
+ }
+ }
+ ],
+ "Gender":"1",
+ "Concurrency":635585295719432047
+ },
+ {
+ "UserName":"jonirosales",
+ "FirstName":"Joni",
+ "LastName":"Rosales",
+ "Emails":[
+ "Joni@example.com",
+ "Joni@contoso.com"
+ ],
+ "AddressInfo":[
+
+ ],
+ "Gender":"1",
+ "Concurrency":635585295719432047
+ },
+ {
+ "UserName":"georginabarlow",
+ "FirstName":"Georgina",
+ "LastName":"Barlow",
+ "Emails":[
+ "Georgina@example.com",
+ "Georgina@contoso.com"
+ ],
+ "AddressInfo":[
+
+ ],
+ "Gender":"1",
+ "Concurrency":635585295719432047
+ },
+ {
+ "UserName":"angelhuffman",
+ "FirstName":"Angel",
+ "LastName":"Huffman",
+ "Emails":[
+ "Angel@example.com"
+ ],
+ "AddressInfo":[
+
+ ],
+ "Gender":"1",
+ "Concurrency":635585295719432047
+ },
+ {
+ "UserName":"laurelosborn",
+ "FirstName":"Laurel",
+ "LastName":"Osborn",
+ "Emails":[
+ "Laurel@example.com",
+ "Laurel@contoso.com"
+ ],
+ "AddressInfo":[
+
+ ],
+ "Gender":"1",
+ "Concurrency":635585295719432047
+ },
+ {
+ "UserName":"sandyosborn",
+ "FirstName":"Sandy",
+ "LastName":"Osborn",
+ "Emails":[
+ "Sandy@example.com",
+ "Sandy@contoso.com"
+ ],
+ "AddressInfo":[
+
+ ],
+ "Gender":"1",
+ "Concurrency":635585295719432047
+ },
+ {
+ "UserName":"ursulabright",
+ "FirstName":"Ursula",
+ "LastName":"Bright",
+ "Emails":[
+ "Ursula@example.com",
+ "Ursula@contoso.com"
+ ],
+ "AddressInfo":[
+
+ ],
+ "Gender":"1",
+ "Concurrency":635585295719432047
+ },
+ {
+ "UserName":"genevievereeves",
+ "FirstName":"Genevieve",
+ "LastName":"Reeves",
+ "Emails":[
+ "Genevieve@example.com",
+ "Genevieve@contoso.com"
+ ],
+ "AddressInfo":[
+
+ ],
+ "Gender":"1",
+ "Concurrency":635585295719432047
+ },
+ {
+ "UserName":"kristakemp",
+ "FirstName":"Krista",
+ "LastName":"Kemp",
+ "Emails":[
+ "Krista@example.com"
+ ],
+ "AddressInfo":[
+
+ ],
+ "Gender":"1",
+ "Concurrency":635585295719432047
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8668b097/lib/server-core-ext/src/test/resources/photos.json
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/test/resources/photos.json b/lib/server-core-ext/src/test/resources/photos.json
new file mode 100644
index 0000000..127d195
--- /dev/null
+++ b/lib/server-core-ext/src/test/resources/photos.json
@@ -0,0 +1,64 @@
+{
+ "value":[
+ {
+ "Id":1,
+ "Name":"My Photo 1"
+ },
+ {
+ "Id":11,
+ "Name":"Trip Photo 11"
+ },
+ {
+ "Id":12,
+ "Name":"Trip Photo 12"
+ },
+ {
+ "Id":13,
+ "Name":"Trip Photo 13"
+ },
+ {
+ "Id":14,
+ "Name":"Trip Photo 14"
+ },
+ {
+ "Id":2,
+ "Name":"My Photo 2"
+ },
+ {
+ "Id":21,
+ "Name":"Trip Photo 21"
+ },
+ {
+ "Id":22,
+ "Name":"Trip Photo 22"
+ },
+ {
+ "Id":23,
+ "Name":"Trip Photo 23"
+ },
+ {
+ "Id":24,
+ "Name":"Trip Photo 24"
+ },
+ {
+ "Id":3,
+ "Name":"My Photo 3"
+ },
+ {
+ "Id":31,
+ "Name":"Trip Photo 31"
+ },
+ {
+ "Id":32,
+ "Name":"Trip Photo 32"
+ },
+ {
+ "Id":33,
+ "Name":"Trip Photo 33"
+ },
+ {
+ "Id":34,
+ "Name":"Trip Photo 34"
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8668b097/lib/server-core-ext/src/test/resources/trip-links.json
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/test/resources/trip-links.json b/lib/server-core-ext/src/test/resources/trip-links.json
new file mode 100644
index 0000000..df8f9b8
--- /dev/null
+++ b/lib/server-core-ext/src/test/resources/trip-links.json
@@ -0,0 +1,28 @@
+{
+ "value":[
+ {
+ "TripId": 1001,
+ "Flights": [1, 2],
+ "Events": [51, 52, 53, 54, 55],
+ "Photos": [21, 22]
+ },
+ {
+ "TripId":2,
+ "Flights": [3, 4],
+ "Events": [55],
+ "Photos": [13, 14]
+ },
+ {
+ "TripId": 1003,
+ "Flights": [5, 6],
+ "Events": [56, 57],
+ "Photos": [23, 24]
+ },
+ {
+ "TripId": 2004,
+ "Flights": [7, 8],
+ "Events": [55, 57],
+ "Photos": [33, 34]
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8668b097/lib/server-core-ext/src/test/resources/trip.json
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/test/resources/trip.json b/lib/server-core-ext/src/test/resources/trip.json
new file mode 100644
index 0000000..79c6104
--- /dev/null
+++ b/lib/server-core-ext/src/test/resources/trip.json
@@ -0,0 +1,224 @@
+{
+ "value":[
+ {
+ "TripId": 1001,
+ "ShareId": "9d9b2fa0-efbf-490e-a5e3-bac8f7d47354",
+ "Description": "Trip from San Francisco to New York City. Nice trip with two friends. It is a 4 days' trip. We actually had a client meeting, but we also took one to go sightseeings in New York.",
+ "Name": "Trip in US",
+ "Budget": 3000.0,
+ "StartsAt":"2014-01-01T00:00:00Z",
+ "EndsAt": "2014-01-04T00:00:00Z",
+ "Tags": ["Trip in New York", "business","sightseeing"]
+ },
+ {
+ "TripId":2,
+ "ShareId": "f94e9116-8bdd-4dac-ab61-08438d0d9a71",
+ "Description": "Trip from Shanghai to Beijing",
+ "Name":"Trip in Beijing",
+ "Budget": 3000.0,
+ "Tags": ["Travel", "Beijing"],
+ "StartsAt": "2014-02-01T00:00:00Z",
+ "EndsAt": "2014-02-04T00:00:00Z"
+ },
+ {
+ "TripId": 3,
+ "ShareId": "9ce142c3-5fd6-4a71-848e-5220ebf1e9f3",
+ "Name": "Honeymoon",
+ "Budget": 800.0,
+ "Description": "Happy honeymoon trip",
+ "Tags": ["Travel", "honeymoon"],
+ "StartsAt": "2014-02-01T00:00:00Z",
+ "EndsAt": "2014-02-04T00:00:00Z"
+ },
+ {
+ "TripId": 4,
+ "ShareId": "4CCFB043-C79C-44EF-8CFE-CD493CED6654",
+ "Name": "Business trip to OData",
+ "Budget": 324.6,
+ "Description": "Business trip to OData",
+ "Tags": ["business", "odata"],
+ "StartsAt": "2013-01-01T00:00:00Z",
+ "EndsAt": "2013-01-04T00:00:00Z"
+ },
+ {
+ "TripId": 5,
+ "ShareId": "4546F419-0070-45F7-BA2C-19E4BC3647E1",
+ "Name": "Travel trip in US",
+ "Budget": 1250.0,
+ "Description": "Travel trip in US",
+ "Tags": ["travel", "overseas"],
+ "StartsAt": "2013-01-19T00:00:00Z",
+ "EndsAt": "2013-01-28T00:00:00Z"
+ },
+ {
+ "TripId": 6,
+ "ShareId": "26F0E8F6-657A-4561-BF3B-719366EF04FA",
+ "Name": "Study music in Europe",
+ "Budget": 3200.0,
+ "Description": "Study music in Europe",
+ "Tags": ["study", "overseas"],
+ "StartsAt": "2013-03-01T00:00:00Z",
+ "EndsAt": "2013-05-04T00:00:00Z"
+ },
+ {
+ "TripId": 7,
+ "ShareId": "2E77BF06-A354-454B-8BCA-5F004C1AFB59",
+ "Name": "Conference talk about OData",
+ "Budget": 2120.55,
+ "Description": "Conference talk about ODatan",
+ "Tags": ["odata", "overseas"],
+ "StartsAt": "2013-07-02T00:00:00Z",
+ "EndsAt": "2013-07-05T00:00:00Z"
+ },
+ {
+ "TripId": 8,
+ "ShareId": "E6E23FB2-C428-439E-BDAB-9283482F49F0",
+ "Name": "Vocation at hometown",
+ "Budget": 1500.0,
+ "Description": "Vocation at hometown",
+ "Tags": ["voaction"],
+ "StartsAt": "2013-10-01T00:00:00Z",
+ "EndsAt": "2013-10-05T00:00:00Z"
+ },
+ {
+ "TripId": 9,
+ "ShareId": "FAE31279-35CE-4119-9BDC-53F6E19DD1C5",
+ "Name": "Business trip for tech training",
+ "Budget": 100.0,
+ "Description": "Business trip for tech training",
+ "Tags": ["business"],
+ "StartsAt": "2013-09-01T00:00:00Z",
+ "EndsAt": "2013-09-04T00:00:00Z"
+ },
+ {
+ "TripId": 3009,
+ "ShareId": "dd6a09c0-e59b-4745-8612-f4499b676c47",
+ "Name": "Gradutaion trip",
+ "Budget": 6000.0,
+ "Description": "Gradution trip with friends",
+ "Tags": ["Travel"],
+ "StartsAt": "2013-05-01T00:00:00Z",
+ "EndsAt": "2013-05-08T00:00:00Z"
+ },
+ {
+ "TripId": 2004,
+ "ShareId": "f94e9116-8bdd-4dac-ab61-08438d0d9a71",
+ "Name": "Trip in Beijing",
+ "Budget": 11000.0,
+ "Description": "Trip from Shanghai to Beijing",
+ "Tags": ["Travel", "Beijing"],
+ "StartsAt": "2014-02-01T00:00:00Z",
+ "EndsAt": "2013-02-02T00:00:00Z"
+ },
+ {
+ "TripId": 4005,
+ "ShareId": "f94e9116-8bdd-4dac-ab61-08438d0d9a71",
+ "Name": "Trip in Beijing",
+ "Budget": 800.0,
+ "Description": "Trip from Shanghai to Beijing",
+ "Tags": ["Travel", "Beijing"],
+ "StartsAt": "2014-02-01T00:00:00Z",
+ "EndsAt": "2014-02-04T00:00:00Z"
+ },
+ {
+ "TripId": 5007,
+ "ShareId": "5ae142c3-5ad6-4a71-768e-5220ebf1e9f3",
+ "Name": "Business Trip",
+ "Budget": 3800.5,
+ "Description": "This is my first business trip",
+ "Tags": ["business", "first"],
+ "StartsAt": "2014-02-01T00:00:00Z",
+ "EndsAt": "2014-02-04T00:00:00Z"
+ },
+ {
+ "TripId": 5008,
+ "ShareId": "9ce32ac3-5fd6-4a72-848e-2250ebf1e9f3",
+ "Name": "Trip in Europe",
+ "Budget": 2000.0,
+ "Description": "The trip is currently in plan.",
+ "Tags": ["Travel", "plan"],
+ "StartsAt": "2014-02-01T00:00:00Z",
+ "EndsAt": "2014-02-04T00:00:00Z"
+ },
+ {
+ "TripId": 1003,
+ "Name": "Trip in Beijing",
+ "Budget": 2000.0,
+ "ShareId": "f94e9116-8bdd-4dac-ab61-08438d0d9a71",
+ "Description": "Trip from Shanghai to Beijing",
+ "Tags": ["Travel", "Beijing"],
+ "StartsAt": "2014-02-01T00:00:00Z",
+ "EndsAt": "2014-02-04T00:00:00Z"
+ },
+ {
+ "TripId": 2004,
+ "ShareId": "f94e9116-8bdd-4dac-ab61-08438d0d9a71",
+ "Name": "Trip in Beijing",
+ "Budget": 11000.0,
+ "Description": "Trip from Shanghai to Beijing",
+ "Tags": ["Travel", "Beijing"],
+ "StartsAt": "2014-02-01T00:00:00Z",
+ "EndsAt": "2014-02-04T00:00:00Z"
+ },
+ {
+ "TripId": 1007,
+ "ShareId": "9ce142c3-5fd6-4a71-848e-5220ebf1e9f3",
+ "Name": "Honeymoon",
+ "Budget": 2650.0,
+ "Description": "Happy honeymoon trip",
+ "Tags": ["Travel", "honeymoon"],
+ "StartsAt": "2014-02-01T00:00:00Z",
+ "EndsAt": "2014-02-04T00:00:00Z"
+ },
+ {
+ "TripId": 7010,
+ "ShareId": "dd6a09c0-e59b-4745-8612-f4499b676c47",
+ "Name": "Gradutaion trip",
+ "Budget": 1000.0,
+ "Description": "Gradution trip with friends",
+ "Tags": ["Travel"],
+ "StartsAt": "2013-05-01T00:00:00Z",
+ "EndsAt": "2013-05-08T00:00:00Z"
+ },
+ {
+ "TripId": 8011,
+ "ShareId": "a88f675d-9199-4392-9656-b08e3b46df8a",
+ "Name": "Study trip",
+ "Budget": 1550.3,
+ "Description": "This is a 2 weeks study trip",
+ "Tags": ["study"],
+ "StartsAt": "2014-01-01T00:00:00Z",
+ "EndsAt": "2013-01-14T00:00:00Z"
+ },
+ {
+ "TripId": 13012,
+ "ShareId": "a88f675d-9199-4392-9656-b08e3b46df8a",
+ "Name": "Study trip",
+ "Budget": 600.0,
+ "Description": "This is a 2 weeks study trip",
+ "Tags": ["study"],
+ "StartsAt": "2014-01-01T00:00:00Z",
+ "EndsAt": "2013-01-14T00:00:00Z"
+ },
+ {
+ "TripId": 14013,
+ "ShareId": "a88f675d-9199-4392-9656-b08e3b46df8a",
+ "Name": "Study trip",
+ "Budget": 2000.0,
+ "Description": "This is a 2 weeks study trip",
+ "Tags": ["study"],
+ "StartsAt": "2014-01-01T00:00:00Z",
+ "EndsAt": "2013-01-14T00:00:00Z"
+ },
+ {
+ "TripId": 16014,
+ "ShareId": "cb0b8acb-79cb-4127-8316-772bc4302824",
+ "Name": "DIY Trip",
+ "Budget": 1500.3,
+ "Description": "This is a DIY trip",
+ "Tags": ["Travel", "DIY"],
+ "StartsAt": "2011-02-11T00:00:00Z",
+ "EndsAt": "2011-02-14T00:00:00Z"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8668b097/lib/server-core-ext/src/test/resources/trippin.xml
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/test/resources/trippin.xml b/lib/server-core-ext/src/test/resources/trippin.xml
new file mode 100644
index 0000000..5970793
--- /dev/null
+++ b/lib/server-core-ext/src/test/resources/trippin.xml
@@ -0,0 +1,356 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">
+ <edmx:DataServices>
+ <Schema Namespace="Microsoft.OData.SampleService.Models.TripPin" xmlns="http://docs.oasis-open.org/odata/ns/edm">
+ <EnumType Name="PersonGender">
+ <Member Name="Male" Value="0" />
+ <Member Name="Female" Value="1" />
+ <Member Name="Unknown" Value="2" />
+ </EnumType>
+ <ComplexType Name="City">
+ <Property Name="CountryRegion" Type="Edm.String" Nullable="false" />
+ <Property Name="Name" Type="Edm.String" Nullable="false" />
+ <Property Name="Region" Type="Edm.String" Nullable="false" />
+ </ComplexType>
+ <ComplexType Name="Location" OpenType="true">
+ <Property Name="Address" Type="Edm.String" Nullable="false" />
+ <Property Name="City" Type="Microsoft.OData.SampleService.Models.TripPin.City" Nullable="false" />
+ </ComplexType>
+ <ComplexType Name="EventLocation" BaseType="Microsoft.OData.SampleService.Models.TripPin.Location" OpenType="true">
+ <Property Name="BuildingInfo" Type="Edm.String" />
+ </ComplexType>
+ <ComplexType Name="AirportLocation" BaseType="Microsoft.OData.SampleService.Models.TripPin.Location" OpenType="true">
+ <Property Name="Loc" Type="Edm.GeographyPoint" Nullable="false" SRID="4326" />
+ </ComplexType>
+ <EntityType Name="Photo" HasStream="true">
+ <Key>
+ <PropertyRef Name="Id" />
+ </Key>
+ <Property Name="Id" Type="Edm.Int64" Nullable="false">
+ <Annotation Term="Org.OData.Core.V1.Permissions">
+ <EnumMember>Org.OData.Core.V1.Permission/Read</EnumMember>
+ </Annotation>
+ </Property>
+ <Property Name="Name" Type="Edm.String" />
+ <Annotation Term="Org.OData.Core.V1.AcceptableMediaTypes">
+ <Collection>
+ <String>image/jpeg</String>
+ </Collection>
+ </Annotation>
+ </EntityType>
+ <EntityType Name="Person" OpenType="true">
+ <Key>
+ <PropertyRef Name="UserName" />
+ </Key>
+ <Property Name="UserName" Type="Edm.String" Nullable="false">
+ <Annotation Term="Org.OData.Core.V1.Permissions">
+ <EnumMember>Org.OData.Core.V1.Permission/Read</EnumMember>
+ </Annotation>
+ </Property>
+ <Property Name="FirstName" Type="Edm.String" Nullable="true" />
+ <Property Name="LastName" Type="Edm.String" Nullable="false" />
+ <Property Name="Emails" Type="Collection(Edm.String)" />
+ <Property Name="AddressInfo" Type="Collection(Microsoft.OData.SampleService.Models.TripPin.Location)" />
+ <Property Name="Gender" Type="Microsoft.OData.SampleService.Models.TripPin.PersonGender" />
+ <Property Name="Concurrency" Type="Edm.Int64" Nullable="false">
+ <Annotation Term="Org.OData.Core.V1.Computed" Bool="true" />
+ </Property>
+ <NavigationProperty Name="Friends" Type="Collection(Microsoft.OData.SampleService.Models.TripPin.Person)" />
+ <NavigationProperty Name="Trips" Type="Collection(Microsoft.OData.SampleService.Models.TripPin.Trip)" ContainsTarget="true" />
+ <NavigationProperty Name="Photo" Type="Microsoft.OData.SampleService.Models.TripPin.Photo" />
+ </EntityType>
+ <EntityType Name="Airline">
+ <Key>
+ <PropertyRef Name="AirlineCode" />
+ </Key>
+ <Property Name="AirlineCode" Type="Edm.String" Nullable="false">
+ <Annotation Term="Org.OData.Core.V1.Permissions">
+ <EnumMember>Org.OData.Core.V1.Permission/Read</EnumMember>
+ </Annotation>
+ </Property>
+ <Property Name="Name" Type="Edm.String" Nullable="false" />
+ <Property Name="Picture" Type="Edm.Stream" Nullable="true" />
+ </EntityType>
+ <EntityType Name="Airport">
+ <Key>
+ <PropertyRef Name="IcaoCode" />
+ </Key>
+ <Property Name="IcaoCode" Type="Edm.String" Nullable="false">
+ <Annotation Term="Org.OData.Core.V1.Permissions">
+ <EnumMember>Org.OData.Core.V1.Permission/Read</EnumMember>
+ </Annotation>
+ </Property>
+ <Property Name="Name" Type="Edm.String" Nullable="false" />
+ <Property Name="IataCode" Type="Edm.String" Nullable="false">
+ <Annotation Term="Org.OData.Core.V1.Immutable" Bool="true" />
+ </Property>
+ <Property Name="Location" Type="Microsoft.OData.SampleService.Models.TripPin.AirportLocation" Nullable="false" />
+ </EntityType>
+ <EntityType Name="PlanItem">
+ <Key>
+ <PropertyRef Name="PlanItemId" />
+ </Key>
+ <Property Name="PlanItemId" Type="Edm.Int32" Nullable="false">
+ <Annotation Term="Org.OData.Core.V1.Permissions">
+ <EnumMember>Org.OData.Core.V1.Permission/Read</EnumMember>
+ </Annotation>
+ </Property>
+ <Property Name="ConfirmationCode" Type="Edm.String" />
+ <Property Name="StartsAt" Type="Edm.DateTimeOffset" />
+ <Property Name="EndsAt" Type="Edm.DateTimeOffset" />
+ <Property Name="Duration" Type="Edm.Duration" />
+ </EntityType>
+ <EntityType Name="PublicTransportation" BaseType="Microsoft.OData.SampleService.Models.TripPin.PlanItem">
+ <Property Name="SeatNumber" Type="Edm.String" />
+ </EntityType>
+ <EntityType Name="Flight" BaseType="Microsoft.OData.SampleService.Models.TripPin.PublicTransportation">
+ <Property Name="FlightNumber" Type="Edm.String" Nullable="false" />
+ <NavigationProperty Name="From" Type="Microsoft.OData.SampleService.Models.TripPin.Airport" Nullable="false" />
+ <NavigationProperty Name="To" Type="Microsoft.OData.SampleService.Models.TripPin.Airport" Nullable="false" />
+ <NavigationProperty Name="Airline" Type="Microsoft.OData.SampleService.Models.TripPin.Airline" Nullable="false" />
+ </EntityType>
+ <EntityType Name="Event" BaseType="Microsoft.OData.SampleService.Models.TripPin.PlanItem" OpenType="true">
+ <Property Name="Description" Type="Edm.String" />
+ <Property Name="OccursAt" Type="Microsoft.OData.SampleService.Models.TripPin.EventLocation" Nullable="false" />
+ </EntityType>
+ <EntityType Name="Trip">
+ <Key>
+ <PropertyRef Name="TripId" />
+ </Key>
+ <Property Name="TripId" Type="Edm.Int32" Nullable="false">
+ <Annotation Term="Org.OData.Core.V1.Permissions">
+ <EnumMember>Org.OData.Core.V1.Permission/Read</EnumMember>
+ </Annotation>
+ </Property>
+ <Property Name="ShareId" Type="Edm.Guid" />
+ <Property Name="Description" Type="Edm.String" />
+ <Property Name="Name" Type="Edm.String" Nullable="false" />
+ <Property Name="Budget" Type="Edm.Single" Nullable="false">
+ <Annotation Term="Org.OData.Measures.V1.ISOCurrency" String="USD" />
+ <Annotation Term="Org.OData.Measures.V1.Scale" Int="2" />
+ </Property>
+ <Property Name="StartsAt" Type="Edm.DateTimeOffset" Nullable="false" />
+ <Property Name="EndsAt" Type="Edm.DateTimeOffset" Nullable="false" />
+ <Property Name="Tags" Type="Collection(Edm.String)" Nullable="false" />
+ <NavigationProperty Name="Photos" Type="Collection(Microsoft.OData.SampleService.Models.TripPin.Photo)" />
+ <NavigationProperty Name="PlanItems" Type="Collection(Microsoft.OData.SampleService.Models.TripPin.PlanItem)" ContainsTarget="true" />
+ </EntityType>
+ <Function Name="GetFavoriteAirline" IsBound="true" EntitySetPath="person/Trips/PlanItems/Microsoft.OData.SampleService.Models.TripPin.Flight/Airline" IsComposable="true">
+ <Parameter Name="person" Type="Microsoft.OData.SampleService.Models.TripPin.Person" Nullable="false" />
+ <ReturnType Type="Microsoft.OData.SampleService.Models.TripPin.Airline" Nullable="false" />
+ </Function>
+ <Function Name="GetInvolvedPeople" IsBound="true" IsComposable="true">
+ <Parameter Name="trip" Type="Microsoft.OData.SampleService.Models.TripPin.Trip" Nullable="false" />
+ <ReturnType Type="Collection(Microsoft.OData.SampleService.Models.TripPin.Person)" Nullable="false" />
+ </Function>
+ <Function Name="GetFriendsTrips" IsBound="true" EntitySetPath="person/Friends/Trips" IsComposable="true">
+ <Parameter Name="person" Type="Microsoft.OData.SampleService.Models.TripPin.Person" Nullable="false" />
+ <Parameter Name="userName" Type="Edm.String" Nullable="false" />
+ <ReturnType Type="Collection(Microsoft.OData.SampleService.Models.TripPin.Trip)" Nullable="false" />
+ </Function>
+ <Function Name="GetNearestAirport" IsComposable="true">
+ <Parameter Name="lat" Type="Edm.Double" Nullable="false" />
+ <Parameter Name="lon" Type="Edm.Double" Nullable="false" />
+ <ReturnType Type="Microsoft.OData.SampleService.Models.TripPin.Airport" Nullable="false" />
+ </Function>
+ <Action Name="ResetDataSource" />
+ <Action Name="ShareTrip" IsBound="true">
+ <Parameter Name="person" Type="Microsoft.OData.SampleService.Models.TripPin.Person" Nullable="false" />
+ <Parameter Name="userName" Type="Edm.String" Nullable="false" />
+ <Parameter Name="tripId" Type="Edm.Int32" Nullable="false" />
+ </Action>
+ <EntityContainer Name="DefaultContainer">
+ <EntitySet Name="Photos" EntityType="Microsoft.OData.SampleService.Models.TripPin.Photo">
+ <Annotation Term="Org.OData.Core.V1.ResourcePath" String="Photos" />
+ <Annotation Term="Org.OData.Capabilities.V1.SearchRestrictions">
+ <Record>
+ <PropertyValue Property="Searchable" Bool="true" />
+ <PropertyValue Property="UnsupportedExpressions">
+ <EnumMember>Org.OData.Capabilities.V1.SearchExpressions/none</EnumMember>
+ </PropertyValue>
+ </Record>
+ </Annotation>
+ <Annotation Term="Org.OData.Capabilities.V1.InsertRestrictions">
+ <Record>
+ <PropertyValue Property="Insertable" Bool="true" />
+ <PropertyValue Property="NonInsertableNavigationProperties">
+ <Collection />
+ </PropertyValue>
+ </Record>
+ </Annotation>
+ </EntitySet>
+ <EntitySet Name="People" EntityType="Microsoft.OData.SampleService.Models.TripPin.Person">
+ <NavigationPropertyBinding Path="Friends" Target="People" />
+ <NavigationPropertyBinding Path="Microsoft.OData.SampleService.Models.TripPin.Flight/Airline" Target="Airlines" />
+ <NavigationPropertyBinding Path="Microsoft.OData.SampleService.Models.TripPin.Flight/From" Target="Airports" />
+ <NavigationPropertyBinding Path="Microsoft.OData.SampleService.Models.TripPin.Flight/To" Target="Airports" />
+ <NavigationPropertyBinding Path="Photo" Target="Photos" />
+ <NavigationPropertyBinding Path="Microsoft.OData.SampleService.Models.TripPin.Trip/Photos" Target="Photos" />
+ <Annotation Term="Org.OData.Core.V1.OptimisticConcurrency">
+ <Collection>
+ <PropertyPath>Concurrency</PropertyPath>
+ </Collection>
+ </Annotation>
+ <Annotation Term="Org.OData.Core.V1.ResourcePath" String="People" />
+ <Annotation Term="Org.OData.Capabilities.V1.NavigationRestrictions">
+ <Record>
+ <PropertyValue Property="Navigability">
+ <EnumMember>Org.OData.Capabilities.V1.NavigationType/None</EnumMember>
+ </PropertyValue>
+ <PropertyValue Property="RestrictedProperties">
+ <Collection>
+ <Record>
+ <PropertyValue Property="NavigationProperty" NavigationPropertyPath="Friends" />
+ <PropertyValue Property="Navigability">
+ <EnumMember>Org.OData.Capabilities.V1.NavigationType/Recursive</EnumMember>
+ </PropertyValue>
+ </Record>
+ </Collection>
+ </PropertyValue>
+ </Record>
+ </Annotation>
+ <Annotation Term="Org.OData.Capabilities.V1.SearchRestrictions">
+ <Record>
+ <PropertyValue Property="Searchable" Bool="true" />
+ <PropertyValue Property="UnsupportedExpressions">
+ <EnumMember>Org.OData.Capabilities.V1.SearchExpressions/none</EnumMember>
+ </PropertyValue>
+ </Record>
+ </Annotation>
+ <Annotation Term="Org.OData.Capabilities.V1.InsertRestrictions">
+ <Record>
+ <PropertyValue Property="Insertable" Bool="true" />
+ <PropertyValue Property="NonInsertableNavigationProperties">
+ <Collection>
+ <NavigationPropertyPath>Trips</NavigationPropertyPath>
+ <NavigationPropertyPath>Friends</NavigationPropertyPath>
+ </Collection>
+ </PropertyValue>
+ </Record>
+ </Annotation>
+ </EntitySet>
+ <EntitySet Name="Airlines" EntityType="Microsoft.OData.SampleService.Models.TripPin.Airline">
+ <Annotation Term="Org.OData.Core.V1.ResourcePath" String="Airlines" />
+ <Annotation Term="Org.OData.Capabilities.V1.SearchRestrictions">
+ <Record>
+ <PropertyValue Property="Searchable" Bool="true" />
+ <PropertyValue Property="UnsupportedExpressions">
+ <EnumMember>Org.OData.Capabilities.V1.SearchExpressions/none</EnumMember>
+ </PropertyValue>
+ </Record>
+ </Annotation>
+ <Annotation Term="Org.OData.Capabilities.V1.InsertRestrictions">
+ <Record>
+ <PropertyValue Property="Insertable" Bool="true" />
+ <PropertyValue Property="NonInsertableNavigationProperties">
+ <Collection />
+ </PropertyValue>
+ </Record>
+ </Annotation>
+ </EntitySet>
+ <EntitySet Name="Airports" EntityType="Microsoft.OData.SampleService.Models.TripPin.Airport">
+ <Annotation Term="Org.OData.Core.V1.ResourcePath" String="Airports" />
+ <Annotation Term="Org.OData.Capabilities.V1.SearchRestrictions">
+ <Record>
+ <PropertyValue Property="Searchable" Bool="true" />
+ <PropertyValue Property="UnsupportedExpressions">
+ <EnumMember>Org.OData.Capabilities.V1.SearchExpressions/none</EnumMember>
+ </PropertyValue>
+ </Record>
+ </Annotation>
+ <Annotation Term="Org.OData.Capabilities.V1.InsertRestrictions">
+ <Record>
+ <PropertyValue Property="Insertable" Bool="false" />
+ <PropertyValue Property="NonInsertableNavigationProperties">
+ <Collection />
+ </PropertyValue>
+ </Record>
+ </Annotation>
+ <Annotation Term="Org.OData.Capabilities.V1.DeleteRestrictions">
+ <Record>
+ <PropertyValue Property="Deletable" Bool="false" />
+ <PropertyValue Property="NonDeletableNavigationProperties">
+ <Collection />
+ </PropertyValue>
+ </Record>
+ </Annotation>
+ </EntitySet>
+ <Singleton Name="Me" Type="Microsoft.OData.SampleService.Models.TripPin.Person">
+ <NavigationPropertyBinding Path="Friends" Target="People" />
+ <NavigationPropertyBinding Path="Microsoft.OData.SampleService.Models.TripPin.Flight/Airline" Target="Airlines" />
+ <NavigationPropertyBinding Path="Microsoft.OData.SampleService.Models.TripPin.Flight/From" Target="Airports" />
+ <NavigationPropertyBinding Path="Microsoft.OData.SampleService.Models.TripPin.Flight/To" Target="Airports" />
+ <NavigationPropertyBinding Path="Photo" Target="Photos" />
+ <NavigationPropertyBinding Path="Microsoft.OData.SampleService.Models.TripPin.Trip/Photos" Target="Photos" />
+ <Annotation Term="Org.OData.Core.V1.ResourcePath" String="Me" />
+ </Singleton>
+ <FunctionImport Name="GetNearestAirport" Function="Microsoft.OData.SampleService.Models.TripPin.GetNearestAirport" EntitySet="Airports" IncludeInServiceDocument="true">
+ <Annotation Term="Org.OData.Core.V1.ResourcePath" String="Microsoft.OData.SampleService.Models.TripPin.GetNearestAirport" />
+ </FunctionImport>
+ <ActionImport Name="ResetDataSource" Action="Microsoft.OData.SampleService.Models.TripPin.ResetDataSource" />
+ <Annotation Term="Org.OData.Core.V1.Description" String="TripPin service is a sample service for OData V4." />
+ </EntityContainer>
+ <Annotations Target="Microsoft.OData.SampleService.Models.TripPin.DefaultContainer">
+ <Annotation Term="Org.OData.Core.V1.DereferenceableIDs" Bool="true" />
+ <Annotation Term="Org.OData.Core.V1.ConventionalIDs" Bool="true" />
+ <Annotation Term="Org.OData.Capabilities.V1.ConformanceLevel">
+ <EnumMember>Org.OData.Capabilities.V1.ConformanceLevelType/Advanced</EnumMember>
+ </Annotation>
+ <Annotation Term="Org.OData.Capabilities.V1.SupportedFormats">
+ <Collection>
+ <String>application/json;odata.metadata=full;IEEE754Compatible=false;odata.streaming=true</String>
+ <String>application/json;odata.metadata=minimal;IEEE754Compatible=false;odata.streaming=true</String>
+ <String>application/json;odata.metadata=none;IEEE754Compatible=false;odata.streaming=true</String>
+ </Collection>
+ </Annotation>
+ <Annotation Term="Org.OData.Capabilities.V1.AsynchronousRequestsSupported" Bool="true" />
+ <Annotation Term="Org.OData.Capabilities.V1.BatchContinueOnErrorSupported" Bool="false" />
+ <Annotation Term="Org.OData.Capabilities.V1.FilterFunctions">
+ <Collection>
+ <String>contains</String>
+ <String>endswith</String>
+ <String>startswith</String>
+ <String>length</String>
+ <String>indexof</String>
+ <String>substring</String>
+ <String>tolower</String>
+ <String>toupper</String>
+ <String>trim</String>
+ <String>concat</String>
+ <String>year</String>
+ <String>month</String>
+ <String>day</String>
+ <String>hour</String>
+ <String>minute</String>
+ <String>second</String>
+ <String>round</String>
+ <String>floor</String>
+ <String>ceiling</String>
+ <String>cast</String>
+ <String>isof</String>
+ </Collection>
+ </Annotation>
+ </Annotations>
+ </Schema>
+ </edmx:DataServices>
+</edmx:Edmx>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8668b097/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
index a15d84a..a1c42ad 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
@@ -20,6 +20,8 @@ package org.apache.olingo.server.core.deserializer.json;
import java.io.IOException;
import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -62,6 +64,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
public class ODataJsonDeserializer implements ODataDeserializer {
@@ -259,8 +262,8 @@ public class ODataJsonDeserializer implements ODataDeserializer {
node.remove(toRemove);
}
- private void consumeEntityProperties(final EdmEntityType edmEntityType, final ObjectNode node, final EntityImpl
- entity) throws DeserializerException {
+ private void consumeEntityProperties(final EdmEntityType edmEntityType, final ObjectNode node,
+ final EntityImpl entity) throws DeserializerException {
List<String> propertyNames = edmEntityType.getPropertyNames();
for (String propertyName : propertyNames) {
JsonNode jsonNode = node.get(propertyName);
@@ -401,7 +404,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
case ENUM:
value = readEnumValue(name, type, isNullable, maxLength, precision, scale, isUnicode, mapping,
jsonNode);
- property.setValue(ValueType.PRIMITIVE, value);
+ property.setValue(ValueType.ENUM, value);
break;
case COMPLEX:
value = readComplexNode(name, type, isNullable, jsonNode);
@@ -698,4 +701,81 @@ public class ODataJsonDeserializer implements ODataDeserializer {
DeserializerException.MessageKeys.NOT_IMPLEMENTED);
}
}
+
+ @Override
+ public Property property(InputStream stream, EdmProperty edmProperty)
+ throws DeserializerException {
+ try {
+ ObjectMapper objectMapper = new ObjectMapper();
+ objectMapper.configure(DeserializationFeature.FAIL_ON_READING_DUP_TREE_KEY, true);
+ JsonParser parser = new JsonFactory(objectMapper).createParser(stream);
+ final ObjectNode tree = parser.getCodec().readTree(parser);
+
+ Property property = null;
+ JsonNode jsonNode = tree.get(Constants.VALUE);
+ if (jsonNode != null) {
+ property = consumePropertyNode(edmProperty.getName(), edmProperty.getType(),
+ edmProperty.isCollection(),
+ edmProperty.isNullable(), edmProperty.getMaxLength(), edmProperty.getPrecision(), edmProperty.getScale(),
+ edmProperty.isUnicode(), edmProperty.getMapping(),
+ jsonNode);
+ tree.remove(Constants.VALUE);
+ } else {
+ property = consumePropertyNode(edmProperty.getName(), edmProperty.getType(),
+ edmProperty.isCollection(),
+ edmProperty.isNullable(), edmProperty.getMaxLength(), edmProperty.getPrecision(), edmProperty.getScale(),
+ edmProperty.isUnicode(), edmProperty.getMapping(),
+ tree);
+ }
+ return property;
+ } catch (JsonParseException e) {
+ throw new DeserializerException("An JsonParseException occurred", e,
+ DeserializerException.MessageKeys.JSON_SYNTAX_EXCEPTION);
+ } catch (JsonMappingException e) {
+ throw new DeserializerException("Duplicate property detected", e,
+ DeserializerException.MessageKeys.DUPLICATE_PROPERTY);
+ } catch (IOException e) {
+ throw new DeserializerException("An IOException occurred", e, DeserializerException.MessageKeys.IO_EXCEPTION);
+ }
+ }
+
+ public List<URI> entityReferences(InputStream stream) throws DeserializerException {
+ try {
+ ArrayList<URI> parsedValues = new ArrayList<URI>();
+ ObjectMapper objectMapper = new ObjectMapper();
+ objectMapper.configure(DeserializationFeature.FAIL_ON_READING_DUP_TREE_KEY, true);
+ JsonParser parser = new JsonFactory(objectMapper).createParser(stream);
+ final ObjectNode tree = parser.getCodec().readTree(parser);
+ final String key = "@odata.id";
+ JsonNode jsonNode = tree.get(Constants.VALUE);
+ if (jsonNode != null) {
+ if (jsonNode.isArray()) {
+ ArrayNode arrayNode = (ArrayNode)jsonNode;
+ Iterator<JsonNode> it = arrayNode.iterator();
+ while(it.hasNext()) {
+ parsedValues.add(new URI(it.next().get(key).asText()));
+ }
+ } else {
+ parsedValues.add(new URI(jsonNode.asText()));
+ }
+ tree.remove(Constants.VALUE);
+ // if this is value there can be only one property
+ return parsedValues;
+ }
+ parsedValues.add(new URI(tree.get(key).asText()));
+ return parsedValues;
+ } catch (JsonParseException e) {
+ throw new DeserializerException("An JsonParseException occurred", e,
+ DeserializerException.MessageKeys.JSON_SYNTAX_EXCEPTION);
+ } catch (JsonMappingException e) {
+ throw new DeserializerException("Duplicate property detected", e,
+ DeserializerException.MessageKeys.DUPLICATE_PROPERTY);
+ } catch (IOException e) {
+ throw new DeserializerException("An IOException occurred", e,
+ DeserializerException.MessageKeys.IO_EXCEPTION);
+ } catch (URISyntaxException e) {
+ throw new DeserializerException("failed to read @odata.id", e,
+ DeserializerException.MessageKeys.UNKOWN_CONTENT);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8668b097/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
index aab6624..5956e82 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -41,6 +41,7 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.EdmProperty;
import org.apache.olingo.commons.api.edm.EdmStructuredType;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
import org.apache.olingo.server.api.ODataServerError;
@@ -127,7 +128,8 @@ public class ODataJsonSerializer implements ODataSerializer {
}
@Override
- public InputStream entityCollection(final EdmEntityType entityType, final EntitySet entitySet,
+ public InputStream entityCollection(final ServiceMetadata metadata,
+ final EdmEntityType entityType, final EntitySet entitySet,
final EntityCollectionSerializerOptions options) throws SerializerException {
CircleStreamBuffer buffer = new CircleStreamBuffer();
try {
@@ -145,8 +147,9 @@ public class ODataJsonSerializer implements ODataSerializer {
json.writeNumberField(Constants.JSON_COUNT, entitySet.getCount());
}
json.writeFieldName(Constants.VALUE);
- writeEntitySet(entityType, entitySet,
- options == null ? null : options.getExpand(), options == null ? null : options.getSelect(), json);
+ writeEntitySet(metadata, entityType, entitySet, options == null ? null : options.getExpand(),
+ options == null ? null : options.getSelect(),
+ options == null ? false : options.onlyReferences(), json);
if (entitySet.getNext() != null) {
json.writeStringField(Constants.JSON_NEXT_LINK, entitySet.getNext().toASCIIString());
}
@@ -159,14 +162,16 @@ public class ODataJsonSerializer implements ODataSerializer {
}
@Override
- public InputStream entity(final EdmEntityType entityType, final Entity entity,
- final EntitySerializerOptions options) throws SerializerException {
+ public InputStream entity(final ServiceMetadata metadata, final EdmEntityType entityType,
+ final Entity entity, final EntitySerializerOptions options) throws SerializerException {
final ContextURL contextURL = checkContextURL(options == null ? null : options.getContextURL());
CircleStreamBuffer buffer = new CircleStreamBuffer();
try {
JsonGenerator json = new JsonFactory().createGenerator(buffer.getOutputStream());
- writeEntity(entityType, entity, contextURL,
- options == null ? null : options.getExpand(), options == null ? null : options.getSelect(), json);
+ writeEntity(metadata, entityType, entity, contextURL,
+ options == null ? null : options.getExpand(),
+ options == null ? null : options.getSelect(),
+ options == null ? false: options.onlyReferences(), json);
json.close();
} catch (final IOException e) {
throw new SerializerException("An I/O exception occurred.", e,
@@ -184,18 +189,26 @@ public class ODataJsonSerializer implements ODataSerializer {
return contextURL;
}
- protected void writeEntitySet(final EdmEntityType entityType, final EntitySet entitySet,
- final ExpandOption expand, final SelectOption select, final JsonGenerator json)
- throws IOException, SerializerException {
+ protected void writeEntitySet(final ServiceMetadata metadata, final EdmEntityType entityType,
+ final EntitySet entitySet, final ExpandOption expand, final SelectOption select,
+ final boolean onlyReference, final JsonGenerator json) throws IOException,
+ SerializerException {
json.writeStartArray();
for (final Entity entity : entitySet.getEntities()) {
- writeEntity(entityType, entity, null, expand, select, json);
+ if (onlyReference) {
+ json.writeStartObject();
+ json.writeStringField(Constants.JSON_ID, entity.getId().toASCIIString());
+ json.writeEndObject();
+ } else {
+ writeEntity(metadata, entityType, entity, null, expand, select, false, json);
+ }
}
json.writeEndArray();
}
- protected void writeEntity(final EdmEntityType entityType, final Entity entity, final ContextURL contextURL,
- final ExpandOption expand, final SelectOption select, final JsonGenerator json)
+ protected void writeEntity(final ServiceMetadata metadata, final EdmEntityType entityType,
+ final Entity entity, final ContextURL contextURL, final ExpandOption expand,
+ final SelectOption select, boolean onlyReference, final JsonGenerator json)
throws IOException, SerializerException {
json.writeStartObject();
if (format != ODataFormat.JSON_NO_METADATA) {
@@ -214,9 +227,63 @@ public class ODataJsonSerializer implements ODataSerializer {
}
}
}
- writeProperties(entityType, entity.getProperties(), select, json);
- writeNavigationProperties(entityType, entity, expand, json);
- json.writeEndObject();
+ if (onlyReference) {
+ json.writeStringField(Constants.JSON_ID, entity.getId().toASCIIString());
+ } else {
+ EdmEntityType resolvedType = resolveEntityType(metadata, entityType, entity.getType());
+ if (!resolvedType.equals(entityType)) {
+ json.writeStringField(Constants.JSON_TYPE, "#"+entity.getType());
+ }
+ writeProperties(resolvedType, entity.getProperties(), select, json);
+ writeNavigationProperties(metadata, resolvedType, entity, expand, json);
+ json.writeEndObject();
+ }
+ }
+
+ protected EdmEntityType resolveEntityType(ServiceMetadata metadata, EdmEntityType baseType,
+ String derivedTypeName) throws SerializerException {
+ if (baseType.getFullQualifiedName().getFullQualifiedNameAsString().equals(derivedTypeName)) {
+ return baseType;
+ }
+ EdmEntityType derivedType = metadata.getEdm().getEntityType(new FullQualifiedName(derivedTypeName));
+ if (derivedType == null) {
+ throw new SerializerException("EntityType not found",
+ SerializerException.MessageKeys.UNKNOWN_TYPE, derivedTypeName);
+ }
+ EdmEntityType type = derivedType.getBaseType();
+ while (type != null) {
+ if (type.getFullQualifiedName().getFullQualifiedNameAsString()
+ .equals(baseType.getFullQualifiedName().getFullQualifiedNameAsString())) {
+ return derivedType;
+ }
+ type = type.getBaseType();
+ }
+ throw new SerializerException("Wrong base type",
+ SerializerException.MessageKeys.WRONG_BASE_TYPE, derivedTypeName, baseType
+ .getFullQualifiedName().getFullQualifiedNameAsString());
+ }
+
+ protected EdmComplexType resolveComplexType(ServiceMetadata metadata, EdmComplexType baseType,
+ String derivedTypeName) throws SerializerException {
+ if (baseType.getFullQualifiedName().getFullQualifiedNameAsString().equals(derivedTypeName)) {
+ return baseType;
+ }
+ EdmComplexType derivedType = metadata.getEdm().getComplexType(new FullQualifiedName(derivedTypeName));
+ if (derivedType == null) {
+ throw new SerializerException("Complex Type not found",
+ SerializerException.MessageKeys.UNKNOWN_TYPE, derivedTypeName);
+ }
+ EdmComplexType type = derivedType.getBaseType();
+ while (type != null) {
+ if (type.getFullQualifiedName().getFullQualifiedNameAsString()
+ .equals(baseType.getFullQualifiedName().getFullQualifiedNameAsString())) {
+ return derivedType;
+ }
+ type = type.getBaseType();
+ }
+ throw new SerializerException("Wrong base type",
+ SerializerException.MessageKeys.WRONG_BASE_TYPE, derivedTypeName, baseType
+ .getFullQualifiedName().getFullQualifiedNameAsString());
}
protected void writeProperties(final EdmStructuredType type, final List<Property> properties,
@@ -235,8 +302,9 @@ public class ODataJsonSerializer implements ODataSerializer {
}
}
- protected void writeNavigationProperties(final EdmStructuredType type, final Linked linked,
- final ExpandOption expand, final JsonGenerator json) throws SerializerException, IOException {
+ protected void writeNavigationProperties(final ServiceMetadata metadata,
+ final EdmStructuredType type, final Linked linked, final ExpandOption expand,
+ final JsonGenerator json) throws SerializerException, IOException {
if (ExpandSelectHelper.hasExpand(expand)) {
final boolean expandAll = ExpandSelectHelper.isExpandAll(expand);
final Set<String> expanded = expandAll ? null :
@@ -251,7 +319,7 @@ public class ODataJsonSerializer implements ODataSerializer {
throw new SerializerException("Expand options $ref and $levels are not supported.",
SerializerException.MessageKeys.NOT_IMPLEMENTED);
}
- writeExpandedNavigationProperty(property, navigationLink,
+ writeExpandedNavigationProperty(metadata, property, navigationLink,
innerOptions == null ? null : innerOptions.getExpandOption(),
innerOptions == null ? null : innerOptions.getSelectOption(),
json);
@@ -260,7 +328,8 @@ public class ODataJsonSerializer implements ODataSerializer {
}
}
- protected void writeExpandedNavigationProperty(final EdmNavigationProperty property, final Link navigationLink,
+ protected void writeExpandedNavigationProperty(final ServiceMetadata metadata,
+ final EdmNavigationProperty property, final Link navigationLink,
final ExpandOption innerExpand, final SelectOption innerSelect, JsonGenerator json)
throws IOException, SerializerException {
json.writeFieldName(property.getName());
@@ -269,13 +338,15 @@ public class ODataJsonSerializer implements ODataSerializer {
json.writeStartArray();
json.writeEndArray();
} else {
- writeEntitySet(property.getType(), navigationLink.getInlineEntitySet(), innerExpand, innerSelect, json);
+ writeEntitySet(metadata, property.getType(), navigationLink.getInlineEntitySet(), innerExpand,
+ innerSelect, false, json);
}
} else {
if (navigationLink == null || navigationLink.getInlineEntity() == null) {
json.writeNull();
} else {
- writeEntity(property.getType(), navigationLink.getInlineEntity(), null, innerExpand, innerSelect, json);
+ writeEntity(metadata, property.getType(), navigationLink.getInlineEntity(), null,
+ innerExpand, innerSelect, false, json);
}
}
}
@@ -316,6 +387,11 @@ public class ODataJsonSerializer implements ODataSerializer {
} else if (property.isComplex()) {
writeComplexValue((EdmComplexType) edmProperty.getType(), property.asComplex().getValue(),
selectedPaths, json);
+ } else if (property.isEnum()) {
+ writePrimitive((EdmPrimitiveType) edmProperty.getType(), property,
+ edmProperty.isNullable(), edmProperty.getMaxLength(),
+ edmProperty.getPrecision(), edmProperty.getScale(), edmProperty.isUnicode(),
+ json);
} else {
throw new SerializerException("Property type not yet supported!",
SerializerException.MessageKeys.UNSUPPORTED_PROPERTY_TYPE, edmProperty.getName());
@@ -467,8 +543,8 @@ public class ODataJsonSerializer implements ODataSerializer {
}
@Override
- public InputStream complex(final EdmComplexType type, final Property property,
- final ComplexSerializerOptions options) throws SerializerException {
+ public InputStream complex(final ServiceMetadata metadata, final EdmComplexType type,
+ final Property property, final ComplexSerializerOptions options) throws SerializerException {
final ContextURL contextURL = checkContextURL(options == null ? null : options.getContextURL());
CircleStreamBuffer buffer = new CircleStreamBuffer();
try {
@@ -477,11 +553,15 @@ public class ODataJsonSerializer implements ODataSerializer {
if (contextURL != null) {
json.writeStringField(Constants.JSON_CONTEXT, ContextURLBuilder.create(contextURL).toASCIIString());
}
+ EdmComplexType resolvedType = resolveComplexType(metadata, type, property.getType());
+ if (!resolvedType.equals(type)) {
+ json.writeStringField(Constants.JSON_TYPE, "#"+property.getType());
+ }
final List<Property> values =
property.isNull() ? Collections.<Property> emptyList() : property.asComplex().getValue();
writeProperties(type, values, options == null ? null : options.getSelect(), json);
if (!property.isNull() && property.isComplex()) {
- writeNavigationProperties(type, property.asComplex(),
+ writeNavigationProperties(metadata, type, property.asComplex(),
options == null ? null : options.getExpand(), json);
}
json.writeEndObject();
@@ -523,8 +603,8 @@ public class ODataJsonSerializer implements ODataSerializer {
}
@Override
- public InputStream complexCollection(final EdmComplexType type, final Property property,
- final ComplexSerializerOptions options) throws SerializerException {
+ public InputStream complexCollection(final ServiceMetadata metadata, final EdmComplexType type,
+ final Property property, final ComplexSerializerOptions options) throws SerializerException {
final ContextURL contextURL = checkContextURL(options == null ? null : options.getContextURL());
CircleStreamBuffer buffer = new CircleStreamBuffer();
try {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8668b097/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ContextURLBuilder.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ContextURLBuilder.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ContextURLBuilder.java
index 4a3f82a..ac33759 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ContextURLBuilder.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ContextURLBuilder.java
@@ -66,7 +66,14 @@ public final class ContextURLBuilder {
if (contextURL.getEntitySetOrSingletonOrType() != null) {
throw new IllegalArgumentException("ContextURL: $ref with Entity Set");
}
- result.append('#').append(ContextURL.Suffix.REFERENCE.getRepresentation());
+ if(contextURL.isCollection()) {
+ result.append('#');
+ result.append("Collection(")
+ .append(ContextURL.Suffix.REFERENCE.getRepresentation())
+ .append(")");
+ } else {
+ result.append('#').append(ContextURL.Suffix.REFERENCE.getRepresentation());
+ }
} else if (contextURL.getSuffix() != null) {
if (contextURL.getEntitySetOrSingletonOrType() == null) {
throw new IllegalArgumentException("ContextURL: Suffix without preceding Entity Set!");
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8668b097/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializerImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializerImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializerImpl.java
index acd1ded..34756c1 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializerImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializerImpl.java
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -87,14 +87,15 @@ public class ODataXmlSerializerImpl implements ODataSerializer {
}
@Override
- public InputStream entity(final EdmEntityType entityType, final Entity entity,
- final EntitySerializerOptions options) throws SerializerException {
+ public InputStream entity(final ServiceMetadata metadata, final EdmEntityType entityType,
+ final Entity entity, final EntitySerializerOptions options) throws SerializerException {
throw new SerializerException("Entity serialization not implemented for XML format",
SerializerException.MessageKeys.NOT_IMPLEMENTED);
}
@Override
- public InputStream entityCollection(final EdmEntityType entityType, final EntitySet entitySet,
+ public InputStream entityCollection(final ServiceMetadata metadata,
+ final EdmEntityType entityType, final EntitySet entitySet,
final EntityCollectionSerializerOptions options) throws SerializerException {
throw new SerializerException("Entityset serialization not implemented for XML format",
SerializerException.MessageKeys.NOT_IMPLEMENTED);
@@ -114,8 +115,8 @@ public class ODataXmlSerializerImpl implements ODataSerializer {
}
@Override
- public InputStream complex(final EdmComplexType type, final Property property,
- final ComplexSerializerOptions options) throws SerializerException {
+ public InputStream complex(final ServiceMetadata metadata, final EdmComplexType type,
+ final Property property, final ComplexSerializerOptions options) throws SerializerException {
throw new SerializerException("Serialization not implemented for XML format.",
SerializerException.MessageKeys.NOT_IMPLEMENTED);
}
@@ -128,8 +129,8 @@ public class ODataXmlSerializerImpl implements ODataSerializer {
}
@Override
- public InputStream complexCollection(final EdmComplexType type, final Property property,
- final ComplexSerializerOptions options) throws SerializerException {
+ public InputStream complexCollection(final ServiceMetadata metadata, final EdmComplexType type,
+ final Property property, final ComplexSerializerOptions options) throws SerializerException {
throw new SerializerException("Serialization not implemented for XML format.",
SerializerException.MessageKeys.NOT_IMPLEMENTED);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8668b097/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceActionImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceActionImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceActionImpl.java
index 82fe743..a78d79f 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceActionImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceActionImpl.java
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -56,12 +56,18 @@ public class UriResourceActionImpl extends UriResourceTypedImpl implements UriRe
@Override
public boolean isCollection() {
- return action.getReturnType() !=null && action.getReturnType().isCollection();
+ if (action.getReturnType() != null) {
+ return action.getReturnType().isCollection();
+ }
+ return false;
}
@Override
public EdmType getType() {
- return action.getReturnType() == null ? null : action.getReturnType().getType();
+ if (action.getReturnType() != null) {
+ return action.getReturnType().getType();
+ }
+ return null;
}
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8668b097/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidator.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidator.java
index 0b3a5f9..cf54938 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidator.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidator.java
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -60,7 +60,7 @@ public class UriValidator {
/* entitySetCount 7 */ { true , false, false, false, false, false, true, false, false, false, false },
/* entity 8 */ { false, true , true , false, false, false, false, true , false, false, false },
/* mediaStream 9 */ { false, false, false, false, false, false, false, false, false, false, false },
- /* references 10 */ { true , true , false, false, false, true , true , false, true , true , true },
+ /* references 10 */ { true , true , false, true, false, true , true , false, true , true , true },
/* reference 11 */ { false, true , false, false, false, false, false, false, false, false, false },
/* propertyComplex 12 */ { false, true , true , false, false, false, false, true , false, false, false },
/* propertyComplexCollection 13 */ { true , true , true , false, true , true , false, true , true , true , true },
@@ -78,7 +78,7 @@ public class UriValidator {
/* GET 0 */ { true , true , true , true, true , true , true , true , true , true , true },
/* POST 0 */ { true , false , true , false, false , true , false , true , false , false , false },
/* PUT 0 */ { false , false , false , false, false , false , false , false , false , false , false },
- /* DELETE 0 */ { false , false , false , false, false , false, false , false, false , false , false },
+ /* DELETE 0 */ { false , false , false , true, false , false, false , false, false , false , false },
/* PATCH 0 */ { false , false , false , false, false , false , false , false , false , false , false }
};
//CHECKSTYLE:ON
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8668b097/lib/server-core/src/main/resources/server-core-exceptions-i18n.properties
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/resources/server-core-exceptions-i18n.properties b/lib/server-core/src/main/resources/server-core-exceptions-i18n.properties
index 76266ea..b8254c3 100644
--- a/lib/server-core/src/main/resources/server-core-exceptions-i18n.properties
+++ b/lib/server-core/src/main/resources/server-core-exceptions-i18n.properties
@@ -96,6 +96,8 @@ SerializerException.INCONSISTENT_PROPERTY_TYPE=An inconsistency has been detecte
SerializerException.MISSING_PROPERTY=The non-nullable property '%1$s' is missing.
SerializerException.WRONG_PROPERTY_VALUE=The value '%2$s' is not valid for property '%1$s'.
SerializerException.WRONG_PRIMITIVE_VALUE=The value '%2$s' is not valid for the primitive type '%1$s' and the given facets.
+SerializerException.UNKNOWN_TYPE=Type '%1s' not found in metadata.
+SerializerException.WRONG_BASE_TYPE=Type '%1s' is not derived from '%2s'.
DeserializerException.NOT_IMPLEMENTED=The requested deserialization method has not been implemented yet.
DeserializerException.IO_EXCEPTION=An I/O exception occurred.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8668b097/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerBasicTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerBasicTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerBasicTest.java
index f3e22ef..a301c3d 100644
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerBasicTest.java
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerBasicTest.java
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -18,8 +18,13 @@
*/
package org.apache.olingo.server.core.deserializer.json;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import java.io.ByteArrayInputStream;
+import java.net.URI;
+import java.util.List;
+
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.server.api.OData;
import org.apache.olingo.server.api.deserializer.ODataDeserializer;
@@ -41,4 +46,33 @@ public class ODataJsonDeserializerBasicTest {
assertNotNull(deserializer);
deserializer = null;
}
+
+ @Test
+ public void testReadingCollectionProperties() throws Exception {
+ String payload = "{\n" +
+ " \"@odata.context\": \"http://host/service/$metadata#Collection($ref)\",\n" +
+ " \"value\": [\n" +
+ " { \"@odata.id\": \"Orders(10643)\" },\n" +
+ " { \"@odata.id\": \"Orders(10759)\" }\n" +
+ " ]\n" +
+ "}";
+ ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
+ List<URI> values = deserializer.entityReferences(new ByteArrayInputStream(payload.getBytes()));
+ assertEquals(2, values.size());
+ assertEquals("Orders(10643)", values.get(0).toASCIIString());
+ assertEquals("Orders(10759)", values.get(1).toASCIIString());
+ }
+
+ @Test
+ public void testReadingProperties() throws Exception {
+ String payload = "{\n" +
+ " \"@odata.context\": \"http://host/service/$metadata#$ref\",\n" +
+ " \"@odata.id\": \"Orders(10643)\"\n" +
+ "}";
+ ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
+ List<URI> values = deserializer.entityReferences(new ByteArrayInputStream(payload
+ .getBytes()));
+ assertEquals(1, values.size());
+ assertEquals("Orders(10643)", values.get(0).toASCIIString());
+ }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8668b097/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
index 742c5d5..1e4537f 100644
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -49,14 +49,17 @@ public class ODataJsonSerializerTest {
final ODataJsonSerializer serializer = new ODataJsonSerializer(ODataFormat.APPLICATION_JSON);
final ComplexSerializerOptions options = ComplexSerializerOptions.with()
.contextURL(ContextURL.with().selectList("ComplexCollection").build()).build();
- final InputStream in = serializer.complexCollection(ComplexTypeHelper.createType(), complexCollection, options);
+ final InputStream in = serializer.complexCollection(null, ComplexTypeHelper.createType(),
+ complexCollection, options);
final BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String line;
while ((line = reader.readLine()) != null) {
if (line.contains("value")) {
- assertEquals("{\"@odata.context\":\"$metadata(ComplexCollection)\",\"value\":"
- + "[{\"prop1\":\"test1\",\"prop2\":\"test11\"},{\"prop1\":\"test2\",\"prop2\":\"test22\"}]}", line);
+ assertEquals(
+ "{\"@odata.context\":\"$metadata(ComplexCollection)\",\"value\":"
+ + "[{\"prop1\":\"test1\",\"prop2\":\"test11\"},{\"prop1\":\"test2\",\"prop2\":\"test22\"}]}",
+ line);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8668b097/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java
index 7fa981b..4137db0 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -66,8 +66,8 @@ public class TechnicalServlet extends HttpServlet {
}
ODataHttpHandler handler = odata.createHandler(serviceMetadata);
- handler.register(new TechnicalEntityProcessor(dataProvider));
- handler.register(new TechnicalPrimitiveComplexProcessor(dataProvider));
+ handler.register(new TechnicalEntityProcessor(dataProvider, serviceMetadata));
+ handler.register(new TechnicalPrimitiveComplexProcessor(dataProvider, serviceMetadata));
handler.register(new TechnicalBatchProcessor(dataProvider));
handler.process(req, resp);
} catch (RuntimeException e) {