datafoodconsortium-connector 1.0.0.pre.alpha

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 (33) hide show
  1. checksums.yaml +7 -0
  2. data/lib/datafoodconsortium/connector/address.rb +51 -0
  3. data/lib/datafoodconsortium/connector/agent.rb +62 -0
  4. data/lib/datafoodconsortium/connector/allergen_characteristic.rb +49 -0
  5. data/lib/datafoodconsortium/connector/allergen_dimension.rb +34 -0
  6. data/lib/datafoodconsortium/connector/catalog_item.rb +62 -0
  7. data/lib/datafoodconsortium/connector/certification.rb +34 -0
  8. data/lib/datafoodconsortium/connector/characteristic.rb +47 -0
  9. data/lib/datafoodconsortium/connector/characteristic_dimension.rb +34 -0
  10. data/lib/datafoodconsortium/connector/connector.rb +73 -0
  11. data/lib/datafoodconsortium/connector/customer_category.rb +45 -0
  12. data/lib/datafoodconsortium/connector/defined_product.rb +157 -0
  13. data/lib/datafoodconsortium/connector/enterprise.rb +86 -0
  14. data/lib/datafoodconsortium/connector/geographical_origin.rb +34 -0
  15. data/lib/datafoodconsortium/connector/json_ld_serializer.rb +39 -0
  16. data/lib/datafoodconsortium/connector/nature_origin.rb +34 -0
  17. data/lib/datafoodconsortium/connector/nutrient_characteristic.rb +49 -0
  18. data/lib/datafoodconsortium/connector/offer.rb +56 -0
  19. data/lib/datafoodconsortium/connector/order.rb +33 -0
  20. data/lib/datafoodconsortium/connector/order_line.rb +33 -0
  21. data/lib/datafoodconsortium/connector/part_origin.rb +34 -0
  22. data/lib/datafoodconsortium/connector/person.rb +57 -0
  23. data/lib/datafoodconsortium/connector/physical_characteristic.rb +49 -0
  24. data/lib/datafoodconsortium/connector/product_type.rb +34 -0
  25. data/lib/datafoodconsortium/connector/quantitative_value.rb +45 -0
  26. data/lib/datafoodconsortium/connector/repository.rb +33 -0
  27. data/lib/datafoodconsortium/connector/skos_concept.rb +85 -0
  28. data/lib/datafoodconsortium/connector/skos_parser.rb +133 -0
  29. data/lib/datafoodconsortium/connector/skos_parser_element.rb +78 -0
  30. data/lib/datafoodconsortium/connector/supplied_product.rb +41 -0
  31. data/lib/datafoodconsortium/connector/unit.rb +34 -0
  32. data/lib/datafoodconsortium/connector.rb +34 -0
  33. metadata +73 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b829aeeace38ebab9bf23d8ab9bbe462f527a1665caaf6dcee360d2f4eaf22c6
