datafoodconsortium-connector 1.0.0.pre.alpha.4 → 1.0.0.pre.alpha.6

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
  SHA256:
3
- metadata.gz: 730da5a9c16ad3380e7374e8cb2ef7c6ce1e85b5dedc262843a77b9facce6eb0
4
- data.tar.gz: 8ec5484fe9a2e862b6077b64ef20e17df76a81fadb9d1ea124c2d9c7ede0463d
3
+ metadata.gz: a824076ba3dcb7d84a5c79b1a234cfe93df085e210eaf3e4afdc75fa2a0d08d2
4
+ data.tar.gz: da11b64f9b159ae00eb6dedd3340aa8de443a44cc43f57325b6b73ba6d96cc91
5
5
  SHA512:
6
- metadata.gz: fc53bf8269ffa64dd5c39b5fe4c2f0fdc9ed1105ffe3dbef20f432b2b708e5339188ae06d9cb2457097f0702467af70bed06d9ae63f3193cb528d81311dff694
7
- data.tar.gz: 1d4c609a3fa0a3976c51c51294ab41a2786a391522e7dc4aeac6e517c0677fc830eefacb9b92d43c724f12bf4cdcbe2bf5446c0c14ccaf05781acfdc6db0976e
6
+ metadata.gz: 5d2717adafc6a45469a2c1e690f9d3721ff1c4fa6ecc9210b8da21e31aa123ece3b1621f866631578bb6356cafe0d1e128ae170eccd2174da96795a53566ed75
7
+ data.tar.gz: b4f8bf9eb7d8057564d5f5891a1a66009cee8e11eb725798985bb8efc7098741548cf01ec528908c9fc1feed9f3916d2532f0dabe7c842ba12bceace2e65bf8f
@@ -27,19 +27,30 @@ class DataFoodConsortium::Connector::Address
27
27
 
28
28
  include VirtualAssembly::Semantizer::SemanticObject
29
29
 
30
+ # @return [String]
30
31
  attr_accessor :street
32
+
33
+ # @return [String]
31
34
  attr_accessor :postalCode
35
+
36
+ # @return [String]
32
37
  attr_accessor :city
38
+
39
+ # @return [String]
33
40
  attr_accessor :country
34
41
 
35
- def initialize(street, postalCode, city, country)
36
- super()
42
+ # @param semanticId [String]
43
+ # @param street [String]
44
+ # @param postalCode [String]
45
+ # @param city [String]
46
+ # @param country [String]
47
+ def initialize(semanticId, street: "", postalCode: "", city: "", country: "")
48
+ super(semanticId)
49
+ @street = street
50
+ @postalCode = postalCode
51
+ @city = city
52
+ @country = country
37
53
  self.semanticType = "http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#Address"
38
- self.street = street
39
- self.postalCode = postalCode
40
- self.city = city
41
- self.country = country
42
-
43
54
  registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#hasStreet") { self.street }
44
55
  registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#hasPostalCode") { self.postalCode }
45
56
  registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#hasCity") { self.city }
@@ -29,33 +29,42 @@ class DataFoodConsortium::Connector::Agent
29
29
 
30
30
  include VirtualAssembly::Semantizer::SemanticObject
31
31
 
32
+ # @return [Contactable]
32
33
  attr_accessor :contacts
34
+
35
+ # @return [Localizable]
33
36
  attr_accessor :localizations
34
37
 
35
- def initialize()
36
- super()
38
+ # @param semanticId [String]
39
+ # @param contacts [Contactable]
40
+ # @param localizations [Localizable]
41
+ def initialize(semanticId, contacts: [], localizations: [])
42
+ super(semanticId)
43
+ @contacts = contacts
44
+ @localizations = localizations
37
45
  self.semanticType = "http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#Agent"
38
-
39
- self.contacts = []
40
- self.localizations = []
41
46
  registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#hasAddress") { self.localizations }
42
47
  end
43
48
 
44
49
 
50
+
45
51
  def addContact(contact)
46
52
  self.contacts.push(contact)
47
53
  end
48
54
 
55
+
49
56
  def addLocalization(localization)
50
57
  self.localizations.push(localization)
51
58
  end
52
59
 
60
+
53
61
  def removeContact(contact)
54
- raise "Not implemented"
62
+ raise "Not yet implemented."
55
63
  end
56
64
 
65
+
57
66
  def removeLocalization(localization)
58
- raise "Not implemented"
67
+ raise "Not yet implemented."
59
68
  end
60
69
 
61
70
 
@@ -21,22 +21,25 @@
21
21
  # SOFTWARE.
22
22
 
23
23
 
24
+ require "datafoodconsortium/connector/characteristic"
24
25
 
25
26
 
26
- require "datafoodconsortium/connector/characteristic"
27
27
  require "virtual_assembly/semantizer"
28
28
 
29
29
  class DataFoodConsortium::Connector::AllergenCharacteristic < DataFoodConsortium::Connector::Characteristic
30
30
 
31
31
 
32
32
 
33
+ # @return [IAllergenDimension]
33
34
  attr_accessor :allergenDimension
34
35
 
