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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 10cef79dc3231070626e77a12f301c6c1d931b3e9aa00455355001622f163d79
4
- data.tar.gz: d3ace7b1a70fa76a2770758dd70604a2581b90db81599927adddb783f8b3cec8
3
+ metadata.gz: b7948a960df0e1c5980954d67ab8b386029789fe867d06bcef4b1ff8944bacec
4
+ data.tar.gz: 8ad3b6dd4c57b621e4a712424b8fcfa7a8b1c0efec75cde535554617ad72e6d6
5
5
  SHA512:
6
- metadata.gz: 1a43218d24441bd3f9983b2998ae7ebd5e9745723df8e991ee6d087b0ef0d2c8213e99e3ef5c054e34acb761f8e7e2c429a4f9943ccfef3f74e1be5082881577
7
- data.tar.gz: 1920c7915626aea13bcd63119ad35476b5d83c1afccebe9c05b31e0475598fe846efacfddb38632d7467e52833083c11baca289377f235a67e3b0bf3356d12d0
6
+ metadata.gz: 45c695953704de93af40ed04d87e73abc0084d93cce29c28fca0925ec5d61d69b0db467370ad6a7b4e5ae6c93897b16a97d67b6ba8f82940241d9edda285f473
7
+ data.tar.gz: 125396ea6bbc7ed9f9313f14e95f6a8568896c0e7f219a268a3f5419e24a8bae292f470fc7f6abb58b977c5129e0953b06398c7eea657bcd5fe0faa137bdc0a3
@@ -24,8 +24,9 @@
24
24
  require "virtual_assembly/semantizer"
25
25
 
26
26
  class DataFoodConsortium::Connector::Address
27
+ include VirtualAssembly::Semantizer::SemanticObject
27
28
 
28
- include VirtualAssembly::Semantizer::SemanticObject
29
+ SEMANTIC_TYPE = "dfc-b:Address".freeze
29
30
 
30
31
  # @return [String]
31
32
  attr_accessor :street
@@ -50,11 +51,11 @@ class DataFoodConsortium::Connector::Address
50
51
  @postalCode = postalCode
51
52
  @city = city
52
53
  @country = country
53
- self.semanticType = "https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#Address"
54
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#hasStreet") { self.street }
55
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#hasPostalCode") { self.postalCode }
56
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#hasCity") { self.city }
57
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#hasCountry") { self.country }
54
+ self.semanticType = "dfc-b:Address"
55
+ registerSemanticProperty("dfc-b:hasStreet", &method("street")).valueSetter = method("street=")
56
+ registerSemanticProperty("dfc-b:hasPostalCode", &method("postalCode")).valueSetter = method("postalCode=")
57
+ registerSemanticProperty("dfc-b:hasCity", &method("city")).valueSetter = method("city=")
58
+ registerSemanticProperty("dfc-b:hasCountry", &method("country")).valueSetter = method("country=")
58
59
  end
59
60
 
60
61
 
@@ -22,50 +22,49 @@
22
22
 
23
23
 
24
24
 
25
-
26
25
  require "virtual_assembly/semantizer"
27
26
 
28
27
  class DataFoodConsortium::Connector::Agent
28
+ include VirtualAssembly::Semantizer::SemanticObject
29
29
 
30
- include VirtualAssembly::Semantizer::SemanticObject
31
-
32
- # @return [Contactable]
33
- attr_accessor :contacts
30
+ SEMANTIC_TYPE = "dfc-b:Agent".freeze
34
31
 
35
- # @return [Localizable]
32
+ # @return [IAddress]
36
33
  attr_accessor :localizations
37
34
 
35
+ # @return [IPhoneNumber]
36
+ attr_accessor :phoneNumbers
37
+
38
+ # @return [String]
39
+ attr_accessor :emails
40
+
41
+ # @return [String]
42
+ attr_accessor :websites
43
+
44
+ # @return [ISocialMedia]
45
+ attr_accessor :socialMedias
46
+
38
47
  # @param semanticId [String]
