datafoodconsortium-connector 1.0.0.pre.alpha.9 → 1.0.0.pre.alpha.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/datafoodconsortium/connector/address.rb +25 -6
- data/lib/datafoodconsortium/connector/agent.rb +14 -7
- data/lib/datafoodconsortium/connector/allergen_characteristic.rb +3 -3
- data/lib/datafoodconsortium/connector/catalog.rb +4 -3
- data/lib/datafoodconsortium/connector/catalog_item.rb +7 -6
- data/lib/datafoodconsortium/connector/characteristic.rb +1 -3
- data/lib/datafoodconsortium/connector/connector.rb +10 -9
- data/lib/datafoodconsortium/connector/context.rb +72 -0
- data/lib/datafoodconsortium/connector/customer_category.rb +3 -2
- data/lib/datafoodconsortium/connector/defined_product.rb +25 -18
- data/lib/datafoodconsortium/connector/enterprise.rb +14 -13
- data/lib/datafoodconsortium/connector/{allergen_dimension.rb → flow.rb} +15 -3
- data/lib/datafoodconsortium/connector/importer.rb +112 -0
- data/lib/datafoodconsortium/connector/json_ld_serializer.rb +7 -14
- data/lib/datafoodconsortium/connector/nutrient_characteristic.rb +2 -2
- data/lib/datafoodconsortium/connector/offer.rb +6 -5
- data/lib/datafoodconsortium/connector/order.rb +26 -7
- data/lib/datafoodconsortium/connector/order_line.rb +7 -6
- data/lib/datafoodconsortium/connector/person.rb +8 -7
- data/lib/datafoodconsortium/connector/phone_number.rb +4 -3
- data/lib/datafoodconsortium/connector/physical_characteristic.rb +3 -3
- data/lib/datafoodconsortium/connector/{certification.rb → planned_consumption_flow.rb} +25 -3
- data/lib/datafoodconsortium/connector/{characteristic_dimension.rb → planned_production_flow.rb} +25 -3
- data/lib/datafoodconsortium/connector/planned_transformation.rb +59 -0
- data/lib/datafoodconsortium/connector/price.rb +5 -4
- data/lib/datafoodconsortium/connector/quantitative_value.rb +4 -3
- data/lib/datafoodconsortium/connector/quantity.rb +4 -3
- data/lib/datafoodconsortium/connector/sale_session.rb +6 -5
- data/lib/datafoodconsortium/connector/skos_concept.rb +10 -7
- data/lib/datafoodconsortium/connector/skos_helper.rb +14 -0
- data/lib/datafoodconsortium/connector/skos_parser.rb +122 -99
- data/lib/datafoodconsortium/connector/skos_parser_element.rb +72 -53
- data/lib/datafoodconsortium/connector/social_media.rb +4 -7
- data/lib/datafoodconsortium/connector/supplied_product.rb +5 -4
- data/lib/datafoodconsortium/connector/technical_product.rb +5 -4
- data/lib/datafoodconsortium/connector.rb +23 -13
- metadata +13 -41
- data/lib/datafoodconsortium/connector/geographical_origin.rb +0 -34
- data/lib/datafoodconsortium/connector/nature_origin.rb +0 -34
- data/lib/datafoodconsortium/connector/part_origin.rb +0 -34
- data/lib/datafoodconsortium/connector/product_type.rb +0 -34
- data/lib/datafoodconsortium/connector/repository.rb +0 -33
- data/lib/datafoodconsortium/connector/unit.rb +0 -34
@@ -30,27 +30,20 @@ class DataFoodConsortium::Connector::JsonLdSerializer
|
|
30
30
|
@hashSerializer = VirtualAssembly::Semantizer::HashSerializer.new(inputContext)
|
31
31
|
end
|
32
32
|
|
33
|
-
def process(
|
34
|
-
subjects.
|
33
|
+
def process(*subjects)
|
34
|
+
return "" if subjects.empty?
|
35
35
|
|
36
|
-
if (subjects.empty?)
|
37
|
-
return ""
|
38
|
-
end
|
39
|
-
|
40
|
-
inputs = []
|
41
|
-
|
42
36
|
# Insert an input context on each subject so the properties could be prefixed. This way,
|
43
37
|
# the DFC's context can be used.
|
44
38
|
# See https://github.com/datafoodconsortium/connector-ruby/issues/11.
|
45
|
-
subjects.
|
46
|
-
|
47
|
-
|
48
|
-
inputs.push(input)
|
39
|
+
inputs = subjects.map do |subject|
|
40
|
+
# JSON::LD needs a context on every input using prefixes.
|
41
|
+
subject.serialize(@hashSerializer).merge("@context" => @outputContext)
|
49
42
|
end
|
50
43
|
|
51
44
|
jsonLd = JSON::LD::API.compact(inputs, @outputContext)
|
52
45
|
|
53
|
-
|
46
|
+
JSON.generate(jsonLd)
|
54
47
|
end
|
55
48
|
|
56
|
-
end
|
49
|
+
end
|
@@ -27,7 +27,7 @@ require "virtual_assembly/semantizer"
|
|
27
27
|
|
28
28
|
class DataFoodConsortium::Connector::NutrientCharacteristic < DataFoodConsortium::Connector::Characteristic
|
29
29
|
|
30
|
-
|
30
|
+
SEMANTIC_TYPE = "dfc-b:NutrientCharacteristic".freeze
|
31
31
|
|
32
32
|
# @return [ISKOSConcept]
|
33
33
|
attr_accessor :nutrientDimension
|
@@ -39,7 +39,7 @@ class DataFoodConsortium::Connector::NutrientCharacteristic < DataFoodConsortium
|
|
39
39
|
super(unit: unit, value: value)
|
40
40
|
@nutrientDimension = nutrientDimension
|
41
41
|
self.semanticType = "dfc-b:NutrientCharacteristic"
|
42
|
-
registerSemanticProperty("dfc-b:hasNutrientDimension")
|
42
|
+
registerSemanticProperty("dfc-b:hasNutrientDimension", &method("nutrientDimension")).valueSetter = method("nutrientDimension=")
|
43
43
|
end
|
44
44
|
|
45
45
|
|
@@ -27,8 +27,9 @@
|
|
27
27
|
require "virtual_assembly/semantizer"
|
28
28
|
|
29
29
|
class DataFoodConsortium::Connector::Offer
|
30
|
+
include VirtualAssembly::Semantizer::SemanticObject
|
30
31
|
|
31
|
-
|
32
|
+
SEMANTIC_TYPE = "dfc-b:Offer".freeze
|
32
33
|
|
33
34
|
# @return [IPrice]
|
34
35
|
attr_accessor :price
|
@@ -54,10 +55,10 @@ class DataFoodConsortium::Connector::Offer
|
|
54
55
|
@offeredItem = offeredItem
|
55
56
|
@offeredTo = offeredTo
|
56
57
|
self.semanticType = "dfc-b:Offer"
|
57
|
-
registerSemanticProperty("dfc-b:hasPrice")
|
58
|
-
registerSemanticProperty("dfc-b:stockLimitation")
|
59
|
-
registerSemanticProperty("dfc-b:offeredItem")
|
60
|
-
registerSemanticProperty("dfc-b:offeredTo")
|
58
|
+
registerSemanticProperty("dfc-b:hasPrice", &method("price")).valueSetter = method("price=")
|
59
|
+
registerSemanticProperty("dfc-b:stockLimitation", &method("stockLimitation")).valueSetter = method("stockLimitation=")
|
60
|
+
registerSemanticProperty("dfc-b:offeredItem", &method("offeredItem")).valueSetter = method("offeredItem=")
|
61
|
+
registerSemanticProperty("dfc-b:offeredTo", &method("offeredTo")).valueSetter = method("offeredTo=")
|
61
62
|
end
|
62
63
|
|
63
64
|
|
@@ -27,8 +27,9 @@
|
|
27
27
|
require "virtual_assembly/semantizer"
|
28
28
|
|
29
29
|
class DataFoodConsortium::Connector::Order
|
30
|
+
include VirtualAssembly::Semantizer::SemanticObject
|
30
31
|
|
31
|
-
|
32
|
+
SEMANTIC_TYPE = "dfc-b:Order".freeze
|
32
33
|
|
33
34
|
# @return [String]
|
34
35
|
attr_accessor :number
|
@@ -45,25 +46,43 @@ class DataFoodConsortium::Connector::Order
|
|
45
46
|
# @return [IAgent]
|
46
47
|
attr_accessor :client
|
47
48
|
|
49
|
+
# @return [ISKOSConcept]
|
50
|
+
attr_accessor :fulfilmentStatus
|
51
|
+
|
52
|
+
# @return [ISKOSConcept]
|
53
|
+
attr_accessor :orderStatus
|
54
|
+
|
55
|
+
# @return [ISKOSConcept]
|
56
|
+
attr_accessor :paymentStatus
|
57
|
+
|
48
58
|
# @param semanticId [String]
|
49
59
|
# @param number [String]
|
50
60
|
# @param date [String]
|
51
61
|
# @param saleSession [ISaleSession]
|
52
62
|
# @param lines [IOrderLine]
|
53
63
|
# @param client [IAgent]
|
54
|
-
|
64
|
+
# @param fulfilmentStatus [ISKOSConcept]
|
65
|
+
# @param orderStatus [ISKOSConcept]
|
66
|
+
# @param paymentStatus [ISKOSConcept]
|
67
|
+
def initialize(semanticId, number: "", date: "", saleSession: nil, lines: [], client: nil, fulfilmentStatus: nil, orderStatus: nil, paymentStatus: nil)
|
55
68
|
super(semanticId)
|
56
69
|
@number = number
|
57
70
|
@date = date
|
58
71
|
@saleSession = saleSession
|
59
72
|
@lines = lines
|
60
73
|
@client = client
|
74
|
+
@fulfilmentStatus = fulfilmentStatus
|
75
|
+
@orderStatus = orderStatus
|
76
|
+
@paymentStatus = paymentStatus
|
61
77
|
self.semanticType = "dfc-b:Order"
|
62
|
-
registerSemanticProperty("dfc-b:orderNumber")
|
63
|
-
registerSemanticProperty("dfc-b:date")
|
64
|
-
registerSemanticProperty("dfc-b:belongsTo")
|
65
|
-
registerSemanticProperty("dfc-b:hasPart")
|
66
|
-
registerSemanticProperty("dfc-b:orderedBy")
|
78
|
+
registerSemanticProperty("dfc-b:orderNumber", &method("number")).valueSetter = method("number=")
|
79
|
+
registerSemanticProperty("dfc-b:date", &method("date")).valueSetter = method("date=")
|
80
|
+
registerSemanticProperty("dfc-b:belongsTo", &method("saleSession")).valueSetter = method("saleSession=")
|
81
|
+
registerSemanticProperty("dfc-b:hasPart", &method("lines")).valueSetter = method("lines=")
|
82
|
+
registerSemanticProperty("dfc-b:orderedBy", &method("client")).valueSetter = method("client=")
|
83
|
+
registerSemanticProperty("dfc-b:hasFulfilmentStatus", &method("fulfilmentStatus")).valueSetter = method("fulfilmentStatus=")
|
84
|
+
registerSemanticProperty("dfc-b:hasOrderStatus", &method("orderStatus")).valueSetter = method("orderStatus=")
|
85
|
+
registerSemanticProperty("dfc-b:hasPaymentStatus", &method("paymentStatus")).valueSetter = method("paymentStatus=")
|
67
86
|
end
|
68
87
|
|
69
88
|
|
@@ -27,8 +27,9 @@
|
|
27
27
|
require "virtual_assembly/semantizer"
|
28
28
|
|
29
29
|
class DataFoodConsortium::Connector::OrderLine
|
30
|
+
include VirtualAssembly::Semantizer::SemanticObject
|
30
31
|
|
31
|
-
|
32
|
+
SEMANTIC_TYPE = "dfc-b:OrderLine".freeze
|
32
33
|
|
33
34
|
# @return [String]
|
34
35
|
attr_accessor :description
|
@@ -59,11 +60,11 @@ class DataFoodConsortium::Connector::OrderLine
|
|
59
60
|
@offer = offer
|
60
61
|
@order = order
|
61
62
|
self.semanticType = "dfc-b:OrderLine"
|
62
|
-
registerSemanticProperty("dfc-b:description")
|
63
|
-
registerSemanticProperty("dfc-b:quantity")
|
64
|
-
registerSemanticProperty("dfc-b:hasPrice")
|
65
|
-
registerSemanticProperty("dfc-b:concerns")
|
66
|
-
registerSemanticProperty("dfc-b:partOf")
|
63
|
+
registerSemanticProperty("dfc-b:description", &method("description")).valueSetter = method("description=")
|
64
|
+
registerSemanticProperty("dfc-b:quantity", &method("quantity")).valueSetter = method("quantity=")
|
65
|
+
registerSemanticProperty("dfc-b:hasPrice", &method("price")).valueSetter = method("price=")
|
66
|
+
registerSemanticProperty("dfc-b:concerns", &method("offer")).valueSetter = method("offer=")
|
67
|
+
registerSemanticProperty("dfc-b:partOf", &method("order")).valueSetter = method("order=")
|
67
68
|
end
|
68
69
|
|
69
70
|
|
@@ -20,15 +20,15 @@
|
|
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/agent"
|
23
24
|
|
24
25
|
|
25
26
|
|
26
|
-
require "datafoodconsortium/connector/agent"
|
27
27
|
require "virtual_assembly/semantizer"
|
28
28
|
|
29
29
|
class DataFoodConsortium::Connector::Person < DataFoodConsortium::Connector::Agent
|
30
30
|
|
31
|
-
|
31
|
+
SEMANTIC_TYPE = "dfc-b:Person".freeze
|
32
32
|
|
33
33
|
# @return [String]
|
34
34
|
attr_accessor :firstName
|
@@ -48,15 +48,16 @@ class DataFoodConsortium::Connector::Person < DataFoodConsortium::Connector::Age
|
|
48
48
|
# @param emails [String]
|
49
49
|
# @param websites [String]
|
50
50
|
# @param socialMedias [ISocialMedia]
|
51
|
-
|
52
|
-
|
51
|
+
# @param logo [String]
|
52
|
+
def initialize(semanticId, firstName: "", lastName: "", affiliatedOrganizations: [], localizations: [], phoneNumbers: [], emails: [], websites: [], socialMedias: [], logo: "")
|
53
|
+
super(semanticId, localizations: localizations, phoneNumbers: phoneNumbers, emails: emails, websites: websites, socialMedias: socialMedias, logo: logo)
|
53
54
|
@firstName = firstName
|
54
55
|
@lastName = lastName
|
55
56
|
@affiliatedOrganizations = affiliatedOrganizations
|
56
57
|
self.semanticType = "dfc-b:Person"
|
57
|
-
registerSemanticProperty("dfc-b:firstName")
|
58
|
-
registerSemanticProperty("dfc-b:familyName")
|
59
|
-
registerSemanticProperty("dfc-b:affiliates")
|
58
|
+
registerSemanticProperty("dfc-b:firstName", &method("firstName")).valueSetter = method("firstName=")
|
59
|
+
registerSemanticProperty("dfc-b:familyName", &method("lastName")).valueSetter = method("lastName=")
|
60
|
+
registerSemanticProperty("dfc-b:affiliates", &method("affiliatedOrganizations")).valueSetter = method("affiliatedOrganizations=")
|
60
61
|
end
|
61
62
|
|
62
63
|
|
@@ -24,8 +24,9 @@
|
|
24
24
|
require "virtual_assembly/semantizer"
|
25
25
|
|
26
26
|
class DataFoodConsortium::Connector::PhoneNumber
|
27
|
+
include VirtualAssembly::Semantizer::SemanticObject
|
27
28
|
|
28
|
-
|
29
|
+
SEMANTIC_TYPE = "dfc-b:PhoneNumber".freeze
|
29
30
|
|
30
31
|
# @return [Integer]
|
31
32
|
attr_accessor :countryCode
|
@@ -41,8 +42,8 @@ class DataFoodConsortium::Connector::PhoneNumber
|
|
41
42
|
@countryCode = countryCode
|
42
43
|
@phoneNumber = phoneNumber
|
43
44
|
self.semanticType = "dfc-b:PhoneNumber"
|
44
|
-
registerSemanticProperty("dfc-b:countryCode")
|
45
|
-
registerSemanticProperty("dfc-b:phoneNumber")
|
45
|
+
registerSemanticProperty("dfc-b:countryCode", &method("countryCode")).valueSetter = method("countryCode=")
|
46
|
+
registerSemanticProperty("dfc-b:phoneNumber", &method("phoneNumber")).valueSetter = method("phoneNumber=")
|
46
47
|
end
|
47
48
|
|
48
49
|
|
@@ -20,14 +20,14 @@
|
|
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
|
require "virtual_assembly/semantizer"
|
27
27
|
|
28
28
|
class DataFoodConsortium::Connector::PhysicalCharacteristic < DataFoodConsortium::Connector::Characteristic
|
29
29
|
|
30
|
-
|
30
|
+
SEMANTIC_TYPE = "dfc-b:PhysicalCharacteristic".freeze
|
31
31
|
|
32
32
|
# @return [ISKOSConcept]
|
33
33
|
attr_accessor :physicalDimension
|
@@ -39,7 +39,7 @@ class DataFoodConsortium::Connector::PhysicalCharacteristic < DataFoodConsortium
|
|
39
39
|
super(unit: unit, value: value)
|
40
40
|
@physicalDimension = physicalDimension
|
41
41
|
self.semanticType = "dfc-b:PhysicalCharacteristic"
|
42
|
-
registerSemanticProperty("dfc-b:hasPhysicalDimension")
|
42
|
+
registerSemanticProperty("dfc-b:hasPhysicalDimension", &method("physicalDimension")).valueSetter = method("physicalDimension=")
|
43
43
|
end
|
44
44
|
|
45
45
|
|
@@ -20,15 +20,37 @@
|
|
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/
|
23
|
+
require "datafoodconsortium/connector/flow"
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
24
28
|
|
25
29
|
require "virtual_assembly/semantizer"
|
26
30
|
|
27
|
-
class DataFoodConsortium::Connector::
|
31
|
+
class DataFoodConsortium::Connector::PlannedConsumptionFlow < DataFoodConsortium::Connector::Flow
|
28
32
|
|
29
|
-
|
33
|
+
SEMANTIC_TYPE = "dfc-b:AsPlannedConsumptionFlow".freeze
|
34
|
+
|
35
|
+
# @return [IPlannedTransformation]
|
36
|
+
attr_accessor :transformation
|
30
37
|
|
38
|
+
# @return [IDefinedProduct]
|
39
|
+
attr_accessor :product
|
31
40
|
|
41
|
+
# @param semanticId [String]
|
42
|
+
# @param transformation [IPlannedTransformation]
|
43
|
+
# @param product [IDefinedProduct]
|
44
|
+
# @param quantity [IQuantity]
|
45
|
+
def initialize(semanticId, transformation: nil, product: nil, quantity: nil)
|
46
|
+
super(semanticId, quantity: quantity)
|
47
|
+
@transformation = transformation
|
48
|
+
@product = product
|
49
|
+
self.semanticType = "dfc-b:AsPlannedConsumptionFlow"
|
50
|
+
registerSemanticProperty("dfc-b:incomeOf", &method("transformation")).valueSetter = method("transformation=")
|
51
|
+
registerSemanticProperty("dfc-b:consumes", &method("product")).valueSetter = method("product=")
|
52
|
+
end
|
53
|
+
|
32
54
|
|
33
55
|
|
34
56
|
end
|
data/lib/datafoodconsortium/connector/{characteristic_dimension.rb → planned_production_flow.rb}
RENAMED
@@ -20,15 +20,37 @@
|
|
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/
|
23
|
+
require "datafoodconsortium/connector/flow"
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
24
28
|
|
25
29
|
require "virtual_assembly/semantizer"
|
26
30
|
|
27
|
-
class DataFoodConsortium::Connector::
|
31
|
+
class DataFoodConsortium::Connector::PlannedProductionFlow < DataFoodConsortium::Connector::Flow
|
28
32
|
|
29
|
-
|
33
|
+
SEMANTIC_TYPE = "dfc-b:AsPlannedProductionFlow".freeze
|
34
|
+
|
35
|
+
# @return [IPlannedTransformation]
|
36
|
+
attr_accessor :transformation
|
30
37
|
|
38
|
+
# @return [ISuppliedProduct]
|
39
|
+
attr_accessor :product
|
31
40
|
|
41
|
+
# @param semanticId [String]
|
42
|
+
# @param transformation [IPlannedTransformation]
|
43
|
+
# @param product [ISuppliedProduct]
|
44
|
+
# @param quantity [IQuantity]
|
45
|
+
def initialize(semanticId, transformation: nil, product: nil, quantity: nil)
|
46
|
+
super(semanticId, quantity: quantity)
|
47
|
+
@transformation = transformation
|
48
|
+
@product = product
|
49
|
+
self.semanticType = "dfc-b:AsPlannedProductionFlow"
|
50
|
+
registerSemanticProperty("dfc-b:outcomeOf", &method("transformation")).valueSetter = method("transformation=")
|
51
|
+
registerSemanticProperty("dfc-b:produces", &method("product")).valueSetter = method("product=")
|
52
|
+
end
|
53
|
+
|
32
54
|
|
33
55
|
|
34
56
|
end
|
@@ -0,0 +1,59 @@
|
|
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 "virtual_assembly/semantizer"
|
27
|
+
|
28
|
+
class DataFoodConsortium::Connector::PlannedTransformation
|
29
|
+
include VirtualAssembly::Semantizer::SemanticObject
|
30
|
+
|
31
|
+
SEMANTIC_TYPE = "dfc-b:AsPlannedTransformation".freeze
|
32
|
+
|
33
|
+
# @return [ISKOSConcept]
|
34
|
+
attr_accessor :transformationType
|
35
|
+
|
36
|
+
# @return [IPlannedConsumptionFlow]
|
37
|
+
attr_accessor :consumptionFlow
|
38
|
+
|
39
|
+
# @return [IPlannedProductionFlow]
|
40
|
+
attr_accessor :productionFlow
|
41
|
+
|
42
|
+
# @param semanticId [String]
|
43
|
+
# @param transformationType [ISKOSConcept]
|
44
|
+
# @param consumptionFlow [IPlannedConsumptionFlow]
|
45
|
+
# @param productionFlow [IPlannedProductionFlow]
|
46
|
+
def initialize(semanticId, transformationType: nil, consumptionFlow: nil, productionFlow: nil)
|
47
|
+
super(semanticId)
|
48
|
+
@transformationType = transformationType
|
49
|
+
@consumptionFlow = consumptionFlow
|
50
|
+
@productionFlow = productionFlow
|
51
|
+
self.semanticType = "dfc-b:AsPlannedTransformation"
|
52
|
+
registerSemanticProperty("dfc-b:hasTransformationType", &method("transformationType")).valueSetter = method("transformationType=")
|
53
|
+
registerSemanticProperty("dfc-b:hasIncome", &method("consumptionFlow")).valueSetter = method("consumptionFlow=")
|
54
|
+
registerSemanticProperty("dfc-b:hasOutcome", &method("productionFlow")).valueSetter = method("productionFlow=")
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
end
|
@@ -25,8 +25,9 @@
|
|
25
25
|
require "virtual_assembly/semantizer"
|
26
26
|
|
27
27
|
class DataFoodConsortium::Connector::Price
|
28
|
+
include VirtualAssembly::Semantizer::SemanticObject
|
28
29
|
|
29
|
-
|
30
|
+
SEMANTIC_TYPE = "dfc-b:Price".freeze
|
30
31
|
|
31
32
|
# @return [Real]
|
32
33
|
attr_accessor :value
|
@@ -46,9 +47,9 @@ class DataFoodConsortium::Connector::Price
|
|
46
47
|
@vatRate = vatRate
|
47
48
|
@unit = unit
|
48
49
|
self.semanticType = "dfc-b:Price"
|
49
|
-
registerSemanticProperty("dfc-b:value")
|
50
|
-
registerSemanticProperty("dfc-b:VATrate")
|
51
|
-
registerSemanticProperty("dfc-b:hasUnit")
|
50
|
+
registerSemanticProperty("dfc-b:value", &method("value")).valueSetter = method("value=")
|
51
|
+
registerSemanticProperty("dfc-b:VATrate", &method("vatRate")).valueSetter = method("vatRate=")
|
52
|
+
registerSemanticProperty("dfc-b:hasUnit", &method("unit")).valueSetter = method("unit=")
|
52
53
|
end
|
53
54
|
|
54
55
|
|
@@ -25,8 +25,9 @@
|
|
25
25
|
require "virtual_assembly/semantizer"
|
26
26
|
|
27
27
|
class DataFoodConsortium::Connector::QuantitativeValue
|
28
|
+
include VirtualAssembly::Semantizer::SemanticObject
|
28
29
|
|
29
|
-
|
30
|
+
SEMANTIC_TYPE = "dfc-b:QuantitativeValue".freeze
|
30
31
|
|
31
32
|
# @return [ISKOSConcept]
|
32
33
|
attr_accessor :unit
|
@@ -41,8 +42,8 @@ class DataFoodConsortium::Connector::QuantitativeValue
|
|
41
42
|
@unit = unit
|
42
43
|
@value = value
|
43
44
|
self.semanticType = "dfc-b:QuantitativeValue"
|
44
|
-
registerSemanticProperty("dfc-b:hasUnit")
|
45
|
-
registerSemanticProperty("dfc-b:value")
|
45
|
+
registerSemanticProperty("dfc-b:hasUnit", &method("unit")).valueSetter = method("unit=")
|
46
|
+
registerSemanticProperty("dfc-b:value", &method("value")).valueSetter = method("value=")
|
46
47
|
end
|
47
48
|
|
48
49
|
|
@@ -25,8 +25,9 @@
|
|
25
25
|
require "virtual_assembly/semantizer"
|
26
26
|
|
27
27
|
class DataFoodConsortium::Connector::Quantity
|
28
|
+
include VirtualAssembly::Semantizer::SemanticObject
|
28
29
|
|
29
|
-
|
30
|
+
SEMANTIC_TYPE = "dfc-b:Quantity".freeze
|
30
31
|
|
31
32
|
# @return [ISKOSConcept]
|
32
33
|
attr_accessor :unit
|
@@ -41,8 +42,8 @@ class DataFoodConsortium::Connector::Quantity
|
|
41
42
|
@unit = unit
|
42
43
|
@value = value
|
43
44
|
self.semanticType = "dfc-b:Quantity"
|
44
|
-
registerSemanticProperty("dfc-b:hasUnit")
|
45
|
-
registerSemanticProperty("dfc-b:value")
|
45
|
+
registerSemanticProperty("dfc-b:hasUnit", &method("unit")).valueSetter = method("unit=")
|
46
|
+
registerSemanticProperty("dfc-b:value", &method("value")).valueSetter = method("value=")
|
46
47
|
end
|
47
48
|
|
48
49
|
|
@@ -25,8 +25,9 @@
|
|
25
25
|
require "virtual_assembly/semantizer"
|
26
26
|
|
27
27
|
class DataFoodConsortium::Connector::SaleSession
|
28
|
+
include VirtualAssembly::Semantizer::SemanticObject
|
28
29
|
|
29
|
-
|
30
|
+
SEMANTIC_TYPE = "dfc-b:SaleSession".freeze
|
30
31
|
|
31
32
|
# @return [String]
|
32
33
|
attr_accessor :beginDate
|
@@ -52,10 +53,10 @@ class DataFoodConsortium::Connector::SaleSession
|
|
52
53
|
@quantity = quantity
|
53
54
|
@offers = offers
|
54
55
|
self.semanticType = "dfc-b:SaleSession"
|
55
|
-
registerSemanticProperty("dfc-b:beginDate")
|
56
|
-
registerSemanticProperty("dfc-b:endDate")
|
57
|
-
registerSemanticProperty("dfc-b:quantity")
|
58
|
-
registerSemanticProperty("dfc-b:lists")
|
56
|
+
registerSemanticProperty("dfc-b:beginDate", &method("beginDate")).valueSetter = method("beginDate=")
|
57
|
+
registerSemanticProperty("dfc-b:endDate", &method("endDate")).valueSetter = method("endDate=")
|
58
|
+
registerSemanticProperty("dfc-b:quantity", &method("quantity")).valueSetter = method("quantity=")
|
59
|
+
registerSemanticProperty("dfc-b:lists", &method("offers")).valueSetter = method("offers=")
|
59
60
|
end
|
60
61
|
|
61
62
|
|
@@ -24,10 +24,12 @@
|
|
24
24
|
|
25
25
|
|
26
26
|
require "virtual_assembly/semantizer"
|
27
|
-
|
27
|
+
require 'datafoodconsortium/connector/skos_helper'
|
28
28
|
class DataFoodConsortium::Connector::SKOSConcept
|
29
|
+
include VirtualAssembly::Semantizer::SemanticObject
|
30
|
+
include DataFoodConsortium::Connector::SKOSHelper
|
29
31
|
|
30
|
-
|
32
|
+
SEMANTIC_TYPE = "skos:Concept".freeze
|
31
33
|
|
32
34
|
# @return [ISKOSConcept]
|
33
35
|
attr_accessor :broaders
|
@@ -51,12 +53,13 @@ class DataFoodConsortium::Connector::SKOSConcept
|
|
51
53
|
@broaders = broaders
|
52
54
|
@schemes = schemes
|
53
55
|
@narrowers = narrowers
|
54
|
-
|
56
|
+
# Sort locale alphabetically
|
57
|
+
@prefLabels = prefLabels.sort.to_h
|
55
58
|
self.semanticType = "skos:Concept"
|
56
|
-
registerSemanticProperty("skos:broader")
|
57
|
-
registerSemanticProperty("skos:inScheme")
|
58
|
-
registerSemanticProperty("skos:narrower")
|
59
|
-
registerSemanticProperty("skos:prefLabel")
|
59
|
+
registerSemanticProperty("skos:broader", &method("broaders")).valueSetter = method("broaders=")
|
60
|
+
registerSemanticProperty("skos:inScheme", &method("schemes")).valueSetter = method("schemes=")
|
61
|
+
registerSemanticProperty("skos:narrower", &method("narrowers")).valueSetter = method("narrowers=")
|
62
|
+
registerSemanticProperty("skos:prefLabel", &method("prefLabels")).valueSetter = method("prefLabels=")
|
60
63
|
end
|
61
64
|
|
62
65
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DataFoodConsortium::Connector::SKOSHelper
|
4
|
+
def addAttribute(name, value)
|
5
|
+
self.instance_variable_set("@#{name}", value)
|
6
|
+
self.define_singleton_method(name) do
|
7
|
+
instance_variable_get("@#{name}")
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def hasAttribute(name)
|
12
|
+
self.methods.include?(:"#{name}")
|
13
|
+
end
|
14
|
+
end
|