35
- def initialize(quantityUnit, quantityValue, allergenDimension)
36
- super(quantityUnit, quantityValue)
36
+ # @param allergenDimension [IAllergenDimension]
37
+ # @param unit [IUnit]
38
+ # @param value [Real]
39
+ def initialize(allergenDimension: nil, unit: nil, value: 0.0)
40
+ super(unit: unit, value: value)
41
+ @allergenDimension = allergenDimension
37
42
  self.semanticType = "http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#AllergenCharacteristic"
38
- self.allergenDimension = allergenDimension
39
-
40
43
  registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#hasAllergenDimension") { self.allergenDimension }
41
44
  end
42
45
 
@@ -20,8 +20,8 @@
20
20
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  # SOFTWARE.
22
22
 
23
-
24
23
  require "datafoodconsortium/connector/characteristic_dimension"
24
+
25
25
  require "virtual_assembly/semantizer"
26
26
 
27
27
  class DataFoodConsortium::Connector::AllergenDimension < DataFoodConsortium::Connector::CharacteristicDimension
@@ -29,18 +29,30 @@ class DataFoodConsortium::Connector::CatalogItem
29
29
 
30
30
  include VirtualAssembly::Semantizer::SemanticObject
31
31
 
32
+ # @return [IDefinedProduct]
32
33
  attr_accessor :product
34
+
35
+ # @return [String]
33
36
  attr_accessor :sku
37
+
38
+ # @return [Real]
34
39
  attr_accessor :stockLimitation
40
+
41
+ # @return [IOffer]
35
42
  attr_accessor :offers
36
43
 
37
- def initialize(product)
38
- super()
44
+ # @param semanticId [String]
45
+ # @param product [IDefinedProduct]
46
+ # @param sku [String]
47
+ # @param stockLimitation [Real]
48
+ # @param offers [IOffer]
49
+ def initialize(semanticId, product: nil, sku: "", stockLimitation: 0.0, offers: [])
50
+ super(semanticId)
51
+ @product = product
52
+ @sku = sku
53
+ @stockLimitation = stockLimitation
54
+ @offers = offers
39
55
  self.semanticType = "http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#CatalogItem"
40
- self.product = product
41
- self.sku = nil
42
- self.stockLimitation = nil
43
- self.offers = []
44
56
  registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#references") { self.product }
45
57
  registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#sku") { self.sku }
46
58
  registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#stockLimitation") { self.stockLimitation }
@@ -50,13 +62,7 @@ class DataFoodConsortium::Connector::CatalogItem
50
62
 
51
63
 
52
64
 
53
- def addOffer(offer)
54
- self.offers.push(offer)
55
- end
56
65
 
57
- def addOffer(offer)
58
- self.offers.push(offer)
59
- end
60
66
 
61
67
 
62
68
  end
@@ -20,8 +20,8 @@
20
20
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  # SOFTWARE.
22
22
 
23
-
24
23
  require "datafoodconsortium/connector/skos_concept"
24
+
25
25
  require "virtual_assembly/semantizer"
26
26
 
27
27
  class DataFoodConsortium::Connector::Certification < DataFoodConsortium::Connector::SKOSConcept
@@ -23,6 +23,7 @@
23
23
 
24
24
 
25
25
  require "datafoodconsortium/connector/quantitative_value"
26
+
26
27
  require "virtual_assembly/semantizer"
27
28
 
28
29
  class DataFoodConsortium::Connector::Characteristic < DataFoodConsortium::Connector::QuantitativeValue
@@ -30,9 +31,10 @@ class DataFoodConsortium::Connector::Characteristic < DataFoodConsortium::Connec
30
31
 
31
32
 
32
33
 
33
- def initialize(quantityUnit, quantityValue)
34
- super(quantityUnit, quantityValue)
35
-
34
+ # @param unit [IUnit]
35
+ # @param value [Real]
36
+ def initialize(unit: nil, value: 0.0)
37
+ super(unit: unit, value: value)
36
38
 
37
39
 
38
40
 
@@ -54,8 +54,21 @@ class DataFoodConsortium::Connector::Connector
54
54
  def initialize()
55
55
  super()
56
56
 
57
+ # used to prefix properties
58
+ # so the DFC's context can be used.
59
+ # See https://github.com/datafoodconsortium/connector-ruby/issues/11.
60
+ inputContext = {
61
+ "dfc-b" => "http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#",
62
+ "dfc-p" => "http://static.datafoodconsortium.org/ontologies/DFC_ProductOntology.owl#",
63
+ "dfc-t" => "http://static.datafoodconsortium.org/ontologies/DFC_TechnicalOntology.owl#",
64
+ "dfc-m" => "http://static.datafoodconsortium.org/data/measures.rdf#",
65
+ "dfc-pt" => "http://static.datafoodconsortium.org/data/productTypes.rdf#",
66
+ "dfc-f" => "http://static.datafoodconsortium.org/data/facets.rdf#"
67
+ }
68
+
57
69
  @context = "http://static.datafoodconsortium.org/ontologies/context.json"
58
- @exporter = DataFoodConsortium::Connector::JsonLdSerializer.new(@context)
70
+
71
+ @exporter = DataFoodConsortium::Connector::JsonLdSerializer.new(@context, inputContext)
59
72
  @parser = DataFoodConsortium::Connector::SKOSParser.new
60
73
 
61
74
  @FACETS = []
