Skip to content

Commit

Permalink
Fix: edited to PROV
Browse files Browse the repository at this point in the history
  • Loading branch information
mosoriob committed Jul 3, 2019
1 parent 8f7f384 commit ac49ad4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
8 changes: 5 additions & 3 deletions src/main/java/edu/isi/wings/opmm/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,11 @@ public class Constants {
//new
public static final String OPMW_PROP_HAD_SOFTWARE_CONFIGURATION = PREFIX_OPMW+"hadSoftwareConfiguration";
public static final String OPMW_PROP_HAS_MAIN_SCRIPT = PREFIX_OPMW+"hasMainScript";



public static final String OPMW_PROP_IS_PROCESS_OF_EXECUTION = PREFIX_OPMW+"isProcessOfExecution";
public static final String OPMW_PROP_IS_ARTIFACT_OF_EXECUTION = PREFIX_OPMW+"isArtifactOfExecution";



public static final String OPMW_PROP_IMPLEMENTS_TEMPLATE = PREFIX_OPMW +"implementsTemplate";
public static final String OPMW_PROP_IMPLEMENTS_TEMPLATE_PROCESS = PREFIX_OPMW+"implementsTemplateProcess";
public static final String OPMW_PROP_IMPLEMENTS_TEMPLATE_ARTIFACT = PREFIX_OPMW+"implementsTemplateArtifact";
Expand Down
1 change: 1 addition & 0 deletions src/main/java/edu/isi/wings/opmm/ModelUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public static ResultSet queryLocalRepository(String queryIn, OntModel repository
// Execute the query and obtain results
QueryExecution qe = QueryExecutionFactory.create(query, repository);
ResultSet rs = qe.execSelect();
System.out.println(queryIn);
return rs;
}
/**
Expand Down
27 changes: 17 additions & 10 deletions src/main/java/edu/isi/wings/opmm/WorkflowExecutionExport.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ private String convertExecutionToOPMW(Individual wingsExecution) {
weInstance.addProperty(opmwModel.createProperty(Constants.OPMW_DATA_PROP_HAS_ORIGINAL_EXECUTION_FILE), wingsExecution.getURI());
//hasTime, endTime and execution status.
String queryExecutionMetadata = QueriesWorkflowExecutionExport.getWINGSExecutionMetadata(wingsExecution.getURI());
System.out.println("Queries queryExecutionMetadata");
ResultSet rs = ModelUtils.queryLocalRepository(queryExecutionMetadata, wingsExecutionModel);
//there is only 1 execution per file
if (rs.hasNext()) {
Expand All @@ -154,20 +155,21 @@ private String convertExecutionToOPMW(Individual wingsExecution) {
String user = wingsExecution.getURI().split("/users/")[1];
user = user.substring(0, user.indexOf("/"));
String userURI = PREFIX_EXPORT_RESOURCE + Constants.CONCEPT_AGENT + "/" + user;
Individual userInstance = opmwModel.createClass(Constants.OPM_AGENT).createIndividual(userURI);
Individual userInstance = opmwModel.createClass(Constants.PROV_AGENT).createIndividual(userURI);
userInstance.addLabel(user, null);
weInstance.addProperty(opmwModel.createProperty(Constants.PROP_HAS_CONTRIBUTOR), userInstance);

//metadata of the execution system (WINGS)
//TODO: Ask Varun to include extra metadata on whether the exec was on Pegasus/OODT, etc.
String wfSystemURI = PREFIX_EXPORT_RESOURCE + Constants.CONCEPT_AGENT + "/" + "WINGS";
Individual wingsInstance = opmwModel.createClass(Constants.OPM_AGENT).createIndividual(wfSystemURI);
Individual wingsInstance = opmwModel.createClass(Constants.PROV_AGENT).createIndividual(wfSystemURI);
weInstance.addProperty(opmwModel.createProperty(Constants.PROP_HAS_CREATOR), wingsInstance);
wingsInstance.addProperty(opmwModel.createProperty(Constants.PROV_ACTED_ON_BEHALF_OF), userInstance);
wingsInstance.addLabel("WINGS", null);

//get expanded template loaded in local model (for parameter linking)
String queryExpandedTemplate = QueriesWorkflowExecutionExport.getWINGSExpandedTemplate();
System.out.println("Queries queryExpandedTemplate");
rs = ModelUtils.queryLocalRepository(queryExpandedTemplate, wingsExecutionModel);
String expandedTemplateURI = null;
if (rs.hasNext()) {
Expand All @@ -183,6 +185,7 @@ private String convertExecutionToOPMW(Individual wingsExecution) {

//transform all steps and data dependencies (params are in expanded template)
String queryExecutionStepMetadata = QueriesWorkflowExecutionExport.getWINGSExecutionStepsAndMetadata();
System.out.println("Queries queryExecutionStepMedata");
rs = ModelUtils.queryLocalRepository(queryExecutionStepMetadata, wingsExecutionModel);
while (rs.hasNext()) {
QuerySolution qs = rs.next();
Expand Down Expand Up @@ -233,9 +236,11 @@ private String convertExecutionToOPMW(Individual wingsExecution) {
Constants.OPMW_SOFTWARE_SCRIPT, mainScriptURI);
stepConfig.addProperty(opmwModel.createProperty(Constants.OPMW_PROP_HAS_MAIN_SCRIPT), mainScript);
executionStep.addProperty(opmwModel.createProperty(Constants.OPMW_PROP_HAD_SOFTWARE_CONFIGURATION), stepConfig);
executionStep.addProperty(opmwModel.createProperty(Constants.OPM_PROP_WCB), wingsInstance);
executionStep.addProperty(opmwModel.createProperty(Constants.PROV_WAS_ASSOCIATED_WITH), wingsInstance);

//for each step get its i/o (plan)
String stepVariables = QueriesWorkflowExecutionExport.getWINGSExecutionStepI_O(wingsStep.getURI());
System.out.println("Queries step variables");
ResultSet rsVar = ModelUtils.queryLocalRepository(stepVariables, wingsExecutionModel);
while (rsVar.hasNext()) {
QuerySolution qsVar = rsVar.next();
Expand All @@ -251,12 +256,13 @@ private String convertExecutionToOPMW(Individual wingsExecution) {


//add as part of the account
executionArtifact.addProperty(opmwModel.createProperty(Constants.OPM_PROP_ACCOUNT), weInstance);
executionArtifact.addProperty(opmwModel.createProperty(Constants.OPMW_PROP_IS_ARTIFACT_OF_EXECUTION), weInstance);
if (varType.equals(Constants.P_PLAN_PROP_HAS_INPUT)) {
//add step used artifact
executionStep.addProperty(opmwModel.createProperty(Constants.OPM_PROP_USED), executionArtifact);
executionStep.addProperty(opmwModel.createProperty(Constants.PROV_USED), executionArtifact);

} else if (varType.equals(Constants.P_PLAN_PROP_HAS_OUTPUT)) {
executionArtifact.addProperty(opmwModel.createProperty(Constants.OPM_PROP_WGB), executionStep);
executionArtifact.addProperty(opmwModel.createProperty(Constants.PROV_WGB), executionStep);
}
//Link to expanded template variable
String concreteTemplateVariableURI = PREFIX_EXPORT_RESOURCE + Constants.CONCEPT_DATA_VARIABLE + "/" +
Expand All @@ -275,6 +281,7 @@ private String convertExecutionToOPMW(Individual wingsExecution) {
//Parameters are specified in the expanded template. The current step is specified with the expanded template URI, same process id.
String wingsExpandedTempProcessURI = expandedTemplateURI + wingsStep.getLocalName();
String queryParams = QueriesWorkflowExecutionExport.getWINGSParametersForStep(wingsExpandedTempProcessURI);
System.out.println("Queries params variables");
ResultSet params = ModelUtils.queryLocalRepository(queryParams, concreteTemplateExport.getWingsTemplateModel());
while (params.hasNext()) {
QuerySolution nextP = params.next();
Expand All @@ -285,8 +292,8 @@ private String convertExecutionToOPMW(Individual wingsExecution) {
Individual parameter = opmwModel.createClass(Constants.OPMW_WORKFLOW_EXECUTION_ARTIFACT).createIndividual(parameterURI);
parameter.addLabel(param.getLocalName(), null);
parameter.addProperty(opmwModel.createProperty(Constants.OPMW_DATA_PROP_HAS_VALUE), paramValue);
parameter.addProperty(opmwModel.createProperty(Constants.OPM_PROP_ACCOUNT), weInstance);
executionStep.addProperty(opmwModel.createProperty(Constants.OPM_PROP_USED), parameter);
parameter.addProperty(opmwModel.createProperty(Constants.OPMW_PROP_IS_ARTIFACT_OF_EXECUTION), weInstance);
executionStep.addProperty(opmwModel.createProperty(Constants.PROV_USED), parameter);
//link parameter to the concrete template
String concreteTemplateParameterURI = PREFIX_EXPORT_RESOURCE + Constants.CONCEPT_PARAMETER_VARIABLE + "/" +
concreteTemplateExport.getTransformedTemplateIndividual().getLocalName() + "_" + param.getLocalName();
Expand All @@ -306,7 +313,7 @@ private String convertExecutionToOPMW(Individual wingsExecution) {

}
//link step to execution
executionStep.addProperty(opmwModel.createProperty(Constants.OPM_PROP_ACCOUNT), weInstance);
executionStep.addProperty(opmwModel.createProperty(Constants.OPMW_PROP_IS_PROCESS_OF_EXECUTION), weInstance);
//link step to concrete template individual
String concreteTemplateProcessURI = PREFIX_EXPORT_RESOURCE + Constants.CONCEPT_WORKFLOW_TEMPLATE_PROCESS + "/" +
concreteTemplateExport.getTransformedTemplateIndividual().getLocalName() + "_" + wingsStep.getLocalName();
Expand Down Expand Up @@ -341,7 +348,7 @@ private String uploadFile(String filePath) {
return mainScriptFile.getAbsolutePath();
}
upload.addFilePart("file_param_1", mainScriptFile);
return upload.finish();
return upload.finish().replaceAll("\n", "");
} catch (Exception e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ private String convertTemplateToOPMW(Individual wingsTemplate, int versionNumber
wtInstance.addLiteral(opmwModel.createProperty(Constants.OPMW_DATA_PROP_HAS_DOCUMENTATION), docContent);
Literal contrib = qs.getLiteral("?contrib");
if (contrib != null){
OntClass agentClass = opmwModel.createClass(Constants.OPM_AGENT);
OntClass agentClass = opmwModel.createClass(Constants.PROV_AGENT);
try {
Individual contributor = agentClass.createIndividual(Constants.PREFIX_EXPORT_RESOURCE+
Constants.CONCEPT_AGENT+"/"+ URLEncoder.encode(""+contrib, "UTF-8"));
Expand Down

0 comments on commit ac49ad4

Please sign in to comment.