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:46 UTC

[11/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/utils/Port.java
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/Port.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/Port.java
new file mode 100644
index 0000000..4c2af25
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/Port.java
@@ -0,0 +1,198 @@
+/*******************************************************************************
+ * 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;
+
+/**
+ * a Port that has no pName is either a WF input or output, depending on isInput
+ * 
+ * @author Paolo Missier
+ */
+public class Port {
+
+	@Override
+	public String toString() {
+		return "Port [identifier=" + identifier + ", isInputPort="
+				+ isInputPort + ", portName=" + portName + ", processorName="
+				+ processorName + ", workflowId=" + workflowId + "]";
+	}
+
+	@Override
+	public int hashCode() {
+		return 31 + ((identifier == null) ? 0 : identifier.hashCode());
+	}
+
+	@Override
+	public boolean equals(Object obj) {
+		if (this == obj)
+			return true;
+		if (obj == null)
+			return false;
+		if (getClass() != obj.getClass())
+			return false;
+		Port other = (Port) obj;
+		if (identifier == null) {
+			if (other.identifier != null)
+				return false;
+		} else if (!identifier.equals(other.identifier))
+			return false;
+		return true;
+	}
+
+	private String identifier;
+	private String portName;
+	private String processorName;
+	private boolean isInputPort;
+	private String workflowId;
+	private int depth = 0;
+	private Integer resolvedDepth = null;
+	private int iterationStrategyOrder = 0;
+	private String processorId;
+
+	/**
+	 * @return the workflowId
+	 */
+	public String getWorkflowId() {
+		return workflowId;
+	}
+
+	/**
+	 * @param workflowId
+	 *            the workflowId to set
+	 */
+	public void setWorkflowId(String workflowId) {
+		this.workflowId = workflowId;
+	}
+
+	/**
+	 * @return the vName
+	 */
+	public String getPortName() {
+		return portName;
+	}
+
+	/**
+	 * @param name
+	 *            the portName to set
+	 */
+	public void setPortName(String portName) {
+		this.portName = portName;
+	}
+
+	/**
+	 * @return the processorName
+	 */
+	public String getProcessorName() {
+		return processorName;
+	}
+
+	/**
+	 * @param name
+	 *            the processorName to set
+	 */
+	public void setProcessorName(String processorName) {
+		this.processorName = processorName;
+	}
+
+	/**
+	 * @return <code>true</code> if the port is an input port,
+	 *         <code>false</code> if it is an output port
+	 */
+	public boolean isInputPort() {
+		return isInputPort;
+	}
+
+	/**
+	 * @param isInputPort
+	 *            <code>true</code> if the port is an input port,
+	 *            <code>false</code> if it is an output port
+	 */
+	public void setInputPort(boolean isInputPort) {
+		this.isInputPort = isInputPort;
+	}
+
+	/**
+	 * @return the depth
+	 */
+	public int getDepth() {
+		return depth;
+	}
+
+	/**
+	 * @param depth
+	 *            the depth to set
+	 */
+	public void setDepth(int depth) {
+		this.depth = depth;
+	}
+
+	/**
+	 * @return the resolvedDepth
+	 */
+	public Integer getResolvedDepth() {
+		return resolvedDepth;
+	}
+
+	/**
+	 * @param resolvedDepth
+	 *            the resolvedDepth to set
+	 */
+	public void setResolvedDepth(Integer resolvedDepth) {
+		this.resolvedDepth = resolvedDepth;
+	}
+
+	/**
+	 * @return <code>true</code> if the {@link #resolvedDepth} has been set
+	 */
+	public boolean isResolvedDepthSet() {
+		return resolvedDepth != null;
+	}
+
+	public void setIdentifier(String identifier) {
+		this.identifier = identifier;
+	}
+
+	public String getIdentifier() {
+		return identifier;
+	}
+
+	/**
+	 * @return the iterationStrategyOrder
+	 */
+	public int getIterationStrategyOrder() {
+		return iterationStrategyOrder;
+	}
+
+	/**
+	 * @param iterationStrategyOrder
+	 *            the iterationStrategyOrder to set
+	 */
+	public void setIterationStrategyOrder(int iterationStrategyOrder) {
+		this.iterationStrategyOrder = iterationStrategyOrder;
+	}
+
+	public String getProcessorId() {
+		return processorId;
+	}
+
+	public void setProcessorId(String processorId) {
+		this.processorId = processorId;
+	}
+}

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/PortBinding.java
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/PortBinding.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/PortBinding.java
new file mode 100644
index 0000000..c6b0b86
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/PortBinding.java
@@ -0,0 +1,258 @@
+/*******************************************************************************
+ * 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 Missier
+ * 
+ */
+public class PortBinding {
+	private String workflowId;
+	private String portName;
+	private String workflowRunId;
+	private String value;
+	private String collIDRef;
+	private int positionInColl;
+	private String processorName;
+	private String valueType;
+	private String reference;
+	private String iteration;
+	private String resolvedValue;
+	private String portId;
+	private Boolean isInputPort;
+
+	public PortBinding() {
+	}
+
+	public PortBinding(PortBinding vb) {
+		workflowId = vb.workflowId;
+		portName = vb.portName;
+		workflowRunId = vb.workflowRunId;
+		value = vb.value;
+		collIDRef = vb.collIDRef;
+		positionInColl = vb.positionInColl;
+		processorName = vb.processorName;
+		valueType = vb.valueType;
+		reference = vb.reference;
+		iteration = vb.iteration;
+		resolvedValue = vb.resolvedValue;
+		portId = vb.portId;
+		isInputPort = vb.isInputPort;
+	}
+
+	public String getPortId() {
+		return portId;
+	}
+
+	@Override
+	public String toString() {
+		return "PortBinding [workflowId=" + workflowId + ", portName="
+				+ portName + ", workflowRunId=" + workflowRunId + ", value="
+				+ value + ", collIDRef=" + collIDRef + ", positionInColl="
+				+ positionInColl + ", processorName=" + processorName
+				+ ", valueType=" + valueType + ", reference=" + reference
+				+ ", iteration=" + iteration + ", resolvedValue="
+				+ resolvedValue + ", portId=" + portId + ", isInputPort="
+				+ isInputPort + "]";
+	}
+
+	/**
+	 * @return the positionInColl
+	 */
+	public int getPositionInColl() {
+		return positionInColl;
+	}
+
+	/**
+	 * @param positionInColl
+	 *            the positionInColl to set
+	 */
+	public void setPositionInColl(int positionInColl) {
+		this.positionInColl = positionInColl;
+	}
+
+	/**
+	 * @return the valueType
+	 */
+	public String getValueType() {
+		return valueType;
+	}
+
+	/**
+	 * @param valueType
+	 *            the valueType to set
+	 */
+	public void setValueType(String valueType) {
+		this.valueType = valueType;
+	}
+
+	/**
+	 * @return the portName
+	 */
+	public String getPortName() {
+		return portName;
+	}
+
+	/**
+	 * @param portName
+	 *            the portName to set
+	 */
+	public void setPortName(String portName) {
+		this.portName = portName;
+	}
+
+	/**
+	 * @return the workflowRunId
+	 */
+	public String getWorkflowRunId() {
+		return workflowRunId;
+	}
+
+	/**
+	 * @param workflowRunId
+	 *            the workflowRunId to set
+	 */
+	public void setWorkflowRunId(String workflowRunId) {
+		this.workflowRunId = workflowRunId;
+	}
+
+	/**
+	 * @return the processorName
+	 */
+	public String getProcessorName() {
+		return processorName;
+	}
+
+	/**
+	 * @param processorName
+	 *            the processorName to set
+	 */
+	public void setProcessorName(String processorName) {
+		this.processorName = processorName;
+	}
+
+	/**
+	 * @return the collIDRef
+	 */
+	public String getCollIDRef() {
+		return collIDRef;
+	}
+
+	/**
+	 * @param collIDRef
+	 *            the collIDRef to set
+	 */
+	public void setCollIDRef(String collIDRef) {
+		this.collIDRef = collIDRef;
+	}
+
+	/**
+	 * @return the iteration
+	 */
+	public String getIteration() {
+		return iteration;
+	}
+
+	/**
+	 * @param iterationVector
+	 *            the iteration to set
+	 */
+	public void setIteration(String iterationVector) {
+		this.iteration = iterationVector;
+	}
+
+	/**
+	 * @return the value
+	 */
+	public String getValue() {
+		return value;
+	}
+
+	/**
+	 * @param value
+	 *            the value to set
+	 */
+	public void setValue(String value) {
+		this.value = value;
+	}
+
+	/**
+	 * @return the ref
+	 */
+	public String getReference() {
+		return reference;
+	}
+
+	/**
+	 * @param ref
+	 *            the ref to set
+	 */
+	public void setReference(String ref) {
+		this.reference = ref;
+	}
+
+	/**
+	 * @return the resolvedValue
+	 */
+	public String getResolvedValue() {
+		return resolvedValue;
+	}
+
+	/**
+	 * @param resolvedValue
+	 *            the resolvedValue to set
+	 */
+	public void setResolvedValue(String resolvedValue) {
+		this.resolvedValue = resolvedValue;
+	}
+
+	/**
+	 * @return the workflowId
+	 */
+	public String getWorkflowId() {
+		return workflowId;
+	}
+
+	/**
+	 * @param workflowId
+	 *            the workflowId to set
+	 */
+	public void setWorkflowId(String workflowId) {
+		this.workflowId = workflowId;
+	}
+
+	public void setPortId(String portId) {
+		this.portId = portId;
+
+	}
+
+	public void setIsInputPort(boolean isInputPort) {
+		this.setInputPort(isInputPort);
+	}
+
+	public void setInputPort(boolean isInputPort) {
+		this.isInputPort = isInputPort;
+	}
+
+	public Boolean isInputPort() {
+		return isInputPort;
+	}
+}

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/ProcessorBinding.java
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/ProcessorBinding.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/ProcessorBinding.java
new file mode 100644
index 0000000..46a8565
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/ProcessorBinding.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 Missier
+ * 
+ */
+public class ProcessorBinding {
+	private String identifier;
+
+	private String processorName;
+	private String workflowRunId;
+	private String workflowId;
+	private String firstActivityClassName;
+	private String iterationVector;
+
+	@Override
+	public String toString() {
+		return "ProcessorBinding [firstActivityClassName="
+				+ firstActivityClassName + ", identifier=" + identifier
+				+ ", iterationVector=" + iterationVector + ", processorName="
+				+ processorName + ", workflowId=" + workflowId
+				+ ", workflowRunId=" + workflowRunId + "]";
+	}
+
+	/**
+	 * @return the processorNameRef
+	 */
+	public String getProcessorName() {
+		return processorName;
+	}
+
+	/**
+	 * @param nameRef
+	 *            the processorNameRef to set
+	 */
+	public void setProcessorName(String processorNameRef) {
+		this.processorName = processorNameRef;
+	}
+
+	/**
+	 * @return the execIDRef
+	 */
+	public String getWorkflowRunId() {
+		return workflowRunId;
+	}
+
+	/**
+	 * @param workflowRunId
+	 *            the workflowRunId to set
+	 */
+	public void setWorkflowRunId(String workflowRunId) {
+		this.workflowRunId = workflowRunId;
+	}
+
+	/**
+	 * @return the actName
+	 */
+	public String getFirstActivityClassName() {
+		return firstActivityClassName;
+	}
+
+	/**
+	 * @param actName
+	 *            the actName to set
+	 */
+	public void setFirstActivityClassName(String actName) {
+		this.firstActivityClassName = actName;
+	}
+
+	/**
+	 * @return the iteration
+	 */
+	public String getIterationVector() {
+		return iterationVector;
+	}
+
+	/**
+	 * @param iterationVector
+	 *            the iteration to set
+	 */
+	public void setIterationVector(String iterationVector) {
+		this.iterationVector = iterationVector;
+	}
+
+	public void setIdentifier(String identifier) {
+		this.identifier = identifier;
+	}
+
+	public String getIdentifier() {
+		return identifier;
+	}
+
+	/**
+	 * @return the workflowId
+	 */
+	public String getWorkflowId() {
+		return workflowId;
+	}
+
+	/**
+	 * @param workflowId
+	 *            the workflowId to set
+	 */
+	public void setWorkflowId(String workflowId) {
+		this.workflowId = workflowId;
+	}
+}

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/ProcessorEnactment.java
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/ProcessorEnactment.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/ProcessorEnactment.java
new file mode 100644
index 0000000..fd59fdf
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/ProcessorEnactment.java
@@ -0,0 +1,151 @@
+package net.sf.taverna.t2.provenance.lineageservice.utils;
+
+import java.sql.Timestamp;
+
+public class ProcessorEnactment {
+	private Timestamp enactmentEnded;
+	private Timestamp enactmentStarted;
+	private String finalOutputsDataBindingId;
+	private String initialInputsDataBindingId;
+	private String iteration;
+	private String parentProcessorEnactmentId;
+	private String processEnactmentId;
+	private String processIdentifier;
+	private String processorId;
+	private String workflowRunId;
+
+	@Override
+	public boolean equals(Object obj) {
+		if (this == obj)
+			return true;
+		if (obj == null)
+			return false;
+		if (getClass() != obj.getClass())
+			return false;
+		ProcessorEnactment other = (ProcessorEnactment) obj;
+		if (processEnactmentId == null) {
+			if (other.processEnactmentId != null)
+				return false;
+		} else if (!processEnactmentId.equals(other.processEnactmentId))
+			return false;
+		return true;
+	}
+
+	public Timestamp getEnactmentEnded() {
+		return enactmentEnded;
+	}
+
+	public Timestamp getEnactmentStarted() {
+		return enactmentStarted;
+	}
+
+	public String getFinalOutputsDataBindingId() {
+		return finalOutputsDataBindingId;
+	}
+
+	public String getInitialInputsDataBindingId() {
+		return initialInputsDataBindingId;
+	}
+
+	public String getIteration() {
+		return iteration;
+	}
+
+	public String getParentProcessorEnactmentId() {
+		return parentProcessorEnactmentId;
+	}
+
+	public String getProcessEnactmentId() {
+		return processEnactmentId;
+	}
+
+	public String getProcessIdentifier() {
+		return processIdentifier;
+	}
+
+	public String getProcessorId() {
+		return processorId;
+	}
+
+	public String getWorkflowRunId() {
+		return workflowRunId;
+	}
+
+	@Override
+	public int hashCode() {
+		final int prime = 31;
+		int result = 1;
+		result = prime
+				* result
+				+ ((processEnactmentId == null) ? 0 : processEnactmentId
+						.hashCode());
+		return result;
+	}
+
+	public void setEnactmentEnded(Timestamp enactmentEnded) {
+		this.enactmentEnded = enactmentEnded;
+	}
+
+	public void setEnactmentStarted(Timestamp enactmentStarted) {
+		this.enactmentStarted = enactmentStarted;
+	}
+
+	public void setFinalOutputsDataBindingId(String finalOutputsDataBindingId) {
+		this.finalOutputsDataBindingId = finalOutputsDataBindingId;
+	}
+
+	public void setInitialInputsDataBindingId(String initialInputsDataBindingId) {
+		this.initialInputsDataBindingId = initialInputsDataBindingId;
+	}
+
+	public void setIteration(String iteration) {
+		this.iteration = iteration;
+	}
+
+	public void setParentProcessorEnactmentId(String parentProcessorEnactmentId) {
+		this.parentProcessorEnactmentId = parentProcessorEnactmentId;
+	}
+
+	public void setProcessEnactmentId(String processEnactmentId) {
+		this.processEnactmentId = processEnactmentId;
+	}
+
+	public void setProcessIdentifier(String processIdentifier) {
+		this.processIdentifier = processIdentifier;
+	}
+
+	public void setProcessorId(String processorId) {
+		this.processorId = processorId;
+	}
+
+	public void setWorkflowRunId(String workflowRunId) {
+		this.workflowRunId = workflowRunId;
+	}
+
+	@Override
+	public String toString() {
+		StringBuilder builder = new StringBuilder();
+		builder.append("ProcessorEnactment [enactmentEnded=");
+		builder.append(enactmentEnded);
+		builder.append(", enactmentStarted=");
+		builder.append(enactmentStarted);
+		builder.append(", finalOutputs=");
+		builder.append(finalOutputsDataBindingId);
+		builder.append(", initialInputs=");
+		builder.append(initialInputsDataBindingId);
+		builder.append(", iteration=");
+		builder.append(iteration);
+		builder.append(", parentProcessEnactmentId=");
+		builder.append(parentProcessorEnactmentId);
+		builder.append(", processEnactmentId=");
+		builder.append(processEnactmentId);
+		builder.append(", processIdentifier=");
+		builder.append(processIdentifier);
+		builder.append(", processorId=");
+		builder.append(processorId);
+		builder.append(", workflowRunId=");
+		builder.append(workflowRunId);
+		builder.append("]");
+		return builder.toString();
+	}
+}

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/ProvenanceProcessor.java
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/ProvenanceProcessor.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/ProvenanceProcessor.java
new file mode 100644
index 0000000..fb1a8fb
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/ProvenanceProcessor.java
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * 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;
+
+/**
+ * a Port that has no pName is either a WF input or output, depending on isInput
+ * 
+ * @author Paolo Missier
+ */
+public class ProvenanceProcessor {
+
+	public static final String DATAFLOW_ACTIVITY = "net.sf.taverna.t2.activities.dataflow.DataflowActivity";
+
+	private String identifier;
+	private String processorName;
+	private String workflowId;
+	private String firstActivityClassName;
+	private boolean isTopLevelProcessor;
+
+	public ProvenanceProcessor() {
+	}
+
+	@Override
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		sb.append("PROCESSOR: ****").append("\nworkflow: " + getWorkflowId())
+				.append("\nprocessor name: " + getProcessorName())
+				.append("\ntype: " + getFirstActivityClassName());
+
+		return sb.toString();
+	}
+
+	/**
+	 * @return the workflowId
+	 */
+	public String getWorkflowId() {
+		return workflowId;
+	}
+
+	/**
+	 * @param workflowId
+	 *            the workflowId to set
+	 */
+	public void setWorkflowId(String workflowId) {
+		this.workflowId = workflowId;
+	}
+
+	/**
+	 * @return The fully qualified classname for the first activity in this
+	 *         processor, or {@link #DATAFLOW_ACTIVITY} if this is a virtual
+	 *         processor representing the workflow itself.
+	 */
+	public String getFirstActivityClassName() {
+		return firstActivityClassName;
+	}
+
+	/**
+	 * @param firstActivityClassName
+	 *            The fully qualified classname for the first activity in this
+	 *            processor, or {@link #DATAFLOW_ACTIVITY} if this is a virtual
+	 *            processor representing the workflow itself.
+	 */
+	public void setFirstActivityClassName(String firstActivityClassName) {
+		this.firstActivityClassName = firstActivityClassName;
+	}
+
+	/**
+	 * @return the processorName
+	 */
+	public String getProcessorName() {
+		return processorName;
+	}
+
+	/**
+	 * @param processorName
+	 *            the processorName to set
+	 */
+	public void setProcessorName(String processorName) {
+		this.processorName = processorName;
+	}
+
+	public void setIdentifier(String identifier) {
+		this.identifier = identifier;
+	}
+
+	public String getIdentifier() {
+		return identifier;
+	}
+
+	public void setTopLevelProcessor(boolean isTopLevelProcessor) {
+		this.isTopLevelProcessor = isTopLevelProcessor;
+	}
+
+	public boolean isTopLevelProcessor() {
+		return isTopLevelProcessor;
+	}
+}

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/ProvenanceUtils.java
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/ProvenanceUtils.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/ProvenanceUtils.java
new file mode 100644
index 0000000..a36308a
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/ProvenanceUtils.java
@@ -0,0 +1,128 @@
+package net.sf.taverna.t2.provenance.lineageservice.utils;
+
+import static net.sf.taverna.t2.provenance.vocabulary.SharedVocabulary.INPUTDATA_EVENT_TYPE;
+
+import java.util.Set;
+import java.util.regex.Pattern;
+
+import net.sf.taverna.t2.provenance.item.DataProvenanceItem;
+import net.sf.taverna.t2.reference.ErrorDocument;
+import net.sf.taverna.t2.reference.ExternalReferenceSPI;
+import net.sf.taverna.t2.reference.IdentifiedList;
+import net.sf.taverna.t2.reference.ReferenceService;
+import net.sf.taverna.t2.reference.ReferenceSet;
+import net.sf.taverna.t2.reference.T2Reference;
+
+import org.jdom.Element;
+import org.tupeloproject.kernel.NotFoundException;
+
+public class ProvenanceUtils {
+	public static Pattern parentProcessPattern = Pattern.compile("^(.*):?[^:]+:[^:]+$");
+	
+	public static String iterationToString(int[] iteration) {
+		String result = "[";
+		for (int i = 0; i < iteration.length; i++) {
+			result += iteration[i];
+			if (i < (iteration.length - 1))
+				result += ",";
+		}
+		result += "]";
+		return result;
+	}
+	
+	/**
+	 * Returns an Element representing the data item, identfied as either input
+	 * or output. References to data are currently resolved to their actual
+	 * values
+	 */
+	public static Element getDataItemAsXML(DataProvenanceItem provenanceItem) {
+		String name;
+		if (provenanceItem.getEventType().equals(INPUTDATA_EVENT_TYPE)) {
+			name = "inputdata";
+		} else {
+			name = "outputdata";
+		}
+		Element result = new Element(name);
+		result.setAttribute("identifier", provenanceItem.getIdentifier());
+		result.setAttribute("processID", provenanceItem.getProcessId());
+		result.setAttribute("parent", provenanceItem.getParentId());
+		for (String port : provenanceItem.getDataMap().keySet()) {
+			Element portElement = new Element("port");
+			portElement.setAttribute("name", port);
+			portElement.setAttribute(
+					"depth",
+					Integer.toString(provenanceItem.getDataMap().get(port)
+							.getDepth()));
+			result.addContent(portElement);
+			portElement.addContent(resolveToElement(provenanceItem.getDataMap()
+					.get(port), provenanceItem.getReferenceService()));
+			Element element = new Element("some_stuff");
+			portElement.addContent(element);
+		}
+		return result;
+	}
+	
+	/**
+	 * Given a {@link T2Reference} return all the other {@link T2Reference}s
+	 * which it contains as an XML Element.
+	 * 
+	 * @param entityIdentifier
+	 * @return
+	 * @throws NotFoundException
+	 * @throws RetrievalException
+	 */
+	private static org.jdom.Element resolveToElement(T2Reference reference,
+			ReferenceService referenceService) {
+		Element element = new Element("resolvedReference");
+		switch (reference.getReferenceType()) {
+		case ErrorDocument:
+			ErrorDocument error = referenceService.getErrorDocumentService()
+					.getError(reference);
+
+			element.setName("error");
+			element.setAttribute("id", reference.toString());
+			Element messageElement = new Element("message");
+			messageElement.addContent(error.getExceptionMessage());
+			element.addContent(messageElement);
+			break;
+		case ReferenceSet:
+			element.setName("referenceSet");
+			element.setAttribute("id", reference.toString());
+			ReferenceSet referenceSet = referenceService
+					.getReferenceSetService().getReferenceSet(reference);
+			Set<ExternalReferenceSPI> externalReferences = referenceSet
+					.getExternalReferences();
+			for (ExternalReferenceSPI externalReference : externalReferences) {
+				// FIXME does this make sense? No!! Should get the actual value
+				// not what it is (TEXT etc)
+				Element refElement = new Element("reference");
+				refElement.addContent(externalReference.getDataNature()
+						.toString());
+				element.addContent(refElement);
+			}
+			break;
+		case IdentifiedList:
+			IdentifiedList<T2Reference> list = referenceService
+					.getListService().getList(reference);
+
+			element.setName("list");
+			element.setAttribute("id", reference.toString());
+			for (T2Reference ref : list)
+				element.addContent(resolveToElement(ref, referenceService));
+			break;
+		default:
+			// throw something (maybe a tantrum)
+		}
+		return element;
+	}
+
+	public static String parentProcess(String processId, int levels) {
+		if (levels < 1)
+			return processId;
+		int lastColon = processId.lastIndexOf(":");
+		if (lastColon == -1)
+			return null;
+		return parentProcess(processId.substring(0, lastColon), --levels);
+	}
+
+}

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/QueryPort.java
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/QueryPort.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/QueryPort.java
new file mode 100644
index 0000000..34b4f9b
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/QueryPort.java
@@ -0,0 +1,119 @@
+/**
+ * 
+ */
+package net.sf.taverna.t2.provenance.lineageservice.utils;
+
+/**
+ * @author Paolo Missier
+ *         <p/>
+ * 
+ */
+public class QueryPort {
+	private String workflowRunId;
+	private String workflowId;
+	private String processorName;
+	private String portName;
+	private String path;
+	private String value;
+
+	@Override
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		sb.append("PORT: ****").append("\nworkflow: " + getWorkflowId())
+				.append("\nprocessor: " + getProcessorName())
+				.append("\nport: " + getPortName())
+				.append("\npath to value: " + getPath());
+
+		return sb.toString();
+	}
+
+	/**
+	 * @return the processorName
+	 */
+	public String getProcessorName() {
+		return processorName;
+	}
+
+	/**
+	 * @param processorName
+	 *            the processorName to set
+	 */
+	public void setProcessorName(String processorName) {
+		this.processorName = processorName;
+	}
+
+	/**
+	 * @return the vname
+	 */
+	public String getPortName() {
+		return portName;
+	}
+
+	/**
+	 * @param vname
+	 *            the vname to set
+	 */
+	public void setPortName(String vname) {
+		this.portName = vname;
+	}
+
+	/**
+	 * @return the path
+	 */
+	public String getPath() {
+		return path;
+	}
+
+	/**
+	 * @param path
+	 *            the path to set
+	 */
+	public void setPath(String path) {
+		this.path = path;
+	}
+
+	/**
+	 * @return the value
+	 */
+	public String getValue() {
+		return value;
+	}
+
+	/**
+	 * @param value
+	 *            the value to set
+	 */
+	public void setValue(String value) {
+		this.value = value;
+	}
+
+	/**
+	 * @return the workflowRunId
+	 */
+	public String getWorkflowRunId() {
+		return workflowRunId;
+	}
+
+	/**
+	 * @param workflowRunId
+	 *            the workflowRunId to set
+	 */
+	public void setWorkflowRunId(String workflowRunId) {
+		this.workflowRunId = workflowRunId;
+	}
+
+	/**
+	 * @return the workflowId
+	 */
+	public String getWorkflowId() {
+		return workflowId;
+	}
+
+	/**
+	 * @param workflowId
+	 *            the workflowId to set
+	 */
+	public void setWorkflowId(String workflowId) {
+		this.workflowId = workflowId;
+	}
+}
\ No newline at end of file

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/ServiceInvocation.java
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/ServiceInvocation.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/ServiceInvocation.java
new file mode 100644
index 0000000..83de7ce
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/ServiceInvocation.java
@@ -0,0 +1,161 @@
+package net.sf.taverna.t2.provenance.lineageservice.utils;
+
+import java.sql.Timestamp;
+
+public class ServiceInvocation {
+	private ProcessorEnactment processorEnactment;
+	private String workflowRunId;
+	private long invocationNumber;
+	private Timestamp invocationStarted;
+	private Timestamp invocationEnded;
+	private DataBinding inputs;
+	private DataBinding outputs;
+	private String failureT2Reference;
+	private Activity activity;
+	private String initiatingDispatchLayer;
+	private String finalDispatchLayer;
+
+	public ProcessorEnactment getProcessorEnactment() {
+		return processorEnactment;
+	}
+
+	public void setProcessorEnactment(ProcessorEnactment processorEnactment) {
+		this.processorEnactment = processorEnactment;
+	}
+
+	public String getWorkflowRunId() {
+		return workflowRunId;
+	}
+
+	public void setWorkflowRunId(String workflowRunId) {
+		this.workflowRunId = workflowRunId;
+	}
+
+	public long getInvocationNumber() {
+		return invocationNumber;
+	}
+
+	public void setInvocationNumber(long invocationNumber) {
+		this.invocationNumber = invocationNumber;
+	}
+
+	public Timestamp getInvocationStarted() {
+		return invocationStarted;
+	}
+
+	public void setInvocationStarted(Timestamp invocationStarted) {
+		this.invocationStarted = invocationStarted;
+	}
+
+	public Timestamp getInvocationEnded() {
+		return invocationEnded;
+	}
+
+	public void setInvocationEnded(Timestamp invocationEnded) {
+		this.invocationEnded = invocationEnded;
+	}
+
+	public DataBinding getInputs() {
+		return inputs;
+	}
+
+	public void setInputs(DataBinding inputs) {
+		this.inputs = inputs;
+	}
+
+	public DataBinding getOutputs() {
+		return outputs;
+	}
+
+	public void setOutputs(DataBinding outputs) {
+		this.outputs = outputs;
+	}
+
+	public String getFailureT2Reference() {
+		return failureT2Reference;
+	}
+
+	public void setFailureT2Reference(String failureT2Reference) {
+		this.failureT2Reference = failureT2Reference;
+	}
+
+	public Activity getActivity() {
+		return activity;
+	}
+
+	public void setActivity(Activity activity) {
+		this.activity = activity;
+	}
+
+	public String getInitiatingDispatchLayer() {
+		return initiatingDispatchLayer;
+	}
+
+	public void setInitiatingDispatchLayer(String initiatingDispatchLayer) {
+		this.initiatingDispatchLayer = initiatingDispatchLayer;
+	}
+
+	public String getFinalDispatchLayer() {
+		return finalDispatchLayer;
+	}
+
+	public void setFinalDispatchLayer(String finalDispatchLayer) {
+		this.finalDispatchLayer = finalDispatchLayer;
+	}
+
+	@Override
+	public int hashCode() {
+		return 31
+				* (int) (invocationNumber ^ (invocationNumber >>> 32))
+				+ ((processorEnactment == null) ? 0 : processorEnactment
+						.hashCode());
+	}
+
+	@Override
+	public boolean equals(Object obj) {
+		if (this == obj)
+			return true;
+		if (obj == null)
+			return false;
+		if (getClass() != obj.getClass())
+			return false;
+		ServiceInvocation other = (ServiceInvocation) obj;
+		if (invocationNumber != other.invocationNumber)
+			return false;
+		if (processorEnactment == null) {
+			if (other.processorEnactment != null)
+				return false;
+		} else if (!processorEnactment.equals(other.processorEnactment))
+			return false;
+		return true;
+	}
+
+	@Override
+	public String toString() {
+		StringBuilder builder = new StringBuilder();
+		builder.append("ServiceInvocation [activity=");
+		builder.append(activity);
+		builder.append(", failureT2Reference=");
+		builder.append(failureT2Reference);
+		builder.append(", finalDispatchLayer=");
+		builder.append(finalDispatchLayer);
+		builder.append(", initiatingDispatchLayer=");
+		builder.append(initiatingDispatchLayer);
+		builder.append(", inputs=");
+		builder.append(inputs);
+		builder.append(", invocationEnded=");
+		builder.append(invocationEnded);
+		builder.append(", invocationNumber=");
+		builder.append(invocationNumber);
+		builder.append(", invocationStarted=");
+		builder.append(invocationStarted);
+		builder.append(", outputs=");
+		builder.append(outputs);
+		builder.append(", processorEnactment=");
+		builder.append(processorEnactment);
+		builder.append(", workflowRunId=");
+		builder.append(workflowRunId);
+		builder.append("]");
+		return builder.toString();
+	}
+}

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/Workflow.java
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/Workflow.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/Workflow.java
new file mode 100644
index 0000000..b1f75ef
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/Workflow.java
@@ -0,0 +1,37 @@
+package net.sf.taverna.t2.provenance.lineageservice.utils;
+
+public class Workflow {
+	private String workflowId;
+	private String parentWorkflowId;
+	private String externalName;
+	
+	public void setWorkflowId(String workflowId) {
+		this.workflowId = workflowId;
+	}
+
+	public String getWorkflowId() {
+		return workflowId;
+	}
+
+	public void setParentWorkflowId(String parentIdentifier) {
+		this.parentWorkflowId = parentIdentifier;
+	}
+
+	public String getParentWorkflowId() {
+		return parentWorkflowId;
+	}
+
+	/**
+	 * @return the externalName
+	 */
+	public String getExternalName() {
+		return externalName;
+	}
+
+	/**
+	 * @param externalName the externalName to set
+	 */
+	public void setExternalName(String externalName) {
+		this.externalName = externalName;
+	}	
+}

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/WorkflowRun.java
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/WorkflowRun.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/WorkflowRun.java
new file mode 100644
index 0000000..8e5b25a
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/WorkflowRun.java
@@ -0,0 +1,72 @@
+package net.sf.taverna.t2.provenance.lineageservice.utils;
+
+import java.sql.Blob;
+
+public class WorkflowRun {
+	private String workflowRunId;
+	/**
+	 * this is the workflowId for the TOP LEVEL workflow for this run.
+	 * <p>
+	 * CHECK
+	 */
+	private String workflowId;
+	private String timestamp;
+	private String workflowExternalName;
+	private byte[] dataflowBlob;
+
+	public void setWorkflowId(String workflowIdentifier) {
+		this.workflowId = workflowIdentifier;
+	}
+
+	public String getWorkflowId() {
+		return workflowId;
+	}
+
+	public void setTimestamp(String timestamp) {
+		this.timestamp = timestamp;
+	}
+
+	public String getTimestamp() {
+		return timestamp;
+	}
+
+	/**
+	 * @return the workflowRunId
+	 */
+	public String getWorkflowRunId() {
+		return workflowRunId;
+	}
+
+	/**
+	 * @param workflowRunId the workflowRunId to set
+	 */
+	public void setWorkflowRunId(String workflowRunId) {
+		this.workflowRunId = workflowRunId;
+	}
+
+	/**
+	 * @return the workflowExternalName
+	 */
+	public String getWorkflowExternalName() {
+		return workflowExternalName;
+	}
+
+	/**
+	 * @param workflowExternalName the workflowExternalName to set
+	 */
+	public void setWorkflowExternalName(String workflowExternalName) {
+		this.workflowExternalName = workflowExternalName;
+	}
+	
+	/**
+	 * A {@link Blob} object representing the dataflow
+	 * @param bs
+	 */
+	public void setDataflowBlob(byte[] bs) {
+		this.dataflowBlob = bs;
+	}
+
+	public byte[] getDataflowBlob() {
+		return dataflowBlob;
+	}
+}

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/WorkflowTree.java
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/WorkflowTree.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/WorkflowTree.java
new file mode 100644
index 0000000..7db0259
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/lineageservice/utils/WorkflowTree.java
@@ -0,0 +1,73 @@
+/**
+ * 
+ */
+package net.sf.taverna.t2.provenance.lineageservice.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * a tree structure used to describe the nested static structure of a workflow
+ * as it is found in the provenance DB
+ * 
+ * @author Paolo Missier
+ */
+public class WorkflowTree {
+	private Workflow node;
+	private List<WorkflowTree> children = new ArrayList<>();
+
+	/**
+	 * @return the children
+	 */
+	public List<WorkflowTree> getChildren() {
+		return children;
+	}
+
+	/**
+	 * @param children
+	 *            the children to set
+	 */
+	public void setChildren(List<WorkflowTree> children) {
+		this.children = children;
+	}
+
+	/**
+	 * @return the node
+	 */
+	public Workflow getNode() {
+		return node;
+	}
+
+	/**
+	 * @param node
+	 *            the node to set
+	 */
+	public void setNode(Workflow node) {
+		this.node = node;
+	}
+
+	public void addChild(WorkflowTree childStructure) {
+		children.add(childStructure);
+	}
+
+	@Override
+	public String toString() {
+		return toString(new StringBuilder(), 0);
+	}
+
+	public String toString(int indent) {
+		return toString(new StringBuilder(), indent);
+	}
+
+	protected String toString(StringBuilder sb, int indent) {
+		sb.append(getNode().getExternalName() + "\n");
+		for (WorkflowTree tree : getChildren()) {
+			indent++;
+			for (int i = 1; i < indent; i++)
+				sb.append("-");
+			sb.append(tree.toString(indent));
+			indent--;
+		}
+		return sb.toString();
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/opm/OPMImporter.java
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/opm/OPMImporter.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/opm/OPMImporter.java
new file mode 100644
index 0000000..f491683
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/opm/OPMImporter.java
@@ -0,0 +1,541 @@
+/**
+ * 
+ */
+package net.sf.taverna.t2.provenance.opm;
+
+import java.io.File;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import net.sf.taverna.t2.provenance.lineageservice.ProvenanceWriter;
+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 org.openprovenance.model.Account;
+import org.openprovenance.model.AccountRef;
+import org.openprovenance.model.Accounts;
+import org.openprovenance.model.Artifact;
+import org.openprovenance.model.ArtifactRef;
+import org.openprovenance.model.Artifacts;
+import org.openprovenance.model.Dependencies;
+import org.openprovenance.model.OPMDeserialiser;
+import org.openprovenance.model.OPMGraph;
+import org.openprovenance.model.Process;
+import org.openprovenance.model.ProcessRef;
+import org.openprovenance.model.Role;
+import org.openprovenance.model.Used;
+import org.openprovenance.model.WasControlledBy;
+import org.openprovenance.model.WasDerivedFrom;
+import org.openprovenance.model.WasGeneratedBy;
+import org.openprovenance.model.WasTriggeredBy;
+
+/**
+ * imports foreign XML-serialized OPM graphs into the native Taverna provenance
+ * DB, so they can be queried using
+ * {@link net.sf.taverna.t2.provenance.lineageservice.ProvenanceAnalysis}
+ * 
+ * @author paolo
+ */
+public class OPMImporter {
+	private static final String PROC_NAME = "P";
+	private static final String OPM_DEF_ACCOUNT = "OPMDefaultAccount";
+	private static Logger logger = Logger.getLogger(OPMImporter.class);
+
+	private ProvenanceWriter pw;
+	private OPMGraph graph;
+
+	// Maps Account names to Taverna workflows
+	private Map<String, String> accountToWorkflow = new HashMap<>();
+	private Map<String, String> workflowToInstance = new HashMap<>();
+
+	// maps workflowId --> (workflowId --> List(Port))
+	private Map<String, Map<String, List<Port>>> usedVarsByAccount = new HashMap<>();
+	private Map<String, Map<String, List<Port>>> wgbVarsByAccount = new HashMap<>();
+
+	// maps accountname --> (artifact -> List(Process))
+	private Map<String, Map<String, List<String>>> wgbArtifactsByAccount = new HashMap<>();
+
+	// maps accountname --> (artifact -> List(Process))
+	private Map<String, Map<String, List<String>>> usedArtifactsByAccount = new HashMap<>();
+
+	private int procNameCounter;
+
+	public OPMImporter(ProvenanceWriter pw) {
+		this.pw = pw;
+	}	
+
+	/**
+	 * orphan artifacts are those that are in the graph but are never used
+	 * neither generated. this indicates some problem with the graph structure.
+	 * this method is used for diagnostics after import has finished
+	 * 
+	 * @return
+	 */
+	public List<String> getOrphanArtifacts() {
+		List<String> allwgb  = new ArrayList<>();
+		List<String> allUsed = new ArrayList<>();
+		List<String> orphans = new ArrayList<>();
+
+		if (graph == null) {
+			logger.warn("null graph while attempting to count orphan artifacts -- giving up");
+			return orphans;
+		}
+
+		Artifacts allArtifacts = graph.getArtifacts();
+
+		for (Map.Entry<String, Map<String, List<String>>> entry : wgbArtifactsByAccount
+				.entrySet())
+			allwgb.addAll(entry.getValue().keySet());
+		for (Map.Entry<String, Map<String, List<String>>> entry : usedArtifactsByAccount
+				.entrySet())
+			allUsed.addAll(entry.getValue().keySet());
+
+		for (Artifact a : allArtifacts.getArtifact())
+			if (!allwgb.contains(a.getId()) && !allUsed.contains(a.getId()))
+				orphans.add(a.getId());
+		return orphans;
+	}
+
+	public void importGraph(String XMLOPMGraphFilename) throws Exception,
+			SQLException {
+		try {
+			logger.info("Importing OPM XML from file " + XMLOPMGraphFilename);
+
+			// deserialize an XML OPM graph from file
+			OPMDeserialiser deser = new OPMDeserialiser();
+			graph = deser.deserialiseOPMGraph(new File(XMLOPMGraphFilename));
+
+		} catch (Exception e) {
+			logger.fatal("exception while deserializing -- unable to continue");
+			logger.fatal(e.getMessage());
+			return;
+		}
+
+		logger.debug("XML graph deserialized");
+
+		/*
+		 * generates one pair <workflowId, workflowRun> for each account in the
+		 * graph
+		 */
+		try {
+			Accounts accounts = graph.getAccounts();
+
+			// use this global account alongside any other that may be defined in the graph
+			generateWFFromAccount(OPM_DEF_ACCOUNT);
+
+			if (accounts == null) {
+				logger.warn("this graph contains no accounts -- using only the default");
+			} else {
+				for (Account acc:accounts.getAccount())
+					// writes both workflow and instance into the DB, updates accountToWorkflow
+					generateWFFromAccount(acc.getId());
+			}
+		} catch (Exception e) {
+			logger.warn("exception while getting accounts for this graph");
+		}
+
+		// what have we got?
+		// retrieve all OPM relations from the graph		
+		Dependencies dependencies = graph.getDependencies();
+
+		/*
+		 * associates processes and ports to workflows and varbindings to
+		 * corresponding workflowRuns
+		 */
+		List<Object> allDeps = dependencies
+				.getUsedOrWasGeneratedByOrWasTriggeredBy();
+		// make sure these are processed in the right order: used, wgby, THEN wdf because this latter is derived from the first 2!
+		// so collect them into sets and process them separately
+
+		Set<WasGeneratedBy> wgbSet = new HashSet<>();
+		Set<Used> usedSet = new HashSet<>();
+		Set<WasDerivedFrom> wdfSet = new HashSet<>();
+		Set<WasControlledBy> wcbSet = new HashSet<>();
+		Set<WasTriggeredBy> wtbSet = new HashSet<>();
+
+		for (Object dep : allDeps) {
+			logger.info("dependency of type: " + dep.getClass().getName());
+
+			if (dep instanceof org.openprovenance.model.WasGeneratedBy)
+				wgbSet.add((WasGeneratedBy) dep);
+			else if (dep instanceof org.openprovenance.model.Used)
+				usedSet.add((Used) dep);
+			else if (dep instanceof org.openprovenance.model.WasDerivedFrom)
+				wdfSet.add((WasDerivedFrom) dep);
+			else if (dep instanceof org.openprovenance.model.WasControlledBy)
+				wcbSet.add((WasControlledBy) dep);
+			else if (dep instanceof org.openprovenance.model.WasTriggeredBy)
+				wtbSet.add((WasTriggeredBy) dep);
+		}
+
+		// process these in the correct order
+		for (WasGeneratedBy dep: wgbSet)
+			processWGBy(dep);
+
+		for (Used dep : usedSet)
+			processUsed(dep);
+
+		for (WasDerivedFrom dep : wdfSet)
+			processWDF(dep);
+
+		// we actually ignore the others... 
+
+		// *********
+		// complete the induced graph by building datalinks using the Artifact -> [Port] maps
+		// *********
+
+		List<String> accountNames = new ArrayList<>();
+
+		accountNames.add(OPM_DEF_ACCOUNT);
+
+		/* Disabled as allAccounts is never assigned to
+		if (allAccounts != null)  
+			for (Account acc:allAccounts) { accountNames.add(acc.getId()); }
+		*/
+
+		for (String acc : accountNames) {
+			String workflowId = accountToWorkflow.get(acc);
+
+			Map<String, List<Port>> usedVars = usedVarsByAccount
+					.get(workflowId);
+			Map<String, List<Port>> wgbVars = wgbVarsByAccount.get(workflowId);
+
+			if (usedVars == null || wgbVars == null)
+				continue;
+
+			// install an Datalink from each wgb var to each used var when the artifact is the same
+			for (Map.Entry<String, List<Port>> entry : wgbVars.entrySet()) {
+				// all Ports for this artifact get connected to all corresponding Ports in used
+				List<Port> sourceVars = entry.getValue();
+				List<Port> targetVars = usedVars.get(entry.getKey());
+
+				if (sourceVars == null || targetVars == null)
+					continue;
+
+				// create an datalink from each sourceVar to each targetVar
+				// note that we expect a single targetVar, but this is not guaranteed
+				for (Port sourceVar : sourceVars)
+					for (Port targetVar : targetVars)
+						pw.addDataLink(sourceVar, targetVar, workflowId);
+			}
+		}
+	}
+
+	private void generateWFFromAccount(String accName) throws SQLException {
+		String workflowId = accName + "-" + UUID.randomUUID().toString();
+		String workflowRun = accName + "-" + UUID.randomUUID().toString();
+
+		pw.addWFId(workflowId);
+		pw.addWorkflowRun(workflowId, workflowRun);
+		accountToWorkflow.put(accName, workflowId);
+		workflowToInstance.put(workflowId, workflowRun);
+
+		logger.info("generated workflowId " + workflowId + " and instance "
+				+ workflowRun + "  for account " + accName);
+	}
+
+	private Port processProcessArtifactDep(String procName, String value,
+			String portName, String workflowId, String workflowRun,
+			boolean artifactIsInput) {
+		// generate Process
+		ProvenanceProcessor proc = null;
+		try {
+			proc = pw.addProcessor(procName, workflowId, false);
+			logger.debug("added processor " + procName + " to workflow "
+					+ workflowId);
+		} catch (SQLException e) {
+			// no panic -- just catch duplicates
+			logger.warn(e.getMessage());
+			return null;
+		}
+
+		// generate Port
+		Port outputVar = new Port();
+		outputVar.setProcessorId(proc.getIdentifier());
+		outputVar.setProcessorName(procName);
+		outputVar.setWorkflowId(workflowId);
+		outputVar.setPortName(portName);
+		outputVar.setDepth(0);
+		outputVar.setInputPort(artifactIsInput); // wgby is an output var
+
+		List<Port> vars = new ArrayList<>(); // only one Port in the list
+		vars.add(outputVar);
+
+		try {
+			pw.addPorts(vars, workflowId);
+			logger.debug("added var "+portName+" to workflow "+workflowId);
+		} catch (SQLException e) {  // no panic -- just catch duplicates
+			logger.warn(e.getMessage());
+		}
+
+		// generate PortBindings (workflowRun, procName, portName, value)
+		PortBinding vb = new PortBinding();
+
+		vb.setWorkflowRunId(workflowRun);
+		vb.setProcessorName(procName);
+		vb.setPortName(portName);
+		vb.setValue(value);
+		vb.setIteration("[]");
+
+		try {
+			pw.addPortBinding(vb);
+			logger.debug("added var binding with value " + value
+					+ " to workflow instance " + workflowRun);
+		} catch (SQLException e) { // no panic -- just catch duplicates
+			logger.error("Failed to add var binding: " + e.getMessage());
+		}
+
+		return outputVar;
+	}
+
+	/**
+	 * generic processing of a process-artifact dependency
+	 * 
+	 * @param procID
+	 * @param artId
+	 * @param role
+	 * @param workflowId
+	 * @param workflowRun
+	 * @param artifactIsInput
+	 */
+	private Port processProcessArtifactDep(ProcessRef procID,
+			ArtifactRef artId, Role role, String workflowId,
+			String workflowRun, boolean artifactIsInput) {
+		String procName = ((Process) procID.getRef()).getId();
+		String portName = role.getValue();
+		String value = ((Artifact) artId.getRef()).getId();
+
+		portName = removeBlanks(portName);
+
+		return processProcessArtifactDep(procName, value, portName, workflowId,
+				workflowRun, artifactIsInput);
+	}
+
+	private String removeBlanks(String portName) {
+		return portName.replace(" ", "_");
+	}
+
+	/**
+	 * used(A,R,P,acc): generates a process for P, a Port for (P,R) an
+	 * <em>input</em> PortBinding for (P,R,A) <br/>
+	 * this is very similar to {@link #processWGBy(WasGeneratedBy)}
+	 * 
+	 * @param dep
+	 */
+	private void processUsed(Used dep) {
+		// Acc determines the scope -- this dep may belong to > 1 account, deal with all of them
+		List<AccountRef> accountIDs = dep.getAccount();
+		ProcessRef procID = dep.getEffect();
+		ArtifactRef artId = dep.getCause();
+		Role role = dep.getRole();
+
+		List<String> accNames = new ArrayList<String>();
+
+		for (AccountRef accId : accountIDs)
+			accNames.add(((Account) accId.getRef()).getId());
+
+		accNames.add(OPM_DEF_ACCOUNT);
+
+		for (String accName : accNames) {
+			String workflowId = accountToWorkflow.get(accName);
+			String workflowRun = workflowToInstance.get(workflowId);
+
+			Port v = processProcessArtifactDep(procID, artId, role, workflowId,
+					workflowRun, true); // true -> input var
+
+			// save the mapping from artifact to var for this account
+			Map<String, List<Port>> usedVars = usedVarsByAccount
+					.get(workflowId);
+			if (usedVars == null) {
+				usedVars = new HashMap<>();
+				usedVarsByAccount.put(workflowId, usedVars);
+			}
+			List<Port> vars = usedVars.get(((Artifact) artId.getRef()).getId());
+
+			if (vars == null) {
+				vars = new ArrayList<>();
+				usedVars.put(((Artifact) artId.getRef()).getId(), vars);
+			}
+			vars.add(v);
+
+			// record the fact that (procID used artId) within this account
+			Map<String, List<String>> usedArtifacts = usedArtifactsByAccount
+					.get(accName);
+			if (usedArtifacts == null) {
+				usedArtifacts = new HashMap<>();
+				usedArtifactsByAccount.put(accName, usedArtifacts);
+			}
+
+			String artifactName = ((Artifact) artId.getRef()).getId();
+			List<String> processes = usedArtifacts.get(artifactName);
+			if (processes == null) {
+				processes = new ArrayList<>();
+				usedArtifacts.put(artifactName, processes);
+			}
+			processes.add(((org.openprovenance.model.Process) procID.getRef())
+					.getId());
+		}
+	}
+
+	/**
+	 * wgb(A,R,P,Acc): generates a Process for P, a Port for (P,R), an
+	 * <em>output</em> PortBinding for (P,R,A) This is all relative to the
+	 * workflow corresponding to account Acc.
+	 * 
+	 * @param dep
+	 * @throws SQLException
+	 */
+	private void processWGBy(WasGeneratedBy dep)  {
+		// Acc determines the scope -- this dep may belong to > 1 account, deal with all of them
+		List<AccountRef> accountIDs = dep.getAccount();
+		ProcessRef procID = dep.getCause();
+		ArtifactRef artId = dep.getEffect();
+		Role role = dep.getRole();
+
+		List<String> accNames = new ArrayList<String>();
+		for (AccountRef accId : accountIDs)
+			accNames.add(((Account) accId.getRef()).getId());
+		accNames.add(OPM_DEF_ACCOUNT);
+
+		for (String accName : accNames) {
+			String workflowId = accountToWorkflow.get(accName);
+			String workflowRun = workflowToInstance.get(workflowId);
+
+			Port v = processProcessArtifactDep(procID, artId, role, workflowId,
+					workflowRun, false); // false -> output var
+
+			Map<String, List<Port>> wgbVars = wgbVarsByAccount.get(workflowId);
+			if (wgbVars == null) {
+				wgbVars = new HashMap<>();
+				wgbVarsByAccount.put(workflowId, wgbVars);
+			}
+
+			List<Port> vars = wgbVars.get(((Artifact) artId.getRef()).getId());
+			if (vars == null) {
+				vars = new ArrayList<>();
+				wgbVars.put(((Artifact) artId.getRef()).getId(), vars);
+			}
+			vars.add(v);
+
+			// record the fact that (artId wgby procID) within this account
+			Map<String, List<String>> wgbArtifacts = wgbArtifactsByAccount
+					.get(accName);
+			if (wgbArtifacts == null) {
+				wgbArtifacts = new HashMap<>();
+				wgbArtifactsByAccount.put(accName, wgbArtifacts);
+			}
+
+			String artifactName = ((Artifact) artId.getRef()).getId();
+			List<String> processes = wgbArtifacts.get(artifactName);
+			if (processes == null) {
+				processes = new ArrayList<>();
+				wgbArtifacts.put(artifactName, processes);
+			}
+			processes.add(((org.openprovenance.model.Process) procID.getRef())
+					.getId());
+		}
+	}
+
+	/**
+	 * this is a dep between two artifacts A1 and A2. In Taverna we need to
+	 * postulate the existence of a Process to mediate this dependency. <p/>
+	 * However, we only need to account for this dep if it cannot be inferred
+	 * from a combination of used and wgby that involve A1 and A2: if there
+	 * exists P s.t. A1 wgby P and P used A2, then this dep. is redundant in the
+	 * DB and we can safely ignore it. <p/>
+	 * note that this analysis is conducted regardless of the accounts in which
+	 * the wgby and used properties appear, as one account could be used
+	 * deliberately to This will unclutter the DB.
+	 * 
+	 * @param dep
+	 */
+	private void processWDF(WasDerivedFrom dep) {
+		List<AccountRef> accountIDs = dep.getAccount();
+		ArtifactRef fromArtId = dep.getCause();
+		ArtifactRef toArtId = dep.getEffect();
+
+		List<String> accNames = new ArrayList<>();
+		for (AccountRef accId : accountIDs)
+			accNames.add(((Account) accId.getRef()).getId());
+		accNames.add(OPM_DEF_ACCOUNT);
+
+		for (String accName:accNames) {
+			int varCounter = 0;
+
+			String workflowId = accountToWorkflow.get(accName);
+			String workflowRun = workflowToInstance.get(workflowId);
+
+			List<String> generatingProcesses = null, usingProcesses = null;
+
+			// look for any triple fromArtId wasGeneratedBy P within this account
+			Map<String, List<String>> wgbArtifacts = wgbArtifactsByAccount
+					.get(accName);
+
+			if (wgbArtifacts != null) {
+				String toArtifactName = ((Artifact) toArtId.getRef()).getId();
+				generatingProcesses = wgbArtifacts.get(toArtifactName);
+				if (generatingProcesses != null)
+					logger.debug("artifact " + toArtifactName
+							+ " wgby one or more processes...");
+			}
+
+			// look for any triple (P used toArtId) within this account
+
+			// get map for this account
+			Map<String, List<String>> usedArtifacts = usedArtifactsByAccount
+					.get(accName);
+
+			if (usedArtifacts != null) {
+				String fromArtifactName = ((Artifact) fromArtId.getRef())
+						.getId();
+				usingProcesses = usedArtifacts.get(fromArtifactName);
+				if (usingProcesses != null)
+					logger.debug("artifact " + fromArtifactName
+							+ " was used by one or more processes...");
+			}
+
+			if (generatingProcesses != null && usingProcesses != null)
+				for (String gp : generatingProcesses)
+					if (usingProcesses.contains(gp)) {
+						logger.debug("intersection between process sets not empty, this WDF is redundant");
+						return;
+					}
+
+			/* We only postulate a new process if the native one was not found */
+
+			String procName = PROC_NAME+"_"+procNameCounter++;
+
+			try {
+				pw.addProcessor(procName, workflowId, false);
+				logger.info("created non-native added processor " + procName
+						+ " to workflow " + workflowId);
+			} catch (SQLException e) {  // no panic -- just catch duplicates
+				logger.warn(e.getMessage());
+			}
+
+			// create a role for fromArtId from the procName
+			String inputPortName = procName + "_" + varCounter++;
+			String inputValue = ((Artifact) fromArtId.getRef()).getId();
+
+			// add to DB
+			processProcessArtifactDep(procName, inputValue, inputPortName,
+					workflowId, workflowRun, true);
+
+			// create a role for toArtId
+			String outputPortName = procName + "_" + varCounter++;
+			String outputValue = ((Artifact) toArtId.getRef()).getId();
+
+			// add to DB
+			processProcessArtifactDep(procName, outputValue, outputPortName,
+					workflowId, workflowRun, false);
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/opm/OPMManager.java
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/opm/OPMManager.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/opm/OPMManager.java
new file mode 100644
index 0000000..a82abdf
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/opm/OPMManager.java
@@ -0,0 +1,414 @@
+/**
+ * 
+ */
+package net.sf.taverna.t2.provenance.opm;
+
+import static org.tupeloproject.rdf.Resource.literal;
+import static org.tupeloproject.rdf.Resource.uriRef;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.List;
+
+import net.sf.taverna.t2.provenance.lineageservice.URIGenerator;
+import net.sf.taverna.t2.provenance.lineageservice.utils.DataValueExtractor;
+
+import org.apache.log4j.Logger;
+import org.tupeloproject.kernel.Context;
+import org.tupeloproject.kernel.OperatorException;
+import org.tupeloproject.kernel.UnionContext;
+import org.tupeloproject.kernel.impl.MemoryContext;
+import org.tupeloproject.kernel.impl.ResourceContext;
+import org.tupeloproject.provenance.ProvenanceAccount;
+import org.tupeloproject.provenance.ProvenanceArtifact;
+import org.tupeloproject.provenance.ProvenanceException;
+import org.tupeloproject.provenance.ProvenanceGeneratedArc;
+import org.tupeloproject.provenance.ProvenanceProcess;
+import org.tupeloproject.provenance.ProvenanceRole;
+import org.tupeloproject.provenance.ProvenanceUsedArc;
+import org.tupeloproject.provenance.impl.ProvenanceContextFacade;
+import org.tupeloproject.rdf.Literal;
+import org.tupeloproject.rdf.Resource;
+import org.tupeloproject.rdf.xml.RdfXmlWriter;
+
+
+/**
+ * @author paolo
+ * 
+ */
+public class OPMManager {
+	private static Logger logger = Logger.getLogger(OPMManager.class);
+
+	public static final String OPM_TAVERNA_NAMESPACE = "http://ns.taverna.org.uk/2011/provenance/opm/";
+	private static final String VALUE_PROP = "value";
+
+	private ProvenanceContextFacade graph = null;
+	private Context context = null;
+
+	private ProvenanceAccount currentAccount = null;
+	private ProvenanceArtifact currentArtifact = null;
+	private ProvenanceRole currentRole = null;
+	private ProvenanceProcess currentProcess = null;
+
+	private boolean isActive = true;
+
+	public OPMManager() {
+		// init Tupelo RDF provenance graph
+		MemoryContext mc = new MemoryContext();
+		ResourceContext rc = new ResourceContext("http://example.org/data/",
+				"/provenanceExample/");
+		context = new UnionContext();
+		context.addChild(mc);
+		context.addChild(rc);
+
+		graph = new ProvenanceContextFacade(mc);
+	}
+
+	/**
+	 * default implementation of this method returns null -- has no idea how to
+	 * extract simple values from incoming artifact values
+	 * 
+	 * @return
+	 */
+	public List<DataValueExtractor> getDataValueExtractor() {
+		return null;
+	}
+
+	/**
+	 * create new account to hold the causality graph and give it a Resource
+	 * name
+	 * 
+	 * @param accountName
+	 * @throws ProvenanceException
+	 */
+	public void createAccount(String accountName) throws ProvenanceException {
+		currentAccount = graph.newAccount("OPM-" + accountName,
+				uriRef(uriGenerator.makeRunUri(accountName)));
+		graph.assertAccount(currentAccount);
+	}
+
+	/**
+	 * @param aName
+	 * @param aValue
+	 *            actual value can be used optionally as part of a separate
+	 *            triple. Whether this is used or not depends on the settings,
+	 *            see {@link OPMManager.addValueTriple}. This also sets the
+	 *            currentArtifact to the newly created artifact
+	 * @throws ProvenanceException
+	 */
+	public void addArtifact(String aName, Object aValue)
+			throws ProvenanceException {
+		Resource r = addArtifact(aName);
+
+		if (aValue == null) {
+			logger.debug("OPMManager::addArtifact: aValue for [" + aName
+					+ "] is NULL");
+			return;
+		}
+
+		logger.debug("OPMManager::addArtifact: aValue is NOT NULL");
+
+		// if we have a valid DataValueExtractor, use it here
+		List<DataValueExtractor> dveList;
+		String extractedValue = (String) aValue;  // default is same value
+		dveList = getDataValueExtractor();
+		if (dveList != null)
+			// try all available extractors... UGLY but data comes with NO TYPE at all!
+			for (DataValueExtractor dve : dveList)
+				try {
+					logger.debug("OPMManager::addArtifact: trying extractor "
+							+ dve.getClass().getName());
+					extractedValue = dve.extractString(aValue);
+					logger.debug("OPMManager::addArtifact: - extracted value = "
+							+ extractedValue);
+					break; // extractor worked
+				} catch (Exception e) {
+					// no panic, reset value and try another extractor
+					logger.warn("OPMManager::addArtifact: extractor failed");
+					extractedValue = (String) aValue;
+				}
+
+		logger.debug("OPMManager::addArtifact: using value " + extractedValue);
+		try {
+			Literal lValue = literal(extractedValue);
+			context.addTriple(r, uriRef(OPM_TAVERNA_NAMESPACE + VALUE_PROP),
+					lValue);
+		} catch (OperatorException e) {
+			logger.warn("OPM iteration triple creation exception", e);
+		}
+	}
+
+	/**
+	 * no actual value is recorded
+	 * 
+	 * @param aName
+	 * @return
+	 * @throws ProvenanceException
+	 */
+	public Resource addArtifact(String aName) throws ProvenanceException {
+		String artID = null;
+		// make sure artifact name is a good URI
+		try {
+			URI artURI = new URI(aName);
+			if (artURI.getScheme() != null) {
+				if (artURI.getScheme().equals("t2"))
+					artID = uriGenerator.makeT2ReferenceURI(aName);
+				else
+					artID = aName;
+			}
+		} catch (URISyntaxException e1) {
+			// generate later
+		}
+		if (artID == null)
+			artID = OPM_TAVERNA_NAMESPACE + "artifact/"
+					+ uriGenerator.escape(aName);
+
+		Resource r = uriRef(artID);
+		currentArtifact = graph.newArtifact(artID, r);
+		graph.assertArtifact(currentArtifact);
+		return r;
+	}
+
+	public void createRole(String workflowRunId, String workflowId,
+			String processorName, String iteration) {
+		String aRole = uriGenerator.makeIteration(workflowRunId, workflowId,
+				processorName, iteration);
+		Resource r = Resource.uriRef(aRole);
+		currentRole = graph.newRole(aRole, r);
+	}
+
+	private URIGenerator uriGenerator = new URIGenerator();
+
+	public void addProcess(String processorName, String iterationVector,
+			String workflowId, String workflowRunId) throws ProvenanceException {
+		String processID;
+
+		/*
+		 * PM added 5/09 -- a process name may already be a URI -- this happens
+		 * for example when we export back OPM after importing a workflow from
+		 * our own OPM... in this case, do not pre-pend a new URI scheme
+		 */
+		try {
+			URI procURI = new URI(processorName);
+
+			if (procURI.getAuthority() == null) {
+				processID = uriGenerator.makeProcessorURI(processorName, workflowId);
+			} else {
+				processID = processorName;
+			}
+		} catch (URISyntaxException e1) {
+			processID = uriGenerator.makeProcessorURI(processorName, workflowId);
+		}
+		
+		uriGenerator.makeIteration(workflowRunId, workflowId, processorName,
+				iterationVector);
+
+		Resource processResource = uriRef(processID);
+		currentProcess = graph.newProcess(processID, processResource);
+		graph.assertProcess(currentProcess);
+
+		/*
+		 * add a triple to specify the iteration vector for this occurrence of
+		 * Process, if it is available
+		 */
+		try {
+			if (! iterationVector.equals("[]"))
+				// Resource inputProcessSubject = ((RdfProvenanceProcess) process).getSubject();
+				context.addTriple(processResource, uriRef(OPM_TAVERNA_NAMESPACE
+						+ "iteration"), iterationVector);
+		} catch (OperatorException e) {
+			logger.warn("OPM iteration triple creation exception", e);
+		}
+	}
+
+	public void assertGeneratedBy(ProvenanceArtifact artifact,
+			ProvenanceProcess process, ProvenanceRole role,
+			ProvenanceAccount account, boolean noDuplicates)
+			throws ProvenanceException {
+		boolean found = false;
+		if (noDuplicates && artifact != null)
+			for (ProvenanceGeneratedArc datalink : graph
+					.getGeneratedBy(artifact)) {
+				ProvenanceProcess pp = datalink.getProcess();
+				if (pp.getName().equals(process.getName())) {
+					found = true;
+					break;
+				}
+			}
+
+		if (!noDuplicates || (noDuplicates && !found) && artifact != null)
+			graph.assertGeneratedBy(artifact, process, role, account);
+	}
+
+	public void assertUsed(ProvenanceArtifact artifact,
+			ProvenanceProcess process, ProvenanceRole role,
+			ProvenanceAccount account, boolean noDuplicates)
+			throws ProvenanceException {
+		boolean found = false;
+
+		if (noDuplicates)
+			for (ProvenanceUsedArc datalink : graph.getUsed(process)) {
+				ProvenanceArtifact pa = datalink.getArtifact();
+				if (pa.getName().equals(artifact.getName())) {
+					found = true;
+					break;
+				}
+			}
+
+		if (!noDuplicates || (noDuplicates && !found))
+			graph.assertUsed(process, artifact, role, account);
+	}
+
+	public ProvenanceContextFacade getGraph() {
+		return graph;
+	}
+
+	/**
+	 * @return the account
+	 */
+	public ProvenanceAccount getAccount() {
+		return currentAccount;
+	}
+
+	/**
+	 * @param account
+	 *            the account to set
+	 */
+	public void setAccount(ProvenanceAccount account) {
+		this.currentAccount = account;
+	}
+
+	/**
+	 * @return the currentRole
+	 */
+	public ProvenanceRole getCurrentRole() {
+		return currentRole;
+	}
+
+	/**
+	 * @param currentRole
+	 *            the currentRole to set
+	 */
+	public void setCurrentRole(ProvenanceRole currentRole) {
+		this.currentRole = currentRole;
+	}
+
+	/**
+	 * @return the currentArtifact
+	 */
+	public ProvenanceArtifact getCurrentArtifact() {
+		return currentArtifact;
+	}
+
+	/**
+	 * @param currentArtifact
+	 *            the currentArtifact to set
+	 */
+	public void setCurrentArtifact(ProvenanceArtifact currentArtifact) {
+		this.currentArtifact = currentArtifact;
+	}
+
+	/**
+	 * @return the currentAccount
+	 */
+	public ProvenanceAccount getCurrentAccount() {
+		return currentAccount;
+	}
+
+	/**
+	 * @param currentAccount
+	 *            the currentAccount to set
+	 */
+	public void setCurrentAccount(ProvenanceAccount currentAccount) {
+		this.currentAccount = currentAccount;
+	}
+
+	/**
+	 * @return the currentProcess
+	 */
+	public ProvenanceProcess getCurrentProcess() {
+		return currentProcess;
+	}
+
+	/**
+	 * @param currentProcess
+	 *            the currentProcess to set
+	 */
+	public void setCurrentProcess(ProvenanceProcess currentProcess) {
+		this.currentProcess = currentProcess;
+	}
+
+	public String writeGraph() {
+		// print out OPM graph in RDF/XML form
+		try {
+			StringWriter sw = new StringWriter();
+			new RdfXmlWriter().write(context.getTriples(), sw);
+			return sw.toString();
+		} catch (OperatorException | IOException e) {
+			logger.error("Could not write graph", e);
+		}
+		return null;
+	}
+
+	/**
+	 * IN THE RELEASE WE DO NOT SUPPORT XML -- ONE CAN CONVERT THE RDF TO XML OUT-OF-BAND
+	 * simply invokes the org.openprovenance for converting an RDF OPM graph to an XML OPM graph
+	 * @return a hard-coded filename for the converted XML OPM graph
+	 * @throws OperatorException
+	 * @throws IOException
+	 * @throws JAXBException
+	 */
+//	public String Rdf2Xml() throws OperatorException, IOException, JAXBException {
+//
+//		OPMRdf2Xml converter = new OPMRdf2Xml();
+//		converter.convert(OPM_RDF_GRAPH_FILE, OPM_XML_GRAPH_FILE);		
+//		return OPM_XML_GRAPH_FILE;
+//	}
+
+	/**
+	 * creates a dot file from the current OPMGraph. <br/>
+	 * DOT NOT USE NEEDS FIXING
+	 * @return
+	 * @throws IOException 
+	 * @throws OperatorException 
+	 */
+	/*
+	public String Rdf2Dot() throws OperatorException, IOException {
+
+		OPMRdf2Xml converter = new OPMRdf2Xml();
+		OPMGraph graph = converter.convert(OPM_RDF_GRAPH_FILE);
+
+		List<Process> processes = graph.getProcesses().getProcess();		
+		for (Process p:processes) { p.setId("\""+p.getId()+"\""); }
+
+		List<Artifact> artifacts = graph.getArtifacts().getArtifact();		
+		for (Artifact a:artifacts) { a.setId("\""+a.getId()+"\""); }
+
+//		OPMToDot aOPMToDot = new OPMToDot(DOT_CONFIG_FILE);  		
+		OPMToDot aOPMToDot = new OPMToDot();  		
+
+		aOPMToDot.convert(graph, new File(OPM_DOT_FILE));
+		return OPM_DOT_FILE;
+
+	}
+
+    */
+
+	/**
+	 * @param graph
+	 *            the graph to set
+	 */
+	public void setGraph(ProvenanceContextFacade graph) {
+		this.graph = graph;
+	}
+
+	public void setActive(boolean active) {
+		isActive = active;
+	}
+
+	public boolean isActive() {
+		return isActive;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-provenanceconnector/src/main/resources/META-INF/spring/provenance-connector-context.xml
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/resources/META-INF/spring/provenance-connector-context.xml b/taverna-provenanceconnector/src/main/resources/META-INF/spring/provenance-connector-context.xml
new file mode 100644
index 0000000..2a4b3c0
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/resources/META-INF/spring/provenance-connector-context.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:osgi="http://www.springframework.org/schema/osgi"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans
+                      http://www.springframework.org/schema/beans/spring-beans.xsd
+                      http://www.springframework.org/schema/osgi
+                      http://www.springframework.org/schema/osgi/spring-osgi.xsd">
+
+	<bean id="ProvenanceAccess" class="net.sf.taverna.t2.provenance.api.ProvenanceAccess">
+		<property name="referenceService" ref="referenceService" />
+		<property name="provenanceConnector" ref="provenanceConnector" />
+	</bean>
+
+	<osgi:service ref="ProvenanceAccess" interface="net.sf.taverna.t2.provenance.Provenance"/>
+
+	<osgi:reference id="referenceService" interface="net.sf.taverna.t2.reference.ReferenceService"/>
+	<osgi:reference id="provenanceConnector" interface="net.sf.taverna.t2.provenance.reporter.ProvenanceReporter"/>
+</beans>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-provenanceconnector/src/main/resources/janus.owl
----------------------------------------------------------------------
diff --git a/taverna-provenanceconnector/src/main/resources/janus.owl b/taverna-provenanceconnector/src/main/resources/janus.owl
new file mode 100644
index 0000000..1017574
--- /dev/null
+++ b/taverna-provenanceconnector/src/main/resources/janus.owl
@@ -0,0 +1 @@
+/Users/paolo/Dropbox/Janus/janus.owl
\ No newline at end of file