@@ -27,16 +27,15 @@ class DataFoodConsortium::Connector::CustomerCategory
27
27
 
28
28
  include VirtualAssembly::Semantizer::SemanticObject
29
29
 
30
- attr_accessor :name
30
+ # @return [String]
31
31
  attr_accessor :description
32
32
 
33
- def initialize(name, description)
34
- super()
33
+ # @param semanticId [String]
34
+ # @param description [String]
35
+ def initialize(semanticId, description: "")
36
+ super(semanticId)
37
+ @description = description
35
38
  self.semanticType = "http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#CustomerCategory"
36
- self.name = name
37
- self.description = description
38
-
39
- registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#name") { self.name }
40
39
  registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#description") { self.description }
41
40
  end
42
41
 
@@ -38,42 +38,90 @@ class DataFoodConsortium::Connector::DefinedProduct
38
38
 
39
39
  include VirtualAssembly::Semantizer::SemanticObject
40
40
 
41
+ # @return [String]
41
42
  attr_accessor :name
43
+
44
+ # @return [String]
42
45
  attr_accessor :description
46
+
47
+ # @return [IProductType]
43
48
  attr_accessor :productType
49
+
50
+ # @return [Quantifiable]
44
51
  attr_accessor :quantity
52
+
53
+ # @return [Real]
45
54
  attr_accessor :alcoholPercentage
55
+
56
+ # @return [String]
46
57
  attr_accessor :lifetime
58
+
59
+ # @return [Claimable]
47
60
  attr_accessor :claims
61
+
62
+ # @return [String]
48
63
  attr_accessor :usageOrStorageConditions
64
+
65
+ # @return [IAllergenCharacteristic]
49
66
  attr_accessor :allergenCharacteristics
67
+
68
+ # @return [INutrientCharacteristic]
50
69
  attr_accessor :nutrientCharacteristics
70
+
71
+ # @return [IPhysicalCharacteristic]
51
72
  attr_accessor :physicalCharacteristics
73
+
74
+ # @return [IGeographicalOrigin]
52
75
  attr_accessor :geographicalOrigin
76
+
77
+ # @return [ICatalogItem]
53
78
  attr_accessor :catalogItems
79
+
80
+ # @return [ICertification]
54
81
  attr_accessor :certifications
82
+
83
+ # @return [INatureOrigin]
55
84
  attr_accessor :natureOrigin
85
+
86
+ # @return [IPartOrigin]
56
87
  attr_accessor :partOrigin
57
88
 
58
- def initialize(name, description)
59
- super()
89
+ # @param semanticId [String]
90
+ # @param name [String]
91
+ # @param description [String]
92
+ # @param productType [IProductType]
93
+ # @param quantity [Quantifiable]
94
+ # @param alcoholPercentage [Real]
95
+ # @param lifetime [String]
96
+ # @param claims [Claimable]
97
+ # @param usageOrStorageConditions [String]
98
+ # @param allergenCharacteristics [IAllergenCharacteristic]
99
+ # @param nutrientCharacteristics [INutrientCharacteristic]
100
+ # @param physicalCharacteristics [IPhysicalCharacteristic]
101
+ # @param geographicalOrigin [IGeographicalOrigin]
102
+ # @param catalogItems [ICatalogItem]
103
+ # @param certifications [ICertification]
104
+ # @param natureOrigin [INatureOrigin]
105
+ # @param partOrigin [IPartOrigin]
106
+ def initialize(semanticId, name: "", description: "", productType: nil, quantity: nil, alcoholPercentage: 0.0, lifetime: "", claims: [], usageOrStorageConditions: "", allergenCharacteristics: [], nutrientCharacteristics: [], physicalCharacteristics: [], geographicalOrigin: nil, catalogItems: [], certifications: [], natureOrigin: [], partOrigin: [])
107
+ super(semanticId)
108
+ @name = name
109
+ @description = description
110
+ @productType = productType
111
+ @quantity = quantity
112
+ @alcoholPercentage = alcoholPercentage
113
+ @lifetime = lifetime
114
+ @claims = claims
115
+ @usageOrStorageConditions = usageOrStorageConditions
116
+ @allergenCharacteristics = allergenCharacteristics
117
+ @nutrientCharacteristics = nutrientCharacteristics
118
+ @physicalCharacteristics = physicalCharacteristics
119
+ @geographicalOrigin = geographicalOrigin
120
+ @catalogItems = catalogItems
121
+ @certifications = certifications
122
+ @natureOrigin = natureOrigin
123
+ @partOrigin = partOrigin
60
124
  self.semanticType = "http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#DefinedProduct"
61
- self.name = name
62
- self.description = description
63
- self.productType = nil
64
- self.quantity = nil
65
- self.alcoholPercentage = nil
66
- self.lifetime = nil
67
- self.claims = []
68
- self.usageOrStorageConditions = nil
69
- self.allergenCharacteristics = []
70
- self.nutrientCharacteristics = []
71
- self.physicalCharacteristics = []
72
- self.geographicalOrigin = nil
73
- self.catalogItems = []
74
- self.certifications = []
75
- self.natureOrigin = []
76
- self.partOrigin = []
77
125
  registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#name") { self.name }
78
126
  registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#description") { self.description }
79
127
  registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#hasType") { self.productType }
