diff --git a/.gitignore b/.gitignore index 9a2a6fa2..eb3b41fa 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,98 @@ portal/src/main/webapp/lib/plupload portal/src/main/webapp/lib/extjs bin *.iml +# Created by https://www.toptal.com/developers/gitignore/api/maven +# Edit at https://www.toptal.com/developers/gitignore?templates=maven + +### Maven ### +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +# https://github.com/takari/maven-wrapper#usage-without-binary-jar +.mvn/wrapper/maven-wrapper.jar + +# Eclipse m2e generated files +# Eclipse Core +.project +# JDT-specific (Eclipse Java Development Tools) +.classpath + +# End of https://www.toptal.com/developers/gitignore/api/maven + +# Created by https://www.toptal.com/developers/gitignore/api/eclipse +# Edit at https://www.toptal.com/developers/gitignore?templates=eclipse + +### Eclipse ### +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.settings/ +.loadpath +.recommenders + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# PyDev specific (Python IDE for Eclipse) +*.pydevproject + +# CDT-specific (C/C++ Development Tooling) +.cproject + +# CDT- autotools +.autotools + +# Java annotation processor (APT) +.factorypath + +# PDT-specific (PHP Development Tools) +.buildpath + +# sbteclipse plugin +.target + +# Tern plugin +.tern-project + +# TeXlipse plugin +.texlipse + +# STS (Spring Tool Suite) +.springBeans + +# Code Recommenders +.recommenders/ + +# Annotation Processing +.apt_generated/ +.apt_generated_test/ + +# Scala IDE specific (Scala & Java development for Eclipse) +.cache-main +.scala_dependencies +.worksheet + +# Uncomment this line if you wish to ignore the project description file. +# Typically, this file would be tracked if it contains build/dependency configurations: +#.project + +### Eclipse Patch ### +# Spring Boot Tooling +.sts4-cache/ + +# End of https://www.toptal.com/developers/gitignore/api/eclipse + diff --git a/core/pom.xml.versionsBackup b/core/pom.xml.versionsBackup deleted file mode 100644 index 13ca4ff6..00000000 --- a/core/pom.xml.versionsBackup +++ /dev/null @@ -1,101 +0,0 @@ - - - 4.0.0 - edu.isi.wings - wings-core - 4.2.6 - Wings Core - pom - Wings project for the IKCAP group - http://www.wings-workflows.org - - USC/Information Sciences Institute - http://www.isi.edu - - - - 4.2.5 - 1.8 - 1.8 - - - - - varunr - Varun Ratnakar - varunr@isi.edu - http://www.isi.edu/~varunr - ISI - http://www.isi.edu - - Researcher - Developer - - 0 - - - dgarijo - Daniel Garijo - dgarijo@fi.upm.es - UPM - http://mayor2.dia.fi.upm.es/oeg-upm/ - - Researcher - Developer - - 1 - - - moody - Joshua Moody - moody@isi.edu - ISI - http://www.isi.edu - - Researcher - Developer - - -8 - - - cfritz - Christian Fritz - cfritz@isi.edu - http://www.cs.toronto.edu/~fritz/ - ISI - http://www.isi.edu - - Post Doc - Researcher - Developer - - -8 - - - jihie - Jihie Kim - jihie@isi.edu - http://www.isi.edu/~jihie/ - ISI - http://www.isi.edu - - Professor Computer Science - Researcher - Developer - - -8 - - - - - - github - GitHub OWNER Apache Maven Packages - https://maven.pkg.github.com/KnowledgeCaptureAndDiscovery/wings - - - - diff --git a/planner/.classpath b/planner/.classpath index 16d4af0d..94fadc55 100644 --- a/planner/.classpath +++ b/planner/.classpath @@ -9,8 +9,9 @@ - + + @@ -28,7 +29,29 @@ - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/planner/.settings/org.eclipse.jdt.core.prefs b/planner/.settings/org.eclipse.jdt.core.prefs index cac0df4d..26aef1a5 100644 --- a/planner/.settings/org.eclipse.jdt.core.prefs +++ b/planner/.settings/org.eclipse.jdt.core.prefs @@ -7,5 +7,6 @@ org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore +org.eclipse.jdt.core.compiler.processAnnotations=enabled org.eclipse.jdt.core.compiler.release=disabled org.eclipse.jdt.core.compiler.source=1.8 diff --git a/planner/pom.xml b/planner/pom.xml index cdafd6ea..d2337291 100644 --- a/planner/pom.xml +++ b/planner/pom.xml @@ -1,6 +1,7 @@ - + 4.0.0 wings-planner Wings Planner @@ -55,15 +56,6 @@ - - - github - Github - https://maven.pkg.github.com/KnowledgeCaptureAndDiscovery/ontapi - - - - diff --git a/planner/pom.xml.versionsBackup b/planner/pom.xml.versionsBackup deleted file mode 100644 index 18eea3bc..00000000 --- a/planner/pom.xml.versionsBackup +++ /dev/null @@ -1,142 +0,0 @@ - - - 4.0.0 - wings-planner - Wings Planner - jar - Wings project for the IKCAP group - - - edu.isi.wings - wings-core - 4.2.6 - ../core/pom.xml - - - - 0.1.53 - 1.2.4 - 0.8.11 - 2.2.4 - 4.5 - 1.7.25 - 2.3.0 - 10.10.1.1 - 2.4 - 1.0.9 - 1.10 - - UTF-8 - UTF-8 - 1.8 - 1.8 - - - - - - src/main/resources - - - src/test/resources - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.16 - - false - 1 - - - - - - - - github - Github - https://maven.pkg.github.com/KnowledgeCaptureAndDiscovery/ontapi - - - - - - - - - junit - junit - ${junit.version} - test - - - - - org.slf4j - slf4j-log4j12 - ${slf4j-log4j.version} - - - - - javax.xml.bind - jaxb-api - ${jaxb.version} - - - - - edu.isi.kcap - ontapi - 1.2.4 - - - - - com.google.code.gson - gson - ${gson.version} - - - - - - - - org.gridkit.lab - nanocloud - ${nanocloud.version} - - - - - urbanophile - java-getopt - ${java-getopt.version} - - - - - commons-configuration - commons-configuration - ${commons-configuration.version} - - - - - commons-io - commons-io - ${commons-io.version} - - - - - \ No newline at end of file diff --git a/pom.xml b/pom.xml index ade41583..0f924f1c 100644 --- a/pom.xml +++ b/pom.xml @@ -1,4 +1,5 @@ - 4.0.0 @@ -14,7 +15,7 @@ 5.4.2 core/pom.xml - + UTF-8 @@ -25,15 +26,7 @@ GitHub OWNER Apache Maven Packages https://maven.pkg.github.com/KnowledgeCaptureAndDiscovery/wings - - - - - github - Github - https://maven.pkg.github.com/KnowledgeCaptureAndDiscovery/ontapi - - + core @@ -43,4 +36,4 @@ - + \ No newline at end of file diff --git a/pom.xml.versionsBackup b/pom.xml.versionsBackup deleted file mode 100644 index 1b867eb9..00000000 --- a/pom.xml.versionsBackup +++ /dev/null @@ -1,46 +0,0 @@ - - 4.0.0 - - wings - Wings - http://www.wings-workflows.org - Wings project for the IKCAP group - pom - - - edu.isi.wings - wings-core - 4.2.6 - core/pom.xml - - - - UTF-8 - - - - - github - GitHub OWNER Apache Maven Packages - https://maven.pkg.github.com/KnowledgeCaptureAndDiscovery/wings - - - - - - github - Github - https://maven.pkg.github.com/KnowledgeCaptureAndDiscovery/ontapi - - - - - core - planner - portal - - - - - diff --git a/portal/.classpath b/portal/.classpath index e4f3f86f..6330fa28 100644 --- a/portal/.classpath +++ b/portal/.classpath @@ -9,6 +9,7 @@ + @@ -21,12 +22,35 @@ - - + + + + + + - + + + + + + + + + + + + + + + + + + + + diff --git a/portal/.settings/org.eclipse.jdt.core.prefs b/portal/.settings/org.eclipse.jdt.core.prefs index 67cf5a8f..7fdcd9c8 100644 --- a/portal/.settings/org.eclipse.jdt.core.prefs +++ b/portal/.settings/org.eclipse.jdt.core.prefs @@ -4,9 +4,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=11 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -19,5 +19,6 @@ org.eclipse.jdt.core.compiler.problem.nullReference=warning org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning -org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=11 +org.eclipse.jdt.core.compiler.processAnnotations=enabled +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/portal/pom.xml b/portal/pom.xml index d73d40e1..b9c6ad16 100644 --- a/portal/pom.xml +++ b/portal/pom.xml @@ -1,6 +1,7 @@ - + 4.0.0 wings-portal Wings Portal @@ -22,17 +23,9 @@ 2.27 2.8.6 1.1.0.Final - 1.3.3 + 1.3.3 - - - github - Github - https://maven.pkg.github.com/KnowledgeCaptureAndDiscovery/WINGS-OPMW-Mapper - - - @@ -63,7 +56,7 @@ - edu.isi.wings + edu.isi.kcap.wings wings-opmm ${wings-opmm.version} @@ -175,9 +168,9 @@ - org.apache.maven.plugins - maven-war-plugin - 3.3.1 + org.apache.maven.plugins + maven-war-plugin + 3.3.1 diff --git a/portal/pom.xml.versionsBackup b/portal/pom.xml.versionsBackup deleted file mode 100644 index 9d921cd5..00000000 --- a/portal/pom.xml.versionsBackup +++ /dev/null @@ -1,212 +0,0 @@ - - - 4.0.0 - wings-portal - Wings Portal - war - Wings portal web application - - - edu.isi.wings - wings-core - 4.2.6 - ../core/pom.xml - - - - - 1.2.4 - 2.5 - 4.5.2 - 2.27 - 2.8.6 - 1.1.0.Final - 1.3.3 - - - - - github - Github - https://maven.pkg.github.com/KnowledgeCaptureAndDiscovery/WINGS-OPMW-Mapper - - - - - - - edu.isi.wings - wings-planner - ${project.parent.version} - - - - - - - - - - - edu.isi.wings - wings-opmm - ${wings-opmm.version} - - - - - commons-fileupload - commons-fileupload - ${commons-fileupload.version} - - - - - org.glassfish.jersey.containers - jersey-container-servlet - ${jersey.version} - - - org.glassfish.jersey.inject - jersey-hk2 - ${jersey.version} - - - javax.activation - activation - 1.1.1 - - - - javax.validation - validation-api - ${javax.validation.version} - - - - org.glassfish.jersey.media - jersey-media-multipart - ${jersey.version} - - - - - org.glassfish.jersey.media - jersey-media-json-jackson - ${jersey.version} - - - com.fasterxml.jackson.jaxrs - jackson-jaxrs-json-provider - ${jackson.version} - - - - - - - - org.apache.tika - tika-core - 1.22 - - - - - javax.servlet - servlet-api - ${servlet-api.version} - provided - - - org.apache.tomcat - tomcat-catalina - 7.0.55 - provided - - - - - org.apache.httpcomponents - httpclient - ${httpclient.version} - - - org.apache.httpcomponents - httpmime - ${httpclient.version} - - - org.asynchttpclient - async-http-client - 2.7.0 - - - - - - - - org.codehaus.mojo - tomcat-maven-plugin - 1.1 - - 9090 - /wings-portal - - - - - org.apache.maven.plugins - maven-antrun-plugin - 1.7 - - - generate-sources - generate-sources - - - - - - - run - - - - clean - clean - - - - - - - run - - - - - - - - \ No newline at end of file diff --git a/portal/src/main/java/edu/isi/wings/portal/controllers/RunController.java b/portal/src/main/java/edu/isi/wings/portal/controllers/RunController.java index 4067455d..142c5eb7 100644 --- a/portal/src/main/java/edu/isi/wings/portal/controllers/RunController.java +++ b/portal/src/main/java/edu/isi/wings/portal/controllers/RunController.java @@ -17,7 +17,6 @@ package edu.isi.wings.portal.controllers; - import java.io.*; import java.net.HttpURLConnection; import java.net.URL; @@ -30,7 +29,7 @@ import javax.servlet.ServletContext; import javax.ws.rs.core.Response; -import edu.isi.wings.opmm.Catalog; +import edu.isi.kcap.wings.opmm.Catalog; import edu.isi.wings.portal.classes.config.Publisher; import edu.isi.wings.portal.classes.config.ServerDetails; import edu.isi.wings.portal.classes.util.ComponentExecutingThread; @@ -47,8 +46,8 @@ import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; -import edu.isi.wings.opmm.WorkflowExecutionExport; -import edu.isi.wings.opmm.WorkflowTemplateExport; +import edu.isi.kcap.wings.opmm.WorkflowExecutionExport; +import edu.isi.kcap.wings.opmm.WorkflowTemplateExport; import edu.isi.kcap.ontapi.KBTriple; import edu.isi.wings.catalog.component.ComponentFactory; import edu.isi.wings.catalog.data.DataFactory; @@ -97,23 +96,25 @@ public RunController(Config config) { this.props = config.getProperties(); this.dataUrl = config.getUserDomainUrl() + "/data"; this.templateUrl = config.getUserDomainUrl() + "/workflows"; - + if (executor == null) { - //System.out.println("Parallel:" + config.getPlannerConfig().getParallelism()); + // System.out.println("Parallel:" + config.getPlannerConfig().getParallelism()); executor = Executors.newFixedThreadPool(config.getPlannerConfig().getParallelism()); } } - + public void end() { } /** * Get the run list json. + * * @param pattern optional, a pattern to filter - * @param status optional, a pattern to filter complete runs - * @param start optional, start offset (for paging) (set to -1 to ignore) - * @param limit optional, number of runs to return (for paging) (set to -1 to ignore) + * @param status optional, a pattern to filter complete runs + * @param start optional, start offset (for paging) (set to -1 to ignore) + * @param limit optional, number of runs to return (for paging) (set to -1 to + * ignore) * @return */ public String getRunListJSON(String pattern, String status, int start, int limit) { @@ -122,12 +123,11 @@ public String getRunListJSON(String pattern, String status, int start, int limit boolean fasterQuery = numberOfRuns > 1000; result.put("success", true); result.put("results", numberOfRuns); - result.put("rows", this.getRunList(pattern, status, start, limit, fasterQuery)); + result.put("rows", this.getRunList(pattern, status, start, limit, fasterQuery)); return json.toJson(result); } - - public String getRunListSimpleJSON(String pattern, String status, int start, int limit, Date started_after) { + public String getRunListSimpleJSON(String pattern, String status, int start, int limit, Date started_after) { HashMap result = new HashMap(); result.put("success", true); result.put("results", this.getNumberOfRuns(pattern, status, started_after)); @@ -135,7 +135,7 @@ public String getRunListSimpleJSON(String pattern, String status, int start, in return json.toJson(result); } - public ArrayList> getRunListSimple(String pattern, String status, + public ArrayList> getRunListSimple(String pattern, String status, int start, int limit, Date started_after) { ExecutionMonitorAPI monitor = config.getDomainExecutionMonitor(); ArrayList> list = new ArrayList>(); @@ -149,18 +149,17 @@ public ArrayList> getRunListSimple(String pattern, Strin return list; } - - public ArrayList> getRunList(String pattern, String status, int start, int limit, + public ArrayList> getRunList(String pattern, String status, int start, int limit, boolean fasterQuery) { ExecutionMonitorAPI monitor = config.getDomainExecutionMonitor(); ArrayList> list = new ArrayList>(); for (RuntimePlan exe : monitor.getRunList(pattern, status, start, limit, fasterQuery)) { HashMap map = new HashMap(); - + map.put("runtimeInfo", exe.getRuntimeInfo()); map.put("template_id", exe.getOriginalTemplateID()); map.put("id", exe.getID()); - + if (exe.getQueue() != null) { int numtotal = exe.getQueue().getAllSteps().size(); int numdone = exe.getQueue().getFinishedSteps().size(); @@ -178,7 +177,7 @@ public ArrayList> getRunList(String pattern, String stat } return list; } - + public int getNumberOfRuns(String pattern, String status, Date started_after) { ExecutionMonitorAPI monitor = config.getDomainExecutionMonitor(); return monitor.getNumberOfRuns(pattern, status, started_after); @@ -222,7 +221,7 @@ public String getRunJSON(String runid) { return json.toJson(returnmap); } - + public String getRunPlanJSON(String runid) { ExecutionMonitorAPI monitor = config.getDomainExecutionMonitor(); RuntimePlan planexe = monitor.getRunDetails(runid); @@ -231,35 +230,36 @@ public String getRunPlanJSON(String runid) { private String getPublishedURL(String runid) { Publisher publisher = config.getPublisher(); - if(publisher == null) + if (publisher == null) return null; /* TODO: Return already published url for the run id if possible */ /* - Mapper opmm = new Mapper(); - String tstoreurl = publisher.getTstorePublishUrl(); - String puburl = publisher.getUrl(); - opmm.setPublishExportPrefix(puburl); - - String rname = runid.substring(runid.indexOf('#') + 1); - String runurl = opmm.getRunUrl(rname); - - // Check if run already published - if (graphExists(tstoreurl, runurl)) - return runurl;*/ + * Mapper opmm = new Mapper(); + * String tstoreurl = publisher.getTstorePublishUrl(); + * String puburl = publisher.getUrl(); + * opmm.setPublishExportPrefix(puburl); + * + * String rname = runid.substring(runid.indexOf('#') + 1); + * String runurl = opmm.getRunUrl(rname); + * + * // Check if run already published + * if (graphExists(tstoreurl, runurl)) + * return runurl; + */ return null; } private Map getShortConstraints(Template tpl) { Map varbindings = new HashMap(); - for(Variable v : tpl.getVariables()) { + for (Variable v : tpl.getVariables()) { List constraints = new ArrayList(); - if(v.isParameterVariable()) + if (v.isParameterVariable()) continue; - for(KBTriple t : tpl.getConstraintEngine().getConstraints(v.getID())) { + for (KBTriple t : tpl.getConstraintEngine().getConstraints(v.getID())) { Map cons = new HashMap(); - if(t.getPredicate().getName().equals("hasDataBinding")) + if (t.getPredicate().getName().equals("hasDataBinding")) continue; cons.put("p", t.getPredicate().getName()); cons.put("o", t.getObject()); @@ -269,27 +269,27 @@ private Map getShortConstraints(Template tpl) { } return varbindings; } - + public String deleteRuns(String rjson, ServletContext context) { HashMap ret = new HashMap(); ret.put("success", false); JsonElement listel = new JsonParser().parse(rjson); if (listel == null) return json.toJson(ret); - - if(listel.isJsonObject()) { + + if (listel.isJsonObject()) { return this.deleteRun(rjson, context); } - + ExecutionMonitorAPI monitor = config.getDomainExecutionMonitor(); - + JsonArray list = listel.getAsJsonArray(); - for(int i=0; i expandAndRunTemplate(TemplateBindings template_bindings, ServletContext context) { // Create a runid String ex_prefix = props.getProperty("domain.executions.dir.url"); String template_id = template_bindings.getTemplateId(); - + PlanningAPIBindings apis = null; - if(apiBindings.containsKey(ex_prefix)) { + if (apiBindings.containsKey(ex_prefix)) { apis = apiBindings.get(ex_prefix); - } - else { + } else { apis = new PlanningAPIBindings(props); apiBindings.put(ex_prefix, apis); } - + // Submit the planning and execution thread try { - PlanningAndExecutingThread thread = new PlanningAndExecutingThread(ex_prefix, template_id, + PlanningAndExecutingThread thread = new PlanningAndExecutingThread(ex_prefix, template_id, this.config, config.getPlannerConfig().getMaxQueueSize(), template_bindings, apis, executor, context); executor.submit(thread).get(); - + // Return the runids return thread.getRunids(); - } - catch(Exception e) { + } catch (Exception e) { e.printStackTrace(); return null; } } - - public Future runComponent(String cid, HashMap role_bindings, + + public Future runComponent(String cid, HashMap role_bindings, String callbackUrl, Cookie[] callbackCookies, ServletContext context) { PlanningAPIBindings apis = null; String exPrefix = props.getProperty("domain.executions.dir.url"); - if(apiBindings.containsKey(exPrefix)) { + if (apiBindings.containsKey(exPrefix)) { apis = apiBindings.get(exPrefix); - } - else { + } else { apis = new PlanningAPIBindings(props); apiBindings.put(exPrefix, apis); } - + // Submit the planning and execution thread - return executor.submit(new ComponentExecutingThread(cid, this.config, role_bindings, apis, callbackUrl, callbackCookies)); + return executor + .submit(new ComponentExecutingThread(cid, this.config, role_bindings, apis, callbackUrl, callbackCookies)); } - + public static void invalidateCachedAPIs() { apiBindings.clear(); } public String runExpandedTemplate(String origtplid, String templatejson, - String consjson, String seedjson, String seedconsjson, String callbackUrl, + String consjson, String seedjson, String seedconsjson, String callbackUrl, ServletContext context) { Gson json = JsonHandler.createTemplateGson(); @@ -397,11 +394,11 @@ public String runExpandedTemplate(String origtplid, String templatejson, return createPlan(origtplid, context, xtpl, seedtpl, callbackUrl); } - private String createPlan(String origtplid, + private String createPlan(String origtplid, ServletContext context, Template xtpl, Template seedtpl, String callbackUrl) { String requestid = UuidGen.generateAUuid(""); WorkflowGenerationAPI wg = new WorkflowGenerationKB(props, - DataFactory.getReasoningAPI(props), DataFactory.getCreationAPI(props), + DataFactory.getReasoningAPI(props), DataFactory.getCreationAPI(props), ComponentFactory.getReasoningAPI(props), ComponentFactory.getCreationAPI(props), ResourceFactory.getAPI(props), requestid); @@ -416,7 +413,7 @@ private String createPlan(String origtplid, if (!seedtpl.saveAs(seedid)) return ""; - if(plan.save()) { + if (plan.save()) { RuntimePlan rplan = new RuntimePlan(plan); rplan.setExpandedTemplateID(xtpl.getID()); rplan.setOriginalTemplateID(origtplid); @@ -429,18 +426,17 @@ private String createPlan(String origtplid, return ""; } - - public Response reRunPlan(String run_id, ServletContext context){ + public Response reRunPlan(String run_id, ServletContext context) { ExecutionMonitorAPI monitor = config.getDomainExecutionMonitor(); RuntimePlan plan = monitor.getRunDetails(run_id); - + TemplateCreationAPI tc = TemplateFactory.getCreationAPI(props); String orig_tp_id = plan.getOriginalTemplateID(); Template xtpl = tc.getTemplate(plan.getExpandedTemplateID()); Template seedtpl = tc.getTemplate(plan.getSeededTemplateID()); String callbackUrl = plan.getCallbackUrl(); tc.end(); - + if (createPlan(orig_tp_id, context, xtpl, seedtpl, callbackUrl) == "") return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("Internal error").build(); return Response.status(Response.Status.CREATED).entity("CREATED").build(); @@ -457,269 +453,270 @@ public void runExecutionPlan(RuntimePlan rplan, ServletContext context) { context.setAttribute("engine_" + rplan.getID(), engine); } -// public String publishRunList(String pattern) { -// ArrayList> runs = this.getRunList(pattern); -// ArrayList> returnJson = new ArrayList<>(); -// Iterator> i = runs.iterator(); -// -// ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(10); -// List futures = new ArrayList(); -// -// while (i.hasNext()){ -// String id = (String) i.next().get("id"); -// futures.add(executor.submit(new Callable() { -// public String call() { -// try { -// return publishRun(id); -// } catch (Exception e) { -// return ""; -// } -// } -// })); -// -// } -// for(Future f: futures) { -// HashMap element = new HashMap<>(); -// try { -// String jsonReturn = (String) f.get(); -// Map map = new Gson().fromJson(jsonReturn, Map.class); -// if (map.containsKey("url")) -// element.put("url", map.get("url")); -// returnJson.add(element); -// } catch (Exception e) { -// e.printStackTrace(); -// } -// } -// return json.toJson(returnJson); -// } + // public String publishRunList(String pattern) { + // ArrayList> runs = this.getRunList(pattern); + // ArrayList> returnJson = new ArrayList<>(); + // Iterator> i = runs.iterator(); + // + // ThreadPoolExecutor executor = (ThreadPoolExecutor) + // Executors.newFixedThreadPool(10); + // List futures = new ArrayList(); + // + // while (i.hasNext()){ + // String id = (String) i.next().get("id"); + // futures.add(executor.submit(new Callable() { + // public String call() { + // try { + // return publishRun(id); + // } catch (Exception e) { + // return ""; + // } + // } + // })); + // + // } + // for(Future f: futures) { + // HashMap element = new HashMap<>(); + // try { + // String jsonReturn = (String) f.get(); + // Map map = new Gson().fromJson(jsonReturn, Map.class); + // if (map.containsKey("url")) + // element.put("url", map.get("url")); + // returnJson.add(element); + // } catch (Exception e) { + // e.printStackTrace(); + // } + // } + // return json.toJson(returnJson); + // } private String urlToString(URL url) { try { HttpURLConnection conn = (HttpURLConnection) url.openConnection(); boolean redirect = false; - + // normally, 3xx is redirect int status = conn.getResponseCode(); if (status != HttpURLConnection.HTTP_OK) { if (status == HttpURLConnection.HTTP_MOVED_TEMP - || status == HttpURLConnection.HTTP_MOVED_PERM + || status == HttpURLConnection.HTTP_MOVED_PERM || status == HttpURLConnection.HTTP_SEE_OTHER) - redirect = true; + redirect = true; } - + if (redirect) { // get redirect url from "location" header field String newUrl = conn.getHeaderField("Location"); - + // open the new connnection again conn = (HttpURLConnection) new URL(newUrl).openConnection(); } - + BufferedReader in = new BufferedReader( - new InputStreamReader(conn.getInputStream())); + new InputStreamReader(conn.getInputStream())); String inputLine; StringBuffer html = new StringBuffer(); - + while ((inputLine = in.readLine()) != null) { html.append(inputLine); } in.close(); return html.toString(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } return null; } - - + public String publishRun(String runid) { HashMap retmap = new HashMap(); ExecutionMonitorAPI monitor = config.getDomainExecutionMonitor(); RuntimePlan plan = monitor.getRunDetails(runid); if (plan.getRuntimeInfo().getStatus() != Status.SUCCESS) { retmap.put("error", "Can only publish successfully completed runs"); - } else try { - //Mapper opmm = new Mapper(); - - Publisher publisher = config.getPublisher(); - - ServerDetails publishUrl = publisher.getUploadServer(); - String tstoreurl = publisher.getTstorePublishUrl(); - String tstorequery = publisher.getTstoreQueryUrl(); - String exportName = publisher.getExportName(); - String exportUrl = publisher.getUrl(); - - String uploadURL = publishUrl.getUrl(); - String uploadUsername = publishUrl.getUsername(); - String uploadDirectory = publishUrl.getDirectory(); - String uploadPassword = publishUrl.getPassword(); - long uploadMaxSize = publishUrl.getMaxUploadSize(); - //opmm.setPublishExportPrefix(puburl); - - String rname = runid.substring(runid.indexOf('#') + 1); - //String runurl = opmm.getRunUrl(rname); - - // Fetch expanded template (to get data binding ids) - TemplateCreationAPI tc = TemplateFactory.getCreationAPI(props); - Template xtpl = tc.getTemplate(plan.getExpandedTemplateID()); - tc.end(); - - HashMap varBindings = new HashMap(); - for (Variable var : xtpl.getVariables()) { - varBindings.put(var.getID(), var.getBinding().getID()); - } - - // Create a temporary directory to upload/move - File _tmpdir = File.createTempFile("temp", ""); - File tempdir = new File(_tmpdir.getParent() + "/" + rname); - FileUtils.deleteQuietly(tempdir); - if (!_tmpdir.delete() || !tempdir.mkdirs()) - throw new Exception("Cannot create temp directory"); - - - File datadir = new File(tempdir.getAbsolutePath() + "/data"); - File codedir = new File(tempdir.getAbsolutePath() + "/code"); - datadir.mkdirs(); - codedir.mkdirs(); - - /* - String tupurl = upurl + "/" + tempdir.getName(); - String dataurl = tupurl + "/data"; - String codeurl = tupurl + "/code"; - String cdir = props.getProperty("lib.domain.code.storage"); - String ddir = props.getProperty("lib.domain.data.storage"); - */ - - FileUtils.deleteQuietly(tempdir); - - //Create the temporal directory to store data, components, workflow and exection - tempdir.mkdirs(); - File dcontdir = new File(tempdir.getAbsolutePath() + "/ont/data"); - File acontdir = new File(tempdir.getAbsolutePath() + "/ont/components"); - File wflowdir = new File(tempdir.getAbsolutePath() + "/ont/workflows"); - File execsdir = new File(tempdir.getAbsolutePath() + "/ont/executions"); - - File run_exportdir = new File(tempdir.getAbsolutePath() + "/export/run"); - File tpl_exportdir = new File(tempdir.getAbsolutePath() + "/export/template"); - dcontdir.mkdirs(); - acontdir.mkdirs(); - wflowdir.mkdirs(); - execsdir.mkdirs(); - run_exportdir.mkdirs(); - tpl_exportdir.mkdirs(); - - // Merge both concrete and abstract component libraries from WINGS - String aclib = props.getProperty("lib.concrete.url"); - String abslib = props.getProperty("lib.abstract.url"); - //String workflow_lib = props.getProperty("lib.domain.workflow.url"); - - String aclibdata = urlToString(new URL(aclib)); - String abslibdata = urlToString(new URL(abslib)); - //String workflow_lib_data = urlToString(new URL(workflow_lib)); - - abslibdata = abslibdata.replaceFirst("<\\?xml.+?>", ""); - abslibdata = Pattern.compile("", Pattern.DOTALL).matcher(abslibdata).replaceFirst(""); - abslibdata = abslibdata.replaceFirst("<\\/rdf:RDF>", ""); - aclibdata = aclibdata.replaceFirst("<\\/rdf:RDF>", ""); - - String rplandata = urlToString(new URL(runid)); - - //write aclibfie and rplanfile - aclibdata += abslibdata + "\n"; - File aclibfile = new File(acontdir.getAbsolutePath() + "/library.owl"); - File rplanfile = new File(execsdir.getAbsolutePath() + "/" + - plan.getName() + ".owl"); - FileUtils.write(aclibfile, aclibdata); - FileUtils.write(rplanfile, rplandata); - - //workflow file? - URL otplurl = new URL(plan.getOriginalTemplateID()); - File otplfile = new File(wflowdir.getAbsolutePath() + "/" + - otplurl.getRef() + ".owl"); - String otpldata = urlToString(otplurl); - FileUtils.write(otplfile, otpldata); - - Catalog catalog = new Catalog(config.getDomainId(), exportName, - publisher.getDomainsDir(), aclibfile.getAbsolutePath()); - - WorkflowExecutionExport exp = new WorkflowExecutionExport( - rplanfile.getAbsolutePath(), catalog, exportUrl, exportName, tstorequery, config.getDomainId()); - exp.setUploadURL(uploadURL); - exp.setUploadUsername(uploadUsername); - exp.setUploadPassword(uploadPassword); - exp.setUploadMaxSize(uploadMaxSize); - exp.setUploadDirectory(uploadDirectory); - String serialization = "TURTLE"; - - //publish the catalog - String domainPath = catalog.exportCatalog(null, serialization); - File domainFile = new File(domainPath); - this.publishFile(tstoreurl, catalog.getDomainGraphURI(), domainFile.getAbsolutePath()); - - //execution - String executionFilePath = run_exportdir + File.separator + "execution"; - String graphUri = exp.exportAsOPMW(executionFilePath, serialization); - if (!exp.isExecPublished()) { - this.publishFile(tstoreurl, graphUri, executionFilePath); - - //expandedTemplate - String expandedTemplateFilePath = run_exportdir + File.separator + "expandedTemplate"; - String expandedTemplateGraphUri = exp.getConcreteTemplateExport().exportAsOPMW(expandedTemplateFilePath, serialization); - if (!exp.getConcreteTemplateExport().isTemplatePublished()) - this.publishFile(tstoreurl, expandedTemplateGraphUri, expandedTemplateFilePath); - - //abstract - WorkflowTemplateExport abstractTemplateExport = exp.getConcreteTemplateExport().getAbstractTemplateExport(); - if (abstractTemplateExport != null) { - String abstractFilePath = run_exportdir + File.separator + "abstract"; - String abstractGraphUri = abstractTemplateExport.exportAsOPMW(abstractFilePath, serialization); - if (!abstractTemplateExport.isTemplatePublished()) - this.publishFile(tstoreurl, abstractGraphUri, abstractFilePath); + } else + try { + // Mapper opmm = new Mapper(); + + Publisher publisher = config.getPublisher(); + + ServerDetails publishUrl = publisher.getUploadServer(); + String tstoreurl = publisher.getTstorePublishUrl(); + String tstorequery = publisher.getTstoreQueryUrl(); + String exportName = publisher.getExportName(); + String exportUrl = publisher.getUrl(); + + String uploadURL = publishUrl.getUrl(); + String uploadUsername = publishUrl.getUsername(); + String uploadDirectory = publishUrl.getDirectory(); + String uploadPassword = publishUrl.getPassword(); + long uploadMaxSize = publishUrl.getMaxUploadSize(); + // opmm.setPublishExportPrefix(puburl); + + String rname = runid.substring(runid.indexOf('#') + 1); + // String runurl = opmm.getRunUrl(rname); + + // Fetch expanded template (to get data binding ids) + TemplateCreationAPI tc = TemplateFactory.getCreationAPI(props); + Template xtpl = tc.getTemplate(plan.getExpandedTemplateID()); + tc.end(); + + HashMap varBindings = new HashMap(); + for (Variable var : xtpl.getVariables()) { + varBindings.put(var.getID(), var.getBinding().getID()); } - } + // Create a temporary directory to upload/move + File _tmpdir = File.createTempFile("temp", ""); + File tempdir = new File(_tmpdir.getParent() + "/" + rname); + FileUtils.deleteQuietly(tempdir); + if (!_tmpdir.delete() || !tempdir.mkdirs()) + throw new Exception("Cannot create temp directory"); + + File datadir = new File(tempdir.getAbsolutePath() + "/data"); + File codedir = new File(tempdir.getAbsolutePath() + "/code"); + datadir.mkdirs(); + codedir.mkdirs(); + + /* + * String tupurl = upurl + "/" + tempdir.getName(); + * String dataurl = tupurl + "/data"; + * String codeurl = tupurl + "/code"; + * String cdir = props.getProperty("lib.domain.code.storage"); + * String ddir = props.getProperty("lib.domain.data.storage"); + */ + + FileUtils.deleteQuietly(tempdir); + + // Create the temporal directory to store data, components, workflow and + // exection + tempdir.mkdirs(); + File dcontdir = new File(tempdir.getAbsolutePath() + "/ont/data"); + File acontdir = new File(tempdir.getAbsolutePath() + "/ont/components"); + File wflowdir = new File(tempdir.getAbsolutePath() + "/ont/workflows"); + File execsdir = new File(tempdir.getAbsolutePath() + "/ont/executions"); + + File run_exportdir = new File(tempdir.getAbsolutePath() + "/export/run"); + File tpl_exportdir = new File(tempdir.getAbsolutePath() + "/export/template"); + dcontdir.mkdirs(); + acontdir.mkdirs(); + wflowdir.mkdirs(); + execsdir.mkdirs(); + run_exportdir.mkdirs(); + tpl_exportdir.mkdirs(); + + // Merge both concrete and abstract component libraries from WINGS + String aclib = props.getProperty("lib.concrete.url"); + String abslib = props.getProperty("lib.abstract.url"); + // String workflow_lib = props.getProperty("lib.domain.workflow.url"); + + String aclibdata = urlToString(new URL(aclib)); + String abslibdata = urlToString(new URL(abslib)); + // String workflow_lib_data = urlToString(new URL(workflow_lib)); + + abslibdata = abslibdata.replaceFirst("<\\?xml.+?>", ""); + abslibdata = Pattern.compile("", Pattern.DOTALL).matcher(abslibdata).replaceFirst(""); + abslibdata = abslibdata.replaceFirst("<\\/rdf:RDF>", ""); + aclibdata = aclibdata.replaceFirst("<\\/rdf:RDF>", ""); + + String rplandata = urlToString(new URL(runid)); + + // write aclibfie and rplanfile + aclibdata += abslibdata + "\n"; + File aclibfile = new File(acontdir.getAbsolutePath() + "/library.owl"); + File rplanfile = new File(execsdir.getAbsolutePath() + "/" + + plan.getName() + ".owl"); + FileUtils.write(aclibfile, aclibdata); + FileUtils.write(rplanfile, rplandata); + + // workflow file? + URL otplurl = new URL(plan.getOriginalTemplateID()); + File otplfile = new File(wflowdir.getAbsolutePath() + "/" + + otplurl.getRef() + ".owl"); + String otpldata = urlToString(otplurl); + FileUtils.write(otplfile, otpldata); + + Catalog catalog = new Catalog(config.getDomainId(), exportName, + publisher.getDomainsDir(), aclibfile.getAbsolutePath()); + + WorkflowExecutionExport exp = new WorkflowExecutionExport( + rplanfile.getAbsolutePath(), catalog, exportUrl, exportName, tstorequery, config.getDomainId()); + exp.setUploadURL(uploadURL); + exp.setUploadUsername(uploadUsername); + exp.setUploadPassword(uploadPassword); + exp.setUploadMaxSize(uploadMaxSize); + exp.setUploadDirectory(uploadDirectory); + String serialization = "TURTLE"; + + // publish the catalog + String domainPath = catalog.exportCatalog(null, serialization); + File domainFile = new File(domainPath); + this.publishFile(tstoreurl, catalog.getDomainGraphURI(), domainFile.getAbsolutePath()); + + // execution + String executionFilePath = run_exportdir + File.separator + "execution"; + String graphUri = exp.exportAsOPMW(executionFilePath, serialization); + if (!exp.isExecPublished()) { + this.publishFile(tstoreurl, graphUri, executionFilePath); + + // expandedTemplate + String expandedTemplateFilePath = run_exportdir + File.separator + "expandedTemplate"; + String expandedTemplateGraphUri = exp.getConcreteTemplateExport().exportAsOPMW(expandedTemplateFilePath, + serialization); + if (!exp.getConcreteTemplateExport().isTemplatePublished()) + this.publishFile(tstoreurl, expandedTemplateGraphUri, expandedTemplateFilePath); + + // abstract + WorkflowTemplateExport abstractTemplateExport = exp.getConcreteTemplateExport().getAbstractTemplateExport(); + if (abstractTemplateExport != null) { + String abstractFilePath = run_exportdir + File.separator + "abstract"; + String abstractGraphUri = abstractTemplateExport.exportAsOPMW(abstractFilePath, serialization); + if (!abstractTemplateExport.isTemplatePublished()) + this.publishFile(tstoreurl, abstractGraphUri, abstractFilePath); + } + } - retmap.put("url", exp.getTransformedExecutionURI()); + retmap.put("url", exp.getTransformedExecutionURI()); - } catch (Exception e) { - e.printStackTrace(); - retmap.put("error", e.getMessage()); - } + } catch (Exception e) { + e.printStackTrace(); + retmap.put("error", e.getMessage()); + } return json.toJson(retmap); } - /* - private void uploadDirectory(ServerDetails server, File tempdir) { - if(server.getHost() != null) { - Machine m = new Machine(server.getHost()); - m.setHostName(server.getHost()); - m.setUserId(server.getHostUserId()); - m.setUserKey(server.getPrivateKey()); - HashMap filemap = new HashMap(); - String srvdir = server.getDirectory(); - for(File f : FileUtils.listFiles(tempdir, null, true)) { - String fpath = f.getAbsolutePath(); - String srvpath = fpath.replace(tempdir.getParent(), srvdir); - filemap.put(fpath, srvpath); - } - GridkitCloud.uploadFiles(m, filemap); - } - else { - try { - FileUtils.copyDirectoryToDirectory(tempdir, new File(server.getDirectory())); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - */ + * private void uploadDirectory(ServerDetails server, File tempdir) { + * if(server.getHost() != null) { + * Machine m = new Machine(server.getHost()); + * m.setHostName(server.getHost()); + * m.setUserId(server.getHostUserId()); + * m.setUserKey(server.getPrivateKey()); + * HashMap filemap = new HashMap(); + * String srvdir = server.getDirectory(); + * for(File f : FileUtils.listFiles(tempdir, null, true)) { + * String fpath = f.getAbsolutePath(); + * String srvpath = fpath.replace(tempdir.getParent(), srvdir); + * filemap.put(fpath, srvpath); + * } + * GridkitCloud.uploadFiles(m, filemap); + * } + * else { + * try { + * FileUtils.copyDirectoryToDirectory(tempdir, new File(server.getDirectory())); + * } catch (IOException e) { + * e.printStackTrace(); + * } + * } + * } + */ /** * Upload triples to a rdf store - * @param tstoreurl: triple store url. e.g., http://ontosoft.isi.edu:3030/provenance/data - * @param graphurl: graph url. + * + * @param tstoreurl: triple store url. e.g., + * http://ontosoft.isi.edu:3030/provenance/data + * @param graphurl: graph url. * @param filepath */ private void publishFile(String tstoreurl, String graphurl, String filepath) { @@ -728,7 +725,7 @@ private void publishFile(String tstoreurl, String graphurl, String filepath) { CloseableHttpClient httpClient = HttpClients.createDefault(); HttpPut putRequest = new HttpPut(tstoreurl + "?graph=" + graphurl); - //Todo: move it to configuration + // Todo: move it to configuration int timeoutSeconds = 10; int CONNECTION_TIMEOUT_MS = timeoutSeconds * 1000; RequestConfig requestConfig = RequestConfig.custom() @@ -753,8 +750,7 @@ private void publishFile(String tstoreurl, String graphurl, String filepath) { System.err.println("Success uploading the domain " + statusCode); System.err.println(response.getStatusLine().getReasonPhrase()); } - } - else { + } else { System.err.println("File content is null " + filepath); } } catch (IOException e) { @@ -763,28 +759,28 @@ private void publishFile(String tstoreurl, String graphurl, String filepath) { } /* - private boolean graphExists(String tstoreurl, String graphurl) { - try { - CloseableHttpClient httpClient = HttpClients.createDefault(); - HttpGet getRequest = new HttpGet(tstoreurl + "?graph=" + graphurl); - - int timeoutSeconds = 5; - int CONNECTION_TIMEOUT_MS = timeoutSeconds * 1000; - RequestConfig requestConfig = RequestConfig.custom() - .setConnectionRequestTimeout(CONNECTION_TIMEOUT_MS) - .setConnectTimeout(CONNECTION_TIMEOUT_MS) - .setSocketTimeout(CONNECTION_TIMEOUT_MS) - .build(); - getRequest.setConfig(requestConfig); - - HttpResponse response = httpClient.execute(getRequest); - if(response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) - return true; - return false; - } catch (IOException e) { - e.printStackTrace(); - return false; - } - } - */ + * private boolean graphExists(String tstoreurl, String graphurl) { + * try { + * CloseableHttpClient httpClient = HttpClients.createDefault(); + * HttpGet getRequest = new HttpGet(tstoreurl + "?graph=" + graphurl); + * + * int timeoutSeconds = 5; + * int CONNECTION_TIMEOUT_MS = timeoutSeconds * 1000; + * RequestConfig requestConfig = RequestConfig.custom() + * .setConnectionRequestTimeout(CONNECTION_TIMEOUT_MS) + * .setConnectTimeout(CONNECTION_TIMEOUT_MS) + * .setSocketTimeout(CONNECTION_TIMEOUT_MS) + * .build(); + * getRequest.setConfig(requestConfig); + * + * HttpResponse response = httpClient.execute(getRequest); + * if(response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) + * return true; + * return false; + * } catch (IOException e) { + * e.printStackTrace(); + * return false; + * } + * } + */ } diff --git a/wings-docker/config/default/settings.xml b/wings-docker/config/default/settings.xml deleted file mode 100644 index 19fca2ba..00000000 --- a/wings-docker/config/default/settings.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - github - - - - - github - - - central - https://repo1.maven.org/maven2 - - - WINGS-OPMW-Mapper - https://maven.pkg.github.com/KnowledgeCaptureAndDiscovery/WINGS-OPMW-Mapper - - true - - - - ontapi - https://maven.pkg.github.com/KnowledgeCaptureAndDiscovery/ontapi - - true - - - - - - - - - github - mosoriob - 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 - - -