Skip to content

Commit

Permalink
Fix: add domain from config
Browse files Browse the repository at this point in the history
Close: #19 #12
  • Loading branch information
mosoriob committed Jun 18, 2019
1 parent 65f1c6b commit 95819a0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
7 changes: 4 additions & 3 deletions src/main/java/edu/isi/wings/opmm/WorkflowExecutionExport.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void setUploadMaxSize(long uploadMaxSize) {
private String uploadPassword;
private long uploadMaxSize;
//private OntModel provModel;//TO IMPLEMENT AT THE END. Can it be done with constructs?

private String domain;
/**
* Default constructor for exporting executions
*
Expand All @@ -59,7 +59,7 @@ public void setUploadMaxSize(long uploadMaxSize) {
* @param exportName
* @param endpointURI
*/
public WorkflowExecutionExport(String executionFile, Catalog catalog, String exportName, String endpointURI) {
public WorkflowExecutionExport(String executionFile, Catalog catalog, String exportName, String endpointURI, String domain) {
this.wingsExecutionModel = ModelUtils.loadModel(executionFile);
this.opmwModel = ModelUtils.initializeModel(opmwModel);
this.componentCatalog = catalog;
Expand All @@ -72,6 +72,7 @@ public WorkflowExecutionExport(String executionFile, Catalog catalog, String exp
this.uploadUsername = uploadUsername;
this.uploadPassword = uploadPassword;
isExecPublished = false;
this.domain = domain;
}

/**
Expand Down Expand Up @@ -170,7 +171,7 @@ private String convertExecutionToOPMW(Individual wingsExecution) {
expandedTemplateURI = rs.next().getResource("?expTemplate").getNameSpace();//the namespace is better for later.
System.out.println("Execution expanded template " + expandedTemplateURI + " loaded successfully");
//publish expanded template. The expanded template will publish the template if necessary.
concreteTemplateExport = new WorkflowTemplateExport(expandedTemplateURI, this.componentCatalog, this.exportName, this.endpointURI);
concreteTemplateExport = new WorkflowTemplateExport(expandedTemplateURI, this.componentCatalog, this.exportName, this.endpointURI, this.domain);
concreteTemplateExport.transform();
System.out.println(concreteTemplateExport.getTransformedTemplateIndividual());
} else {
Expand Down
17 changes: 8 additions & 9 deletions src/main/java/edu/isi/wings/opmm/WorkflowTemplateExport.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class WorkflowTemplateExport {
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)

private String domain;
//private OntModel PplanModel;//TO IMPLEMENT AT THE END. Can it be done with constructs?


Expand All @@ -43,14 +43,15 @@ public class WorkflowTemplateExport {
* @param exportName name of the dataset to export (will be part of the URI)
* @param endpointURI
*/
public WorkflowTemplateExport(String templateFile, Catalog catalog, String exportName, String endpointURI) {
public WorkflowTemplateExport(String templateFile, Catalog catalog, String exportName, String endpointURI, String domain) {
this.wingsTemplateModel = ModelUtils.loadModel(templateFile);
this.opmwModel = ModelUtils.initializeModel(opmwModel);
this.componentCatalog = catalog;
PREFIX_EXPORT_RESOURCE = Constants.PREFIX_EXPORT_GENERIC+exportName+"/"+"resource/";
this.endpointURI = endpointURI;
isTemplatePublished = false;
this.exportName = exportName;
this.domain = domain;
}

/**
Expand Down Expand Up @@ -154,10 +155,7 @@ private String convertTemplateToOPMW(Individual wingsTemplate, int versionNumber
wtInstance.addLiteral(opmwModel.createProperty(Constants.OWL_VERSION_INFO), versionNumber);
//template MD5
wtInstance.addLiteral(opmwModel.createProperty(Constants.OPMW_DATA_PROP_HAS_MD5), HashUtils.createMD5ForTemplate(wingsTemplate,this.wingsTemplateModel, this.componentCatalog.getWINGSDomainTaxonomy()));
//domain to which this template belongs. It can bee xtracted from the template path.
String domain = wingsTemplate.getNameSpace().split("/workflows/")[0];
domain = domain.substring(domain.lastIndexOf("/")+1);
wtInstance.addLiteral(opmwModel.createProperty(Constants.OPMW_DATA_PROP_HAS_DOMAIN),domain);
wtInstance.addLiteral(opmwModel.createProperty(Constants.OPMW_DATA_PROP_HAS_DOMAIN),this.domain);
//add the native system template as a reference.
opmwModel.add(wtInstance,opmwModel.createProperty(Constants.OPMW_DATA_PROP_HAS_NATIVE_SYSTEM_TEMPLATE),wingsTemplate.getURI(),XSDDatatype.XSDanyURI);
//state that the template was created in WINGS
Expand Down Expand Up @@ -205,7 +203,7 @@ private String convertTemplateToOPMW(Individual wingsTemplate, int versionNumber
if(rsD.hasNext()){
//publish abstract template with the URI taken from derivation
QuerySolution qs = rsD.next();
this.abstractTemplateExport = new WorkflowTemplateExport(qs.getResource("?dest").getURI(), componentCatalog, exportName, endpointURI);
this.abstractTemplateExport = new WorkflowTemplateExport(qs.getResource("?dest").getURI(), componentCatalog, exportName, endpointURI, domain);
abstractTemplateExport.transform();
abstractTemplateInstance = abstractTemplateExport.getTransformedTemplateIndividual();
System.out.println("Abstract template: "+abstractTemplateInstance.getURI());
Expand Down Expand Up @@ -423,8 +421,9 @@ public static void main(String[] args){
//set up on datascience4all
String taxonomyURL = "http://datascience4all.org/wings-portal/export/users/admin/mint/components/library.owl";
String templatePath = "http://datascience4all.org/wings-portal/export/users/admin/mint/workflows/storyboard_isi_cag_64kpzcza7.owl";
Catalog c = new Catalog("mint", "testExport", "domains", taxonomyURL);
WorkflowTemplateExport w = new WorkflowTemplateExport(templatePath, c, "exportTest", "http://localhost:3030/test/query");
String domain = "mint";
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);

Expand Down

0 comments on commit 95819a0

Please sign in to comment.