@@ -93,64 +141,79 @@ class DataFoodConsortium::Connector::DefinedProduct
93
141
  end
94
142
 
95
143
 
144
+
96
145
  def addClaim(claim)
97
146
  self.claims.push(claim)
98
147
  end
99
148
 
149
+
100
150
  def removeClaim(claim)
101
- raise "Not implemented"
151
+ raise "Not yet implemented."
102
152
  end
103
153
 
154
+
104
155
  def addAllergenCharacteristic(allergenCharacteristic)
105
156
  self.allergenCharacteristics.push(allergenCharacteristic)
106
157
  end
107
158
 
159
+
108
160
  def addNutrientCharacteristic(nutrientCharacteristic)
109
161
  self.nutrientCharacteristics.push(nutrientCharacteristic)
110
162
  end
111
163
 
164
+
112
165
  def addPhysicalCharacteristic(physicalCharacteristic)
113
166
  self.physicalCharacteristics.push(physicalCharacteristic)
114
167
  end
115
168
 
169
+
116
170
  def addNatureOrigin(natureOrigin)
117
171
  self.natureOrigin.push(natureOrigin)
118
172
  end
119
173
 
174
+
120
175
  def addPartOrigin(partOrigin)
121
176
  self.partOrigin.push(partOrigin)
122
177
  end
123
178
 
179
+
124
180
  def removeAllergenCharacteristic(allergenCharacteristic)
125
- raise "Not implemented"
181
+ raise "Not yet implemented."
126
182
  end
127
183
 
184
+
128
185
  def removeNutrientCharacteristic(nutrientCharacteristic)
129
- raise "Not implemented"
186
+ raise "Not yet implemented."
130
187
  end
131
188
 
189
+
132
190
  def removePhysicalCharacteristic(physicalCharacteristic)
133
- raise "Not implemented"
191
+ raise "Not yet implemented."
134
192
  end
135
193
 
194
+
136
195
  def removeNatureOrigin(natureOrigin)
137
- raise "Not implemented"
196
+ raise "Not yet implemented."
138
197
  end
139
198
 
199
+
140
200
  def removePartOrigin(partOrigin)
141
- raise "Not implemented"
201
+ raise "Not yet implemented."
142
202
  end
143
203
 
204
+
144
205
  def addCatalogItem(catalogItem)
145
206
  self.catalogItems.push(catalogItem)
146
207
  end
147
208
 
209
+
148
210
  def addCertification(certification)
149
211
  self.certifications.push(certification)
150
212
  end
151
213
 
214
+
152
215
  def removeCertification(certification)
153
- raise "Not implemented"
216
+ raise "Not yet implemented."
154
217
  end
155
218
 
156
219
 
@@ -20,35 +20,55 @@
20
20
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  # SOFTWARE.
22
22
 
23
+ require "datafoodconsortium/connector/supplied_product"
23
24
 
24
25
 
25
26
 
26
- require "datafoodconsortium/connector/supplied_product"
27
-
28
27
  require "datafoodconsortium/connector/agent"
29
28
 
29
+
30
30
  require "virtual_assembly/semantizer"
31
31
 
32
32
  class DataFoodConsortium::Connector::Enterprise < DataFoodConsortium::Connector::Agent
33
33
 
34
34
 
35
35
 
36
+ # @return [String]
36
37
  attr_accessor :name
38
+
39
+ # @return [String]
37
40
  attr_accessor :description
41
+
42
+ # @return [String]
38
43
  attr_accessor :vatNumber
44
+
45
+ # @return [ICustomerCategory]
39
46
  attr_accessor :customerCategories
47
+
48
+ # @return [SuppliedProduct]
40
49
  attr_accessor :suppliedProducts
50
+
51
+ # @return [ICatalogItem]
41
52
  attr_accessor :catalogItems
42
53
 
43
- def initialize(name)
44
- super()
54
+ # @param semanticId [String]
55
+ # @param name [String]
56
+ # @param description [String]
57
+ # @param vatNumber [String]
58
+ # @param customerCategories [ICustomerCategory]
59
+ # @param suppliedProducts [SuppliedProduct]
60
+ # @param catalogItems [ICatalogItem]
61
+ # @param contacts [Contactable]
62
+ # @param localizations [Localizable]
63
+ def initialize(semanticId, name: "", description: "", vatNumber: "", customerCategories: [], suppliedProducts: [], catalogItems: [], contacts: [], localizations: [])
64
+ super(semanticId, contacts: contacts, localizations: localizations)
65
+ @name = name
66
+ @description = description
67
+ @vatNumber = vatNumber
68
+ @customerCategories = customerCategories
69
+ @suppliedProducts = suppliedProducts
70
+ @catalogItems = catalogItems
45
71
  self.semanticType = "http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#Enterprise"
46
- self.name = name
47
- self.description = nil
48
- self.vatNumber = nil
49
- self.customerCategories = []
50
- self.suppliedProducts = []
51
- self.catalogItems = []
52
72
  registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#hasName") { self.name }
53
73
  registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#hasDescription") { self.description }
54
74
  registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#VATnumber") { self.vatNumber }
@@ -58,25 +78,6 @@ class DataFoodConsortium::Connector::Enterprise < DataFoodConsortium::Connector:
58
78
  end
59
79
 
