datafoodconsortium-connector 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. checksums.yaml +4 -4
  2. data/lib/datafoodconsortium/connector/connector.rb +8 -8
  3. data/lib/datafoodconsortium/connector/context.rb +13 -5
  4. data/lib/datafoodconsortium/connector/{context_1.14.0.json → context_1.16.0.json} +36 -0
  5. data/lib/datafoodconsortium/connector/delivery_option.rb +67 -0
  6. data/lib/datafoodconsortium/connector/localized_product.rb +105 -0
  7. data/lib/datafoodconsortium/connector/payment_method.rb +70 -0
  8. data/lib/datafoodconsortium/connector/physical_place.rb +94 -0
  9. data/lib/datafoodconsortium/connector/physical_product.rb +104 -0
  10. data/lib/datafoodconsortium/connector/pickup_option.rb +55 -0
  11. data/lib/datafoodconsortium/connector/planned_local_consumption_flow.rb +56 -0
  12. data/lib/datafoodconsortium/connector/planned_local_production_flow.rb +56 -0
  13. data/lib/datafoodconsortium/connector/planned_local_transformation.rb +79 -0
  14. data/lib/datafoodconsortium/connector/planned_transformation.rb +1 -0
  15. data/lib/datafoodconsortium/connector/product_batch.rb +90 -0
  16. data/lib/datafoodconsortium/connector/real_stock.rb +74 -0
  17. data/lib/datafoodconsortium/connector/realized_consumption_flow.rb +56 -0
  18. data/lib/datafoodconsortium/connector/realized_production_flow.rb +56 -0
  19. data/lib/datafoodconsortium/connector/realized_transformation.rb +73 -0
  20. data/lib/datafoodconsortium/connector/shipping_option.rb +91 -0
  21. data/lib/datafoodconsortium/connector/theoretical_stock.rb +67 -0
  22. data/lib/datafoodconsortium/connector/virtual_place.rb +64 -0
  23. data/lib/datafoodconsortium/connector.rb +17 -0
  24. metadata +21 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 40d1b7f766984fc8ee3d3f26cf2ade067ec7dd9a235909b0899eb4ec332cd661
4
- data.tar.gz: 5319424d204c44431b22906c3c31409a890b4de229472540f701b24c15081b4a
3
+ metadata.gz: 8c8a65b126a0a4837acd570ccc5fe0057fb49ab6440958bed35cfec693944e2d
4
+ data.tar.gz: cd7f2ed362d8a06a7d9605b1dcfa1e3591cb903b7319b6b0297a9c9e3f1fb9be
5
5
  SHA512:
6
- metadata.gz: 953e93000215c7db54e7bc7fbcb03a04e724ab131b945a6a89963b3b92d92ef163ac1c429255e8b4c88408ea237ff7d6e34354394e8d5560b42755b32abd285b
7
- data.tar.gz: 94281d6f476d285260f552fe96a17755b60c0e7bb4513e7665d3d12d5d554d78455b50cf95bb25bfd1f12ab33c14ced681ea7d639bc0181f26ce46650a509737
6
+ metadata.gz: aa01d91de19e4282f94c4ae4e7c09fa5e2bde5a8f29b5b166ffb530502ef86455ee8011ee69590d2656042ca1373914e93ca7433829fa7233f3570d377390288
7
+ data.tar.gz: 5b60adf9c9825f3ae395290749bd545b866d9a1daa4c3090c715af1102f656c75293f473408879fbe2a6ace73819b7a4fa3cefb64bfb28837e82079270b9a4f5
@@ -25,8 +25,8 @@ require 'datafoodconsortium/connector/context'
25
25
  require 'datafoodconsortium/connector/importer'
26
26
  require 'datafoodconsortium/connector/json_ld_serializer'
27
27
 
28
- class DataFoodConsortium::Connector::Connector
29
-
28
+ module DataFoodConsortium::Connector
29
+ class Connector
30
30
  include Singleton
31
31
 
32
32
  attr_accessor :context
@@ -40,7 +40,7 @@ class DataFoodConsortium::Connector::Connector
40
40
  end
41
41
 
42
42
  def import(json_string_or_io)
43
- DataFoodConsortium::Connector::Importer.new.import(json_string_or_io)
43
+ Importer.new.import(json_string_or_io)
44
44
  end
45
45
 
46
46
  def loadFacets(data)
