Spec DFC SuppliedProduct#update with new Prototype

I observed new data from the DFC Prototype. It now uses the DFC 1.8
ontology with the hasQuantity object.

It now also uses PUT requests for updates because PATCH is not as well
supported. Rails doesn't care though.

I couldn't observe a request for the CatalogItem yet because the
Prototype failed to send it.
This commit is contained in:
Maikel Linke
2023-08-10 13:21:02 +10:00
parent cf8d5a584e
commit faa112c3ae
5 changed files with 134 additions and 97 deletions

View File

@@ -37,9 +37,8 @@ module DfcProvider
description: dfc_request["dfc-b:description"],
)
# This input is DFC v1.6 currently sent by the DFC Prototype.
variant.update!(
unit_value: dfc_request["dfc-b:quantity"],
unit_value: dfc_request["dfc-b:hasQuantity"]["dfc-b:value"],
)
end

View File

@@ -1,85 +0,0 @@
{
"@context": {
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"skos": "http://www.w3.org/2004/02/skos/core#",
"dfc": "http://static.datafoodconsortium.org/ontologies/DFC_FullModel.owl#",
"dc": "http://purl.org/dc/elements/1.1/#",
"dfc-b": "http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#",
"dfc-p": "http://static.datafoodconsortium.org/ontologies/DFC_ProductOntology.owl#",
"dfc-t": "http://static.datafoodconsortium.org/ontologies/DFC_TechnicalOntology.owl#",
"dfc-m": "http://static.datafoodconsortium.org/data/measures.rdf#",
"dfc-pt": "http://static.datafoodconsortium.org/data/productTypes.rdf#",
"dfc-f": "http://static.datafoodconsortium.org/data/facets.rdf#",
"dfc-p:hasUnit": {
"@type": "@id"
},
"dfc-b:hasUnit": {
"@type": "@id"
},
"dfc-b:hasQuantity": {
"@type": "@id"
},
"dfc-p:hasType": {
"@type": "@id"
},
"dfc-b:hasType": {
"@type": "@id"
},
"dfc-b:references": {
"@type": "@id"
},
"dfc-b:referencedBy": {
"@type": "@id"
},
"dfc-b:offeres": {
"@type": "@id"
},
"dfc-b:supplies": {
"@type": "@id"
},
"dfc-b:defines": {
"@type": "@id"
},
"dfc-b:affiliates": {
"@type": "@id"
},
"dfc-b:manages": {
"@type": "@id"
},
"dfc-b:offeredThrough": {
"@type": "@id"
},
"dfc-b:hasBrand": {
"@type": "@id"
},
"dfc-b:hasGeographicalOrigin": {
"@type": "@id"
},
"dfc-b:hasClaim": {
"@type": "@id"
},
"dfc-b:hasAllergenDimension": {
"@type": "@id"
},
"dfc-b:hasNutrimentDimension": {
"@type": "@id"
},
"dfc-b:hasPhysicalDimension": {
"@type": "@id"
},
"dfc:owner": {
"@type": "@id"
},
"dfc-t:hostedBy": {
"@type": "@id"
},
"dfc-t:hasPivot": {
"@type": "@id"
},
"dfc-t:represent": {
"@type": "@id"
}
},
"dfc-b:description": "DFC-Pesto updated",
"dfc-b:quantity": 17
}

View File

@@ -0,0 +1,105 @@
{
"@context": {
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"skos": "http://www.w3.org/2004/02/skos/core#",
"dfc": "https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_FullModel.owl#",
"dc": "http://purl.org/dc/elements/1.1/#",
"dfc-b": "https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#",
"dfc-p": "https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_ProductGlossary.owl#",
"dfc-t": "https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_TechnicalOntology.owl#",
"dfc-m": "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/measures.rdf#",
"dfc-pt": "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/productTypes.rdf#",
"dfc-f": "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/facets.rdf#",
"ontosec": "http://www.semanticweb.org/ontologies/2008/11/OntologySecurity.owl#",
"dfc-p:hasUnit": {
"@type": "@id"
},
"dfc-b:hasUnit": {
"@type": "@id"
},
"dfc-b:hasQuantity": {
"@type": "@id"
},
"dfc-p:hasType": {
"@type": "@id"
},
"dfc-b:hasType": {
"@type": "@id"
},
"dfc-b:references": {
"@type": "@id"
},
"dfc-b:referencedBy": {
"@type": "@id"
},
"dfc-b:offeres": {
"@type": "@id"
},
"dfc-b:supplies": {
"@type": "@id"
},
"dfc-b:defines": {
"@type": "@id"
},
"dfc-b:affiliates": {
"@type": "@id"
},
"dfc-b:hasCertification": {
"@type": "@id"
},
"dfc-b:manages": {
"@type": "@id"
},
"dfc-b:offeredThrough": {
"@type": "@id"
},
"dfc-b:hasBrand": {
"@type": "@id"
},
"dfc-b:hasGeographicalOrigin": {
"@type": "@id"
},
"dfc-b:hasClaim": {
"@type": "@id"
},
"dfc-b:hasAllergenDimension": {
"@type": "@id"
},
"dfc-b:hasNutrientDimension": {
"@type": "@id"
},
"dfc-b:hasPhysicalDimension": {
"@type": "@id"
},
"dfc:owner": {
"@type": "@id"
},
"dfc-t:hostedBy": {
"@type": "@id"
},
"dfc-t:hasPivot": {
"@type": "@id"
},
"dfc-t:represent": {
"@type": "@id"
}
},
"@id": "https://staging.coopcircuits.fr/api/dfc-v1.7/enterprises/2731/supplied_products/56790",
"@type": "dfc-b:SuppliedProduct",
"dfc-b:alcoholPercentage": 0,
"dfc-b:description": "DFC-Pesto updated",
"dfc-b:hasQuantity": {
"@type": "dfc-b:QuantitativeValue",
"dfc-b:hasUnit": "dfc-m:Piece",
"dfc-b:value": 17
},
"dfc-b:hasType": "dfc-pt:non-local-vegetable",
"dfc-b:lifetime": "",
"dfc-b:name": "Pesto novo",
"dfc-b:totalTheoreticalStock": 0,
"dfc-b:usageOrStorageCondition": "",
"dfc:owner": "http://proto.datafoodconsortium.org:3000/ldp/user/64c1d30351ecb4367037a9f6",
"dfc-b:hasPhysicalCharacteristic": [],
"dfc-b:hasNutrientCharacteristic": [],
"dfc-b:hasAllergenCharacteristic": []
}