60
80
 
61
- def addCustomerCategory(customerCategory)
62
- self.customerCategories.push(customerCategory)
63
- end
64
-
65
- def addSupplyProduct(suppliedProduct)
66
- self.suppliedProducts.push(suppliedProduct)
67
- end
68
-
69
- def addCatalogItem(catalogItem)
70
- self.catalogItems.push(catalogItem)
71
- end
72
-
73
- def addSupplyProduct(suppliedProduct)
74
- self.suppliedProducts.push(suppliedProduct)
75
- end
76
-
77
- def addCatalogItem(catalogItem)
78
- self.catalogItems.push(catalogItem)
79
- end
80
81
 
81
82
  def addCustomerCategory(customerCategory)
82
83
  self.customerCategories.push(customerCategory)
@@ -20,8 +20,8 @@
20
20
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  # SOFTWARE.
22
22
 
23
-
24
23
  require "datafoodconsortium/connector/skos_concept"
24
+
25
25
  require "virtual_assembly/semantizer"
26
26
 
27
27
  class DataFoodConsortium::Connector::GeographicalOrigin < DataFoodConsortium::Connector::SKOSConcept
@@ -25,9 +25,9 @@ require 'json/ld'
25
25
 
26
26
  class DataFoodConsortium::Connector::JsonLdSerializer
27
27
 
28
- def initialize(context = nil)
29
- @context = context
30
- @hashSerializer = VirtualAssembly::Semantizer::HashSerializer.new
28
+ def initialize(outputContext = nil, inputContext = nil)
29
+ @outputContext = outputContext
30
+ @hashSerializer = VirtualAssembly::Semantizer::HashSerializer.new(inputContext)
31
31
  end
32
32
 
33
33
  def process(subject, *subjects)
@@ -39,11 +39,16 @@ class DataFoodConsortium::Connector::JsonLdSerializer
39
39
 
40
40
  inputs = []
41
41
 
42
+ # Insert an input context on each subject so the properties could be prefixed. This way,
43
+ # the DFC's context can be used.
44
+ # See https://github.com/datafoodconsortium/connector-ruby/issues/11.
42
45
  subjects.each do |subject|
43
- inputs.push(subject.serialize(@hashSerializer))
46
+ input = { "@context" => "http://static.datafoodconsortium.org/ontologies/context.json" }
47
+ input.merge!(subject.serialize(@hashSerializer))
48
+ inputs.push(input)
44
49
  end
45
-
46
- jsonLd = JSON::LD::API.compact(inputs, @context)
50
+
51
+ jsonLd = JSON::LD::API.compact(inputs, @outputContext)
47
52
 
48
53
  return JSON.generate(jsonLd)
49
54
  end
@@ -22,21 +22,24 @@
22
22
 
23
23
 
24
24
 
25
-
26
25
  require "datafoodconsortium/connector/characteristic"
26
+
27
27
  require "virtual_assembly/semantizer"
28
28
 
29
29
  class DataFoodConsortium::Connector::NutrientCharacteristic < DataFoodConsortium::Connector::Characteristic
30
30
 
31
31
 
32
32
 
33
+ # @return [INutrientDimension]
33
34
  attr_accessor :nutrientDimension
34
35
 
35
- def initialize(quantityUnit, quantityValue, nutrientDimension)
36
- super(quantityUnit, quantityValue)
36
+ # @param nutrientDimension [INutrientDimension]
37
+ # @param unit [IUnit]
38
+ # @param value [Real]
39
+ def initialize(nutrientDimension: nil, unit: nil, value: 0.0)
40
+ super(unit: unit, value: value)
41
+ @nutrientDimension = nutrientDimension
37
42
  self.semanticType = "http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#NutrientCharacteristic"
38
- self.nutrientDimension = nutrientDimension
39
-
40
43
  registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#hasNutrientDimension") { self.nutrientDimension }
41
44
  end
42
45
 
@@ -29,18 +29,30 @@ class DataFoodConsortium::Connector::Offer
29
29
 
30
30
  include VirtualAssembly::Semantizer::SemanticObject
31
31
 
32
+ # @return [IPrice]
32
33
  attr_accessor :price
34
+
35
+ # @return [Real]
33
36
  attr_accessor :stockLimitation
37
+
38
+ # @return [ICatalogItem]
34
39
  attr_accessor :offeredItem
40
+
41
+ # @return [ICustomerCategory]
35
42
  attr_accessor :offeredTo
36
43
 
37
- def initialize(offeredItem, offeredTo)
38
- super()
44
+ # @param semanticId [String]
45
+ # @param price [IPrice]
46
+ # @param stockLimitation [Real]
47
+ # @param offeredItem [ICatalogItem]
48
+ # @param offeredTo [ICustomerCategory]
49
+ def initialize(semanticId, price: nil, stockLimitation: 0.0, offeredItem: nil, offeredTo: nil)
50
+ super(semanticId)
51
+ @price = price
52
+ @stockLimitation = stockLimitation
53
+ @offeredItem = offeredItem
54
+ @offeredTo = offeredTo
39
55
  self.semanticType = "http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#Offer"
40
- self.offeredItem = offeredItem
41
- self.offeredTo = offeredTo
42
- self.price = nil
43
- self.stockLimitation = nil
44
56
  registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#price") { self.price }
