Steps involved in creating OPM (using Plier API):
Hereafter, we enumerate the different steps involved in building and storing an OPM graph.
The complete source code of this example can be downloaded from:
OpmDBTestSample (Victoria Sponge Cake Provenance)
- Configure and Build a Session Factory and start a Transaction. (configuration is based on a setting file 'hibernate.cfg.xml')
PersistenceManager persistenceManager = PersistenceManager.instance();
persistenceManager.init("hibernate.cfg.xml");
- Create an OPM Graph and set its values:
OPMGraph opmGraph= new OPMGraph();
opmGraph.setId("Victoria Sponge Cake Provenance");
- Create Acounts and add them to the accountList:
Accounts accountList = new Accounts();
Account account1 = new Account();
account1.setId("account 1");
accountList.getAccount().add(account1);
- Create Agents and add them to the agentList:
Agents agentList = new Agents();
Agent agent1 = new Agent();
agent1.setId("John Doe");
agent1.getAccount().add(account1);
agentList.getAgent().add(agent1);
- Create Processes, link them to accounts, and add them to the processtList:
Processes processList = new Processes();
Process process = new Process();
process.setId("baking cake with ingredients");
Date d = new Date(Long.parseLong("1301045589371"));
process.setStartTime(d);
d = new Date(Long.parseLong("1301046300776"));
process.setTime(new Date());
process.getAccount().add(account1);
processList.getProcess().add(process);
- Create Artifacts, link them to accounts, and add them to the artifactList:
Artifacts artifactList = new Artifacts();
Artifact a1 = new Artifact();
a1.setId("butter"); a1.setValue("100 g butter"); a1.getAccount().add(account1);
Artifact a2 = new Artifact();
. . .
artifactList.getArtifact().add(a1); . . .
- Create Causal Dependencies and link them to corresponding Roles:
CausalDependencies cdList = new CausalDependencies();
Used u1 = new Used();
u1.setId("used1"); u1.setCause(a1); u1.setEffect(process); u1.setRole("butter");
Used used2= new Used();
. . .
cdList.getDependency().add(u1); cdList.getDependency().add(u2); ...
WasGeneratedBy wgb1 = new WasGeneratedBy();
wgb1.setId("wgb1"); wgb1.setCause(process); wgb1.setEffect(a5); wgb1.setRole("(cake)");
cdList.getDependency().add(wgb1);
WasControlledBy wcb1 = new WasControlledBy();
wcb1.setId("wcb1"); wcb1.setCause(agent1); wcb1.setEffect(process); wcb1.setRole("baker");
cdList.getDependency().add(wcb1);
- Create Process Events using Annotation/Property concepts:
Property p1 = new Property();
p1.setUri("STARTED"); p1.setValue("1301045589371");
Property p2 = new Property();
p2.setUri("COMPLETED"); p2.setValue("1301046589371");
Annotations annotationList = new Annotations();
Annotation ann = new Annotation();
ann.setLocalSubject("STATUS"); ann.setId(process.getId());
ann.getPropertyList().add(p1); ann.getPropertyList().add(p2);
annotationList.getAnnotation().add(ann);
process.getAnnotation().add(ann);
- Add the list of Accounts, Agents, Artifacts, processes, dependencies, and Annotations to the graph:
graph.setAccounts(accountList);
graph.setAgents(agentList);
graph.setProcesses(processList);
graph.setArtifacts(artifactList);
graph.setCausalDependencies(cdList);
graph.setAnnotations(annotationList);
- Store the OPM graph and close the session:
persistenceManager.persist(createOPM());
--
AmmarBenabdelkader - 10 Jan 2011
to top