datafoodconsortium-connector 1.0.0.pre.alpha.8 → 1.0.0.pre.alpha.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/lib/datafoodconsortium/connector/address.rb +7 -6
  3. data/lib/datafoodconsortium/connector/agent.rb +31 -32
  4. data/lib/datafoodconsortium/connector/allergen_characteristic.rb +6 -7
  5. data/lib/datafoodconsortium/connector/{characteristic_dimension.rb → catalog.rb} +23 -3
  6. data/lib/datafoodconsortium/connector/catalog_item.rb +15 -11
  7. data/lib/datafoodconsortium/connector/characteristic.rb +1 -4
  8. data/lib/datafoodconsortium/connector/connector.rb +10 -9
  9. data/lib/datafoodconsortium/connector/context.rb +72 -0
  10. data/lib/datafoodconsortium/connector/customer_category.rb +4 -3
  11. data/lib/datafoodconsortium/connector/defined_product.rb +33 -112
  12. data/lib/datafoodconsortium/connector/enterprise.rb +43 -23
  13. data/lib/datafoodconsortium/connector/importer.rb +112 -0
  14. data/lib/datafoodconsortium/connector/json_ld_serializer.rb +7 -14
  15. data/lib/datafoodconsortium/connector/nutrient_characteristic.rb +7 -8
  16. data/lib/datafoodconsortium/connector/offer.rb +8 -7
  17. data/lib/datafoodconsortium/connector/order.rb +40 -1
  18. data/lib/datafoodconsortium/connector/order_line.rb +40 -1
  19. data/lib/datafoodconsortium/connector/person.rb +16 -22
  20. data/lib/datafoodconsortium/connector/{geographical_origin.rb → phone_number.rb} +20 -3
  21. data/lib/datafoodconsortium/connector/physical_characteristic.rb +6 -7
  22. data/lib/datafoodconsortium/connector/price.rb +9 -7
  23. data/lib/datafoodconsortium/connector/quantitative_value.rb +7 -6
  24. data/lib/datafoodconsortium/connector/{allergen_dimension.rb → quantity.rb} +20 -3
  25. data/lib/datafoodconsortium/connector/sale_session.rb +64 -0
  26. data/lib/datafoodconsortium/connector/skos_concept.rb +14 -34
  27. data/lib/datafoodconsortium/connector/skos_helper.rb +14 -0
  28. data/lib/datafoodconsortium/connector/skos_parser.rb +122 -100
  29. data/lib/datafoodconsortium/connector/skos_parser_element.rb +72 -53
  30. data/lib/datafoodconsortium/connector/{certification.rb → social_media.rb} +23 -2
  31. data/lib/datafoodconsortium/connector/supplied_product.rb +21 -14
  32. data/lib/datafoodconsortium/connector/technical_product.rb +59 -0
  33. data/lib/datafoodconsortium/connector.rb +21 -18
  34. metadata +12 -40
  35. data/lib/datafoodconsortium/connector/nature_origin.rb +0 -34
  36. data/lib/datafoodconsortium/connector/part_origin.rb +0 -34
  37. data/lib/datafoodconsortium/connector/product_type.rb +0 -34
  38. data/lib/datafoodconsortium/connector/repository.rb +0 -33
  39. data/lib/datafoodconsortium/connector/unit.rb +0 -34
@@ -20,18 +20,22 @@
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
+ require "datafoodconsortium/connector/agent"
24
+
25
+
26
+
27
+
28
+
24
29
 
25
30
 
26
31
 
27
- require "datafoodconsortium/connector/agent"
28
32
 
29
33
 
30
34
  require "virtual_assembly/semantizer"
31
35
 
32
36
  class DataFoodConsortium::Connector::Enterprise < DataFoodConsortium::Connector::Agent
33
37
 
34
-
38
+ SEMANTIC_TYPE = "dfc-b:Enterprise".freeze
35
39
 
36
40
  # @return [String]
37
41
  attr_accessor :name
@@ -45,43 +49,59 @@ class DataFoodConsortium::Connector::Enterprise < DataFoodConsortium::Connector:
45
49
  # @return [ICustomerCategory]
46
50
  attr_accessor :customerCategories
47
51
 
48
- # @return [SuppliedProduct]
49
- attr_accessor :suppliedProducts
52
+ # @return [ICatalog]
53
+ attr_accessor :catalogs
50
54
 
51
55
  # @return [ICatalogItem]