45
57
  registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#stockLimitation") { self.stockLimitation }
46
58
  registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#offeredItem") { self.offeredItem }
@@ -48,9 +60,6 @@ class DataFoodConsortium::Connector::Offer
48
60
  end
49
61
 
50
62
 
51
- def addOffer(offer)
52
- self..push(offer)
53
- end
54
63
 
55
64
 
56
65
  end
@@ -20,8 +20,8 @@
20
20
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  # SOFTWARE.
22
22
 
23
-
24
23
  require "datafoodconsortium/connector/skos_concept"
24
+
25
25
  require "virtual_assembly/semantizer"
26
26
 
27
27
  class DataFoodConsortium::Connector::PartOrigin < DataFoodConsortium::Connector::SKOSConcept
@@ -29,28 +29,41 @@ class DataFoodConsortium::Connector::Person < DataFoodConsortium::Connector::Age
29
29
 
30
30
 
31
31
 
32
+ # @return [String]
32
33
  attr_accessor :firstName
34
+
35
+ # @return [String]
33
36
  attr_accessor :lastName
37
+
38
+ # @return [Onboardable]
34
39
  attr_accessor :affiliatedOrganizations
35
40
 
36
- def initialize(firstName, lastName)
37
- super()
41
+ # @param semanticId [String]
42
+ # @param firstName [String]
43
+ # @param lastName [String]
44
+ # @param affiliatedOrganizations [Onboardable]
45
+ # @param contacts [Contactable]
46
+ # @param localizations [Localizable]
47
+ def initialize(semanticId, firstName: "", lastName: "", affiliatedOrganizations: [], contacts: [], localizations: [])
48
+ super(semanticId, contacts: contacts, localizations: localizations)
49
+ @firstName = firstName
50
+ @lastName = lastName
51
+ @affiliatedOrganizations = affiliatedOrganizations
38
52
  self.semanticType = "http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#Person"
39
- self.firstName = firstName
40
- self.lastName = lastName
41
- self.affiliatedOrganizations = []
42
53
  registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#firstName") { self.firstName }
43
54
  registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#familyName") { self.lastName }
44
55
  registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#affiliates") { self.affiliatedOrganizations }
45
56
  end
46
57
 
47
58
 
59
+
48
60
  def affiliateTo(organization)
49
61
  self.affiliatedOrganizations.push(organization)
50
62
  end
51
63
 
64
+
52
65
  def leaveAffiliatedOrganization(organization)
53
- raise "Not implemented"
66
+ raise "Not yet implemented."
54
67
  end
55
68
 
56
69
 
@@ -20,9 +20,9 @@
20
20
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  # SOFTWARE.
22
22
 
23
+ require "datafoodconsortium/connector/characteristic"
23
24
 
24
25
 
25
- require "datafoodconsortium/connector/characteristic"
26
26
 
27
27
  require "virtual_assembly/semantizer"
28
28
 
@@ -30,13 +30,16 @@ class DataFoodConsortium::Connector::PhysicalCharacteristic < DataFoodConsortium
30
30
 
31
31
 
32
32
 
33
+ # @return [IPhysicalDimension]
33
34
  attr_accessor :physicalDimension
34
35
 
35
- def initialize(quantityUnit, quantityValue, physicalDimension)
36
- super(quantityUnit, quantityValue)
36
+ # @param physicalDimension [IPhysicalDimension]
37
+ # @param unit [IUnit]
38
+ # @param value [Real]
39
+ def initialize(physicalDimension: nil, unit: nil, value: 0.0)
40
+ super(unit: unit, value: value)
41
+ @physicalDimension = physicalDimension
37
42
  self.semanticType = "http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#PhysicalCharacteristic"
38
- self.physicalDimension = physicalDimension
39
-
40
43
  registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#hasPhysicalDimension") { self.physicalDimension }
41
44
  end
42
45
 
@@ -0,0 +1,55 @@
1
+ # MIT License
2
+ #
3
+ # Copyright (c) 2023 Maxime Lecoq <maxime@lecoqlibre.fr>
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+
24
+ require "virtual_assembly/semantizer"
25
+
26
+ class DataFoodConsortium::Connector::Price
27
+
28
+ include VirtualAssembly::Semantizer::SemanticObject
29
+
30
+ # @return [Real]
31
+ attr_accessor :value
32
+
33
+ # @return [Real]
34
+ attr_accessor :vatRate
35
+
36
+ # @return [IUnit]
37
+ attr_accessor :unit
38
+
39
+ # @param value [Real]
40
+ # @param vatRate [Real]
41
+ # @param unit [IUnit]
42
+ def initialize(value: 0.0, vatRate: 0.0, unit: nil)
43
+ super()
44
+ @value = value
45
+ @vatRate = vatRate
46
+ @unit = unit
47
+ self.semanticType = "http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#Price"
48
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#value") { self.value }
49
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#VATrate") { self.vatRate }
50
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#hasUnit") { self.unit }
51
+ end
52
+
53
+
54
+
55
+ end
@@ -21,23 +21,28 @@
21
21
  # SOFTWARE.
22
22
 
23
23
 
24
+
24
25
  require "virtual_assembly/semantizer"
25
26
 