39
- # @param contacts [Contactable]
40
- # @param localizations [Localizable]
41
- def initialize(semanticId, contacts: [], localizations: [])
48
+ # @param localizations [IAddress]
49
+ # @param phoneNumbers [IPhoneNumber]
50
+ # @param emails [String]
51
+ # @param websites [String]
52
+ # @param socialMedias [ISocialMedia]
53
+ def initialize(semanticId, localizations: [], phoneNumbers: [], emails: [], websites: [], socialMedias: [])
42
54
  super(semanticId)
43
- @contacts = contacts
44
55
  @localizations = localizations
45
- self.semanticType = "https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#Agent"
46
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#hasAddress") { self.localizations }
56
+ @phoneNumbers = phoneNumbers
57
+ @emails = emails
58
+ @websites = websites
59
+ @socialMedias = socialMedias
60
+ self.semanticType = "dfc-b:Agent"
61
+ registerSemanticProperty("dfc-b:hasAddress", &method("localizations")).valueSetter = method("localizations=")
62
+ registerSemanticProperty("dfc-b:hasPhoneNumber", &method("phoneNumbers")).valueSetter = method("phoneNumbers=")
63
+ registerSemanticProperty("dfc-b:email", &method("emails")).valueSetter = method("emails=")
64
+ registerSemanticProperty("dfc-b:websitePage", &method("websites")).valueSetter = method("websites=")
65
+ registerSemanticProperty("dfc-b:hasSocialMedia", &method("socialMedias")).valueSetter = method("socialMedias=")
47
66
  end
48
67
 
49
68
 
50
-
51
- def addContact(contact)
52
- self.contacts.push(contact)
53
- end
54
-
55
-
56
- def addLocalization(localization)
57
- self.localizations.push(localization)
58
- end
59
-
60
-
61
- def removeContact(contact)
62
- raise "Not yet implemented."
63
- end
64
-
65
-
66
- def removeLocalization(localization)
67
- raise "Not yet implemented."
68
- end
69
-
70
69
 
71
70
  end
@@ -20,7 +20,6 @@
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"
25
24
 
26
25
 
@@ -28,19 +27,19 @@ require "virtual_assembly/semantizer"
28
27
 
29
28
  class DataFoodConsortium::Connector::AllergenCharacteristic < DataFoodConsortium::Connector::Characteristic
30
29
 
31
-
30
+ SEMANTIC_TYPE = "dfc-b:AllergenCharacteristic".freeze
32
31
 
33
- # @return [IAllergenDimension]
32
+ # @return [ISKOSConcept]
34
33
  attr_accessor :allergenDimension
35
34
 
36
- # @param allergenDimension [IAllergenDimension]
37
- # @param unit [IUnit]
35
+ # @param allergenDimension [ISKOSConcept]
36
+ # @param unit [ISKOSConcept]
38
37
  # @param value [Real]
39
38
  def initialize(allergenDimension: nil, unit: nil, value: 0.0)
40
39
  super(unit: unit, value: value)
41
40
  @allergenDimension = allergenDimension
42
- self.semanticType = "https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#AllergenCharacteristic"
43
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#hasAllergenDimension") { self.allergenDimension }
41
+ self.semanticType = "dfc-b:AllergenCharacteristic"
42
+ registerSemanticProperty("dfc-b:hasAllergenDimension", &method("allergenDimension")).valueSetter = method("allergenDimension=")
44
43
  end
45
44
 
46
45
 
@@ -20,15 +20,35 @@
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"
23
+
24
+
25
+
24
26
 
25
27
  require "virtual_assembly/semantizer"
26
28
 
27
- class DataFoodConsortium::Connector::CharacteristicDimension < DataFoodConsortium::Connector::SKOSConcept
29
+ class DataFoodConsortium::Connector::Catalog
30
+ include VirtualAssembly::Semantizer::SemanticObject
28
31
 
29
-
32
+ SEMANTIC_TYPE = "dfc-b:Catalog".freeze
33
+
34
+ # @return [ICatalogItem]
35
+ attr_accessor :items
30
36
 