4
+ data.tar.gz: e7082289210a9c96c24785c6c6f938c300662fb1fef0d5dcfe7519c9965aed3e
5
+ SHA512:
6
+ metadata.gz: c51129ea0f6b3f3e887631f9734bd70d0eaff1a790bb5012627b13c751aa9e5b2438e71cb4d62420c27804e99850414168d9b5285c99e06942e48f94ccc11b0f
7
+ data.tar.gz: b875b69efc821390eb3f4d855d602c631d6def233a8ebe6e379a5f66855085ff6865b0e96b619e2303573c8c5fb353456d423274f1acec388ffa19e5fae8783c
@@ -0,0 +1,51 @@
1
+ # MIT License
2
+ #
3
+ # Copyright (c) 2023 Maxime Lecoq <maxime@lecoqlibre.fr>
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+
24
+ require "virtual_assembly/semantizer"
25
+
26
+ class DataFoodConsortium::Connector::Address
27
+
28
+ include VirtualAssembly::Semantizer::SemanticObject
29
+
30
+ attr_accessor :street
31
+ attr_accessor :postalCode
32
+ attr_accessor :city
33
+ attr_accessor :country
34
+
35
+ def initialize(street, postalCode, city, country)
36
+ super()
37
+ self.semanticType = "http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#Address"
38
+ self.street = street
39
+ self.postalCode = postalCode
40
+ self.city = city
41
+ self.country = country
42
+
43
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#hasStreet") { self.street }
44
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#hasPostalCode") { self.postalCode }
45
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#hasCity") { self.city }
46
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#hasCountry") { self.country }
47
+ end
48
+
49
+
50
+
51
+ end
@@ -0,0 +1,62 @@
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::Agent
29
+
30
+ include VirtualAssembly::Semantizer::SemanticObject
31
+
32
+ attr_accessor :contacts
33
+ attr_accessor :localizations
34
+
35
+ def initialize()
36
+ super()
37
+ self.semanticType = "http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#Agent"
38
+
39
+ self.contacts = []
40
+ self.localizations = []
41
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#hasAddress") { self.localizations }
42
+ end
43
+
44
+
45
+ def addContact(contact)
46
+ self.contacts.push(contact)
47
+ end
48
+
49
+ def addLocalization(localization)
50
+ self.localizations.push(localization)
51
+ end
52
+
53
+ def removeContact(contact)
54
+ raise "Not implemented"
55
+ end
56
+
57
+ def removeLocalization(localization)
58
+ raise "Not implemented"
59
+ end
60
+
61
+
62
+ end
@@ -0,0 +1,49 @@
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/characteristic"
27
+ require "virtual_assembly/semantizer"
28
+
29
+ class DataFoodConsortium::Connector::AllergenCharacteristic < DataFoodConsortium::Connector::Characteristic
30
+
31
+
32
+
33
+ attr_accessor :allergenDimension
34
+
35
+ def initialize(quantityUnit, quantityValue, allergenDimension)
36
+ super(quantityUnit, quantityValue)
37
+ self.semanticType = "http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#AllergenCharacteristic"
38
+ self.allergenDimension = allergenDimension
39
+
40
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#hasAllergenDimension") { self.allergenDimension }
41
+ end
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+ end
@@ -0,0 +1,34 @@
1
+ # MIT License
2
+ #
3
+ # Copyright (c) 2023 Maxime Lecoq <maxime@lecoqlibre.fr>
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+
24
+ require "datafoodconsortium/connector/characteristic_dimension"
25
+ require "virtual_assembly/semantizer"
26
+
27
+ class DataFoodConsortium::Connector::AllergenDimension < DataFoodConsortium::Connector::CharacteristicDimension
28
+
29
+
30
+
31
+
32
+
33
+
34
+ end
@@ -0,0 +1,62 @@
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::CatalogItem
29
+
30
+ include VirtualAssembly::Semantizer::SemanticObject
31
+
32
+ attr_accessor :product
33
+ attr_accessor :sku
34
+ attr_accessor :stockLimitation
35
+ attr_accessor :offers
36
+
37
+ def initialize(product)
38
+ super()
39
+ self.semanticType = "http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#CatalogItem"
40
+ self.product = product
41
+ self.sku = nil
42
+ self.stockLimitation = nil
43
+ self.offers = []
44
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#references") { self.product }
45
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#sku") { self.sku }
46
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#stockLimitation") { self.stockLimitation }
47
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#offeredThrough") { self.offers }
48
+ end
49
+
50
+
51
+
52
+
53
+ def addOffer(offer)
54
+ self.offers.push(offer)
55
+ end
56
+
57
+ def addOffer(offer)
58
+ self.offers.push(offer)
59
+ end
60
+
61
+
62
+ end
@@ -0,0 +1,34 @@
1
+ # MIT License
2
+ #
3
+ # Copyright (c) 2023 Maxime Lecoq <maxime@lecoqlibre.fr>
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+
24
+ require "datafoodconsortium/connector/skos_concept"
25
+ require "virtual_assembly/semantizer"
26
+
27
+ class DataFoodConsortium::Connector::Certification < DataFoodConsortium::Connector::SKOSConcept
28
+
29
+
30
+
31
+
32
+
33
+
34
+ end
@@ -0,0 +1,47 @@
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 "datafoodconsortium/connector/quantitative_value"
26
+ require "virtual_assembly/semantizer"
27
+
28
+ class DataFoodConsortium::Connector::Characteristic < DataFoodConsortium::Connector::QuantitativeValue
29
+
30
+
31
+
32
+
33
+ def initialize(quantityUnit, quantityValue)
34
+ super(quantityUnit, quantityValue)
35
+
36
+
37
+
38
+
39
+ end
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+ end
@@ -0,0 +1,34 @@
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
+ require "datafoodconsortium/connector/skos_concept"
24
+
25
+ require "virtual_assembly/semantizer"
26
+
27
+ class DataFoodConsortium::Connector::CharacteristicDimension < DataFoodConsortium::Connector::SKOSConcept
28
+
29
+
30
+
31
+
32
+
33
+
34
+ end
@@ -0,0 +1,73 @@
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
+ require 'singleton'
24
+ require 'datafoodconsortium/connector/json_ld_serializer'
25
+
26
+ class DataFoodConsortium::Connector::Connector
27
+
28
+ include Singleton
29
+
30
+ attr_reader :FACETS
31
+ attr_reader :MEASURES
32
+ attr_reader :PRODUCT_TYPES
33
+
34
+ def export(subject)
35
+ return @exporter.process(subject);
36
+ end
37
+
38
+ def loadFacets(data)
39
+ @FACETS = loadThesaurus(data);
40
+ end
41
+
42
+ def loadMeasures(data)
43
+ @MEASURES = loadThesaurus(data);
44
+ end
45
+
46
+ def loadProductTypes(data)
47
+ @PRODUCT_TYPES = loadThesaurus(data);
48
+ end
49
+
50
+ private
51
+
52
+ def initialize()
53
+ super()
54
+
55
+ @context = JSON.parse(%({
56
+ "@context": {
57
+ "dfc-b": "http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#"
58
+ }
59
+ }))['@context']
60
+
61
+ @exporter = DataFoodConsortium::Connector::JsonLdSerializer.new(@context)
62
+ @parser = DataFoodConsortium::Connector::SKOSParser.new
63
+
64
+ @FACETS = []
65
+ @MEASURES = []
66
+ @PRODUCT_TYPES = []
67
+ end
68
+
69
+ def loadThesaurus(data)
70
+ return @parser.parse(data[0]["@graph"])
71
+ end
72
+
73
+ end
@@ -0,0 +1,45 @@
1
+ # MIT License
2
+ #
3
+ # Copyright (c) 2023 Maxime Lecoq <maxime@lecoqlibre.fr>
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+
24
+ require "virtual_assembly/semantizer"
25
+
26
+ class DataFoodConsortium::Connector::CustomerCategory
27
+
28
+ include VirtualAssembly::Semantizer::SemanticObject
29
+
30
+ attr_accessor :name
31
+ attr_accessor :description
32
+
33
+ def initialize(name, description)
34
+ super()
35
+ self.semanticType = "http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#CustomerCategory"
36
+ self.name = name
37
+ self.description = description
38
+
39
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#name") { self.name }
40
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#description") { self.description }
41
+ end
42
+
43
+
44
+
45
+ end
@@ -0,0 +1,157 @@
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
+
31
+
32
+
33
+
34
+
35
+ require "virtual_assembly/semantizer"
36
+
37
+ class DataFoodConsortium::Connector::DefinedProduct
38
+
39
+ include VirtualAssembly::Semantizer::SemanticObject
40
+
41
+ attr_accessor :name
42
+ attr_accessor :description
43
+ attr_accessor :productType
44
+ attr_accessor :quantity
45
+ attr_accessor :alcoholPercentage
46
+ attr_accessor :lifetime
47
+ attr_accessor :claims
48
+ attr_accessor :usageOrStorageConditions
49
+ attr_accessor :allergenCharacteristics
50
+ attr_accessor :nutrientCharacteristics
51
+ attr_accessor :physicalCharacteristics
52
+ attr_accessor :geographicalOrigin
53
+ attr_accessor :catalogItems
54
+ attr_accessor :certifications
55
+ attr_accessor :natureOrigin
56
+ attr_accessor :partOrigin
57
+
58
+ def initialize(name, description)
59
+ super()
60
+ self.semanticType = "http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#DefinedProduct"
61
+ self.name = name
62
+ self.description = description
63
+ self.productType = nil
64
+ self.quantity = nil
65
+ self.alcoholPercentage = nil
66
+ self.lifetime = nil
67
+ self.claims = []
68
+ self.usageOrStorageConditions = nil
69
+ self.allergenCharacteristics = []
70
+ self.nutrientCharacteristics = []
71
+ self.physicalCharacteristics = []
72
+ self.geographicalOrigin = nil
73
+ self.catalogItems = []
74
+ self.certifications = []
75
+ self.natureOrigin = []
76
+ self.partOrigin = []
77
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#name") { self.name }
78
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#description") { self.description }
79
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#hasType") { self.productType }
80
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#hasQuantity") { self.quantity }
81
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#alcoholPercentage") { self.alcoholPercentage }
82
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#lifetime") { self.lifetime }
83
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#hasClaim") { self.claims }
84
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#usageOrStorageCondition") { self.usageOrStorageConditions }
85
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#hasAllergenCharacteristic") { self.allergenCharacteristics }
86
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#hasNutrientCharacteristic") { self.nutrientCharacteristics }
87
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#hasPhysicalCharacteristic") { self.physicalCharacteristics }
88
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#hasGeographicalOrigin") { self.geographicalOrigin }
89
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#referencedBy") { self.catalogItems }
90
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#hasCertification") { self.certifications }
91
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#hasNatureOrigin") { self.natureOrigin }
92
+ registerSemanticProperty("http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#hasPartOrigin") { self.partOrigin }
93
+ end
94
+
95
+
96
+ def addClaim(claim)
97
+ self.claims.push(claim)
98
+ end
99
+
100
+ def removeClaim(claim)
101
+ raise "Not implemented"
102
+ end
103
+
104
+ def addAllergenCharacteristic(allergenCharacteristic)
105
+ self.allergenCharacteristics.push(allergenCharacteristic)
106
+ end
107
+
108
+ def addNutrientCharacteristic(nutrientCharacteristic)
109
+ self.nutrientCharacteristics.push(nutrientCharacteristic)
110
+ end
111
+
112
+ def addPhysicalCharacteristic(physicalCharacteristic)
113
+ self.physicalCharacteristics.push(physicalCharacteristic)
114
+ end
115
+
116
+ def addNatureOrigin(natureOrigin)
117
+ self.natureOrigin.push(natureOrigin)
118
+ end
119
+
120
+ def addPartOrigin(partOrigin)
121
+ self.partOrigin.push(partOrigin)
122
+ end
123
+
124
+ def removeAllergenCharacteristic(allergenCharacteristic)
125
+ raise "Not implemented"
126
+ end
127
+
128
+ def removeNutrientCharacteristic(nutrientCharacteristic)
129
+ raise "Not implemented"
130
+ end
131
+
132
+ def removePhysicalCharacteristic(physicalCharacteristic)
133
+ raise "Not implemented"
134
+ end
135
+
136
+ def removeNatureOrigin(natureOrigin)
137
+ raise "Not implemented"
138
+ end
139
+
140
+ def removePartOrigin(partOrigin)
141
+ raise "Not implemented"
142
+ end
143
+
144
+ def addCatalogItem(catalogItem)
145
+ self.catalogItems.push(catalogItem)
146
+ end
147
+
148
+ def addCertification(certification)
149
+ self.certifications.push(certification)
150
+ end
151
+
152
+ def removeCertification(certification)
153
+ raise "Not implemented"
154
+ end
155
+
156
+
157
+ end