26
27
  class DataFoodConsortium::Connector::QuantitativeValue
27
28
 
28
29
  include VirtualAssembly::Semantizer::SemanticObject
29
30
 
30
- attr_accessor :quantityUnit
31
- attr_accessor :quantityValue
31
+ # @return [IUnit]
32
+ attr_accessor :unit
33
+
34
+ # @return [Real]
35
+ attr_accessor :value
32
36
 
33
- def initialize(quantityUnit, quantityValue)
37
+ # @param unit [IUnit]
38
+ # @param value [Real]
39
+ def initialize(unit: nil, value: 0.0)
34
40
  super()
41
+ @unit = unit
42
+ @value = value
35
43
  self.semanticType = "http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#QuantitativeValue"
36
- self.quantityUnit = quantityUnit
37
- self.quantityValue = quantityValue
38
-
39
- registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#hasUnit") { self.quantityUnit }
40
- registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#value") { self.quantityValue }
44
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#hasUnit") { self.unit }
45
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#value") { self.value }
41
46
  end
42
47
 
43
48
 
@@ -29,19 +29,29 @@ class DataFoodConsortium::Connector::SKOSConcept
29
29
 
30
30
  include VirtualAssembly::Semantizer::SemanticObject
31
31
 
32
+ # @return [ISKOSConcept]
32
33
  attr_accessor :broaders
34
+
35
+ # @return [ISKOSConceptScheme]
33
36
  attr_accessor :schemes
37
+
38
+ # @return [ISKOSConcept]
34
39
  attr_accessor :narrowers
40
+
41
+ # @return [ISKOSLabel]
35
42
  attr_accessor :prefLabels
36
43
 
37
- def initialize()
44
+ # @param broaders [ISKOSConcept]
45
+ # @param schemes [ISKOSConceptScheme]
46
+ # @param narrowers [ISKOSConcept]
47
+ # @param prefLabels [ISKOSLabel]
48
+ def initialize(broaders: [], schemes: [], narrowers: [], prefLabels: [])
38
49
  super()
50
+ @broaders = broaders
51
+ @schemes = schemes
52
+ @narrowers = narrowers
53
+ @prefLabels = prefLabels
39
54
  self.semanticType = "http://www.w3.org/2004/02/skos/core#Concept"
40
-
41
- self.broaders = []
42
- self.schemes = []
43
- self.narrowers = []
44
- self.prefLabels = []
45
55
  registerSemanticProperty("http://www.w3.org/2004/02/skos/core#broader") { self.broaders }
46
56
  registerSemanticProperty("http://www.w3.org/2004/02/skos/core#inScheme") { self.schemes }
47
57
  registerSemanticProperty("http://www.w3.org/2004/02/skos/core#narrower") { self.narrowers }
@@ -49,36 +59,28 @@ class DataFoodConsortium::Connector::SKOSConcept
49
59
  end
50
60
 
51
61
 
52
- def addBroader(broader)
53
- self.broaders.push(broader)
54
- end
55
62
 
56
- def addScheme(scheme)
57
- self.schemes.push(scheme)
58
- end
59
63
 
60
- def addNarrower(narrower)
61
- self.narrowers.push(narrower)
62
- end
63
64
 
64
- def addPrefLabel(prefLabel)
65
- self.prefLabels.push(prefLabel)
66
- end
65
+
67
66
 
68
67
  def removeBroader(broader)
69
- raise "Not implemented"
68
+ raise "Not yet implemented."
70
69
  end
71
70
 
71
+
72
72
  def removeScheme(scheme)
73
- raise "Not implemented"
73
+ raise "Not yet implemented."
74
74
  end
75
75
 
76
+
76
77
  def removeNarrower(narrower)
77
- raise "Not implemented"
78
+ raise "Not yet implemented."
78
79
  end
79
80
 
81
+
80
82
  def removePrefLabel(prefLabel)
81
- raise "Not implemented"
83
+ raise "Not yet implemented."
82
84
  end
83
85
 
84
86
 
@@ -27,15 +27,38 @@ class DataFoodConsortium::Connector::SuppliedProduct < DataFoodConsortium::Conne
27
27
 
28
28
 
29
29
 
30
+ # @return [Real]
31
+ attr_accessor :totalTheoreticalStock
30
32
 
