Add new DFC vocabulary

So that we can use order states programmatically.
This commit is contained in:
Maikel Linke
2024-09-05 16:26:10 +10:00
parent db76cd1659
commit 3e7f61c4d1
4 changed files with 370 additions and 3 deletions

View File

@@ -2,15 +2,24 @@
class DfcLoader
def self.connector
@connector ||= load_vocabularies
unless @connector
@connector = DataFoodConsortium::Connector::Connector.instance
load_vocabularies
end
@connector
end
def self.vocabulary(name)
@vocabs ||= {}
@vocabs[name] ||= connector.__send__(:loadThesaurus, read_file(name))
end
def self.load_vocabularies
connector = DataFoodConsortium::Connector::Connector.instance
connector.loadMeasures(read_file("measures"))
connector.loadFacets(read_file("facets"))
connector.loadProductTypes(read_file("productTypes"))
connector
vocabulary("vocabulary") # order states etc
end
def self.read_file(name)

View File

@@ -9,3 +9,4 @@ mkdir -p "$dst"
curl --location "$src/facets.json" > "$dst/facets.json"
curl --location "$src/measures.json" > "$dst/measures.json"
curl --location "$src/productTypes.json" > "$dst/productTypes.json"
curl --location "$src/vocabulary.json" > "$dst/vocabulary.json"

View File

@@ -21,4 +21,10 @@ RSpec.describe DfcLoader do
)
expect(result["dfc-b:name"]).to eq "Tomato"
end
it "loads vocabularies" do
terms = DfcLoader.vocabulary("vocabulary")
expect(terms.STATES.ORDERSTATE.HELD.semanticId)
.to eq "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#Held"
end
end

View File