37
+ # @return [IEnterprise]
38
+ attr_accessor :maintainers
31
39
 
40
+ # @param semanticId [String]
41
+ # @param items [ICatalogItem]
42
+ # @param maintainers [IEnterprise]
43
+ def initialize(semanticId, items: [], maintainers: [])
44
+ super(semanticId)
45
+ @items = items
46
+ @maintainers = maintainers
47
+ self.semanticType = "dfc-b:Catalog"
48
+ registerSemanticProperty("dfc-b:lists", &method("items")).valueSetter = method("items=")
49
+ registerSemanticProperty("dfc-b:maintainedBy", &method("maintainers")).valueSetter = method("maintainers=")
50
+ end
51
+
32
52
 
33
53
 
34
54
  end
@@ -23,11 +23,13 @@
23
23
 
24
24
 
25
25
 
26
+
26
27
  require "virtual_assembly/semantizer"
27
28
 
28
29
  class DataFoodConsortium::Connector::CatalogItem
30
+ include VirtualAssembly::Semantizer::SemanticObject
29
31
 
30
- include VirtualAssembly::Semantizer::SemanticObject
32
+ SEMANTIC_TYPE = "dfc-b:CatalogItem".freeze
31
33
 
32
34
  # @return [IDefinedProduct]
33
35
  attr_accessor :product
@@ -41,28 +43,30 @@ class DataFoodConsortium::Connector::CatalogItem
41
43
  # @return [IOffer]
42
44
  attr_accessor :offers
43
45
 
46
+ # @return [ICatalog]
47
+ attr_accessor :catalogs
48
+
44
49
  # @param semanticId [String]
45
50
  # @param product [IDefinedProduct]
46
51
  # @param sku [String]
47
52
  # @param stockLimitation [Real]
48
53
  # @param offers [IOffer]
49
- def initialize(semanticId, product: nil, sku: "", stockLimitation: 0.0, offers: [])
54
+ # @param catalogs [ICatalog]
55
+ def initialize(semanticId, product: nil, sku: "", stockLimitation: 0.0, offers: [], catalogs: [])
50
56
  super(semanticId)
51
57
  @product = product
52
58
  @sku = sku
53
59
  @stockLimitation = stockLimitation
54
60
  @offers = offers
55
- self.semanticType = "https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#CatalogItem"
56
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#references") { self.product }
57
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#sku") { self.sku }
58
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#stockLimitation") { self.stockLimitation }
59
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#offeredThrough") { self.offers }
61
+ @catalogs = catalogs
62
+ self.semanticType = "dfc-b:CatalogItem"
63
+ registerSemanticProperty("dfc-b:references", &method("product")).valueSetter = method("product=")
64
+ registerSemanticProperty("dfc-b:sku", &method("sku")).valueSetter = method("sku=")
65
+ registerSemanticProperty("dfc-b:stockLimitation", &method("stockLimitation")).valueSetter = method("stockLimitation=")
66
+ registerSemanticProperty("dfc-b:offeredThrough", &method("offers")).valueSetter = method("offers=")
67
+ registerSemanticProperty("dfc-b:listedIn", &method("catalogs")).valueSetter = method("catalogs=")
60
68
  end
61
69
 
62
70
 
63
-
64
-
65
-
66
-
67
71
 
68
72
  end
@@ -23,15 +23,12 @@
23
23
 
24
24
 
25
25
  require "datafoodconsortium/connector/quantitative_value"
26
-
27
26
  require "virtual_assembly/semantizer"
28
27
 
29
28
  class DataFoodConsortium::Connector::Characteristic < DataFoodConsortium::Connector::QuantitativeValue
30
29
 
31
-
32
-
33
30
 
34
- # @param unit [IUnit]
31
+ # @param unit [ISKOSConcept]
35
32
  # @param value [Real]
36
33
  def initialize(unit: nil, value: 0.0)
37
34
  super(unit: unit, value: value)
@@ -21,6 +21,8 @@
21
21
  # SOFTWARE.
