diff --git a/src/main/java/edu/isi/wings/opmm/Catalog.java b/src/main/java/edu/isi/wings/opmm/Catalog.java index 41f42ad..abc87e8 100644 --- a/src/main/java/edu/isi/wings/opmm/Catalog.java +++ b/src/main/java/edu/isi/wings/opmm/Catalog.java @@ -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 @@ -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/"; @@ -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; } /** @@ -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"); diff --git a/src/main/java/edu/isi/wings/opmm/WorkflowExecutionExport.java b/src/main/java/edu/isi/wings/opmm/WorkflowExecutionExport.java index 9108431..0142108 100644 --- a/src/main/java/edu/isi/wings/opmm/WorkflowExecutionExport.java +++ b/src/main/java/edu/isi/wings/opmm/WorkflowExecutionExport.java @@ -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/ @@ -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); } @@ -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); @@ -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); } diff --git a/src/main/java/edu/isi/wings/opmm/WorkflowTemplateExport.java b/src/main/java/edu/isi/wings/opmm/WorkflowTemplateExport.java index a12e87b..253d932 100644 --- a/src/main/java/edu/isi/wings/opmm/WorkflowTemplateExport.java +++ b/src/main/java/edu/isi/wings/opmm/WorkflowTemplateExport.java @@ -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) @@ -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"); } }