| <activity xmlns="http://taverna.sf.net/2008/xml/t2flow"><class>net.sf.taverna.t2.activities.localworker.LocalworkerActivity</class><inputMap><map from="password" to="password" /><map from="userid" to="userid" /><map from="params" to="params" /><map from="url" to="url" /><map from="provideXml" to="provideXml" /><map from="driver" to="driver" /><map from="sql" to="sql" /></inputMap><outputMap><map from="resultList" to="resultList" /><map from="xmlresults" to="xmlresults" /></outputMap><configBean encoding="xstream"><net.sf.taverna.t2.activities.localworker.LocalworkerActivityConfigurationBean xmlns=""> |
| |
| <script> |
| import java.sql.Driver; |
| import java.sql.DriverManager; |
| import java.sql.Connection; |
| import java.sql.PreparedStatement; |
| import java.sql.ResultSet; |
| import java.sql.ResultSetMetaData; |
| import java.sql.SQLException; |
| |
| import javax.sql.rowset.WebRowSet; |
| |
| import com.sun.rowset.WebRowSetImpl; |
| |
| |
| |
| if ((driver == void) || (driver == null) || driver.equals("")) { |
| throw new RuntimeException("The driver must be specified"); |
| } |
| |
| if ((url == void) || (url == null) || url.equals("")) { |
| throw new RuntimeException("The url must be specified"); |
| } |
| |
| boolean provideXmlBoolean = ((provideXml != void) && (provideXml != null) && Boolean.valueOf(provideXml)); |
| |
| if ((params == void) || (params == null)) { |
| params = new ArrayList(); |
| } |
| |
| if ((sql == void) || (sql == null) || sql.equals("")) { |
| throw new RuntimeException("The sql must be specified"); |
| } |
| |
| Class c = Thread.currentThread().getContextClassLoader().loadClass(driver); |
| |
| if (c == null) { |
| throw new RuntimeException("Class " + driver + " not found"); |
| } |
| |
| Driver d = c.newInstance(); |
| if (d == null) { |
| throw new RuntimeException("Could not create instance of driver"); |
| } |
| |
| Properties p = new Properties(); |
| |
| if ((userid == void) || (userid == null)) { |
| userid = ""; |
| } |
| |
| p.setProperty("user", userid); |
| |
| if ((password == void) || (password == null)) { |
| password = ""; |
| } |
| |
| p.setProperty("password", password); |
| |
| Connection con = null; |
| PreparedStatement ps = null; |
| ResultSet rs = null; |
| try { |
| |
| con = d.connect(url, p); |
| ps = con.prepareStatement(sql); |
| |
| int paramSize = params.size(); |
| for (int i = 0; i < paramSize; i++) { |
| ps.setObject(i + 1, params.get(i)); |
| } |
| |
| rs = ps.executeQuery(); |
| |
| if (provideXmlBoolean) { |
| WebRowSet webrs = new WebRowSetImpl(); |
| StringWriter sw = new StringWriter(); |
| webrs.writeXml(rs, sw); |
| xmlresults = sw.toString(); |
| } else { |
| xmlresults = ""; |
| } |
| |
| try { |
| rs.beforeFirst(); |
| } catch (SQLException e) { |
| // redo the query |
| rs = ps.executeQuery(); |
| } |
| |
| ResultSetMetaData rsmd = rs.getMetaData(); |
| int numCols = rsmd.getColumnCount(); |
| resultList = new ArrayList(); |
| |
| // put the results into the results list. |
| while (rs.next()) { |
| List row = new ArrayList(numCols); |
| for (int i = 0; i < numCols; i++) { |
| String str = rs.getString(i + 1); |
| row.add(str == null ? "null" : str); |
| } |
| resultList.add(row); |
| } |
| } |
| finally { |
| if (rs != null) { |
| rs.close(); |
| } |
| if (ps != null) { |
| ps.close(); |
| } |
| if (con != null) { |
| con.close(); |
| } |
| } |
| |
| |
| </script> |
| |
| <dependencies /> |
| |
| <classLoaderSharing>system</classLoaderSharing> |
| |
| <localDependencies /> |
| |
| <artifactDependencies /> |
| |
| <inputs> |
| |
| <net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityInputPortDefinitionBean> |
| |
| <handledReferenceSchemes /> |
| |
| <translatedElementType>java.lang.String</translatedElementType> |
| |
| <allowsLiteralValues>true</allowsLiteralValues> |
| |
| <name>driver</name> |
| |
| <depth>0</depth> |
| |
| <mimeTypes> |
| |
| <string>text/plain</string> |
| |
| </mimeTypes> |
| |
| </net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityInputPortDefinitionBean> |
| |
| <net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityInputPortDefinitionBean> |
| |
| <handledReferenceSchemes /> |
| |
| <translatedElementType>java.lang.String</translatedElementType> |
| |
| <allowsLiteralValues>true</allowsLiteralValues> |
| |
| <name>password</name> |
| |
| <depth>0</depth> |
| |
| <mimeTypes> |
| |
| <string>text/plain</string> |
| |
| </mimeTypes> |
| |
| </net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityInputPortDefinitionBean> |
| |
| <net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityInputPortDefinitionBean> |
| |
| <handledReferenceSchemes /> |
| |
| <translatedElementType>java.lang.String</translatedElementType> |
| |
| <allowsLiteralValues>true</allowsLiteralValues> |
| |
| <name>userid</name> |
| |
| <depth>0</depth> |
| |
| <mimeTypes> |
| |
| <string>text/plain</string> |
| |
| </mimeTypes> |
| |
| </net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityInputPortDefinitionBean> |
| |
| <net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityInputPortDefinitionBean> |
| |
| <handledReferenceSchemes /> |
| |
| <translatedElementType>java.lang.String</translatedElementType> |
| |
| <allowsLiteralValues>true</allowsLiteralValues> |
| |
| <name>url</name> |
| |
| <depth>0</depth> |
| |
| <mimeTypes> |
| |
| <string>text/plain</string> |
| |
| </mimeTypes> |
| |
| </net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityInputPortDefinitionBean> |
| |
| <net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityInputPortDefinitionBean> |
| |
| <handledReferenceSchemes /> |
| |
| <translatedElementType>java.lang.String</translatedElementType> |
| |
| <allowsLiteralValues>true</allowsLiteralValues> |
| |
| <name>provideXml</name> |
| |
| <depth>0</depth> |
| |
| <mimeTypes> |
| |
| <string>text/plain</string> |
| |
| </mimeTypes> |
| |
| </net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityInputPortDefinitionBean> |
| |
| <net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityInputPortDefinitionBean> |
| |
| <handledReferenceSchemes /> |
| |
| <translatedElementType>java.lang.String</translatedElementType> |
| |
| <allowsLiteralValues>true</allowsLiteralValues> |
| |
| <name>sql</name> |
| |
| <depth>0</depth> |
| |
| <mimeTypes> |
| |
| <string>text/plain</string> |
| |
| </mimeTypes> |
| |
| </net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityInputPortDefinitionBean> |
| |
| <net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityInputPortDefinitionBean> |
| |
| <handledReferenceSchemes /> |
| |
| <translatedElementType>java.lang.String</translatedElementType> |
| |
| <allowsLiteralValues>true</allowsLiteralValues> |
| |
| <name>params</name> |
| |
| <depth>1</depth> |
| |
| <mimeTypes> |
| |
| <string>text/plain</string> |
| |
| </mimeTypes> |
| |
| </net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityInputPortDefinitionBean> |
| |
| </inputs> |
| |
| <outputs> |
| |
| <net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityOutputPortDefinitionBean> |
| |
| <granularDepth>2</granularDepth> |
| |
| <name>resultList</name> |
| |
| <depth>2</depth> |
| |
| <mimeTypes> |
| |
| <string>text/plain</string> |
| |
| </mimeTypes> |
| |
| </net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityOutputPortDefinitionBean> |
| |
| <net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityOutputPortDefinitionBean> |
| |
| <granularDepth>0</granularDepth> |
| |
| <name>xmlresults</name> |
| |
| <depth>0</depth> |
| |
| <mimeTypes> |
| |
| <string>text/plain</string> |
| |
| </mimeTypes> |
| |
| </net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityOutputPortDefinitionBean> |
| |
| </outputs> |
| |
| </net.sf.taverna.t2.activities.localworker.LocalworkerActivityConfigurationBean></configBean><annotations /></activity> |