blob: c3752ec305e0142f2e70bf3495e245577cd614d4 [file] [log] [blame]
{
"http://purl.org/dc/terms/rights": "Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the 'License'); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.",
"http://purl.org/dc/terms/license": {"@id": "http://www.apache.org/licenses/LICENSE-2.0"},
"classLoaderSharing" : "workflow",
"script" : "\n import java.sql.Driver;\nimport java.sql.DriverManager;\nimport java.sql.Connection;\nimport java.sql.PreparedStatement;\nimport java.sql.ResultSet;\nimport java.sql.ResultSetMetaData;\nimport java.sql.SQLException;\n\nimport javax.sql.rowset.WebRowSet;\n\nimport com.sun.rowset.WebRowSetImpl;\n\n\n\nif ((driver == void) || (driver == null) || driver.equals(\"\")) {\n\tthrow new RuntimeException(\"The driver must be specified\");\n}\n\nif ((url == void) || (url == null) || url.equals(\"\")) {\n\tthrow new RuntimeException(\"The url must be specified\");\n}\n\nboolean provideXmlBoolean = ((provideXml != void) && (provideXml != null) && Boolean.valueOf(provideXml));\n\nif ((params == void) || (params == null)) {\n params = new ArrayList();\n}\n\nif ((sql == void) || (sql == null) || sql.equals(\"\")) {\n\tthrow new RuntimeException(\"The sql must be specified\");\n}\n\nClass c = Thread.currentThread().getContextClassLoader().loadClass(driver);\n\nif (c == null) {\n\tthrow new RuntimeException(\"Class \" + driver + \" not found\");\n}\n\nDriver d = c.newInstance();\nif (d == null) {\n\tthrow new RuntimeException(\"Could not create instance of driver\");\n}\n\nProperties p = new Properties();\n\nif ((userid == void) || (userid == null)) {\n\tuserid = \"\";\n}\n\np.setProperty(\"user\", userid);\n\nif ((password == void) || (password == null)) {\n\tpassword = \"\";\n}\n\np.setProperty(\"password\", password);\n\nConnection con = null;\nPreparedStatement ps = null;\nResultSet rs = null;\ntry {\n\n\tcon = d.connect(url, p);\n\tps = con.prepareStatement(sql);\n\n\tint paramSize = params.size();\n\tfor (int i = 0; i < paramSize; i++) {\n\t\tps.setObject(i + 1, params.get(i));\n\t}\n\n\trs = ps.executeQuery();\n\n\tif (provideXmlBoolean) {\n\t\tWebRowSet webrs = new WebRowSetImpl();\n\t\tStringWriter sw = new StringWriter();\n\t\twebrs.writeXml(rs, sw);\n\t\txmlresults = sw.toString();\n\t} else {\n\t\txmlresults = \"\";\n\t}\n\n\ttry {\n\t\trs.beforeFirst();\n\t} catch (SQLException e) {\n\t\t// redo the query\n\t\trs = ps.executeQuery();\n\t}\n\n\tResultSetMetaData rsmd = rs.getMetaData();\n\tint numCols = rsmd.getColumnCount();\n\tresultList = new ArrayList();\n\t\n\t// put the results into the results list.\n\twhile (rs.next()) {\n\t\tList row = new ArrayList(numCols);\n\t\tfor (int i = 0; i < numCols; i++) {\n\t\t\tString str = rs.getString(i + 1); \n\t\t\trow.add(str == null ? \"null\" : str); \n\t\t}\n\t\tresultList.add(row);\n\t}\n}\nfinally {\n\tif (rs != null) {\n\t\trs.close();\n\t}\n\tif (ps != null) {\n\t\tps.close();\n\t}\n\tif (con != null) {\n\t\tcon.close();\n\t}\n}\n \n\n ",
"localworkerName" : "net.sourceforge.taverna.scuflworkers.jdbc.SQLQueryWorker",
"inputPorts" : [ {
"name" : "driver",
"depth" : 0,
"type" : "String"
}, {
"name" : "password",
"depth" : 0,
"type" : "String"
}, {
"name" : "userid",
"depth" : 0,
"type" : "String"
}, {
"name" : "url",
"depth" : 0,
"type" : "String"
}, {
"name" : "provideXml",
"depth" : 0,
"type" : "String"
}, {
"name" : "sql",
"depth" : 0,
"type" : "String"
}, {
"name" : "params",
"depth" : 1,
"type" : "String"
} ],
"outputPorts" : [ {
"name" : "resultList",
"depth" : 2,
"granularDepth" : 2
}, {
"name" : "xmlresults",
"depth" : 0,
"granularDepth" : 0
} ],
"isAltered" : false
}