31
- def initialize(name, description)
32
- super(name, description)
33
+ # @param semanticId [String]
34
+ # @param totalTheoreticalStock [Real]
35
+ # @param name [String]
36
+ # @param description [String]
37
+ # @param productType [IProductType]
38
+ # @param quantity [Quantifiable]
39
+ # @param alcoholPercentage [Real]
40
+ # @param lifetime [String]
41
+ # @param claims [Claimable]
42
+ # @param usageOrStorageConditions [String]
43
+ # @param allergenCharacteristics [IAllergenCharacteristic]
44
+ # @param nutrientCharacteristics [INutrientCharacteristic]
45
+ # @param physicalCharacteristics [IPhysicalCharacteristic]
46
+ # @param geographicalOrigin [IGeographicalOrigin]
47
+ # @param catalogItems [ICatalogItem]
48
+ # @param certifications [ICertification]
49
+ # @param natureOrigin [INatureOrigin]
50
+ # @param partOrigin [IPartOrigin]
51
+ def initialize(semanticId, totalTheoreticalStock: 0.0, name: "", description: "", productType: nil, quantity: nil, alcoholPercentage: 0.0, lifetime: "", claims: [], usageOrStorageConditions: "", allergenCharacteristics: [], nutrientCharacteristics: [], physicalCharacteristics: [], geographicalOrigin: nil, catalogItems: [], certifications: [], natureOrigin: [], partOrigin: [])
52
+ super(semanticId, name: name, description: description, productType: productType, quantity: quantity, alcoholPercentage: alcoholPercentage, lifetime: lifetime, claims: claims, usageOrStorageConditions: usageOrStorageConditions, allergenCharacteristics: allergenCharacteristics, nutrientCharacteristics: nutrientCharacteristics, physicalCharacteristics: physicalCharacteristics, geographicalOrigin: geographicalOrigin, catalogItems: catalogItems, certifications: certifications, natureOrigin: natureOrigin, partOrigin: partOrigin)
53
+ @totalTheoreticalStock = totalTheoreticalStock
33
54
  self.semanticType = "http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#SuppliedProduct"
34
-
35
-
36
-
55
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#totalTheoreticalStock") { self.totalTheoreticalStock }
37
56
  end
38
57
 
39
58
 
59
+
60
+
61
+
62
+
40
63
 
41
64
  end
@@ -6,26 +6,27 @@ module DataFoodConsortium
6
6
  require 'datafoodconsortium/connector/skos_parser'
7
7
  require 'datafoodconsortium/connector/agent.rb'
8
8
  require 'datafoodconsortium/connector/enterprise.rb'
9
- require 'datafoodconsortium/connector/customer_category.rb'
10
9
  require 'datafoodconsortium/connector/person.rb'
10
+ require 'datafoodconsortium/connector/customer_category.rb'
11
+ require 'datafoodconsortium/connector/offer.rb'
11
12
  require 'datafoodconsortium/connector/repository.rb'
12
- require 'datafoodconsortium/connector/catalog_item.rb'
13
+ require 'datafoodconsortium/connector/price.rb'
13
14
  require 'datafoodconsortium/connector/order.rb'
14
- require 'datafoodconsortium/connector/offer.rb'
15
+ require 'datafoodconsortium/connector/catalog_item.rb'
15
16
  require 'datafoodconsortium/connector/order_line.rb'
16
- require 'datafoodconsortium/connector/address.rb'
17
- require 'datafoodconsortium/connector/geographical_origin.rb'
18
- require 'datafoodconsortium/connector/physical_characteristic.rb'
19
17
  require 'datafoodconsortium/connector/allergen_dimension.rb'
20
- require 'datafoodconsortium/connector/allergen_characteristic.rb'
21
- require 'datafoodconsortium/connector/nutrient_characteristic.rb'
22
18
  require 'datafoodconsortium/connector/characteristic.rb'
23
- require 'datafoodconsortium/connector/product_type.rb'
19
+ require 'datafoodconsortium/connector/address.rb'
20
+ require 'datafoodconsortium/connector/characteristic_dimension.rb'
21
+ require 'datafoodconsortium/connector/nutrient_characteristic.rb'
24
22
  require 'datafoodconsortium/connector/part_origin.rb'
25
- require 'datafoodconsortium/connector/quantitative_value.rb'
26
23
  require 'datafoodconsortium/connector/unit.rb'
24
+ require 'datafoodconsortium/connector/quantitative_value.rb'
27
25
  require 'datafoodconsortium/connector/certification.rb'
28
- require 'datafoodconsortium/connector/characteristic_dimension.rb'
26
+ require 'datafoodconsortium/connector/product_type.rb'
27
+ require 'datafoodconsortium/connector/physical_characteristic.rb'
28
+ require 'datafoodconsortium/connector/allergen_characteristic.rb'
29
+ require 'datafoodconsortium/connector/geographical_origin.rb'
29
30
  require 'datafoodconsortium/connector/nature_origin.rb'
30
31
  require 'datafoodconsortium/connector/defined_product.rb'
31
32
  require 'datafoodconsortium/connector/supplied_product.rb'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datafoodconsortium-connector
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.alpha.4
4
+ version: 1.0.0.pre.alpha.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxime Lecoq
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-13 00:00:00.000000000 Z
11
+ date: 2023-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: virtual_assembly-semantizer
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '1.0'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 1.0.2
22
+ version: 1.0.4
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,35 @@ dependencies:
29
29
  version: '1.0'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 1.0.2
32
+ version: 1.0.4
33
+ - !ruby/object:Gem::Dependency
34
+ name: minitest
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
33
61
  description: A library to easily integrate the DFC standard within your application.
34
62
  email: maxime@lecoqlibre.fr
35
63
  executables: []
@@ -59,6 +87,7 @@ files:
59
87
  - lib/datafoodconsortium/connector/part_origin.rb
60
88
  - lib/datafoodconsortium/connector/person.rb
61
89
  - lib/datafoodconsortium/connector/physical_characteristic.rb
90
+ - lib/datafoodconsortium/connector/price.rb
62
91
  - lib/datafoodconsortium/connector/product_type.rb
63
92
  - lib/datafoodconsortium/connector/quantitative_value.rb
64
93
  - lib/datafoodconsortium/connector/repository.rb