22
22
 
23
23
  require 'singleton'
24
+ require 'datafoodconsortium/connector/context'
25
+ require 'datafoodconsortium/connector/importer'
24
26
  require 'datafoodconsortium/connector/json_ld_serializer'
25
27
 
26
28
  class DataFoodConsortium::Connector::Connector
@@ -37,6 +39,10 @@ class DataFoodConsortium::Connector::Connector
37
39
  return @exporter.process(subject, *subjects)
38
40
  end
39
41
 
42
+ def import(json_string_or_io)
43
+ DataFoodConsortium::Connector::Importer.new.import(json_string_or_io)
44
+ end
45
+
40
46
  def loadFacets(data)
41
47
  @FACETS = loadThesaurus(data)
42
48
  end
@@ -57,14 +63,7 @@ class DataFoodConsortium::Connector::Connector
57
63
  # used to prefix properties
58
64
  # so the DFC's context can be used.
59
65
  # See https://github.com/datafoodconsortium/connector-ruby/issues/11.
60
- inputContext = {
61
- "dfc-b" => "https://github.com/datafoodconsortium/ontology/releases/latest/download/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" => "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/measures.rdf#",
65
- "dfc-pt" => "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/productTypes.rdf#",
66
- "dfc-f" => "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/facets.rdf#"
67
- }
66
+ inputContext = DataFoodConsortium::Connector::Context.inputContext
68
67
 
69
68
  @context = "https://www.datafoodconsortium.org"
70
69
 
@@ -77,7 +76,9 @@ class DataFoodConsortium::Connector::Connector
77
76
  end
78
77
 
79
78
  def loadThesaurus(data)
80
- return @parser.parse(data[0]["@graph"])
79
+ # The root element may be an array or the ontology.
80
+ data = data[0] if data.is_a?(Array)
81
+ @parser.parse(data["@graph"])
81
82
  end
82
83
 
83
84
  end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json/ld'
4
+
5
+ # Preload the DFC context.
6
+ #
7
+ # Similar to: https://github.com/ruby-rdf/json-ld-preloaded/
8
+ module DataFoodConsortium
9
+ module Connector
10
+ class Context < JSON::LD::Context
11
+ VERSION_1_8 = JSON.parse <<~JSON
12
+ {
13
+ "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
14
+ "skos" : "http://www.w3.org/2004/02/skos/core#",
15
+ "dfc": "https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_FullModel.owl#",
16
+ "dc": "http://purl.org/dc/elements/1.1/#",
17
+ "dfc-b": "https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#",
18
+ "dfc-p": "https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_ProductGlossary.owl#",
19
+ "dfc-t": "https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_TechnicalOntology.owl#",
20
+ "dfc-m": "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/measures.rdf#",
21
+ "dfc-pt": "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/productTypes.rdf#",
22
+ "dfc-f": "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/facets.rdf#",
23
+ "ontosec": "http://www.semanticweb.org/ontologies/2008/11/OntologySecurity.owl#",
24
+ "dfc-p:hasUnit":{ "@type":"@id" },
25
+ "dfc-b:hasUnit":{ "@type":"@id" },
26
+ "dfc-b:hasQuantity":{ "@type":"@id" },
27
+ "dfc-p:hasType":{ "@type":"@id" },
28
+ "dfc-b:hasType":{ "@type":"@id" },
29
+ "dfc-b:references":{ "@type":"@id" },
30
+ "dfc-b:referencedBy":{ "@type":"@id" },
31
+ "dfc-b:offeres":{ "@type":"@id" },
32
+ "dfc-b:supplies":{ "@type":"@id" },
33
+ "dfc-b:defines":{ "@type":"@id" },
34
+ "dfc-b:affiliates":{ "@type":"@id" },
35
+ "dfc-b:hasCertification":{ "@type":"@id" },
36
+ "dfc-b:manages":{ "@type":"@id" },
37
+ "dfc-b:offeredThrough":{ "@type":"@id" },
38
+ "dfc-b:hasBrand":{ "@type":"@id" },
39
+ "dfc-b:hasGeographicalOrigin":{ "@type":"@id" },
40
+ "dfc-b:hasClaim":{ "@type":"@id" },
41
+ "dfc-b:hasAllergenDimension":{ "@type":"@id" },
42
+ "dfc-b:hasNutrientDimension":{ "@type":"@id" },
43
+ "dfc-b:hasPhysicalDimension":{ "@type":"@id" },
44
+ "dfc:owner":{ "@type":"@id" },
45
+ "dfc-t:hostedBy":{ "@type":"@id" },
46
+ "dfc-t:hasPivot":{ "@type":"@id" },
47
+ "dfc-t:represent":{ "@type":"@id" }
48
+ }
49
+ JSON
50
+
51
+ add_preloaded("http://www.datafoodconsortium.org/") { parse(VERSION_1_8) }
52
+
53
+ # This is the actual file the DFC website refers to in a link header.
54
+ alias_preloaded(
55
+ "https://www.datafoodconsortium.org/wp-content/plugins/wordpress-context-jsonld/context.jsonld",
56
+ "http://www.datafoodconsortium.org/"
57
+ )
58
+
59
+ # This is the old URL that's not online anymore.
60
+ # Keep it for compatiblity with all versions before 1.8.
61
+ alias_preloaded(
62
+ "http://static.datafoodconsortium.org/ontologies/context.json",
63
+ "http://www.datafoodconsortium.org/"
64
+ )
65
+
66
+ # The hash serializer expects only string values in the context.
67
+ def self.inputContext
68
+ @inputContext = VERSION_1_8.select { |key, value| value.is_a? String }
69
+ end
70
+ end
71
+ end
72
+ end
@@ -24,8 +24,9 @@
24
24
  require "virtual_assembly/semantizer"