@@ -0,0 +1,351 @@
[ {
"@graph" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#",
"@type" : [ "http://www.w3.org/2002/07/owl#Ontology" ]
}, {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#Cancelled",
"@type" : [ "http://www.w3.org/2004/02/skos/core#Concept" ],
"http://www.w3.org/2004/02/skos/core#broader" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#OrderState"
}, {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#PaymentState"
}, {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#FulfilmentState"
} ],
"http://www.w3.org/2004/02/skos/core#inScheme" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#DFC_Vocabulary"
} ],
"http://www.w3.org/2004/02/skos/core#prefLabel" : [ {
"@language" : "en",
"@value" : "Cancelled"
} ]
}, {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#Complete",
"@type" : [ "http://www.w3.org/2004/02/skos/core#Concept" ],
"http://www.w3.org/2004/02/skos/core#broader" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#OrderState"
} ],
"http://www.w3.org/2004/02/skos/core#inScheme" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#DFC_Vocabulary"
} ],
"http://www.w3.org/2004/02/skos/core#prefLabel" : [ {
"@language" : "en",
"@value" : "Complete"
} ]
}, {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#DFC_Vocabulary",
"@type" : [ "http://www.w3.org/2004/02/skos/core#ConceptScheme" ],
"http://www.w3.org/2004/02/skos/core#prefLabel" : [ {
"@language" : "en",
"@value" : "DFC_Vocabulary"
} ]
}, {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#Draft",
"@type" : [ "http://www.w3.org/2004/02/skos/core#Concept" ],
"http://www.w3.org/2004/02/skos/core#broader" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#OrderState"
} ],
"http://www.w3.org/2004/02/skos/core#inScheme" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#DFC_Vocabulary"
} ],
"http://www.w3.org/2004/02/skos/core#prefLabel" : [ {
"@language" : "en",
"@value" : "Draft"
} ]
}, {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#Fulfilled",
"@type" : [ "http://www.w3.org/2004/02/skos/core#Concept" ],
"http://www.w3.org/2004/02/skos/core#broader" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#FulfilmentState"
} ],
"http://www.w3.org/2004/02/skos/core#inScheme" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#DFC_Vocabulary"
} ],
"http://www.w3.org/2004/02/skos/core#prefLabel" : [ {
"@language" : "en",
"@value" : "Fulfilled"
} ]
}, {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#FulfilmentState",
"@type" : [ "http://www.w3.org/2004/02/skos/core#Concept" ],
"http://www.w3.org/2004/02/skos/core#broader" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#States"
} ],
"http://www.w3.org/2004/02/skos/core#inScheme" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#DFC_Vocabulary"
} ],
"http://www.w3.org/2004/02/skos/core#prefLabel" : [ {
"@language" : "en",
"@value" : "Fulfilment state"
} ]
}, {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#Held",
"@type" : [ "http://www.w3.org/2004/02/skos/core#Concept" ],
"http://www.w3.org/2004/02/skos/core#broader" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#OrderState"
}, {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#FulfilmentState"
} ],
"http://www.w3.org/2004/02/skos/core#inScheme" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#DFC_Vocabulary"
} ],
"http://www.w3.org/2004/02/skos/core#prefLabel" : [ {
"@language" : "en",
"@value" : "Held"
} ]
}, {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#OrderState",
"@type" : [ "http://www.w3.org/2004/02/skos/core#Concept" ],
"http://www.w3.org/2004/02/skos/core#broader" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#States"
} ],
"http://www.w3.org/2004/02/skos/core#inScheme" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#DFC_Vocabulary"
} ],
"http://www.w3.org/2004/02/skos/core#prefLabel" : [ {
"@language" : "en",
"@value" : "Order state"
} ]
}, {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#Paid",
"@type" : [ "http://www.w3.org/2004/02/skos/core#Concept" ],
"http://www.w3.org/2004/02/skos/core#broader" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#PaymentState"
} ],
"http://www.w3.org/2004/02/skos/core#inScheme" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#DFC_Vocabulary"
} ],
"http://www.w3.org/2004/02/skos/core#prefLabel" : [ {
"@language" : "en",
"@value" : "Paid"
} ]
}, {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#PaymentState",
"@type" : [ "http://www.w3.org/2004/02/skos/core#Concept" ],
"http://www.w3.org/2004/02/skos/core#broader" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#States"
} ],
"http://www.w3.org/2004/02/skos/core#inScheme" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#DFC_Vocabulary"
} ],
"http://www.w3.org/2004/02/skos/core#prefLabel" : [ {
"@language" : "en",
"@value" : "Payment state"
} ]
}, {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#States",
"@type" : [ "http://www.w3.org/2004/02/skos/core#Concept" ],
"http://www.w3.org/2004/02/skos/core#inScheme" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#DFC_Vocabulary"
} ],
"http://www.w3.org/2004/02/skos/core#prefLabel" : [ {
"@language" : "en",
"@value" : "States"
} ],
"http://www.w3.org/2004/02/skos/core#topConceptOf" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#DFC_Vocabulary"
} ]
}, {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#Unfulfilled",
"@type" : [ "http://www.w3.org/2004/02/skos/core#Concept" ],
"http://www.w3.org/2004/02/skos/core#broader" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#FulfilmentState"
} ],
"http://www.w3.org/2004/02/skos/core#inScheme" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#DFC_Vocabulary"
} ],
"http://www.w3.org/2004/02/skos/core#prefLabel" : [ {
"@language" : "en",
"@value" : "Unfulfilled"
} ]
}, {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#Unpaid",
"@type" : [ "http://www.w3.org/2004/02/skos/core#Concept" ],
"http://www.w3.org/2004/02/skos/core#broader" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#PaymentState"
} ],
"http://www.w3.org/2004/02/skos/core#inScheme" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#DFC_Vocabulary"
} ],
"http://www.w3.org/2004/02/skos/core#prefLabel" : [ {
"@language" : "en",
"@value" : "Unpaid"
} ]
}, {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#accept",
"@type" : [ "http://www.w3.org/2004/02/skos/core#Concept" ],
"http://www.w3.org/2004/02/skos/core#broader" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#transformationType"
} ],
"http://www.w3.org/2004/02/skos/core#inScheme" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#DFC_Vocabulary"
} ],
"http://www.w3.org/2004/02/skos/core#prefLabel" : [ {
"@language" : "en",
"@value" : "accept"
} ]
}, {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#c_734fc709",
"http://www.w3.org/2004/02/skos/core#prefLabel" : [ {
"@language" : "en",
"@value" : "FulfilmentState"
} ]
}, {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#combine",
"@type" : [ "http://www.w3.org/2004/02/skos/core#Concept" ],
"http://www.w3.org/2004/02/skos/core#broader" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#transformationType"
} ],
"http://www.w3.org/2004/02/skos/core#inScheme" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#DFC_Vocabulary"
} ],
"http://www.w3.org/2004/02/skos/core#prefLabel" : [ {
"@language" : "en",
"@value" : "combine"
} ]
}, {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#consume",
"@type" : [ "http://www.w3.org/2004/02/skos/core#Concept" ],
"http://www.w3.org/2004/02/skos/core#broader" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#transformationType"
} ],
"http://www.w3.org/2004/02/skos/core#inScheme" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#DFC_Vocabulary"
} ],
"http://www.w3.org/2004/02/skos/core#prefLabel" : [ {
"@language" : "en",
"@value" : "consume"
} ]
}, {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#dropoff",
"@type" : [ "http://www.w3.org/2004/02/skos/core#Concept" ],
"http://www.w3.org/2004/02/skos/core#broader" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#transformationType"
} ],
"http://www.w3.org/2004/02/skos/core#inScheme" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#DFC_Vocabulary"
} ],
"http://www.w3.org/2004/02/skos/core#prefLabel" : [ {
"@language" : "en",
"@value" : "dropoff"
} ]
}, {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#lower",
"@type" : [ "http://www.w3.org/2004/02/skos/core#Concept" ],
"http://www.w3.org/2004/02/skos/core#broader" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#transformationType"
} ],
"http://www.w3.org/2004/02/skos/core#inScheme" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#DFC_Vocabulary"
} ],
"http://www.w3.org/2004/02/skos/core#prefLabel" : [ {
"@language" : "en",
"@value" : "lower"
} ]
}, {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#modify",
"@type" : [ "http://www.w3.org/2004/02/skos/core#Concept" ],
"http://www.w3.org/2004/02/skos/core#broader" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#transformationType"
} ],
"http://www.w3.org/2004/02/skos/core#inScheme" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#DFC_Vocabulary"
} ],
"http://www.w3.org/2004/02/skos/core#prefLabel" : [ {
"@language" : "en",
"@value" : "modify"
} ]
}, {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#move",
"@type" : [ "http://www.w3.org/2004/02/skos/core#Concept" ],
"http://www.w3.org/2004/02/skos/core#broader" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#transformationType"
} ],
"http://www.w3.org/2004/02/skos/core#inScheme" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#DFC_Vocabulary"
} ],
"http://www.w3.org/2004/02/skos/core#prefLabel" : [ {
"@language" : "en",
"@value" : "move"
} ]
}, {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#pickup",
"@type" : [ "http://www.w3.org/2004/02/skos/core#Concept" ],
"http://www.w3.org/2004/02/skos/core#broader" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#transformationType"
} ],
"http://www.w3.org/2004/02/skos/core#inScheme" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#DFC_Vocabulary"
} ],
"http://www.w3.org/2004/02/skos/core#prefLabel" : [ {
"@language" : "en",
"@value" : "pickup"
} ]
}, {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#produce",
"@type" : [ "http://www.w3.org/2004/02/skos/core#Concept" ],
"http://www.w3.org/2004/02/skos/core#broader" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#transformationType"
} ],
"http://www.w3.org/2004/02/skos/core#inScheme" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#DFC_Vocabulary"
} ],
"http://www.w3.org/2004/02/skos/core#prefLabel" : [ {
"@language" : "en",
"@value" : "produce"
} ]
}, {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#raise",
"@type" : [ "http://www.w3.org/2004/02/skos/core#Concept" ],
"http://www.w3.org/2004/02/skos/core#broader" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#transformationType"
} ],
"http://www.w3.org/2004/02/skos/core#inScheme" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#DFC_Vocabulary"
} ],
"http://www.w3.org/2004/02/skos/core#prefLabel" : [ {
"@language" : "en",
"@value" : "raise"
} ]
}, {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#separate",
"@type" : [ "http://www.w3.org/2004/02/skos/core#Concept" ],
"http://www.w3.org/2004/02/skos/core#broader" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#transformationType"
} ],
"http://www.w3.org/2004/02/skos/core#inScheme" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#DFC_Vocabulary"
} ],
"http://www.w3.org/2004/02/skos/core#prefLabel" : [ {
"@language" : "en",
"@value" : "separate"
} ]
}, {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#transformationType",
"@type" : [ "http://www.w3.org/2004/02/skos/core#Concept" ],
"http://www.w3.org/2004/02/skos/core#inScheme" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#DFC_Vocabulary"
} ],
"http://www.w3.org/2004/02/skos/core#prefLabel" : [ {
"@language" : "en",
"@value" : "Transformation type"
} ],
"http://www.w3.org/2004/02/skos/core#topConceptOf" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#DFC_Vocabulary"
} ]
}, {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#use",
"@type" : [ "http://www.w3.org/2004/02/skos/core#Concept" ],
"http://www.w3.org/2004/02/skos/core#broader" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#transformationType"
} ],
"http://www.w3.org/2004/02/skos/core#inScheme" : [ {
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#DFC_Vocabulary"
} ],
"http://www.w3.org/2004/02/skos/core#prefLabel" : [ {
"@language" : "en",
"@value" : "use"
} ]
} ],
"@id" : "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#"
} ]