You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@taverna.apache.org by st...@apache.org on 2015/02/23 11:09:47 UTC
[12/54] [partial] incubator-taverna-engine git commit: Revert
"temporarily empty repository"
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/ProvenanceWriter.java
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/ProvenanceWriter.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/ProvenanceWriter.java
new file mode 100644
index 0000000..23ad705
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/ProvenanceWriter.java
@@ -0,0 +1,676 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester
+ *
+ * Modifications to the initial code base are copyright of their
+ * respective authors, or their employers as appropriate.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package net.sf.taverna.t2.provenance.lineageservice;
+
+import static net.sf.taverna.t2.provenance.connector.AbstractProvenanceConnector.DataflowInvocationTable.DataflowInvocation;
+
+import java.sql.Blob;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.UUID;
+
+import net.sf.taverna.t2.provenance.connector.AbstractProvenanceConnector.ActivityTable;
+import net.sf.taverna.t2.provenance.connector.AbstractProvenanceConnector.DataBindingTable;
+import net.sf.taverna.t2.provenance.connector.AbstractProvenanceConnector.DataflowInvocationTable;
+import net.sf.taverna.t2.provenance.connector.AbstractProvenanceConnector.ProcessorEnactmentTable;
+import net.sf.taverna.t2.provenance.connector.AbstractProvenanceConnector.ServiceInvocationTable;
+import net.sf.taverna.t2.provenance.lineageservice.utils.NestedListNode;
+import net.sf.taverna.t2.provenance.lineageservice.utils.Port;
+import net.sf.taverna.t2.provenance.lineageservice.utils.PortBinding;
+import net.sf.taverna.t2.provenance.lineageservice.utils.ProvenanceProcessor;
+
+import org.apache.log4j.Logger;
+
+import uk.org.taverna.configuration.database.DatabaseManager;
+
+/**
+ * Handles all the writing out of provenance items to the database layer. Uses
+ * standard SQL so all specific instances of this class can extend this writer
+ * to handle all of the db writes
+ *
+ * @author Paolo Missier
+ * @author Ian Dunlop
+ * @author Stuart Owen
+ *
+ */
+public class ProvenanceWriter {
+
+ protected static Logger logger = Logger.getLogger(ProvenanceWriter.class);
+ protected int cnt; // counts number of calls to PortBinding
+ protected ProvenanceQuery pq = null;
+ private final DatabaseManager databaseManager;
+
+ public ProvenanceWriter(DatabaseManager databaseManager) {
+ this.databaseManager = databaseManager;
+ }
+
+ public Connection getConnection() throws SQLException {
+ return databaseManager.getConnection();
+ }
+
+ public void closeCurrentModel() {
+
+ }
+
+ /**
+ * add each Port as a row into the Port DB table <strong>note: no static
+ * port type available as part of the dataflow...</strong>
+ *
+ * @param ports
+ * @param wfId
+ * @throws SQLException
+ */
+ public void addPorts(List<Port> ports, String wfId) throws SQLException {
+ String sql = "INSERT INTO Port "
+ + "(portName, processorName, isInputPort, depth, workflowId, portId, processorId)"
+ + " VALUES(?,?,?,?,?,?,?)";
+ try (Connection connection = getConnection();
+ PreparedStatement ps = connection.prepareStatement(sql)) {
+ for (Port v : ports) {
+ ps.setString(1, v.getPortName());
+ ps.setString(2, v.getProcessorName());
+ ps.setBoolean(3, v.isInputPort());
+ int depth = v.getDepth() >= 0 ? v.getDepth() : 0;
+ ps.setInt(4, depth);
+ ps.setString(5, wfId);
+ ps.setString(6, v.getIdentifier());
+ ps.setString(7, v.getProcessorId());
+
+ try {
+ ps.executeUpdate();
+ } catch (Exception e) {
+ logger.warn("Could not insert var " + v.getPortName(), e);
+ }
+ }
+ }
+ }
+
+ @SuppressWarnings("static-access")
+ public void addDataflowInvocation(
+ net.sf.taverna.t2.provenance.lineageservice.utils.DataflowInvocation invocation)
+ throws SQLException {
+ String sql = "INSERT INTO " + DataflowInvocation.DataflowInvocation
+ + "(" + DataflowInvocation.dataflowInvocationId + ","
+ + DataflowInvocation.workflowId + ","
+ + DataflowInvocation.invocationStarted + ","
+ + DataflowInvocation.invocationEnded + ","
+ + DataflowInvocation.inputsDataBinding + ","
+ + DataflowInvocation.outputsDataBinding + ","
+ + DataflowInvocation.parentProcessorEnactmentId + ","
+ + DataflowInvocation.workflowRunId + ","
+ + DataflowInvocation.completed + ") "
+ + " VALUES(?,?,?,?,?,?,?,?,?)";
+ try (Connection connection = getConnection();
+ PreparedStatement ps = connection.prepareStatement(sql);) {
+ ps.setString(1, invocation.getDataflowInvocationId());
+ ps.setString(2, invocation.getWorkflowId());
+ ps.setTimestamp(3, invocation.getInvocationStarted());
+ ps.setTimestamp(4, invocation.getInvocationEnded());
+ ps.setString(5, invocation.getInputsDataBindingId());
+ ps.setString(6, invocation.getOutputsDataBindingId());
+ ps.setString(7, invocation.getParentProcessorEnactmentId());
+ ps.setString(8, invocation.getWorkflowRunId());
+ ps.setBoolean(9, invocation.getCompleted());
+
+ ps.executeUpdate();
+ }
+ }
+
+ /**
+ * inserts one row into the ARC DB table
+ *
+ * @param sourcePort
+ * @param destinationPort
+ * @param workflowId
+ */
+ public void addDataLink(Port sourcePort, Port destinationPort,
+ String workflowId) throws SQLException {
+ String sql = "INSERT INTO Datalink (workflowId, sourceProcessorName, "
+ + " sourcePortName, destinationProcessorName, destinationPortName,"
+ + " sourcePortId, destinationPortId) "
+ + "VALUES(?,?,?,?,?,?,?)";
+ try (Connection connection = getConnection();
+ PreparedStatement ps = connection.prepareStatement(sql)) {
+ ps.setString(1, workflowId);
+ ps.setString(2, sourcePort.getProcessorName());
+ ps.setString(3, sourcePort.getPortName());
+ ps.setString(4, destinationPort.getProcessorName());
+ ps.setString(5, destinationPort.getPortName());
+ ps.setString(6, sourcePort.getIdentifier());
+ ps.setString(7, destinationPort.getIdentifier());
+
+ ps.executeUpdate();
+ }
+ }
+
+ public void addDataBinding(
+ net.sf.taverna.t2.provenance.lineageservice.utils.DataBinding dataBinding)
+ throws SQLException {
+ String sql = "INSERT INTO " + DataBindingTable.DataBinding + "("
+ + DataBindingTable.dataBindingId + ","
+ + DataBindingTable.portId + "," + DataBindingTable.t2Reference
+ + "," + DataBindingTable.workflowRunId + ") VALUES(?,?,?,?)";
+ try (Connection connection = getConnection();
+ PreparedStatement ps = connection.prepareStatement(sql)) {
+ ps.setString(1, dataBinding.getDataBindingId());
+ ps.setString(2, dataBinding.getPort().getIdentifier());
+ ps.setString(3, dataBinding.getT2Reference());
+ ps.setString(4, dataBinding.getWorkflowRunId());
+ ps.executeUpdate();
+ if (logger.isDebugEnabled())
+ logger.debug("adding DataBinding:\n " + dataBinding);
+ }
+ }
+
+ public void addWFId(String wfId) throws SQLException {
+ String sql = "INSERT INTO Workflow (workflowId) VALUES (?)";
+ try (Connection connection = getConnection();
+ PreparedStatement ps = connection.prepareStatement(sql)) {
+ ps.setString(1, wfId);
+ ps.executeUpdate();
+ }
+ }
+
+ public void addWFId(String wfId, String parentWorkflowId,
+ String externalName, Blob dataflow) throws SQLException {
+ String sql = "INSERT INTO Workflow (workflowId, parentWorkflowId, externalName, dataflow) "
+ + "VALUES (?, ?, ?, ?)";
+ try (Connection connection = getConnection();
+ PreparedStatement ps = connection.prepareStatement(sql)) {
+ ps.setString(1, wfId);
+ ps.setString(2, parentWorkflowId);
+ ps.setString(3, externalName);
+ ps.setBlob(4, dataflow);
+
+ ps.executeUpdate();
+ }
+ }
+
+ public void addWorkflowRun(String wfId, String workflowRunId)
+ throws SQLException {
+ String sql = "INSERT INTO WorkflowRun (workflowRunId, workflowId) VALUES (?,?)";
+ try (Connection connection = getConnection();
+ PreparedStatement ps = connection.prepareStatement(sql)) {
+ ps.setString(1, workflowRunId);
+ ps.setString(2, wfId);
+
+ ps.executeUpdate();
+ }
+ }
+
+ /**
+ * insert new processor into the provenance DB
+ *
+ * @param name
+ * @throws SQLException
+ */
+ public ProvenanceProcessor addProcessor(String name, String wfID,
+ boolean isTopLevel) throws SQLException {
+ ProvenanceProcessor provProc = new ProvenanceProcessor();
+ provProc.setIdentifier(UUID.randomUUID().toString());
+ provProc.setProcessorName(name);
+ provProc.setWorkflowId(wfID);
+ provProc.setTopLevelProcessor(isTopLevel);
+ // pType is unknown
+ addProcessor(provProc);
+ return provProc;
+ }
+
+ /**
+ * add a processor to the static portion of the DB with given name, type and
+ * workflowId scope
+ *
+ * @param name
+ * @param type
+ * @param workflowId
+ * @throws SQLException
+ */
+ public void addProcessor(ProvenanceProcessor provProc) throws SQLException {
+ String sql = "INSERT INTO Processor (processorName, firstActivityClass, workflowId, isTopLevel, processorId) "
+ + "VALUES (?,?,?,?,?)";
+ try (Connection connection = getConnection();
+ PreparedStatement ps = connection.prepareStatement(sql);) {
+ ps.setString(1, provProc.getProcessorName());
+ ps.setString(2, provProc.getFirstActivityClassName());
+ ps.setString(3, provProc.getWorkflowId());
+ ps.setBoolean(4, provProc.isTopLevelProcessor());
+ ps.setString(5, provProc.getIdentifier());
+
+ ps.executeUpdate();
+ }
+ }
+
+ public void addProcessorEnactment(
+ net.sf.taverna.t2.provenance.lineageservice.utils.ProcessorEnactment enactment)
+ throws SQLException {
+ String sql = "INSERT INTO "
+ + ProcessorEnactmentTable.ProcessorEnactment + "("
+ + ProcessorEnactmentTable.processEnactmentId + ","
+ + ProcessorEnactmentTable.workflowRunId + ","
+ + ProcessorEnactmentTable.processorId + ","
+ + ProcessorEnactmentTable.processIdentifier + ","
+ + ProcessorEnactmentTable.iteration + ","
+ + ProcessorEnactmentTable.parentProcessorEnactmentId + ","
+ + ProcessorEnactmentTable.enactmentStarted + ","
+ + ProcessorEnactmentTable.enactmentEnded + ","
+ + ProcessorEnactmentTable.initialInputsDataBindingId + ","
+ + ProcessorEnactmentTable.finalOutputsDataBindingId
+ + ") VALUES(?,?,?,?,?,?,?,?,?,?)";
+ try (Connection connection = getConnection();
+ PreparedStatement ps = connection.prepareStatement(sql)) {
+ ps.setString(1, enactment.getProcessEnactmentId());
+ ps.setString(2, enactment.getWorkflowRunId());
+ ps.setString(3, enactment.getProcessorId());
+ ps.setString(4, enactment.getProcessIdentifier());
+ ps.setString(5, enactment.getIteration());
+ ps.setString(6, enactment.getParentProcessorEnactmentId());
+ ps.setTimestamp(7, enactment.getEnactmentStarted());
+ ps.setTimestamp(8, enactment.getEnactmentEnded());
+ ps.setString(9, enactment.getInitialInputsDataBindingId());
+ ps.setString(10, enactment.getFinalOutputsDataBindingId());
+ ps.executeUpdate();
+
+ if (logger.isDebugEnabled())
+ logger.debug("adding ProcessorEnactment binding:\n "
+ + enactment);
+ }
+ }
+
+ public String addCollection(String processorId, String collId,
+ String parentCollectionId, String iteration, String portName,
+ String dataflowId) throws SQLException {
+ String newParentCollectionId = null;
+ String sql = "INSERT INTO Collection (processorNameRef, workflowRunId, portName, iteration, parentCollIdRef, collId) "
+ + "VALUES(?, ?, ?, ?, ?, ?)";
+ try (Connection connection = getConnection();
+ PreparedStatement ps = connection.prepareStatement(sql)) {
+ if (parentCollectionId == null)
+ // this is a top-level list
+ parentCollectionId = "TOP";
+
+ newParentCollectionId = collId;
+
+ ps.setString(1, processorId);
+ ps.setString(2, dataflowId);
+ ps.setString(3, portName);
+ ps.setString(4, iteration);
+ ps.setString(5, parentCollectionId);
+ ps.setString(6, collId);
+
+ ps.executeUpdate();
+ }
+
+ return newParentCollectionId;
+ }
+
+ public void addData(String dataRef, String wfInstanceId, Object data)
+ throws SQLException {
+ String sql = "INSERT INTO Data (dataReference,wfInstanceID,data) VALUES (?,?,?)";
+ try (Connection connection = getConnection();
+ PreparedStatement ps = connection.prepareStatement(sql);) {
+ ps.setString(1, dataRef);
+ ps.setString(2, wfInstanceId);
+ ps.setString(3, (String) data);
+
+ ps.executeUpdate();
+
+ cnt++;
+
+ logger.debug("addData executed on data value from char: "
+ + data);
+ } catch (SQLException e) {
+ // the same ID will come in several times -- duplications are
+ // expected, don't panic
+ }
+ }
+
+ /**
+ * OBSOLETE
+ * <p/>
+ * adds (dataRef, data) pairs to the Data table (only for string data)
+ */
+ public void addData(String dataRef, String wfInstanceId, byte[] data)
+ throws SQLException {
+ String sql = "INSERT INTO Data (dataReference,wfInstanceID,data) VALUES (?,?,?)";
+ try (Connection connection = getConnection();
+ PreparedStatement ps = connection.prepareStatement(sql)) {
+ ps.setString(1, dataRef);
+ ps.setString(2, wfInstanceId);
+ ps.setBytes(3, data);
+
+ ps.executeUpdate();
+
+ cnt++;
+
+ logger.debug("addData executed on data value from char: " + data);
+
+ } catch (SQLException e) {
+ // the same ID will come in several times -- duplications are
+ // expected, don't panic
+ }
+ }
+
+ public void addPortBinding(PortBinding vb) throws SQLException {
+ logger.debug("START addVarBinding proc " + vb.getProcessorName()
+ + " port " + vb.getPortName());
+ String sql = "INSERT INTO PortBinding (workflowId, processorNameRef, workflowRunId, portName, valueType, value, ref, collIdRef, iteration,positionInColl) "
+ + "VALUES(?,?,?,?,?,?,?,?,?,?)";
+ try (Connection connection = getConnection();
+ PreparedStatement ps = connection.prepareStatement(sql)) {
+ ps.setString(1, vb.getWorkflowId());
+ ps.setString(2, vb.getProcessorName());
+ ps.setString(3, vb.getWorkflowRunId());
+ ps.setString(4, vb.getPortName());
+ ps.setString(5, vb.getValueType());
+ ps.setString(6, vb.getValue());
+ ps.setString(7, vb.getReference());
+ ps.setString(8, vb.getCollIDRef());
+ ps.setString(9, vb.getIteration());
+ ps.setInt(10, vb.getPositionInColl());
+
+ logger.debug("addVarBinding query: \n" + ps.toString());
+ ps.executeUpdate();
+ logger.debug("insert done");
+
+ logger.debug("COMPLETE addVarBinding proc " + vb.getProcessorName()
+ + " port " + vb.getPortName());
+
+ cnt++; // who uses this?
+ }
+ }
+
+ /**
+ * persists var v back to DB
+ *
+ * @param v
+ * @throws SQLException
+ */
+ public void updatePort(Port v) throws SQLException {
+ String sql = "UPDATE Port SET isInputPort=?, depth=?,"
+ + "resolvedDepth=?, iterationStrategyOrder=? "
+ + "WHERE portId=?";
+ try (Connection connection = getConnection();
+ PreparedStatement ps = connection.prepareStatement(sql)) {
+ ps.setInt(1, v.isInputPort() ? 1 : 0);
+ ps.setInt(2, v.getDepth());
+ if (v.isResolvedDepthSet()) {
+ ps.setInt(3, v.getResolvedDepth());
+ } else {
+ ps.setString(3, null);
+ }
+ ps.setInt(4, v.getIterationStrategyOrder());
+ ps.setString(5, v.getIdentifier());
+ ps.execute();
+ }
+ }
+
+ public void updateProcessorEnactment(
+ net.sf.taverna.t2.provenance.lineageservice.utils.ProcessorEnactment enactment) {
+ String sql = "UPDATE " + ProcessorEnactmentTable.ProcessorEnactment
+ + " SET " + ProcessorEnactmentTable.finalOutputsDataBindingId
+ + "=?, " + ProcessorEnactmentTable.enactmentEnded + "=?"
+ + " WHERE " + ProcessorEnactmentTable.processEnactmentId + "=?";
+ try (Connection connection = getConnection();
+ PreparedStatement ps = connection.prepareStatement(sql)) {
+ ps.setString(1, enactment.getFinalOutputsDataBindingId());
+ ps.setTimestamp(2, enactment.getEnactmentEnded());
+ ps.setString(3, enactment.getProcessEnactmentId());
+
+ ps.executeUpdate();
+ } catch (SQLException e) {
+ logger.warn("**** insert failed for query ", e);
+ }
+ }
+
+ public void updatePortBinding(PortBinding vb) {
+ String sql = "UPDATE PortBinding SET valueType = ?, value = ?, ref = ?, collIdRef = ?, positionInColl = ? "
+ + "WHERE portName = ? AND workflowRunId = ? AND processorNameRef = ? AND iteration = ?" ;
+ try (Connection connection = getConnection();
+ PreparedStatement ps = connection.prepareStatement(sql)) {
+ // Update values
+ ps.setString(1, vb.getValueType());
+ ps.setString(2, vb.getValue());
+ ps.setString(3, vb.getReference());
+ ps.setString(4, vb.getCollIDRef());
+ ps.setInt(5, vb.getPositionInColl());
+ // Where clauses
+ ps.setString(6, vb.getPortName());
+ ps.setString(7, vb.getWorkflowRunId());
+ ps.setString(8, vb.getProcessorName());
+ ps.setString(9, vb.getIteration());
+
+ ps.executeUpdate();
+
+ cnt++;
+
+ } catch (SQLException e) {
+ logger.warn("**** insert failed for query ", e);
+ }
+ }
+
+ public void replaceCollectionRecord(NestedListNode nln, String prevPName,
+ String prevPortName) {
+ String sql = "DELETE FROM Collection WHERE collId = ? AND workflowRunId = ?"
+ + " AND portName = ? AND processorNameRef = ? AND iteration = ?";
+ try (Connection connection = getConnection();
+ PreparedStatement ps = connection.prepareStatement(sql)) {
+ ps.setString(1, nln.getCollectionT2Reference());
+ ps.setString(2, nln.getWorkflowRunId());
+ ps.setString(3, prevPortName);
+ ps.setString(4, prevPName);
+ ps.setString(5, nln.getIteration());
+
+ ps.executeUpdate();
+ } catch (SQLException e) {
+ logger.warn("Error replacing collection record", e);
+ }
+
+ try {
+ addCollection(prevPName, nln.getCollectionT2Reference(),
+ nln.getParentCollIdRef(), nln.getIteration(), prevPortName,
+ nln.getWorkflowRunId());
+ } catch (SQLException e) {
+ logger.warn("Collection insert failed", e);
+ }
+ }
+
+ /**
+ * deletes DB contents for the static structures -- called prior to each run
+ *
+ * @throws SQLException
+ */
+ public void clearDBStatic() throws SQLException {
+ try (Connection connection = getConnection();
+ Statement stmt = connection.createStatement()) {
+ stmt.executeUpdate("DELETE FROM Workflow");
+ stmt.executeUpdate("DELETE FROM Processor");
+ stmt.executeUpdate("DELETE FROM Datalink");
+ stmt.executeUpdate("DELETE FROM Port");
+ stmt.executeUpdate("DELETE FROM " + ActivityTable.Activity);
+ logger.info("DB cleared STATIC");
+ } catch (SQLException e) {
+ logger.warn("Could not clear static database", e);
+ }
+ }
+
+ /**
+ * deletes DB contents for the static structures -- called prior to each run
+ *
+ * @throws SQLException
+ */
+ public void clearDBStatic(String wfID) throws SQLException {
+ try (Connection connection = getConnection()) {
+ try (PreparedStatement ps = connection
+ .prepareStatement("DELETE FROM Workflow WHERE workflowId = ?")) {
+ ps.setString(1, wfID);
+ ps.executeUpdate();
+ }
+ try (PreparedStatement ps = connection
+ .prepareStatement("DELETE FROM Processor WHERE workflowId = ?")) {
+ ps.setString(1, wfID);
+ ps.executeUpdate();
+ }
+ try (PreparedStatement ps = connection
+ .prepareStatement("DELETE FROM Datalink WHERE workflowId = ?")) {
+ ps.setString(1, wfID);
+ ps.executeUpdate();
+ }
+ try (PreparedStatement ps = connection
+ .prepareStatement("DELETE FROM Port WHERE workflowId = ?")) {
+ ps.setString(1, wfID);
+ ps.executeUpdate();
+ }
+ try (PreparedStatement ps = connection
+ .prepareStatement("DELETE FROM " + ActivityTable.Activity
+ + " WHERE " + ActivityTable.workflowId + "=?")) {
+ ps.setString(1, wfID);
+ ps.executeUpdate();
+ }
+ }
+ logger.info("DB cleared STATICfor wfID " + wfID);
+ }
+
+ public Set<String> clearDBDynamic() throws SQLException {
+ return clearDBDynamic(null);
+ }
+
+ private void delete(Connection connection, Object table, String runID) throws SQLException {
+ if (runID != null) {
+ try (PreparedStatement ps = connection
+ .prepareStatement("DELETE FROM " + table
+ + " WHERE workflowRunId = ?")) {
+ ps.setString(1, runID);
+ ps.executeUpdate();
+ }
+ } else
+ try (PreparedStatement ps = connection
+ .prepareStatement("DELETE FROM " + table)) {
+ ps.executeUpdate();
+ }
+ }
+ /**
+ * deletes DB contents for all runs -- for testing purposes
+ *
+ * @throws SQLException
+ */
+ public Set<String> clearDBDynamic(String runID) throws SQLException {
+ Set<String> refsToRemove = collectValueReferences(runID);
+ // collect all relevant refs from PortBinding and Collection
+
+ try (Connection connection = getConnection()) {
+ delete(connection, "WorkflowRun", runID);
+ delete(connection, "PortBinding", runID);
+ delete(connection, "Collection", runID);
+ delete(connection, DataflowInvocationTable.DataflowInvocation, runID);
+ delete(connection, ServiceInvocationTable.ServiceInvocation, runID);
+ delete(connection, ProcessorEnactmentTable.ProcessorEnactment, runID);
+ delete(connection, DataBindingTable.DataBinding, runID);
+ }
+ logger.info("DB cleared DYNAMIC");
+ return refsToRemove;
+ }
+
+ private Set<String> collectValueReferences(String runID)
+ throws SQLException {
+ Set<String> refs = new HashSet<>();
+ try (Connection connection = getConnection()) {
+ String sql = "SELECT value FROM PortBinding";
+ if (runID != null)
+ sql += " WHERE workflowRunId = ?";
+ try (PreparedStatement ps = connection.prepareStatement(sql)) {
+ if (runID != null)
+ ps.setString(1, runID);
+ ResultSet rs = ps.executeQuery();
+ while (rs.next())
+ refs.add(rs.getString("value"));
+ }
+
+ sql = "SELECT collId FROM Collection";
+ if (runID != null)
+ sql += " WHERE workflowRunId = ?";
+ try (PreparedStatement ps = connection.prepareStatement(sql)) {
+ if (runID != null)
+ ps.setString(1, runID);
+ ResultSet rs = ps.executeQuery();
+ while (rs.next())
+ refs.add(rs.getString("collId"));
+ }
+ } catch (SQLException e) {
+ logger.error("Problem collecting value references for: " + runID
+ + " : " + e);
+ }
+ return refs;
+ }
+
+ public void clearDD() {
+ try (Connection connection = getConnection();
+ Statement stmt = connection.createStatement()) {
+ stmt.executeUpdate("DELETE FROM DD");
+ } catch (SQLException e) {
+ logger.warn("Error execting delete query for provenance records", e);
+ }
+ }
+
+ /**
+ * used to support the implementation of
+ *
+ * @param pname
+ * @param vFrom
+ * @param valFrom
+ * @param vTo
+ * @param valTo
+ * @param iteration
+ * @param workflowRunId
+ */
+ public void writeDDRecord(String pFrom, String vFrom, String valFrom,
+ String pTo, String vTo, String valTo, String iteration,
+ String workflowRunId) {
+ String sql = "INSERT INTO DD (PFrom,VFrom,valFrom,PTo,VTo,valTo,iteration,workflowRun) VALUES "
+ + "(?,?,?,?,?,?,?)";
+ try (Connection connection = getConnection();
+ PreparedStatement ps = connection.prepareStatement(sql)) {
+ ps.setString(1, pFrom);
+ ps.setString(2, vFrom);
+ ps.setString(3, valFrom);
+ ps.setString(4, pTo);
+ ps.setString(5, vTo);
+ ps.setString(6, iteration);
+ ps.setString(7, workflowRunId);
+ ps.executeUpdate();
+ } catch (SQLException e) {
+ logger.warn("Error inserting record into DD", e);
+ }
+ }
+
+ public void setQuery(ProvenanceQuery query) {
+ this.pq = query;
+ }
+
+ public ProvenanceQuery getQuery() {
+ return this.pq;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/URIGenerator.java
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/URIGenerator.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/URIGenerator.java
new file mode 100644
index 0000000..94a0b8a
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/URIGenerator.java
@@ -0,0 +1,58 @@
+package net.sf.taverna.t2.provenance.lineageservice;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+public class URIGenerator {
+
+ public String makeT2ReferenceURI(String collId) {
+ // collId is of the form t2:list//<UUID>
+ // map to a proper URI
+
+ String[] tokens = collId.split("//");
+ String type = tokens[0].split(":")[1];
+ String namespace = tokens[1].split("/")[0].split("\\?")[0];
+ String dataId = tokens[1].split("\\?")[1];
+ return "http://ns.taverna.org.uk/2011/data/" + namespace + "/" + type + "/" + dataId;
+ }
+
+ public String makeWFInstanceURI(String workflowRunId) {
+ return "http://ns.taverna.org.uk/2011/run/" + workflowRunId + "/";
+ }
+
+ public String makeWorkflowURI(String wfId) {
+ return "http://ns.taverna.org.uk/2010/workflow/" + wfId + "/";
+ }
+
+ public String makePortURI(String wfId, String pName, String vName,
+ boolean inputPort) {
+ return makeProcessorURI(pName, wfId) + (inputPort ? "in/" : "out/")
+ + escape(vName);
+ }
+
+ public String escape(String part) {
+ try {
+ return new URI(null, null, part.replace("/", "%47"), null)
+ .getRawPath();
+ } catch (URISyntaxException e) {
+ throw new RuntimeException("Can't escape URI part " + part, e);
+ }
+ }
+
+ public String makeProcessorURI(String pName, String wfId) {
+ return makeWorkflowURI(wfId) + "processor/" + escape(pName) + "/";
+ }
+
+ public String makeIteration(String workflowRunId, String workflowId,
+ String processorName, String iteration) {
+ String iterationUri = iteration.replace(',', '-').replace('[', ' ')
+ .replace(']', ' ').trim();
+
+ return makeWFInstanceURI(workflowRunId) + "workflow/" + workflowId
+ + "/processor/" + processorName + "/iteration/" + iterationUri;
+ }
+
+ public URI makeRunUri(String workflowRunId) {
+ return URI.create(makeWFInstanceURI(workflowRunId));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/WorkflowDataProcessor.java
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/WorkflowDataProcessor.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/WorkflowDataProcessor.java
new file mode 100644
index 0000000..25369fd
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/WorkflowDataProcessor.java
@@ -0,0 +1,453 @@
+/**
+ *
+ */
+package net.sf.taverna.t2.provenance.lineageservice;
+
+import static net.sf.taverna.t2.provenance.lineageservice.utils.ProvenanceUtils.iterationToString;
+import static net.sf.taverna.t2.provenance.lineageservice.utils.ProvenanceUtils.parentProcess;
+
+import java.sql.SQLException;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+
+import net.sf.taverna.t2.facade.WorkflowInstanceFacade.State;
+import net.sf.taverna.t2.provenance.item.DataflowRunComplete;
+import net.sf.taverna.t2.provenance.item.ProvenanceItem;
+import net.sf.taverna.t2.provenance.item.WorkflowDataProvenanceItem;
+import net.sf.taverna.t2.provenance.lineageservice.utils.DataBinding;
+import net.sf.taverna.t2.provenance.lineageservice.utils.DataflowInvocation;
+import net.sf.taverna.t2.provenance.lineageservice.utils.Port;
+import net.sf.taverna.t2.provenance.lineageservice.utils.PortBinding;
+import net.sf.taverna.t2.provenance.lineageservice.utils.ProcessorEnactment;
+
+import org.apache.log4j.Logger;
+
+/**
+ * @author paolo
+ * this class manages the outputs from a workflow, as they come along through WorkflowData events
+ */
+public class WorkflowDataProcessor {
+ private static Logger logger = Logger.getLogger(WorkflowDataProcessor.class);
+
+ // set of trees (impl as lists), one for each portName
+ // PM portName not enough must use the WFID as context as well, because the same output portName
+ // may occur in multiple nested workflows
+ Map<String, List<WorkflowDataNode>> workflowDataTrees = new HashMap<>();
+
+ protected Map<String, Timestamp> workflowStarted = new ConcurrentHashMap<>();
+
+ ProvenanceQuery pq=null;
+ ProvenanceWriter pw = null;
+
+ protected Map<String, ProcessorEnactment> invocationProcessToProcessEnactment = new ConcurrentHashMap<>();
+
+ /**
+ * adds the input ProvenanceItem event to the tree structure corresponding
+ * to the portName found in the item. Repeated invocations of this method
+ * incrementally reconstruct the tree structure for each of the workflow
+ * outputs
+ *
+ * @param root
+ */
+ public void addWorkflowDataItem(ProvenanceItem provenanceItem) {
+ WorkflowDataProvenanceItem workflowDataItem = (WorkflowDataProvenanceItem) provenanceItem;
+
+ WorkflowDataNode wdn = new WorkflowDataNode();
+ wdn.setProcessId(provenanceItem.getProcessId());
+ wdn.setPortName(workflowDataItem.getPortName());
+ wdn.setInputPort(workflowDataItem.isInputPort());
+ wdn.setValue(workflowDataItem.getData().toString());
+ int[] index = workflowDataItem.getIndex();
+ String iterationToString = iterationToString(index);
+ wdn.setIndex(iterationToString);
+ wdn.setWorkflowID(workflowDataItem.getWorkflowId());
+
+ if (wdn.getValue().contains("list"))
+ wdn.setList(true); // HACK
+ else
+ wdn.setList(false);
+
+ // position this wdn into the tree associated to its portName
+ List<WorkflowDataNode> aTree = workflowDataTrees.get(wdn.getPortName());
+
+ if (aTree == null) { // first item in the tree
+ aTree = new ArrayList<WorkflowDataNode>();
+ workflowDataTrees.put(wdn.getPortName(), aTree);
+ } else
+ // update parent pointers
+ for (WorkflowDataNode aNode: aTree)
+ if (isParent(wdn.getIndex(), aNode.getIndex())) {
+ aNode.setParent(wdn);
+
+ // set position in collection as the last index in the vector
+ aNode.setRelativePosition(getPosition(aNode));
+ }
+ aTree.add(wdn);
+ }
+
+ /**
+ * writes records to PortBinding or Collection by traversing the trees<br/>
+ * expect this to be invoked after workflow completion
+ *
+ * @param workflowId
+ * the external name of the dataflow (not the UUID)
+ * @param workflowRunId
+ * the runID
+ */
+ public void processTrees(DataflowRunComplete completeEvent,
+ String workflowRunId) {
+ String workflowId = completeEvent.getWorkflowId();
+ logger.debug("processing output trees");
+
+ // i:inputPortName -> t2Ref
+ Map<String, String> workflowPortData = new HashMap<>();
+
+ for (Map.Entry<String, List<WorkflowDataNode>> entry : workflowDataTrees
+ .entrySet()) {
+ String portName = entry.getKey();
+ List<WorkflowDataNode> tree = entry.getValue();
+
+ PortBinding vb = null;
+
+ logger.debug("storing tree for var "+portName+" in workflow with ID "+workflowId+" and instance "+workflowRunId);
+ for (WorkflowDataNode node:tree) {
+ try {
+ if (!node.getWorkflowID().equals(workflowId))
+ continue;
+
+ if (node.getIndex().equals("[]")) {
+ // Store top-level workflow inputs/outputs
+ if (! node.getProcessId().equals(completeEvent.getProcessId()))
+ //logger.warn("Unexpected process ID " + node.getProcessId() + " expected " + completeEvent.getProcessId());
+ continue;
+ String portKey = (node.isInputPort() ? "/i:" : "/o:") + node.getPortName();
+ workflowPortData.put(portKey, node.getValue());
+ }
+
+ if (node.isList) {
+ logger.debug("creating collection entry for "
+ + node.value + " with index " + node.index);
+
+ if (node.getParent() != null) {
+ logger.debug(" and parent " + node.parent.index);
+ // write a collection record to DB
+ getPw().addCollection(workflowId, node.getValue(),
+ node.getParent().getValue(),
+ node.getIndex(), portName, workflowRunId);
+ } else
+ getPw().addCollection(workflowId, node.getValue(),
+ null, node.getIndex(), portName,
+ workflowRunId);
+ } else {
+ logger.debug("creating PortBinding for " + node.value
+ + " with index " + node.index);
+
+ vb = new PortBinding();
+
+ vb.setWorkflowId(workflowId);
+ vb.setWorkflowRunId(workflowRunId);
+
+ vb.setProcessorName(pq.getWorkflow(workflowId)
+ .getExternalName());
+
+ // vb.setValueType(); // TODO not sure what to set this to
+ vb.setPortName(portName);
+ vb.setIteration(node.getIndex());
+ vb.setValue(node.getValue());
+
+ if (node.getParent() != null) {
+ logger.debug(" in collection "
+ + node.getParent().value + " with index "
+ + node.getParent().getIndex());
+
+ vb.setCollIDRef(node.getParent().getValue());
+ vb.setPositionInColl(node.getRelativePosition());
+ } else
+ vb.setPositionInColl(1); // default
+
+ try {
+ getPw().addPortBinding(vb);
+ } catch (SQLException e) {
+ logger.debug("Problem processing trees for workflow: "
+ + workflowId
+ + " instance: "
+ + workflowRunId
+ + " : updating instead of inserting");
+ getPw().updatePortBinding(vb);
+ }
+ }
+ } catch (SQLException e) {
+ logger.debug(
+ "Database problem processing trees for workflow: "
+ + workflowId + " instance: "
+ + workflowRunId + " : " + workflowId, e);
+ }
+ }
+ }
+
+ List<Port> ports = getPq().getPortsForDataflow(workflowId);
+ String processId = completeEvent.getProcessId();
+
+ DataflowInvocation invocation = new DataflowInvocation();
+ invocation.setDataflowInvocationId(UUID.randomUUID().toString());
+ invocation.setWorkflowId(workflowId);
+ invocation.setWorkflowRunId(workflowRunId);
+
+ String parentProcessId = parentProcess(processId, 1);
+ if (parentProcessId != null) {
+ ProcessorEnactment procAct = invocationProcessToProcessEnactment
+ .get(parentProcessId);
+ if (procAct != null)
+ invocation.setParentProcessorEnactmentId(procAct
+ .getProcessEnactmentId());
+ }
+
+ invocation.setInvocationStarted(workflowStarted.get(completeEvent
+ .getParentId()));
+ invocation.setInvocationEnded(completeEvent.getInvocationEnded());
+ invocation.setCompleted(completeEvent.getState()
+ .equals(State.completed));
+
+ // Register data
+ String inputsDataBindingId = UUID.randomUUID().toString();
+ String outputsDataBindingId = UUID.randomUUID().toString();
+ for (Port port : ports) {
+ String portKey = (port.isInputPort() ? "/i:" : "/o:")
+ + port.getPortName();
+ String t2Reference = workflowPortData.get(portKey);
+ if (t2Reference == null) {
+ logger.warn("No workflow port data for " + portKey);
+ continue;
+ }
+ DataBinding dataBinding = new DataBinding();
+ dataBinding
+ .setDataBindingId(port.isInputPort() ? inputsDataBindingId
+ : outputsDataBindingId);
+ dataBinding.setPort(port);
+ dataBinding.setT2Reference(t2Reference);
+ dataBinding.setWorkflowRunId(workflowRunId);
+ try {
+ pw.addDataBinding(dataBinding);
+ } catch (SQLException e) {
+ logger.warn("Could not add databinding for " + portKey, e);
+ }
+ }
+
+ invocation.setInputsDataBindingId(inputsDataBindingId);
+ invocation.setOutputsDataBindingId(outputsDataBindingId);
+ try {
+ pw.addDataflowInvocation(invocation);
+ } catch (SQLException e) {
+ logger.warn("Could not store dataflow invocation for " + processId,
+ e);
+ }
+ }
+
+
+ /**
+ * @param node
+ * @return the last digit in the index
+ */
+ private int getPosition(WorkflowDataNode node) {
+ String[] vector = node.getIndex()
+ .substring(1, node.getIndex().length() - 1).split(",");
+ //TODO need some logic here to avoid trying to parse "" as integer, this is my try
+
+ if ((vector[vector.length-1]).equals(""))
+ return 1;
+ return Integer.parseInt(vector[vector.length - 1]) + 1;
+ }
+
+ private boolean isParent(String index1, String index2) {
+ // strip first and last '[' ']'
+ String index11 = index1.substring(1, index1.length() - 1);
+ String index22 = index2.substring(1, index2.length() - 1);
+
+ String[] tokens1 = index11.split(",");
+ String[] tokens2 = index22.split(",");
+
+ // [] cannot be parent of [x1,x2,...] with >= 2 elements
+ if (index11.equals("") && tokens2.length > 1)
+ return false;
+
+ // [] is parent of any [x]
+ if (index11.equals("") && tokens2.length == 1)
+ return true;
+
+ // [x1,x2, ...,xk] cannot be parent of [x1,x2,...xh] when k < h-1
+ // because [x1,x2,...xh] is more than one level deeper than [x1,x2, ...,xk]
+ if (tokens1.length != tokens2.length - 1)
+ return false;
+
+ return index22.startsWith(index11);
+ }
+
+ static class WorkflowDataNode {
+ private String portName;
+ private String value;
+ private String index;
+ private String workflowID;
+ private int relativePosition;
+ private boolean isList;
+ private WorkflowDataNode parent;
+ private String processId;
+ private boolean isInputPort;
+
+ public String getProcessId() {
+ return processId;
+ }
+
+ /**
+ * @return the value
+ */
+ public String getValue() {
+ return value;
+ }
+
+ public void setProcessId(String processId) {
+ this.processId = processId;
+
+ }
+
+ /**
+ * @param value
+ * the value to set
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ /**
+ * @return the index
+ */
+ public String getIndex() {
+ return index;
+ }
+
+ /**
+ * @param index
+ * the index to set
+ */
+ public void setIndex(String index) {
+ this.index = index;
+ }
+
+ /**
+ * @return the portName
+ */
+ public String getPortName() {
+ return portName;
+ }
+
+ /**
+ * @param portName
+ * the portName to set
+ */
+ public void setPortName(String portName) {
+ this.portName = portName;
+ }
+
+ /**
+ * @return the isList
+ */
+ public boolean isList() {
+ return isList;
+ }
+
+ /**
+ * @param isList
+ * the isList to set
+ */
+ public void setList(boolean isList) {
+ this.isList = isList;
+ }
+
+ /**
+ * @return the parent
+ */
+ public WorkflowDataNode getParent() {
+ return parent;
+ }
+
+ /**
+ * @param parent
+ * the parent to set
+ */
+ public void setParent(WorkflowDataNode parent) {
+ this.parent = parent;
+ }
+
+ /**
+ * @return the relativePosition
+ */
+ public int getRelativePosition() {
+ return relativePosition;
+ }
+
+ /**
+ * @param relativePosition
+ * the relativePosition to set
+ */
+ public void setRelativePosition(int relativePosition) {
+ this.relativePosition = relativePosition;
+ }
+
+ /**
+ * @return the workflowID
+ */
+ public String getWorkflowID() {
+ return workflowID;
+ }
+
+ /**
+ * @param workflowID
+ * the workflowID to set
+ */
+ public void setWorkflowID(String workflowID) {
+ this.workflowID = workflowID;
+ }
+
+ public void setInputPort(boolean isInputPort) {
+ this.isInputPort = isInputPort;
+ }
+
+ public boolean isInputPort() {
+ return isInputPort;
+ }
+ }
+
+ /**
+ * @return the pq
+ */
+ public ProvenanceQuery getPq() {
+ return pq;
+ }
+
+ /**
+ * @param pq
+ * the pq to set
+ */
+ public void setPq(ProvenanceQuery pq) {
+ this.pq = pq;
+ }
+
+ /**
+ * @return the pw
+ */
+ public ProvenanceWriter getPw() {
+ return pw;
+ }
+
+ /**
+ * @param pw
+ * the pw to set
+ */
+ public void setPw(ProvenanceWriter pw) {
+ this.pw = pw;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/ActivityType.java
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/ActivityType.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/ActivityType.java
new file mode 100644
index 0000000..b5f8644
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/ActivityType.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester
+ *
+ * Modifications to the initial code base are copyright of their
+ * respective authors, or their employers as appropriate.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package net.sf.taverna.t2.provenance.lineageservice.types;
+
+import net.sf.taverna.t2.provenance.lineageservice.types.ProvenanceEventType;
+
+/**
+ *
+ * @author Paolo Missier
+ *
+ */
+public class ActivityType implements ProvenanceEventType {
+ private IterationType[] iteration;
+
+ private String id; // attribute
+
+ public ActivityType() {
+ }
+
+ public ActivityType(IterationType[] iteration, String id) {
+ this.iteration = iteration;
+ this.id = id;
+ }
+
+ /**
+ * Gets the iteration value for this ActivityType.
+ *
+ * @return iteration
+ */
+ public IterationType[] getIteration() {
+ return iteration;
+ }
+
+ /**
+ * Sets the iteration value for this ActivityType.
+ *
+ * @param iteration
+ */
+ public void setIteration(IterationType[] iteration) {
+ this.iteration = iteration;
+ }
+
+ public IterationType getIteration(int i) {
+ return this.iteration[i];
+ }
+
+ public void setIteration(int i, IterationType _value) {
+ this.iteration[i] = _value;
+ }
+
+ /**
+ * Gets the id value for this ActivityType.
+ *
+ * @return id
+ */
+ public java.lang.String getId() {
+ return id;
+ }
+
+ /**
+ * Sets the id value for this ActivityType.
+ *
+ * @param id
+ */
+ public void setId(java.lang.String id) {
+ this.id = id;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/DataDocumentType.java
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/DataDocumentType.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/DataDocumentType.java
new file mode 100644
index 0000000..27fa322
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/DataDocumentType.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester
+ *
+ * Modifications to the initial code base are copyright of their
+ * respective authors, or their employers as appropriate.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package net.sf.taverna.t2.provenance.lineageservice.types;
+
+/**
+ *
+ * @author Paolo Missier
+ *
+ */
+public class DataDocumentType implements ProvenanceEventType {
+ private String reference;
+ private String id; // attribute
+
+ public DataDocumentType() {
+ }
+
+ public DataDocumentType(String reference, String id) {
+ this.reference = reference;
+ this.id = id;
+ }
+
+ /**
+ * Gets the reference value for this DataDocumentType.
+ *
+ * @return reference
+ */
+ public String getReference() {
+ return reference;
+ }
+
+ /**
+ * Sets the reference value for this DataDocumentType.
+ *
+ * @param reference
+ */
+ public void setReference(String reference) {
+ this.reference = reference;
+ }
+
+ /**
+ * Gets the id value for this DataDocumentType.
+ *
+ * @return id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Sets the id value for this DataDocumentType.
+ *
+ * @param id
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/IterationType.java
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/IterationType.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/IterationType.java
new file mode 100644
index 0000000..be5389b
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/IterationType.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester
+ *
+ * Modifications to the initial code base are copyright of their
+ * respective authors, or their employers as appropriate.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package net.sf.taverna.t2.provenance.lineageservice.types;
+
+/**
+ *
+ * @author Paolo Missier
+ *
+ */
+public class IterationType implements ProvenanceEventType {
+ private PortsSequenceType inputdata;
+ private PortsSequenceType outputdata;
+ private String id; // attribute
+
+ public IterationType() {
+ }
+
+ public IterationType(PortsSequenceType inputdata,
+ PortsSequenceType outputdata, String id) {
+ this.inputdata = inputdata;
+ this.outputdata = outputdata;
+ this.id = id;
+ }
+
+ /**
+ * Gets the inputdata value for this IterationType.
+ *
+ * @return inputdata
+ */
+ public PortsSequenceType getInputdata() {
+ return inputdata;
+ }
+
+ /**
+ * Sets the inputdata value for this IterationType.
+ *
+ * @param inputdata
+ */
+ public void setInputdata(PortsSequenceType inputdata) {
+ this.inputdata = inputdata;
+ }
+
+ /**
+ * Gets the outputdata value for this IterationType.
+ *
+ * @return outputdata
+ */
+ public PortsSequenceType getOutputdata() {
+ return outputdata;
+ }
+
+ /**
+ * Sets the outputdata value for this IterationType.
+ *
+ * @param outputdata
+ */
+ public void setOutputdata(PortsSequenceType outputdata) {
+ this.outputdata = outputdata;
+ }
+
+ /**
+ * Gets the id value for this IterationType.
+ *
+ * @return id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Sets the id value for this IterationType.
+ *
+ * @param id
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/LiteralType.java
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/LiteralType.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/LiteralType.java
new file mode 100644
index 0000000..2b87758
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/LiteralType.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester
+ *
+ * Modifications to the initial code base are copyright of their
+ * respective authors, or their employers as appropriate.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package net.sf.taverna.t2.provenance.lineageservice.types;
+
+/**
+ *
+ * @author Paolo Missier
+ *
+ */
+public class LiteralType implements ProvenanceEventType {
+ private String id; // attribute
+
+ public LiteralType() {
+ }
+
+ public LiteralType(String id) {
+ this.id = id;
+ }
+
+ /**
+ * Gets the id value for this LiteralType.
+ *
+ * @return id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Sets the id value for this LiteralType.
+ *
+ * @param id
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/PortType.java
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/PortType.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/PortType.java
new file mode 100644
index 0000000..6978ac9
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/PortType.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester
+ *
+ * Modifications to the initial code base are copyright of their
+ * respective authors, or their employers as appropriate.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package net.sf.taverna.t2.provenance.lineageservice.types;
+
+/**
+ *
+ * @author Paolo Missier
+ *
+ */
+public class PortType implements ProvenanceEventType {
+ private DataDocumentType dataDocument;
+ private LiteralType literal;
+ private String name; // attribute
+
+ public PortType() {
+ }
+
+ public PortType(DataDocumentType dataDocument, LiteralType literal,
+ String name) {
+ this.dataDocument = dataDocument;
+ this.literal = literal;
+ this.name = name;
+ }
+
+ /**
+ * Gets the dataDocument value for this PortType.
+ *
+ * @return dataDocument
+ */
+ public DataDocumentType getDataDocument() {
+ return dataDocument;
+ }
+
+ /**
+ * Sets the dataDocument value for this PortType.
+ *
+ * @param dataDocument
+ */
+ public void setDataDocument(DataDocumentType dataDocument) {
+ this.dataDocument = dataDocument;
+ }
+
+ /**
+ * Gets the literal value for this PortType.
+ *
+ * @return literal
+ */
+ public LiteralType getLiteral() {
+ return literal;
+ }
+
+ /**
+ * Sets the literal value for this PortType.
+ *
+ * @param literal
+ */
+ public void setLiteral(LiteralType literal) {
+ this.literal = literal;
+ }
+
+ /**
+ * Gets the name value for this PortType.
+ *
+ * @return name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the name value for this PortType.
+ *
+ * @param name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/PortsSequenceType.java
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/PortsSequenceType.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/PortsSequenceType.java
new file mode 100644
index 0000000..5eddde8
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/PortsSequenceType.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester
+ *
+ * Modifications to the initial code base are copyright of their
+ * respective authors, or their employers as appropriate.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package net.sf.taverna.t2.provenance.lineageservice.types;
+
+/**
+ *
+ * @author Paolo Missier
+ *
+ */
+public class PortsSequenceType implements ProvenanceEventType {
+ private PortType[] port;
+
+ public PortsSequenceType() {
+ }
+
+ public PortsSequenceType(PortType[] port) {
+ this.port = port;
+ }
+
+ /**
+ * Gets the port value for this PortsSequenceType.
+ *
+ * @return port
+ */
+ public PortType[] getPort() {
+ return port;
+ }
+
+ /**
+ * Sets the port value for this PortsSequenceType.
+ *
+ * @param port
+ */
+ public void setPort(PortType[] port) {
+ this.port = port;
+ }
+
+ public PortType getPort(int i) {
+ return this.port[i];
+ }
+
+ public void setPort(int i, PortType _value) {
+ this.port[i] = _value;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/ProcessType.java
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/ProcessType.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/ProcessType.java
new file mode 100644
index 0000000..163bc93
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/ProcessType.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester
+ *
+ * Modifications to the initial code base are copyright of their
+ * respective authors, or their employers as appropriate.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package net.sf.taverna.t2.provenance.lineageservice.types;
+
+/**
+ *
+ * @author Paolo Missier
+ *
+ */
+public class ProcessType implements ProvenanceEventType {
+ private ProcessorType[] processor;
+ private String dataflowID; // attribute
+ private String facadeID; // attribute
+
+ public ProcessType() {
+ }
+
+ public ProcessType(ProcessorType[] processor, String dataflowID,
+ String facadeID) {
+ this.processor = processor;
+ this.dataflowID = dataflowID;
+ this.facadeID = facadeID;
+ }
+
+ /**
+ * Gets the processor value for this ProcessType.
+ *
+ * @return processor
+ */
+ public ProcessorType[] getProcessor() {
+ return processor;
+ }
+
+ /**
+ * Sets the processor value for this ProcessType.
+ *
+ * @param processor
+ */
+ public void setProcessor(ProcessorType[] processor) {
+ this.processor = processor;
+ }
+
+ public ProcessorType getProcessor(int i) {
+ return this.processor[i];
+ }
+
+ public void setProcessor(int i, ProcessorType _value) {
+ this.processor[i] = _value;
+ }
+
+ /**
+ * Gets the dataflowID value for this ProcessType.
+ *
+ * @return dataflowID
+ */
+ public String getDataflowID() {
+ return dataflowID;
+ }
+
+ /**
+ * Sets the dataflowID value for this ProcessType.
+ *
+ * @param dataflowID
+ */
+ public void setDataflowID(String dataflowID) {
+ this.dataflowID = dataflowID;
+ }
+
+ /**
+ * Gets the facadeID value for this ProcessType.
+ *
+ * @return facadeID
+ */
+ public String getFacadeID() {
+ return facadeID;
+ }
+
+ /**
+ * Sets the facadeID value for this ProcessType.
+ *
+ * @param facadeID
+ */
+ public void setFacadeID(String facadeID) {
+ this.facadeID = facadeID;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/ProcessorType.java
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/ProcessorType.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/ProcessorType.java
new file mode 100644
index 0000000..53285df
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/ProcessorType.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester
+ *
+ * Modifications to the initial code base are copyright of their
+ * respective authors, or their employers as appropriate.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package net.sf.taverna.t2.provenance.lineageservice.types;
+
+/**
+ *
+ * @author Paolo Missier
+ *
+ */
+public class ProcessorType implements ProvenanceEventType {
+ private ActivityType[] activity;
+ private String id; // attribute
+
+ public ProcessorType() {
+ }
+
+ public ProcessorType(ActivityType[] activity, String id) {
+ this.activity = activity;
+ this.id = id;
+ }
+
+ /**
+ * Gets the activity value for this ProcessorType.
+ *
+ * @return activity
+ */
+ public ActivityType[] getActivity() {
+ return activity;
+ }
+
+ /**
+ * Sets the activity value for this ProcessorType.
+ *
+ * @param activity
+ */
+ public void setActivity(ActivityType[] activity) {
+ this.activity = activity;
+ }
+
+ public ActivityType getActivity(int i) {
+ return this.activity[i];
+ }
+
+ public void setActivity(int i, ActivityType _value) {
+ this.activity[i] = _value;
+ }
+
+ /**
+ * Gets the id value for this ProcessorType.
+ *
+ * @return id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Sets the id value for this ProcessorType.
+ *
+ * @param id
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/ProvenanceEventType.java
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/ProvenanceEventType.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/ProvenanceEventType.java
new file mode 100644
index 0000000..6ebe680
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/types/ProvenanceEventType.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester
+ *
+ * Modifications to the initial code base are copyright of their
+ * respective authors, or their employers as appropriate.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package net.sf.taverna.t2.provenance.lineageservice.types;
+
+/**
+ * Used by an implementation of Provenance to identify the item type
+ *
+ * @author Paolo Missier
+ */
+public interface ProvenanceEventType {
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/Activity.java
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/Activity.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/Activity.java
new file mode 100644
index 0000000..819fce8
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/Activity.java
@@ -0,0 +1,63 @@
+package net.sf.taverna.t2.provenance.lineageservice.utils;
+
+public class Activity {
+ private String activityId;
+
+ @Override
+ public int hashCode() {
+ return 31 + ((activityId == null) ? 0 : activityId.hashCode());
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("Activity [activityDefinition=");
+ builder.append(activityDefinition);
+ builder.append("]");
+ return builder.toString();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Activity other = (Activity) obj;
+ if (activityId == null) {
+ if (other.activityId != null)
+ return false;
+ } else if (!activityId.equals(other.activityId))
+ return false;
+ return true;
+ }
+
+ private String activityDefinition;
+ private Workflow workflow;
+
+ public String getActivityId() {
+ return activityId;
+ }
+
+ public void setActivityId(String activityId) {
+ this.activityId = activityId;
+ }
+
+ public String getActivityDefinition() {
+ return activityDefinition;
+ }
+
+ public void setActivityDefinition(String activityDefinition) {
+ this.activityDefinition = activityDefinition;
+ }
+
+ public Workflow getWorkflow() {
+ return workflow;
+ }
+
+ public void setWorkflow(Workflow workflow) {
+ this.workflow = workflow;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/Collection.java
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/Collection.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/Collection.java
new file mode 100644
index 0000000..56340db
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/Collection.java
@@ -0,0 +1,68 @@
+package net.sf.taverna.t2.provenance.lineageservice.utils;
+
+public class Collection {
+ private String identifier;
+ private String parentIdentifier;
+ private String workflowRunIdentifier;
+ private String processorName;
+ private String portName;
+ private String iteration;
+ private String collId;
+
+ public String getIdentifier() {
+ return identifier;
+ }
+
+ public void setIdentifier(String identifier) {
+ this.identifier = identifier;
+ }
+
+ public String getParentIdentifier() {
+ return parentIdentifier;
+ }
+
+ public void setParentIdentifier(String parentIdentifier) {
+ this.parentIdentifier = parentIdentifier;
+ }
+
+ public String getWorkflowRunIdentifier() {
+ return workflowRunIdentifier;
+ }
+
+ public void setWorkflowRunIdentifier(String workflowRunIdentifier) {
+ this.workflowRunIdentifier = workflowRunIdentifier;
+ }
+
+ public String getProcessorName() {
+ return processorName;
+ }
+
+ public void setProcessorName(String processorName) {
+ this.processorName = processorName;
+ }
+
+ public String getPortName() {
+ return portName;
+ }
+
+ public void setPortName(String portName) {
+ this.portName = portName;
+ }
+
+ public String getIteration() {
+ return iteration;
+ }
+
+ public void setIteration(String iteration) {
+ this.iteration = iteration;
+ }
+
+ public void setCollId(String collId) {
+ this.collId = collId;
+ }
+
+ public String getCollId() {
+ return collId;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/DDRecord.java
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/DDRecord.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/DDRecord.java
new file mode 100644
index 0000000..ec762c0
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/DDRecord.java
@@ -0,0 +1,149 @@
+/**
+ *
+ */
+package net.sf.taverna.t2.provenance.lineageservice.utils;
+
+/**
+ * a simple bean to hold a database record from the DD table
+ *
+ * @author paolo
+ *
+ */
+public class DDRecord {
+
+ private String PFrom;
+ private String PTo;
+ private String vTo;
+ private String valTo;
+ private String vFrom;
+ private String valFrom;
+ private String iteration;
+ public boolean isInput;
+
+ @Override
+ public String toString() {
+ return new String("proc: " + PFrom + " vFrom: " + vFrom + " valFrom: "
+ + valFrom + "PTo: " + PTo + " vTo: " + vTo + " valTo: " + valTo);
+ }
+
+ /**
+ * @return the vTo
+ */
+ public String getVTo() {
+ return vTo;
+ }
+
+ /**
+ * @param to
+ * the vTo to set
+ */
+ public void setVTo(String to) {
+ vTo = to;
+ }
+
+ /**
+ * @return the valTo
+ */
+ public String getValTo() {
+ return valTo;
+ }
+
+ /**
+ * @param valTo
+ * the valTo to set
+ */
+ public void setValTo(String valTo) {
+ this.valTo = valTo;
+ }
+
+ /**
+ * @return the vFrom
+ */
+ public String getVFrom() {
+ return vFrom;
+ }
+
+ /**
+ * @param from
+ * the vFrom to set
+ */
+ public void setVFrom(String from) {
+ vFrom = from;
+ }
+
+ /**
+ * @return the valFrom
+ */
+ public String getValFrom() {
+ return valFrom;
+ }
+
+ /**
+ * @param valFrom
+ * the valFrom to set
+ */
+ public void setValFrom(String valFrom) {
+ this.valFrom = valFrom;
+ }
+
+ /**
+ * @return the isInput
+ */
+ public boolean isInput() {
+ return isInput;
+ }
+
+ /**
+ * @param isInput
+ * the isInput to set
+ */
+ public void setInput(boolean isInput) {
+ this.isInput = isInput;
+ }
+
+ /**
+ * @return the pFrom
+ */
+ public String getPFrom() {
+ return PFrom;
+ }
+
+ /**
+ * @param from
+ * the pFrom to set
+ */
+ public void setPFrom(String from) {
+ PFrom = from;
+ }
+
+ /**
+ * @return the pTo
+ */
+ public String getPTo() {
+ return PTo;
+ }
+
+ /**
+ * @param to
+ * the pTo to set
+ */
+ public void setPTo(String to) {
+ PTo = to;
+ }
+
+ /**
+ * @return the iteration
+ */
+ public String getIteration() {
+ return iteration;
+ }
+
+ /**
+ * @param iteration
+ * the iteration to set
+ */
+ public void setIteration(String iteration) {
+ this.iteration = iteration;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/DataBinding.java
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/DataBinding.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/DataBinding.java
new file mode 100644
index 0000000..3b4f123
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/DataBinding.java
@@ -0,0 +1,82 @@
+package net.sf.taverna.t2.provenance.lineageservice.utils;
+
+public class DataBinding {
+ private String dataBindingId;
+ private Port port;
+ private String t2Reference;
+ private String workflowRunId;
+
+ public String getDataBindingId() {
+ return dataBindingId;
+ }
+
+ public void setDataBindingId(String dataBindingId) {
+ this.dataBindingId = dataBindingId;
+ }
+
+ public Port getPort() {
+ return port;
+ }
+
+ public void setPort(Port port) {
+ this.port = port;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 31 + ((dataBindingId == null) ? 0 : dataBindingId
+ .hashCode());
+ return 31 * result + ((port == null) ? 0 : port.hashCode());
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("DataBinding [dataBindingId=");
+ builder.append(dataBindingId);
+ builder.append(", port=");
+ builder.append(port);
+ builder.append(", t2Reference=");
+ builder.append(t2Reference);
+ builder.append("]");
+ return builder.toString();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ DataBinding other = (DataBinding) obj;
+ if (dataBindingId == null) {
+ if (other.dataBindingId != null)
+ return false;
+ } else if (!dataBindingId.equals(other.dataBindingId))
+ return false;
+ if (port == null) {
+ if (other.port != null)
+ return false;
+ } else if (!port.equals(other.port))
+ return false;
+ return true;
+ }
+
+ public String getT2Reference() {
+ return t2Reference;
+ }
+
+ public void setT2Reference(String t2Reference) {
+ this.t2Reference = t2Reference;
+ }
+
+ public String getWorkflowRunId() {
+ return workflowRunId;
+ }
+
+ public void setWorkflowRunId(String workflowRunId) {
+ this.workflowRunId = workflowRunId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/DataLink.java
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/DataLink.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/DataLink.java
new file mode 100644
index 0000000..db2e42a
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/DataLink.java
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester
+ *
+ * Modifications to the initial code base are copyright of their
+ * respective authors, or their employers as appropriate.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package net.sf.taverna.t2.provenance.lineageservice.utils;
+
+/**
+ * @author paolo
+ *
+ */
+
+public class DataLink {
+ private String workflowId;
+ private String sourcePortId;
+ private String sourceProcessorName;
+ private String sourcePortName;
+ private String destinationPortId;
+ private String destinationProcessorName;
+ private String destinationPortName;
+
+ /**
+ * @return the workflowId
+ */
+ public String getWorkflowId() {
+ return workflowId;
+ }
+
+ /**
+ * @param workflowId
+ * the workflowId to set
+ */
+ public void setWorkflowId(String workflowRunId) {
+ this.workflowId = workflowRunId;
+ }
+
+ public String getSourcePortId() {
+ return sourcePortId;
+ }
+
+ public void setSourcePortId(String sourcePortId) {
+ this.sourcePortId = sourcePortId;
+ }
+
+ /**
+ * @return the sourceProcessorName
+ */
+ public String getSourceProcessorName() {
+ return sourceProcessorName;
+ }
+
+ /**
+ * @param sourceProcessorName
+ * the sourceProcessorName to set
+ */
+ public void setSourceProcessorName(String sourceProcessorName) {
+ this.sourceProcessorName = sourceProcessorName;
+ }
+
+ /**
+ * @return the sourcePortName
+ */
+ public String getSourcePortName() {
+ return sourcePortName;
+ }
+
+ /**
+ * @param sourcePortName
+ * the sourcePortName to set
+ */
+ public void setSourcePortName(String sourcePortName) {
+ this.sourcePortName = sourcePortName;
+ }
+
+ public String getDestinationPortId() {
+ return destinationPortId;
+ }
+
+ public void setDestinationPortId(String destinationPortId) {
+ this.destinationPortId = destinationPortId;
+ }
+
+ /**
+ * @return the sourceprocessorNameRef
+ */
+ public String getDestinationProcessorName() {
+ return destinationProcessorName;
+ }
+
+ /**
+ * @param sourceprocessorNameRef
+ * the sourceprocessorNameRef to set
+ */
+ public void setDestinationProcessorName(String destinationProcessorName) {
+ this.destinationProcessorName = destinationProcessorName;
+ }
+
+ /**
+ * @return the destinationPortName
+ */
+ public String getDestinationPortName() {
+ return destinationPortName;
+ }
+
+ /**
+ * @param destinationPortName
+ * the destinationPortName to set
+ */
+ public void setDestinationPortName(String destinationPortName) {
+ this.destinationPortName = destinationPortName;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/DataValueExtractor.java
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/DataValueExtractor.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/DataValueExtractor.java
new file mode 100644
index 0000000..8480197
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/DataValueExtractor.java
@@ -0,0 +1,23 @@
+/**
+ *
+ */
+package net.sf.taverna.t2.provenance.lineageservice.utils;
+
+/**
+ * @author paolo
+ *
+ */
+public interface DataValueExtractor {
+
+ /**
+ * extracts a printable string from a more complex object. This is not the
+ * same as toString() as it is applied to an object, rather than being a
+ * method on the object itself
+ *
+ * @param complexContent
+ * should really be a byte array FIXME
+ * @return
+ */
+ public String extractString(Object complexContent);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/DataflowInvocation.java
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/DataflowInvocation.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/DataflowInvocation.java
new file mode 100644
index 0000000..f838f79
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/DataflowInvocation.java
@@ -0,0 +1,118 @@
+package net.sf.taverna.t2.provenance.lineageservice.utils;
+
+import java.sql.Timestamp;
+
+public class DataflowInvocation {
+ private String dataflowInvocationId;
+ private String workflowId;
+ private String workflowRunId;
+ private String parentProcessorEnactmentId;
+ private String inputsDataBindingId;
+ private String outputsDataBindingId;
+ private Timestamp invocationEnded;
+ private Timestamp invocationStarted;
+ private boolean completed;
+
+ @Override
+ public int hashCode() {
+ return 31 + ((dataflowInvocationId == null) ? 0 : dataflowInvocationId
+ .hashCode());
+ }
+
+ @Override
+ public String toString() {
+ return "DataflowInvocation [dataflowInvocationId="
+ + dataflowInvocationId + ", parentProcessorEnactmentId="
+ + parentProcessorEnactmentId + ", workflowRunId="
+ + workflowRunId + "]";
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ DataflowInvocation other = (DataflowInvocation) obj;
+ if (dataflowInvocationId == null) {
+ if (other.dataflowInvocationId != null)
+ return false;
+ } else if (!dataflowInvocationId.equals(other.dataflowInvocationId))
+ return false;
+ return true;
+ }
+
+ public String getDataflowInvocationId() {
+ return dataflowInvocationId;
+ }
+
+ public void setDataflowInvocationId(String dataflowInvocationId) {
+ this.dataflowInvocationId = dataflowInvocationId;
+ }
+
+ public String getWorkflowId() {
+ return workflowId;
+ }
+
+ public void setWorkflowId(String workflowId) {
+ this.workflowId = workflowId;
+ }
+
+ public String getWorkflowRunId() {
+ return workflowRunId;
+ }
+
+ public void setWorkflowRunId(String workflowRunId) {
+ this.workflowRunId = workflowRunId;
+ }
+
+ public String getParentProcessorEnactmentId() {
+ return parentProcessorEnactmentId;
+ }
+
+ public void setParentProcessorEnactmentId(String parentProcessorEnactmentId) {
+ this.parentProcessorEnactmentId = parentProcessorEnactmentId;
+ }
+
+ public String getInputsDataBindingId() {
+ return inputsDataBindingId;
+ }
+
+ public void setInputsDataBindingId(String inputsDataBindingId) {
+ this.inputsDataBindingId = inputsDataBindingId;
+ }
+
+ public String getOutputsDataBindingId() {
+ return outputsDataBindingId;
+ }
+
+ public void setOutputsDataBindingId(String outputsDataBindingId) {
+ this.outputsDataBindingId = outputsDataBindingId;
+ }
+
+ public Timestamp getInvocationEnded() {
+ return invocationEnded;
+ }
+
+ public void setInvocationEnded(Timestamp invocationEnded) {
+ this.invocationEnded = invocationEnded;
+ }
+
+ public Timestamp getInvocationStarted() {
+ return invocationStarted;
+ }
+
+ public void setInvocationStarted(Timestamp invocationStarted) {
+ this.invocationStarted = invocationStarted;
+ }
+
+ public void setCompleted(boolean completed) {
+ this.completed = completed;
+ }
+
+ public boolean getCompleted() {
+ return completed;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/NestedListNode.java
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/NestedListNode.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/NestedListNode.java
new file mode 100644
index 0000000..c17a11d
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/NestedListNode.java
@@ -0,0 +1,107 @@
+/**
+ *
+ */
+package net.sf.taverna.t2.provenance.lineageservice.utils;
+
+/**
+ * @author paolo
+ *
+ */
+public class NestedListNode {
+ private String collectionT2Reference;
+ private String parentCollectionT2Reference;
+ private String workflowRunId;
+ private String processorName;
+ private String portName;
+ private String iteration;
+
+ /**
+ * @return the collectionT2Reference
+ */
+ public String getCollectionT2Reference() {
+ return collectionT2Reference;
+ }
+
+ /**
+ * @param collectionT2Reference
+ * the collectionT2Reference to set
+ */
+ public void setCollectionT2Reference(String collectionT2Reference) {
+ this.collectionT2Reference = collectionT2Reference;
+ }
+
+ /**
+ * @return the parentCollIdRef
+ */
+ public String getParentCollIdRef() {
+ return parentCollectionT2Reference;
+ }
+
+ /**
+ * @param parentCollIdRef
+ * the parentCollIdRef to set
+ */
+ public void setParentCollIdRef(String parentCollIdRef) {
+ this.parentCollectionT2Reference = parentCollIdRef;
+ }
+
+ /**
+ * @return the workflowRunId
+ */
+ public String getWorkflowRunId() {
+ return workflowRunId;
+ }
+
+ /**
+ * @param workflowRunId
+ * the workflowRunId to set
+ */
+ public void setWorkflowRunId(String workflowRunId) {
+ this.workflowRunId = workflowRunId;
+ }
+
+ /**
+ * @return the processorNameRef
+ */
+ public String getProcessorName() {
+ return processorName;
+ }
+
+ /**
+ * @param nameRef
+ * the processorNameRef to set
+ */
+ public void setProcessorName(String nameRef) {
+ processorName = nameRef;
+ }
+
+ /**
+ * @return the portName
+ */
+ public String getPortName() {
+ return portName;
+ }
+
+ /**
+ * @param portName
+ * the portName to set
+ */
+ public void setPortName(String portName) {
+ this.portName = portName;
+ }
+
+ /**
+ * @return the iteration
+ */
+ public String getIteration() {
+ return iteration;
+ }
+
+ /**
+ * @param iteration
+ * the iteration to set
+ */
+ public void setIteration(String iteration) {
+ this.iteration = iteration;
+ }
+}