25
25
 
26
26
  class DataFoodConsortium::Connector::CustomerCategory
27
+ include VirtualAssembly::Semantizer::SemanticObject
27
28
 
28
- include VirtualAssembly::Semantizer::SemanticObject
29
+ SEMANTIC_TYPE = "dfc-b:CustomerCategory".freeze
29
30
 
30
31
  # @return [String]
31
32
  attr_accessor :description
@@ -35,8 +36,8 @@ class DataFoodConsortium::Connector::CustomerCategory
35
36
  def initialize(semanticId, description: "")
36
37
  super(semanticId)
37
38
  @description = description
38
- self.semanticType = "https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#CustomerCategory"
39
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#description") { self.description }
39
+ self.semanticType = "dfc-b:CustomerCategory"
40
+ registerSemanticProperty("dfc-b:description", &method("description")).valueSetter = method("description=")
40
41
  end
41
42
 
42
43
 
@@ -27,16 +27,12 @@
27
27
 
28
28
 
29
29
 
30
-
31
-
32
-
33
-
34
-
35
30
  require "virtual_assembly/semantizer"
36
31
 
37
32
  class DataFoodConsortium::Connector::DefinedProduct
33
+ include VirtualAssembly::Semantizer::SemanticObject
38
34
 
39
- include VirtualAssembly::Semantizer::SemanticObject
35
+ SEMANTIC_TYPE = "dfc-b:DefinedProduct".freeze
40
36
 
41
37
  # @return [String]
42
38
  attr_accessor :name
@@ -44,10 +40,10 @@ class DataFoodConsortium::Connector::DefinedProduct
44
40
  # @return [String]
45
41
  attr_accessor :description
46
42
 
47
- # @return [IProductType]
43
+ # @return [ISKOSConcept]
48
44
  attr_accessor :productType
49
45
 
50
- # @return [Quantifiable]
46
+ # @return [IQuantity]
51
47
  attr_accessor :quantity
52
48
 
53
49
  # @return [Real]
@@ -56,7 +52,7 @@ class DataFoodConsortium::Connector::DefinedProduct
56
52
  # @return [String]
57
53
  attr_accessor :lifetime
58
54
 