52
56
  attr_accessor :catalogItems
53
57
 
58
+ # @return [ISuppliedProduct]
59
+ attr_accessor :suppliedProducts
60
+
61
+ # @return [ITechnicalProduct]
62
+ attr_accessor :technicalProducts
63
+
64
+ # @return [IPerson]
65
+ attr_accessor :mainContact
66
+
54
67
  # @param semanticId [String]
55
68
  # @param name [String]
56
69
  # @param description [String]
57
70
  # @param vatNumber [String]
58
71
  # @param customerCategories [ICustomerCategory]
59
- # @param suppliedProducts [SuppliedProduct]
72
+ # @param catalogs [ICatalog]
60
73
  # @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)
74
+ # @param suppliedProducts [ISuppliedProduct]
75
+ # @param technicalProducts [ITechnicalProduct]
76
+ # @param mainContact [IPerson]
77
+ # @param localizations [IAddress]
78
+ # @param phoneNumbers [IPhoneNumber]
79
+ # @param emails [String]
80
+ # @param websites [String]
81
+ # @param socialMedias [ISocialMedia]
82
+ def initialize(semanticId, name: "", description: "", vatNumber: "", customerCategories: [], catalogs: [], catalogItems: [], suppliedProducts: [], technicalProducts: [], mainContact: nil, localizations: [], phoneNumbers: [], emails: [], websites: [], socialMedias: [])
83
+ super(semanticId, localizations: localizations, phoneNumbers: phoneNumbers, emails: emails, websites: websites, socialMedias: socialMedias)
65
84
  @name = name
66
85
  @description = description
67
86
  @vatNumber = vatNumber
68
87
  @customerCategories = customerCategories
69
- @suppliedProducts = suppliedProducts
88
+ @catalogs = catalogs
70
89
  @catalogItems = catalogItems
71
- self.semanticType = "https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#Enterprise"
72
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#hasName") { self.name }
73
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#hasDescription") { self.description }
74
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#VATnumber") { self.vatNumber }
75
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#defines") { self.customerCategories }
76
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#supplies") { self.suppliedProducts }
77
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#manages") { self.catalogItems }
90
+ @suppliedProducts = suppliedProducts
91
+ @technicalProducts = technicalProducts
92
+ @mainContact = mainContact
93
+ self.semanticType = "dfc-b:Enterprise"
94
+ registerSemanticProperty("dfc-b:name", &method("name")).valueSetter = method("name=")
95
+ registerSemanticProperty("dfc-b:hasDescription", &method("description")).valueSetter = method("description=")
96
+ registerSemanticProperty("dfc-b:VATnumber", &method("vatNumber")).valueSetter = method("vatNumber=")
97
+ registerSemanticProperty("dfc-b:defines", &method("customerCategories")).valueSetter = method("customerCategories=")
98
+ registerSemanticProperty("dfc-b:maintains", &method("catalogs")).valueSetter = method("catalogs=")
99
+ registerSemanticProperty("dfc-b:manages", &method("catalogItems")).valueSetter = method("catalogItems=")
100
+ registerSemanticProperty("dfc-b:supplies", &method("suppliedProducts")).valueSetter = method("suppliedProducts=")
101
+ registerSemanticProperty("dfc-b:proposes", &method("technicalProducts")).valueSetter = method("technicalProducts=")
102
+ registerSemanticProperty("dfc-b:hasMainContact", &method("mainContact")).valueSetter = method("mainContact=")
78
103
  end
79
104
 
80
105
 
81
-
82
- def addCustomerCategory(customerCategory)
83
- self.customerCategories.push(customerCategory)
84
- end
85
-
86
106
 
87
107
  end
