Skip to content

Commit

Permalink
Update context IRIs from static.dfc.org
Browse files Browse the repository at this point in the history
  • Loading branch information
jgaehring committed Mar 5, 2024
1 parent a97098e commit 92f8218
Show file tree
Hide file tree
Showing 21 changed files with 31 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ options?: {
This will output DFC compliant valid JSON-LD like:
```JS
{
"@context": "http://static.datafoodconsortium.org/ontologies/context.json",
"@context": "http://www.datafoodconsortium.org/ontologies/context.json",
"@graph": [
{
"@id": "_:b1",
Expand Down Expand Up @@ -374,7 +374,7 @@ const Semanticable | undefined = await connector.importOne(jsonAsAString);

You can pass the `only` option to target one type using the `importOneTyped` method:
```JS
const order: string = "http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#Order";
const order: string = "http://www.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#Order";
const IOrder | undefined = await connector.importOneTyped<IOrder>(jsonAsAString, { only: order });
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default class Connector implements IConnector {
this.fetchFunction = async (semanticId: string) => (await fetch(semanticId));
this.factory = new ConnectorFactory(this);
this.importer = new ConnectorImporterJsonldStream({ context: context });
const outputContext = "http://static.datafoodconsortium.org/ontologies/context.json";
const outputContext = "https://www.datafoodconsortium.org";
this.exporter = new ConnectorExporterJsonldStream(context, outputContext);
}

Expand Down Expand Up @@ -260,17 +260,17 @@ export default class Connector implements IConnector {
}

public async loadFacets(facets: any): Promise<void> {
const prefix: string = "http://static.datafoodconsortium.org/data/facets.rdf#";
const prefix: string = "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/facets.rdf#";
this.FACETS = await this.importThesaurus(facets, prefix);
}

public async loadMeasures(measures: any): Promise<void> {
const prefix: string = "http://static.datafoodconsortium.org/data/measures.rdf#";
const prefix: string = "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/measures.rdf#";
this.MEASURES = await this.importThesaurus(measures, prefix);
}

public async loadProductTypes(productTypes: any): Promise<void> {
const prefix: string = "http://static.datafoodconsortium.org/data/productTypes.rdf#";
const prefix: string = "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/productTypes.rdf#";
this.PRODUCT_TYPES = await this.importThesaurus(productTypes, prefix);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export default class ConnectorFactory implements IConnectorFactory {

public createFromType(type: string): Semanticable | undefined {
let result: Semanticable | undefined = undefined;
const prefix: string = "http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#";
const prefix: string = "https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#";
switch (type) {
case prefix + "Enterprise":
result = this.createEnterprise({ semanticId: "" });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
export default {
"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": "http://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": "http://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#",
"dfc-p": "http://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_ProductOntology.owl#",
"dfc-t": "http://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_TechnicalOntology.owl#",
"dfc-m": "http://github.com/datafoodconsortium/ontology/releases/latest/download/measures.rdf#",
"dfc-pt": "http://github.com/datafoodconsortium/ontology/releases/latest/download/productTypes.rdf#",
"dfc-f": "http://github.com/datafoodconsortium/ontology/releases/latest/download/facets.rdf#",
"dfc-p:hasUnit":{
"@type":"@id"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const address = new Address({
country: "Belgium",
});

const data = '{"@context":"http://static.datafoodconsortium.org/ontologies/context.json","@id":"http://myplatform.com/address/address1","@type":"dfc-b:Address","dfc-b:hasCity":"Brussels","dfc-b:hasCountry":"Belgium","dfc-b:hasPostalCode":"00001","dfc-b:hasStreet":"1, place or Europe"}';
const data = '{"@context":"https://www.datafoodconsortium.org","@id":"http://myplatform.com/address/address1","@type":"dfc-b:Address","dfc-b:hasCity":"Brussels","dfc-b:hasCountry":"Belgium","dfc-b:hasPostalCode":"00001","dfc-b:hasStreet":"1, place or Europe"}';

test('Address:import', async () => {
const imported = await connector.import(data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const allergenCharacteristic = new AllergenCharacteristic({
allergenDimension: allergenDimension
});

const json = `{"@context":"http://static.datafoodconsortium.org/ontologies/context.json","@id":"_:b1","@type":"dfc-b:AllergenCharacteristic","dfc-b:hasAllergenDimension":"dfc-m:Peanuts","dfc-b:hasUnit":"dfc-m:Kilogram","dfc-b:value":"1"}`;
const json = `{"@context":"https://www.datafoodconsortium.org","@id":"_:b1","@type":"dfc-b:AllergenCharacteristic","dfc-b:hasAllergenDimension":"dfc-m:Peanuts","dfc-b:hasUnit":"dfc-m:Kilogram","dfc-b:value":"1"}`;

test('AllergenCharacteristic:import', async () => {
const imported = await connector.import(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Connector from "../lib/Connector.js";

const connector = new Connector();

const json = `{"@context":"http://static.datafoodconsortium.org/ontologies/context.json","@id":"http://myplatform.com/catalog1","@type":"dfc-b:Catalog","dfc-b:lists":{"@id":"http://myplatform.com/catalogItem1"},"dfc-b:maintainedBy":{"@id":"http://myplatform.com/enterprise1"}}`;
const json = `{"@context":"https://www.datafoodconsortium.org","@id":"http://myplatform.com/catalog1","@type":"dfc-b:Catalog","dfc-b:lists":{"@id":"http://myplatform.com/catalogItem1"},"dfc-b:maintainedBy":{"@id":"http://myplatform.com/enterprise1"}}`;

const enterprise = new Enterprise({
connector: connector,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Connector from "../lib/Connector.js";

const connector = new Connector();

const json = `{"@context":"http://static.datafoodconsortium.org/ontologies/context.json","@id":"http://myplatform.com/catalogItem1","@type":"dfc-b:CatalogItem","dfc-b:listedIn":{"@id":"http://myplatform.com/catalog1"},"dfc-b:offeredThrough":"http://myplatform.com/offer1","dfc-b:references":"http://myplatform.com/suppliedProduct1","dfc-b:sku":"sku","dfc-b:stockLimitation":"6.32"}`;
const json = `{"@context":"https://www.datafoodconsortium.org","@id":"http://myplatform.com/catalogItem1","@type":"dfc-b:CatalogItem","dfc-b:listedIn":{"@id":"http://myplatform.com/catalog1"},"dfc-b:offeredThrough":"http://myplatform.com/offer1","dfc-b:references":"http://myplatform.com/suppliedProduct1","dfc-b:sku":"sku","dfc-b:stockLimitation":"6.32"}`;

const suppliedProduct = new SuppliedProduct({
connector: connector,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Loader {
}
const importer = new ConnectorImporterJsonldStream({ documentLoader: new Loader() });

const data = `{"@context":"http://static.datafoodconsortium.org/ontologies/context.json","@graph":[{"@id":"_:b1","@type":"dfc-b:Price","dfc-b:VATrate":"8","dfc-b:hasUnit":"dfc-m:Euro","dfc-b:value":"2.54"},{"@id":"http://myplatform.com/offer1","@type":"dfc-b:Offer","dfc-b:offeredItem":{"@id":"http://myplatform.com/suppliedProduct1"},"dfc-b:offeredTo":{"@id":"http://myplatform.com/customerCategory1"},"dfc-b:price":{"@id":"_:b1"},"dfc-b:stockLimitation":"4.21"}]}`;
const data = `{"@context":"https://www.datafoodconsortium.org","@graph":[{"@id":"_:b1","@type":"dfc-b:Price","dfc-b:VATrate":"8","dfc-b:hasUnit":"dfc-m:Euro","dfc-b:value":"2.54"},{"@id":"http://myplatform.com/offer1","@type":"dfc-b:Offer","dfc-b:offeredItem":{"@id":"http://myplatform.com/suppliedProduct1"},"dfc-b:offeredTo":{"@id":"http://myplatform.com/customerCategory1"},"dfc-b:price":{"@id":"_:b1"},"dfc-b:stockLimitation":"4.21"}]}`;

const imported = await connector.import(data, { importer: importer });
const expected = imported[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const customerCategory = new CustomerCategory({
description: "description"
})

const json = `{"@context":"http://static.datafoodconsortium.org/ontologies/context.json","@id":"http://myplatform.com/customerCategory1","@type":"dfc-b:CustomerCategory","dfc-b:description":"description"}`;
const json = `{"@context":"https://www.datafoodconsortium.org","@id":"http://myplatform.com/customerCategory1","@type":"dfc-b:CustomerCategory","dfc-b:description":"description"}`;

test('CustomerCategory:import', async () => {
const imported = await connector.import(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const enterprise = new Enterprise({
catalogItems: [catalogItem]
});

const json = `{"@context":"http://static.datafoodconsortium.org/ontologies/context.json","@id":"http://myplatform.com/enterprise1","@type":"dfc-b:Enterprise","dfc-b:VATnumber":"vatNumber","dfc-b:defines":"http://myplatform.com/customerCategory1","dfc-b:hasAddress":{"@id":"http://myplatform.com/address1"},"dfc-b:hasDescription":"description","dfc-b:maintains":{"@id":"http://myplatform.com/catalog1"},"dfc-b:manages":"http://myplatform.com/catalogItem1","dfc-b:supplies":"http://myplatform.com/suppliedProduct1"}`;
const json = `{"@context":"https://www.datafoodconsortium.org","@id":"http://myplatform.com/enterprise1","@type":"dfc-b:Enterprise","dfc-b:VATnumber":"vatNumber","dfc-b:defines":"http://myplatform.com/customerCategory1","dfc-b:hasAddress":{"@id":"http://myplatform.com/address1"},"dfc-b:hasDescription":"description","dfc-b:maintains":{"@id":"http://myplatform.com/catalog1"},"dfc-b:manages":"http://myplatform.com/catalogItem1","dfc-b:supplies":"http://myplatform.com/suppliedProduct1"}`;

test('Enterprise:import', async () => {
const imported = await connector.import(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const nutrientCharacteristic = new NutrientCharacteristic({
nutrientDimension: nutrientDimension
});

const json = `{"@context":"http://static.datafoodconsortium.org/ontologies/context.json","@id":"_:b1","@type":"dfc-b:NutrientCharacteristic","dfc-b:hasNutrientDimension":{"@id":"dfc-m:Calcium"},"dfc-b:hasUnit":"dfc-m:Kilogram","dfc-b:value":"10"}`;
const json = `{"@context":"https://www.datafoodconsortium.org","@id":"_:b1","@type":"dfc-b:NutrientCharacteristic","dfc-b:hasNutrientDimension":{"@id":"dfc-m:Calcium"},"dfc-b:hasUnit":"dfc-m:Kilogram","dfc-b:value":"10"}`;

test('NutrientCharacteristic:import', async () => {
const imported = await connector.import(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const offer = new Offer({
stockLimitation: 4.21
});

const json = `{"@context":"http://static.datafoodconsortium.org/ontologies/context.json","@graph":[{"@id":"_:b1","@type":"dfc-b:Price","dfc-b:VATrate":"8","dfc-b:hasUnit":"dfc-m:Euro","dfc-b:value":"2.54"},{"@id":"http://myplatform.com/offer1","@type":"dfc-b:Offer","dfc-b:hasPrice":{"@id":"_:b1"},"dfc-b:offeredItem":{"@id":"http://myplatform.com/suppliedProduct1"},"dfc-b:offeredTo":{"@id":"http://myplatform.com/customerCategory1"},"dfc-b:stockLimitation":"4.21"}]}`;
const json = `{"@context":"https://www.datafoodconsortium.org","@graph":[{"@id":"_:b1","@type":"dfc-b:Price","dfc-b:VATrate":"8","dfc-b:hasUnit":"dfc-m:Euro","dfc-b:value":"2.54"},{"@id":"http://myplatform.com/offer1","@type":"dfc-b:Offer","dfc-b:hasPrice":{"@id":"_:b1"},"dfc-b:offeredItem":{"@id":"http://myplatform.com/suppliedProduct1"},"dfc-b:offeredTo":{"@id":"http://myplatform.com/customerCategory1"},"dfc-b:stockLimitation":"4.21"}]}`;

test('Offer:import', async () => {
const imported = await connector.import(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const order = new Order({
lines: [orderLine]
});

const json = `{"@context":"http://static.datafoodconsortium.org/ontologies/context.json","@id":"http://myplatform.com/order1","@type":"dfc-b:Order","dfc-b:belongsTo":{"@id":"http://myplatform.com/saleSession1"},"dfc-b:date":"date","dfc-b:hasPart":{"@id":"http://myplatform.com/orderLine1"},"dfc-b:orderNumber":"0001","dfc-b:orderedBy":{"@id":"http://myplatform.com/person1"}}`;
const json = `{"@context":"https://www.datafoodconsortium.org","@id":"http://myplatform.com/order1","@type":"dfc-b:Order","dfc-b:belongsTo":{"@id":"http://myplatform.com/saleSession1"},"dfc-b:date":"date","dfc-b:hasPart":{"@id":"http://myplatform.com/orderLine1"},"dfc-b:orderNumber":"0001","dfc-b:orderedBy":{"@id":"http://myplatform.com/person1"}}`;

test('Order:import', async () => {
const imported = await connector.import(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const orderLine = new OrderLine({
quantity: 2
});

const json = `{"@context":"http://static.datafoodconsortium.org/ontologies/context.json","@graph":[{"@id":"_:b1","@type":"dfc-b:Price","dfc-b:VATrate":"19.9","dfc-b:hasUnit":"dfc-m:Euro","dfc-b:value":"5.42"},{"@id":"http://myplatform.com/orderLine1","@type":"dfc-b:OrderLine","dfc-b:concerns":{"@id":"http://myplatform.com/offer1"},"dfc-b:hasPrice":{"@id":"_:b1"},"dfc-b:partOf":{"@id":"http://myplatform.com/order1"},"dfc-b:quantity":"2"}]}`;
const json = `{"@context":"https://www.datafoodconsortium.org","@graph":[{"@id":"_:b1","@type":"dfc-b:Price","dfc-b:VATrate":"19.9","dfc-b:hasUnit":"dfc-m:Euro","dfc-b:value":"5.42"},{"@id":"http://myplatform.com/orderLine1","@type":"dfc-b:OrderLine","dfc-b:concerns":{"@id":"http://myplatform.com/offer1"},"dfc-b:hasPrice":{"@id":"_:b1"},"dfc-b:partOf":{"@id":"http://myplatform.com/order1"},"dfc-b:quantity":"2"}]}`;

test('OrderLine:import', async () => {
const imported = await connector.import(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const person = new Person({
organizations: [enterprise]
});

const json = `{"@context":"http://static.datafoodconsortium.org/ontologies/context.json","@id":"http://myplatform.com/person1","@type":"dfc-b:Person","dfc-b:affiliates":"http://myplatform.com/address/enterprise1","dfc-b:familyName":"Smith","dfc-b:firstName":"John","dfc-b:hasAddress":{"@id":"http://myplatform.com/address/address1"}}`;
const json = `{"@context":"https://www.datafoodconsortium.org","@id":"http://myplatform.com/person1","@type":"dfc-b:Person","dfc-b:affiliates":"http://myplatform.com/address/enterprise1","dfc-b:familyName":"Smith","dfc-b:firstName":"John","dfc-b:hasAddress":{"@id":"http://myplatform.com/address/address1"}}`;

test('Person:import', async () => {
const imported = await connector.import(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const physicalCharacteristic = new PhysicalCharacteristic({
physicalDimension: physicalDimension
});

const json = `{"@context":"http://static.datafoodconsortium.org/ontologies/context.json","@id":"_:b1","@type":"dfc-b:PhysicalCharacteristic","dfc-b:hasPhysicalDimension":"dfc-m:Weight","dfc-b:hasUnit":"dfc-m:Kilogram","dfc-b:value":"100"}`;
const json = `{"@context":"https://www.datafoodconsortium.org","@id":"_:b1","@type":"dfc-b:PhysicalCharacteristic","dfc-b:hasPhysicalDimension":"dfc-m:Weight","dfc-b:hasUnit":"dfc-m:Kilogram","dfc-b:value":"100"}`;

test('PhysicalCharacteristic:import', async () => {
const imported = await connector.import(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const price = new Price({
unit: euro
});

const json = `{"@context":"http://static.datafoodconsortium.org/ontologies/context.json","@id":"_:b1","@type":"dfc-b:Price","dfc-b:VATrate":"8","dfc-b:hasUnit":"dfc-m:Euro","dfc-b:value":"2.54"}`;
const json = `{"@context":"https://www.datafoodconsortium.org","@id":"_:b1","@type":"dfc-b:Price","dfc-b:VATrate":"8","dfc-b:hasUnit":"dfc-m:Euro","dfc-b:value":"2.54"}`;

test('Price:import', async () => {
const imported = await connector.import(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const quantitativeValue = new QuantitativeValue({
unit: kilogram
});

const json = `{"@context":"http://static.datafoodconsortium.org/ontologies/context.json","@id":"_:b1","@type":"dfc-b:QuantitativeValue","dfc-b:hasUnit":"dfc-m:Kilogram","dfc-b:value":"1"}`;
const json = `{"@context":"https://www.datafoodconsortium.org","@id":"_:b1","@type":"dfc-b:QuantitativeValue","dfc-b:hasUnit":"dfc-m:Kilogram","dfc-b:value":"1"}`;

test('QuantitativeValue:import', async () => {
const importedAll = await connector.import(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const saleSession = new SaleSession({
offers: [offer]
});

const json = `{"@context":"http://static.datafoodconsortium.org/ontologies/context.json","@id":"http://myplatform.com/saleSession1","@type":"dfc-b:SaleSession","dfc-b:beginDate":"beginDate","dfc-b:endDate":"endDate","dfc-b:lists":{"@id":"http://myplatform.com/offer1"},"dfc-b:quantity":"5"}`;
const json = `{"@context":"https://www.datafoodconsortium.org","@id":"http://myplatform.com/saleSession1","@type":"dfc-b:SaleSession","dfc-b:beginDate":"beginDate","dfc-b:endDate":"endDate","dfc-b:lists":{"@id":"http://myplatform.com/offer1"},"dfc-b:quantity":"5"}`;

test('SaleSession:import', async () => {
const importedAll = await connector.import(json);
Expand Down
Loading

0 comments on commit 92f8218

Please sign in to comment.