59
- # @return [Claimable]
55
+ # @return [ISKOSConcept]
60
56
  attr_accessor :claims
61
57
 
62
58
  # @return [String]
@@ -71,38 +67,38 @@ class DataFoodConsortium::Connector::DefinedProduct
71
67
  # @return [IPhysicalCharacteristic]
72
68
  attr_accessor :physicalCharacteristics
73
69
 
74
- # @return [IGeographicalOrigin]
70
+ # @return [ISKOSConcept]
75
71
  attr_accessor :geographicalOrigin
76
72
 
77
73
  # @return [ICatalogItem]
78
74
  attr_accessor :catalogItems
79
75
 
80
- # @return [ICertification]
76
+ # @return [ISKOSConcept]
81
77
  attr_accessor :certifications
82
78
 
83
- # @return [INatureOrigin]
79
+ # @return [ISKOSConcept]
84
80
  attr_accessor :natureOrigin
85
81
 
86
- # @return [IPartOrigin]
82
+ # @return [ISKOSConcept]
87
83
  attr_accessor :partOrigin
88
84
 
89
85
  # @param semanticId [String]
90
86
  # @param name [String]
91
87
  # @param description [String]
92
- # @param productType [IProductType]
93
- # @param quantity [Quantifiable]
88
+ # @param productType [ISKOSConcept]
89
+ # @param quantity [IQuantity]
94
90
  # @param alcoholPercentage [Real]
95
91
  # @param lifetime [String]
96
- # @param claims [Claimable]
92
+ # @param claims [ISKOSConcept]
97
93
  # @param usageOrStorageConditions [String]
98
94
  # @param allergenCharacteristics [IAllergenCharacteristic]
99
95
  # @param nutrientCharacteristics [INutrientCharacteristic]
100
96
  # @param physicalCharacteristics [IPhysicalCharacteristic]
101
- # @param geographicalOrigin [IGeographicalOrigin]
97
+ # @param geographicalOrigin [ISKOSConcept]
102
98
  # @param catalogItems [ICatalogItem]
103
- # @param certifications [ICertification]
104
- # @param natureOrigin [INatureOrigin]
105
- # @param partOrigin [IPartOrigin]
99
+ # @param certifications [ISKOSConcept]
100
+ # @param natureOrigin [ISKOSConcept]
101
+ # @param partOrigin [ISKOSConcept]
106
102
  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
103
  super(semanticId)
108
104
  @name = name
@@ -121,100 +117,25 @@ class DataFoodConsortium::Connector::DefinedProduct
121
117
  @certifications = certifications
122
118
  @natureOrigin = natureOrigin
123
119
  @partOrigin = partOrigin