@@ -0,0 +1,112 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "skos_parser"
4
+
5
+ module DataFoodConsortium
6
+ module Connector
7
+ class Importer
8
+ def self.type_map
9
+ unless @type_map
10
+ @type_map = {}
11
+ DataFoodConsortium::Connector.semantic_types.each do |type|
12
+ register_type(type)
13
+ end
14
+ end
15
+
16
+ @type_map
17
+ end
18
+
19
+ def self.register_type(clazz)
20
+ type_map[clazz::SEMANTIC_TYPE] = clazz
21
+ end
22
+
23
+ def self.prefixed_name(uri)
24
+ RDF::URI.new(uri).pname(prefixes: Context::VERSION_1_8)
25
+ end
26
+
27
+ def import(json_string_or_io)
28
+ @subjects = {}
29
+
30
+ graph = parse_rdf(json_string_or_io)
31
+ build_subjects(graph)
32
+ apply_statements(graph)
33
+
34
+ if @subjects.size > 1
35
+ @subjects.values
36
+ else
37
+ @subjects.values.first
38
+ end
39
+ end
40
+
41
+ private
42
+
43
+ # The `io` parameter can be a String or an IO instance.
44
+ def parse_rdf(io)
45
+ io = StringIO.new(io) if io.is_a?(String)
46
+ RDF::Graph.new << JSON::LD::API.toRdf(io)
47
+ end
48
+
49
+ def build_subjects(graph)
50
+ graph.query({ predicate: RDF.type }).each do |statement|
51
+ @subjects[statement.subject] = build_subject(statement)
52
+ end
53
+ end
54
+
55
+ def build_subject(type_statement)
56
+ # Not all subjects have an id, some are anonymous.
57
+ id = if type_statement.subject.respond_to?(:value)
58
+ type_statement.subject.value
59
+ end
60
+ type = type_statement.object.value
61
+ key = self.class.prefixed_name(type)
62
+ clazz = self.class.type_map[key]
63
+
64
+ clazz.new(*[id].compact)
65
+ end
66
+
67
+ def apply_statements(statements)
68
+ statements.each do |statement|
69
+ apply_statement(statement)
70
+ end
71
+ end
72
+
73
+ def apply_statement(statement)
74
+ subject = subject_of(statement)
75
+ property_uri = statement.predicate.value
76
+ value = resolve_object(statement.object)
77
+
78
+ property_id = self.class.prefixed_name(property_uri)
79
+
80
+ return unless subject.hasSemanticProperty?(property_id)
81
+
82
+ property = subject.semanticProperty(property_id)
83
+
84
+ if property.value.is_a?(Enumerable)
85
+ property.value << value
86
+ else
87
+ property.value = value
88
+ end
89
+ end
90
+
91
+ def subject_of(statement)
92
+ @subjects[statement.subject]
93
+ end
94
+
95
+ def resolve_object(object)
96
+ @subjects[object] || skos_concept(object) || object.object
97
+ end
98
+
99
+ def skos_concept(object)
100
+ return unless object.uri?
101
+
102
+ id = object.value.sub(
103
+ "http://static.datafoodconsortium.org/data/measures.rdf#", "dfc-m:"
104
+ ).sub(
105
+ "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/measures.rdf#",
106
+ "dfc-m:"
107
+ )
108
+ SKOSParser.concepts[id]
109
+ end
110
+ end
111
+ end
112
+ end
@@ -30,27 +30,20 @@ class DataFoodConsortium::Connector::JsonLdSerializer
30
30
  @hashSerializer = VirtualAssembly::Semantizer::HashSerializer.new(inputContext)
31
31
  end
32
32
 
33
- def process(subject, *subjects)
34
- subjects.insert(0, subject)
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.each do |subject|
46
- input = { "@context" => "https://www.datafoodconsortium.org" }
47
- input.merge!(subject.serialize(@hashSerializer))
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
- return JSON.generate(jsonLd)
46
+ JSON.generate(jsonLd)
54
47
  end
55
48
 
56
- end
49
+ end
@@ -20,27 +20,26 @@
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
-
25
23
  require "datafoodconsortium/connector/characteristic"
26
24
 
25
+
27
26
  require "virtual_assembly/semantizer"
28
27
 
29
28
  class DataFoodConsortium::Connector::NutrientCharacteristic < DataFoodConsortium::Connector::Characteristic
30
29
 
31
-
30
+ SEMANTIC_TYPE = "dfc-b:NutrientCharacteristic".freeze
32
31
 
33
- # @return [INutrientDimension]
32
+ # @return [ISKOSConcept]
34
33
  attr_accessor :nutrientDimension
35
34
 
36
- # @param nutrientDimension [INutrientDimension]
37
- # @param unit [IUnit]
35
+ # @param nutrientDimension [ISKOSConcept]
36
+ # @param unit [ISKOSConcept]
38
37
  # @param value [Real]
39
38
  def initialize(nutrientDimension: nil, unit: nil, value: 0.0)
40
39
  super(unit: unit, value: value)
41
40
  @nutrientDimension = nutrientDimension
