Merge branch 'olingo200' of https://git-wip-us.apache.org/repos/asf/olingo-odata4 into olingo200
This commit is contained in:
commit
cde94fc09b
|
@ -68,9 +68,10 @@ public abstract class AbstractServices {
|
|||
*/
|
||||
protected static final Logger LOG = LoggerFactory.getLogger(AbstractServices.class);
|
||||
|
||||
private static Set<ODataVersion> initialized = EnumSet.noneOf(ODataVersion.class);
|
||||
private static final Set<ODataVersion> INITIALIZED = EnumSet.noneOf(ODataVersion.class);
|
||||
|
||||
protected abstract ODataVersion getVersion();
|
||||
|
||||
protected final AbstractXMLUtilities xml;
|
||||
|
||||
protected final AbstractJSONUtilities json;
|
||||
|
@ -84,9 +85,9 @@ public abstract class AbstractServices {
|
|||
this.json = new org.apache.olingo.fit.utils.v4.JSONUtilities();
|
||||
}
|
||||
|
||||
if (!initialized.contains(getVersion())) {
|
||||
if (!INITIALIZED.contains(getVersion())) {
|
||||
xml.retrieveLinkInfoFromMetadata();
|
||||
initialized.add(getVersion());
|
||||
INITIALIZED.add(getVersion());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,10 +137,9 @@ public abstract class AbstractServices {
|
|||
return getMetadata("large" + StringUtils.capitalize(METADATA));
|
||||
}
|
||||
|
||||
private Response getMetadata(final String filename) {
|
||||
protected Response getMetadata(final String filename) {
|
||||
try {
|
||||
return xml.
|
||||
createResponse(FSManager.instance(getVersion()).readFile(filename, Accept.XML), null, Accept.XML);
|
||||
return xml.createResponse(FSManager.instance(getVersion()).readFile(filename, Accept.XML), null, Accept.XML);
|
||||
} catch (Exception e) {
|
||||
return xml.createFaultResponse(Accept.XML.toString(getVersion()), e);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.apache.olingo.fit;
|
||||
|
||||
import org.apache.olingo.fit.utils.ODataVersion;
|
||||
import org.apache.olingo.fit.utils.XHTTPMethodInterceptor;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.core.Response;
|
||||
import org.apache.cxf.interceptor.InInterceptors;
|
||||
import static org.apache.olingo.fit.utils.Constants.METADATA;
|
||||
|
||||
@Path("/V40/NorthWind.svc")
|
||||
@InInterceptors(classes = XHTTPMethodInterceptor.class)
|
||||
public class V4NorthWind extends AbstractServices {
|
||||
|
||||
public V4NorthWind() throws Exception {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ODataVersion getVersion() {
|
||||
return ODataVersion.v4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response getMetadata() {
|
||||
return getMetadata("northwind-" + METADATA);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.apache.olingo.fit;
|
||||
|
||||
import org.apache.olingo.fit.utils.ODataVersion;
|
||||
import org.apache.olingo.fit.utils.XHTTPMethodInterceptor;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.core.Response;
|
||||
import org.apache.cxf.interceptor.InInterceptors;
|
||||
import static org.apache.olingo.fit.utils.Constants.METADATA;
|
||||
|
||||
@Path("/V40/NorthWindExt.svc")
|
||||
@InInterceptors(classes = XHTTPMethodInterceptor.class)
|
||||
public class V4NorthWindExt extends AbstractServices {
|
||||
|
||||
public V4NorthWindExt() throws Exception {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ODataVersion getVersion() {
|
||||
return ODataVersion.v4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response getMetadata() {
|
||||
return getMetadata("northwindExt-" + METADATA);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
<?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:Reference Uri="http://localhost:${cargo.servlet.port}/StaticService/V40/NorthWindExt.svc">
|
||||
<edmx:Include Namespace="NorthwindModel"/>
|
||||
</edmx:Reference>
|
||||
<edmx:DataServices>
|
||||
<Schema Namespace="ODataWebExperimental.Northwind.Model" xmlns="http://docs.oasis-open.org/odata/ns/edm">
|
||||
<EntityContainer Name="NorthwindEntities" p4:LazyLoadingEnabled="true" xmlns:p4="http://schemas.microsoft.com/ado/2009/02/edm/annotation">
|
||||
<EntitySet Name="Categories" EntityType="NorthwindModel.Category">
|
||||
<NavigationPropertyBinding Path="Products" Target="Products" />
|
||||
</EntitySet>
|
||||
<EntitySet Name="CustomerDemographics" EntityType="NorthwindModel.CustomerDemographic">
|
||||
<NavigationPropertyBinding Path="Customers" Target="Customers" />
|
||||
</EntitySet>
|
||||
<EntitySet Name="Customers" EntityType="NorthwindModel.Customer">
|
||||
<NavigationPropertyBinding Path="CustomerDemographics" Target="CustomerDemographics" />
|
||||
<NavigationPropertyBinding Path="Orders" Target="Orders" />
|
||||
</EntitySet>
|
||||
<EntitySet Name="Employees" EntityType="NorthwindModel.Employee">
|
||||
<NavigationPropertyBinding Path="Employees1" Target="Employees" />
|
||||
<NavigationPropertyBinding Path="Employee1" Target="Employees" />
|
||||
<NavigationPropertyBinding Path="Orders" Target="Orders" />
|
||||
<NavigationPropertyBinding Path="Territories" Target="Territories" />
|
||||
</EntitySet>
|
||||
<EntitySet Name="Order_Details" EntityType="NorthwindModel.Order_Detail">
|
||||
<NavigationPropertyBinding Path="Order" Target="Orders" />
|
||||
<NavigationPropertyBinding Path="Product" Target="Products" />
|
||||
</EntitySet>
|
||||
<EntitySet Name="Orders" EntityType="NorthwindModel.Order">
|
||||
<NavigationPropertyBinding Path="Customer" Target="Customers" />
|
||||
<NavigationPropertyBinding Path="Employee" Target="Employees" />
|
||||
<NavigationPropertyBinding Path="Order_Details" Target="Order_Details" />
|
||||
<NavigationPropertyBinding Path="Shipper" Target="Shippers" />
|
||||
</EntitySet>
|
||||
<EntitySet Name="Products" EntityType="NorthwindModel.Product">
|
||||
<NavigationPropertyBinding Path="Category" Target="Categories" />
|
||||
<NavigationPropertyBinding Path="Order_Details" Target="Order_Details" />
|
||||
<NavigationPropertyBinding Path="Supplier" Target="Suppliers" />
|
||||
</EntitySet>
|
||||
<EntitySet Name="Regions" EntityType="NorthwindModel.Region">
|
||||
<NavigationPropertyBinding Path="Territories" Target="Territories" />
|
||||
</EntitySet>
|
||||
<EntitySet Name="Shippers" EntityType="NorthwindModel.Shipper">
|
||||
<NavigationPropertyBinding Path="Orders" Target="Orders" />
|
||||
</EntitySet>
|
||||
<EntitySet Name="Suppliers" EntityType="NorthwindModel.Supplier">
|
||||
<NavigationPropertyBinding Path="Products" Target="Products" />
|
||||
</EntitySet>
|
||||
<EntitySet Name="Territories" EntityType="NorthwindModel.Territory">
|
||||
<NavigationPropertyBinding Path="Employees" Target="Employees" />
|
||||
<NavigationPropertyBinding Path="Region" Target="Regions" />
|
||||
</EntitySet>
|
||||
<EntitySet Name="Alphabetical_list_of_products" EntityType="NorthwindModel.Alphabetical_list_of_product" />
|
||||
<EntitySet Name="Category_Sales_for_1997" EntityType="NorthwindModel.Category_Sales_for_1997" />
|
||||
<EntitySet Name="Current_Product_Lists" EntityType="NorthwindModel.Current_Product_List" />
|
||||
<EntitySet Name="Customer_and_Suppliers_by_Cities" EntityType="NorthwindModel.Customer_and_Suppliers_by_City" />
|
||||
<EntitySet Name="Invoices" EntityType="NorthwindModel.Invoice" />
|
||||
<EntitySet Name="Order_Details_Extendeds" EntityType="NorthwindModel.Order_Details_Extended" />
|
||||
<EntitySet Name="Order_Subtotals" EntityType="NorthwindModel.Order_Subtotal" />
|
||||
<EntitySet Name="Orders_Qries" EntityType="NorthwindModel.Orders_Qry" />
|
||||
<EntitySet Name="Product_Sales_for_1997" EntityType="NorthwindModel.Product_Sales_for_1997" />
|
||||
<EntitySet Name="Products_Above_Average_Prices" EntityType="NorthwindModel.Products_Above_Average_Price" />
|
||||
<EntitySet Name="Products_by_Categories" EntityType="NorthwindModel.Products_by_Category" />
|
||||
<EntitySet Name="Sales_by_Categories" EntityType="NorthwindModel.Sales_by_Category" />
|
||||
<EntitySet Name="Sales_Totals_by_Amounts" EntityType="NorthwindModel.Sales_Totals_by_Amount" />
|
||||
<EntitySet Name="Summary_of_Sales_by_Quarters" EntityType="NorthwindModel.Summary_of_Sales_by_Quarter" />
|
||||
<EntitySet Name="Summary_of_Sales_by_Years" EntityType="NorthwindModel.Summary_of_Sales_by_Year" />
|
||||
</EntityContainer>
|
||||
</Schema>
|
||||
</edmx:DataServices>
|
||||
</edmx:Edmx>
|
|
@ -0,0 +1,408 @@
|
|||
<?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="NorthwindModel" xmlns="http://docs.oasis-open.org/odata/ns/edm">
|
||||
<EntityType Name="Category">
|
||||
<Key>
|
||||
<PropertyRef Name="CategoryID" />
|
||||
</Key>
|
||||
<Property Name="CategoryID" Type="Edm.Int32" Nullable="false" p5:StoreGeneratedPattern="Identity" xmlns:p5="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
|
||||
<Property Name="CategoryName" Type="Edm.String" Nullable="false" MaxLength="15" />
|
||||
<Property Name="Description" Type="Edm.String" MaxLength="max" />
|
||||
<Property Name="Picture" Type="Edm.Binary" MaxLength="max" />
|
||||
<NavigationProperty Name="Products" Type="Collection(NorthwindModel.Product)" Partner="Category" />
|
||||
</EntityType>
|
||||
<EntityType Name="CustomerDemographic">
|
||||
<Key>
|
||||
<PropertyRef Name="CustomerTypeID" />
|
||||
</Key>
|
||||
<Property Name="CustomerTypeID" Type="Edm.String" Nullable="false" MaxLength="10" />
|
||||
<Property Name="CustomerDesc" Type="Edm.String" MaxLength="max" />
|
||||
<NavigationProperty Name="Customers" Type="Collection(NorthwindModel.Customer)" Partner="CustomerDemographics" />
|
||||
</EntityType>
|
||||
<EntityType Name="Customer">
|
||||
<Key>
|
||||
<PropertyRef Name="CustomerID" />
|
||||
</Key>
|
||||
<Property Name="CustomerID" Type="Edm.String" Nullable="false" MaxLength="5" />
|
||||
<Property Name="CompanyName" Type="Edm.String" Nullable="false" MaxLength="40" />
|
||||
<Property Name="ContactName" Type="Edm.String" MaxLength="30" />
|
||||
<Property Name="ContactTitle" Type="Edm.String" MaxLength="30" />
|
||||
<Property Name="Address" Type="Edm.String" MaxLength="60" />
|
||||
<Property Name="City" Type="Edm.String" MaxLength="15" />
|
||||
<Property Name="Region" Type="Edm.String" MaxLength="15" />
|
||||
<Property Name="PostalCode" Type="Edm.String" MaxLength="10" />
|
||||
<Property Name="Country" Type="Edm.String" MaxLength="15" />
|
||||
<Property Name="Phone" Type="Edm.String" MaxLength="24" />
|
||||
<Property Name="Fax" Type="Edm.String" MaxLength="24" />
|
||||
<NavigationProperty Name="Orders" Type="Collection(NorthwindModel.Order)" Partner="Customer" />
|
||||
<NavigationProperty Name="CustomerDemographics" Type="Collection(NorthwindModel.CustomerDemographic)" Partner="Customers" />
|
||||
</EntityType>
|
||||
<EntityType Name="Employee">
|
||||
<Key>
|
||||
<PropertyRef Name="EmployeeID" />
|
||||
</Key>
|
||||
<Property Name="EmployeeID" Type="Edm.Int32" Nullable="false" p5:StoreGeneratedPattern="Identity" xmlns:p5="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
|
||||
<Property Name="LastName" Type="Edm.String" Nullable="false" MaxLength="20" />
|
||||
<Property Name="FirstName" Type="Edm.String" Nullable="false" MaxLength="10" />
|
||||
<Property Name="Title" Type="Edm.String" MaxLength="30" />
|
||||
<Property Name="TitleOfCourtesy" Type="Edm.String" MaxLength="25" />
|
||||
<Property Name="BirthDate" Type="Edm.DateTimeOffset" />
|
||||
<Property Name="HireDate" Type="Edm.DateTimeOffset" />
|
||||
<Property Name="Address" Type="Edm.String" MaxLength="60" />
|
||||
<Property Name="City" Type="Edm.String" MaxLength="15" />
|
||||
<Property Name="Region" Type="Edm.String" MaxLength="15" />
|
||||
<Property Name="PostalCode" Type="Edm.String" MaxLength="10" />
|
||||
<Property Name="Country" Type="Edm.String" MaxLength="15" />
|
||||
<Property Name="HomePhone" Type="Edm.String" MaxLength="24" />
|
||||
<Property Name="Extension" Type="Edm.String" MaxLength="4" />
|
||||
<Property Name="Photo" Type="Edm.Binary" MaxLength="max" />
|
||||
<Property Name="Notes" Type="Edm.String" MaxLength="max" />
|
||||
<Property Name="ReportsTo" Type="Edm.Int32" />
|
||||
<Property Name="PhotoPath" Type="Edm.String" MaxLength="255" />
|
||||
<NavigationProperty Name="Employees1" Type="Collection(NorthwindModel.Employee)" Partner="Employee1" />
|
||||
<NavigationProperty Name="Employee1" Type="NorthwindModel.Employee" Partner="Employees1">
|
||||
<ReferentialConstraint Property="ReportsTo" ReferencedProperty="EmployeeID" />
|
||||
</NavigationProperty>
|
||||
<NavigationProperty Name="Orders" Type="Collection(NorthwindModel.Order)" Partner="Employee" />
|
||||
<NavigationProperty Name="Territories" Type="Collection(NorthwindModel.Territory)" Partner="Employees" />
|
||||
</EntityType>
|
||||
<EntityType Name="Order_Detail">
|
||||
<Key>
|
||||
<PropertyRef Name="OrderID" />
|
||||
<PropertyRef Name="ProductID" />
|
||||
</Key>
|
||||
<Property Name="OrderID" Type="Edm.Int32" Nullable="false" />
|
||||
<Property Name="ProductID" Type="Edm.Int32" Nullable="false" />
|
||||
<Property Name="UnitPrice" Type="Edm.Decimal" Nullable="false" Precision="19" Scale="4" />
|
||||
<Property Name="Quantity" Type="Edm.Int16" Nullable="false" />
|
||||
<Property Name="Discount" Type="Edm.Single" Nullable="false" />
|
||||
<NavigationProperty Name="Order" Type="NorthwindModel.Order" Nullable="false" Partner="Order_Details">
|
||||
<ReferentialConstraint Property="OrderID" ReferencedProperty="OrderID" />
|
||||
</NavigationProperty>
|
||||
<NavigationProperty Name="Product" Type="NorthwindModel.Product" Nullable="false" Partner="Order_Details">
|
||||
<ReferentialConstraint Property="ProductID" ReferencedProperty="ProductID" />
|
||||
</NavigationProperty>
|
||||
</EntityType>
|
||||
<EntityType Name="Order">
|
||||
<Key>
|
||||
<PropertyRef Name="OrderID" />
|
||||
</Key>
|
||||
<Property Name="OrderID" Type="Edm.Int32" Nullable="false" p5:StoreGeneratedPattern="Identity" xmlns:p5="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
|
||||
<Property Name="CustomerID" Type="Edm.String" MaxLength="5" />
|
||||
<Property Name="EmployeeID" Type="Edm.Int32" />
|
||||
<Property Name="OrderDate" Type="Edm.DateTimeOffset" />
|
||||
<Property Name="RequiredDate" Type="Edm.DateTimeOffset" />
|
||||
<Property Name="ShippedDate" Type="Edm.DateTimeOffset" />
|
||||
<Property Name="ShipVia" Type="Edm.Int32" />
|
||||
<Property Name="Freight" Type="Edm.Decimal" Precision="19" Scale="4" />
|
||||
<Property Name="ShipName" Type="Edm.String" MaxLength="40" />
|
||||
<Property Name="ShipAddress" Type="Edm.String" MaxLength="60" />
|
||||
<Property Name="ShipCity" Type="Edm.String" MaxLength="15" />
|
||||
<Property Name="ShipRegion" Type="Edm.String" MaxLength="15" />
|
||||
<Property Name="ShipPostalCode" Type="Edm.String" MaxLength="10" />
|
||||
<Property Name="ShipCountry" Type="Edm.String" MaxLength="15" />
|
||||
<NavigationProperty Name="Customer" Type="NorthwindModel.Customer" Partner="Orders">
|
||||
<ReferentialConstraint Property="CustomerID" ReferencedProperty="CustomerID" />
|
||||
</NavigationProperty>
|
||||
<NavigationProperty Name="Employee" Type="NorthwindModel.Employee" Partner="Orders">
|
||||
<ReferentialConstraint Property="EmployeeID" ReferencedProperty="EmployeeID" />
|
||||
</NavigationProperty>
|
||||
<NavigationProperty Name="Order_Details" Type="Collection(NorthwindModel.Order_Detail)" Partner="Order" />
|
||||
<NavigationProperty Name="Shipper" Type="NorthwindModel.Shipper" Partner="Orders">
|
||||
<ReferentialConstraint Property="ShipVia" ReferencedProperty="ShipperID" />
|
||||
</NavigationProperty>
|
||||
</EntityType>
|
||||
<EntityType Name="Product">
|
||||
<Key>
|
||||
<PropertyRef Name="ProductID" />
|
||||
</Key>
|
||||
<Property Name="ProductID" Type="Edm.Int32" Nullable="false" p5:StoreGeneratedPattern="Identity" xmlns:p5="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
|
||||
<Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" />
|
||||
<Property Name="SupplierID" Type="Edm.Int32" />
|
||||
<Property Name="CategoryID" Type="Edm.Int32" />
|
||||
<Property Name="QuantityPerUnit" Type="Edm.String" MaxLength="20" />
|
||||
<Property Name="UnitPrice" Type="Edm.Decimal" Precision="19" Scale="4" />
|
||||
<Property Name="UnitsInStock" Type="Edm.Int16" />
|
||||
<Property Name="UnitsOnOrder" Type="Edm.Int16" />
|
||||
<Property Name="ReorderLevel" Type="Edm.Int16" />
|
||||
<Property Name="Discontinued" Type="Edm.Boolean" Nullable="false" />
|
||||
<NavigationProperty Name="Category" Type="NorthwindModel.Category" Partner="Products">
|
||||
<ReferentialConstraint Property="CategoryID" ReferencedProperty="CategoryID" />
|
||||
</NavigationProperty>
|
||||
<NavigationProperty Name="Order_Details" Type="Collection(NorthwindModel.Order_Detail)" Partner="Product" />
|
||||
<NavigationProperty Name="Supplier" Type="NorthwindModel.Supplier" Partner="Products">
|
||||
<ReferentialConstraint Property="SupplierID" ReferencedProperty="SupplierID" />
|
||||
</NavigationProperty>
|
||||
</EntityType>
|
||||
<EntityType Name="Region">
|
||||
<Key>
|
||||
<PropertyRef Name="RegionID" />
|
||||
</Key>
|
||||
<Property Name="RegionID" Type="Edm.Int32" Nullable="false" />
|
||||
<Property Name="RegionDescription" Type="Edm.String" Nullable="false" MaxLength="50" />
|
||||
<NavigationProperty Name="Territories" Type="Collection(NorthwindModel.Territory)" Partner="Region" />
|
||||
</EntityType>
|
||||
<EntityType Name="Shipper">
|
||||
<Key>
|
||||
<PropertyRef Name="ShipperID" />
|
||||
</Key>
|
||||
<Property Name="ShipperID" Type="Edm.Int32" Nullable="false" p5:StoreGeneratedPattern="Identity" xmlns:p5="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
|
||||
<Property Name="CompanyName" Type="Edm.String" Nullable="false" MaxLength="40" />
|
||||
<Property Name="Phone" Type="Edm.String" MaxLength="24" />
|
||||
<NavigationProperty Name="Orders" Type="Collection(NorthwindModel.Order)" Partner="Shipper" />
|
||||
</EntityType>
|
||||
<EntityType Name="Supplier">
|
||||
<Key>
|
||||
<PropertyRef Name="SupplierID" />
|
||||
</Key>
|
||||
<Property Name="SupplierID" Type="Edm.Int32" Nullable="false" p5:StoreGeneratedPattern="Identity" xmlns:p5="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
|
||||
<Property Name="CompanyName" Type="Edm.String" Nullable="false" MaxLength="40" />
|
||||
<Property Name="ContactName" Type="Edm.String" MaxLength="30" />
|
||||
<Property Name="ContactTitle" Type="Edm.String" MaxLength="30" />
|
||||
<Property Name="Address" Type="Edm.String" MaxLength="60" />
|
||||
<Property Name="City" Type="Edm.String" MaxLength="15" />
|
||||
<Property Name="Region" Type="Edm.String" MaxLength="15" />
|
||||
<Property Name="PostalCode" Type="Edm.String" MaxLength="10" />
|
||||
<Property Name="Country" Type="Edm.String" MaxLength="15" />
|
||||
<Property Name="Phone" Type="Edm.String" MaxLength="24" />
|
||||
<Property Name="Fax" Type="Edm.String" MaxLength="24" />
|
||||
<Property Name="HomePage" Type="Edm.String" MaxLength="max" />
|
||||
<NavigationProperty Name="Products" Type="Collection(NorthwindModel.Product)" Partner="Supplier" />
|
||||
</EntityType>
|
||||
<EntityType Name="Territory">
|
||||
<Key>
|
||||
<PropertyRef Name="TerritoryID" />
|
||||
</Key>
|
||||
<Property Name="TerritoryID" Type="Edm.String" Nullable="false" MaxLength="20" />
|
||||
<Property Name="TerritoryDescription" Type="Edm.String" Nullable="false" MaxLength="50" />
|
||||
<Property Name="RegionID" Type="Edm.Int32" Nullable="false" />
|
||||
<NavigationProperty Name="Region" Type="NorthwindModel.Region" Nullable="false" Partner="Territories">
|
||||
<ReferentialConstraint Property="RegionID" ReferencedProperty="RegionID" />
|
||||
</NavigationProperty>
|
||||
<NavigationProperty Name="Employees" Type="Collection(NorthwindModel.Employee)" Partner="Territories" />
|
||||
</EntityType>
|
||||
<EntityType Name="Alphabetical_list_of_product">
|
||||
<Key>
|
||||
<PropertyRef Name="CategoryName" />
|
||||
<PropertyRef Name="Discontinued" />
|
||||
<PropertyRef Name="ProductID" />
|
||||
<PropertyRef Name="ProductName" />
|
||||
</Key>
|
||||
<Property Name="ProductID" Type="Edm.Int32" Nullable="false" />
|
||||
<Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" />
|
||||
<Property Name="SupplierID" Type="Edm.Int32" />
|
||||
<Property Name="CategoryID" Type="Edm.Int32" />
|
||||
<Property Name="QuantityPerUnit" Type="Edm.String" MaxLength="20" />
|
||||
<Property Name="UnitPrice" Type="Edm.Decimal" Precision="19" Scale="4" />
|
||||
<Property Name="UnitsInStock" Type="Edm.Int16" />
|
||||
<Property Name="UnitsOnOrder" Type="Edm.Int16" />
|
||||
<Property Name="ReorderLevel" Type="Edm.Int16" />
|
||||
<Property Name="Discontinued" Type="Edm.Boolean" Nullable="false" />
|
||||
<Property Name="CategoryName" Type="Edm.String" Nullable="false" MaxLength="15" />
|
||||
</EntityType>
|
||||
<EntityType Name="Category_Sales_for_1997">
|
||||
<Key>
|
||||
<PropertyRef Name="CategoryName" />
|
||||
</Key>
|
||||
<Property Name="CategoryName" Type="Edm.String" Nullable="false" MaxLength="15" />
|
||||
<Property Name="CategorySales" Type="Edm.Decimal" Precision="19" Scale="4" />
|
||||
</EntityType>
|
||||
<EntityType Name="Current_Product_List">
|
||||
<Key>
|
||||
<PropertyRef Name="ProductID" />
|
||||
<PropertyRef Name="ProductName" />
|
||||
</Key>
|
||||
<Property Name="ProductID" Type="Edm.Int32" Nullable="false" p5:StoreGeneratedPattern="Identity" xmlns:p5="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
|
||||
<Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" />
|
||||
</EntityType>
|
||||
<EntityType Name="Customer_and_Suppliers_by_City">
|
||||
<Key>
|
||||
<PropertyRef Name="CompanyName" />
|
||||
<PropertyRef Name="Relationship" />
|
||||
</Key>
|
||||
<Property Name="City" Type="Edm.String" MaxLength="15" />
|
||||
<Property Name="CompanyName" Type="Edm.String" Nullable="false" MaxLength="40" />
|
||||
<Property Name="ContactName" Type="Edm.String" MaxLength="30" />
|
||||
<Property Name="Relationship" Type="Edm.String" Nullable="false" MaxLength="9" Unicode="false" />
|
||||
</EntityType>
|
||||
<EntityType Name="Invoice">
|
||||
<Key>
|
||||
<PropertyRef Name="CustomerName" />
|
||||
<PropertyRef Name="Discount" />
|
||||
<PropertyRef Name="OrderID" />
|
||||
<PropertyRef Name="ProductID" />
|
||||
<PropertyRef Name="ProductName" />
|
||||
<PropertyRef Name="Quantity" />
|
||||
<PropertyRef Name="Salesperson" />
|
||||
<PropertyRef Name="ShipperName" />
|
||||
<PropertyRef Name="UnitPrice" />
|
||||
</Key>
|
||||
<Property Name="ShipName" Type="Edm.String" MaxLength="40" />
|
||||
<Property Name="ShipAddress" Type="Edm.String" MaxLength="60" />
|
||||
<Property Name="ShipCity" Type="Edm.String" MaxLength="15" />
|
||||
<Property Name="ShipRegion" Type="Edm.String" MaxLength="15" />
|
||||
<Property Name="ShipPostalCode" Type="Edm.String" MaxLength="10" />
|
||||
<Property Name="ShipCountry" Type="Edm.String" MaxLength="15" />
|
||||
<Property Name="CustomerID" Type="Edm.String" MaxLength="5" />
|
||||
<Property Name="CustomerName" Type="Edm.String" Nullable="false" MaxLength="40" />
|
||||
<Property Name="Address" Type="Edm.String" MaxLength="60" />
|
||||
<Property Name="City" Type="Edm.String" MaxLength="15" />
|
||||
<Property Name="Region" Type="Edm.String" MaxLength="15" />
|
||||
<Property Name="PostalCode" Type="Edm.String" MaxLength="10" />
|
||||
<Property Name="Country" Type="Edm.String" MaxLength="15" />
|
||||
<Property Name="Salesperson" Type="Edm.String" Nullable="false" MaxLength="31" />
|
||||
<Property Name="OrderID" Type="Edm.Int32" Nullable="false" />
|
||||
<Property Name="OrderDate" Type="Edm.DateTimeOffset" />
|
||||
<Property Name="RequiredDate" Type="Edm.DateTimeOffset" />
|
||||
<Property Name="ShippedDate" Type="Edm.DateTimeOffset" />
|
||||
<Property Name="ShipperName" Type="Edm.String" Nullable="false" MaxLength="40" />
|
||||
<Property Name="ProductID" Type="Edm.Int32" Nullable="false" />
|
||||
<Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" />
|
||||
<Property Name="UnitPrice" Type="Edm.Decimal" Nullable="false" Precision="19" Scale="4" />
|
||||
<Property Name="Quantity" Type="Edm.Int16" Nullable="false" />
|
||||
<Property Name="Discount" Type="Edm.Single" Nullable="false" />
|
||||
<Property Name="ExtendedPrice" Type="Edm.Decimal" Precision="19" Scale="4" />
|
||||
<Property Name="Freight" Type="Edm.Decimal" Precision="19" Scale="4" />
|
||||
</EntityType>
|
||||
<EntityType Name="Order_Details_Extended">
|
||||
<Key>
|
||||
<PropertyRef Name="Discount" />
|
||||
<PropertyRef Name="OrderID" />
|
||||
<PropertyRef Name="ProductID" />
|
||||
<PropertyRef Name="ProductName" />
|
||||
<PropertyRef Name="Quantity" />
|
||||
<PropertyRef Name="UnitPrice" />
|
||||
</Key>
|
||||
<Property Name="OrderID" Type="Edm.Int32" Nullable="false" />
|
||||
<Property Name="ProductID" Type="Edm.Int32" Nullable="false" />
|
||||
<Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" />
|
||||
<Property Name="UnitPrice" Type="Edm.Decimal" Nullable="false" Precision="19" Scale="4" />
|
||||
<Property Name="Quantity" Type="Edm.Int16" Nullable="false" />
|
||||
<Property Name="Discount" Type="Edm.Single" Nullable="false" />
|
||||
<Property Name="ExtendedPrice" Type="Edm.Decimal" Precision="19" Scale="4" />
|
||||
</EntityType>
|
||||
<EntityType Name="Order_Subtotal">
|
||||
<Key>
|
||||
<PropertyRef Name="OrderID" />
|
||||
</Key>
|
||||
<Property Name="OrderID" Type="Edm.Int32" Nullable="false" />
|
||||
<Property Name="Subtotal" Type="Edm.Decimal" Precision="19" Scale="4" />
|
||||
</EntityType>
|
||||
<EntityType Name="Orders_Qry">
|
||||
<Key>
|
||||
<PropertyRef Name="CompanyName" />
|
||||
<PropertyRef Name="OrderID" />
|
||||
</Key>
|
||||
<Property Name="OrderID" Type="Edm.Int32" Nullable="false" />
|
||||
<Property Name="CustomerID" Type="Edm.String" MaxLength="5" />
|
||||
<Property Name="EmployeeID" Type="Edm.Int32" />
|
||||
<Property Name="OrderDate" Type="Edm.DateTimeOffset" />
|
||||
<Property Name="RequiredDate" Type="Edm.DateTimeOffset" />
|
||||
<Property Name="ShippedDate" Type="Edm.DateTimeOffset" />
|
||||
<Property Name="ShipVia" Type="Edm.Int32" />
|
||||
<Property Name="Freight" Type="Edm.Decimal" Precision="19" Scale="4" />
|
||||
<Property Name="ShipName" Type="Edm.String" MaxLength="40" />
|
||||
<Property Name="ShipAddress" Type="Edm.String" MaxLength="60" />
|
||||
<Property Name="ShipCity" Type="Edm.String" MaxLength="15" />
|
||||
<Property Name="ShipRegion" Type="Edm.String" MaxLength="15" />
|
||||
<Property Name="ShipPostalCode" Type="Edm.String" MaxLength="10" />
|
||||
<Property Name="ShipCountry" Type="Edm.String" MaxLength="15" />
|
||||
<Property Name="CompanyName" Type="Edm.String" Nullable="false" MaxLength="40" />
|
||||
<Property Name="Address" Type="Edm.String" MaxLength="60" />
|
||||
<Property Name="City" Type="Edm.String" MaxLength="15" />
|
||||
<Property Name="Region" Type="Edm.String" MaxLength="15" />
|
||||
<Property Name="PostalCode" Type="Edm.String" MaxLength="10" />
|
||||
<Property Name="Country" Type="Edm.String" MaxLength="15" />
|
||||
</EntityType>
|
||||
<EntityType Name="Product_Sales_for_1997">
|
||||
<Key>
|
||||
<PropertyRef Name="CategoryName" />
|
||||
<PropertyRef Name="ProductName" />
|
||||
</Key>
|
||||
<Property Name="CategoryName" Type="Edm.String" Nullable="false" MaxLength="15" />
|
||||
<Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" />
|
||||
<Property Name="ProductSales" Type="Edm.Decimal" Precision="19" Scale="4" />
|
||||
</EntityType>
|
||||
<EntityType Name="Products_Above_Average_Price">
|
||||
<Key>
|
||||
<PropertyRef Name="ProductName" />
|
||||
</Key>
|
||||
<Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" />
|
||||
<Property Name="UnitPrice" Type="Edm.Decimal" Precision="19" Scale="4" />
|
||||
</EntityType>
|
||||
<EntityType Name="Products_by_Category">
|
||||
<Key>
|
||||
<PropertyRef Name="CategoryName" />
|
||||
<PropertyRef Name="Discontinued" />
|
||||
<PropertyRef Name="ProductName" />
|
||||
</Key>
|
||||
<Property Name="CategoryName" Type="Edm.String" Nullable="false" MaxLength="15" />
|
||||
<Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" />
|
||||
<Property Name="QuantityPerUnit" Type="Edm.String" MaxLength="20" />
|
||||
<Property Name="UnitsInStock" Type="Edm.Int16" />
|
||||
<Property Name="Discontinued" Type="Edm.Boolean" Nullable="false" />
|
||||
</EntityType>
|
||||
<EntityType Name="Sales_by_Category">
|
||||
<Key>
|
||||
<PropertyRef Name="CategoryID" />
|
||||
<PropertyRef Name="CategoryName" />
|
||||
<PropertyRef Name="ProductName" />
|
||||
</Key>
|
||||
<Property Name="CategoryID" Type="Edm.Int32" Nullable="false" />
|
||||
<Property Name="CategoryName" Type="Edm.String" Nullable="false" MaxLength="15" />
|
||||
<Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" />
|
||||
<Property Name="ProductSales" Type="Edm.Decimal" Precision="19" Scale="4" />
|
||||
</EntityType>
|
||||
<EntityType Name="Sales_Totals_by_Amount">
|
||||
<Key>
|
||||
<PropertyRef Name="CompanyName" />
|
||||
<PropertyRef Name="OrderID" />
|
||||
</Key>
|
||||
<Property Name="SaleAmount" Type="Edm.Decimal" Precision="19" Scale="4" />
|
||||
<Property Name="OrderID" Type="Edm.Int32" Nullable="false" />
|
||||
<Property Name="CompanyName" Type="Edm.String" Nullable="false" MaxLength="40" />
|
||||
<Property Name="ShippedDate" Type="Edm.DateTimeOffset" />
|
||||
</EntityType>
|
||||
<EntityType Name="Summary_of_Sales_by_Quarter">
|
||||
<Key>
|
||||
<PropertyRef Name="OrderID" />
|
||||
</Key>
|
||||
<Property Name="ShippedDate" Type="Edm.DateTimeOffset" />
|
||||
<Property Name="OrderID" Type="Edm.Int32" Nullable="false" />
|
||||
<Property Name="Subtotal" Type="Edm.Decimal" Precision="19" Scale="4" />
|
||||
</EntityType>
|
||||
<EntityType Name="Summary_of_Sales_by_Year">
|
||||
<Key>
|
||||
<PropertyRef Name="OrderID" />
|
||||
</Key>
|
||||
<Property Name="ShippedDate" Type="Edm.DateTimeOffset" />
|
||||
<Property Name="OrderID" Type="Edm.Int32" Nullable="false" />
|
||||
<Property Name="Subtotal" Type="Edm.Decimal" Precision="19" Scale="4" />
|
||||
</EntityType>
|
||||
<Annotations Target="ODataWebExperimental.Northwind.Model.NorthwindEntities">
|
||||
<Annotation Term="Com.Microsoft.OData.Service.Conventions.V1.UrlConventions" String="KeyAsSegment" />
|
||||
</Annotations>
|
||||
</Schema>
|
||||
</edmx:DataServices>
|
||||
</edmx:Edmx>
|
|
@ -39,8 +39,10 @@
|
|||
|
||||
<jaxrs:server id="services" address="/">
|
||||
<jaxrs:serviceBeans>
|
||||
<bean class="org.apache.olingo.fit.V4Services"/>
|
||||
<bean class="org.apache.olingo.fit.V3Services"/>
|
||||
<bean class="org.apache.olingo.fit.V4Services"/>
|
||||
<bean class="org.apache.olingo.fit.V4NorthWind"/>
|
||||
<bean class="org.apache.olingo.fit.V4NorthWindExt"/>
|
||||
</jaxrs:serviceBeans>
|
||||
<jaxrs:providers>
|
||||
<bean class="com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider"/>
|
||||
|
|
|
@ -27,30 +27,42 @@ import java.net.URI;
|
|||
public interface CommonRetrieveRequestFactory extends Serializable {
|
||||
|
||||
/**
|
||||
* Gets a service document request instance.
|
||||
* Gets a metadata request instance.
|
||||
* <br/>
|
||||
* Compared to {@link #getMetadataRequest(java.lang.String)}, this method returns a request instance for fetching
|
||||
* low-level metadata representation.
|
||||
*
|
||||
* @param serviceRoot absolute URL (schema, host and port included) representing the location of the root of the data
|
||||
* service.
|
||||
* @return new ODataServiceDocumentRequest instance.
|
||||
* @return new {@link XMLMetadataRequest} instance.
|
||||
*/
|
||||
ODataServiceDocumentRequest getServiceDocumentRequest(String serviceRoot);
|
||||
XMLMetadataRequest getXMLMetadataRequest(String serviceRoot);
|
||||
|
||||
/**
|
||||
* Gets a metadata request instance.
|
||||
*
|
||||
* @param serviceRoot absolute URL (schema, host and port included) representing the location of the root of the data
|
||||
* service.
|
||||
* @return new ODataMetadataRequest instance.
|
||||
* @return new {@link EdmMetadataRequest} instance.
|
||||
*/
|
||||
ODataMetadataRequest getMetadataRequest(String serviceRoot);
|
||||
EdmMetadataRequest getMetadataRequest(String serviceRoot);
|
||||
|
||||
/**
|
||||
* Gets a service document request instance.
|
||||
*
|
||||
* @param serviceRoot absolute URL (schema, host and port included) representing the location of the root of the data
|
||||
* service.
|
||||
* @return new {@link ODataServiceDocumentRequest} instance.
|
||||
*/
|
||||
ODataServiceDocumentRequest getServiceDocumentRequest(String serviceRoot);
|
||||
|
||||
/**
|
||||
* Gets a query request returning a set of one or more OData entities.
|
||||
*
|
||||
* @param query query to be performed.
|
||||
* @return new ODataEntitySetRequest instance.
|
||||
* @param uri request URI.
|
||||
* @return new {@link ODataEntitySetRequest} instance.
|
||||
*/
|
||||
ODataEntitySetRequest getEntitySetRequest(URI query);
|
||||
ODataEntitySetRequest getEntitySetRequest(URI uri);
|
||||
|
||||
/**
|
||||
* Gets a query request returning a set of one or more OData entities.
|
||||
|
@ -58,48 +70,48 @@ public interface CommonRetrieveRequestFactory extends Serializable {
|
|||
* Returned request gives the possibility to consume entities iterating on them without parsing and loading in memory
|
||||
* the entire entity set.
|
||||
*
|
||||
* @param query query to be performed.
|
||||
* @return new ODataEntitySetIteratorRequest instance.
|
||||
* @param uri request URI.
|
||||
* @return new {@link ODataEntitySetIteratorRequest} instance.
|
||||
*/
|
||||
ODataEntitySetIteratorRequest getEntitySetIteratorRequest(URI query);
|
||||
ODataEntitySetIteratorRequest getEntitySetIteratorRequest(URI uri);
|
||||
|
||||
/**
|
||||
* Gets a query request returning a single OData entity.
|
||||
*
|
||||
* @param query query to be performed.
|
||||
* @return new ODataEntityRequest instance.
|
||||
* @param uri request URI.
|
||||
* @return new {@link ODataEntityRequest} instance.
|
||||
*/
|
||||
ODataEntityRequest getEntityRequest(URI query);
|
||||
ODataEntityRequest getEntityRequest(URI uri);
|
||||
|
||||
/**
|
||||
* Gets a query request returning a single OData entity property.
|
||||
*
|
||||
* @param query query to be performed.
|
||||
* @return new ODataPropertyRequest instance.
|
||||
* @param uri request URI.
|
||||
* @return new {@link ODataPropertyRequest} instance.
|
||||
*/
|
||||
ODataPropertyRequest getPropertyRequest(URI query);
|
||||
ODataPropertyRequest getPropertyRequest(URI uri);
|
||||
|
||||
/**
|
||||
* Gets a query request returning a single OData entity property value.
|
||||
*
|
||||
* @param query query to be performed.
|
||||
* @return new ODataValueRequest instance.
|
||||
* @param uri request URI.
|
||||
* @return new {@link ODataValueRequest} instance.
|
||||
*/
|
||||
ODataValueRequest getValueRequest(URI query);
|
||||
ODataValueRequest getValueRequest(URI uri);
|
||||
|
||||
/**
|
||||
* Gets a query request returning a media stream.
|
||||
*
|
||||
* @param query query to be performed.
|
||||
* @return new ODataMediaRequest instance.
|
||||
* @param uri request URI.
|
||||
* @return new {@link ODataMediaRequest} instance.
|
||||
*/
|
||||
ODataMediaRequest getMediaRequest(URI query);
|
||||
ODataMediaRequest getMediaRequest(URI uri);
|
||||
|
||||
/**
|
||||
* Implements a raw request request without specifying any return type.
|
||||
*
|
||||
* @param uri query to be performed.
|
||||
* @return new ODataRawRequest instance.
|
||||
* @param uri request URI.
|
||||
* @return new {@link ODataRawRequest} instance.
|
||||
*/
|
||||
ODataRawRequest getRawRequest(URI uri);
|
||||
}
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
*/
|
||||
package org.apache.olingo.client.api.communication.request.retrieve;
|
||||
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.edm.Edm;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
|
||||
/**
|
||||
* This class implements a metadata query request.
|
||||
*/
|
||||
public interface ODataMetadataRequest extends ODataRetrieveRequest<Edm, ODataPubFormat> {
|
||||
public interface EdmMetadataRequest extends ODataRetrieveRequest<Edm, ODataFormat> {
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.apache.olingo.client.api.communication.request.retrieve;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.olingo.client.api.edm.xml.Schema;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
|
||||
/**
|
||||
* This class implements an XML metadata request.
|
||||
*/
|
||||
public interface XMLMetadataRequest extends ODataRetrieveRequest<List<? extends Schema>, ODataFormat> {
|
||||
}
|
|
@ -20,14 +20,16 @@ package org.apache.olingo.client.api.op;
|
|||
|
||||
import java.io.InputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import org.apache.olingo.client.api.edm.xml.Schema;
|
||||
import org.apache.olingo.commons.api.domain.ODataError;
|
||||
import org.apache.olingo.commons.api.domain.ODataEntity;
|
||||
import org.apache.olingo.commons.api.domain.ODataEntitySet;
|
||||
import org.apache.olingo.commons.api.domain.ODataProperty;
|
||||
import org.apache.olingo.commons.api.domain.ODataServiceDocument;
|
||||
import org.apache.olingo.commons.api.edm.Edm;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.edm.Edm;
|
||||
|
||||
/**
|
||||
* OData reader.
|
||||
|
@ -46,6 +48,15 @@ public interface CommonODataReader extends Serializable {
|
|||
*/
|
||||
Edm readMetadata(InputStream input);
|
||||
|
||||
/**
|
||||
* Parses a stream into metadata representation, including referenced metadata documents.
|
||||
*
|
||||
* @param xmlSchemas XML representation of the requested metadata document + any other referenced (via
|
||||
* <tt><edmx:Reference/></tt>) metadata document
|
||||
* @return metadata representation.
|
||||
*/
|
||||
Edm readMetadata(List<? extends Schema> xmlSchemas);
|
||||
|
||||
/**
|
||||
* Parses an OData service document.
|
||||
*
|
||||
|
|
|
@ -80,7 +80,7 @@ public class ODataRequestImpl<T extends Format> implements ODataRequest {
|
|||
|
||||
protected final CommonODataClient odataClient;
|
||||
|
||||
protected final Class<T> formatRef;
|
||||
private final Class<T> formatRef;
|
||||
|
||||
/**
|
||||
* OData request method.
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.apache.olingo.client.core.communication.request.retrieve;
|
||||
|
||||
import java.net.URI;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.olingo.client.api.CommonODataClient;
|
||||
import org.apache.olingo.client.api.communication.request.ODataRequest;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
|
||||
public abstract class AbstractMetadataRequestImpl<V> extends AbstractODataRetrieveRequest<V, ODataFormat> {
|
||||
|
||||
public AbstractMetadataRequestImpl(final CommonODataClient odataClient, final URI query) {
|
||||
super(odataClient, ODataFormat.class, query);
|
||||
super.setAccept(ContentType.APPLICATION_XML.getMimeType());
|
||||
super.setContentType(ContentType.APPLICATION_XML.getMimeType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataFormat getDefaultFormat() {
|
||||
return ODataFormat.XML;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataRequest setAccept(final String value) {
|
||||
// do nothing: Accept is application/xml
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataRequest setContentType(final String value) {
|
||||
// do nothing: Content-Type is application/xml
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
|
@ -89,6 +89,10 @@ public abstract class AbstractODataRetrieveRequest<V, T extends Format>
|
|||
super(client, res);
|
||||
}
|
||||
|
||||
protected HttpResponse getHttpResponse() {
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc }
|
||||
*/
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRe
|
|||
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetIteratorRequest;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataMediaRequest;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataMetadataRequest;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.EdmMetadataRequest;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataRawRequest;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataServiceDocumentRequest;
|
||||
|
@ -78,8 +78,9 @@ public abstract class AbstractRetrieveRequestFactory implements CommonRetrieveRe
|
|||
}
|
||||
|
||||
@Override
|
||||
public ODataMetadataRequest getMetadataRequest(final String serviceRoot) {
|
||||
return new ODataMetadataRequestImpl(client, client.getURIBuilder(serviceRoot).appendMetadataSegment().build());
|
||||
public EdmMetadataRequest getMetadataRequest(final String serviceRoot) {
|
||||
return new EdmMetadataRequestImpl(client, serviceRoot,
|
||||
client.getURIBuilder(serviceRoot).appendMetadataSegment().build());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.apache.olingo.client.core.communication.request.retrieve;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
import org.apache.olingo.client.api.CommonODataClient;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.EdmMetadataRequest;
|
||||
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
||||
import org.apache.olingo.client.api.edm.xml.Schema;
|
||||
import org.apache.olingo.commons.api.edm.Edm;
|
||||
|
||||
/**
|
||||
* This class implements a metadata query request.
|
||||
*/
|
||||
class EdmMetadataRequestImpl extends AbstractMetadataRequestImpl<Edm> implements EdmMetadataRequest {
|
||||
|
||||
private final String serviceRoot;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param odataClient client instance getting this request
|
||||
* @param uri metadata URI.
|
||||
*/
|
||||
EdmMetadataRequestImpl(final CommonODataClient odataClient, final String serviceRoot, final URI uri) {
|
||||
super(odataClient, uri);
|
||||
this.serviceRoot = serviceRoot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataRetrieveResponse<Edm> execute() {
|
||||
final ODataRetrieveResponse<List<? extends Schema>> xmlMetadataResponse =
|
||||
odataClient.getRetrieveRequestFactory().getXMLMetadataRequest(serviceRoot).execute();
|
||||
|
||||
return new ODataRetrieveResponseImpl() {
|
||||
private Edm metadata = null;
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
xmlMetadataResponse.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Edm getBody() {
|
||||
if (metadata == null) {
|
||||
try {
|
||||
metadata = odataClient.getReader().readMetadata(xmlMetadataResponse.getBody());
|
||||
} finally {
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
return metadata;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,108 +0,0 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.apache.olingo.client.core.communication.request.retrieve;
|
||||
|
||||
import java.net.URI;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.olingo.client.api.CommonODataClient;
|
||||
import org.apache.olingo.client.api.communication.request.ODataRequest;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataMetadataRequest;
|
||||
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.edm.Edm;
|
||||
|
||||
/**
|
||||
* This class implements a metadata query request.
|
||||
*/
|
||||
class ODataMetadataRequestImpl extends AbstractODataRetrieveRequest<Edm, ODataPubFormat>
|
||||
implements ODataMetadataRequest {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param odataClient client instance getting this request
|
||||
* @param uri metadata URI.
|
||||
*/
|
||||
ODataMetadataRequestImpl(final CommonODataClient odataClient, final URI uri) {
|
||||
super(odataClient, ODataPubFormat.class, uri);
|
||||
super.setAccept(ContentType.APPLICATION_XML.getMimeType());
|
||||
super.setContentType(ContentType.APPLICATION_XML.getMimeType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataRequest setAccept(final String value) {
|
||||
// do nothing: Accept is application/XML
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataRequest setContentType(final String value) {
|
||||
// do nothing: Accept is application/XML
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataRetrieveResponse<Edm> execute() {
|
||||
final HttpResponse res = doExecute();
|
||||
return new ODataMetadataResponseImpl(httpClient, res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Response class about an ODataMetadataRequest.
|
||||
*/
|
||||
protected class ODataMetadataResponseImpl extends ODataRetrieveResponseImpl {
|
||||
|
||||
private Edm metadata = null;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* <p>
|
||||
* Just to create response templates to be initialized from batch.
|
||||
*/
|
||||
public ODataMetadataResponseImpl() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param client HTTP client.
|
||||
* @param res HTTP response.
|
||||
*/
|
||||
private ODataMetadataResponseImpl(final HttpClient client, final HttpResponse res) {
|
||||
super(client, res);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc }
|
||||
*/
|
||||
@Override
|
||||
public Edm getBody() {
|
||||
if (metadata == null) {
|
||||
try {
|
||||
metadata = odataClient.getReader().readMetadata(getRawResponse());
|
||||
} finally {
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
return metadata;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,8 +18,8 @@
|
|||
*/
|
||||
package org.apache.olingo.client.core.communication.request.retrieve.v3;
|
||||
|
||||
import org.apache.olingo.client.core.communication.request.retrieve.v3.ODataLinkCollectionRequestImpl;
|
||||
import java.net.URI;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.XMLMetadataRequest;
|
||||
import org.apache.olingo.client.api.v3.ODataClient;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.v3.ODataLinkCollectionRequest;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.v3.RetrieveRequestFactory;
|
||||
|
@ -34,6 +34,12 @@ public class RetrieveRequestFactoryImpl extends AbstractRetrieveRequestFactory
|
|||
super(client);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLMetadataRequest getXMLMetadataRequest(final String serviceRoot) {
|
||||
return new XMLMetadataRequestImpl(((ODataClient) client),
|
||||
client.getURIBuilder(serviceRoot).appendMetadataSegment().build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataLinkCollectionRequest getLinkCollectionRequest(final URI targetURI, final String linkName) {
|
||||
return new ODataLinkCollectionRequestImpl((ODataClient) client, targetURI, linkName);
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.apache.olingo.client.core.communication.request.retrieve.v3;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.XMLMetadataRequest;
|
||||
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
||||
import org.apache.olingo.client.api.edm.xml.Schema;
|
||||
import org.apache.olingo.client.api.edm.xml.XMLMetadata;
|
||||
import org.apache.olingo.client.api.v3.ODataClient;
|
||||
import org.apache.olingo.client.core.communication.request.retrieve.AbstractMetadataRequestImpl;
|
||||
|
||||
public class XMLMetadataRequestImpl extends AbstractMetadataRequestImpl<List<? extends Schema>>
|
||||
implements XMLMetadataRequest {
|
||||
|
||||
XMLMetadataRequestImpl(final ODataClient odataClient, final URI query) {
|
||||
super(odataClient, query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataRetrieveResponse<List<? extends Schema>> execute() {
|
||||
return new XMLMetadataResponseImpl(httpClient, doExecute());
|
||||
}
|
||||
|
||||
public class XMLMetadataResponseImpl extends ODataRetrieveResponseImpl {
|
||||
|
||||
private XMLMetadata metadata = null;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* <br/>
|
||||
* Just to create response templates to be initialized from batch.
|
||||
*/
|
||||
private XMLMetadataResponseImpl() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param client HTTP client.
|
||||
* @param res HTTP response.
|
||||
*/
|
||||
private XMLMetadataResponseImpl(final HttpClient client, final HttpResponse res) {
|
||||
super(client, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Schema> getBody() {
|
||||
if (metadata == null) {
|
||||
try {
|
||||
metadata = odataClient.getDeserializer().toMetadata(getRawResponse());
|
||||
} finally {
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
return metadata.getSchemas();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.apache.olingo.client.core.communication.request.retrieve.v4;
|
||||
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.XMLMetadataRequest;
|
||||
import org.apache.olingo.client.api.v4.ODataClient;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.v4.RetrieveRequestFactory;
|
||||
import org.apache.olingo.client.core.communication.request.retrieve.AbstractRetrieveRequestFactory;
|
||||
|
@ -30,4 +31,10 @@ public class RetrieveRequestFactoryImpl extends AbstractRetrieveRequestFactory
|
|||
public RetrieveRequestFactoryImpl(final ODataClient client) {
|
||||
super(client);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLMetadataRequest getXMLMetadataRequest(final String serviceRoot) {
|
||||
return new XMLMetadataRequestImpl(((ODataClient) client),
|
||||
client.getURIBuilder(serviceRoot).appendMetadataSegment().build());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,122 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.apache.olingo.client.core.communication.request.retrieve.v4;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.XMLMetadataRequest;
|
||||
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
||||
import org.apache.olingo.client.api.edm.xml.Schema;
|
||||
import org.apache.olingo.client.api.edm.xml.v4.Include;
|
||||
import org.apache.olingo.client.api.edm.xml.v4.Reference;
|
||||
import org.apache.olingo.client.api.edm.xml.v4.XMLMetadata;
|
||||
import org.apache.olingo.client.api.v4.ODataClient;
|
||||
import org.apache.olingo.client.core.communication.request.retrieve.AbstractMetadataRequestImpl;
|
||||
|
||||
public class XMLMetadataRequestImpl extends AbstractMetadataRequestImpl<List<? extends Schema>>
|
||||
implements XMLMetadataRequest {
|
||||
|
||||
XMLMetadataRequestImpl(final ODataClient odataClient, final URI uri) {
|
||||
super(odataClient, uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataRetrieveResponse<List<? extends Schema>> execute() {
|
||||
final SingleXMLMetadatRequestImpl rootReq = new SingleXMLMetadatRequestImpl((ODataClient) odataClient, uri);
|
||||
final ODataRetrieveResponse<XMLMetadata> rootRes = rootReq.execute();
|
||||
|
||||
final XMLMetadataResponseImpl response = new XMLMetadataResponseImpl();
|
||||
|
||||
final XMLMetadata rootMetadata = rootRes.getBody();
|
||||
response.getSchemas().addAll(rootMetadata.getSchemas());
|
||||
|
||||
if (!rootMetadata.getReferences().isEmpty()) {
|
||||
for (Reference reference : rootMetadata.getReferences()) {
|
||||
final SingleXMLMetadatRequestImpl includeReq = new SingleXMLMetadatRequestImpl((ODataClient) odataClient,
|
||||
odataClient.getURIBuilder(reference.getUri().toASCIIString()).appendMetadataSegment().build());
|
||||
final XMLMetadata includeMetadata = includeReq.execute().getBody();
|
||||
|
||||
for (Include include : reference.getIncludes()) {
|
||||
Schema includedSchema = includeMetadata.getSchema(include.getNamespace());
|
||||
if (includedSchema == null && StringUtils.isNotBlank(include.getAlias())) {
|
||||
includedSchema = includeMetadata.getSchema(include.getAlias());
|
||||
}
|
||||
if (includedSchema != null) {
|
||||
response.getSchemas().add(includedSchema);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
private class SingleXMLMetadatRequestImpl extends AbstractMetadataRequestImpl<XMLMetadata> {
|
||||
|
||||
public SingleXMLMetadatRequestImpl(final ODataClient odataClient, final URI uri) {
|
||||
super(odataClient, uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataRetrieveResponse<XMLMetadata> execute() {
|
||||
return new ODataRetrieveResponseImpl(httpClient, doExecute()) {
|
||||
|
||||
@Override
|
||||
public XMLMetadata getBody() {
|
||||
try {
|
||||
return ((ODataClient) odataClient).getDeserializer().toMetadata(getRawResponse());
|
||||
} finally {
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class XMLMetadataResponseImpl extends ODataRetrieveResponseImpl {
|
||||
|
||||
private final List<Schema> schemas = new ArrayList<Schema>();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* <br/>
|
||||
* Just to create response templates to be initialized from batch.
|
||||
*/
|
||||
private XMLMetadataResponseImpl() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
// just do nothing, this is a placeholder response
|
||||
}
|
||||
|
||||
public List<Schema> getSchemas() {
|
||||
return schemas;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Schema> getBody() {
|
||||
return getSchemas();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -29,16 +29,16 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
|||
import org.apache.olingo.client.api.edm.xml.EntityContainer;
|
||||
import org.apache.olingo.client.api.edm.xml.EntitySet;
|
||||
import org.apache.olingo.client.api.edm.xml.Schema;
|
||||
import org.apache.olingo.client.api.edm.xml.XMLMetadata;
|
||||
import org.apache.olingo.commons.api.edm.EdmActionImportInfo;
|
||||
import org.apache.olingo.commons.api.edm.EdmEntitySetInfo;
|
||||
import org.apache.olingo.commons.api.edm.EdmFunctionImportInfo;
|
||||
import org.apache.olingo.commons.api.edm.EdmServiceMetadata;
|
||||
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
||||
import org.apache.olingo.commons.core.edm.EdmEntitySetInfoImpl;
|
||||
|
||||
public abstract class AbstractEdmServiceMetadataImpl implements EdmServiceMetadata {
|
||||
|
||||
protected final XMLMetadata xmlMetadata;
|
||||
protected final List<? extends Schema> xmlSchemas;
|
||||
|
||||
private List<EdmEntitySetInfo> entitySetInfos;
|
||||
|
||||
|
@ -46,17 +46,16 @@ public abstract class AbstractEdmServiceMetadataImpl implements EdmServiceMetada
|
|||
|
||||
protected List<EdmActionImportInfo> actionImportInfos;
|
||||
|
||||
public static EdmServiceMetadata getInstance(final XMLMetadata xmlMetadata) {
|
||||
return xmlMetadata instanceof org.apache.olingo.client.core.edm.xml.v3.XMLMetadataImpl
|
||||
? new org.apache.olingo.client.core.edm.v3.EdmServiceMetadataImpl(
|
||||
(org.apache.olingo.client.core.edm.xml.v3.XMLMetadataImpl) xmlMetadata)
|
||||
: new org.apache.olingo.client.core.edm.v4.EdmServiceMetadataImpl(
|
||||
(org.apache.olingo.client.core.edm.xml.v4.XMLMetadataImpl) xmlMetadata);
|
||||
public static EdmServiceMetadata getInstance(final ODataServiceVersion version,
|
||||
final List<? extends Schema> xmlSchemas) {
|
||||
|
||||
return version == ODataServiceVersion.V30
|
||||
? new org.apache.olingo.client.core.edm.v3.EdmServiceMetadataImpl(xmlSchemas)
|
||||
: new org.apache.olingo.client.core.edm.v4.EdmServiceMetadataImpl(xmlSchemas);
|
||||
}
|
||||
|
||||
public AbstractEdmServiceMetadataImpl(final XMLMetadata xmlMetadata) {
|
||||
this.xmlMetadata = xmlMetadata;
|
||||
public AbstractEdmServiceMetadataImpl(final List<? extends Schema> xmlSchemas) {
|
||||
this.xmlSchemas = xmlSchemas;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -69,11 +68,10 @@ public abstract class AbstractEdmServiceMetadataImpl implements EdmServiceMetada
|
|||
synchronized (this) {
|
||||
if (entitySetInfos == null) {
|
||||
entitySetInfos = new ArrayList<EdmEntitySetInfo>();
|
||||
for (Schema schema : xmlMetadata.getSchemas()) {
|
||||
for (Schema schema : xmlSchemas) {
|
||||
for (EntityContainer entityContainer : schema.getEntityContainers()) {
|
||||
for (EntitySet entitySet : entityContainer.getEntitySets()) {
|
||||
entitySetInfos.add(
|
||||
new EdmEntitySetInfoImpl(entityContainer.getName(), entitySet.getName()));
|
||||
entitySetInfos.add(new EdmEntitySetInfoImpl(entityContainer.getName(), entitySet.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ import org.apache.olingo.client.api.edm.xml.EntityContainer;
|
|||
import org.apache.olingo.client.api.edm.xml.EntityType;
|
||||
import org.apache.olingo.client.api.edm.xml.EnumType;
|
||||
import org.apache.olingo.client.api.edm.xml.Schema;
|
||||
import org.apache.olingo.client.api.edm.xml.XMLMetadata;
|
||||
import org.apache.olingo.client.api.edm.xml.v3.FunctionImport;
|
||||
import org.apache.olingo.client.api.edm.xml.v4.Action;
|
||||
import org.apache.olingo.client.api.edm.xml.v4.Function;
|
||||
|
@ -64,18 +63,23 @@ public class EdmClientImpl extends AbstractEdmImpl {
|
|||
|
||||
private final ODataServiceVersion version;
|
||||
|
||||
private final XMLMetadata xmlMetadata;
|
||||
private final List<? extends Schema> xmlSchemas;
|
||||
|
||||
private final Map<String, Schema> xmlSchemaByNamespace;
|
||||
|
||||
private final EdmServiceMetadata serviceMetadata;
|
||||
|
||||
public EdmClientImpl(final ODataServiceVersion version, final XMLMetadata xmlMetadata) {
|
||||
public EdmClientImpl(final ODataServiceVersion version, final List<? extends Schema> xmlSchemas) {
|
||||
this.version = version;
|
||||
this.xmlMetadata = xmlMetadata;
|
||||
this.serviceMetadata = AbstractEdmServiceMetadataImpl.getInstance(xmlMetadata);
|
||||
}
|
||||
|
||||
public XMLMetadata getXMLMetadata() {
|
||||
return xmlMetadata;
|
||||
this.xmlSchemas = xmlSchemas;
|
||||
|
||||
this.xmlSchemaByNamespace = new HashMap<String, Schema>();
|
||||
for (Schema schema : xmlSchemas) {
|
||||
xmlSchemaByNamespace.put(schema.getNamespace(), schema);
|
||||
}
|
||||
|
||||
this.serviceMetadata = AbstractEdmServiceMetadataImpl.getInstance(version, xmlSchemas);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -87,7 +91,7 @@ public class EdmClientImpl extends AbstractEdmImpl {
|
|||
protected Map<String, String> createAliasToNamespaceInfo() {
|
||||
final Map<String, String> aliasToNamespace = new HashMap<String, String>();
|
||||
|
||||
for (Schema schema : xmlMetadata.getSchemas()) {
|
||||
for (Schema schema : xmlSchemas) {
|
||||
aliasToNamespace.put(null, schema.getNamespace());
|
||||
if (StringUtils.isNotBlank(schema.getAlias())) {
|
||||
aliasToNamespace.put(schema.getAlias(), schema.getNamespace());
|
||||
|
@ -101,11 +105,11 @@ public class EdmClientImpl extends AbstractEdmImpl {
|
|||
protected EdmEntityContainer createEntityContainer(final FullQualifiedName containerName) {
|
||||
EdmEntityContainer result = null;
|
||||
|
||||
final Schema schema = xmlMetadata.getSchema(containerName.getNamespace());
|
||||
final Schema schema = xmlSchemaByNamespace.get(containerName.getNamespace());
|
||||
if (schema != null) {
|
||||
final EntityContainer xmlEntityContainer = schema.getDefaultEntityContainer();
|
||||
if (xmlEntityContainer != null) {
|
||||
result = new EdmEntityContainerImpl(this, containerName, xmlEntityContainer, xmlMetadata);
|
||||
result = new EdmEntityContainerImpl(this, containerName, xmlEntityContainer, xmlSchemas);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,7 +120,7 @@ public class EdmClientImpl extends AbstractEdmImpl {
|
|||
protected EdmEnumType createEnumType(final FullQualifiedName enumName) {
|
||||
EdmEnumType result = null;
|
||||
|
||||
final Schema schema = xmlMetadata.getSchema(enumName.getNamespace());
|
||||
final Schema schema = xmlSchemaByNamespace.get(enumName.getNamespace());
|
||||
if (schema != null) {
|
||||
final EnumType xmlEnumType = schema.getEnumType(enumName.getName());
|
||||
if (xmlEnumType != null) {
|
||||
|
@ -131,7 +135,7 @@ public class EdmClientImpl extends AbstractEdmImpl {
|
|||
protected EdmTypeDefinition createTypeDefinition(final FullQualifiedName typeDefinitionName) {
|
||||
EdmTypeDefinition result = null;
|
||||
|
||||
final Schema schema = xmlMetadata.getSchema(typeDefinitionName.getNamespace());
|
||||
final Schema schema = xmlSchemaByNamespace.get(typeDefinitionName.getNamespace());
|
||||
if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) {
|
||||
final TypeDefinition xmlTypeDefinition = ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).
|
||||
getTypeDefinition(typeDefinitionName.getName());
|
||||
|
@ -149,7 +153,7 @@ public class EdmClientImpl extends AbstractEdmImpl {
|
|||
protected EdmEntityType createEntityType(final FullQualifiedName entityTypeName) {
|
||||
EdmEntityType result = null;
|
||||
|
||||
final Schema schema = xmlMetadata.getSchema(entityTypeName.getNamespace());
|
||||
final Schema schema = xmlSchemaByNamespace.get(entityTypeName.getNamespace());
|
||||
final EntityType xmlEntityType = schema.getEntityType(entityTypeName.getName());
|
||||
if (xmlEntityType != null) {
|
||||
result = EdmEntityTypeImpl.getInstance(this, entityTypeName, xmlEntityType);
|
||||
|
@ -162,7 +166,7 @@ public class EdmClientImpl extends AbstractEdmImpl {
|
|||
protected EdmComplexType createComplexType(final FullQualifiedName complexTypeName) {
|
||||
EdmComplexType result = null;
|
||||
|
||||
final Schema schema = xmlMetadata.getSchema(complexTypeName.getNamespace());
|
||||
final Schema schema = xmlSchemaByNamespace.get(complexTypeName.getNamespace());
|
||||
final ComplexType xmlComplexType = schema.getComplexType(complexTypeName.getName());
|
||||
if (xmlComplexType != null) {
|
||||
result = EdmComplexTypeImpl.getInstance(this, complexTypeName, xmlComplexType);
|
||||
|
@ -175,7 +179,7 @@ public class EdmClientImpl extends AbstractEdmImpl {
|
|||
protected EdmAction createUnboundAction(final FullQualifiedName actionName) {
|
||||
EdmAction result = null;
|
||||
|
||||
final Schema schema = xmlMetadata.getSchema(actionName.getNamespace());
|
||||
final Schema schema = xmlSchemaByNamespace.get(actionName.getNamespace());
|
||||
if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) {
|
||||
final List<Action> actions = ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).
|
||||
getActions(actionName.getName());
|
||||
|
@ -210,7 +214,7 @@ public class EdmClientImpl extends AbstractEdmImpl {
|
|||
protected EdmFunction createUnboundFunction(final FullQualifiedName functionName, final List<String> parameterNames) {
|
||||
EdmFunction result = null;
|
||||
|
||||
final Schema schema = xmlMetadata.getSchema(functionName.getNamespace());
|
||||
final Schema schema = xmlSchemaByNamespace.get(functionName.getNamespace());
|
||||
if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) {
|
||||
final List<Function> functions = ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).
|
||||
getFunctions(functionName.getName());
|
||||
|
@ -259,7 +263,7 @@ public class EdmClientImpl extends AbstractEdmImpl {
|
|||
|
||||
EdmAction result = null;
|
||||
|
||||
final Schema schema = xmlMetadata.getSchema(actionName.getNamespace());
|
||||
final Schema schema = xmlSchemaByNamespace.get(actionName.getNamespace());
|
||||
if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) {
|
||||
final List<Action> actions = ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).
|
||||
getActions(actionName.getName());
|
||||
|
@ -309,7 +313,7 @@ public class EdmClientImpl extends AbstractEdmImpl {
|
|||
|
||||
EdmFunction result = null;
|
||||
|
||||
final Schema schema = xmlMetadata.getSchema(functionName.getNamespace());
|
||||
final Schema schema = xmlSchemaByNamespace.get(functionName.getNamespace());
|
||||
if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) {
|
||||
final List<Function> functions = ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).
|
||||
getFunctions(functionName.getName());
|
||||
|
@ -382,8 +386,8 @@ public class EdmClientImpl extends AbstractEdmImpl {
|
|||
@Override
|
||||
protected List<EdmSchema> createSchemas() {
|
||||
final List<EdmSchema> schemas = new ArrayList<EdmSchema>();
|
||||
for (Schema schema : xmlMetadata.getSchemas()) {
|
||||
schemas.add(new EdmSchemaImpl(version, this, xmlMetadata, schema));
|
||||
for (Schema schema : xmlSchemas) {
|
||||
schemas.add(new EdmSchemaImpl(version, this, xmlSchemas, schema));
|
||||
}
|
||||
return schemas;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.apache.olingo.client.api.v3.UnsupportedInV3Exception;
|
|||
import org.apache.olingo.client.api.edm.xml.CommonFunctionImport;
|
||||
import org.apache.olingo.client.api.edm.xml.EntityContainer;
|
||||
import org.apache.olingo.client.api.edm.xml.EntitySet;
|
||||
import org.apache.olingo.client.api.edm.xml.XMLMetadata;
|
||||
import org.apache.olingo.client.api.edm.xml.Schema;
|
||||
import org.apache.olingo.client.api.edm.xml.v3.FunctionImport;
|
||||
import org.apache.olingo.client.api.edm.xml.v4.ActionImport;
|
||||
import org.apache.olingo.client.api.edm.xml.v4.Singleton;
|
||||
|
@ -45,15 +45,15 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
|
|||
|
||||
private final EntityContainer xmlEntityContainer;
|
||||
|
||||
private final XMLMetadata xmlMetadata;
|
||||
private final List<? extends Schema> xmlSchemas;
|
||||
|
||||
public EdmEntityContainerImpl(final Edm edm, final FullQualifiedName entityContainerName,
|
||||
final EntityContainer xmlEntityContainer, final XMLMetadata xmlMetadata) {
|
||||
final EntityContainer xmlEntityContainer, final List<? extends Schema> xmlSchemas) {
|
||||
|
||||
super(edm, entityContainerName);
|
||||
|
||||
this.xmlEntityContainer = xmlEntityContainer;
|
||||
this.xmlMetadata = xmlMetadata;
|
||||
this.xmlSchemas = xmlSchemas;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -63,13 +63,13 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
|
|||
}
|
||||
|
||||
final Singleton singleton = ((org.apache.olingo.client.api.edm.xml.v4.EntityContainer) xmlEntityContainer).
|
||||
getSingleton(singletonName);
|
||||
getSingleton(singletonName);
|
||||
if (singleton == null) {
|
||||
throw new EdmException("Singleton named '" + singletonName + "' not found in " + entityContainerName);
|
||||
}
|
||||
return new EdmSingletonImpl(edm, this, singletonName, new EdmTypeInfo.Builder().
|
||||
setTypeExpression(singleton.getEntityType()).setDefaultNamespace(entityContainerName.getNamespace()).
|
||||
build().getFullQualifiedName(), singleton);
|
||||
setTypeExpression(singleton.getEntityType()).setDefaultNamespace(entityContainerName.getNamespace()).
|
||||
build().getFullQualifiedName(), singleton);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -80,12 +80,12 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
|
|||
}
|
||||
|
||||
final FullQualifiedName entityType = new EdmTypeInfo.Builder().setTypeExpression(entitySet.getEntityType()).
|
||||
setDefaultNamespace(entityContainerName.getNamespace()).build().getFullQualifiedName();
|
||||
setDefaultNamespace(entityContainerName.getNamespace()).build().getFullQualifiedName();
|
||||
if (entitySet instanceof org.apache.olingo.client.api.edm.xml.v4.EntitySet) {
|
||||
return new EdmEntitySetImpl(edm, this, entitySetName, entityType,
|
||||
(org.apache.olingo.client.api.edm.xml.v4.EntitySet) entitySet);
|
||||
(org.apache.olingo.client.api.edm.xml.v4.EntitySet) entitySet);
|
||||
} else {
|
||||
return new EdmEntitySetProxy(edm, this, entitySetName, entityType, xmlMetadata);
|
||||
return new EdmEntitySetProxy(edm, this, entitySetName, entityType, xmlSchemas);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
|
|||
protected EdmActionImport createActionImport(final String actionImportName) {
|
||||
if (xmlEntityContainer instanceof org.apache.olingo.client.api.edm.xml.v4.EntityContainer) {
|
||||
final ActionImport actionImport = ((org.apache.olingo.client.api.edm.xml.v4.EntityContainer) xmlEntityContainer).
|
||||
getActionImport(actionImportName);
|
||||
getActionImport(actionImportName);
|
||||
if (actionImport == null) {
|
||||
throw new EdmException("ActionImport named '" + actionImportName + "' not found in " + entityContainerName);
|
||||
}
|
||||
|
@ -116,10 +116,10 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
|
|||
|
||||
if (functionImport instanceof org.apache.olingo.client.api.edm.xml.v4.FunctionImport) {
|
||||
return new EdmFunctionImportImpl(edm, this, functionImportName,
|
||||
(org.apache.olingo.client.api.edm.xml.v4.FunctionImport) functionImport);
|
||||
(org.apache.olingo.client.api.edm.xml.v4.FunctionImport) functionImport);
|
||||
} else {
|
||||
return new EdmFunctionImportProxy(edm, this, functionImportName,
|
||||
(org.apache.olingo.client.api.edm.xml.v3.FunctionImport) functionImport);
|
||||
(org.apache.olingo.client.api.edm.xml.v3.FunctionImport) functionImport);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,13 +130,13 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
|
|||
for (EntitySet entitySet : localEntitySets) {
|
||||
EdmEntitySet edmSet;
|
||||
final FullQualifiedName entityType = new EdmTypeInfo.Builder().setTypeExpression(entitySet.getEntityType()).
|
||||
setDefaultNamespace(entityContainerName.getNamespace()).build().getFullQualifiedName();
|
||||
setDefaultNamespace(entityContainerName.getNamespace()).build().getFullQualifiedName();
|
||||
if (entitySet instanceof org.apache.olingo.client.api.edm.xml.v4.EntitySet) {
|
||||
edmSet =
|
||||
new EdmEntitySetImpl(edm, this, entitySet.getName(), entityType,
|
||||
(org.apache.olingo.client.api.edm.xml.v4.EntitySet) entitySet);
|
||||
new EdmEntitySetImpl(edm, this, entitySet.getName(), entityType,
|
||||
(org.apache.olingo.client.api.edm.xml.v4.EntitySet) entitySet);
|
||||
} else {
|
||||
edmSet = new EdmEntitySetProxy(edm, this, entitySet.getName(), entityType, xmlMetadata);
|
||||
edmSet = new EdmEntitySetProxy(edm, this, entitySet.getName(), entityType, xmlSchemas);
|
||||
}
|
||||
entitySets.put(edmSet.getName(), edmSet);
|
||||
}
|
||||
|
@ -152,10 +152,10 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
|
|||
EdmFunctionImport edmFunctionImport;
|
||||
if (functionImport instanceof org.apache.olingo.client.api.edm.xml.v4.FunctionImport) {
|
||||
edmFunctionImport = new EdmFunctionImportImpl(edm, this, functionImport.getName(),
|
||||
(org.apache.olingo.client.api.edm.xml.v4.FunctionImport) functionImport);
|
||||
(org.apache.olingo.client.api.edm.xml.v4.FunctionImport) functionImport);
|
||||
} else {
|
||||
edmFunctionImport = new EdmFunctionImportProxy(edm, this, functionImport.getName(),
|
||||
(org.apache.olingo.client.api.edm.xml.v3.FunctionImport) functionImport);
|
||||
(org.apache.olingo.client.api.edm.xml.v3.FunctionImport) functionImport);
|
||||
}
|
||||
functionImports.put(edmFunctionImport.getName(), edmFunctionImport);
|
||||
}
|
||||
|
@ -169,11 +169,11 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
|
|||
}
|
||||
|
||||
final List<Singleton> localSingletons =
|
||||
((org.apache.olingo.client.api.edm.xml.v4.EntityContainer) xmlEntityContainer).getSingletons();
|
||||
((org.apache.olingo.client.api.edm.xml.v4.EntityContainer) xmlEntityContainer).getSingletons();
|
||||
if (localSingletons != null) {
|
||||
for (Singleton singleton : localSingletons) {
|
||||
singletons.put(singleton.getName(), new EdmSingletonImpl(edm, this, singleton.getName(),
|
||||
new EdmTypeInfo.Builder().
|
||||
new EdmTypeInfo.Builder().
|
||||
setTypeExpression(singleton.getEntityType()).setDefaultNamespace(entityContainerName.getNamespace()).
|
||||
build().getFullQualifiedName(), singleton));
|
||||
}
|
||||
|
@ -184,11 +184,11 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
|
|||
protected void loadAllActionImports() {
|
||||
if (xmlEntityContainer instanceof org.apache.olingo.client.api.edm.xml.v4.EntityContainer) {
|
||||
final List<ActionImport> localActionImports =
|
||||
((org.apache.olingo.client.api.edm.xml.v4.EntityContainer) xmlEntityContainer).getActionImports();
|
||||
((org.apache.olingo.client.api.edm.xml.v4.EntityContainer) xmlEntityContainer).getActionImports();
|
||||
if (actionImports != null) {
|
||||
for (ActionImport actionImport : localActionImports) {
|
||||
actionImports.put(actionImport.getName(),
|
||||
new EdmActionImportImpl(edm, this, actionImport.getName(), actionImport));
|
||||
new EdmActionImportImpl(edm, this, actionImport.getName(), actionImport));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -197,7 +197,7 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
|
|||
if (localFunctionImports != null) {
|
||||
for (FunctionImport functionImport : localFunctionImports) {
|
||||
actionImports.put(functionImport.getName(),
|
||||
new EdmActionImportProxy(edm, this, functionImport.getName(), functionImport));
|
||||
new EdmActionImportProxy(edm, this, functionImport.getName(), functionImport));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ import org.apache.olingo.client.api.edm.xml.EntityContainer;
|
|||
import org.apache.olingo.client.api.edm.xml.EntityType;
|
||||
import org.apache.olingo.client.api.edm.xml.EnumType;
|
||||
import org.apache.olingo.client.api.edm.xml.Schema;
|
||||
import org.apache.olingo.client.api.edm.xml.XMLMetadata;
|
||||
import org.apache.olingo.client.api.edm.xml.v3.FunctionImport;
|
||||
import org.apache.olingo.client.api.edm.xml.v4.Action;
|
||||
import org.apache.olingo.client.api.edm.xml.v4.Function;
|
||||
|
@ -50,18 +49,18 @@ public class EdmSchemaImpl extends AbstractEdmSchemaImpl {
|
|||
|
||||
private final Edm edm;
|
||||
|
||||
private final XMLMetadata xmlMetadata;
|
||||
private final List<? extends Schema> xmlSchemas;
|
||||
|
||||
private final Schema schema;
|
||||
|
||||
public EdmSchemaImpl(final ODataServiceVersion version, final Edm edm,
|
||||
final XMLMetadata xmlMetadata, final Schema schema) {
|
||||
final List<? extends Schema> xmlSchemas, final Schema schema) {
|
||||
|
||||
super(schema.getNamespace(), schema.getAlias());
|
||||
|
||||
this.version = version;
|
||||
this.edm = edm;
|
||||
this.xmlMetadata = xmlMetadata;
|
||||
this.xmlSchemas = xmlSchemas;
|
||||
this.schema = schema;
|
||||
}
|
||||
|
||||
|
@ -71,7 +70,7 @@ public class EdmSchemaImpl extends AbstractEdmSchemaImpl {
|
|||
if (defaultContainer != null) {
|
||||
final FullQualifiedName entityContainerName =
|
||||
new FullQualifiedName(schema.getNamespace(), defaultContainer.getName());
|
||||
return new EdmEntityContainerImpl(edm, entityContainerName, defaultContainer, xmlMetadata);
|
||||
return new EdmEntityContainerImpl(edm, entityContainerName, defaultContainer, xmlSchemas);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.util.List;
|
|||
|
||||
import org.apache.olingo.client.api.edm.xml.EntityContainer;
|
||||
import org.apache.olingo.client.api.edm.xml.Schema;
|
||||
import org.apache.olingo.client.api.edm.xml.XMLMetadata;
|
||||
import org.apache.olingo.client.api.edm.xml.v3.Association;
|
||||
import org.apache.olingo.client.api.edm.xml.v3.AssociationSet;
|
||||
import org.apache.olingo.client.core.edm.xml.v3.EntityContainerImpl;
|
||||
|
@ -38,19 +37,19 @@ import org.apache.olingo.commons.core.edm.AbstractEdmBindingTarget;
|
|||
|
||||
public class EdmEntitySetProxy extends AbstractEdmBindingTarget implements EdmEntitySet {
|
||||
|
||||
private final XMLMetadata xmlMetadata;
|
||||
private final List<? extends Schema> xmlSchemas;
|
||||
|
||||
public EdmEntitySetProxy(final Edm edm, final EdmEntityContainer container, final String name,
|
||||
final FullQualifiedName type, final XMLMetadata xmlMetadata) {
|
||||
final FullQualifiedName type, final List<? extends Schema> xmlSchemas) {
|
||||
|
||||
super(edm, container, name, type);
|
||||
this.xmlMetadata = xmlMetadata;
|
||||
this.xmlSchemas = xmlSchemas;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EdmBindingTarget getRelatedBindingTarget(final String path) {
|
||||
final List<AssociationSet> candidateAssociationSets = new ArrayList<AssociationSet>();
|
||||
for (Schema schema : xmlMetadata.getSchemas()) {
|
||||
for (Schema schema : xmlSchemas) {
|
||||
for (EntityContainer _entityContainer : schema.getEntityContainers()) {
|
||||
final EntityContainerImpl entityContainer = (EntityContainerImpl) _entityContainer;
|
||||
for (AssociationSet associationSet : entityContainer.getAssociationSets()) {
|
||||
|
@ -69,7 +68,7 @@ public class EdmEntitySetProxy extends AbstractEdmBindingTarget implements EdmEn
|
|||
Schema targetSchema = null;
|
||||
String targetEntitySet = null;
|
||||
for (AssociationSet associationSet : candidateAssociationSets) {
|
||||
for (Schema schema : xmlMetadata.getSchemas()) {
|
||||
for (Schema schema : xmlSchemas) {
|
||||
for (Association association : ((SchemaImpl) schema).getAssociations()) {
|
||||
final FullQualifiedName associationName = new FullQualifiedName(schema.getNamespace(), association.getName());
|
||||
if (associationName.getFullQualifiedNameAsString().equals(associationSet.getAssociation())
|
||||
|
|
|
@ -27,7 +27,6 @@ import org.apache.olingo.client.api.edm.xml.EntityContainer;
|
|||
import org.apache.olingo.client.api.edm.xml.Schema;
|
||||
import org.apache.olingo.client.api.edm.xml.v3.FunctionImport;
|
||||
import org.apache.olingo.client.core.edm.AbstractEdmServiceMetadataImpl;
|
||||
import org.apache.olingo.client.core.edm.xml.v3.XMLMetadataImpl;
|
||||
import org.apache.olingo.commons.api.edm.EdmActionImportInfo;
|
||||
import org.apache.olingo.commons.api.edm.EdmFunctionImportInfo;
|
||||
import org.apache.olingo.commons.api.edm.EdmSingletonInfo;
|
||||
|
@ -39,8 +38,8 @@ public class EdmServiceMetadataImpl extends AbstractEdmServiceMetadataImpl {
|
|||
|
||||
private static final ODataServiceVersion SERVICE_VERSION = ODataServiceVersion.V30;
|
||||
|
||||
public EdmServiceMetadataImpl(final XMLMetadataImpl xmlMetadata) {
|
||||
super(xmlMetadata);
|
||||
public EdmServiceMetadataImpl(final List<? extends Schema> xmlSchemas) {
|
||||
super(xmlSchemas);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -58,7 +57,7 @@ public class EdmServiceMetadataImpl extends AbstractEdmServiceMetadataImpl {
|
|||
synchronized (this) {
|
||||
if (functionImportInfos == null) {
|
||||
functionImportInfos = new ArrayList<EdmFunctionImportInfo>();
|
||||
for (Schema schema : xmlMetadata.getSchemas()) {
|
||||
for (Schema schema : xmlSchemas) {
|
||||
for (EntityContainer entityContainer : schema.getEntityContainers()) {
|
||||
for (CommonFunctionImport functionImport : entityContainer.getFunctionImports()) {
|
||||
final FunctionImport _funFunctionImport = (FunctionImport) functionImport;
|
||||
|
@ -79,7 +78,7 @@ public class EdmServiceMetadataImpl extends AbstractEdmServiceMetadataImpl {
|
|||
synchronized (this) {
|
||||
if (actionImportInfos == null) {
|
||||
actionImportInfos = new ArrayList<EdmActionImportInfo>();
|
||||
for (Schema schema : xmlMetadata.getSchemas()) {
|
||||
for (Schema schema : xmlSchemas) {
|
||||
for (EntityContainer entityContainer : schema.getEntityContainers()) {
|
||||
for (CommonFunctionImport functionImport : entityContainer.getFunctionImports()) {
|
||||
final FunctionImport _funFunctionImport = (FunctionImport) functionImport;
|
||||
|
|
|
@ -22,12 +22,11 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.apache.olingo.client.api.edm.xml.CommonFunctionImport;
|
||||
import org.apache.olingo.client.api.edm.xml.Schema;
|
||||
import org.apache.olingo.client.api.edm.xml.v4.ActionImport;
|
||||
import org.apache.olingo.client.api.edm.xml.v4.EntityContainer;
|
||||
import org.apache.olingo.client.api.edm.xml.v4.Schema;
|
||||
import org.apache.olingo.client.api.edm.xml.v4.Singleton;
|
||||
import org.apache.olingo.client.core.edm.AbstractEdmServiceMetadataImpl;
|
||||
import org.apache.olingo.client.core.edm.xml.v4.XMLMetadataImpl;
|
||||
import org.apache.olingo.commons.api.edm.EdmActionImportInfo;
|
||||
import org.apache.olingo.commons.api.edm.EdmFunctionImportInfo;
|
||||
import org.apache.olingo.commons.api.edm.EdmSingletonInfo;
|
||||
|
@ -44,8 +43,8 @@ public class EdmServiceMetadataImpl extends AbstractEdmServiceMetadataImpl {
|
|||
|
||||
private List<EdmActionImportInfo> actionImportInfos;
|
||||
|
||||
public EdmServiceMetadataImpl(final XMLMetadataImpl xmlMetadata) {
|
||||
super(xmlMetadata);
|
||||
public EdmServiceMetadataImpl(final List<? extends Schema> xmlSchemas) {
|
||||
super(xmlSchemas);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -58,7 +57,7 @@ public class EdmServiceMetadataImpl extends AbstractEdmServiceMetadataImpl {
|
|||
synchronized (this) {
|
||||
if (singletonInfos == null) {
|
||||
singletonInfos = new ArrayList<EdmSingletonInfo>();
|
||||
for (Schema schema : ((XMLMetadataImpl) xmlMetadata).getSchemas()) {
|
||||
for (Schema schema : xmlSchemas) {
|
||||
final EntityContainer entityContainer = (EntityContainer) schema.getDefaultEntityContainer();
|
||||
for (Singleton singleton : entityContainer.getSingletons()) {
|
||||
singletonInfos.add(new EdmSingletonInfoImpl(entityContainer.getName(), singleton.getName()));
|
||||
|
@ -74,16 +73,17 @@ public class EdmServiceMetadataImpl extends AbstractEdmServiceMetadataImpl {
|
|||
synchronized (this) {
|
||||
if (functionImportInfos == null) {
|
||||
functionImportInfos = new ArrayList<EdmFunctionImportInfo>();
|
||||
for (Schema schema : ((XMLMetadataImpl) xmlMetadata).getSchemas()) {
|
||||
for (EntityContainer entityContainer : schema.getEntityContainers()) {
|
||||
for (CommonFunctionImport functionImport : entityContainer.getFunctionImports()) {
|
||||
functionImportInfos.add(
|
||||
new EdmFunctionImportInfoImpl(entityContainer.getName(), functionImport.getName()));
|
||||
}
|
||||
for (Schema schema : xmlSchemas) {
|
||||
final EntityContainer entityContainer = (EntityContainer) schema.getDefaultEntityContainer();
|
||||
|
||||
for (CommonFunctionImport functionImport : entityContainer.getFunctionImports()) {
|
||||
functionImportInfos.add(
|
||||
new EdmFunctionImportInfoImpl(entityContainer.getName(), functionImport.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return functionImportInfos;
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ public class EdmServiceMetadataImpl extends AbstractEdmServiceMetadataImpl {
|
|||
synchronized (this) {
|
||||
if (actionImportInfos == null) {
|
||||
actionImportInfos = new ArrayList<EdmActionImportInfo>();
|
||||
for (Schema schema : ((XMLMetadataImpl) xmlMetadata).getSchemas()) {
|
||||
for (Schema schema : xmlSchemas) {
|
||||
final EntityContainer entityContainer = (EntityContainer) schema.getDefaultEntityContainer();
|
||||
for (ActionImport actionImport : entityContainer.getActionImports()) {
|
||||
actionImportInfos.add(new EdmActionImportInfoImpl(entityContainer.getName(), actionImport.getName()));
|
||||
|
|
|
@ -50,6 +50,7 @@ public class XMLMetadataImpl extends AbstractXMLMetadata implements XMLMetadata
|
|||
return (Schema) super.getSchema(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Reference> getReferences() {
|
||||
return ((Edmx) this.edmx).getReferences();
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.apache.olingo.client.core.op;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.olingo.client.api.CommonODataClient;
|
||||
import org.apache.olingo.commons.api.domain.ODataError;
|
||||
|
@ -26,6 +27,7 @@ import org.apache.olingo.commons.api.data.Property;
|
|||
import org.apache.olingo.commons.api.domain.ODataEntity;
|
||||
import org.apache.olingo.commons.api.domain.ODataEntitySet;
|
||||
import org.apache.olingo.client.api.domain.ODataEntitySetIterator;
|
||||
import org.apache.olingo.client.api.edm.xml.Schema;
|
||||
import org.apache.olingo.commons.api.domain.ODataProperty;
|
||||
import org.apache.olingo.commons.api.domain.ODataServiceDocument;
|
||||
import org.apache.olingo.commons.api.domain.ODataValue;
|
||||
|
@ -34,6 +36,8 @@ import org.apache.olingo.commons.api.format.ODataFormat;
|
|||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataValueFormat;
|
||||
import org.apache.olingo.client.api.op.CommonODataReader;
|
||||
import org.apache.olingo.client.core.edm.EdmClientImpl;
|
||||
import org.apache.olingo.commons.api.edm.Edm;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -53,6 +57,21 @@ public abstract class AbstractODataReader implements CommonODataReader {
|
|||
this.client = client;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Edm readMetadata(final InputStream input) {
|
||||
return readMetadata(client.getDeserializer().toMetadata(input).getSchemas());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Edm readMetadata(final List<? extends Schema> xmlSchemas) {
|
||||
return new EdmClientImpl(client.getServiceVersion(), xmlSchemas);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataServiceDocument readServiceDocument(final InputStream input, final ODataFormat format) {
|
||||
return client.getBinder().getODataServiceDocument(client.getDeserializer().toServiceDocument(input, format));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataEntitySet readEntitySet(final InputStream input, final ODataPubFormat format) {
|
||||
return client.getBinder().getODataEntitySet(client.getDeserializer().toFeed(input, format));
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.apache.olingo.client.core.op.impl.v3;
|
|||
import java.io.InputStream;
|
||||
|
||||
import org.apache.olingo.client.api.data.ServiceDocument;
|
||||
import org.apache.olingo.client.api.edm.xml.XMLMetadata;
|
||||
import org.apache.olingo.commons.api.data.v3.LinkCollection;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.client.api.op.v3.ODataDeserializer;
|
||||
|
@ -42,7 +43,7 @@ public class ODataDeserializerImpl extends AbstractODataDeserializer implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public XMLMetadataImpl toMetadata(final InputStream input) {
|
||||
public XMLMetadata toMetadata(final InputStream input) {
|
||||
try {
|
||||
return new XMLMetadataImpl(getXmlMapper().readValue(input, EdmxImpl.class));
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -20,15 +20,11 @@ package org.apache.olingo.client.core.op.impl.v3;
|
|||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.apache.olingo.commons.api.domain.ODataServiceDocument;
|
||||
import org.apache.olingo.client.api.domain.v3.ODataLinkCollection;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.client.api.op.v3.ODataReader;
|
||||
import org.apache.olingo.client.api.v3.ODataClient;
|
||||
import org.apache.olingo.client.core.v3.ODataClientImpl;
|
||||
import org.apache.olingo.client.core.edm.EdmClientImpl;
|
||||
import org.apache.olingo.client.core.op.AbstractODataReader;
|
||||
import org.apache.olingo.commons.api.edm.Edm;
|
||||
|
||||
public class ODataReaderImpl extends AbstractODataReader implements ODataReader {
|
||||
|
||||
|
@ -38,17 +34,6 @@ public class ODataReaderImpl extends AbstractODataReader implements ODataReader
|
|||
super(client);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Edm readMetadata(final InputStream input) {
|
||||
return new EdmClientImpl(client.getServiceVersion(), client.getDeserializer().toMetadata(input));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataServiceDocument readServiceDocument(final InputStream input, final ODataFormat format) {
|
||||
return ((ODataClientImpl) client).getBinder().getODataServiceDocument(
|
||||
((ODataClientImpl) client).getDeserializer().toServiceDocument(input, format));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataLinkCollection readLinks(final InputStream input, final ODataFormat format) {
|
||||
return ((ODataClient) client).getBinder().getLinkCollection(
|
||||
|
|
|
@ -18,15 +18,9 @@
|
|||
*/
|
||||
package org.apache.olingo.client.core.op.impl.v4;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.apache.olingo.commons.api.domain.ODataServiceDocument;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.client.api.op.v4.ODataReader;
|
||||
import org.apache.olingo.client.api.v4.ODataClient;
|
||||
import org.apache.olingo.client.core.edm.EdmClientImpl;
|
||||
import org.apache.olingo.client.core.op.AbstractODataReader;
|
||||
import org.apache.olingo.commons.api.edm.Edm;
|
||||
|
||||
public class ODataReaderImpl extends AbstractODataReader implements ODataReader {
|
||||
|
||||
|
@ -36,14 +30,4 @@ public class ODataReaderImpl extends AbstractODataReader implements ODataReader
|
|||
super(client);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Edm readMetadata(final InputStream input) {
|
||||
return new EdmClientImpl(client.getServiceVersion(), client.getDeserializer().toMetadata(input));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataServiceDocument readServiceDocument(final InputStream input, final ODataFormat format) {
|
||||
return ((ODataClient) client).getBinder().getODataServiceDocument(
|
||||
((ODataClient) client).getDeserializer().toServiceDocument(input, format));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,4 +28,8 @@ public abstract class AbstractMetadataTestITCase extends AbstractTestITCase {
|
|||
protected String getTestServiceRoot() {
|
||||
return "http://localhost:9080/StaticService/" + getClient().getServiceVersion().name() + "/Static.svc";
|
||||
}
|
||||
|
||||
protected String getNorthwindServiceRoot() {
|
||||
return "http://localhost:9080/StaticService/" + getClient().getServiceVersion().name() + "/NorthWind.svc";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,11 +18,16 @@
|
|||
*/
|
||||
package org.apache.olingo.client.core.it.v4;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import org.apache.olingo.client.api.v4.ODataClient;
|
||||
import org.apache.olingo.client.core.ODataClientFactory;
|
||||
import org.apache.olingo.client.core.it.AbstractMetadataTestITCase;
|
||||
import org.apache.olingo.commons.api.edm.Edm;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
|
||||
import org.apache.olingo.commons.api.edm.EdmEntitySet;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.junit.Test;
|
||||
|
||||
public class MetadataTestITCase extends AbstractMetadataTestITCase {
|
||||
|
@ -38,4 +43,19 @@ public class MetadataTestITCase extends AbstractMetadataTestITCase {
|
|||
getMetadataRequest(getTestServiceRoot()).execute().getBody();
|
||||
assertNotNull(metadata);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void include() {
|
||||
final Edm metadata = getClient().getRetrieveRequestFactory().
|
||||
getMetadataRequest(getNorthwindServiceRoot()).execute().getBody();
|
||||
assertNotNull(metadata);
|
||||
|
||||
final EdmEntityContainer container = metadata.getEntityContainer(
|
||||
new FullQualifiedName("ODataWebExperimental.Northwind.Model", "NorthwindEntities"));
|
||||
assertNotNull(container);
|
||||
|
||||
final EdmEntitySet categories = container.getEntitySet("Categories");
|
||||
assertNotNull(categories);
|
||||
assertEquals("NorthwindModel", categories.getEntityType().getNamespace());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -279,5 +279,4 @@ public class MetadataTest extends AbstractTest {
|
|||
readMetadata(getClass().getResourceAsStream("fromdoc3-metadata.xml"));
|
||||
assertNotNull(metadata);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
under the License.
|
||||
|
||||
-->
|
||||
<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">
|
||||
<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">
|
||||
<edmx:Reference Uri="http://docs.oasis-open.org/odata/odata/v4.0/cs01/vocabularies/Org.OData.Core.V1.xml">
|
||||
<edmx:Include Namespace="Org.OData.Core.V1" Alias="Core"/>
|
||||
</edmx:Reference>
|
||||
|
|
Loading…
Reference in New Issue