124
- self.semanticType = "https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#DefinedProduct"
125
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#name") { self.name }
126
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#description") { self.description }
127
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#hasType") { self.productType }
128
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#hasQuantity") { self.quantity }
129
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#alcoholPercentage") { self.alcoholPercentage }
130
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#lifetime") { self.lifetime }
131
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#hasClaim") { self.claims }
132
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#usageOrStorageCondition") { self.usageOrStorageConditions }
133
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#hasAllergenCharacteristic") { self.allergenCharacteristics }
134
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#hasNutrientCharacteristic") { self.nutrientCharacteristics }
135
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#hasPhysicalCharacteristic") { self.physicalCharacteristics }
136
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#hasGeographicalOrigin") { self.geographicalOrigin }
137
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#referencedBy") { self.catalogItems }
138
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#hasCertification") { self.certifications }
139
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#hasNatureOrigin") { self.natureOrigin }
140
- registerSemanticProperty("https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#hasPartOrigin") { self.partOrigin }
120
+ self.semanticType = "dfc-b:DefinedProduct"
121
+ registerSemanticProperty("dfc-b:name", &method("name")).valueSetter = method("name=")
122
+ registerSemanticProperty("dfc-b:description", &method("description")).valueSetter = method("description=")
123
+ registerSemanticProperty("dfc-b:hasType", &method("productType")).valueSetter = method("productType=")
124
+ registerSemanticProperty("dfc-b:hasQuantity", &method("quantity")).valueSetter = method("quantity=")
125
+ registerSemanticProperty("dfc-b:alcoholPercentage", &method("alcoholPercentage")).valueSetter = method("alcoholPercentage=")
126
+ registerSemanticProperty("dfc-b:lifetime", &method("lifetime")).valueSetter = method("lifetime=")
127
+ registerSemanticProperty("dfc-b:hasClaim", &method("claims")).valueSetter = method("claims=")
128
+ registerSemanticProperty("dfc-b:usageOrStorageCondition", &method("usageOrStorageConditions")).valueSetter = method("usageOrStorageConditions=")
129
+ registerSemanticProperty("dfc-b:hasAllergenCharacteristic", &method("allergenCharacteristics")).valueSetter = method("allergenCharacteristics=")
130
+ registerSemanticProperty("dfc-b:hasNutrientCharacteristic", &method("nutrientCharacteristics")).valueSetter = method("nutrientCharacteristics=")
131
+ registerSemanticProperty("dfc-b:hasPhysicalCharacteristic", &method("physicalCharacteristics")).valueSetter = method("physicalCharacteristics=")
132
+ registerSemanticProperty("dfc-b:hasGeographicalOrigin", &method("geographicalOrigin")).valueSetter = method("geographicalOrigin=")
133
+ registerSemanticProperty("dfc-b:referencedBy", &method("catalogItems")).valueSetter = method("catalogItems=")
134
+ registerSemanticProperty("dfc-b:hasCertification", &method("certifications")).valueSetter = method("certifications=")
135
+ registerSemanticProperty("dfc-b:hasNatureOrigin", &method("natureOrigin")).valueSetter = method("natureOrigin=")
136
+ registerSemanticProperty("dfc-b:hasPartOrigin", &method("partOrigin")).valueSetter = method("partOrigin=")
141
137
  end
142
138
 
143
139
 
144
-
145
- def addClaim(claim)
146
- self.claims.push(claim)
147
- end
148
-
149
-
150
- def removeClaim(claim)
151
- raise "Not yet implemented."
152
- end
153
-
154
-
155
- def addAllergenCharacteristic(allergenCharacteristic)
156
- self.allergenCharacteristics.push(allergenCharacteristic)
157
- end
158
-
159
-
160
- def addNutrientCharacteristic(nutrientCharacteristic)
161
- self.nutrientCharacteristics.push(nutrientCharacteristic)
162
- end
163
-
164
-
165
- def addPhysicalCharacteristic(physicalCharacteristic)
166
- self.physicalCharacteristics.push(physicalCharacteristic)
167
- end
168
-
169
-
170
- def addNatureOrigin(natureOrigin)
171
- self.natureOrigin.push(natureOrigin)
172
- end
173
-
174
-
175
- def addPartOrigin(partOrigin)
176
- self.partOrigin.push(partOrigin)
177
- end
178
-
179
-
180
- def removeAllergenCharacteristic(allergenCharacteristic)
181
- raise "Not yet implemented."
182
- end
183
-
184
-
185
- def removeNutrientCharacteristic(nutrientCharacteristic)
186
- raise "Not yet implemented."
187
- end
188
-
189
-
190
- def removePhysicalCharacteristic(physicalCharacteristic)
191
- raise "Not yet implemented."
192
- end
193
-
194
-
195
- def removeNatureOrigin(natureOrigin)
196
- raise "Not yet implemented."
197
- end
198
-
199
-
200
- def removePartOrigin(partOrigin)
201
- raise "Not yet implemented."
202
- end
203
-
204
-
205
- def addCatalogItem(catalogItem)
206
- self.catalogItems.push(catalogItem)
207
- end
208
-
209
-
210
- def addCertification(certification)
211
- self.certifications.push(certification)
212
- end
213
-
214
-
215
- def removeCertification(certification)
216
- raise "Not yet implemented."
217
- end
218
-
219
140
 
220
141
  end