42
- self.semanticType = "https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#NutrientCharacteristic"
43
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#hasNutrientDimension") { self.nutrientDimension }
41
+ self.semanticType = "dfc-b:NutrientCharacteristic"
42
+ registerSemanticProperty("dfc-b:hasNutrientDimension", &method("nutrientDimension")).valueSetter = method("nutrientDimension=")
44
43
  end
45
44
 
46
45
 
@@ -23,11 +23,13 @@
23
23
 
24
24
 
25
25
 
26
+
26
27
  require "virtual_assembly/semantizer"
27
28
 
28
29
  class DataFoodConsortium::Connector::Offer
30
+ include VirtualAssembly::Semantizer::SemanticObject
29
31
 
30
- include VirtualAssembly::Semantizer::SemanticObject
32
+ SEMANTIC_TYPE = "dfc-b:Offer".freeze
31
33
 
32
34
  # @return [IPrice]
33
35
  attr_accessor :price
@@ -52,14 +54,13 @@ class DataFoodConsortium::Connector::Offer
52
54
  @stockLimitation = stockLimitation
53
55
  @offeredItem = offeredItem
54
56
  @offeredTo = offeredTo
55
- self.semanticType = "https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#Offer"
56
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#price") { self.price }
57
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#stockLimitation") { self.stockLimitation }
58
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#offeredItem") { self.offeredItem }
59
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#offeredTo") { self.offeredTo }
57
+ self.semanticType = "dfc-b:Offer"
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=")
60
62
  end
61
63
 
62
64
 
63
-
64
65
 
65
66
  end
@@ -21,13 +21,52 @@
21
21
  # SOFTWARE.
22
22
 
23
23
 
24
+
25
+
26
+
24
27
  require "virtual_assembly/semantizer"
25
28
 
26
29
  class DataFoodConsortium::Connector::Order
30
+ include VirtualAssembly::Semantizer::SemanticObject
27
31
 
28
-
32
+ SEMANTIC_TYPE = "dfc-b:Order".freeze
33
+
34
+ # @return [String]
35
+ attr_accessor :number
29
36
 
37
+ # @return [String]
38
+ attr_accessor :date
30
39
 
40
+ # @return [ISaleSession]
41
+ attr_accessor :saleSession
42
+
43
+ # @return [IOrderLine]
44
+ attr_accessor :lines
45
+
46
+ # @return [IAgent]
47
+ attr_accessor :client
48
+
49
+ # @param semanticId [String]
50
+ # @param number [String]
51
+ # @param date [String]
52
+ # @param saleSession [ISaleSession]
53
+ # @param lines [IOrderLine]
54
+ # @param client [IAgent]
55
+ def initialize(semanticId, number: "", date: "", saleSession: nil, lines: [], client: nil)
56
+ super(semanticId)
57
+ @number = number
58
+ @date = date
59
+ @saleSession = saleSession
60
+ @lines = lines
61
+ @client = client
62
+ self.semanticType = "dfc-b:Order"
63
+ registerSemanticProperty("dfc-b:orderNumber", &method("number")).valueSetter = method("number=")
64
+ registerSemanticProperty("dfc-b:date", &method("date")).valueSetter = method("date=")
65
+ registerSemanticProperty("dfc-b:belongsTo", &method("saleSession")).valueSetter = method("saleSession=")
66
+ registerSemanticProperty("dfc-b:hasPart", &method("lines")).valueSetter = method("lines=")
67
+ registerSemanticProperty("dfc-b:orderedBy", &method("client")).valueSetter = method("client=")
68
+ end
69
+
31
70
 
32
71
 
33
72
  end
@@ -21,13 +21,52 @@
21
21
  # SOFTWARE.
22
22
 
23
23
 
24
+
25
+
26
+
24
27
  require "virtual_assembly/semantizer"
25
28
 
26
29
  class DataFoodConsortium::Connector::OrderLine
30
+ include VirtualAssembly::Semantizer::SemanticObject
27
31
 
28
-
32
+ SEMANTIC_TYPE = "dfc-b:OrderLine".freeze
33
+
34
+ # @return [String]
35
+ attr_accessor :description
29
36
 
37
+ # @return [Real]
38
+ attr_accessor :quantity
30
39
 
