Various small improvements, added test for instance annotations
This commit is contained in:
parent
c32f4a0bb1
commit
8720a30e21
|
@ -345,6 +345,17 @@ public class V4Services extends AbstractServices {
|
||||||
return new ByteArrayInputStream(bos.toByteArray());
|
return new ByteArrayInputStream(bos.toByteArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/Boss")
|
||||||
|
public Response getSingletonBoss(
|
||||||
|
@Context UriInfo uriInfo,
|
||||||
|
@HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
|
||||||
|
@QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
|
||||||
|
|
||||||
|
return getEntityInternal(
|
||||||
|
uriInfo.getRequestUri().toASCIIString(), accept, "Boss", StringUtils.EMPTY, format, null, null, false);
|
||||||
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/Company")
|
@Path("/Company")
|
||||||
public Response getSingletonCompany(
|
public Response getSingletonCompany(
|
||||||
|
|
|
@ -125,6 +125,8 @@ public class DataBinder {
|
||||||
properties.add(toJSONProperty((AtomPropertyImpl) property));
|
properties.add(toJSONProperty((AtomPropertyImpl) property));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jsonEntity.getAnnotations().addAll(atomEntity.getAnnotations());
|
||||||
|
|
||||||
return jsonEntity;
|
return jsonEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
{
|
||||||
|
"@odata.context": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/$metadata#Boss",
|
||||||
|
"@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.Customer",
|
||||||
|
"@odata.id": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Boss",
|
||||||
|
"@odata.editLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Boss/Microsoft.Test.OData.Services.ODataWCFService.Customer",
|
||||||
|
"@Microsoft.Test.OData.Services.ODataWCFService.IsBoss": true,
|
||||||
|
"PersonID": 2,
|
||||||
|
"FirstName": "Jill",
|
||||||
|
"LastName": "Jones",
|
||||||
|
"MiddleName": null,
|
||||||
|
"HomeAddress": null,
|
||||||
|
"Home@odata.type": "#GeographyPoint",
|
||||||
|
"Home": {
|
||||||
|
"type": "Point",
|
||||||
|
"coordinates": [161.8, 15.0],
|
||||||
|
"crs": {
|
||||||
|
"type": "name",
|
||||||
|
"properties": {
|
||||||
|
"name": "EPSG:4326"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Numbers@odata.type": "#Collection(String)",
|
||||||
|
"Numbers": [],
|
||||||
|
"Emails@odata.type": "#Collection(String)",
|
||||||
|
"Emails": [],
|
||||||
|
"City": "Sydney",
|
||||||
|
"Birthday@odata.type": "#DateTimeOffset",
|
||||||
|
"Birthday": "1983-01-15T00:00:00Z",
|
||||||
|
"TimeBetweenLastTwoOrders@odata.type": "#Duration",
|
||||||
|
"TimeBetweenLastTwoOrders": "PT0.0000002S",
|
||||||
|
"Parent@odata.associationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Boss/Microsoft.Test.OData.Services.ODataWCFService.Customer/Parent/$ref",
|
||||||
|
"Parent@odata.navigationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Boss/Microsoft.Test.OData.Services.ODataWCFService.Customer/Parent",
|
||||||
|
"Orders@odata.associationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Boss/Microsoft.Test.OData.Services.ODataWCFService.Customer/Orders/$ref",
|
||||||
|
"Orders@odata.navigationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Boss/Microsoft.Test.OData.Services.ODataWCFService.Customer/Orders",
|
||||||
|
"Company@odata.associationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Boss/Microsoft.Test.OData.Services.ODataWCFService.Customer/Company/$ref",
|
||||||
|
"Company@odata.navigationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Boss/Microsoft.Test.OData.Services.ODataWCFService.Customer/Company",
|
||||||
|
"#Microsoft.Test.OData.Services.ODataWCFService.ResetAddress": {
|
||||||
|
"title": "Microsoft.Test.OData.Services.ODataWCFService.ResetAddress",
|
||||||
|
"target": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Boss/Microsoft.Test.OData.Services.ODataWCFService.Customer/Microsoft.Test.OData.Services.ODataWCFService.ResetAddress"
|
||||||
|
},
|
||||||
|
"#Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress": {
|
||||||
|
"title": "Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress",
|
||||||
|
"target": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Boss/Microsoft.Test.OData.Services.ODataWCFService.Customer/Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
<?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.
|
||||||
|
|
||||||
|
-->
|
||||||
|
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:m="http://docs.oasis-open.org/odata/ns/metadata" xmlns:d="http://docs.oasis-open.org/odata/ns/data" xmlns:gml="http://www.opengis.net/gml" xmlns:georss="http://www.georss.org/georss">
|
||||||
|
<id>http://localhost:9080/stub/StaticService/V40/Static.svc/Boss</id>
|
||||||
|
<category scheme="http://docs.oasis-open.org/odata/ns/scheme" term="#Microsoft.Test.OData.Services.ODataWCFService.Customer"/>
|
||||||
|
<link rel="http://docs.oasis-open.org/odata/ns/relatedlinks/Parent" title="Parent" href="http://localhost:9080/stub/StaticService/V40/Static.svc/Boss/Microsoft.Test.OData.Services.ODataWCFService.Customer/Parent/$ref" type="application/xml"/>
|
||||||
|
<link rel="http://docs.oasis-open.org/odata/ns/relatedlinks/Orders" title="Orders" href="http://localhost:9080/stub/StaticService/V40/Static.svc/Boss/Microsoft.Test.OData.Services.ODataWCFService.Customer/Orders/$ref" type="application/xml"/>
|
||||||
|
<link rel="http://docs.oasis-open.org/odata/ns/relatedlinks/Company" title="Company" href="http://localhost:9080/stub/StaticService/V40/Static.svc/Boss/Microsoft.Test.OData.Services.ODataWCFService.Customer/Company/$ref" type="application/xml"/>
|
||||||
|
<link rel="http://docs.oasis-open.org/odata/ns/related/Parent" title="Parent" href="http://localhost:9080/stub/StaticService/V40/Static.svc/Boss/Microsoft.Test.OData.Services.ODataWCFService.Customer/Parent" type="application/atom+xml;type=entry"/>
|
||||||
|
<link rel="http://docs.oasis-open.org/odata/ns/related/Orders" title="Orders" href="http://localhost:9080/stub/StaticService/V40/Static.svc/Boss/Microsoft.Test.OData.Services.ODataWCFService.Customer/Orders" type="application/atom+xml;type=entry"/>
|
||||||
|
<link rel="http://docs.oasis-open.org/odata/ns/related/Company" title="Company" href="http://localhost:9080/stub/StaticService/V40/Static.svc/Boss/Microsoft.Test.OData.Services.ODataWCFService.Customer/Company" type="application/atom+xml;type=entry"/>
|
||||||
|
<content type="application/xml">
|
||||||
|
<m:properties>
|
||||||
|
<d:PersonID m:type="Int32">2</d:PersonID>
|
||||||
|
<d:FirstName>Jill</d:FirstName>
|
||||||
|
<d:LastName>Jones</d:LastName>
|
||||||
|
<d:MiddleName m:null="true"/>
|
||||||
|
<d:HomeAddress m:null="true"/>
|
||||||
|
<d:Home m:type="GeographyPoint">
|
||||||
|
<gml:Point gml:srsName="http://www.opengis.net/def/crs/EPSG/0/4326">
|
||||||
|
<gml:pos>161.8 15.0</gml:pos>
|
||||||
|
</gml:Point>
|
||||||
|
</d:Home>
|
||||||
|
<d:Numbers m:type="#Collection(String)"/>
|
||||||
|
<d:Emails m:type="#Collection(String)"/>
|
||||||
|
<d:City>Sydney</d:City>
|
||||||
|
<d:Birthday m:type="DateTimeOffset">1983-01-15T01:00:00+01:00</d:Birthday>
|
||||||
|
<d:TimeBetweenLastTwoOrders m:type="Duration">PT0.0000002S</d:TimeBetweenLastTwoOrders>
|
||||||
|
</m:properties>
|
||||||
|
</content>
|
||||||
|
<m:annotation term="Microsoft.Test.OData.Services.ODataWCFService.IsBoss" m:type="Boolean">true</m:annotation>
|
||||||
|
</entry>
|
|
@ -1,35 +1,24 @@
|
||||||
{
|
{
|
||||||
|
|
||||||
"error": {
|
"error": {
|
||||||
|
|
||||||
"code": "400",
|
"code": "400",
|
||||||
|
|
||||||
"message": "Bad request.",
|
"message": "Bad request.",
|
||||||
|
|
||||||
"target": "query",
|
"target": "query",
|
||||||
|
|
||||||
"details": [
|
"details": [
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
"code": "400",
|
"code": "400",
|
||||||
|
|
||||||
"target": "$search",
|
"target": "$search",
|
||||||
|
|
||||||
"message": "Microsoft.Data.OData.BadRequest"
|
"message": "Microsoft.Data.OData.BadRequest"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
"innererror": {
|
"innererror": {
|
||||||
|
|
||||||
"trace": ["at Microsoft.Data.OData.MediaTypeUtils.GetContentTypeFromSettings....", "callmethod2 etc"],
|
"trace": ["at Microsoft.Data.OData.MediaTypeUtils.GetContentTypeFromSettings....", "callmethod2 etc"],
|
||||||
|
"context": {
|
||||||
"context": {"key1":"for debug deployment only"}
|
"key1": "for debug deployment only"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">
|
<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">
|
||||||
<edmx:DataServices>
|
<edmx:DataServices>
|
||||||
<Schema Namespace="Microsoft.Test.OData.Services.ODataWCFService" xmlns="http://docs.oasis-open.org/odata/ns/edm">
|
<Schema Namespace="Microsoft.Test.OData.Services.ODataWCFService" xmlns="http://docs.oasis-open.org/odata/ns/edm">
|
||||||
|
<Term Name="IsBoss" Type="Edm.Boolean"/>
|
||||||
<ComplexType Name="Address">
|
<ComplexType Name="Address">
|
||||||
<Property Name="Street" Type="Edm.String" Nullable="false"/>
|
<Property Name="Street" Type="Edm.String" Nullable="false"/>
|
||||||
<Property Name="City" Type="Edm.String" Nullable="false"/>
|
<Property Name="City" Type="Edm.String" Nullable="false"/>
|
||||||
|
@ -32,7 +33,6 @@
|
||||||
</ComplexType>
|
</ComplexType>
|
||||||
<ComplexType Name="CompanyAddress" BaseType="Microsoft.Test.OData.Services.ODataWCFService.Address">
|
<ComplexType Name="CompanyAddress" BaseType="Microsoft.Test.OData.Services.ODataWCFService.Address">
|
||||||
<Property Name="CompanyName" Type="Edm.String" Nullable="false"/>
|
<Property Name="CompanyName" Type="Edm.String" Nullable="false"/>
|
||||||
<NavigationProperty Name="Contact" Type="Microsoft.Test.OData.Services.ODataWCFService.Person" Nullable="true" />
|
|
||||||
</ComplexType>
|
</ComplexType>
|
||||||
<EnumType Name="AccessLevel" IsFlags="true">
|
<EnumType Name="AccessLevel" IsFlags="true">
|
||||||
<Member Name="None" Value="0"/>
|
<Member Name="None" Value="0"/>
|
||||||
|
@ -155,9 +155,10 @@
|
||||||
</Key>
|
</Key>
|
||||||
<Property Name="DepartmentID" Type="Edm.Int32" Nullable="false"/>
|
<Property Name="DepartmentID" Type="Edm.Int32" Nullable="false"/>
|
||||||
<Property Name="Name" Type="Edm.String" Nullable="false"/>
|
<Property Name="Name" Type="Edm.String" Nullable="false"/>
|
||||||
|
<Property Name="DepartmentNO" Type="Edm.String"/>
|
||||||
<NavigationProperty Name="Company" Type="Microsoft.Test.OData.Services.ODataWCFService.Company" Nullable="false" Partner="Departments"/>
|
<NavigationProperty Name="Company" Type="Microsoft.Test.OData.Services.ODataWCFService.Company" Nullable="false" Partner="Departments"/>
|
||||||
</EntityType>
|
</EntityType>
|
||||||
<EntityType Name="Company">
|
<EntityType Name="Company" OpenType="true">
|
||||||
<Key>
|
<Key>
|
||||||
<PropertyRef Name="CompanyID"/>
|
<PropertyRef Name="CompanyID"/>
|
||||||
</Key>
|
</Key>
|
||||||
|
@ -171,7 +172,7 @@
|
||||||
<NavigationProperty Name="Departments" Type="Collection(Microsoft.Test.OData.Services.ODataWCFService.Department)" Partner="Company"/>
|
<NavigationProperty Name="Departments" Type="Collection(Microsoft.Test.OData.Services.ODataWCFService.Department)" Partner="Company"/>
|
||||||
<NavigationProperty Name="CoreDepartment" Type="Microsoft.Test.OData.Services.ODataWCFService.Department" Nullable="false"/>
|
<NavigationProperty Name="CoreDepartment" Type="Microsoft.Test.OData.Services.ODataWCFService.Department" Nullable="false"/>
|
||||||
</EntityType>
|
</EntityType>
|
||||||
<EntityType Name="PublicCompany" BaseType="Microsoft.Test.OData.Services.ODataWCFService.Company">
|
<EntityType Name="PublicCompany" BaseType="Microsoft.Test.OData.Services.ODataWCFService.Company" OpenType="true">
|
||||||
<Property Name="StockExchange" Type="Edm.String"/>
|
<Property Name="StockExchange" Type="Edm.String"/>
|
||||||
<NavigationProperty Name="Assets" Type="Collection(Microsoft.Test.OData.Services.ODataWCFService.Asset)" ContainsTarget="true"/>
|
<NavigationProperty Name="Assets" Type="Collection(Microsoft.Test.OData.Services.ODataWCFService.Asset)" ContainsTarget="true"/>
|
||||||
<NavigationProperty Name="Club" Type="Microsoft.Test.OData.Services.ODataWCFService.Club" Nullable="false" ContainsTarget="true"/>
|
<NavigationProperty Name="Club" Type="Microsoft.Test.OData.Services.ODataWCFService.Club" Nullable="false" ContainsTarget="true"/>
|
||||||
|
@ -231,6 +232,7 @@
|
||||||
<Parameter Name="address" Type="Microsoft.Test.OData.Services.ODataWCFService.Address" Nullable="false"/>
|
<Parameter Name="address" Type="Microsoft.Test.OData.Services.ODataWCFService.Address" Nullable="false"/>
|
||||||
<ReturnType Type="Microsoft.Test.OData.Services.ODataWCFService.Address" Nullable="false"/>
|
<ReturnType Type="Microsoft.Test.OData.Services.ODataWCFService.Address" Nullable="false"/>
|
||||||
</Action>
|
</Action>
|
||||||
|
<Action Name="ResetDataSource"/>
|
||||||
<Function Name="GetEmployeesCount" IsBound="true">
|
<Function Name="GetEmployeesCount" IsBound="true">
|
||||||
<Parameter Name="p" Type="Microsoft.Test.OData.Services.ODataWCFService.Company" Nullable="false"/>
|
<Parameter Name="p" Type="Microsoft.Test.OData.Services.ODataWCFService.Company" Nullable="false"/>
|
||||||
<ReturnType Type="Edm.Int32" Nullable="false"/>
|
<ReturnType Type="Edm.Int32" Nullable="false"/>
|
||||||
|
@ -240,7 +242,7 @@
|
||||||
<Parameter Name="count" Type="Edm.Int32"/>
|
<Parameter Name="count" Type="Edm.Int32"/>
|
||||||
<ReturnType Type="Collection(Microsoft.Test.OData.Services.ODataWCFService.ProductDetail)" Nullable="false"/>
|
<ReturnType Type="Collection(Microsoft.Test.OData.Services.ODataWCFService.ProductDetail)" Nullable="false"/>
|
||||||
</Function>
|
</Function>
|
||||||
<Function Name="GetRelatedProduct" IsBound="true" EntitySetPath="productDetail/Products" IsComposable="true">
|
<Function Name="GetRelatedProduct" IsBound="true" EntitySetPath="productDetail/RelatedProduct" IsComposable="true">
|
||||||
<Parameter Name="productDetail" Type="Microsoft.Test.OData.Services.ODataWCFService.ProductDetail" Nullable="false"/>
|
<Parameter Name="productDetail" Type="Microsoft.Test.OData.Services.ODataWCFService.ProductDetail" Nullable="false"/>
|
||||||
<ReturnType Type="Microsoft.Test.OData.Services.ODataWCFService.Product" Nullable="false"/>
|
<ReturnType Type="Microsoft.Test.OData.Services.ODataWCFService.Product" Nullable="false"/>
|
||||||
</Function>
|
</Function>
|
||||||
|
@ -264,7 +266,7 @@
|
||||||
<ReturnType Type="Collection(Edm.String)" Nullable="false"/>
|
<ReturnType Type="Collection(Edm.String)" Nullable="false"/>
|
||||||
</Function>
|
</Function>
|
||||||
<Function Name="GetProductsByAccessLevel">
|
<Function Name="GetProductsByAccessLevel">
|
||||||
<Parameter Name="accessLevel" Type="Microsoft.Test.OData.Services.ODataWCFService.AccessLevel" />
|
<Parameter Name="accessLevel" Type="Microsoft.Test.OData.Services.ODataWCFService.AccessLevel" Nullable="false"/>
|
||||||
<ReturnType Type="Collection(Edm.String)" Nullable="false"/>
|
<ReturnType Type="Collection(Edm.String)" Nullable="false"/>
|
||||||
</Function>
|
</Function>
|
||||||
<Function Name="GetActualAmount" IsBound="true">
|
<Function Name="GetActualAmount" IsBound="true">
|
||||||
|
@ -313,6 +315,7 @@
|
||||||
<Property Name="GiftCardNO" Type="Edm.String" Nullable="false"/>
|
<Property Name="GiftCardNO" Type="Edm.String" Nullable="false"/>
|
||||||
<Property Name="Amount" Type="Edm.Double" Nullable="false"/>
|
<Property Name="Amount" Type="Edm.Double" Nullable="false"/>
|
||||||
<Property Name="ExperationDate" Type="Edm.DateTimeOffset" Nullable="false"/>
|
<Property Name="ExperationDate" Type="Edm.DateTimeOffset" Nullable="false"/>
|
||||||
|
<Property Name="OwnerName" Type="Edm.String"/>
|
||||||
</EntityType>
|
</EntityType>
|
||||||
<EntityType Name="PaymentInstrument">
|
<EntityType Name="PaymentInstrument">
|
||||||
<Key>
|
<Key>
|
||||||
|
@ -374,15 +377,20 @@
|
||||||
<EntitySet Name="People" EntityType="Microsoft.Test.OData.Services.ODataWCFService.Person">
|
<EntitySet Name="People" EntityType="Microsoft.Test.OData.Services.ODataWCFService.Person">
|
||||||
<NavigationPropertyBinding Path="Parent" Target="People"/>
|
<NavigationPropertyBinding Path="Parent" Target="People"/>
|
||||||
</EntitySet>
|
</EntitySet>
|
||||||
<Singleton Name="Boss" Type="Microsoft.Test.OData.Services.ODataWCFService.Person" />
|
<Singleton Name="Boss" Type="Microsoft.Test.OData.Services.ODataWCFService.Person">
|
||||||
|
<NavigationPropertyBinding Path="Parent" Target="People"/>
|
||||||
|
</Singleton>
|
||||||
<EntitySet Name="Customers" EntityType="Microsoft.Test.OData.Services.ODataWCFService.Customer">
|
<EntitySet Name="Customers" EntityType="Microsoft.Test.OData.Services.ODataWCFService.Customer">
|
||||||
<NavigationPropertyBinding Path="Orders" Target="Orders"/>
|
<NavigationPropertyBinding Path="Orders" Target="Orders"/>
|
||||||
|
<NavigationPropertyBinding Path="Parent" Target="People"/>
|
||||||
</EntitySet>
|
</EntitySet>
|
||||||
<Singleton Name="VipCustomer" Type="Microsoft.Test.OData.Services.ODataWCFService.Customer">
|
<Singleton Name="VipCustomer" Type="Microsoft.Test.OData.Services.ODataWCFService.Customer">
|
||||||
<NavigationPropertyBinding Path="Orders" Target="Orders"/>
|
<NavigationPropertyBinding Path="Orders" Target="Orders"/>
|
||||||
|
<NavigationPropertyBinding Path="Parent" Target="People"/>
|
||||||
<NavigationPropertyBinding Path="Company" Target="Company"/>
|
<NavigationPropertyBinding Path="Company" Target="Company"/>
|
||||||
</Singleton>
|
</Singleton>
|
||||||
<EntitySet Name="Employees" EntityType="Microsoft.Test.OData.Services.ODataWCFService.Employee">
|
<EntitySet Name="Employees" EntityType="Microsoft.Test.OData.Services.ODataWCFService.Employee">
|
||||||
|
<NavigationPropertyBinding Path="Parent" Target="People"/>
|
||||||
<NavigationPropertyBinding Path="Company" Target="Company"/>
|
<NavigationPropertyBinding Path="Company" Target="Company"/>
|
||||||
</EntitySet>
|
</EntitySet>
|
||||||
<EntitySet Name="Products" EntityType="Microsoft.Test.OData.Services.ODataWCFService.Product">
|
<EntitySet Name="Products" EntityType="Microsoft.Test.OData.Services.ODataWCFService.Product">
|
||||||
|
@ -397,6 +405,21 @@
|
||||||
<NavigationPropertyBinding Path="LoggedInEmployee" Target="Employees"/>
|
<NavigationPropertyBinding Path="LoggedInEmployee" Target="Employees"/>
|
||||||
<NavigationPropertyBinding Path="CustomerForOrder" Target="Customers"/>
|
<NavigationPropertyBinding Path="CustomerForOrder" Target="Customers"/>
|
||||||
<NavigationPropertyBinding Path="OrderDetails" Target="OrderDetails"/>
|
<NavigationPropertyBinding Path="OrderDetails" Target="OrderDetails"/>
|
||||||
|
<Annotation Term="Core.ChangeTracking">
|
||||||
|
<Record>
|
||||||
|
<PropertyValue Property="Supported" Bool="true"/>
|
||||||
|
<PropertyValue Property="FilterableProperties">
|
||||||
|
<Collection>
|
||||||
|
<PropertyPath>OrderID</PropertyPath>
|
||||||
|
</Collection>
|
||||||
|
</PropertyValue>
|
||||||
|
<PropertyValue Property="ExpandableProperties">
|
||||||
|
<Collection>
|
||||||
|
<PropertyPath>OrderDetails</PropertyPath>
|
||||||
|
</Collection>
|
||||||
|
</PropertyValue>
|
||||||
|
</Record>
|
||||||
|
</Annotation>
|
||||||
</EntitySet>
|
</EntitySet>
|
||||||
<EntitySet Name="OrderDetails" EntityType="Microsoft.Test.OData.Services.ODataWCFService.OrderDetail">
|
<EntitySet Name="OrderDetails" EntityType="Microsoft.Test.OData.Services.ODataWCFService.OrderDetail">
|
||||||
<NavigationPropertyBinding Path="AssociatedOrder" Target="Orders"/>
|
<NavigationPropertyBinding Path="AssociatedOrder" Target="Orders"/>
|
||||||
|
@ -418,12 +441,13 @@
|
||||||
<ActionImport Name="Discount" Action="Microsoft.Test.OData.Services.ODataWCFService.Discount"/>
|
<ActionImport Name="Discount" Action="Microsoft.Test.OData.Services.ODataWCFService.Discount"/>
|
||||||
<ActionImport Name="ResetBossEmail" Action="Microsoft.Test.OData.Services.ODataWCFService.ResetBossEmail"/>
|
<ActionImport Name="ResetBossEmail" Action="Microsoft.Test.OData.Services.ODataWCFService.ResetBossEmail"/>
|
||||||
<ActionImport Name="ResetBossAddress" Action="Microsoft.Test.OData.Services.ODataWCFService.ResetBossAddress"/>
|
<ActionImport Name="ResetBossAddress" Action="Microsoft.Test.OData.Services.ODataWCFService.ResetBossAddress"/>
|
||||||
<FunctionImport Name="GetDefaultColor" Function="Microsoft.Test.OData.Services.ODataWCFService.GetDefaultColor" />
|
<ActionImport Name="ResetDataSource" Action="Microsoft.Test.OData.Services.ODataWCFService.ResetDataSource"/>
|
||||||
<FunctionImport Name="GetPerson" Function="Microsoft.Test.OData.Services.ODataWCFService.GetPerson" EntitySet="People" />
|
<FunctionImport Name="GetDefaultColor" Function="Microsoft.Test.OData.Services.ODataWCFService.GetDefaultColor" IncludeInServiceDocument="true"/>
|
||||||
<FunctionImport Name="GetPerson2" Function="Microsoft.Test.OData.Services.ODataWCFService.GetPerson2" EntitySet="People" />
|
<FunctionImport Name="GetPerson" Function="Microsoft.Test.OData.Services.ODataWCFService.GetPerson" EntitySet="People" IncludeInServiceDocument="true"/>
|
||||||
<FunctionImport Name="GetAllProducts" Function="Microsoft.Test.OData.Services.ODataWCFService.GetAllProducts" EntitySet="Products" />
|
<FunctionImport Name="GetPerson2" Function="Microsoft.Test.OData.Services.ODataWCFService.GetPerson2" EntitySet="People" IncludeInServiceDocument="true"/>
|
||||||
<FunctionImport Name="GetBossEmails" Function="Microsoft.Test.OData.Services.ODataWCFService.GetBossEmails" />
|
<FunctionImport Name="GetAllProducts" Function="Microsoft.Test.OData.Services.ODataWCFService.GetAllProducts" EntitySet="Products" IncludeInServiceDocument="true"/>
|
||||||
<FunctionImport Name="GetProductsByAccessLevel" Function="Microsoft.Test.OData.Services.ODataWCFService.GetProductsByAccessLevel" />
|
<FunctionImport Name="GetBossEmails" Function="Microsoft.Test.OData.Services.ODataWCFService.GetBossEmails" IncludeInServiceDocument="true"/>
|
||||||
|
<FunctionImport Name="GetProductsByAccessLevel" Function="Microsoft.Test.OData.Services.ODataWCFService.GetProductsByAccessLevel" IncludeInServiceDocument="true"/>
|
||||||
<EntitySet Name="Accounts" EntityType="Microsoft.Test.OData.Services.ODataWCFService.Account">
|
<EntitySet Name="Accounts" EntityType="Microsoft.Test.OData.Services.ODataWCFService.Account">
|
||||||
<NavigationPropertyBinding Path="Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument/TheStoredPI" Target="StoredPIs"/>
|
<NavigationPropertyBinding Path="Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument/TheStoredPI" Target="StoredPIs"/>
|
||||||
<NavigationPropertyBinding Path="AvailableSubscriptionTemplatess" Target="SubscriptionTemplates"/>
|
<NavigationPropertyBinding Path="AvailableSubscriptionTemplatess" Target="SubscriptionTemplates"/>
|
||||||
|
@ -436,4 +460,3 @@
|
||||||
</Schema>
|
</Schema>
|
||||||
</edmx:DataServices>
|
</edmx:DataServices>
|
||||||
</edmx:Edmx>
|
</edmx:Edmx>
|
||||||
|
|
||||||
|
|
|
@ -1,35 +1,23 @@
|
||||||
{
|
{
|
||||||
|
|
||||||
"error": {
|
"error": {
|
||||||
|
|
||||||
"code": "501",
|
"code": "501",
|
||||||
|
|
||||||
"message": "Unsupported functionality",
|
"message": "Unsupported functionality",
|
||||||
|
|
||||||
"target": "query",
|
"target": "query",
|
||||||
|
|
||||||
"details": [
|
"details": [
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
"code": "301",
|
"code": "301",
|
||||||
|
|
||||||
"target": "$search",
|
"target": "$search",
|
||||||
|
|
||||||
"message": "$search query option not supported"
|
"message": "$search query option not supported"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
"innererror": {
|
"innererror": {
|
||||||
|
|
||||||
"trace": ["callmethod1 etc", "callmethod2 etc"],
|
"trace": ["callmethod1 etc", "callmethod2 etc"],
|
||||||
|
"context": {
|
||||||
"context": {"key1":"for debug deployment only"}
|
"key1": "for debug deployment only"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,11 +19,10 @@
|
||||||
package org.apache.olingo.fit.v4;
|
package org.apache.olingo.fit.v4;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Dictionary;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.olingo.client.api.communication.ODataClientErrorException;
|
import org.apache.olingo.client.api.communication.ODataClientErrorException;
|
||||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
|
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
|
||||||
import org.apache.olingo.commons.api.domain.ODataError;
|
import org.apache.olingo.commons.api.domain.ODataError;
|
||||||
|
@ -36,41 +35,31 @@ public class ErrorResponseTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void jsonError() {
|
public void jsonError() {
|
||||||
|
final URI readURI = getClient().getURIBuilder(testStaticServiceRootURL).
|
||||||
|
appendEntitySetSegment("Customers").appendKeySegment(32).
|
||||||
|
build();
|
||||||
|
|
||||||
ODataPubFormat format = ODataPubFormat.JSON;
|
final ODataEntityRequest<ODataEntity> req = getClient().getRetrieveRequestFactory().getEntityRequest(readURI);
|
||||||
final URI readURI = getClient().getURIBuilder(testStaticServiceRootURL)
|
|
||||||
.appendEntitySetSegment("Customers").appendKeySegment(32)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
final ODataEntityRequest<ODataEntity> req = getClient()
|
|
||||||
.getRetrieveRequestFactory().getEntityRequest(readURI);
|
|
||||||
try {
|
try {
|
||||||
final ODataEntity read = read(format, readURI);
|
final ODataEntity read = read(ODataPubFormat.JSON, readURI);
|
||||||
|
|
||||||
|
fail("should have got exception");
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ODataError err = ((ODataClientErrorException) ex).getODataError();
|
final ODataError err = ((ODataClientErrorException) ex).getODataError();
|
||||||
|
|
||||||
// verify details
|
// verify details
|
||||||
ODataErrorDetail detail = (ODataErrorDetail) err.getDetails()
|
final ODataErrorDetail detail = (ODataErrorDetail) err.getDetails().get(0);
|
||||||
.get(0);
|
|
||||||
assertEquals("Code should be correct", "301", detail.getCode());
|
assertEquals("Code should be correct", "301", detail.getCode());
|
||||||
assertEquals("Target should be correct", "$search",
|
assertEquals("Target should be correct", "$search", detail.getTarget());
|
||||||
detail.getTarget());
|
assertEquals("Message should be correct", "$search query option not supported", detail.getMessage());
|
||||||
assertEquals("Message should be correct",
|
|
||||||
"$search query option not supported", detail.getMessage());
|
|
||||||
|
|
||||||
// verify inner error dictionary
|
// verify inner error dictionary
|
||||||
Dictionary<String, Object> innerErr = err.getInnerError();
|
final Map<String, String> innerErr = err.getInnerError();
|
||||||
assertEquals("innerError dictionary size should be correct", 2,
|
assertEquals("innerError dictionary size should be correct", 2, innerErr.size());
|
||||||
innerErr.size());
|
|
||||||
assertEquals("innerError['context'] should be correct",
|
assertEquals("innerError['context'] should be correct",
|
||||||
"{\"key1\":\"for debug deployment only\"}",
|
"{\"key1\":\"for debug deployment only\"}", innerErr.get("context"));
|
||||||
innerErr.get("context"));
|
|
||||||
assertEquals("innerError['trace'] should be correct",
|
assertEquals("innerError['trace'] should be correct",
|
||||||
"[\"callmethod1 etc\",\"callmethod2 etc\"]",
|
"[\"callmethod1 etc\",\"callmethod2 etc\"]", innerErr.get("trace"));
|
||||||
innerErr.get("trace"));
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
assertNotNull("should have got exception", null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.olingo.fit.v4;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.edm.Edm;
|
import org.apache.olingo.commons.api.edm.Edm;
|
||||||
|
@ -28,35 +29,56 @@ import org.apache.olingo.commons.api.edm.EdmEntityContainer;
|
||||||
import org.apache.olingo.commons.api.edm.EdmEntitySet;
|
import org.apache.olingo.commons.api.edm.EdmEntitySet;
|
||||||
import org.apache.olingo.commons.api.edm.EdmEntityType;
|
import org.apache.olingo.commons.api.edm.EdmEntityType;
|
||||||
import org.apache.olingo.commons.api.edm.EdmEnumType;
|
import org.apache.olingo.commons.api.edm.EdmEnumType;
|
||||||
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||||
import org.apache.olingo.commons.api.edm.EdmProperty;
|
import org.apache.olingo.commons.api.edm.EdmProperty;
|
||||||
import org.apache.olingo.commons.api.edm.EdmSchema;
|
import org.apache.olingo.commons.api.edm.EdmSchema;
|
||||||
import org.apache.olingo.commons.api.edm.EdmTerm;
|
import org.apache.olingo.commons.api.edm.EdmTerm;
|
||||||
import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
|
import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||||
|
import org.apache.olingo.commons.api.edm.annotation.EdmRecord;
|
||||||
import org.apache.olingo.commons.core.edm.primitivetype.EdmBoolean;
|
import org.apache.olingo.commons.core.edm.primitivetype.EdmBoolean;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class MetadataTestITCase extends AbstractTestITCase {
|
public class MetadataTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void retrieve() {
|
public void retrieve() throws EdmPrimitiveTypeException {
|
||||||
final Edm metadata = client.getRetrieveRequestFactory().
|
final Edm edm = client.getRetrieveRequestFactory().getMetadataRequest(testStaticServiceRootURL).execute().getBody();
|
||||||
getMetadataRequest(testStaticServiceRootURL).execute().getBody();
|
assertNotNull(edm);
|
||||||
assertNotNull(metadata);
|
|
||||||
|
|
||||||
final EdmEntityType order = metadata.getEntityType(
|
final EdmEntityType order = edm.getEntityType(
|
||||||
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService", "Order"));
|
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService", "Order"));
|
||||||
assertNotNull(order);
|
assertNotNull(order);
|
||||||
|
|
||||||
final EdmProperty orderDate = order.getStructuralProperty("OrderDate");
|
final EdmProperty orderDate = order.getStructuralProperty("OrderDate");
|
||||||
assertNotNull(orderDate);
|
assertNotNull(orderDate);
|
||||||
assertEquals("Edm.DateTimeOffset", orderDate.getType().getFullQualifiedName().toString());
|
assertEquals("Edm.DateTimeOffset", orderDate.getType().getFullQualifiedName().toString());
|
||||||
|
|
||||||
|
final EdmTerm isBoss = edm.getTerm(new FullQualifiedName(edm.getSchemas().get(0).getNamespace(), "IsBoss"));
|
||||||
|
assertNotNull(isBoss);
|
||||||
|
assertEquals(EdmBoolean.getInstance(), isBoss.getType());
|
||||||
|
|
||||||
|
final EdmEntitySet orders = edm.getSchemas().get(0).getEntityContainer().getEntitySet("Orders");
|
||||||
|
assertNotNull(orders);
|
||||||
|
assertFalse(orders.getAnnotations().isEmpty());
|
||||||
|
assertTrue(orders.getAnnotations().get(0).getExpression().isDynamic());
|
||||||
|
assertTrue(orders.getAnnotations().get(0).getExpression().asDynamic().isRecord());
|
||||||
|
final EdmRecord record = orders.getAnnotations().get(0).getExpression().asDynamic().asRecord();
|
||||||
|
assertNotNull(record);
|
||||||
|
assertEquals(3, record.getPropertyValues().size());
|
||||||
|
assertTrue(record.getPropertyValues().get(0).getValue().isConstant());
|
||||||
|
assertTrue(record.getPropertyValues().get(0).getValue().asConstant().getValue().asPrimitive().
|
||||||
|
toCastValue(Boolean.class));
|
||||||
|
assertTrue(record.getPropertyValues().get(1).getValue().asDynamic().isCollection());
|
||||||
|
assertEquals(1, record.getPropertyValues().get(1).getValue().asDynamic().asCollection().getItems().size());
|
||||||
|
assertTrue(record.getPropertyValues().get(1).getValue().asDynamic().asCollection().getItems().get(0).isDynamic());
|
||||||
|
assertEquals("OrderID", record.getPropertyValues().get(1).getValue().asDynamic().asCollection().
|
||||||
|
getItems().get(0).asDynamic().asPropertyPath().getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void include() {
|
public void include() {
|
||||||
final Edm edm = client.getRetrieveRequestFactory().
|
final Edm edm = client.getRetrieveRequestFactory().getMetadataRequest(testNorthwindRootURL).execute().getBody();
|
||||||
getMetadataRequest(testNorthwindRootURL).execute().getBody();
|
|
||||||
assertNotNull(edm);
|
assertNotNull(edm);
|
||||||
|
|
||||||
final EdmEntityContainer container = edm.getEntityContainer(
|
final EdmEntityContainer container = edm.getEntityContainer(
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.olingo.fit.v4;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
@ -29,6 +30,7 @@ import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRe
|
||||||
import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
|
import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
|
||||||
import org.apache.olingo.client.api.uri.v4.URIBuilder;
|
import org.apache.olingo.client.api.uri.v4.URIBuilder;
|
||||||
import org.apache.olingo.client.api.v4.ODataClient;
|
import org.apache.olingo.client.api.v4.ODataClient;
|
||||||
|
import org.apache.olingo.commons.api.domain.v4.ODataAnnotation;
|
||||||
import org.apache.olingo.commons.api.domain.v4.ODataValuable;
|
import org.apache.olingo.commons.api.domain.v4.ODataValuable;
|
||||||
import org.apache.olingo.commons.api.domain.v4.Singleton;
|
import org.apache.olingo.commons.api.domain.v4.Singleton;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||||
|
@ -55,12 +57,12 @@ public class SingletonTestITCase extends AbstractTestITCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readfromAtom() throws EdmPrimitiveTypeException {
|
public void readFromAtom() throws EdmPrimitiveTypeException {
|
||||||
read(client, ODataPubFormat.ATOM);
|
read(client, ODataPubFormat.ATOM);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readfromJSON() throws EdmPrimitiveTypeException {
|
public void readFromJSON() throws EdmPrimitiveTypeException {
|
||||||
read(edmClient, ODataPubFormat.JSON);
|
read(edmClient, ODataPubFormat.JSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,6 +71,37 @@ public class SingletonTestITCase extends AbstractTestITCase {
|
||||||
read(client, ODataPubFormat.JSON_FULL_METADATA);
|
read(client, ODataPubFormat.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void readWithAnnotations(final ODataClient client, final ODataPubFormat format)
|
||||||
|
throws EdmPrimitiveTypeException {
|
||||||
|
|
||||||
|
final URIBuilder builder = client.getURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Boss");
|
||||||
|
final ODataEntityRequest<Singleton> singleton =
|
||||||
|
client.getRetrieveRequestFactory().getSingletonRequest(builder.build());
|
||||||
|
singleton.setFormat(format);
|
||||||
|
singleton.setPrefer(client.newPreferences().includeAnnotations("*"));
|
||||||
|
final Singleton boss = singleton.execute().getBody();
|
||||||
|
assertNotNull(boss);
|
||||||
|
|
||||||
|
assertFalse(boss.getAnnotations().isEmpty());
|
||||||
|
final ODataAnnotation isBoss = boss.getAnnotations().get(0);
|
||||||
|
assertTrue(isBoss.getPrimitiveValue().toCastValue(Boolean.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void readWithAnnotationsFromAtom() throws EdmPrimitiveTypeException {
|
||||||
|
readWithAnnotations(client, ODataPubFormat.ATOM);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void readWithAnnotationsFromJSON() throws EdmPrimitiveTypeException {
|
||||||
|
readWithAnnotations(edmClient, ODataPubFormat.JSON);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void readWithAnnotationsFromJSONFull() throws EdmPrimitiveTypeException {
|
||||||
|
readWithAnnotations(client, ODataPubFormat.JSON_FULL_METADATA);
|
||||||
|
}
|
||||||
|
|
||||||
private void update(final ODataPubFormat format) throws EdmPrimitiveTypeException {
|
private void update(final ODataPubFormat format) throws EdmPrimitiveTypeException {
|
||||||
final Singleton changes = getClient().getObjectFactory().newSingleton(
|
final Singleton changes = getClient().getObjectFactory().newSingleton(
|
||||||
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Company"));
|
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Company"));
|
||||||
|
|
|
@ -32,15 +32,17 @@ public class EdmRecordImpl extends AbstractEdmAnnotatableDynamicAnnotationExpres
|
||||||
|
|
||||||
private final List<EdmPropertyValue> propertyValues;
|
private final List<EdmPropertyValue> propertyValues;
|
||||||
|
|
||||||
private final EdmStructuredType type;
|
private EdmStructuredType type;
|
||||||
|
|
||||||
public EdmRecordImpl(final Edm edm, final String type, final List<EdmPropertyValue> propertyValues) {
|
public EdmRecordImpl(final Edm edm, final String type, final List<EdmPropertyValue> propertyValues) {
|
||||||
this.edm = edm;
|
this.edm = edm;
|
||||||
this.propertyValues = propertyValues;
|
this.propertyValues = propertyValues;
|
||||||
|
|
||||||
|
if (type != null) {
|
||||||
final EdmTypeInfo typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(type).build();
|
final EdmTypeInfo typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(type).build();
|
||||||
this.type = typeInfo.getEntityType() == null ? typeInfo.getComplexType() : typeInfo.getEntityType();
|
this.type = typeInfo.getEntityType() == null ? typeInfo.getComplexType() : typeInfo.getEntityType();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<EdmPropertyValue> getPropertyValues() {
|
public List<EdmPropertyValue> getPropertyValues() {
|
||||||
|
|
|
@ -145,6 +145,7 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
|
||||||
final Annotation annotation = new AnnotationImpl();
|
final Annotation annotation = new AnnotationImpl();
|
||||||
|
|
||||||
annotation.setTerm(odataAnnotation.getTerm());
|
annotation.setTerm(odataAnnotation.getTerm());
|
||||||
|
annotation.setType(odataAnnotation.getValue().getTypeName());
|
||||||
updateValuable(annotation, odataAnnotation, reference);
|
updateValuable(annotation, odataAnnotation, reference);
|
||||||
|
|
||||||
annotatable.getAnnotations().add(annotation);
|
annotatable.getAnnotations().add(annotation);
|
||||||
|
@ -230,8 +231,16 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fqn == null && annotation.getType() != null) {
|
||||||
|
final EdmTypeInfo typeInfo = new EdmTypeInfo.Builder().setTypeExpression(annotation.getType()).build();
|
||||||
|
if (typeInfo.isPrimitiveType()) {
|
||||||
|
fqn = typeInfo.getPrimitiveTypeKind().getFullQualifiedName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final ODataAnnotation odataAnnotation = new ODataAnnotationImpl(annotation.getTerm(),
|
final ODataAnnotation odataAnnotation = new ODataAnnotationImpl(annotation.getTerm(),
|
||||||
(org.apache.olingo.commons.api.domain.v4.ODataValue) getODataValue(fqn, annotation, null, null));
|
(org.apache.olingo.commons.api.domain.v4.ODataValue) getODataValue(fqn, annotation, null, null));
|
||||||
|
odataAnnotatable.getAnnotations().add(odataAnnotation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.olingo.commons.api.domain;
|
package org.apache.olingo.commons.api.domain;
|
||||||
|
|
||||||
import java.util.Dictionary;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OData error.
|
* OData error.
|
||||||
|
@ -47,7 +47,6 @@ public interface ODataError {
|
||||||
*/
|
*/
|
||||||
String getTarget();
|
String getTarget();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets error details.
|
* Gets error details.
|
||||||
*
|
*
|
||||||
|
@ -58,7 +57,7 @@ public interface ODataError {
|
||||||
/**
|
/**
|
||||||
* Gets server defined key-value pairs for debug environment only.
|
* Gets server defined key-value pairs for debug environment only.
|
||||||
*
|
*
|
||||||
* @return a Dictionary representing server defined object.
|
* @return a pair representing server defined object.
|
||||||
*/
|
*/
|
||||||
Dictionary<String, Object> getInnerError();
|
Map<String, String> getInnerError();
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,9 +19,9 @@
|
||||||
package org.apache.olingo.commons.api.domain;
|
package org.apache.olingo.commons.api.domain;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OData details, for example - { "error": {..., "details":[
|
* OData details, for example <tt>{ "error": {..., "details":[
|
||||||
* {"code": "301","target": "$search" ,"message": "$search query option not supported"}
|
* {"code": "301","target": "$search" ,"message": "$search query option not supported"}
|
||||||
* ],...}}
|
* ],...}}</tt>.
|
||||||
*/
|
*/
|
||||||
public interface ODataErrorDetail {
|
public interface ODataErrorDetail {
|
||||||
|
|
||||||
|
|
|
@ -209,7 +209,7 @@ abstract class AbstractJsonSerializer<T> extends ODataJacksonSerializer<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void valuable(final JsonGenerator jgen, final Valuable valuable, final String name) throws IOException {
|
protected void valuable(final JsonGenerator jgen, final Valuable valuable, final String name) throws IOException {
|
||||||
if (serverMode && !Constants.VALUE.equals(name)) {
|
if (serverMode && !Constants.VALUE.equals(name) && !(valuable instanceof Annotation)) {
|
||||||
String type = valuable.getType();
|
String type = valuable.getType();
|
||||||
if (StringUtils.isBlank(type) && valuable.getValue().isPrimitive() || valuable.getValue().isNull()) {
|
if (StringUtils.isBlank(type) && valuable.getValue().isPrimitive() || valuable.getValue().isNull()) {
|
||||||
type = EdmPrimitiveTypeKind.String.getFullQualifiedName().toString();
|
type = EdmPrimitiveTypeKind.String.getFullQualifiedName().toString();
|
||||||
|
|
|
@ -18,30 +18,22 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.olingo.commons.core.data;
|
package org.apache.olingo.commons.core.data;
|
||||||
|
|
||||||
import java.util.Dictionary;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.domain.ODataError;
|
import org.apache.olingo.commons.api.domain.ODataError;
|
||||||
import org.apache.olingo.commons.api.domain.ODataErrorDetail;
|
import org.apache.olingo.commons.api.domain.ODataErrorDetail;
|
||||||
|
|
||||||
// {
|
/**
|
||||||
// "error": {
|
* Example:
|
||||||
// "code": "501",
|
* <tt>
|
||||||
// "message": "Unsupported functionality",
|
* {
|
||||||
// "target": "query",
|
* "error": { "code": "501", "message": "Unsupported functionality", "target": "query", "details": [ { "code": "301",
|
||||||
// "details": [
|
* "target": "$search", "message": "$search query option not supported" } ], "innererror": { "trace": [...], "context":
|
||||||
// {
|
* {...} } } }
|
||||||
// "code": "301",
|
* </tt>.
|
||||||
// "target": "$search",
|
*/
|
||||||
// "message": "$search query option not supported"
|
|
||||||
// }
|
|
||||||
// ],
|
|
||||||
// "innererror": {
|
|
||||||
// "trace": [...],
|
|
||||||
// "context": {...}
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
public abstract class AbstractODataError implements ODataError {
|
public abstract class AbstractODataError implements ODataError {
|
||||||
|
|
||||||
private String code;
|
private String code;
|
||||||
|
@ -52,7 +44,7 @@ public abstract class AbstractODataError implements ODataError {
|
||||||
|
|
||||||
private List<ODataErrorDetail> details;
|
private List<ODataErrorDetail> details;
|
||||||
|
|
||||||
private Dictionary<String,Object> innerError;
|
private Map<String, String> innerError = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCode() {
|
public String getCode() {
|
||||||
|
@ -91,11 +83,7 @@ public abstract class AbstractODataError implements ODataError {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dictionary<String,Object> getInnerError() {
|
public Map<String, String> getInnerError() {
|
||||||
return innerError;
|
return innerError;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInnerError(final Dictionary<String,Object> innerError) {
|
|
||||||
this.innerError = innerError;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,17 +24,12 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Dictionary;
|
|
||||||
import java.util.Hashtable;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.Constants;
|
import org.apache.olingo.commons.api.Constants;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
import org.apache.olingo.commons.api.domain.ODataErrorDetail;
|
import org.apache.olingo.commons.api.domain.ODataErrorDetail;
|
||||||
|
|
||||||
|
@ -65,10 +60,9 @@ public class JSONODataErrorDeserializer extends AbstractJsonDeserializer<JSONODa
|
||||||
error.setTarget(errorNode.get(Constants.ERROR_TARGET).textValue());
|
error.setTarget(errorNode.get(Constants.ERROR_TARGET).textValue());
|
||||||
}
|
}
|
||||||
if (errorNode.hasNonNull(Constants.ERROR_DETAILS)) {
|
if (errorNode.hasNonNull(Constants.ERROR_DETAILS)) {
|
||||||
List<ODataErrorDetail> details = new ArrayList<ODataErrorDetail>();
|
final List<ODataErrorDetail> details = new ArrayList<ODataErrorDetail>();
|
||||||
for (final Iterator<JsonNode> itor = errorNode.get(Constants.ERROR_DETAILS).iterator(); itor.hasNext();) {
|
for (final Iterator<JsonNode> itor = errorNode.get(Constants.ERROR_DETAILS).iterator(); itor.hasNext();) {
|
||||||
details.add(
|
details.add(itor.next().traverse(parser.getCodec()).<ResWrap<JSONODataErrorDetailImpl>>readValueAs(
|
||||||
itor.next().traverse(parser.getCodec()).<ResWrap<JSONODataErrorDetailImpl>>readValueAs(
|
|
||||||
new TypeReference<JSONODataErrorDetailImpl>() {
|
new TypeReference<JSONODataErrorDetailImpl>() {
|
||||||
}).getPayload());
|
}).getPayload());
|
||||||
}
|
}
|
||||||
|
@ -76,15 +70,12 @@ public class JSONODataErrorDeserializer extends AbstractJsonDeserializer<JSONODa
|
||||||
error.setDetails(details);
|
error.setDetails(details);
|
||||||
}
|
}
|
||||||
if (errorNode.hasNonNull(Constants.ERROR_INNERERROR)) {
|
if (errorNode.hasNonNull(Constants.ERROR_INNERERROR)) {
|
||||||
JsonNode innerError = errorNode.get(Constants.ERROR_INNERERROR);
|
final JsonNode innerError = errorNode.get(Constants.ERROR_INNERERROR);
|
||||||
Dictionary<String, Object> innerErr = new Hashtable<String, Object>();
|
|
||||||
for (final Iterator<String> itor = innerError.fieldNames(); itor.hasNext();) {
|
for (final Iterator<String> itor = innerError.fieldNames(); itor.hasNext();) {
|
||||||
String keyTmp = itor.next();
|
final String keyTmp = itor.next();
|
||||||
String val = innerError.get(keyTmp).toString();
|
final String val = innerError.get(keyTmp).toString();
|
||||||
innerErr.put(keyTmp,val);
|
error.getInnerError().put(keyTmp, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
error.setInnerError(innerErr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,24 +20,14 @@ package org.apache.olingo.commons.core.data;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonParser;
|
import com.fasterxml.jackson.core.JsonParser;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.Constants;
|
import org.apache.olingo.commons.api.Constants;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
import org.apache.olingo.commons.api.domain.ODataErrorDetail;
|
|
||||||
|
|
||||||
public class JSONODataErrorDetailDeserializer extends
|
public class JSONODataErrorDetailDeserializer extends AbstractJsonDeserializer<JSONODataErrorDetailImpl> {
|
||||||
AbstractJsonDeserializer<JSONODataErrorDetailImpl> {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ResWrap<JSONODataErrorDetailImpl> doDeserialize(
|
protected ResWrap<JSONODataErrorDetailImpl> doDeserialize(
|
||||||
|
|
Loading…
Reference in New Issue