@@ -63,12 +63,12 @@ class DataFoodConsortium::Connector::Connector
63
63
  # used to prefix properties
64
64
  # so the DFC's context can be used.
65
65
  # See https://github.com/datafoodconsortium/connector-ruby/issues/11.
66
- inputContext = DataFoodConsortium::Connector::Context.inputContext
66
+ inputContext = Context.inputContext
67
67
 
68
- @context = "https://www.datafoodconsortium.org"
68
+ @context = Context::URL
69
69
 
70
- @exporter = DataFoodConsortium::Connector::JsonLdSerializer.new(@context, inputContext)
71
- @parser = DataFoodConsortium::Connector::SKOSParser.new
70
+ @exporter = JsonLdSerializer.new(@context, inputContext)
71
+ @parser = SKOSParser.new
72
72
 
73
73
  @FACETS = []
74
74
  @MEASURES = []
@@ -80,5 +80,5 @@ class DataFoodConsortium::Connector::Connector
80
80
  data = data[0] if data.is_a?(Array)
81
81
  @parser.parse(data["@graph"])
82
82
  end
83
-
83
+ end
84
84
  end
@@ -2,15 +2,23 @@
2
2
 
3
3
  require 'json/ld'
4
4
 
5
- # Preload the DFC context.
6
- #
7
- # Similar to: https://github.com/ruby-rdf/json-ld-preloaded/
8
5
  module DataFoodConsortium
9
6
  module Connector
7
+ # Preload the DFC context.
8
+ #
9
+ # Similar to: https://github.com/ruby-rdf/json-ld-preloaded/
10
10
  class Context < JSON::LD::Context
11
+ URL = "https://www.datafoodconsortium.org"
12
+
11
13
  add_preloaded("http://www.datafoodconsortium.org/") { parse(json) }
12
14
 