40
+ # @return [IPrice]
41
+ attr_accessor :price
42
+
43
+ # @return [IOffer]
44
+ attr_accessor :offer
45
+
46
+ # @return [IOrder]
47
+ attr_accessor :order
48
+
49
+ # @param semanticId [String]
50
+ # @param description [String]
51
+ # @param quantity [Real]
52
+ # @param price [IPrice]
53
+ # @param offer [IOffer]
54
+ # @param order [IOrder]
55
+ def initialize(semanticId, description: "", quantity: 0.0, price: nil, offer: nil, order: nil)
56
+ super(semanticId)
57
+ @description = description
58
+ @quantity = quantity
59
+ @price = price
60
+ @offer = offer
61
+ @order = order
62
+ self.semanticType = "dfc-b:OrderLine"
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=")
68
+ end
69
+
31
70
 
32
71
 
33
72
  end
@@ -20,14 +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"
24
+
23
25
 
24
26
 
25
- require "datafoodconsortium/connector/agent"
26
27
  require "virtual_assembly/semantizer"
27
28
 
28
29
  class DataFoodConsortium::Connector::Person < DataFoodConsortium::Connector::Agent
29
30
 
30
-
31
+ SEMANTIC_TYPE = "dfc-b:Person".freeze
31
32
 
32
33
  # @return [String]
33
34
  attr_accessor :firstName
@@ -35,36 +36,29 @@ class DataFoodConsortium::Connector::Person < DataFoodConsortium::Connector::Age
35
36
  # @return [String]
36
37
  attr_accessor :lastName
37
38
 
38
- # @return [Onboardable]
39
+ # @return [IEnterprise]
39
40
  attr_accessor :affiliatedOrganizations
40
41
 
41
42
  # @param semanticId [String]
42
43
  # @param firstName [String]
43
44
  # @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)
45
+ # @param affiliatedOrganizations [IEnterprise]
46
+ # @param localizations [IAddress]
47
+ # @param phoneNumbers [IPhoneNumber]
48
+ # @param emails [String]
49
+ # @param websites [String]
50
+ # @param socialMedias [ISocialMedia]
51
+ def initialize(semanticId, firstName: "", lastName: "", affiliatedOrganizations: [], localizations: [], phoneNumbers: [], emails: [], websites: [], socialMedias: [])
52
+ super(semanticId, localizations: localizations, phoneNumbers: phoneNumbers, emails: emails, websites: websites, socialMedias: socialMedias)
49
53
  @firstName = firstName
50
54
  @lastName = lastName
51
55
  @affiliatedOrganizations = affiliatedOrganizations
52
- self.semanticType = "https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#Person"
53
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#firstName") { self.firstName }
54
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#familyName") { self.lastName }
55
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#affiliates") { self.affiliatedOrganizations }
56
+ self.semanticType = "dfc-b:Person"
57
+ registerSemanticProperty("dfc-b:firstName", &method("firstName")).valueSetter = method("firstName=")
58
+ registerSemanticProperty("dfc-b:familyName", &method("lastName")).valueSetter = method("lastName=")
59
+ registerSemanticProperty("dfc-b:affiliates", &method("affiliatedOrganizations")).valueSetter = method("affiliatedOrganizations=")
56
60
  end
57
61
 
58
62
 
59
-
60
- def affiliateTo(organization)
61
- self.affiliatedOrganizations.push(organization)
62
- end
63
-
64
-
65
- def leaveAffiliatedOrganization(organization)
66
- raise "Not yet implemented."
67
- end
68
-
69
63
 
70
64
  end
@@ -20,15 +20,32 @@
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/skos_concept"
24
23
 
25
24
  require "virtual_assembly/semantizer"
26
25
 
27
- class DataFoodConsortium::Connector::GeographicalOrigin < DataFoodConsortium::Connector::SKOSConcept
26
+ class DataFoodConsortium::Connector::PhoneNumber
27
+ include VirtualAssembly::Semantizer::SemanticObject
28
28
 
29
-
29
+ SEMANTIC_TYPE = "dfc-b:PhoneNumber".freeze
30
+
31
+ # @return [Integer]
32
+ attr_accessor :countryCode
30
33
 
34
+ # @return [String]
35
+ attr_accessor :phoneNumber
31
36
 
37
+ # @param semanticId [String]
38
+ # @param countryCode [Integer]
39
+ # @param phoneNumber [String]
40
+ def initialize(semanticId, countryCode: 0, phoneNumber: "")
41
+ super(semanticId)
42
+ @countryCode = countryCode
43
+ @phoneNumber = phoneNumber
44
+ self.semanticType = "dfc-b:PhoneNumber"
45
+ registerSemanticProperty("dfc-b:countryCode", &method("countryCode")).valueSetter = method("countryCode=")
46
+ registerSemanticProperty("dfc-b:phoneNumber", &method("phoneNumber")).valueSetter = method("phoneNumber=")
47
+ end
48
+
32
49
 
