You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@taverna.apache.org by re...@apache.org on 2015/03/23 17:38:13 UTC

[29/51] [partial] incubator-taverna-engine git commit:

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-report-api/src/main/java/org/apache/taverna/platform/report/WorkflowReport.java
----------------------------------------------------------------------
diff --git a/taverna-report-api/src/main/java/org/apache/taverna/platform/report/WorkflowReport.java b/taverna-report-api/src/main/java/org/apache/taverna/platform/report/WorkflowReport.java
new file mode 100644
index 0000000..20807ae
--- /dev/null
+++ b/taverna-report-api/src/main/java/org/apache/taverna/platform/report/WorkflowReport.java
@@ -0,0 +1,168 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.report;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.LinkedHashSet;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import org.apache.taverna.robundle.Bundle;
+import org.apache.taverna.scufl2.api.core.Workflow;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+/**
+ * Report about the {@link State} of a {@link Workflow} run.
+ *
+ * @author David Withers
+ */
+public class WorkflowReport extends StatusReport<Workflow, ActivityReport> {
+	@SuppressWarnings("unused")
+	private static final Logger logger = Logger.getLogger(WorkflowReport.class.getName());
+	private static final String dateFormatString = "yyyy-MM-dd HH:mm:ss";
+
+	private Set<ProcessorReport> processorReports = new LinkedHashSet<>();
+	private Bundle dataBundle;
+
+	public WorkflowReport(Workflow workflow) {
+		super(workflow);
+	}
+
+	public Set<ProcessorReport> getProcessorReports() {
+		return processorReports;
+	}
+
+	public void addProcessorReport(ProcessorReport processorReport) {
+		processorReports.add(processorReport);
+	}
+
+	@JsonIgnore
+	public Bundle getDataBundle() {
+		return dataBundle;
+	}
+
+	public void setDataBundle(Bundle dataBundle) {
+		this.dataBundle = dataBundle;
+	}
+
+	@Override
+	public String toString() {
+		DateFormat dateFormat = new SimpleDateFormat(dateFormatString);
+		StringBuilder sb = new StringBuilder();
+		int max = getLongestName(this, 0);
+		spaces(sb, max + 1);
+		sb.append("Status    ");
+		sb.append("Queued    ");
+		sb.append("Started   ");
+		sb.append("Complete  ");
+		sb.append("Errors    ");
+		sb.append("Started             ");
+		sb.append("Finished\n");
+		sb.append(getSubject().getName());
+		spaces(sb, max - getSubject().getName().length() + 1);
+		sb.append(getState());
+		spaces(sb, 10 - getState().name().length());
+		sb.append("-");
+		spaces(sb, 9);
+		sb.append("-");
+		spaces(sb, 9);
+		sb.append("-");
+		spaces(sb, 9);
+		sb.append("-");
+		spaces(sb, 9);
+		addDates(sb, getStartedDate(), getCompletedDate(), dateFormat);
+		for (ProcessorReport processorReport : getProcessorReports())
+			addProcessor(sb, max, 0, processorReport, dateFormat);
+		return sb.toString();
+	}
+
+	private void addProcessor(StringBuilder sb, int max, int level, ProcessorReport processorReport, DateFormat dateFormat) {
+		String processorName = processorReport.getSubject().getName();
+		spaces(sb, level);
+		sb.append(processorName);
+		spaces(sb, max - processorName.length() - level + 1);
+
+		State processorState = processorReport.getState();
+		sb.append(processorState);
+		spaces(sb, 10 - processorState.name().length());
+
+		String jobsQueued = String.valueOf(processorReport.getJobsQueued());
+		sb.append(jobsQueued);
+		spaces(sb, 10 - jobsQueued.length());
+
+		String jobsStarted = String.valueOf(processorReport.getJobsStarted());
+		sb.append(jobsStarted);
+		spaces(sb, 10 - jobsStarted.length());
+
+		String jobsCompleted = String.valueOf(processorReport.getJobsCompleted());
+		sb.append(jobsCompleted);
+		spaces(sb, 10 - jobsCompleted.length());
+
+		String jobsCompletedWithErrors = String.valueOf(processorReport
+				.getJobsCompletedWithErrors());
+		sb.append(jobsCompletedWithErrors);
+		spaces(sb, 10 - jobsCompletedWithErrors.length());
+
+		addDates(sb, processorReport.getStartedDate(), processorReport.getCompletedDate(), dateFormat);
+
+		for (ActivityReport activityReport : processorReport.getActivityReports()) {
+			WorkflowReport nestedWorkflowReport = activityReport.getNestedWorkflowReport();
+			if (nestedWorkflowReport != null)
+				for (ProcessorReport nestedProcessorReport : nestedWorkflowReport.getProcessorReports())
+					addProcessor(sb, max, level + 1, nestedProcessorReport, dateFormat);
+		}
+	}
+
+	private void addDates(StringBuilder sb, Date started, Date stopped, DateFormat dateFormat) {
+		if (started != null) {
+			sb.append(dateFormat.format(started));
+			sb.append(' ');
+		} else {
+			sb.append('-');
+			spaces(sb, dateFormatString.length());
+		}
+		if (stopped != null)
+			sb.append(dateFormat.format(stopped) + "\n");
+		else
+			sb.append("-\n");
+	}
+
+	private int getLongestName(WorkflowReport workflowReport, int level) {
+		int result = 0;
+		result = Math.max(result, getSubject().getName().length() + level);
+		for (ProcessorReport processorReport : workflowReport.getProcessorReports()) {
+			result = Math.max(result, processorReport.getSubject().getName().length());
+			for (ActivityReport activityReport : processorReport.getActivityReports()) {
+				WorkflowReport nestedWorkflowReport = activityReport.getNestedWorkflowReport();
+				if (nestedWorkflowReport != null)
+					result = Math.max(result, getLongestName(nestedWorkflowReport, level + 1));
+			}
+		}
+		return result;
+	}
+
+	private static void spaces(StringBuilder sb, int length) {
+		for (int i = 0; i < length; i++)
+			sb.append(' ');
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-report-api/src/main/java/uk/org/taverna/platform/report/ActivityReport.java
----------------------------------------------------------------------
diff --git a/taverna-report-api/src/main/java/uk/org/taverna/platform/report/ActivityReport.java b/taverna-report-api/src/main/java/uk/org/taverna/platform/report/ActivityReport.java
deleted file mode 100644
index 4a9d1ea..0000000
--- a/taverna-report-api/src/main/java/uk/org/taverna/platform/report/ActivityReport.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 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 uk.org.taverna.platform.report;
-
-import org.apache.taverna.scufl2.api.activity.Activity;
-
-/**
- * Report about the {@link State} of an {@link Activity} invocation.
- *
- * @author David Withers
- */
-public class ActivityReport extends StatusReport<Activity, ProcessorReport> {
-	private WorkflowReport nestedWorkflowReport;
-
-	/**
-	 * Constructs a new <code>ActivityReport</code>.
-	 *
-	 * @param activity
-	 */
-	public ActivityReport(Activity activity) {
-		super(activity);
-	}
-
-	public WorkflowReport getNestedWorkflowReport() {
-		return nestedWorkflowReport;
-	}
-
-	public void setNestedWorkflowReport(WorkflowReport nestedWorkflowReport) {
-		this.nestedWorkflowReport = nestedWorkflowReport;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-report-api/src/main/java/uk/org/taverna/platform/report/Invocation.java
----------------------------------------------------------------------
diff --git a/taverna-report-api/src/main/java/uk/org/taverna/platform/report/Invocation.java b/taverna-report-api/src/main/java/uk/org/taverna/platform/report/Invocation.java
deleted file mode 100644
index fc95157..0000000
--- a/taverna-report-api/src/main/java/uk/org/taverna/platform/report/Invocation.java
+++ /dev/null
@@ -1,306 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2013 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 uk.org.taverna.platform.report;
-
-import java.nio.file.Path;
-import java.util.Date;
-import java.util.Map;
-import java.util.SortedMap;
-import java.util.SortedSet;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-import org.apache.taverna.scufl2.api.port.Port;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
-
-/**
- * A single invocation of a workflow, processor or activity.
- *
- * @author David Withers
- */
-@JsonPropertyOrder({"id","parent", "name",  "index", "state", "startedDate", "completedDate", "inputs", "outputs"})
-public class Invocation implements Comparable<Invocation> {
-	private final String name;
-	private final int[] index;
-	private final Invocation parent;
-	private State state;
-	private Date startedDate, completedDate;
-	private final SortedSet<Invocation> invocations;
-	private final StatusReport<?, ?> report;
-	private SortedMap<String, Path> inputs, outputs;
-
-	/**
-     * Internal constructor for comparison use.
-     *
-     * Only use with {@link #compareTo(Invocation)} use when looking
-     * up from {@link StatusReport#getInvocation(String)}. All fields except
-     * {@link #getName()} are <code>null</code>.
-     *
-     * @param name The name of the invocation to compare with
-     **/
-	Invocation(String name) {
-	    this.name = name;
-	    this.report = null;
-	    this.parent = null;
-	    this.invocations = null;
-	    this.index = null;
-	}
-
-	public Invocation(String name, Invocation parent, StatusReport<?, ?> report) {
-		this(name, new int[0], parent, report);
-	}
-
-	public Invocation(String name, int[] index, Invocation parent, StatusReport<?, ?> report) {
-		this.name = name;
-		this.index = index;
-		this.parent = parent;
-		this.report = report;
-
-		invocations = new TreeSet<>();
-
-		inputs = new TreeMap<>();
-		for (Port port : report.getSubject().getInputPorts())
-			inputs.put(port.getName(), null);
-
-		outputs = new TreeMap<>();
-		for (Port port : report.getSubject().getOutputPorts())
-			outputs.put(port.getName(), null);
-
-		setStartedDate(new Date());
-
-		if (parent != null)
-			parent.getInvocations().add(this);
-		report.addInvocation(this);
-	}
-
-	/**
-	 * Returns the name for this invocation.
-	 *
-	 * @return the name for this invocation
-	 */
-	@JsonProperty("name")
-	public String getName() {
-		return name;
-	}
-
-	public int[] getIndex() {
-		return index;
-	}
-
-	/**
-	 * Returns the  identifier for this invocation by prepending the identifier of the parent
-	 * invocation.
-	 *
-	 * @return the identifier for this invocation
-	 */
-	@JsonProperty("id")
-	public String getId() {
-		if (parent != null) {
-			String parentId = parent.getId();
-			if (parentId != null && !parentId.isEmpty())
-				return parent.getId() + "/" + name;
-		}
-		return name;
-	}
-
-	@JsonIgnore
-	public StatusReport<?, ?> getReport() {
-		return report;
-	}
-
-	/**
-	 * Returns the parent invocation.
-	 * <p>
-	 * Returns <code>null</code> if there is no parent invocation.
-	 *
-	 * @return the parent invocation
-	 */
-	@JsonIgnore
-	public Invocation getParent() {
-		return parent;
-	}
-
-	@JsonProperty("parent")
-	public String getParentId() {
-	    if (parent == null)
-	        return null;
-	    return parent.getId();
-	}
-
-	/**
-	 * Returns the child invocations.
-	 * <p>
-	 * Returns and empty set if there are no child invocations.
-	 *
-	 * @return the child invocations
-	 */
-	@JsonIgnore
-	public SortedSet<Invocation> getInvocations() {
-		return invocations;
-	}
-
-	/**
-	 * Returns a map of input port names to values.
-	 * <p>
-	 * Returns an empty map if there are no input ports. If there is no value for an input port the
-	 * map will contain a <code>null</code> value.
-	 *
-	 * @return a map of input port names to values
-	 */
-	public SortedMap<String, Path> getInputs() {
-		return inputs;
-	}
-
-	/**
-	 * Sets the values of input ports.
-	 *
-	 * @param inputs
-	 *            the values of input ports
-	 */
-	public void setInputs(Map<String, Path> inputs) {
-		this.inputs.putAll(inputs);
-	}
-
-	/**
-	 * Sets the value of an input port.
-	 *
-	 * @param port the port name
-	 * @param value the port value
-	 */
-	public void setInput(String port, Path value) {
-		inputs.put(port, value);
-	}
-
-	/**
-	 * Returns a map of output port names to values.
-	 * <p>
-	 * Returns an empty map if there are no output ports. If there is no value for an output port
-	 * the map will contain a <code>null</code> value.
-	 *
-	 * @return a map of input port names to values
-	 */
-	public SortedMap<String, Path> getOutputs() {
-		return outputs;
-	}
-
-	/**
-	 * Sets the values of input ports.
-	 *
-	 * @param inputs
-	 *            the values of input ports
-	 */
-	public void setOutputs(Map<String, Path> outputs) {
-		this.outputs.putAll(outputs);
-	}
-
-	/**
-	 * Sets the value of an output port.
-	 *
-	 * @param port the port name
-	 * @param value the port value
-	 */
-	public void setOutput(String port, Path value) {
-		outputs.put(port, value);
-	}
-
-	/**
-	 * Returns the current {@link State} of the invocation.
-	 * <p>
-	 * An invocation state can be RUNNING or COMPLETED.
-	 *
-	 * @return the current <code>State</code>
-	 */
-	public State getState() {
-		return state;
-	}
-
-	/**
-	 * Returns the date that the status changed to RUNNING.
-	 * <p>
-	 * If the status has never been RUNNING <code>null</code> is returned.
-	 *
-	 * @return the date that the status changed to started
-	 */
-	public Date getStartedDate() {
-		return startedDate;
-	}
-
-	/**
-	 * Sets the date that the status changed to RUNNING.
-	 *
-	 * @param startedDate
-	 *            the date that the status changed to RUNNING
-	 */
-	public void setStartedDate(Date startedDate) {
-		this.startedDate = startedDate;
-		state = State.RUNNING;
-	}
-
-	/**
-	 * Returns the date that the status changed to COMPLETED.
-	 * <p>
-	 * If the status never been COMPLETED <code>null</code> is returned.
-	 *
-	 * @return the date that the status changed to COMPLETED
-	 */
-	public Date getCompletedDate() {
-		return completedDate;
-	}
-
-	/**
-	 * Sets the date that the status changed to COMPLETED.
-	 *
-	 * @param completedDate
-	 *            the date that the status changed to COMPLETED
-	 */
-	public void setCompletedDate(Date completedDate) {
-		this.completedDate = completedDate;
-		state = State.COMPLETED;
-	}
-
-	@Override
-	public String toString() {
-		return "Invocation " + indexToString(index);
-	}
-
-	@Override
-	public int compareTo(Invocation o) {
-		String id = getId();
-		String otherId = o.getId();
-		if (id.length() == otherId.length())
-			return id.compareTo(otherId);
-		// Make "invoc5" be sorted before "invoc49"
-		return id.length() - otherId.length();
-	}
-
-	private String indexToString(int[] index) {
-		StringBuilder indexString = new StringBuilder();
-		String sep = "";
-		for (int idx : index) {
-			indexString.append(sep).append(idx + 1);
-			sep = ":";
-		}
-		return indexString.toString();
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-report-api/src/main/java/uk/org/taverna/platform/report/ProcessorReport.java
----------------------------------------------------------------------
diff --git a/taverna-report-api/src/main/java/uk/org/taverna/platform/report/ProcessorReport.java b/taverna-report-api/src/main/java/uk/org/taverna/platform/report/ProcessorReport.java
deleted file mode 100644
index 1912eb3..0000000
--- a/taverna-report-api/src/main/java/uk/org/taverna/platform/report/ProcessorReport.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 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 uk.org.taverna.platform.report;
-
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.Set;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-import org.apache.taverna.scufl2.api.core.Processor;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
-
-/**
- * Report about the {@link State} of a {@link Processor} invocation.
- *
- * @author David Withers
- * @author Stian Soiland-Reyes
- */
-@JsonPropertyOrder({ "subject", "parent", "state", "createdDate",
-        "startedDate", "pausedDate", "pausedDates", "resumedDate",
-        "resumedDates", "cancelledDate", "failedDate", "completedDate",
-        "jobsQueued", "jobsStarted", "jobsCompleted",
-        "jobsCompletedWithErrors", "invocations", "activityReports"})
-public class ProcessorReport extends StatusReport<Processor, WorkflowReport> {
-	private Set<ActivityReport> activityReports = new LinkedHashSet<>();
-	private int jobsCompleted;
-    private int jobsCompletedWithErrors;
-    private int jobsQueued;
-    private int jobsStarted;
-    private SortedMap<String, Object> properties = new TreeMap<>();
-
-    /**
-	 * Constructs a new <code>ProcessorReport</code>.
-	 *
-	 * @param processor The processor to report on
-	 */
-	public ProcessorReport(Processor processor) {
-		super(processor);
-	}
-
-    public void addActivityReport(ActivityReport activityReport) {
-		activityReports.add(activityReport);
-	}
-
-    public Set<ActivityReport> getActivityReports() {
-		return activityReports;
-	}
-
-    /**
-	 * Returns the number of jobs that the processor has completed.
-	 *
-	 * @return the number of jobs that the processor has completed
-	 */
-	public int getJobsCompleted() {
-	    return jobsCompleted;
-	}
-
-	/**
-	 * Returns the number of jobs that completed with an error.
-	 *
-	 * @return the number of jobs that completed with an error
-	 */
-	public int getJobsCompletedWithErrors() {
-	    return jobsCompletedWithErrors;
-	}
-
-	/**
-	 * Returns the number of jobs queued by the processor.
-	 *
-	 * @return the number of jobs queued by the processor
-	 */
-	public int getJobsQueued() {
-        return jobsQueued;
-    }
-
-	/**
-	 * Returns the number of jobs that the processor has started processing.
-	 *
-	 * @return the number of jobs that the processor has started processing
-	 */
-	public int getJobsStarted() {
-	    return jobsStarted;
-	}
-
-	public Object getProperty(String key) {
-		return properties.get(key);
-	}
-
-	@JsonIgnore 
-	public Set<String> getPropertyKeys() {
-		return new HashSet<>(properties.keySet());
-	}
-
-	/**
-     * Set the number of completed jobs.
-     * 
-     * @param jobsCompleted the number of jobs that the processor has completed.
-     */
-    public void setJobsCompleted(int jobsCompleted) {
-        this.jobsCompleted = jobsCompleted;
-    }
-
-	/**
-     * Set the number of jobs that have completed, but with errors.
-     * 
-     * @param jobsCompletedWithErrors the number of jobs that completed with errors
-     */
-    public void setJobsCompletedWithErrors(int jobsCompletedWithErrors) {
-        this.jobsCompletedWithErrors = jobsCompletedWithErrors;
-    }
-
-	/**
-     * Set the number of queued jobs.
-     * 
-     * @param jobsQueued the number of jobs queued by the processor
-     */
-    public void setJobsQueued(int jobsQueued) {
-        this.jobsQueued = jobsQueued;
-    }
-
-	/**
-     * Set the number of started jobs.
-     * 
-     * @param jobsStarted the number of jobs that the processor has started processing
-     */
-    public void setJobsStarted(int jobsStarted) {
-        this.jobsStarted = jobsStarted;
-    }
-
-    /**
-     * Set an additional property
-     * 
-     * @param key
-     * @param value
-     */
-	public void setProperty(String key, Object value) {
-		synchronized (properties) {
-			// if (properties.containsKey(key)) {
-			properties.put(key, value);
-			// }
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-report-api/src/main/java/uk/org/taverna/platform/report/ReportListener.java
----------------------------------------------------------------------
diff --git a/taverna-report-api/src/main/java/uk/org/taverna/platform/report/ReportListener.java b/taverna-report-api/src/main/java/uk/org/taverna/platform/report/ReportListener.java
deleted file mode 100644
index 5458fb5..0000000
--- a/taverna-report-api/src/main/java/uk/org/taverna/platform/report/ReportListener.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2013 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 uk.org.taverna.platform.report;
-
-import java.nio.file.Path;
-
-/**
- * @author David Withers
- */
-public interface ReportListener {
-	void outputAdded(Path path, String portName, int[] index);
-
-	void stateChanged(State oldState, State newState);
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-report-api/src/main/java/uk/org/taverna/platform/report/State.java
----------------------------------------------------------------------
diff --git a/taverna-report-api/src/main/java/uk/org/taverna/platform/report/State.java b/taverna-report-api/src/main/java/uk/org/taverna/platform/report/State.java
deleted file mode 100755
index 226d3eb..0000000
--- a/taverna-report-api/src/main/java/uk/org/taverna/platform/report/State.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 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 uk.org.taverna.platform.report;
-
-/**
- * Valid states for status reports.
- *
- * @author David Withers
- */
-public enum State {
-	CREATED, RUNNING, COMPLETED, PAUSED, CANCELLED, FAILED
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-report-api/src/main/java/uk/org/taverna/platform/report/StatusReport.java
----------------------------------------------------------------------
diff --git a/taverna-report-api/src/main/java/uk/org/taverna/platform/report/StatusReport.java b/taverna-report-api/src/main/java/uk/org/taverna/platform/report/StatusReport.java
deleted file mode 100644
index 254230f..0000000
--- a/taverna-report-api/src/main/java/uk/org/taverna/platform/report/StatusReport.java
+++ /dev/null
@@ -1,373 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 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 uk.org.taverna.platform.report;
-
-import java.net.URI;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.NavigableSet;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import org.apache.taverna.scufl2.api.common.Ported;
-import org.apache.taverna.scufl2.api.common.URITools;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
-
-/**
- * Report about the {@link State} of a workflow component.
- *
- * @author David Withers
- * @param <SUBJECT>
- *            the WorkflowBean that the report is about
- * @param <PARENT>
- *            the parent report type
- */
-
-@JsonPropertyOrder({ "subject", "parent", "state", "createdDate", "startedDate", "pausedDate",
-    "pausedDates", "resumedDate", "resumedDates", "cancelledDate", "failedDate", "completedDate"})
-public class StatusReport<SUBJECT extends Ported, PARENT extends StatusReport<?, ?>> {
-	private final SUBJECT subject;
-	private PARENT parentReport;
-	private State state;
-	private NavigableSet<Invocation> invocations = new TreeSet<>();
-	private Date createdDate, startedDate, pausedDate, resumedDate, cancelledDate, completedDate,
-			failedDate;
-	private final List<Date> pausedDates = new ArrayList<>(),
-			resumedDates = new ArrayList<>();
-	private List<ReportListener> reportListeners = new ArrayList<>();
-
-	/**
-	 * Constructs a new <code>StatusReport</code> for the subject and sets the created date to the
-	 * current date.
-	 *
-	 * @param subject
-	 *            the subject of the report
-	 */
-	public StatusReport(SUBJECT subject) {
-		this.subject = subject;
-		setCreatedDate(new Date());
-	}
-
-	/**
-	 * Returns the subject of this report.
-	 *
-	 * @return the subject of this report
-	 */
-	@JsonIgnore
-	public SUBJECT getSubject() {
-		return subject;
-	}
-
-	@JsonProperty("subject")
-	public URI getSubjectURI() {
-		return new URITools().uriForBean(subject);
-	}
-
-	/**
-	 * Returns the parent report.
-	 * <p>
-	 * Returns null if this report has no parent.
-	 *
-	 * @return the parent report
-	 */
-	@JsonIgnore
-	public PARENT getParentReport() {
-		return parentReport;
-	}
-
-	/**
-	 * Sets the parent report.
-	 * <p>
-	 * Can be null if this report has no parent.
-	 *
-	 * @param workflowReport
-	 *            the parent report
-	 */
-	public void setParentReport(PARENT parentReport) {
-		this.parentReport = parentReport;
-	}
-
-	/**
-	 * Returns the current {@link State}.
-	 * <p>
-	 * A state can be CREATED, RUNNING, COMPLETED, PAUSED, CANCELLED or FAILED.
-	 *
-	 * @return the current <code>State</code>
-	 */
-	public State getState() {
-		return state;
-	}
-
-	public void setState(State state) {
-		synchronized (reportListeners) {
-			if (this.state != state) {
-				State oldState = this.state;
-				this.state = state;
-				for (ReportListener reportListener : reportListeners)
-					reportListener.stateChanged(oldState, state);
-			}
-		}
-	}
-
-	/**
-	 * Returns the date that the status was set to CREATED.
-	 *
-	 * @return the the date that the status was set to CREATED
-	 */
-	public Date getCreatedDate() {
-		return createdDate;
-	}
-
-	/**
-	 * Sets the date that the status was set to CREATED.
-	 *
-	 * @param createdDate
-	 *            the date that the status was set to CREATED
-	 */
-	public void setCreatedDate(Date createdDate) {
-		this.createdDate = createdDate;
-		setState(State.CREATED);
-	}
-
-	/**
-	 * Returns the date that the status changed to RUNNING.
-	 * <p>
-	 * If the status has never been RUNNING <code>null</code> is returned.
-	 *
-	 * @return the date that the status changed to started
-	 */
-	public Date getStartedDate() {
-		return startedDate;
-	}
-
-	/**
-	 * Sets the date that the status changed to RUNNING.
-	 *
-	 * @param startedDate
-	 *            the date that the status changed to RUNNING
-	 */
-	public void setStartedDate(Date startedDate) {
-		if (this.startedDate == null)
-			this.startedDate = startedDate;
-		setState(State.RUNNING);
-	}
-
-	/**
-	 * Returns the date that the status last changed to PAUSED.
-	 * <p>
-	 * If the status has never been PAUSED <code>null</code> is returned.
-	 *
-	 * @return the date that the status last changed to PAUSED
-	 */
-	public Date getPausedDate() {
-		return pausedDate;
-	}
-
-	/**
-	 * Sets the date that the status last changed to PAUSED.
-	 *
-	 * @param pausedDate
-	 *            the date that the status last changed to PAUSED
-	 */
-	public void setPausedDate(Date pausedDate) {
-		this.pausedDate = pausedDate;
-		pausedDates.add(pausedDate);
-		setState(State.PAUSED);
-	}
-
-	/**
-	 * Returns the date that the status last changed form PAUSED to RUNNING.
-	 * <p>
-	 * If the status has never changed form PAUSED to RUNNING <code>null</code> is returned.
-	 *
-	 * @return the date that the status last changed form PAUSED to RUNNING
-	 */
-	public Date getResumedDate() {
-		return resumedDate;
-	}
-
-	/**
-	 * Sets the date that the status last changed form PAUSED to RUNNING.
-	 *
-	 * @param resumedDate
-	 *            the date that the status last changed form PAUSED to RUNNING
-	 */
-	public void setResumedDate(Date resumedDate) {
-		this.resumedDate = resumedDate;
-		resumedDates.add(resumedDate);
-		setState(State.RUNNING);
-	}
-
-	/**
-	 * Returns the date that the status changed to CANCELLED.
-	 * <p>
-	 * If the status has never been CANCELLED <code>null</code> is returned.
-	 *
-	 * @return the date that the status changed to canceled
-	 */
-	public Date getCancelledDate() {
-		return cancelledDate;
-	}
-
-	/**
-	 * Sets the date that the status changed to CANCELLED.
-	 *
-	 * @param cancelledDate
-	 *            the date that the status changed to CANCELLED
-	 */
-	public void setCancelledDate(Date cancelledDate) {
-		this.cancelledDate = cancelledDate;
-		setState(State.CANCELLED);
-	}
-
-	/**
-	 * Returns the date that the status changed to COMPLETED.
-	 * <p>
-	 * If the status never been COMPLETED <code>null</code> is returned.
-	 *
-	 * @return the date that the status changed to COMPLETED
-	 */
-	public Date getCompletedDate() {
-		return completedDate;
-	}
-
-	/**
-	 * Sets the date that the status changed to COMPLETED.
-	 *
-	 * @param completedDate
-	 *            the date that the status changed to COMPLETED
-	 */
-	public void setCompletedDate(Date completedDate) {
-		this.completedDate = completedDate;
-		setState(State.COMPLETED);
-	}
-
-	/**
-	 * Returns the date that the status changed to FAILED. If the status has never been FAILED
-	 * <code>null</code> is returned.
-	 *
-	 * @return the date that the status changed to failed
-	 */
-	public Date getFailedDate() {
-		return failedDate;
-	}
-
-	/**
-	 * Sets the date that the status changed to FAILED.
-	 *
-	 * @param failedDate
-	 *            the date that the status changed to FAILED
-	 */
-	public void setFailedDate(Date failedDate) {
-		this.failedDate = failedDate;
-		setState(State.FAILED);
-	}
-
-	/**
-	 * Returns the dates that the status changed to PAUSED.
-	 * <p>
-	 * If the status has never been PAUSED an empty list is returned.
-	 *
-	 * @return the dates that the status was paused
-	 */
-	public List<Date> getPausedDates() {
-		return pausedDates;
-	}
-
-	/**
-	 * Returns the dates that the status changed from PAUSED to RUNNING.
-	 * <p>
-	 * If the status has never changed from PAUSED to RUNNING an empty list is returned.
-	 *
-	 * @return the dates that the status was resumed
-	 */
-	public List<Date> getResumedDates() {
-		return resumedDates;
-	}
-
-	/**
-	 * Returns the invocations.
-	 *
-	 * @return the invocations
-	 */
-	public NavigableSet<Invocation> getInvocations() {
-		synchronized (invocations) {
-			return new TreeSet<>(invocations);
-		}
-	}
-
-	public void addInvocation(Invocation invocation) {
-		synchronized (invocations) {
-			invocations.add(invocation);
-		}
-	}
-
-	/**
-	 * Informs the report that an output value has been added.
-	 * <p>
-	 * Any <code>ReportListener</code>s registered with this report will be notified that an output
-	 * value has been added.
-	 *
-	 * @param path
-	 *            the path that the value was added to
-	 * @param portName
-	 *            the port that the value belongs to
-	 * @param index
-	 *            the position of the value
-	 */
-	public void outputAdded(Path path, String portName, int[] index) {
-		synchronized (reportListeners) {
-			for (ReportListener reportListener : reportListeners)
-				reportListener.outputAdded(path, portName, index);
-		}
-	}
-
-	public void addReportListener(ReportListener reportListener) {
-		synchronized (reportListeners) {
-			reportListeners.add(reportListener);
-		}
-	}
-
-	public void removeReportListener(ReportListener reportListener) {
-		synchronized (reportListeners) {
-			reportListeners.remove(reportListener);
-		}
-	}
-
-	/**
-	 * Get an invocation with a given name.
-	 * @param invocationName
-	 * @return
-	 */
-    public Invocation getInvocation(String invocationName) {
-        NavigableSet<Invocation> invocs = getInvocations();
-        // A Comparable Invocation with the desired name
-        SortedSet<Invocation> tailSet = invocs.tailSet(new Invocation(invocationName));
-        if (!tailSet.isEmpty())
-        	return tailSet.first();
-        return null;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-report-api/src/main/java/uk/org/taverna/platform/report/WorkflowReport.java
----------------------------------------------------------------------
diff --git a/taverna-report-api/src/main/java/uk/org/taverna/platform/report/WorkflowReport.java b/taverna-report-api/src/main/java/uk/org/taverna/platform/report/WorkflowReport.java
deleted file mode 100644
index 1b0ca1c..0000000
--- a/taverna-report-api/src/main/java/uk/org/taverna/platform/report/WorkflowReport.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 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 uk.org.taverna.platform.report;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.LinkedHashSet;
-import java.util.Set;
-import java.util.logging.Logger;
-
-import org.apache.taverna.robundle.Bundle;
-import org.apache.taverna.scufl2.api.core.Workflow;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-
-/**
- * Report about the {@link State} of a {@link Workflow} run.
- *
- * @author David Withers
- */
-public class WorkflowReport extends StatusReport<Workflow, ActivityReport> {
-	@SuppressWarnings("unused")
-	private static final Logger logger = Logger.getLogger(WorkflowReport.class.getName());
-	private static final String dateFormatString = "yyyy-MM-dd HH:mm:ss";
-
-	private Set<ProcessorReport> processorReports = new LinkedHashSet<>();
-	private Bundle dataBundle;
-
-	public WorkflowReport(Workflow workflow) {
-		super(workflow);
-	}
-
-	public Set<ProcessorReport> getProcessorReports() {
-		return processorReports;
-	}
-
-	public void addProcessorReport(ProcessorReport processorReport) {
-		processorReports.add(processorReport);
-	}
-
-	@JsonIgnore
-	public Bundle getDataBundle() {
-		return dataBundle;
-	}
-
-	public void setDataBundle(Bundle dataBundle) {
-		this.dataBundle = dataBundle;
-	}
-
-	@Override
-	public String toString() {
-		DateFormat dateFormat = new SimpleDateFormat(dateFormatString);
-		StringBuilder sb = new StringBuilder();
-		int max = getLongestName(this, 0);
-		spaces(sb, max + 1);
-		sb.append("Status    ");
-		sb.append("Queued    ");
-		sb.append("Started   ");
-		sb.append("Complete  ");
-		sb.append("Errors    ");
-		sb.append("Started             ");
-		sb.append("Finished\n");
-		sb.append(getSubject().getName());
-		spaces(sb, max - getSubject().getName().length() + 1);
-		sb.append(getState());
-		spaces(sb, 10 - getState().name().length());
-		sb.append("-");
-		spaces(sb, 9);
-		sb.append("-");
-		spaces(sb, 9);
-		sb.append("-");
-		spaces(sb, 9);
-		sb.append("-");
-		spaces(sb, 9);
-		addDates(sb, getStartedDate(), getCompletedDate(), dateFormat);
-		for (ProcessorReport processorReport : getProcessorReports())
-			addProcessor(sb, max, 0, processorReport, dateFormat);
-		return sb.toString();
-	}
-
-	private void addProcessor(StringBuilder sb, int max, int level, ProcessorReport processorReport, DateFormat dateFormat) {
-		String processorName = processorReport.getSubject().getName();
-		spaces(sb, level);
-		sb.append(processorName);
-		spaces(sb, max - processorName.length() - level + 1);
-
-		State processorState = processorReport.getState();
-		sb.append(processorState);
-		spaces(sb, 10 - processorState.name().length());
-
-		String jobsQueued = String.valueOf(processorReport.getJobsQueued());
-		sb.append(jobsQueued);
-		spaces(sb, 10 - jobsQueued.length());
-
-		String jobsStarted = String.valueOf(processorReport.getJobsStarted());
-		sb.append(jobsStarted);
-		spaces(sb, 10 - jobsStarted.length());
-
-		String jobsCompleted = String.valueOf(processorReport.getJobsCompleted());
-		sb.append(jobsCompleted);
-		spaces(sb, 10 - jobsCompleted.length());
-
-		String jobsCompletedWithErrors = String.valueOf(processorReport
-				.getJobsCompletedWithErrors());
-		sb.append(jobsCompletedWithErrors);
-		spaces(sb, 10 - jobsCompletedWithErrors.length());
-
-		addDates(sb, processorReport.getStartedDate(), processorReport.getCompletedDate(), dateFormat);
-
-		for (ActivityReport activityReport : processorReport.getActivityReports()) {
-			WorkflowReport nestedWorkflowReport = activityReport.getNestedWorkflowReport();
-			if (nestedWorkflowReport != null)
-				for (ProcessorReport nestedProcessorReport : nestedWorkflowReport.getProcessorReports())
-					addProcessor(sb, max, level + 1, nestedProcessorReport, dateFormat);
-		}
-	}
-
-	private void addDates(StringBuilder sb, Date started, Date stopped, DateFormat dateFormat) {
-		if (started != null) {
-			sb.append(dateFormat.format(started));
-			sb.append(' ');
-		} else {
-			sb.append('-');
-			spaces(sb, dateFormatString.length());
-		}
-		if (stopped != null)
-			sb.append(dateFormat.format(stopped) + "\n");
-		else
-			sb.append("-\n");
-	}
-
-	private int getLongestName(WorkflowReport workflowReport, int level) {
-		int result = 0;
-		result = Math.max(result, getSubject().getName().length() + level);
-		for (ProcessorReport processorReport : workflowReport.getProcessorReports()) {
-			result = Math.max(result, processorReport.getSubject().getName().length());
-			for (ActivityReport activityReport : processorReport.getActivityReports()) {
-				WorkflowReport nestedWorkflowReport = activityReport.getNestedWorkflowReport();
-				if (nestedWorkflowReport != null)
-					result = Math.max(result, getLongestName(nestedWorkflowReport, level + 1));
-			}
-		}
-		return result;
-	}
-
-	private static void spaces(StringBuilder sb, int length) {
-		for (int i = 0; i < length; i++)
-			sb.append(' ');
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-report-api/src/test/java/org/apache/taverna/platform/report/StatusReportTest.java
----------------------------------------------------------------------
diff --git a/taverna-report-api/src/test/java/org/apache/taverna/platform/report/StatusReportTest.java b/taverna-report-api/src/test/java/org/apache/taverna/platform/report/StatusReportTest.java
new file mode 100644
index 0000000..115104e
--- /dev/null
+++ b/taverna-report-api/src/test/java/org/apache/taverna/platform/report/StatusReportTest.java
@@ -0,0 +1,244 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.report;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Date;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.taverna.scufl2.api.core.Workflow;
+
+/**
+ * Unit tests for StatusReport.
+ *
+ * @author David Withers
+ */
+public class StatusReportTest {
+
+	private StatusReport<Workflow, ?> statusReport;
+	private Workflow subject;
+
+	/**
+	 * @throws java.lang.Exception
+	 */
+	@Before
+	public void setUp() throws Exception {
+		subject = new Workflow();
+		statusReport = new StatusReport<Workflow,StatusReport<?,?>>(subject);
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#StatusReport()}.
+	 */
+	@Test
+	public void testStatusReport() {
+		Date preCreationTime = new Date();
+		statusReport = new StatusReport<Workflow,StatusReport<?,?>>(null);
+		assertFalse(statusReport.getCreatedDate().before(preCreationTime));
+		assertFalse(statusReport.getCreatedDate().after(new Date()));
+		assertEquals(State.CREATED, statusReport.getState());
+		assertTrue(statusReport.getPausedDates().isEmpty());
+		assertTrue(statusReport.getResumedDates().isEmpty());
+		assertNull(statusReport.getCancelledDate());
+		assertNull(statusReport.getCompletedDate());
+		assertNull(statusReport.getFailedDate());
+		assertNull(statusReport.getPausedDate());
+		assertNull(statusReport.getResumedDate());
+		assertNull(statusReport.getStartedDate());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getSubject()}.
+	 */
+	@Test
+	public void testGetSubject() {
+		assertNotNull(statusReport.getSubject());
+		assertEquals(subject, statusReport.getSubject());
+		assertEquals(subject, statusReport.getSubject());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getState()}.
+	 */
+	@Test
+	public void testGetState() {
+		assertEquals(State.CREATED, statusReport.getState());
+		assertEquals(State.CREATED, statusReport.getState());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getCreatedDate()}.
+	 */
+	@Test
+	public void testGetCreatedDate() {
+		assertNotNull(statusReport.getCreatedDate());
+		assertFalse(statusReport.getCreatedDate().after(new Date()));
+		assertEquals(statusReport.getCreatedDate(), statusReport.getCreatedDate());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#setCreatedDate(java.util.Date)}.
+	 */
+	@Test
+	public void testSetCreatedDate() {
+		Date now = new Date();
+		statusReport.setCreatedDate(now);
+		assertEquals(now, statusReport.getCreatedDate());
+		assertEquals(State.CREATED, statusReport.getState());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getStartedDate()}.
+	 */
+	@Test
+	public void testGetStartedDate() {
+		assertNull(statusReport.getStartedDate());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#setStartedDate(java.util.Date)}.
+	 */
+	@Test
+	public void testSetStartedDate() {
+		Date now = new Date();
+		statusReport.setStartedDate(now);
+		assertEquals(now, statusReport.getStartedDate());
+		assertEquals(State.RUNNING, statusReport.getState());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getPausedDate()}.
+	 */
+	@Test
+	public void testGetPausedDate() {
+		assertNull(statusReport.getPausedDate());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#setPausedDate(java.util.Date)}.
+	 */
+	@Test
+	public void testSetPausedDate() {
+		Date now = new Date();
+		statusReport.setPausedDate(now);
+		assertEquals(now, statusReport.getPausedDate());
+		assertEquals(State.PAUSED, statusReport.getState());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getResumedDate()}.
+	 */
+	@Test
+	public void testGetResumedDate() {
+		assertNull(statusReport.getResumedDate());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#setResumedDate(java.util.Date)}.
+	 */
+	@Test
+	public void testSetResumedDate() {
+		Date now = new Date();
+		statusReport.setResumedDate(now);
+		assertEquals(now, statusReport.getResumedDate());
+		assertEquals(State.RUNNING, statusReport.getState());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getCancelledDate()}.
+	 */
+	@Test
+	public void testGetCancelledDate() {
+		assertNull(statusReport.getCancelledDate());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#setCancelledDate(java.util.Date)}.
+	 */
+	@Test
+	public void testSetCancelledDate() {
+		Date now = new Date();
+		statusReport.setCancelledDate(now);
+		assertEquals(now, statusReport.getCancelledDate());
+		assertEquals(State.CANCELLED, statusReport.getState());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getCompletedDate()}.
+	 */
+	@Test
+	public void testGetCompletedDate() {
+		assertNull(statusReport.getCompletedDate());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#setCompletedDate(java.util.Date)}.
+	 */
+	@Test
+	public void testSetCompletedDate() {
+		Date now = new Date();
+		statusReport.setCompletedDate(now);
+		assertEquals(now, statusReport.getCompletedDate());
+		assertEquals(State.COMPLETED, statusReport.getState());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getFailedDate()}.
+	 */
+	@Test
+	public void testGetFailedDate() {
+		assertNull(statusReport.getFailedDate());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#setFailedDate(java.util.Date)}.
+	 */
+	@Test
+	public void testSetFailedDate() {
+		Date now = new Date();
+		statusReport.setFailedDate(now);
+		assertEquals(now, statusReport.getFailedDate());
+		assertEquals(State.FAILED, statusReport.getState());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getPausedDates()}.
+	 */
+	@Test
+	public void testGetPausedDates() {
+		assertTrue(statusReport.getPausedDates().isEmpty());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getResumedDates()}.
+	 */
+	@Test
+	public void testGetResumedDates() {
+		assertTrue(statusReport.getResumedDates().isEmpty());
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-report-api/src/test/java/uk/org/taverna/platform/report/StatusReportTest.java
----------------------------------------------------------------------
diff --git a/taverna-report-api/src/test/java/uk/org/taverna/platform/report/StatusReportTest.java b/taverna-report-api/src/test/java/uk/org/taverna/platform/report/StatusReportTest.java
deleted file mode 100644
index 3c39cbb..0000000
--- a/taverna-report-api/src/test/java/uk/org/taverna/platform/report/StatusReportTest.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2011 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 uk.org.taverna.platform.report;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Date;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import org.apache.taverna.scufl2.api.core.Workflow;
-
-/**
- * Unit tests for StatusReport.
- *
- * @author David Withers
- */
-public class StatusReportTest {
-
-	private StatusReport<Workflow, ?> statusReport;
-	private Workflow subject;
-
-	/**
-	 * @throws java.lang.Exception
-	 */
-	@Before
-	public void setUp() throws Exception {
-		subject = new Workflow();
-		statusReport = new StatusReport<Workflow,StatusReport<?,?>>(subject);
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#StatusReport()}.
-	 */
-	@Test
-	public void testStatusReport() {
-		Date preCreationTime = new Date();
-		statusReport = new StatusReport<Workflow,StatusReport<?,?>>(null);
-		assertFalse(statusReport.getCreatedDate().before(preCreationTime));
-		assertFalse(statusReport.getCreatedDate().after(new Date()));
-		assertEquals(State.CREATED, statusReport.getState());
-		assertTrue(statusReport.getPausedDates().isEmpty());
-		assertTrue(statusReport.getResumedDates().isEmpty());
-		assertNull(statusReport.getCancelledDate());
-		assertNull(statusReport.getCompletedDate());
-		assertNull(statusReport.getFailedDate());
-		assertNull(statusReport.getPausedDate());
-		assertNull(statusReport.getResumedDate());
-		assertNull(statusReport.getStartedDate());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getSubject()}.
-	 */
-	@Test
-	public void testGetSubject() {
-		assertNotNull(statusReport.getSubject());
-		assertEquals(subject, statusReport.getSubject());
-		assertEquals(subject, statusReport.getSubject());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getState()}.
-	 */
-	@Test
-	public void testGetState() {
-		assertEquals(State.CREATED, statusReport.getState());
-		assertEquals(State.CREATED, statusReport.getState());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getCreatedDate()}.
-	 */
-	@Test
-	public void testGetCreatedDate() {
-		assertNotNull(statusReport.getCreatedDate());
-		assertFalse(statusReport.getCreatedDate().after(new Date()));
-		assertEquals(statusReport.getCreatedDate(), statusReport.getCreatedDate());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#setCreatedDate(java.util.Date)}.
-	 */
-	@Test
-	public void testSetCreatedDate() {
-		Date now = new Date();
-		statusReport.setCreatedDate(now);
-		assertEquals(now, statusReport.getCreatedDate());
-		assertEquals(State.CREATED, statusReport.getState());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getStartedDate()}.
-	 */
-	@Test
-	public void testGetStartedDate() {
-		assertNull(statusReport.getStartedDate());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#setStartedDate(java.util.Date)}.
-	 */
-	@Test
-	public void testSetStartedDate() {
-		Date now = new Date();
-		statusReport.setStartedDate(now);
-		assertEquals(now, statusReport.getStartedDate());
-		assertEquals(State.RUNNING, statusReport.getState());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getPausedDate()}.
-	 */
-	@Test
-	public void testGetPausedDate() {
-		assertNull(statusReport.getPausedDate());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#setPausedDate(java.util.Date)}.
-	 */
-	@Test
-	public void testSetPausedDate() {
-		Date now = new Date();
-		statusReport.setPausedDate(now);
-		assertEquals(now, statusReport.getPausedDate());
-		assertEquals(State.PAUSED, statusReport.getState());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getResumedDate()}.
-	 */
-	@Test
-	public void testGetResumedDate() {
-		assertNull(statusReport.getResumedDate());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#setResumedDate(java.util.Date)}.
-	 */
-	@Test
-	public void testSetResumedDate() {
-		Date now = new Date();
-		statusReport.setResumedDate(now);
-		assertEquals(now, statusReport.getResumedDate());
-		assertEquals(State.RUNNING, statusReport.getState());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getCancelledDate()}.
-	 */
-	@Test
-	public void testGetCancelledDate() {
-		assertNull(statusReport.getCancelledDate());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#setCancelledDate(java.util.Date)}.
-	 */
-	@Test
-	public void testSetCancelledDate() {
-		Date now = new Date();
-		statusReport.setCancelledDate(now);
-		assertEquals(now, statusReport.getCancelledDate());
-		assertEquals(State.CANCELLED, statusReport.getState());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getCompletedDate()}.
-	 */
-	@Test
-	public void testGetCompletedDate() {
-		assertNull(statusReport.getCompletedDate());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#setCompletedDate(java.util.Date)}.
-	 */
-	@Test
-	public void testSetCompletedDate() {
-		Date now = new Date();
-		statusReport.setCompletedDate(now);
-		assertEquals(now, statusReport.getCompletedDate());
-		assertEquals(State.COMPLETED, statusReport.getState());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getFailedDate()}.
-	 */
-	@Test
-	public void testGetFailedDate() {
-		assertNull(statusReport.getFailedDate());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#setFailedDate(java.util.Date)}.
-	 */
-	@Test
-	public void testSetFailedDate() {
-		Date now = new Date();
-		statusReport.setFailedDate(now);
-		assertEquals(now, statusReport.getFailedDate());
-		assertEquals(State.FAILED, statusReport.getState());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getPausedDates()}.
-	 */
-	@Test
-	public void testGetPausedDates() {
-		assertTrue(statusReport.getPausedDates().isEmpty());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getResumedDates()}.
-	 */
-	@Test
-	public void testGetResumedDates() {
-		assertTrue(statusReport.getResumedDates().isEmpty());
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/InvalidRunIdException.java
----------------------------------------------------------------------
diff --git a/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/InvalidRunIdException.java b/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/InvalidRunIdException.java
new file mode 100644
index 0000000..1637616
--- /dev/null
+++ b/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/InvalidRunIdException.java
@@ -0,0 +1,45 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.run.api;
+
+/**
+ * Thrown when a runID is not valid for the RunService.
+ * 
+ * @author David Withers
+ */
+public class InvalidRunIdException extends Exception {
+	private static final long serialVersionUID = -8524012164316151704L;
+
+	public InvalidRunIdException() {
+		super();
+	}
+
+	public InvalidRunIdException(String message) {
+		super(message);
+	}
+
+	public InvalidRunIdException(String message, Throwable cause) {
+		super(message, cause);
+	}
+
+	public InvalidRunIdException(Throwable cause) {
+		super(cause);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/RunProfile.java
----------------------------------------------------------------------
diff --git a/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/RunProfile.java b/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/RunProfile.java
new file mode 100644
index 0000000..02d42ab
--- /dev/null
+++ b/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/RunProfile.java
@@ -0,0 +1,215 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.run.api;
+
+import org.apache.taverna.robundle.Bundle;
+
+import org.apache.taverna.platform.execution.api.ExecutionEnvironment;
+import org.apache.taverna.scufl2.api.container.WorkflowBundle;
+
+/**
+ * A <code>RunProfile</code> specifies the parameters required to run a
+ * {@link org.apache.taverna.scufl2.api.core.Workflow}.
+ * 
+ * @author David Withers
+ */
+public class RunProfile {
+	private ExecutionEnvironment executionEnvironment;
+	private WorkflowBundle workflowBundle;
+	private Bundle dataBundle;
+	private String workflowName;
+	private String profileName;
+
+	/**
+	 * Constructs a <code>RunProfile</code> that specifies the parameters
+	 * required to run a {@link org.apache.taverna.scufl2.api.core.Workflow}. The
+	 * main <code>Workflow</code> and <code>Profile</code> from the
+	 * <code>WorkflowBundle</code> are used.
+	 * 
+	 * @param executionEnvironment
+	 *            the {@link ExecutionEnvironment} used to execute the
+	 *            <code>Workflow</code>
+	 * @param workflowBundle
+	 *            the <code>WorkflowBundle</code> containing the
+	 *            <code>Workflow</code> to run
+	 * @param dataBundle
+	 *            the <code>Bundle</code> containing the data values for the
+	 *            <code>Workflow</code>
+	 */
+	public RunProfile(ExecutionEnvironment executionEnvironment,
+			WorkflowBundle workflowBundle, Bundle dataBundle) {
+		this(executionEnvironment, workflowBundle, null, null, dataBundle);
+	}
+
+	/**
+	 * Constructs a <code>RunProfile</code> that specifies the parameters
+	 * required to run a {@link org.apache.taverna.scufl2.api.core.Workflow}.
+	 * 
+	 * @param executionEnvironment
+	 *            the {@link ExecutionEnvironment} used to execute the
+	 *            <code>Workflow</code>
+	 * @param workflowBundle
+	 *            the <code>WorkflowBundle</code> containing the
+	 *            <code>Workflow</code> to run
+	 * @param workflow
+	 *            the <code>Workflow</code> to run. If <code>null</code> uses
+	 *            the main <code>Workflow</code> from the
+	 *            <code>WorkflowBundle</code>
+	 * @param profile
+	 *            the {@link org.apache.taverna.scufl2.api.profiles.Profile} to use
+	 *            when running the <code>Workflow</code>. If null uses the main
+	 *            <code>Profile</code> from the <code>WorkflowBundle</code>
+	 * @param dataBundle
+	 *            the <code>Bundle</code> containing the data values for the
+	 *            <code>Workflow</code>
+	 */
+	public RunProfile(ExecutionEnvironment executionEnvironment,
+			WorkflowBundle workflowBundle, String workflowName,
+			String profileName, Bundle dataBundle) {
+		this.executionEnvironment = executionEnvironment;
+		this.workflowBundle = workflowBundle;
+		this.workflowName = workflowName;
+		this.profileName = profileName;
+		this.dataBundle = dataBundle;
+	}
+
+	/**
+	 * Returns the <code>WorkflowBundle</code>.
+	 * 
+	 * @return the <code>WorkflowBundle</code>
+	 */
+	public WorkflowBundle getWorkflowBundle() {
+		return workflowBundle;
+	}
+
+	/**
+	 * Sets the <code>WorkflowBundle</code> containing the <code>Workflow</code>
+	 * to run.
+	 * 
+	 * @param workflowBundle
+	 *            the <code>WorkflowBundle</code> containing the
+	 *            <code>Workflow</code> to run
+	 */
+	public void setWorkflowBundle(WorkflowBundle workflowBundle) {
+		this.workflowBundle = workflowBundle;
+	}
+
+	/**
+	 * Returns the name of the <code>Workflow</code> to run. If no
+	 * <code>Workflow</code> name is set the main <code>Workflow</code> from the
+	 * <code>WorkflowBundle</code> will be run.
+	 * 
+	 * @return the <code>Workflow</code> to run
+	 */
+	public String getWorkflowName() {
+		if (workflowName == null && workflowBundle.getMainWorkflow() != null)
+			return workflowBundle.getMainWorkflow().getName();
+		return workflowName;
+	}
+
+	/**
+	 * Sets the name of the <code>Workflow</code> to run. If no
+	 * <code>Workflow</code> name is set the main <code>Workflow</code> from the
+	 * <code>WorkflowBundle</code> will be run.
+	 * 
+	 * @param workflowName
+	 *            the name of the <code>Workflow</code> to run
+	 */
+	public void setWorkflowName(String workflowName) {
+		this.workflowName = workflowName;
+	}
+
+	/**
+	 * Returns the name of the <code>Profile</code> to use when running the
+	 * <code>Workflow</code>. If no <code>Profile</code> name is set the main
+	 * <code>Profile</code> from the <code>WorkflowBundle</code> will be used.
+	 * 
+	 * @return the <code>Profile</code> to use when running the
+	 *         <code>Workflow</code>
+	 */
+	public String getProfileName() {
+		if (profileName == null && workflowBundle.getMainProfile() != null) {
+			return workflowBundle.getMainProfile().getName();
+		}
+		return profileName;
+	}
+
+	/**
+	 * Sets the name of the <code>Profile</code> to use when running the
+	 * <code>Workflow</code>.
+	 * <p>
+	 * If no <code>Profile</code> name is set the main <code>Profile</code> from
+	 * the <code>WorkflowBundle</code> will be used.
+	 * 
+	 * @param profileName
+	 *            the name of the <code>Profile</code> to use when running the
+	 *            <code>Workflow</code>
+	 */
+	public void setProfileName(String profileName) {
+		this.profileName = profileName;
+	}
+
+	/**
+	 * Returns the <code>Bundle</code> containing the data values for the
+	 * <code>Workflow</code>.
+	 * 
+	 * @return the <code>Bundle</code> containing the data values for the
+	 *         <code>Workflow</code>
+	 */
+	public Bundle getDataBundle() {
+		return dataBundle;
+	}
+
+	/**
+	 * Sets the <code>Bundle</code> containing the data values for the
+	 * <code>Workflow</code>.
+	 * 
+	 * @param dataBundle
+	 *            the <code>Bundle</code> containing the data values for the
+	 *            <code>Workflow</code>
+	 */
+	public void setDataBundle(Bundle dataBundle) {
+		this.dataBundle = dataBundle;
+	}
+
+	/**
+	 * Returns the <code>ExecutionEnvironment</code> used to execute the
+	 * <code>Workflow</code>.
+	 * 
+	 * @return the <code>ExecutionEnvironment</code> used to execute the
+	 *         <code>Workflow</code>
+	 */
+	public ExecutionEnvironment getExecutionEnvironment() {
+		return executionEnvironment;
+	}
+
+	/**
+	 * Sets the <code>ExecutionEnvironment</code> used to execute the
+	 * <code>Workflow</code>.
+	 * 
+	 * @param executionEnvironment
+	 *            the <code>ExecutionEnvironment</code> used to execute the
+	 *            <code>Workflow</code>
+	 */
+	public void setExecutionEnvironment(
+			ExecutionEnvironment executionEnvironment) {
+		this.executionEnvironment = executionEnvironment;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/RunProfileException.java
----------------------------------------------------------------------
diff --git a/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/RunProfileException.java b/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/RunProfileException.java
new file mode 100644
index 0000000..d932c3c
--- /dev/null
+++ b/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/RunProfileException.java
@@ -0,0 +1,46 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.run.api;
+
+/**
+ * Thrown when a <code>RunProfile</code> doesn't contain the correct components
+ * to run a workflow.
+ * 
+ * @author David Withers
+ */
+public class RunProfileException extends Exception {
+	private static final long serialVersionUID = 4717267498382223527L;
+
+	public RunProfileException() {
+		super();
+	}
+
+	public RunProfileException(String message, Throwable cause) {
+		super(message, cause);
+	}
+
+	public RunProfileException(String message) {
+		super(message);
+	}
+
+	public RunProfileException(Throwable cause) {
+		super(cause);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/RunService.java
----------------------------------------------------------------------
diff --git a/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/RunService.java b/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/RunService.java
new file mode 100644
index 0000000..ab52ab4
--- /dev/null
+++ b/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/RunService.java
@@ -0,0 +1,254 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.run.api;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.taverna.robundle.Bundle;
+
+import org.apache.taverna.platform.execution.api.ExecutionEnvironment;
+import org.apache.taverna.platform.execution.api.InvalidExecutionIdException;
+import org.apache.taverna.platform.execution.api.InvalidWorkflowException;
+import org.apache.taverna.platform.report.State;
+import org.apache.taverna.platform.report.WorkflowReport;
+import org.apache.taverna.scufl2.api.container.WorkflowBundle;
+import org.apache.taverna.scufl2.api.core.Workflow;
+import org.apache.taverna.scufl2.api.profiles.Profile;
+
+/**
+ * Service for managing runs of Taverna workflows.
+ * 
+ * @author David Withers
+ */
+public interface RunService {
+	String EVENT_TOPIC_ROOT = "uk/org/taverna/platform/run/RunService/";
+	String RUN_CREATED = EVENT_TOPIC_ROOT + "RUN_CREATED";
+	String RUN_DELETED = EVENT_TOPIC_ROOT + "RUN_DELETED";
+	String RUN_STARTED = EVENT_TOPIC_ROOT + "RUN_STARTED";
+	String RUN_STOPPED = EVENT_TOPIC_ROOT + "RUN_STOPPED";
+	String RUN_PAUSED = EVENT_TOPIC_ROOT + "RUN_PAUSED";
+	String RUN_RESUMED = EVENT_TOPIC_ROOT + "RUN_RESUMED";
+	String RUN_OPENED = EVENT_TOPIC_ROOT + "RUN_OPENED";
+	String RUN_CLOSED = EVENT_TOPIC_ROOT + "RUN_CLOSED";
+
+	/**
+	 * Returns the available <code>ExecutionEnvironment</code>s.
+	 * 
+	 * @return the available <code>ExecutionEnvironment</code>s
+	 */
+	Set<ExecutionEnvironment> getExecutionEnvironments();
+
+	/**
+	 * Returns the <code>ExecutionEnvironment</code>s that can execute the
+	 * specified <code>WorkflowBundle</code> using its default
+	 * <code>Profile</code>.
+	 * 
+	 * @param workflowBundle
+	 *            the <code>WorkflowBundle</code> to find
+	 *            <code>ExecutionEnvironment</code>s for
+	 * @return the <code>ExecutionEnvironment</code>s that can execute the
+	 *         specified <code>WorkflowBundle</code>
+	 */
+	Set<ExecutionEnvironment> getExecutionEnvironments(
+			WorkflowBundle workflowBundle);
+
+	/**
+	 * Returns the <code>ExecutionEnvironment</code>s that can execute the
+	 * specified <code>Profile</code>.
+	 * 
+	 * @param profile
+	 *            the <code>Profile</code> to find
+	 *            <code>ExecutionEnvironment</code>s for
+	 * @return the <code>ExecutionEnvironment</code>s that can execute the
+	 *         specified <code>Profile</code>
+	 */
+	Set<ExecutionEnvironment> getExecutionEnvironments(Profile profile);
+
+	/**
+	 * Creates a new run and returns the ID for the run.
+	 * 
+	 * To start the run use the {@link #start(String)} method.
+	 * 
+	 * @param runProfile
+	 *            the workflow to run
+	 * @return the run ID
+	 * @throws InvalidWorkflowException
+	 * @throws RunProfileException
+	 */
+	String createRun(RunProfile runProfile) throws InvalidWorkflowException,
+			RunProfileException;
+
+	/**
+	 * Returns the list of runs that this service is managing.
+	 * <p>
+	 * If there are no runs this method returns an empty list.
+	 * 
+	 * @return the list of runs that this service is managing
+	 */
+	List<String> getRuns();
+
+	/**
+	 * Opens a run and returns the ID for the run.
+	 * 
+	 * @param runFile
+	 *            the workflow run to open
+	 * @return the run ID
+	 * @throws InvalidWorkflowException
+	 * @throws RunProfileException
+	 */
+	String open(File runFile) throws IOException;
+
+	/**
+	 * Closes a run.
+	 * 
+	 * @param runID
+	 *            the ID of the run
+	 * @throws InvalidRunIdException
+	 *             if the run ID is not valid
+	 * @throws InvalidExecutionIdException
+	 */
+	void close(String runID) throws InvalidRunIdException,
+			InvalidExecutionIdException;
+
+	/**
+	 * Saves a run.
+	 * 
+	 * @param runID
+	 *            the ID of the run
+	 * @throws InvalidRunIdException
+	 *             if the run ID is not valid
+	 * @throws InvalidExecutionIdException
+	 */
+	void save(String runID, File runFile) throws InvalidRunIdException,
+			IOException;
+
+	/**
+	 * Deletes a run.
+	 * 
+	 * @param runID
+	 *            the ID of the run
+	 * @throws InvalidRunIdException
+	 *             if the run ID is not valid
+	 * @throws InvalidExecutionIdException
+	 */
+	void delete(String runID) throws InvalidRunIdException,
+			InvalidExecutionIdException;
+
+	/**
+	 * Starts a run.
+	 * 
+	 * @param runID
+	 *            the ID of the run
+	 * @throws InvalidRunIdException
+	 *             if the run ID is not valid
+	 * @throws RunStateException
+	 *             if the run state is not CREATED
+	 * @throws InvalidExecutionIdException
+	 */
+	void start(String runID) throws InvalidRunIdException, RunStateException,
+			InvalidExecutionIdException;
+
+	/**
+	 * Pauses a running run.
+	 * 
+	 * @param runID
+	 *            the ID of the run
+	 * @throws InvalidRunIdException
+	 *             if the run ID is not valid
+	 * @throws RunStateException
+	 *             if the run state is not RUNNING
+	 * @throws InvalidExecutionIdException
+	 */
+	void pause(String runID) throws InvalidRunIdException, RunStateException,
+			InvalidExecutionIdException;
+
+	/**
+	 * Resumes a paused run.
+	 * 
+	 * @param runID
+	 *            the ID of the run
+	 * @throws InvalidRunIdException
+	 *             if the run ID is not valid
+	 * @throws RunStateException
+	 *             if the run state is not PAUSED
+	 * @throws InvalidExecutionIdException
+	 */
+	void resume(String runID) throws InvalidRunIdException, RunStateException,
+			InvalidExecutionIdException;
+
+	/**
+	 * Cancels a running or paused run.
+	 * 
+	 * @param runID
+	 *            the ID of the run
+	 * @throws InvalidRunIdException
+	 *             if the run ID is not valid
+	 * @throws RunStateException
+	 *             if the run state is not RUNNING or PAUSED
+	 * @throws InvalidExecutionIdException
+	 */
+	void cancel(String runID) throws InvalidRunIdException, RunStateException,
+			InvalidExecutionIdException;
+
+	/**
+	 * Returns the current state of the run.
+	 * 
+	 * A run's state can be CREATED, RUNNING, COMPLETED, PAUSED, CANCELLED or
+	 * FAILED.
+	 * 
+	 * @param runID
+	 *            the ID of the run
+	 * @return the current state of the run
+	 * @throws InvalidRunIdException
+	 *             if the run ID is not valid
+	 */
+	State getState(String runID) throws InvalidRunIdException;
+
+	/**
+	 * Returns the <code>Bundle</code> containing the data values of the run.
+	 * 
+	 * @param runID
+	 *            the ID of the run
+	 * @return the <code>Databundle</code> containing the data values of the run
+	 * @throws InvalidRunIdException
+	 *             if the run ID is not valid
+	 */
+	Bundle getDataBundle(String runID) throws InvalidRunIdException;
+
+	/**
+	 * Returns the status report for the run.
+	 * 
+	 * @param runID
+	 *            the ID of the run
+	 * @return the status report for the run
+	 * @throws InvalidRunIdException
+	 *             if the run ID is not valid
+	 */
+	WorkflowReport getWorkflowReport(String runID) throws InvalidRunIdException;
+
+	Workflow getWorkflow(String runID) throws InvalidRunIdException;
+
+	Profile getProfile(String runID) throws InvalidRunIdException;
+
+	String getRunName(String runID) throws InvalidRunIdException;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/RunStateException.java
----------------------------------------------------------------------
diff --git a/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/RunStateException.java b/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/RunStateException.java
new file mode 100644
index 0000000..eb695ad
--- /dev/null
+++ b/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/RunStateException.java
@@ -0,0 +1,46 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.run.api;
+
+/**
+ * Thrown when an operation is attempted when a workflow is in the wrong state,
+ * e.g., resuming a workflow that is not paused.
+ * 
+ * @author David Withers
+ */
+public class RunStateException extends Exception {
+	private static final long serialVersionUID = 6759341273715906131L;
+
+	public RunStateException() {
+		super();
+	}
+
+	public RunStateException(String message, Throwable cause) {
+		super(message, cause);
+	}
+
+	public RunStateException(String message) {
+		super(message);
+	}
+
+	public RunStateException(Throwable cause) {
+		super(cause);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-run-api/src/main/java/uk/org/taverna/platform/run/api/InvalidRunIdException.java
----------------------------------------------------------------------
diff --git a/taverna-run-api/src/main/java/uk/org/taverna/platform/run/api/InvalidRunIdException.java b/taverna-run-api/src/main/java/uk/org/taverna/platform/run/api/InvalidRunIdException.java
deleted file mode 100644
index 2cfecb3..0000000
--- a/taverna-run-api/src/main/java/uk/org/taverna/platform/run/api/InvalidRunIdException.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 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 uk.org.taverna.platform.run.api;
-
-/**
- * Thrown when a runID is not valid for the RunService.
- * 
- * @author David Withers
- */
-public class InvalidRunIdException extends Exception {
-	private static final long serialVersionUID = -8524012164316151704L;
-
-	public InvalidRunIdException() {
-		super();
-	}
-
-	public InvalidRunIdException(String message) {
-		super(message);
-	}
-
-	public InvalidRunIdException(String message, Throwable cause) {
-		super(message, cause);
-	}
-
-	public InvalidRunIdException(Throwable cause) {
-		super(cause);
-	}
-}