mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Merge pull request #11781 from openfoodfoundation/dependabot/bundler/datafoodconsortium-connector-1.0.0.pre.alpha.9
chore(deps): bump datafoodconsortium-connector from 1.0.0.pre.alpha.8 to 1.0.0.pre.alpha.9
This commit is contained in:
10
Gemfile.lock
10
Gemfile.lock
@@ -171,6 +171,7 @@ GEM
|
||||
aws-sigv4 (1.6.0)
|
||||
aws-eventstream (~> 1, >= 1.0.2)
|
||||
base64 (0.1.1)
|
||||
bcp47_spec (0.2.1)
|
||||
bcrypt (3.1.19)
|
||||
bigdecimal (3.0.2)
|
||||
bindata (2.4.15)
|
||||
@@ -234,7 +235,7 @@ GEM
|
||||
activerecord (>= 5.a)
|
||||
database_cleaner-core (~> 2.0.0)
|
||||
database_cleaner-core (2.0.1)
|
||||
datafoodconsortium-connector (1.0.0.pre.alpha.8)
|
||||
datafoodconsortium-connector (1.0.0.pre.alpha.9)
|
||||
virtual_assembly-semantizer (~> 1.0, >= 1.0.5)
|
||||
date (3.3.3)
|
||||
debug (1.8.0)
|
||||
@@ -363,13 +364,13 @@ GEM
|
||||
bindata
|
||||
faraday (~> 2.0)
|
||||
faraday-follow_redirects
|
||||
json-ld (3.2.5)
|
||||
json-ld (3.3.0)
|
||||
htmlentities (~> 4.3)
|
||||
json-canonicalization (~> 0.3, >= 0.3.2)
|
||||
link_header (~> 0.0, >= 0.0.8)
|
||||
multi_json (~> 1.15)
|
||||
rack (>= 2.2, < 4)
|
||||
rdf (~> 3.2, >= 3.2.10)
|
||||
rdf (~> 3.3)
|
||||
json-schema (3.0.0)
|
||||
addressable (>= 2.8)
|
||||
json_spec (1.1.5)
|
||||
@@ -562,7 +563,8 @@ GEM
|
||||
rb-fsevent (0.11.2)
|
||||
rb-inotify (0.10.1)
|
||||
ffi (~> 1.0)
|
||||
rdf (3.2.11)
|
||||
rdf (3.3.1)
|
||||
bcp47_spec (~> 0.2)
|
||||
link_header (~> 0.0, >= 0.0.8)
|
||||
redcarpet (3.6.0)
|
||||
redis (4.8.1)
|
||||
|
||||
@@ -17,7 +17,7 @@ module DfcProvider
|
||||
group = EnterpriseGroup.find(params[:id])
|
||||
address = AddressBuilder.address(group.address)
|
||||
enterprise = EnterpriseBuilder.enterprise_group(group)
|
||||
enterprise.addLocalization(address)
|
||||
enterprise.localizations = [address]
|
||||
render json: DfcIo.export(enterprise, address)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -13,10 +13,9 @@ class EnterpriseBuilder < DfcBuilder
|
||||
description: enterprise.description,
|
||||
vatNumber: enterprise.abn,
|
||||
suppliedProducts: supplied_products,
|
||||
catalogItems: catalog_items
|
||||
).tap do |e|
|
||||
e.addLocalization(address)
|
||||
end
|
||||
catalogItems: catalog_items,
|
||||
localizations: [address],
|
||||
)
|
||||
end
|
||||
|
||||
def self.enterprise_group(group)
|
||||
|
||||
@@ -30,13 +30,22 @@ module DataFoodConsortium
|
||||
args = Array.new(number_of_required_args)
|
||||
type_uri = clazz.new(*args).semanticType
|
||||
type_map[type_uri] = clazz
|
||||
end
|
||||
|
||||
# Add support for the old DFC v1.7 URLs:
|
||||
new_type_uri = type_uri.gsub(
|
||||
def self.prefixed_name(uri)
|
||||
# When we skip backwards compatibility, we can just do this:
|
||||
#
|
||||
# key = RDF::URI.new(uri).pname(prefixes: Context::VERSION_1_8)
|
||||
#
|
||||
# But for now we do it manually.
|
||||
uri.gsub(
|
||||
"https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#",
|
||||
"http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#"
|
||||
"dfc-b:"
|
||||
).gsub(
|
||||
# legacy URI
|
||||
"http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#",
|
||||
"dfc-b:"
|
||||
)
|
||||
type_map[new_type_uri] = clazz
|
||||
end
|
||||
|
||||
def import(json_string_or_io)
|
||||
@@ -71,7 +80,8 @@ module DataFoodConsortium
|
||||
# Not all subjects have an id, some are anonymous.
|
||||
id = type_statement.subject.try(:value)
|
||||
type = type_statement.object.value
|
||||
clazz = self.class.type_map[type]
|
||||
key = self.class.prefixed_name(type)
|
||||
clazz = self.class.type_map[key]
|
||||
|
||||
clazz.new(*[id].compact)
|
||||
end
|
||||
@@ -84,16 +94,11 @@ module DataFoodConsortium
|
||||
|
||||
def apply_statement(statement)
|
||||
subject = subject_of(statement)
|
||||
property_id = statement.predicate.value
|
||||
property_uri = statement.predicate.value
|
||||
value = resolve_object(statement.object)
|
||||
|
||||
# Backwards-compatibility with old DFC v1.7 ids:
|
||||
unless subject.hasSemanticProperty?(property_id)
|
||||
property_id = property_id.gsub(
|
||||
"http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#",
|
||||
"https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#"
|
||||
)
|
||||
end
|
||||
property_id = self.class.prefixed_name(property_uri)
|
||||
|
||||
return unless subject.hasSemanticProperty?(property_id)
|
||||
|
||||
property = subject.semanticProperty(property_id)
|
||||
|
||||
@@ -13,8 +13,7 @@ module DataFoodConsortium
|
||||
protected
|
||||
|
||||
def createSKOSConcept(element) # rubocop:disable Naming/MethodName
|
||||
concept = DataFoodConsortium::Connector::SKOSConcept.new
|
||||
concept.semanticId = element.id
|
||||
concept = DataFoodConsortium::Connector::SKOSConcept.new(element.id)
|
||||
concept.semanticType = element.type
|
||||
self.class.concepts[element.id] = concept
|
||||
concept
|
||||
|
||||
@@ -112,7 +112,7 @@ describe DataFoodConsortium::Connector::Importer do
|
||||
result = connector.import(product_data)
|
||||
|
||||
expect(result).to be_a DataFoodConsortium::Connector::SuppliedProduct
|
||||
expect(result.semanticType).to eq "https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#SuppliedProduct"
|
||||
expect(result.semanticType).to eq "dfc-b:SuppliedProduct"
|
||||
expect(result.semanticId).to eq "https://example.net/tomato"
|
||||
expect(result.name).to eq "Tomato"
|
||||
expect(result.description).to eq "Awesome tomato"
|
||||
@@ -123,7 +123,7 @@ describe DataFoodConsortium::Connector::Importer do
|
||||
result = connector.import(product_data_with_context)
|
||||
|
||||
expect(result).to be_a DataFoodConsortium::Connector::SuppliedProduct
|
||||
expect(result.semanticType).to eq "https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#SuppliedProduct"
|
||||
expect(result.semanticType).to eq "dfc-b:SuppliedProduct"
|
||||
expect(result.semanticId).to eq "https://example.net/tomato"
|
||||
expect(result.name).to eq "Tomato"
|
||||
expect(result.description).to eq "Awesome tomato"
|
||||
@@ -134,7 +134,7 @@ describe DataFoodConsortium::Connector::Importer do
|
||||
result = connector.import(product_data_with_context_v1_8)
|
||||
|
||||
expect(result).to be_a DataFoodConsortium::Connector::SuppliedProduct
|
||||
expect(result.semanticType).to eq "https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#SuppliedProduct"
|
||||
expect(result.semanticType).to eq "dfc-b:SuppliedProduct"
|
||||
expect(result.semanticId).to eq "https://example.net/tomato"
|
||||
expect(result.name).to eq "Tomato"
|
||||
expect(result.description).to eq "Awesome tomato"
|
||||
|
||||
@@ -33,7 +33,7 @@ describe "EnterpriseGroups", type: :request, swagger_doc: "dfc.yaml", rswag_auto
|
||||
|
||||
expect(graph[1]["@type"]).to eq "dfc-b:Enterprise"
|
||||
expect(graph[1]).to include(
|
||||
"dfc-b:hasName" => "Sustainable Farmers",
|
||||
"dfc-b:name" => "Sustainable Farmers",
|
||||
"dfc-b:affiliatedBy" => "http://test.host/api/dfc/enterprises/10000",
|
||||
)
|
||||
end
|
||||
@@ -54,7 +54,7 @@ describe "EnterpriseGroups", type: :request, swagger_doc: "dfc.yaml", rswag_auto
|
||||
|
||||
expect(graph[0]).to include(
|
||||
"@type" => "dfc-b:Enterprise",
|
||||
"dfc-b:hasName" => "Sustainable Farmers",
|
||||
"dfc-b:name" => "Sustainable Farmers",
|
||||
"dfc-b:hasAddress" => "http://test.host/api/dfc/addresses/40000",
|
||||
"dfc-b:affiliatedBy" => "http://test.host/api/dfc/enterprises/10000",
|
||||
)
|
||||
|
||||
@@ -95,10 +95,10 @@ paths:
|
||||
- "@id": http://test.host/api/dfc/enterprises/10000
|
||||
"@type": dfc-b:Enterprise
|
||||
dfc-b:hasAddress: http://test.host/api/dfc/addresses/40000
|
||||
dfc-b:hasName: Fred's Farm
|
||||
dfc-b:name: Fred's Farm
|
||||
dfc-b:hasDescription: Beautiful
|
||||
dfc-b:supplies: http://test.host/api/dfc/enterprises/10000/supplied_products/10001
|
||||
dfc-b:manages: http://test.host/api/dfc/enterprises/10000/catalog_items/10001
|
||||
dfc-b:supplies: http://test.host/api/dfc/enterprises/10000/supplied_products/10001
|
||||
- "@id": http://test.host/api/dfc/enterprises/10000/catalog_items/10001
|
||||
"@type": dfc-b:CatalogItem
|
||||
dfc-b:references: http://test.host/api/dfc/enterprises/10000/supplied_products/10001
|
||||
@@ -121,7 +121,7 @@ paths:
|
||||
ofn:spree_product_id: 90000
|
||||
- "@id": http://test.host/api/dfc/enterprises/10000/offers/10001
|
||||
"@type": dfc-b:Offer
|
||||
dfc-b:price: 19.99
|
||||
dfc-b:hasPrice: 19.99
|
||||
dfc-b:stockLimitation: 0
|
||||
'401':
|
||||
description: unauthorized
|
||||
@@ -159,7 +159,7 @@ paths:
|
||||
dfc-b:offeredThrough: http://test.host/api/dfc/enterprises/10000/offers/10001
|
||||
- "@id": http://test.host/api/dfc/enterprises/10000/offers/10001
|
||||
"@type": dfc-b:Offer
|
||||
dfc-b:price: 19.99
|
||||
dfc-b:hasPrice: 19.99
|
||||
dfc-b:stockLimitation: 0
|
||||
'404':
|
||||
description: not found
|
||||
@@ -255,7 +255,7 @@ paths:
|
||||
dfc-b:affiliates: http://test.host/api/dfc/enterprise_groups/60000
|
||||
- "@id": http://test.host/api/dfc/enterprise_groups/60000
|
||||
"@type": dfc-b:Enterprise
|
||||
dfc-b:hasName: Sustainable Farmers
|
||||
dfc-b:name: Sustainable Farmers
|
||||
dfc-b:hasDescription: this is a group
|
||||
dfc-b:VATnumber: ''
|
||||
dfc-b:affiliatedBy: http://test.host/api/dfc/enterprises/10000
|
||||
@@ -283,7 +283,7 @@ paths:
|
||||
- "@id": http://test.host/api/dfc/enterprise_groups/60000
|
||||
"@type": dfc-b:Enterprise
|
||||
dfc-b:hasAddress: http://test.host/api/dfc/addresses/40000
|
||||
dfc-b:hasName: Sustainable Farmers
|
||||
dfc-b:name: Sustainable Farmers
|
||||
dfc-b:hasDescription: this is a group
|
||||
dfc-b:VATnumber: ''
|
||||
dfc-b:affiliatedBy: http://test.host/api/dfc/enterprises/10000
|
||||
@@ -317,11 +317,11 @@ paths:
|
||||
- "@id": http://test.host/api/dfc/enterprises/10000
|
||||
"@type": dfc-b:Enterprise
|
||||
dfc-b:hasAddress: http://test.host/api/dfc/addresses/40000
|
||||
dfc-b:hasName: Fred's Farm
|
||||
dfc-b:name: Fred's Farm
|
||||
dfc-b:hasDescription: This is an awesome enterprise
|
||||
dfc-b:VATnumber: 123 456
|
||||
dfc-b:supplies: http://test.host/api/dfc/enterprises/10000/supplied_products/10001
|
||||
dfc-b:manages: http://test.host/api/dfc/enterprises/10000/catalog_items/10001
|
||||
dfc-b:supplies: http://test.host/api/dfc/enterprises/10000/supplied_products/10001
|
||||
dfc-b:affiliates: http://test.host/api/dfc/enterprise_groups/60000
|
||||
- "@id": http://test.host/api/dfc/addresses/40000
|
||||
"@type": dfc-b:Address
|
||||
|
||||
Reference in New Issue
Block a user