Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added simple root Event and fixed OGBillOfLading Generator #164

Merged
merged 15 commits into from
Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions packages/traceability-schemas/schemas/Event.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"$id": "https://w3id.org/traceability/schemas/Event.json",
"$schema": "https://json-schema.org/draft-07/schema#",
"$comment": "{\"term\": \"Event\", \"@id\": \"https://schema.org/Event\"}",
"title": "Organization",
"description": "An event such as transformation, aggregation, commission etc.",
mkhraisha marked this conversation as resolved.
Show resolved Hide resolved
"type": "object",
"properties": {
"@context": {
"type": "array"
},
"type": {
"oneOf": [
{
"type": "string"
},
{
"type": "array"
}
]
},
"eventType": {
"$comment": "{\"term\": \"eventType\", \"@id\": \"https://schema.org/value\"}",
"title": "Event Type",
"description": "Type of Event",
mkhraisha marked this conversation as resolved.
Show resolved Hide resolved
"type": "string"
},
"eventId": {
"$comment": "{\"term\": \"eventId\", \"@id\": \"https://schema.org/identifier\"}",
"title": "Event Identifier",
"description": "Event Identifier.",
mkhraisha marked this conversation as resolved.
Show resolved Hide resolved
"type": "string"
},
"actor": {
"$comment": "{\"term\": \"actor\", \"@id\": \"https://w3id.org/traceability#Organization\", \"@type\": \"https://schema.org/ItemList\"}",
"title": "Actor",
"description": "The organization performing the activity.",
"type": "array",
"items": {
"$ref": "https://w3id.org/traceability/schemas/Organization.json"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want this to be an org? or is entity possibly better? We at least also deal with individuals in the supply chain where Person sometimes is a better representation than Organization

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had misgivings on whether we should have two fields or just one for this, I wanted initially to have an actor and an actingOrg field.

An entity might solve the problem. good shout

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer use of Entity

}
},
"eventLocation": {
"$comment": "{\"term\": \"eventLocation\", \"@id\": \"https://w3id.org/traceability#eventLocation\"}",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure we want to be defining "eventLocation"... can we use an existing ontology for this field?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 I think this should be a Place

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

absolutely should be place

"title": "Event Location",
"description": "Location where event took place",
mkhraisha marked this conversation as resolved.
Show resolved Hide resolved
"$ref": "https://w3id.org/traceability/schemas/Place.json"
},
"eventTime": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we may want to actually record a few more things here (possibly optionally), e.g. scheduled or planned start time, planned duration, actual start time, actual end time, etc. open on this.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer ability to record at a minimum

  1. event start time
  2. event end time

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this makes sense to split up, probably another base object that encapsulates eventTime that would have the planned start/duration etc.

"$comment": "{\"term\": \"eventTime\", \"@id\": \"https://schema.org/DateTime#v2\"}",
"title": "Event Time",
"description": "Time when the event took place",
mkhraisha marked this conversation as resolved.
Show resolved Hide resolved
"type": "string"
},
"products": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to have to mull over use of Product here. I think it is probably correct, but also thinking about raw materials becoming a product etc.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see note from @OR13 below - should this be GS1 or schema.org? Other aspects of the vocab are utilizing schema.org

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider "inputs" (raw materials, outputs from other processes/sources, etc.) and "outputs" (refined version of inputs becoming inputs to other processes/consumers, finished products, etc.). These can then be easily turned into a complex trace from most-basic-origin (e.g., extraction of various ores from deep underground) to most-refined-consumable (e.g., a smartphone, tablet, or computer)...

"$comment": "{\"term\": \"products\", \"@id\": \"https://www.gs1.org/voc/Product\"}",
mkhraisha marked this conversation as resolved.
Show resolved Hide resolved
"title": "Products",
"description": "Products referenced by the event",
mkhraisha marked this conversation as resolved.
Show resolved Hide resolved
"type": "array",
"items": {
"$ref": "https://w3id.org/traceability/schemas/Product.json"
}
}
},
"additionalProperties": false,
"examples": []
}
33 changes: 33 additions & 0 deletions packages/traceability-schemas/src/generators/Event.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const faker = require('faker');
const { getOrganization } = require('./Organization');
const { getPlace } = require('./Place');
const { getProduct } = require('./Product');

const getEvent = () => {
const eventType = 'commission';
const eventId = '12345';
const actor = [getOrganization(), getOrganization()];
mkhraisha marked this conversation as resolved.
Show resolved Hide resolved

delete actor[0]['@context'];
delete actor[1]['@context'];
const eventLocation = getPlace();
delete eventLocation['@context'];
const eventTime = '';
const products = [getProduct(), getProduct()];
delete products[0]['@context'];
delete products[1]['@context'];

const example = {
'@context': ['https://w3id.org/traceability/v1'],
type: 'Event',
eventType,
eventId,
actor,
eventLocation,
eventTime,
products,
};
return example;
};

module.exports = { getEvent };
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const _ = require('lodash');

const { generator, schemas } = require('../data/util/data');
const { getBillOfLading } = require('./BillOfLading');
const { getMeasuredValue } = require('./MeasuredValue');
const { getObservation } = require('./Observation');
const { getPlace } = require('./Place');

Expand Down Expand Up @@ -61,8 +62,8 @@ const getOGBillOfLading = () => {
totalOrderValue: '1500',
freightChargeTerms: 'Freight Prepaid',
batchNumber: '12345678',
openingVolume: '123',
closingVolume: '222',
openingVolume: getMeasuredValue(),
closingVolume: getMeasuredValue(),
observation,
};
const validate = ajv.compile(schemas.OGBillOfLading);
Expand Down