Skip to content

Commit

Permalink
Add: load the resources if the template was published
Browse files Browse the repository at this point in the history
  • Loading branch information
mosoriob committed Jul 2, 2019
1 parent ce9576f commit 8f7f384
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 10 deletions.
17 changes: 13 additions & 4 deletions src/main/java/edu/isi/wings/opmm/Catalog.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,13 @@ public class Catalog {
* URL for the OPMW extensions (is generated by, uses_as, wgb_as, used_as)
*/
private final String extensionsURI;


public String getDomainGraphURI() {
return domainGraphURI;
}

private final String domainGraphURI;

/**
* Default constructor. Assumption: domains are saved in Turtle.
* @param domain
Expand All @@ -95,6 +101,8 @@ public Catalog(String domain, String exportName, String defaultRepositoryFolder,
this.domain = domain;
this.exportName = exportName;
this.defaultRepositoryPath = defaultRepositoryFolder;
this.domainGraphURI = Constants.CATALOG_URI + this.exportName+"/Domain/"+domain;

this.componentCatalogURI = Constants.CATALOG_URI + this.exportName+"/"+domain+"/"+"Component#";
this.dataCatalogURI = Constants.CATALOG_URI + this.exportName+"/"+domain+"/"+"Data#";
this.instanceCatalogURI = Constants.CATALOG_URI + this.exportName+"/"+domain+"/"+"resource/CanonicalInstance/";
Expand Down Expand Up @@ -434,12 +442,13 @@ private String getCatalogTypeForObject(Resource wingsObjType){
* @param path FOLDER path where to export the catalog. If null, the repository will
* use the defaultRepositoryPath. The catalog is exported in TTL.
*/
public void exportCatalog(String path){
public String exportCatalog(String path, String serialization){
String exportPath;
if(path == null) exportPath = this.defaultRepositoryPath;
else exportPath = path;
exportPath +=File.separator+domain;
ModelUtils.exportRDFFile(exportPath, localCatalog, "TURTLE");
ModelUtils.exportRDFFile(exportPath, localCatalog, serialization);
return exportPath;
}

/**
Expand Down Expand Up @@ -473,7 +482,7 @@ public static void main(String[] args){
System.out.println("Local component type for instance http://www.wings-workflows.org/wings-omics-portal/export/users/alyssa/DataAbstractions/components/library.owl#SNPcaller-Polyphred "+
" is "+c.getCatalogTypeForComponentInstanceURI("http://www.wings-workflows.org/wings-omics-portal/export/users/alyssa/DataAbstractions/components/library.owl#SNPcaller-Polyphred"));

c.exportCatalog(null);
c.exportCatalog(null, "RDF/XML");
System.out.println("Catalog exported");


Expand Down
35 changes: 32 additions & 3 deletions src/main/java/edu/isi/wings/opmm/WorkflowExecutionExport.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
import java.io.File;

import org.apache.jena.ontology.Individual;
import org.apache.jena.ontology.OntClass;
import org.apache.jena.ontology.OntModel;
import org.apache.jena.query.QuerySolution;
import org.apache.jena.query.ResultSet;
import org.apache.jena.rdf.model.Literal;
import org.apache.jena.rdf.model.Resource;

import static edu.isi.wings.opmm.Constants.*;

/**
* Class designed to export WINGS workflow execution traces in RDF according to the OPMW-PROV model.
* See: https://www.opmw.org/ontology/
Expand Down Expand Up @@ -258,7 +261,14 @@ private String convertExecutionToOPMW(Individual wingsExecution) {
//Link to expanded template variable
String concreteTemplateVariableURI = PREFIX_EXPORT_RESOURCE + Constants.CONCEPT_DATA_VARIABLE + "/" +
concreteTemplateExport.getTransformedTemplateIndividual().getLocalName() + "_" + variable.getLocalName();
Individual concreteTemplateVariable = concreteTemplateExport.getOpmwModel().getIndividual(concreteTemplateVariableURI);
Individual concreteTemplateVariable;
//if the template has been published the resources are not loaded. So, we create the individual
if(concreteTemplateExport.isTemplatePublished()) {
OntClass aClass = concreteTemplateExport.getOpmwModel().createClass(OPMW_DATA_VARIABLE);
concreteTemplateVariable = concreteTemplateExport.getOpmwModel().createIndividual(concreteTemplateVariableURI, aClass);
} else {
concreteTemplateVariable = concreteTemplateExport.getOpmwModel().getIndividual(concreteTemplateVariableURI);
}
executionArtifact.addProperty(opmwModel.createAnnotationProperty(Constants.OPMW_PROP_CORRESPONDS_TO_TEMPLATE_ARTIFACT),
concreteTemplateVariable);
}
Expand All @@ -280,7 +290,17 @@ private String convertExecutionToOPMW(Individual wingsExecution) {
//link parameter to the concrete template
String concreteTemplateParameterURI = PREFIX_EXPORT_RESOURCE + Constants.CONCEPT_PARAMETER_VARIABLE + "/" +
concreteTemplateExport.getTransformedTemplateIndividual().getLocalName() + "_" + param.getLocalName();
Individual concreteTemplateParameter = concreteTemplateExport.getOpmwModel().getIndividual(concreteTemplateParameterURI);

//if the template has been published the resources are not loaded. So, we create the individual
Individual concreteTemplateParameter;
if(concreteTemplateExport.isTemplatePublished()) {
OntClass aClass = concreteTemplateExport.getOpmwModel().createClass(OPMW_PARAMETER_VARIABLE);
concreteTemplateParameter = concreteTemplateExport.getOpmwModel().createIndividual(concreteTemplateParameterURI, aClass);
}
else {
concreteTemplateParameter = concreteTemplateExport.getOpmwModel().getIndividual(concreteTemplateParameterURI);
}

parameter.addProperty(opmwModel.createAnnotationProperty(Constants.OPMW_PROP_CORRESPONDS_TO_TEMPLATE_ARTIFACT),
concreteTemplateParameter);

Expand All @@ -290,7 +310,16 @@ private String convertExecutionToOPMW(Individual wingsExecution) {
//link step to concrete template individual
String concreteTemplateProcessURI = PREFIX_EXPORT_RESOURCE + Constants.CONCEPT_WORKFLOW_TEMPLATE_PROCESS + "/" +
concreteTemplateExport.getTransformedTemplateIndividual().getLocalName() + "_" + wingsStep.getLocalName();
Individual concreteTemplateProcess = concreteTemplateExport.getOpmwModel().getIndividual(concreteTemplateProcessURI);

//if the template has been published the resources are not loaded. So, we create the individual
Individual concreteTemplateProcess;
if(concreteTemplateExport.isTemplatePublished()) {
OntClass ontClass = concreteTemplateExport.getOpmwModel().createClass(OPMW_WORKFLOW_TEMPLATE_PROCESS);
concreteTemplateProcess = concreteTemplateExport.getOpmwModel().createIndividual(concreteTemplateProcessURI, ontClass);
}
else {
concreteTemplateProcess = concreteTemplateExport.getOpmwModel().getIndividual(concreteTemplateProcessURI);
}
executionStep.addProperty(opmwModel.createAnnotationProperty(Constants.OPMW_PROP_CORRESPONDS_TO_TEMPLATE_PROCESS),
concreteTemplateProcess);
}
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/edu/isi/wings/opmm/WorkflowTemplateExport.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ public class WorkflowTemplateExport {
private final String PREFIX_EXPORT_RESOURCE;
private final String endpointURI;//URI of the endpoint where everything is published.
private Individual transformedTemplate = null;

public boolean isTemplatePublished() {
return isTemplatePublished;
}

private boolean isTemplatePublished;//boolean value to know if the template has already been published on the repository
private final String exportName;//needed to pass it on to template exports
private WorkflowTemplateExport abstractTemplateExport;//a template may implement a template, and therefore publish its abstract template (on a separate file)
Expand Down Expand Up @@ -427,8 +432,6 @@ public static void main(String[] args){
Catalog c = new Catalog(domain, "testExport", "domains", taxonomyURL);
WorkflowTemplateExport w = new WorkflowTemplateExport(templatePath, c, "exportTest", "http://localhost:3030/test/query", domain);
w.exportAsOPMW(".", "TTL");
c.exportCatalog(null);


c.exportCatalog(null, "RDF/XML");
}
}

0 comments on commit 8f7f384

Please sign in to comment.