View File

@@ -128,7 +128,7 @@ describe "SuppliedProducts", type: :request, swagger_doc: "dfc-v1.7/swagger.yaml
consumes "application/json"
parameter name: :supplied_product, in: :body, schema: {
example: ExampleJson.read("patch_supplied_product")
example: ExampleJson.read("put_supplied_product")
}
let(:id) { variant.id }

View File

@@ -412,14 +412,15 @@ paths:
"@context":
rdfs: http://www.w3.org/2000/01/rdf-schema#
skos: http://www.w3.org/2004/02/skos/core#
dfc: http://static.datafoodconsortium.org/ontologies/DFC_FullModel.owl#
dfc: https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_FullModel.owl#
dc: http://purl.org/dc/elements/1.1/#
dfc-b: http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#
dfc-p: http://static.datafoodconsortium.org/ontologies/DFC_ProductOntology.owl#
dfc-t: http://static.datafoodconsortium.org/ontologies/DFC_TechnicalOntology.owl#
dfc-m: http://static.datafoodconsortium.org/data/measures.rdf#
dfc-pt: http://static.datafoodconsortium.org/data/productTypes.rdf#
dfc-f: http://static.datafoodconsortium.org/data/facets.rdf#
dfc-b: https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#
dfc-p: https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_ProductGlossary.owl#
dfc-t: https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_TechnicalOntology.owl#
dfc-m: https://github.com/datafoodconsortium/taxonomies/releases/latest/download/measures.rdf#
dfc-pt: https://github.com/datafoodconsortium/taxonomies/releases/latest/download/productTypes.rdf#
dfc-f: https://github.com/datafoodconsortium/taxonomies/releases/latest/download/facets.rdf#
ontosec: http://www.semanticweb.org/ontologies/2008/11/OntologySecurity.owl#
dfc-p:hasUnit:
"@type": "@id"
dfc-b:hasUnit:
@@ -442,6 +443,8 @@ paths:
"@type": "@id"
dfc-b:affiliates:
"@type": "@id"
dfc-b:hasCertification:
"@type": "@id"
dfc-b:manages:
"@type": "@id"
dfc-b:offeredThrough:
@@ -454,7 +457,7 @@ paths:
"@type": "@id"
dfc-b:hasAllergenDimension:
"@type": "@id"
dfc-b:hasNutrimentDimension:
dfc-b:hasNutrientDimension:
"@type": "@id"
dfc-b:hasPhysicalDimension:
"@type": "@id"
@@ -466,7 +469,22 @@ paths:
"@type": "@id"
dfc-t:represent:
"@type": "@id"
"@id": https://staging.coopcircuits.fr/api/dfc-v1.7/enterprises/2731/supplied_products/56790
"@type": dfc-b:SuppliedProduct
dfc-b:alcoholPercentage: 0
dfc-b:description: DFC-Pesto updated
dfc-b:quantity: 17
dfc-b:hasQuantity:
"@type": dfc-b:QuantitativeValue
dfc-b:hasUnit: dfc-m:Piece
dfc-b:value: 17
dfc-b:hasType: dfc-pt:non-local-vegetable
dfc-b:lifetime: ''
dfc-b:name: Pesto novo
dfc-b:totalTheoreticalStock: 0
dfc-b:usageOrStorageCondition: ''
dfc:owner: http://proto.datafoodconsortium.org:3000/ldp/user/64c1d30351ecb4367037a9f6
dfc-b:hasPhysicalCharacteristic: []
dfc-b:hasNutrientCharacteristic: []
dfc-b:hasAllergenCharacteristic: []
servers:
- url: "/"