-
Notifications
You must be signed in to change notification settings - Fork 2
/
primer-node.js
106 lines (82 loc) · 3.46 KB
/
primer-node.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/**
* Example usages of the ProvJS library
*
* Copyright 2013 University of Southampton - All rights reserved.
* Licence: To be determined
*/
/* jslint node: true */
"use strict";
var prov = require('./prov');
function primer() {
"use strict";
var doc = prov.document();
// Prefix declarations
var ex = doc.addNamespace("ex", "http://www.example.org#");
var dcterms = doc.addNamespace("dcterms", "http://purl.org/dc/terms/");
var foaf = doc.addNamespace("foaf", "http://xmlns.com/foaf/0.1/");
// Entities
doc.entity("ex:article", ["dcterms:title", "Crime rises in cities"]);
doc.entity("ex:dataSet1");
doc.entity("ex:regionList");
doc.entity("ex:compositionList");
doc.entity("ex:chart1");
// Activities
doc.activity("ex:compile1");
doc.activity("ex:compose1");
doc.activity("ex:illustrate1");
// Usage and Generation
doc.used("ex:compose1", "ex:dataset1");
doc.used("ex:compose1", "ex:regionList");
doc.wasGeneratedBy("ex:composition1", "ex:compose1");
doc.used("ex:illustrate1", "ex:composition1");
doc.wasGeneratedBy("ex:chart1", "ex:illustrate1");
// Agents and Responsibility
doc.wasAssociatedWith("ex:compose1", "ex:derek");
doc.wasAssociatedWith("ex:illustrate1", "ex:derek");
doc.agent("ex:derek",
["prov:type", prov.ns.Person, "foaf:givenName", "Derek",
"foaf:mbox", "<mailto:derek@example.org>"]);
// Roles
doc.agent("ex:chartgen",
["prov:type", prov.ns.Organization,
"foaf:name", "Chart Generators Inc"]);
doc.actedOnBehalfOf("ex:derek", "ex:chartgen");
doc.wasAttributedTo("ex:chart1", "ex:derek");
doc.used("ex:compose1", "ex:dataset1", ["prov:role", ex.qn("dataToCompose")]);
doc.used("ex:compose1", "ex:regionList", ["prov:role", ex.qn("regionsToAggregateBy")]);
doc.wasAssociatedWith("ex:compose1", "ex:derek", ["prov:role", ex.qn("analyst")]);
doc.wasGeneratedBy("ex:composition1", "ex:compose1", ["prov:role", ex.qn("composedData")]);
// Derivation and Revision
doc.entity("ex:dataSet2");
doc.wasDerivedFrom("ex:dataSet2", "ex:dataset1", ["prov:type", prov.ns.Revision]);
doc.wasDerivedFrom("ex:chart2", "ex:dataSet2");
doc.entity("ex:chart2");
doc.wasDerivedFrom("ex:chart2", "ex:chart1", ["prov:type", prov.ns.Revision]);
// Plans
doc.activity("ex:correct1");
doc.agent("ex:edith", ["prov:type", prov.ns.Person]);
doc.entity("ex:instructions");
doc.wasAssociatedWith("ex:correct1", "ex:edith", "ex:instructions");
doc.wasGeneratedBy("ex:dataSet2", "ex:correct1");
// Time
doc.wasGeneratedBy("ex:chart1", "ex:compile1", "2012-03-02T10:30:00");
doc.wasGeneratedBy("ex:chart2", "ex:compile2", "2012-04-01T15:21:00");
doc.activity("ex:correct1", "2012-03-31T09:21:00", "2012-04-01T15:21:00");
// Alternate Entities and Specialization
doc.entity("ex:quoteInBlogEntry-20130326");
doc.wasDerivedFrom("ex:quoteInBlogEntry-20130326", "ex:article", ["prov:type", prov.ns.Quotation]);
doc.entity("ex:articleV1");
doc.specializationOf("ex:articleV1", "ex:article");
doc.specializationOf("ex:articleV2", "ex:article");
doc.alternateOf("ex:articleV2", "ex:articleV1");
return doc.scope;
}
var doc = primer();
var ProvStore = require('./provstore');
var store = new ProvStore(
'https://provenance.ecs.soton.ac.uk/store/api/v0/',
'username',
'apikey'
);
var provjson = doc.getProvJSON();
store.submitDocument('primer-node.js', provjson);