odata 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d911a37f1ddabb81a5436e902be0eb9d9d04e1e8
4
- data.tar.gz: 5d824862ef9be51ebf937d6504e08d6a778581a9
3
+ metadata.gz: e6981ed111f758f019824c0616927692584ad31a
4
+ data.tar.gz: 2f187e5ea95313d48ce325f752e59787624bb9a8
5
5
  SHA512:
6
- metadata.gz: 86c8c16380794a64e35e0395b306c5d07d1debe05e4f5c227d934aa62720f8945f04f0282e4d0c40ef0b69c3279850336ede3967d9d3d9aafd8fd118da795026
7
- data.tar.gz: b72b3b5176ddbc539477a549d185a63a44aa872beb8ede934b3c3f8dc174560b6c2b856cb0d7d0d090f152ab6a47a6661a638acc2704b5538010c37b31e5cb9d
6
+ metadata.gz: e49a84b9757a07d297ac25606a0f92a0760bac242d07a2de0e0d404006382d93c256e08e5e983a72119c28d1f57322d541ee2fabd3e7d4c3a69e07d3d48f61b5
7
+ data.tar.gz: 4a55c19eba6a3e609ffae47a24e737148992f98ab433fab36bdd9d285f876eb0c8b88bab54d94bd7cd881b88cd80fe7f2c434236c7b1b3ce8a3b5d63a48b656e
@@ -0,0 +1 @@
1
+ 2.1.2
data/README.md CHANGED
@@ -3,6 +3,7 @@
3
3
  [![Build Status](https://travis-ci.org/plainprogrammer/odata.svg?branch=master)](https://travis-ci.org/plainprogrammer/odata)
4
4
  [![Code Climate](https://codeclimate.com/github/plainprogrammer/odata.png)](https://codeclimate.com/github/plainprogrammer/odata)
5
5
  [![Coverage](https://codeclimate.com/github/plainprogrammer/odata/coverage.png)](https://codeclimate.com/github/plainprogrammer/odata)
6
+ [![Gem Version](https://badge.fury.io/rb/odata.svg)](http://badge.fury.io/rb/odata)
6
7
 
7
8
  The OData gem provides a simple wrapper around the OData API protocol. It has
8
9
  the ability to automatically inspect compliant APIs and expose the relevant
@@ -25,7 +26,35 @@ Or install it yourself as:
25
26
 
26
27
  ## Usage
27
28
 
28
- TODO: Write usage instructions here
29
+ The OData gem provides a number of core classes, the two most basic ones are
30
+ the OData::Service and the OData::ServiceRegistry. The only time you will need
31
+ to worry about the OData::ServiceRegistry is when you have multiple OData
32
+ services you are interacting with that you want to keep straight easily. The
33
+ nice thing about OData::Service is that it automatically registers with the
34
+ registry on creation, so there is no manual interaction with the registry
35
+ necessary.
36
+
37
+ To create an OData::Service simply provide the location of a service endpoint
38
+ to it like this:
39
+
40
+ OData::Service.open('http://services.odata.org/OData/OData.svc')
41
+
42
+ This one call will setup the service and allow for the discovery of everything
43
+ the other parts of the OData gem need to function. The two methods you will
44
+ want to remember from OData::Service are `#service_url` and `#namespace`. Both
45
+ of these methods are available on instances and will allow for lookup in the
46
+ OData::ServiceRegistry, should you need it.
47
+
48
+ Using either the service URL or the namespace provided by a service's CSDL
49
+ schema will allow for quick lookup in the OData::ServiceRegistry like such:
50
+
51
+ OData::ServiceRegistry['http://services.odata.org/OData/OData.svc']
52
+ OData::ServiceRegistry['ODataDemo']
53
+
54
+ Both of the above calls would retrieve the same service from the registry. At
55
+ the moment there is no protection against namespace collisions provided in
56
+ OData::ServiceRegistry. So, looking up services by their service URL is the
57
+ most exact method, but lookup by namespace is provided for convenience.
29
58
 
30
59
  ## Contributing
31
60
 
@@ -1,11 +1,16 @@
1
1
  require 'nokogiri'
2
- require 'open-uri'
2
+ require 'typhoeus'
3
+
4
+ require 'active_support'
5
+ require 'active_support/core_ext'
6
+ require 'active_support/concern'
3
7
 
4
8
  require 'odata/version'
5
9
  require 'odata/service'
6
10
  require 'odata/service_registry'
11
+ require 'odata/model'
7
12
 
8
- require 'odata/railtie' if defined?(Rails)
13
+ require 'odata/railtie' if defined?(::Rails)
9
14
 
10
15
  module OData
11
16
  # Your code goes here...
@@ -0,0 +1,55 @@
1
+ module OData
2
+ module Model
3
+ extend ::ActiveSupport::Concern
4
+ include ::ActiveModel::Model if defined?(::Rails) && defined?(::ActiveModel::Model)
5
+
6
+ included do
7
+ cattr_accessor :registered_properties
8
+ cattr_accessor :primary_key
9
+
10
+ self.class_eval <<-EOS
11
+ @@registered_properties = {}
12
+ @@primary_key = nil
13
+ EOS
14
+ end
15
+
16
+ module ClassMethods
17
+ def model_name
18
+ self.to_s.demodulize
19
+ end
20
+
21
+ def odata_name
22
+ model_name.pluralize
23
+ end
24
+
25
+ def property(name, options = {})
26
+ register_property(name.to_s.underscore, options.merge(literal_name: name))
27
+ create_accessors(name.to_s.underscore, options)
28
+ register_primary_key(name.to_s.underscore) if options[:primary_key]
29
+ end
30
+
31
+ private
32
+
33
+ def register_property(name, options)
34
+ new_registered_properties = registered_properties
35
+ new_registered_properties[name.to_sym] = options
36
+ registered_properties = new_registered_properties
37
+ end
38
+
39
+ def create_accessors(name, options)
40
+ self.class_eval do
41
+ define_method(name) { @properties[name.to_sym] || nil }
42
+ define_method("#{name}=") {|value| @properties[name.to_sym] = value}
43
+ end
44
+ end
45
+
46
+ def register_primary_key(name)
47
+ if primary_key.nil?
48
+ self.class_eval <<-EOS
49
+ @@primary_key = :#{name}
50
+ EOS
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -28,10 +28,29 @@ module OData
28
28
  "#<#{self.class.name}:#{self.object_id} namespace='#{self.namespace}' service_url='#{self.service_url}'>"
29
29
  end
30
30
 
31
+ def get(model)
32
+ request = ::Typhoeus::Request.new(
33
+ "#{service_url}/#{model.odata_name}",
34
+ method: :get
35
+ )
36
+ request.run
37
+ response = request.response
38
+ feed = ::Nokogiri::XML(response.body).remove_namespaces!
39
+ feed.xpath('//entry')
40
+ end
41
+
31
42
  private
32
43
 
33
44
  def metadata
34
- @metadata ||= ::Nokogiri::XML(open("#{service_url}/$metadata")).remove_namespaces!
45
+ @metadata ||= lambda {
46
+ request = ::Typhoeus::Request.new(
47
+ "#{service_url}/$metadata",
48
+ method: :get
49
+ )
50
+ request.run
51
+ response = request.response
52
+ ::Nokogiri::XML(response.body).remove_namespaces!
53
+ }.call
35
54
  end
36
55
  end
37
56
  end
@@ -1,3 +1,3 @@
1
1
  module OData
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
@@ -26,4 +26,6 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency 'webmock', '~> 1.18.0'
27
27
 
28
28
  spec.add_dependency 'nokogiri', '~> 1.6.2'
29
+ spec.add_dependency 'activesupport', '>= 3.0.0'
30
+ spec.add_dependency 'typhoeus', '~> 0.6.8'
29
31
  end
@@ -0,0 +1,13 @@
1
+ module Examples
2
+ class Product
3
+ include OData::Model
4
+
5
+ property 'ID', primary_key: true
6
+ property 'Name'
7
+ property 'Description'
8
+ property 'ReleaseDate'
9
+ property 'DiscontinuedDate'
10
+ property 'Rating'
11
+ property 'Price'
12
+ end
13
+ end
@@ -1 +1,193 @@
1
- <?xml version="1.0" encoding="utf-8"?><edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx"><edmx:DataServices m:DataServiceVersion="3.0" m:MaxDataServiceVersion="3.0" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><Schema Namespace="ODataDemo" xmlns="http://schemas.microsoft.com/ado/2009/11/edm"><EntityType Name="Product"><Key><PropertyRef Name="ID" /></Key><Property Name="ID" Type="Edm.Int32" Nullable="false" /><Property Name="Name" Type="Edm.String" m:FC_TargetPath="SyndicationTitle" m:FC_ContentKind="text" m:FC_KeepInContent="false" /><Property Name="Description" Type="Edm.String" m:FC_TargetPath="SyndicationSummary" m:FC_ContentKind="text" m:FC_KeepInContent="false" /><Property Name="ReleaseDate" Type="Edm.DateTime" Nullable="false" /><Property Name="DiscontinuedDate" Type="Edm.DateTime" /><Property Name="Rating" Type="Edm.Int16" Nullable="false" /><Property Name="Price" Type="Edm.Double" Nullable="false" /><NavigationProperty Name="Categories" Relationship="ODataDemo.Product_Categories_Category_Products" ToRole="Category_Products" FromRole="Product_Categories" /><NavigationProperty Name="Supplier" Relationship="ODataDemo.Product_Supplier_Supplier_Products" ToRole="Supplier_Products" FromRole="Product_Supplier" /><NavigationProperty Name="ProductDetail" Relationship="ODataDemo.Product_ProductDetail_ProductDetail_Product" ToRole="ProductDetail_Product" FromRole="Product_ProductDetail" /></EntityType><EntityType Name="FeaturedProduct" BaseType="ODataDemo.Product"><NavigationProperty Name="Advertisement" Relationship="ODataDemo.FeaturedProduct_Advertisement_Advertisement_FeaturedProduct" ToRole="Advertisement_FeaturedProduct" FromRole="FeaturedProduct_Advertisement" /></EntityType><EntityType Name="ProductDetail"><Key><PropertyRef Name="ProductID" /></Key><Property Name="ProductID" Type="Edm.Int32" Nullable="false" /><Property Name="Details" Type="Edm.String" /><NavigationProperty Name="Product" Relationship="ODataDemo.Product_ProductDetail_ProductDetail_Product" ToRole="Product_ProductDetail" FromRole="ProductDetail_Product" /></EntityType><EntityType Name="Category" OpenType="true"><Key><PropertyRef Name="ID" /></Key><Property Name="ID" Type="Edm.Int32" Nullable="false" /><Property Name="Name" Type="Edm.String" m:FC_TargetPath="SyndicationTitle" m:FC_ContentKind="text" m:FC_KeepInContent="true" /><NavigationProperty Name="Products" Relationship="ODataDemo.Product_Categories_Category_Products" ToRole="Product_Categories" FromRole="Category_Products" /></EntityType><EntityType Name="Supplier"><Key><PropertyRef Name="ID" /></Key><Property Name="ID" Type="Edm.Int32" Nullable="false" /><Property Name="Name" Type="Edm.String" m:FC_TargetPath="SyndicationTitle" m:FC_ContentKind="text" m:FC_KeepInContent="true" /><Property Name="Address" Type="ODataDemo.Address" /><Property Name="Location" Type="Edm.GeographyPoint" SRID="Variable" /><Property Name="Concurrency" Type="Edm.Int32" ConcurrencyMode="Fixed" Nullable="false" /><NavigationProperty Name="Products" Relationship="ODataDemo.Product_Supplier_Supplier_Products" ToRole="Product_Supplier" FromRole="Supplier_Products" /></EntityType><ComplexType Name="Address"><Property Name="Street" Type="Edm.String" /><Property Name="City" Type="Edm.String" /><Property Name="State" Type="Edm.String" /><Property Name="ZipCode" Type="Edm.String" /><Property Name="Country" Type="Edm.String" /></ComplexType><EntityType Name="Person"><Key><PropertyRef Name="ID" /></Key><Property Name="ID" Type="Edm.Int32" Nullable="false" /><Property Name="Name" Type="Edm.String" /><NavigationProperty Name="PersonDetail" Relationship="ODataDemo.Person_PersonDetail_PersonDetail_Person" ToRole="PersonDetail_Person" FromRole="Person_PersonDetail" /></EntityType><EntityType Name="Customer" BaseType="ODataDemo.Person"><Property Name="TotalExpense" Type="Edm.Decimal" Nullable="false" /></EntityType><EntityType Name="Employee" BaseType="ODataDemo.Person"><Property Name="EmployeeID" Type="Edm.Int64" Nullable="false" /><Property Name="HireDate" Type="Edm.DateTime" Nullable="false" /><Property Name="Salary" Type="Edm.Single" Nullable="false" /></EntityType><EntityType Name="PersonDetail"><Key><PropertyRef Name="PersonID" /></Key><Property Name="PersonID" Type="Edm.Int32" Nullable="false" /><Property Name="Age" Type="Edm.Byte" Nullable="false" /><Property Name="Gender" Type="Edm.Boolean" Nullable="false" /><Property Name="Phone" Type="Edm.String" /><Property Name="Address" Type="ODataDemo.Address" /><Property Name="Photo" Type="Edm.Stream" Nullable="false" /><NavigationProperty Name="Person" Relationship="ODataDemo.Person_PersonDetail_PersonDetail_Person" ToRole="Person_PersonDetail" FromRole="PersonDetail_Person" /></EntityType><EntityType Name="Advertisement" m:HasStream="true"><Key><PropertyRef Name="ID" /></Key><Property Name="ID" Type="Edm.Guid" Nullable="false" /><Property Name="Name" Type="Edm.String" /><Property Name="AirDate" Type="Edm.DateTime" Nullable="false" /><NavigationProperty Name="FeaturedProduct" Relationship="ODataDemo.FeaturedProduct_Advertisement_Advertisement_FeaturedProduct" ToRole="FeaturedProduct_Advertisement" FromRole="Advertisement_FeaturedProduct" /></EntityType><Association Name="Product_Categories_Category_Products"><End Type="ODataDemo.Category" Role="Category_Products" Multiplicity="*" /><End Type="ODataDemo.Product" Role="Product_Categories" Multiplicity="*" /></Association><Association Name="Product_Supplier_Supplier_Products"><End Type="ODataDemo.Supplier" Role="Supplier_Products" Multiplicity="0..1" /><End Type="ODataDemo.Product" Role="Product_Supplier" Multiplicity="*" /></Association><Association Name="Product_ProductDetail_ProductDetail_Product"><End Type="ODataDemo.ProductDetail" Role="ProductDetail_Product" Multiplicity="0..1" /><End Type="ODataDemo.Product" Role="Product_ProductDetail" Multiplicity="0..1" /></Association><Association Name="FeaturedProduct_Advertisement_Advertisement_FeaturedProduct"><End Type="ODataDemo.Advertisement" Role="Advertisement_FeaturedProduct" Multiplicity="0..1" /><End Type="ODataDemo.FeaturedProduct" Role="FeaturedProduct_Advertisement" Multiplicity="0..1" /></Association><Association Name="Person_PersonDetail_PersonDetail_Person"><End Type="ODataDemo.PersonDetail" Role="PersonDetail_Person" Multiplicity="0..1" /><End Type="ODataDemo.Person" Role="Person_PersonDetail" Multiplicity="0..1" /></Association><EntityContainer Name="DemoService" m:IsDefaultEntityContainer="true"><EntitySet Name="Products" EntityType="ODataDemo.Product" /><EntitySet Name="ProductDetails" EntityType="ODataDemo.ProductDetail" /><EntitySet Name="Categories" EntityType="ODataDemo.Category" /><EntitySet Name="Suppliers" EntityType="ODataDemo.Supplier" /><EntitySet Name="Persons" EntityType="ODataDemo.Person" /><EntitySet Name="PersonDetails" EntityType="ODataDemo.PersonDetail" /><EntitySet Name="Advertisements" EntityType="ODataDemo.Advertisement" /><FunctionImport Name="GetProductsByRating" ReturnType="Collection(ODataDemo.Product)" EntitySet="Products" m:HttpMethod="GET"><Parameter Name="rating" Type="Edm.Int16" Nullable="false" /></FunctionImport><AssociationSet Name="Products_Advertisement_Advertisements" Association="ODataDemo.FeaturedProduct_Advertisement_Advertisement_FeaturedProduct"><End Role="FeaturedProduct_Advertisement" EntitySet="Products" /><End Role="Advertisement_FeaturedProduct" EntitySet="Advertisements" /></AssociationSet><AssociationSet Name="Products_Categories_Categories" Association="ODataDemo.Product_Categories_Category_Products"><End Role="Product_Categories" EntitySet="Products" /><End Role="Category_Products" EntitySet="Categories" /></AssociationSet><AssociationSet Name="Products_Supplier_Suppliers" Association="ODataDemo.Product_Supplier_Supplier_Products"><End Role="Product_Supplier" EntitySet="Products" /><End Role="Supplier_Products" EntitySet="Suppliers" /></AssociationSet><AssociationSet Name="Products_ProductDetail_ProductDetails" Association="ODataDemo.Product_ProductDetail_ProductDetail_Product"><End Role="Product_ProductDetail" EntitySet="Products" /><End Role="ProductDetail_Product" EntitySet="ProductDetails" /></AssociationSet><AssociationSet Name="Persons_PersonDetail_PersonDetails" Association="ODataDemo.Person_PersonDetail_PersonDetail_Person"><End Role="Person_PersonDetail" EntitySet="Persons" /><End Role="PersonDetail_Person" EntitySet="PersonDetails" /></AssociationSet></EntityContainer><Annotations Target="ODataDemo.DemoService"><ValueAnnotation Term="Org.OData.Display.V1.Description" String="This is a sample OData service with vocabularies" /></Annotations><Annotations Target="ODataDemo.Product"><ValueAnnotation Term="Org.OData.Display.V1.Description" String="All Products available in the online store" /></Annotations><Annotations Target="ODataDemo.Product/Name"><ValueAnnotation Term="Org.OData.Display.V1.DisplayName" String="Product Name" /></Annotations><Annotations Target="ODataDemo.DemoService/Suppliers"><ValueAnnotation Term="Org.OData.Publication.V1.PublisherName" String="Microsoft Corp." /><ValueAnnotation Term="Org.OData.Publication.V1.PublisherId" String="MSFT" /><ValueAnnotation Term="Org.OData.Publication.V1.Keywords" String="Inventory, Supplier, Advertisers, Sales, Finance" /><ValueAnnotation Term="Org.OData.Publication.V1.AttributionUrl" String="http://www.odata.org/" /><ValueAnnotation Term="Org.OData.Publication.V1.AttributionDescription" String="All rights reserved" /><ValueAnnotation Term="Org.OData.Publication.V1.DocumentationUrl " String="http://www.odata.org/" /><ValueAnnotation Term="Org.OData.Publication.V1.TermsOfUseUrl" String="All rights reserved" /><ValueAnnotation Term="Org.OData.Publication.V1.PrivacyPolicyUrl" String="http://www.odata.org/" /><ValueAnnotation Term="Org.OData.Publication.V1.LastModified" String="4/2/2013" /><ValueAnnotation Term="Org.OData.Publication.V1.ImageUrl " String="http://www.odata.org/" /></Annotations></Schema></edmx:DataServices></edmx:Edmx>
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
3
+ <edmx:DataServices m:DataServiceVersion="3.0" m:MaxDataServiceVersion="3.0"
4
+ xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
5
+ <Schema Namespace="ODataDemo" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
6
+ <EntityType Name="Product">
7
+ <Key>
8
+ <PropertyRef Name="ID"/>
9
+ </Key>
10
+ <Property Name="ID" Type="Edm.Int32" Nullable="false"/>
11
+ <Property Name="Name" Type="Edm.String" m:FC_TargetPath="SyndicationTitle" m:FC_ContentKind="text"
12
+ m:FC_KeepInContent="false"/>
13
+ <Property Name="Description" Type="Edm.String" m:FC_TargetPath="SyndicationSummary" m:FC_ContentKind="text"
14
+ m:FC_KeepInContent="false"/>
15
+ <Property Name="ReleaseDate" Type="Edm.DateTime" Nullable="false"/>
16
+ <Property Name="DiscontinuedDate" Type="Edm.DateTime"/>
17
+ <Property Name="Rating" Type="Edm.Int16" Nullable="false"/>
18
+ <Property Name="Price" Type="Edm.Double" Nullable="false"/>
19
+ <NavigationProperty Name="Categories" Relationship="ODataDemo.Product_Categories_Category_Products"
20
+ ToRole="Category_Products" FromRole="Product_Categories"/>
21
+ <NavigationProperty Name="Supplier" Relationship="ODataDemo.Product_Supplier_Supplier_Products"
22
+ ToRole="Supplier_Products" FromRole="Product_Supplier"/>
23
+ <NavigationProperty Name="ProductDetail" Relationship="ODataDemo.Product_ProductDetail_ProductDetail_Product"
24
+ ToRole="ProductDetail_Product" FromRole="Product_ProductDetail"/>
25
+ </EntityType>
26
+ <EntityType Name="FeaturedProduct" BaseType="ODataDemo.Product">
27
+ <NavigationProperty Name="Advertisement"
28
+ Relationship="ODataDemo.FeaturedProduct_Advertisement_Advertisement_FeaturedProduct"
29
+ ToRole="Advertisement_FeaturedProduct" FromRole="FeaturedProduct_Advertisement"/>
30
+ </EntityType>
31
+ <EntityType Name="ProductDetail">
32
+ <Key>
33
+ <PropertyRef Name="ProductID"/>
34
+ </Key>
35
+ <Property Name="ProductID" Type="Edm.Int32" Nullable="false"/>
36
+ <Property Name="Details" Type="Edm.String"/>
37
+ <NavigationProperty Name="Product" Relationship="ODataDemo.Product_ProductDetail_ProductDetail_Product"
38
+ ToRole="Product_ProductDetail" FromRole="ProductDetail_Product"/>
39
+ </EntityType>
40
+ <EntityType Name="Category" OpenType="true">
41
+ <Key>
42
+ <PropertyRef Name="ID"/>
43
+ </Key>
44
+ <Property Name="ID" Type="Edm.Int32" Nullable="false"/>
45
+ <Property Name="Name" Type="Edm.String" m:FC_TargetPath="SyndicationTitle" m:FC_ContentKind="text"
46
+ m:FC_KeepInContent="true"/>
47
+ <NavigationProperty Name="Products" Relationship="ODataDemo.Product_Categories_Category_Products"
48
+ ToRole="Product_Categories" FromRole="Category_Products"/>
49
+ </EntityType>
50
+ <EntityType Name="Supplier">
51
+ <Key>
52
+ <PropertyRef Name="ID"/>
53
+ </Key>
54
+ <Property Name="ID" Type="Edm.Int32" Nullable="false"/>
55
+ <Property Name="Name" Type="Edm.String" m:FC_TargetPath="SyndicationTitle" m:FC_ContentKind="text"
56
+ m:FC_KeepInContent="true"/>
57
+ <Property Name="Address" Type="ODataDemo.Address"/>
58
+ <Property Name="Location" Type="Edm.GeographyPoint" SRID="Variable"/>
59
+ <Property Name="Concurrency" Type="Edm.Int32" ConcurrencyMode="Fixed" Nullable="false"/>
60
+ <NavigationProperty Name="Products" Relationship="ODataDemo.Product_Supplier_Supplier_Products"
61
+ ToRole="Product_Supplier" FromRole="Supplier_Products"/>
62
+ </EntityType>
63
+ <ComplexType Name="Address">
64
+ <Property Name="Street" Type="Edm.String"/>
65
+ <Property Name="City" Type="Edm.String"/>
66
+ <Property Name="State" Type="Edm.String"/>
67
+ <Property Name="ZipCode" Type="Edm.String"/>
68
+ <Property Name="Country" Type="Edm.String"/>
69
+ </ComplexType>
70
+ <EntityType Name="Person">
71
+ <Key>
72
+ <PropertyRef Name="ID"/>
73
+ </Key>
74
+ <Property Name="ID" Type="Edm.Int32" Nullable="false"/>
75
+ <Property Name="Name" Type="Edm.String"/>
76
+ <NavigationProperty Name="PersonDetail" Relationship="ODataDemo.Person_PersonDetail_PersonDetail_Person"
77
+ ToRole="PersonDetail_Person" FromRole="Person_PersonDetail"/>
78
+ </EntityType>
79
+ <EntityType Name="Customer" BaseType="ODataDemo.Person">
80
+ <Property Name="TotalExpense" Type="Edm.Decimal" Nullable="false"/>
81
+ </EntityType>
82
+ <EntityType Name="Employee" BaseType="ODataDemo.Person">
83
+ <Property Name="EmployeeID" Type="Edm.Int64" Nullable="false"/>
84
+ <Property Name="HireDate" Type="Edm.DateTime" Nullable="false"/>
85
+ <Property Name="Salary" Type="Edm.Single" Nullable="false"/>
86
+ </EntityType>
87
+ <EntityType Name="PersonDetail">
88
+ <Key>
89
+ <PropertyRef Name="PersonID"/>
90
+ </Key>
91
+ <Property Name="PersonID" Type="Edm.Int32" Nullable="false"/>
92
+ <Property Name="Age" Type="Edm.Byte" Nullable="false"/>
93
+ <Property Name="Gender" Type="Edm.Boolean" Nullable="false"/>
94
+ <Property Name="Phone" Type="Edm.String"/>
95
+ <Property Name="Address" Type="ODataDemo.Address"/>
96
+ <Property Name="Photo" Type="Edm.Stream" Nullable="false"/>
97
+ <NavigationProperty Name="Person" Relationship="ODataDemo.Person_PersonDetail_PersonDetail_Person"
98
+ ToRole="Person_PersonDetail" FromRole="PersonDetail_Person"/>
99
+ </EntityType>
100
+ <EntityType Name="Advertisement" m:HasStream="true">
101
+ <Key>
102
+ <PropertyRef Name="ID"/>
103
+ </Key>
104
+ <Property Name="ID" Type="Edm.Guid" Nullable="false"/>
105
+ <Property Name="Name" Type="Edm.String"/>
106
+ <Property Name="AirDate" Type="Edm.DateTime" Nullable="false"/>
107
+ <NavigationProperty Name="FeaturedProduct"
108
+ Relationship="ODataDemo.FeaturedProduct_Advertisement_Advertisement_FeaturedProduct"
109
+ ToRole="FeaturedProduct_Advertisement" FromRole="Advertisement_FeaturedProduct"/>
110
+ </EntityType>
111
+ <Association Name="Product_Categories_Category_Products">
112
+ <End Type="ODataDemo.Category" Role="Category_Products" Multiplicity="*"/>
113
+ <End Type="ODataDemo.Product" Role="Product_Categories" Multiplicity="*"/>
114
+ </Association>
115
+ <Association Name="Product_Supplier_Supplier_Products">
116
+ <End Type="ODataDemo.Supplier" Role="Supplier_Products" Multiplicity="0..1"/>
117
+ <End Type="ODataDemo.Product" Role="Product_Supplier" Multiplicity="*"/>
118
+ </Association>
119
+ <Association Name="Product_ProductDetail_ProductDetail_Product">
120
+ <End Type="ODataDemo.ProductDetail" Role="ProductDetail_Product" Multiplicity="0..1"/>
121
+ <End Type="ODataDemo.Product" Role="Product_ProductDetail" Multiplicity="0..1"/>
122
+ </Association>
123
+ <Association Name="FeaturedProduct_Advertisement_Advertisement_FeaturedProduct">
124
+ <End Type="ODataDemo.Advertisement" Role="Advertisement_FeaturedProduct" Multiplicity="0..1"/>
125
+ <End Type="ODataDemo.FeaturedProduct" Role="FeaturedProduct_Advertisement" Multiplicity="0..1"/>
126
+ </Association>
127
+ <Association Name="Person_PersonDetail_PersonDetail_Person">
128
+ <End Type="ODataDemo.PersonDetail" Role="PersonDetail_Person" Multiplicity="0..1"/>
129
+ <End Type="ODataDemo.Person" Role="Person_PersonDetail" Multiplicity="0..1"/>
130
+ </Association>
131
+ <EntityContainer Name="DemoService" m:IsDefaultEntityContainer="true">
132
+ <EntitySet Name="Products" EntityType="ODataDemo.Product"/>
133
+ <EntitySet Name="ProductDetails" EntityType="ODataDemo.ProductDetail"/>
134
+ <EntitySet Name="Categories" EntityType="ODataDemo.Category"/>
135
+ <EntitySet Name="Suppliers" EntityType="ODataDemo.Supplier"/>
136
+ <EntitySet Name="Persons" EntityType="ODataDemo.Person"/>
137
+ <EntitySet Name="PersonDetails" EntityType="ODataDemo.PersonDetail"/>
138
+ <EntitySet Name="Advertisements" EntityType="ODataDemo.Advertisement"/>
139
+ <FunctionImport Name="GetProductsByRating" ReturnType="Collection(ODataDemo.Product)" EntitySet="Products"
140
+ m:HttpMethod="GET">
141
+ <Parameter Name="rating" Type="Edm.Int16" Nullable="false"/>
142
+ </FunctionImport>
143
+ <AssociationSet Name="Products_Advertisement_Advertisements"
144
+ Association="ODataDemo.FeaturedProduct_Advertisement_Advertisement_FeaturedProduct">
145
+ <End Role="FeaturedProduct_Advertisement" EntitySet="Products"/>
146
+ <End Role="Advertisement_FeaturedProduct" EntitySet="Advertisements"/>
147
+ </AssociationSet>
148
+ <AssociationSet Name="Products_Categories_Categories"
149
+ Association="ODataDemo.Product_Categories_Category_Products">
150
+ <End Role="Product_Categories" EntitySet="Products"/>
151
+ <End Role="Category_Products" EntitySet="Categories"/>
152
+ </AssociationSet>
153
+ <AssociationSet Name="Products_Supplier_Suppliers" Association="ODataDemo.Product_Supplier_Supplier_Products">
154
+ <End Role="Product_Supplier" EntitySet="Products"/>
155
+ <End Role="Supplier_Products" EntitySet="Suppliers"/>
156
+ </AssociationSet>
157
+ <AssociationSet Name="Products_ProductDetail_ProductDetails"
158
+ Association="ODataDemo.Product_ProductDetail_ProductDetail_Product">
159
+ <End Role="Product_ProductDetail" EntitySet="Products"/>
160
+ <End Role="ProductDetail_Product" EntitySet="ProductDetails"/>
161
+ </AssociationSet>
162
+ <AssociationSet Name="Persons_PersonDetail_PersonDetails"
163
+ Association="ODataDemo.Person_PersonDetail_PersonDetail_Person">
164
+ <End Role="Person_PersonDetail" EntitySet="Persons"/>
165
+ <End Role="PersonDetail_Person" EntitySet="PersonDetails"/>
166
+ </AssociationSet>
167
+ </EntityContainer>
168
+ <Annotations Target="ODataDemo.DemoService">
169
+ <ValueAnnotation Term="Org.OData.Display.V1.Description"
170
+ String="This is a sample OData service with vocabularies"/>
171
+ </Annotations>
172
+ <Annotations Target="ODataDemo.Product">
173
+ <ValueAnnotation Term="Org.OData.Display.V1.Description" String="All Products available in the online store"/>
174
+ </Annotations>
175
+ <Annotations Target="ODataDemo.Product/Name">
176
+ <ValueAnnotation Term="Org.OData.Display.V1.DisplayName" String="Product Name"/>
177
+ </Annotations>
178
+ <Annotations Target="ODataDemo.DemoService/Suppliers">
179
+ <ValueAnnotation Term="Org.OData.Publication.V1.PublisherName" String="Microsoft Corp."/>
180
+ <ValueAnnotation Term="Org.OData.Publication.V1.PublisherId" String="MSFT"/>
181
+ <ValueAnnotation Term="Org.OData.Publication.V1.Keywords"
182
+ String="Inventory, Supplier, Advertisers, Sales, Finance"/>
183
+ <ValueAnnotation Term="Org.OData.Publication.V1.AttributionUrl" String="http://www.odata.org/"/>
184
+ <ValueAnnotation Term="Org.OData.Publication.V1.AttributionDescription" String="All rights reserved"/>
185
+ <ValueAnnotation Term="Org.OData.Publication.V1.DocumentationUrl " String="http://www.odata.org/"/>
186
+ <ValueAnnotation Term="Org.OData.Publication.V1.TermsOfUseUrl" String="All rights reserved"/>
187
+ <ValueAnnotation Term="Org.OData.Publication.V1.PrivacyPolicyUrl" String="http://www.odata.org/"/>
188
+ <ValueAnnotation Term="Org.OData.Publication.V1.LastModified" String="4/2/2013"/>
189
+ <ValueAnnotation Term="Org.OData.Publication.V1.ImageUrl " String="http://www.odata.org/"/>
190
+ </Annotations>
191
+ </Schema>
192
+ </edmx:DataServices>
193
+ </edmx:Edmx>
@@ -0,0 +1,378 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <feed xml:base="http://services.odata.org/OData/OData.svc/" xmlns="http://www.w3.org/2005/Atom"
3
+ xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
4
+ xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
5
+ xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml">
6
+ <id>http://services.odata.org/OData/OData.svc/Products</id>
7
+ <title type="text">Products</title>
8
+ <updated>2014-06-20T06:22:58Z</updated>
9
+ <link rel="self" title="Products" href="Products"/>
10
+ <entry>
11
+ <id>http://services.odata.org/OData/OData.svc/Products(0)</id>
12
+ <category term="ODataDemo.Product" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
13
+ <link rel="edit" title="Product" href="Products(0)"/>
14
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Categories"
15
+ type="application/atom+xml;type=feed" title="Categories" href="Products(0)/Categories"/>
16
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Supplier"
17
+ type="application/atom+xml;type=entry" title="Supplier" href="Products(0)/Supplier"/>
18
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ProductDetail"
19
+ type="application/atom+xml;type=entry" title="ProductDetail" href="Products(0)/ProductDetail"/>
20
+ <title type="text">Bread</title>
21
+ <summary type="text">Whole grain bread</summary>
22
+ <updated>2014-06-20T06:22:58Z</updated>
23
+ <author>
24
+ <name/>
25
+ </author>
26
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Categories" type="application/xml"
27
+ title="Categories" href="Products(0)/$links/Categories"/>
28
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Supplier" type="application/xml"
29
+ title="Supplier" href="Products(0)/$links/Supplier"/>
30
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/ProductDetail" type="application/xml"
31
+ title="ProductDetail" href="Products(0)/$links/ProductDetail"/>
32
+ <content type="application/xml">
33
+ <m:properties>
34
+ <d:ID m:type="Edm.Int32">0</d:ID>
35
+ <d:ReleaseDate m:type="Edm.DateTime">1992-01-01T00:00:00</d:ReleaseDate>
36
+ <d:DiscontinuedDate m:null="true"/>
37
+ <d:Rating m:type="Edm.Int16">4</d:Rating>
38
+ <d:Price m:type="Edm.Double">2.5</d:Price>
39
+ </m:properties>
40
+ </content>
41
+ </entry>
42
+ <entry>
43
+ <id>http://services.odata.org/OData/OData.svc/Products(1)</id>
44
+ <category term="ODataDemo.Product" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
45
+ <link rel="edit" title="Product" href="Products(1)"/>
46
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Categories"
47
+ type="application/atom+xml;type=feed" title="Categories" href="Products(1)/Categories"/>
48
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Supplier"
49
+ type="application/atom+xml;type=entry" title="Supplier" href="Products(1)/Supplier"/>
50
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ProductDetail"
51
+ type="application/atom+xml;type=entry" title="ProductDetail" href="Products(1)/ProductDetail"/>
52
+ <title type="text">Milk</title>
53
+ <summary type="text">Low fat milk</summary>
54
+ <updated>2014-06-20T06:22:58Z</updated>
55
+ <author>
56
+ <name/>
57
+ </author>
58
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Categories" type="application/xml"
59
+ title="Categories" href="Products(1)/$links/Categories"/>
60
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Supplier" type="application/xml"
61
+ title="Supplier" href="Products(1)/$links/Supplier"/>
62
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/ProductDetail" type="application/xml"
63
+ title="ProductDetail" href="Products(1)/$links/ProductDetail"/>
64
+ <content type="application/xml">
65
+ <m:properties>
66
+ <d:ID m:type="Edm.Int32">1</d:ID>
67
+ <d:ReleaseDate m:type="Edm.DateTime">1995-10-01T00:00:00</d:ReleaseDate>
68
+ <d:DiscontinuedDate m:null="true"/>
69
+ <d:Rating m:type="Edm.Int16">3</d:Rating>
70
+ <d:Price m:type="Edm.Double">3.5</d:Price>
71
+ </m:properties>
72
+ </content>
73
+ </entry>
74
+ <entry>
75
+ <id>http://services.odata.org/OData/OData.svc/Products(2)</id>
76
+ <category term="ODataDemo.Product" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
77
+ <link rel="edit" title="Product" href="Products(2)"/>
78
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Categories"
79
+ type="application/atom+xml;type=feed" title="Categories" href="Products(2)/Categories"/>
80
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Supplier"
81
+ type="application/atom+xml;type=entry" title="Supplier" href="Products(2)/Supplier"/>
82
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ProductDetail"
83
+ type="application/atom+xml;type=entry" title="ProductDetail" href="Products(2)/ProductDetail"/>
84
+ <title type="text">Vint soda</title>
85
+ <summary type="text">Americana Variety - Mix of 6 flavors</summary>
86
+ <updated>2014-06-20T06:22:58Z</updated>
87
+ <author>
88
+ <name/>
89
+ </author>
90
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Categories" type="application/xml"
91
+ title="Categories" href="Products(2)/$links/Categories"/>
92
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Supplier" type="application/xml"
93
+ title="Supplier" href="Products(2)/$links/Supplier"/>
94
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/ProductDetail" type="application/xml"
95
+ title="ProductDetail" href="Products(2)/$links/ProductDetail"/>
96
+ <content type="application/xml">
97
+ <m:properties>
98
+ <d:ID m:type="Edm.Int32">2</d:ID>
99
+ <d:ReleaseDate m:type="Edm.DateTime">2000-10-01T00:00:00</d:ReleaseDate>
100
+ <d:DiscontinuedDate m:null="true"/>
101
+ <d:Rating m:type="Edm.Int16">3</d:Rating>
102
+ <d:Price m:type="Edm.Double">20.9</d:Price>
103
+ </m:properties>
104
+ </content>
105
+ </entry>
106
+ <entry>
107
+ <id>http://services.odata.org/OData/OData.svc/Products(3)</id>
108
+ <category term="ODataDemo.Product" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
109
+ <link rel="edit" title="Product" href="Products(3)"/>
110
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Categories"
111
+ type="application/atom+xml;type=feed" title="Categories" href="Products(3)/Categories"/>
112
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Supplier"
113
+ type="application/atom+xml;type=entry" title="Supplier" href="Products(3)/Supplier"/>
114
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ProductDetail"
115
+ type="application/atom+xml;type=entry" title="ProductDetail" href="Products(3)/ProductDetail"/>
116
+ <title type="text">Havina Cola</title>
117
+ <summary type="text">The Original Key Lime Cola</summary>
118
+ <updated>2014-06-20T06:22:58Z</updated>
119
+ <author>
120
+ <name/>
121
+ </author>
122
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Categories" type="application/xml"
123
+ title="Categories" href="Products(3)/$links/Categories"/>
124
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Supplier" type="application/xml"
125
+ title="Supplier" href="Products(3)/$links/Supplier"/>
126
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/ProductDetail" type="application/xml"
127
+ title="ProductDetail" href="Products(3)/$links/ProductDetail"/>
128
+ <content type="application/xml">
129
+ <m:properties>
130
+ <d:ID m:type="Edm.Int32">3</d:ID>
131
+ <d:ReleaseDate m:type="Edm.DateTime">2005-10-01T00:00:00</d:ReleaseDate>
132
+ <d:DiscontinuedDate m:type="Edm.DateTime">2006-10-01T00:00:00</d:DiscontinuedDate>
133
+ <d:Rating m:type="Edm.Int16">3</d:Rating>
134
+ <d:Price m:type="Edm.Double">19.9</d:Price>
135
+ </m:properties>
136
+ </content>
137
+ </entry>
138
+ <entry>
139
+ <id>http://services.odata.org/OData/OData.svc/Products(4)</id>
140
+ <category term="ODataDemo.Product" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
141
+ <link rel="edit" title="Product" href="Products(4)"/>
142
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Categories"
143
+ type="application/atom+xml;type=feed" title="Categories" href="Products(4)/Categories"/>
144
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Supplier"
145
+ type="application/atom+xml;type=entry" title="Supplier" href="Products(4)/Supplier"/>
146
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ProductDetail"
147
+ type="application/atom+xml;type=entry" title="ProductDetail" href="Products(4)/ProductDetail"/>
148
+ <title type="text">Fruit Punch</title>
149
+ <summary type="text">Mango flavor, 8.3 Ounce Cans (Pack of 24)</summary>
150
+ <updated>2014-06-20T06:22:58Z</updated>
151
+ <author>
152
+ <name/>
153
+ </author>
154
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Categories" type="application/xml"
155
+ title="Categories" href="Products(4)/$links/Categories"/>
156
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Supplier" type="application/xml"
157
+ title="Supplier" href="Products(4)/$links/Supplier"/>
158
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/ProductDetail" type="application/xml"
159
+ title="ProductDetail" href="Products(4)/$links/ProductDetail"/>
160
+ <content type="application/xml">
161
+ <m:properties>
162
+ <d:ID m:type="Edm.Int32">4</d:ID>
163
+ <d:ReleaseDate m:type="Edm.DateTime">2003-01-05T00:00:00</d:ReleaseDate>
164
+ <d:DiscontinuedDate m:null="true"/>
165
+ <d:Rating m:type="Edm.Int16">3</d:Rating>
166
+ <d:Price m:type="Edm.Double">22.99</d:Price>
167
+ </m:properties>
168
+ </content>
169
+ </entry>
170
+ <entry>
171
+ <id>http://services.odata.org/OData/OData.svc/Products(5)</id>
172
+ <category term="ODataDemo.Product" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
173
+ <link rel="edit" title="Product" href="Products(5)"/>
174
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Categories"
175
+ type="application/atom+xml;type=feed" title="Categories" href="Products(5)/Categories"/>
176
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Supplier"
177
+ type="application/atom+xml;type=entry" title="Supplier" href="Products(5)/Supplier"/>
178
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ProductDetail"
179
+ type="application/atom+xml;type=entry" title="ProductDetail" href="Products(5)/ProductDetail"/>
180
+ <title type="text">Cranberry Juice</title>
181
+ <summary type="text">16-Ounce Plastic Bottles (Pack of 12)</summary>
182
+ <updated>2014-06-20T06:22:58Z</updated>
183
+ <author>
184
+ <name/>
185
+ </author>
186
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Categories" type="application/xml"
187
+ title="Categories" href="Products(5)/$links/Categories"/>
188
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Supplier" type="application/xml"
189
+ title="Supplier" href="Products(5)/$links/Supplier"/>
190
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/ProductDetail" type="application/xml"
191
+ title="ProductDetail" href="Products(5)/$links/ProductDetail"/>
192
+ <content type="application/xml">
193
+ <m:properties>
194
+ <d:ID m:type="Edm.Int32">5</d:ID>
195
+ <d:ReleaseDate m:type="Edm.DateTime">2006-08-04T00:00:00</d:ReleaseDate>
196
+ <d:DiscontinuedDate m:null="true"/>
197
+ <d:Rating m:type="Edm.Int16">3</d:Rating>
198
+ <d:Price m:type="Edm.Double">22.8</d:Price>
199
+ </m:properties>
200
+ </content>
201
+ </entry>
202
+ <entry>
203
+ <id>http://services.odata.org/OData/OData.svc/Products(6)</id>
204
+ <category term="ODataDemo.Product" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
205
+ <link rel="edit" title="Product" href="Products(6)"/>
206
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Categories"
207
+ type="application/atom+xml;type=feed" title="Categories" href="Products(6)/Categories"/>
208
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Supplier"
209
+ type="application/atom+xml;type=entry" title="Supplier" href="Products(6)/Supplier"/>
210
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ProductDetail"
211
+ type="application/atom+xml;type=entry" title="ProductDetail" href="Products(6)/ProductDetail"/>
212
+ <title type="text">Pink Lemonade</title>
213
+ <summary type="text">36 Ounce Cans (Pack of 3)</summary>
214
+ <updated>2014-06-20T06:22:58Z</updated>
215
+ <author>
216
+ <name/>
217
+ </author>
218
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Categories" type="application/xml"
219
+ title="Categories" href="Products(6)/$links/Categories"/>
220
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Supplier" type="application/xml"
221
+ title="Supplier" href="Products(6)/$links/Supplier"/>
222
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/ProductDetail" type="application/xml"
223
+ title="ProductDetail" href="Products(6)/$links/ProductDetail"/>
224
+ <content type="application/xml">
225
+ <m:properties>
226
+ <d:ID m:type="Edm.Int32">6</d:ID>
227
+ <d:ReleaseDate m:type="Edm.DateTime">2006-11-05T00:00:00</d:ReleaseDate>
228
+ <d:DiscontinuedDate m:null="true"/>
229
+ <d:Rating m:type="Edm.Int16">3</d:Rating>
230
+ <d:Price m:type="Edm.Double">18.8</d:Price>
231
+ </m:properties>
232
+ </content>
233
+ </entry>
234
+ <entry>
235
+ <id>http://services.odata.org/OData/OData.svc/Products(7)</id>
236
+ <category term="ODataDemo.Product" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
237
+ <link rel="edit" title="Product" href="Products(7)"/>
238
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Categories"
239
+ type="application/atom+xml;type=feed" title="Categories" href="Products(7)/Categories"/>
240
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Supplier"
241
+ type="application/atom+xml;type=entry" title="Supplier" href="Products(7)/Supplier"/>
242
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ProductDetail"
243
+ type="application/atom+xml;type=entry" title="ProductDetail" href="Products(7)/ProductDetail"/>
244
+ <title type="text">DVD Player</title>
245
+ <summary type="text">1080P Upconversion DVD Player</summary>
246
+ <updated>2014-06-20T06:22:58Z</updated>
247
+ <author>
248
+ <name/>
249
+ </author>
250
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Categories" type="application/xml"
251
+ title="Categories" href="Products(7)/$links/Categories"/>
252
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Supplier" type="application/xml"
253
+ title="Supplier" href="Products(7)/$links/Supplier"/>
254
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/ProductDetail" type="application/xml"
255
+ title="ProductDetail" href="Products(7)/$links/ProductDetail"/>
256
+ <content type="application/xml">
257
+ <m:properties>
258
+ <d:ID m:type="Edm.Int32">7</d:ID>
259
+ <d:ReleaseDate m:type="Edm.DateTime">2006-11-15T00:00:00</d:ReleaseDate>
260
+ <d:DiscontinuedDate m:null="true"/>
261
+ <d:Rating m:type="Edm.Int16">5</d:Rating>
262
+ <d:Price m:type="Edm.Double">35.88</d:Price>
263
+ </m:properties>
264
+ </content>
265
+ </entry>
266
+ <entry>
267
+ <id>http://services.odata.org/OData/OData.svc/Products(8)</id>
268
+ <category term="ODataDemo.Product" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
269
+ <link rel="edit" title="Product" href="Products(8)"/>
270
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Categories"
271
+ type="application/atom+xml;type=feed" title="Categories" href="Products(8)/Categories"/>
272
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Supplier"
273
+ type="application/atom+xml;type=entry" title="Supplier" href="Products(8)/Supplier"/>
274
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ProductDetail"
275
+ type="application/atom+xml;type=entry" title="ProductDetail" href="Products(8)/ProductDetail"/>
276
+ <title type="text">LCD HDTV</title>
277
+ <summary type="text">42 inch 1080p LCD with Built-in Blu-ray Disc Player</summary>
278
+ <updated>2014-06-20T06:22:58Z</updated>
279
+ <author>
280
+ <name/>
281
+ </author>
282
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Categories" type="application/xml"
283
+ title="Categories" href="Products(8)/$links/Categories"/>
284
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Supplier" type="application/xml"
285
+ title="Supplier" href="Products(8)/$links/Supplier"/>
286
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/ProductDetail" type="application/xml"
287
+ title="ProductDetail" href="Products(8)/$links/ProductDetail"/>
288
+ <content type="application/xml">
289
+ <m:properties>
290
+ <d:ID m:type="Edm.Int32">8</d:ID>
291
+ <d:ReleaseDate m:type="Edm.DateTime">2008-05-08T00:00:00</d:ReleaseDate>
292
+ <d:DiscontinuedDate m:null="true"/>
293
+ <d:Rating m:type="Edm.Int16">3</d:Rating>
294
+ <d:Price m:type="Edm.Double">1088.8</d:Price>
295
+ </m:properties>
296
+ </content>
297
+ </entry>
298
+ <entry>
299
+ <id>http://services.odata.org/OData/OData.svc/Products(9)</id>
300
+ <category term="ODataDemo.FeaturedProduct" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
301
+ <link rel="edit" title="Product" href="Products(9)/ODataDemo.FeaturedProduct"/>
302
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Categories"
303
+ type="application/atom+xml;type=feed" title="Categories"
304
+ href="Products(9)/ODataDemo.FeaturedProduct/Categories"/>
305
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Supplier"
306
+ type="application/atom+xml;type=entry" title="Supplier"
307
+ href="Products(9)/ODataDemo.FeaturedProduct/Supplier"/>
308
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ProductDetail"
309
+ type="application/atom+xml;type=entry" title="ProductDetail"
310
+ href="Products(9)/ODataDemo.FeaturedProduct/ProductDetail"/>
311
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Advertisement"
312
+ type="application/atom+xml;type=entry" title="Advertisement"
313
+ href="Products(9)/ODataDemo.FeaturedProduct/Advertisement"/>
314
+ <title type="text">Lemonade</title>
315
+ <summary type="text">Classic, refreshing lemonade (Single bottle)</summary>
316
+ <updated>2014-06-20T06:22:58Z</updated>
317
+ <author>
318
+ <name/>
319
+ </author>
320
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Categories" type="application/xml"
321
+ title="Categories" href="Products(9)/ODataDemo.FeaturedProduct/$links/Categories"/>
322
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Supplier" type="application/xml"
323
+ title="Supplier" href="Products(9)/ODataDemo.FeaturedProduct/$links/Supplier"/>
324
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/ProductDetail" type="application/xml"
325
+ title="ProductDetail" href="Products(9)/ODataDemo.FeaturedProduct/$links/ProductDetail"/>
326
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Advertisement" type="application/xml"
327
+ title="Advertisement" href="Products(9)/ODataDemo.FeaturedProduct/$links/Advertisement"/>
328
+ <content type="application/xml">
329
+ <m:properties>
330
+ <d:ID m:type="Edm.Int32">9</d:ID>
331
+ <d:ReleaseDate m:type="Edm.DateTime">1970-01-01T00:00:00</d:ReleaseDate>
332
+ <d:DiscontinuedDate m:null="true"/>
333
+ <d:Rating m:type="Edm.Int16">7</d:Rating>
334
+ <d:Price m:type="Edm.Double">1.01</d:Price>
335
+ </m:properties>
336
+ </content>
337
+ </entry>
338
+ <entry>
339
+ <id>http://services.odata.org/OData/OData.svc/Products(10)</id>
340
+ <category term="ODataDemo.FeaturedProduct" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
341
+ <link rel="edit" title="Product" href="Products(10)/ODataDemo.FeaturedProduct"/>
342
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Categories"
343
+ type="application/atom+xml;type=feed" title="Categories"
344
+ href="Products(10)/ODataDemo.FeaturedProduct/Categories"/>
345
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Supplier"
346
+ type="application/atom+xml;type=entry" title="Supplier"
347
+ href="Products(10)/ODataDemo.FeaturedProduct/Supplier"/>
348
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ProductDetail"
349
+ type="application/atom+xml;type=entry" title="ProductDetail"
350
+ href="Products(10)/ODataDemo.FeaturedProduct/ProductDetail"/>
351
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Advertisement"
352
+ type="application/atom+xml;type=entry" title="Advertisement"
353
+ href="Products(10)/ODataDemo.FeaturedProduct/Advertisement"/>
354
+ <title type="text">Coffee</title>
355
+ <summary type="text">Bulk size can of instant coffee</summary>
356
+ <updated>2014-06-20T06:22:58Z</updated>
357
+ <author>
358
+ <name/>
359
+ </author>
360
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Categories" type="application/xml"
361
+ title="Categories" href="Products(10)/ODataDemo.FeaturedProduct/$links/Categories"/>
362
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Supplier" type="application/xml"
363
+ title="Supplier" href="Products(10)/ODataDemo.FeaturedProduct/$links/Supplier"/>
364
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/ProductDetail" type="application/xml"
365
+ title="ProductDetail" href="Products(10)/ODataDemo.FeaturedProduct/$links/ProductDetail"/>
366
+ <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Advertisement" type="application/xml"
367
+ title="Advertisement" href="Products(10)/ODataDemo.FeaturedProduct/$links/Advertisement"/>
368
+ <content type="application/xml">
369
+ <m:properties>
370
+ <d:ID m:type="Edm.Int32">10</d:ID>
371
+ <d:ReleaseDate m:type="Edm.DateTime">1982-12-31T00:00:00</d:ReleaseDate>
372
+ <d:DiscontinuedDate m:null="true"/>
373
+ <d:Rating m:type="Edm.Int16">1</d:Rating>
374
+ <d:Price m:type="Edm.Double">6.99</d:Price>
375
+ </m:properties>
376
+ </content>
377
+ </entry>
378
+ </feed>
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+ require 'examples/product_model'
3
+
4
+ describe OData::Model do
5
+ describe 'class methods' do
6
+ it { expect(::Examples::Product).to respond_to(:model_name) }
7
+ it { expect(::Examples::Product.model_name).to eq('Product') }
8
+ it { expect(::Examples::Product.odata_name).to eq('Products') }
9
+ end
10
+
11
+ describe 'defining properties' do
12
+ let(:subject) { ::Examples::Product.new }
13
+
14
+ it { expect(subject).to respond_to(:id) }
15
+ it { expect(subject).to respond_to(:name) }
16
+ it { expect(subject).to respond_to(:description) }
17
+ it { expect(subject).to respond_to(:release_date) }
18
+ it { expect(subject).to respond_to(:discontinued_date) }
19
+ it { expect(subject).to respond_to(:rating) }
20
+ it { expect(subject).to respond_to(:price) }
21
+
22
+ it { expect(::Examples::Product).to respond_to(:primary_key) }
23
+ it { expect(::Examples::Product.primary_key).to eq(:id)}
24
+ end
25
+ end
@@ -11,10 +11,20 @@ describe OData::Service do
11
11
  OData::ServiceRegistry.instance.send(:flush)
12
12
  end
13
13
 
14
- describe 'class methods' do
14
+ describe '.open' do
15
15
  it { expect(OData::Service).to respond_to(:open) }
16
16
  end
17
17
 
18
+ it 'adds itself to OData::ServiceRegistry on creation' do
19
+ expect(OData::ServiceRegistry['ODataDemo']).to be_nil
20
+ expect(OData::ServiceRegistry['http://services.odata.org/OData/OData.svc']).to be_nil
21
+
22
+ service = OData::Service.open('http://services.odata.org/OData/OData.svc')
23
+
24
+ expect(OData::ServiceRegistry['ODataDemo']).to eq(service)
25
+ expect(OData::ServiceRegistry['http://services.odata.org/OData/OData.svc']).to eq(service)
26
+ end
27
+
18
28
  describe 'instance methods' do
19
29
  it { expect(subject).to respond_to(:service_url) }
20
30
  it { expect(subject).to respond_to(:entities) }
@@ -40,13 +50,7 @@ describe OData::Service do
40
50
  it { expect(subject.namespace).to eq('ODataDemo') }
41
51
  end
42
52
 
43
- it 'adds itself to OData::ServiceRegistry on creation' do
44
- expect(OData::ServiceRegistry['ODataDemo']).to be_nil
45
- expect(OData::ServiceRegistry['http://services.odata.org/OData/OData.svc']).to be_nil
46
-
47
- service = OData::Service.open('http://services.odata.org/OData/OData.svc')
48
-
49
- expect(OData::ServiceRegistry['ODataDemo']).to eq(service)
50
- expect(OData::ServiceRegistry['http://services.odata.org/OData/OData.svc']).to eq(service)
53
+ describe '#get' do
54
+ it { expect(subject.get(::Examples::Product).size).to eq(11) }
51
55
  end
52
56
  end
@@ -34,5 +34,8 @@ RSpec.configure do |config|
34
34
  config.before(:example) do
35
35
  WebMock.stub_request(:get, 'http://services.odata.org/OData/OData.svc/$metadata').
36
36
  to_return(status: 200, body: File.open('spec/fixtures/sample_service/metadata.xml'))
37
+
38
+ WebMock.stub_request(:get, 'http://services.odata.org/OData/OData.svc/Products').
39
+ to_return(status: 200, body: File.open('spec/fixtures/sample_service/products.xml'))
37
40
  end
38
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: odata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Thompson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-15 00:00:00.000000000 Z
11
+ date: 2014-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -108,6 +108,34 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: 1.6.2
111
+ - !ruby/object:Gem::Dependency
112
+ name: activesupport
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: 3.0.0
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: 3.0.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: typhoeus
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 0.6.8
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 0.6.8
111
139
  description: Provides a simple interface for working with OData APIs.
112
140
  email:
113
141
  - james@plainprograms.com
@@ -117,18 +145,23 @@ extra_rdoc_files: []
117
145
  files:
118
146
  - ".gitignore"
119
147
  - ".rspec"
148
+ - ".ruby-version"
120
149
  - ".travis.yml"
121
150
  - Gemfile
122
151
  - LICENSE.txt
123
152
  - README.md
124
153
  - Rakefile
125
154
  - lib/odata.rb
155
+ - lib/odata/model.rb
126
156
  - lib/odata/railtie.rb
127
157
  - lib/odata/service.rb
128
158
  - lib/odata/service_registry.rb
129
159
  - lib/odata/version.rb
130
160
  - odata.gemspec
161
+ - spec/examples/product_model.rb
131
162
  - spec/fixtures/sample_service/metadata.xml
163
+ - spec/fixtures/sample_service/products.xml
164
+ - spec/odata/model_spec.rb
132
165
  - spec/odata/service_registry_spec.rb
133
166
  - spec/odata/service_spec.rb
134
167
  - spec/spec_helper.rb
@@ -157,7 +190,10 @@ signing_key:
157
190
  specification_version: 4
158
191
  summary: Simple OData library
159
192
  test_files:
193
+ - spec/examples/product_model.rb
160
194
  - spec/fixtures/sample_service/metadata.xml
195
+ - spec/fixtures/sample_service/products.xml
196
+ - spec/odata/model_spec.rb
161
197
  - spec/odata/service_registry_spec.rb
162
198
  - spec/odata/service_spec.rb
163
199
  - spec/spec_helper.rb