33
50
 
34
51
  end
@@ -23,24 +23,23 @@
23
23
  require "datafoodconsortium/connector/characteristic"
24
24
 
25
25
 
26
-
27
26
  require "virtual_assembly/semantizer"
28
27
 
29
28
  class DataFoodConsortium::Connector::PhysicalCharacteristic < DataFoodConsortium::Connector::Characteristic
30
29
 
31
-
30
+ SEMANTIC_TYPE = "dfc-b:PhysicalCharacteristic".freeze
32
31
 
33
- # @return [IPhysicalDimension]
32
+ # @return [ISKOSConcept]
34
33
  attr_accessor :physicalDimension
35
34
 
36
- # @param physicalDimension [IPhysicalDimension]
37
- # @param unit [IUnit]
35
+ # @param physicalDimension [ISKOSConcept]
36
+ # @param unit [ISKOSConcept]
38
37
  # @param value [Real]
39
38
  def initialize(physicalDimension: nil, unit: nil, value: 0.0)
40
39
  super(unit: unit, value: value)
41
40
  @physicalDimension = physicalDimension
42
- self.semanticType = "https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#PhysicalCharacteristic"
43
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#hasPhysicalDimension") { self.physicalDimension }
41
+ self.semanticType = "dfc-b:PhysicalCharacteristic"
42
+ registerSemanticProperty("dfc-b:hasPhysicalDimension", &method("physicalDimension")).valueSetter = method("physicalDimension=")
44
43
  end
45
44
 
46
45
 
@@ -21,11 +21,13 @@
21
21
  # SOFTWARE.
22
22
 
23
23
 
24
+
24
25
  require "virtual_assembly/semantizer"
25
26
 
26
27
  class DataFoodConsortium::Connector::Price
28
+ include VirtualAssembly::Semantizer::SemanticObject
27
29
 
28
- include VirtualAssembly::Semantizer::SemanticObject
30
+ SEMANTIC_TYPE = "dfc-b:Price".freeze
29
31
 
30
32
  # @return [Real]
31
33
  attr_accessor :value
@@ -33,21 +35,21 @@ class DataFoodConsortium::Connector::Price
33
35
  # @return [Real]
34
36
  attr_accessor :vatRate
35
37
 
36
- # @return [IUnit]
38
+ # @return [ISKOSConcept]
37
39
  attr_accessor :unit
38
40
 
39
41
  # @param value [Real]
40
42
  # @param vatRate [Real]
41
- # @param unit [IUnit]
43
+ # @param unit [ISKOSConcept]
42
44
  def initialize(value: 0.0, vatRate: 0.0, unit: nil)
43
45
  super()
44
46
  @value = value
45
47
  @vatRate = vatRate
46
48
  @unit = unit
47
- self.semanticType = "https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#Price"
48
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#value") { self.value }
49
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#VATrate") { self.vatRate }
50
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#hasUnit") { self.unit }
49
+ self.semanticType = "dfc-b:Price"
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=")
51
53
  end
52
54
 
53
55
 
@@ -25,24 +25,25 @@
25
25
  require "virtual_assembly/semantizer"
26
26
 
27
27
  class DataFoodConsortium::Connector::QuantitativeValue
28
+ include VirtualAssembly::Semantizer::SemanticObject
28
29
 
29
- include VirtualAssembly::Semantizer::SemanticObject
30
+ SEMANTIC_TYPE = "dfc-b:QuantitativeValue".freeze
30
31
 
31
- # @return [IUnit]
32
+ # @return [ISKOSConcept]
32
33
  attr_accessor :unit
33
34
 
34
35
  # @return [Real]
35
36
  attr_accessor :value
36
37
 
37
- # @param unit [IUnit]
38
+ # @param unit [ISKOSConcept]
38
39
  # @param value [Real]
39
40
  def initialize(unit: nil, value: 0.0)
40
41
  super()
41
42
  @unit = unit
42
43
  @value = value
43
- self.semanticType = "https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#QuantitativeValue"
44
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#hasUnit") { self.unit }
45
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#value") { self.value }
44
+ self.semanticType = "dfc-b:QuantitativeValue"
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