13
- # This is the actual file the DFC website refers to in a link header.
15
+ # This is the current file the DFC website refers to in a link header.
16
+ alias_preloaded(
17
+ "https://www.datafoodconsortium.org/wp-content/plugins/wordpress-context-jsonld/context_1.16.0.jsonld",
18
+ "http://www.datafoodconsortium.org/"
19
+ )
20
+
21
+ # This was the file the DFC website refers to in a link header.
14
22
  alias_preloaded(
15
23
  "https://www.datafoodconsortium.org/wp-content/plugins/wordpress-context-jsonld/context.jsonld",
16
24
  "http://www.datafoodconsortium.org/"
@@ -29,7 +37,7 @@ module DataFoodConsortium
29
37
  end
30
38
 
31
39
  def self.json
32
- @json ||= JSON.parse(File.read("#{__dir__}/context_1.14.0.json"))["@context"]
40
+ @json ||= JSON.parse(File.read("#{__dir__}/context_1.16.0.json"))["@context"]
33
41
  end
34
42
  end
35
43
  end
@@ -29,6 +29,9 @@
29
29
  "dfc-b:allergenCharacteristicOf": {
30
30
  "@type": "@id"
31
31
  },
32
+ "dfc-b:basedAt": {
33
+ "@type": "@id"
34
+ },
32
35
  "dfc-b:belongsTo": {
33
36
  "@type": "@id"
34
37
  },
@@ -86,6 +89,9 @@
86
89
  "dfc-b:deliveredAt": {
87
90
  "@type": "@id"
88
91
  },
92
+ "dfc-b:endsAt": {
93
+ "@type": "@id"
94
+ },
89
95
  "dfc-b:facetOf": {
90
96
  "@type": "@id"
91
97
  },
@@ -122,6 +128,9 @@
122
128
  "dfc-b:hasContainerInformation": {
123
129
  "@type": "@id"
124
130
  },
131
+ "dfc-b:hasCountry": {
132
+ "@type": "@id"
133
+ },
125
134
  "dfc-b:hasDimension": {
126
135
  "@type": "@id"
127
136
  },
@@ -224,6 +233,9 @@
224
233
  "dfc-b:hasUnit": {
225
234
  "@type": "@id"
226
235
  },
236
+ "dfc-b:hasVariant": {
237
+ "@type": "@id"
238
+ },
227
239
  "dfc-b:holds": {
228
240
  "@type": "@id"
229
241
  },
@@ -248,18 +260,30 @@
248
260
  "dfc-b:inputOf": {
249
261
  "@type": "@id"
250
262
  },
263
+ "dfc-b:isAvailableDuring": {
264
+ "@type": "@id"
265
+ },
251
266
  "dfc-b:isFulfilledBy": {
252
267
  "@type": "@id"
253
268
  },
254
269
  "dfc-b:isIngredientOf": {
255
270
  "@type": "@id"
256
271
  },
272
+ "dfc-b:isOpenDuring": {
273
+ "@type": "@id"
274
+ },
257
275
  "dfc-b:isPriceOf": {
258
276
  "@type": "@id"
259
277
  },
278
+ "dfc-b:isShippedIn": {
279
+ "@type": "@id"
280
+ },
260
281
  "dfc-b:isTemperatureOf": {
261
282
  "@type": "@id"
262
283
  },
284
+ "dfc-b:isVariantOf": {
285
+ "@type": "@id"
286
+ },
263
287
  "dfc-b:labellingCharacteristicOf": {
264
288
  "@type": "@id"
265
289
  },
@@ -398,12 +422,18 @@
398
422
  "dfc-b:sells": {
399
423
  "@type": "@id"
400
424
  },
425
+ "dfc-b:ships": {
426
+ "@type": "@id"
427
+ },
401
428
  "dfc-b:socialMediaOf": {
402
429
  "@type": "@id"
403
430
  },
404
431
  "dfc-b:soldBy": {
405
432
  "@type": "@id"
406
433
  },
434
+ "dfc-b:startsAt": {
435
+ "@type": "@id"
436
+ },
407
437
  "dfc-b:storedIn": {
408
438
  "@type": "@id"
409
439
  },
@@ -434,6 +464,12 @@
434
464
  "dfc-b:transforms": {
435
465
  "@type": "@id"
436
466
  },
467
+ "dfc-b:transportedBy": {
468
+ "@type": "@id"
469
+ },
470
+ "dfc-b:transports": {
471
+ "@type": "@id"
472
+ },
437
473
  "dfc-b:typeOf": {
438
474
  "@type": "@id"
439
475
  },
@@ -0,0 +1,67 @@
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
+
25
+
26
+ require "datafoodconsortium/connector/shipping_option"
27
+ require "virtual_assembly/semantizer"
28
+
29
+ class DataFoodConsortium::Connector::DeliveryOption < DataFoodConsortium::Connector::ShippingOption
30
+
31
+ SEMANTIC_TYPE = "dfc-b:DeliveryOption".freeze
32
+
33
+ # @return [IPhysicalPlace]
34
+ attr_accessor :deliveredPlace
35
+
36
+ # @return [String]
37
+ attr_accessor :deliveryConstraint
38
+
39
+ # @return [String]
40
+ attr_accessor :accessibilityInformation
41
+
42
+ # @param semanticId [String]
43
+ # @param deliveredPlace [IPhysicalPlace]
44
+ # @param deliveryConstraint [String]
45
+ # @param accessibilityInformation [String]
46
+ # @param name [String]
47
+ # @param description [String]
48
+ # @param fee [Real]
49
+ # @param quantity [IQuantity]
50
+ # @param order [IOrder]
51
+ # @param saleSession [ISaleSession]
52
+ # @param beginDate [DateTime]
53
+ # @param endDate [DateTime]
54
+ def initialize(semanticId, deliveredPlace: nil, deliveryConstraint: nil, accessibilityInformation: nil, name: nil, description: nil, fee: nil, quantity: nil, order: nil, saleSession: nil, beginDate: nil, endDate: nil)
55
+ super(semanticId, name: name, description: description, fee: fee, quantity: quantity, order: order, saleSession: saleSession, beginDate: beginDate, endDate: endDate)
56
+ @deliveredPlace = deliveredPlace
57
+ @deliveryConstraint = deliveryConstraint
58
+ @accessibilityInformation = accessibilityInformation
59
+ self.semanticType = "dfc-b:DeliveryOption"
60
+ registerSemanticProperty("dfc-b:deliveredAt", &method("deliveredPlace")).valueSetter = method("deliveredPlace=")
61
+ registerSemanticProperty("dfc-b:deliveryConstraint", &method("deliveryConstraint")).valueSetter = method("deliveryConstraint=")
62
+ registerSemanticProperty("dfc-b:accessibilityInfo", &method("accessibilityInformation")).valueSetter = method("accessibilityInformation=")
63
+ end
64
+
65
+
66
+
67
+ end
@@ -0,0 +1,105 @@
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
+
25
+
26
+
27
+
28
+
29
+
30
+ require "virtual_assembly/semantizer"
31
+
32
+ class DataFoodConsortium::Connector::LocalizedProduct
33
+ include VirtualAssembly::Semantizer::SemanticObject
34
+
35
+ SEMANTIC_TYPE = "dfc-b:LocalizedProduct".freeze
36
+
37
+ # @return [String]
38
+ attr_accessor :name
39
+
40
+ # @return [String]
41
+ attr_accessor :description
42
+
43
+ # @return [String]
44
+ attr_accessor :images
45
+
46
+ # @return [IQuantity]
47
+ attr_accessor :quantity
48
+
49
+ # @return [Real]
50
+ attr_accessor :cost
51
+
52
+ # @return [Real]
53
+ attr_accessor :theoreticalStocks
54
+
55
+ # @return [ISuppliedProduct]
56
+ attr_accessor :suppliedProducts
57
+
58
+ # @return [IPhysicalProduct]
59
+ attr_accessor :physicalProducts
60
+
61
+ # @return [IPlannedLocalProductionFlow]
62
+ attr_accessor :plannedLocalProductionFlows
63
+
64
+ # @return [IPlannedLocalConsumptionFlow]
65
+ attr_accessor :plannedLocalConsumptionFlows
66
+
67
+ # @param semanticId [String]
68
+ # @param name [String]
69
+ # @param description [String]
70
+ # @param images [String]
71
+ # @param quantity [IQuantity]
72
+ # @param cost [Real]
73
+ # @param theoreticalStocks [Real]
74
+ # @param suppliedProducts [ISuppliedProduct]
75
+ # @param physicalProducts [IPhysicalProduct]
76
+ # @param plannedLocalProductionFlows [IPlannedLocalProductionFlow]
77
+ # @param plannedLocalConsumptionFlows [IPlannedLocalConsumptionFlow]
78
+ def initialize(semanticId, name: nil, description: nil, images: [], quantity: nil, cost: nil, theoreticalStocks: [], suppliedProducts: [], physicalProducts: [], plannedLocalProductionFlows: [], plannedLocalConsumptionFlows: [])
79
+ super(semanticId)
80
+ @name = name
81
+ @description = description
82
+ @images = images
83
+ @quantity = quantity
84
+ @cost = cost
85
+ @theoreticalStocks = theoreticalStocks
86
+ @suppliedProducts = suppliedProducts
87
+ @physicalProducts = physicalProducts
88
+ @plannedLocalProductionFlows = plannedLocalProductionFlows
89
+ @plannedLocalConsumptionFlows = plannedLocalConsumptionFlows
90
+ self.semanticType = "dfc-b:LocalizedProduct"
91
+ registerSemanticProperty("dfc-b:name", &method("name")).valueSetter = method("name=")
92
+ registerSemanticProperty("dfc-b:description", &method("description")).valueSetter = method("description=")
93
+ registerSemanticProperty("dfc-b:image", &method("images")).valueSetter = method("images=")
94
+ registerSemanticProperty("dfc-b:hasQuantity", &method("quantity")).valueSetter = method("quantity=")
95
+ registerSemanticProperty("dfc-b:cost", &method("cost")).valueSetter = method("cost=")
96
+ registerSemanticProperty("dfc-b:constituedBy", &method("theoreticalStocks")).valueSetter = method("theoreticalStocks=")
97
+ registerSemanticProperty("dfc-b:hasReference", &method("suppliedProducts")).valueSetter = method("suppliedProducts=")
98
+ registerSemanticProperty("dfc-b:representedBy", &method("physicalProducts")).valueSetter = method("physicalProducts=")
99
+ registerSemanticProperty("dfc-b:producedBy", &method("plannedLocalProductionFlows")).valueSetter = method("plannedLocalProductionFlows=")
100
+ registerSemanticProperty("dfc-b:consumedBy", &method("plannedLocalConsumptionFlows")).valueSetter = method("plannedLocalConsumptionFlows=")
101
+ end
102
+
103
+
104
+
105
+ end
@@ -0,0 +1,70 @@
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
+
25
+ require "virtual_assembly/semantizer"
26
+
27
+ class DataFoodConsortium::Connector::PaymentMethod
28
+ include VirtualAssembly::Semantizer::SemanticObject
29
+
30
+ SEMANTIC_TYPE = "dfc-b:PaymentMethod".freeze
31
+
32
+ # @return [String]
33
+ attr_accessor :name
34
+
35
+ # @return [String]
36
+ attr_accessor :description
37
+
38
+ # @return [IPrice]
39
+ attr_accessor :price
40
+
41
+ # @return [String]
42
+ attr_accessor :provider
43
+
44
+ # @return [String]
45
+ attr_accessor :type
46
+
47
+ # @param semanticId [String]
48
+ # @param name [String]
49
+ # @param description [String]
50
+ # @param price [IPrice]
51
+ # @param provider [String]
52
+ # @param type [String]
53
+ def initialize(semanticId, name: nil, description: nil, price: nil, provider: nil, type: nil)
54
+ super(semanticId)
55
+ @name = name
56
+ @description = description
57
+ @price = price
58
+ @provider = provider
59
+ @type = type
60
+ self.semanticType = "dfc-b:PaymentMethod"
61
+ registerSemanticProperty("dfc-b:name", &method("name")).valueSetter = method("name=")
62
+ registerSemanticProperty("dfc-b:description", &method("description")).valueSetter = method("description=")
63
+ registerSemanticProperty("dfc-b:hasPrice", &method("price")).valueSetter = method("price=")
64
+ registerSemanticProperty("dfc-b:paymentMethodProvider", &method("provider")).valueSetter = method("provider=")
65
+ registerSemanticProperty("dfc-b:paymentMethodType", &method("type")).valueSetter = method("type=")
66
+ end
67
+
68
+
69
+
70
+ end
@@ -0,0 +1,94 @@
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
+
25
+ require "virtual_assembly/semantizer"
26
+
27
+ class DataFoodConsortium::Connector::PhysicalPlace
28
+ include VirtualAssembly::Semantizer::SemanticObject
29
+
30
+ SEMANTIC_TYPE = "dfc-b:PhysicalPlace".freeze
31
+
32
+ # @return [String]
33
+ attr_accessor :name
34
+
35
+ # @return [String]
36
+ attr_accessor :description
37
+
38
+ # @return [ISaleSession]
39
+ attr_accessor :hostedSaleSessions
40
+
41
+ # @return [IPhoneNumber]
42
+ attr_accessor :phoneNumbers
43
+
44
+ # @return [IOpeningHoursSpecification]
45
+ attr_accessor :openingHours
46
+
47
+ # @return [IAddress]
48
+ attr_accessor :addresses
49
+
50
+ # @return [IPerson]
51
+ attr_accessor :mainContact
52
+
53
+ # @return [ITheoreticalStock]
54
+ attr_accessor :theoreticalStocks
55
+
56
+ # @return [IRealStock]
57
+ attr_accessor :realStocks
58
+
59
+ # @param semanticId [String]
60
+ # @param name [String]
61
+ # @param description [String]
62
+ # @param hostedSaleSessions [ISaleSession]
63
+ # @param phoneNumbers [IPhoneNumber]
64
+ # @param openingHours [IOpeningHoursSpecification]
65
+ # @param addresses [IAddress]
66
+ # @param mainContact [IPerson]
67
+ # @param theoreticalStocks [ITheoreticalStock]
68
+ # @param realStocks [IRealStock]
69
+ def initialize(semanticId, name: nil, description: nil, hostedSaleSessions: [], phoneNumbers: [], openingHours: [], addresses: [], mainContact: nil, theoreticalStocks: [], realStocks: [])
70
+ super(semanticId)
71
+ @name = name
72
+ @description = description
73
+ @hostedSaleSessions = hostedSaleSessions
74
+ @phoneNumbers = phoneNumbers
75
+ @openingHours = openingHours
76
+ @addresses = addresses
77
+ @mainContact = mainContact
78
+ @theoreticalStocks = theoreticalStocks
79
+ @realStocks = realStocks
80
+ self.semanticType = "dfc-b:PhysicalPlace"
81
+ registerSemanticProperty("dfc-b:name", &method("name")).valueSetter = method("name=")
82
+ registerSemanticProperty("dfc-b:description", &method("description")).valueSetter = method("description=")
83
+ registerSemanticProperty("dfc-b:hosts", &method("hostedSaleSessions")).valueSetter = method("hostedSaleSessions=")
84
+ registerSemanticProperty("dfc-b:hasPhoneNumber", &method("phoneNumbers")).valueSetter = method("phoneNumbers=")
85
+ registerSemanticProperty("dfc-b:hasOpeningHours", &method("openingHours")).valueSetter = method("openingHours=")
86
+ registerSemanticProperty("dfc-b:hasAddress", &method("addresses")).valueSetter = method("addresses=")
87
+ registerSemanticProperty("dfc-b:hasMainContact", &method("mainContact")).valueSetter = method("mainContact=")
88
+ registerSemanticProperty("dfc-b:localizes", &method("theoreticalStocks")).valueSetter = method("theoreticalStocks=")
89
+ registerSemanticProperty("dfc-b:stores", &method("realStocks")).valueSetter = method("realStocks=")
90
+ end
91
+
92
+
93
+
94
+ end
@@ -0,0 +1,104 @@
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
+
25
+
26
+
27
+
28
+
29
+ require "virtual_assembly/semantizer"
30
+
31
+ class DataFoodConsortium::Connector::PhysicalProduct
32
+ include VirtualAssembly::Semantizer::SemanticObject
33
+
34
+ SEMANTIC_TYPE = "dfc-b:PhysicalProduct".freeze
35
+
36
+ # @return [String]
37
+ attr_accessor :name
38
+
39
+ # @return [String]
40
+ attr_accessor :description
41
+
42
+ # @return [String]
43
+ attr_accessor :images
44
+
45
+ # @return [IQuantity]
46
+ attr_accessor :quantity
47
+
48
+ # @return [Real]
49
+ attr_accessor :cost
50
+
51
+ # @return [Real]
52
+ attr_accessor :realStocks
53
+
54
+ # @return [ILocalizedProduct]
55
+ attr_accessor :localizedProducts
56
+
57
+ # @return [IProductBatch]
58
+ attr_accessor :productBatches
59
+
60
+ # @return [IRealizedProductionFlow]
61
+ attr_accessor :realizedProductionFlows
62
+
63
+ # @return [IRealizedConsumptionFlow]
64
+ attr_accessor :realizedConsumptionFlows
65
+
66
+ # @param semanticId [String]
67
+ # @param name [String]
68
+ # @param description [String]
69
+ # @param images [String]
70
+ # @param quantity [IQuantity]
71
+ # @param cost [Real]
72
+ # @param realStocks [Real]
73
+ # @param localizedProducts [ILocalizedProduct]
74
+ # @param productBatches [IProductBatch]
75
+ # @param realizedProductionFlows [IRealizedProductionFlow]
76
+ # @param realizedConsumptionFlows [IRealizedConsumptionFlow]
77
+ def initialize(semanticId, name: nil, description: nil, images: [], quantity: nil, cost: nil, realStocks: [], localizedProducts: [], productBatches: [], realizedProductionFlows: [], realizedConsumptionFlows: [])
78
+ super(semanticId)
79
+ @name = name
80
+ @description = description
81
+ @images = images
82
+ @quantity = quantity
83
+ @cost = cost
84
+ @realStocks = realStocks
85
+ @localizedProducts = localizedProducts
86
+ @productBatches = productBatches
87
+ @realizedProductionFlows = realizedProductionFlows
88
+ @realizedConsumptionFlows = realizedConsumptionFlows
89
+ self.semanticType = "dfc-b:PhysicalProduct"
90
+ registerSemanticProperty("dfc-b:name", &method("name")).valueSetter = method("name=")
91
+ registerSemanticProperty("dfc-b:description", &method("description")).valueSetter = method("description=")
92
+ registerSemanticProperty("dfc-b:image", &method("images")).valueSetter = method("images=")
93
+ registerSemanticProperty("dfc-b:hasQuantity", &method("quantity")).valueSetter = method("quantity=")
94
+ registerSemanticProperty("dfc-b:cost", &method("cost")).valueSetter = method("cost=")
95
+ registerSemanticProperty("dfc-b:constituedBy", &method("realStocks")).valueSetter = method("realStocks=")
96
+ registerSemanticProperty("dfc-b:represents", &method("localizedProducts")).valueSetter = method("localizedProducts=")
97
+ registerSemanticProperty("dfc-b:tracedBy", &method("productBatches")).valueSetter = method("productBatches=")
98
+ registerSemanticProperty("dfc-b:producedBy", &method("realizedProductionFlows")).valueSetter = method("realizedProductionFlows=")
99
+ registerSemanticProperty("dfc-b:consumedBy", &method("realizedConsumptionFlows")).valueSetter = method("realizedConsumptionFlows=")
100
+ end
101
+
102
+
103
+
104
+ end