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/17 12:46:55 UTC
[28/50] [abbrv] incubator-taverna-plugin-bioinformatics git commit:
taverna-biomoby-activity-ui/
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/fd2e9765/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/SimpleActionFrame.java
----------------------------------------------------------------------
diff --git a/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/SimpleActionFrame.java b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/SimpleActionFrame.java
new file mode 100644
index 0000000..a85b50b
--- /dev/null
+++ b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/SimpleActionFrame.java
@@ -0,0 +1,46 @@
+/*
+ * This file is a component of the Taverna project,
+ * and is licensed under the GNU LGPL.
+ * Copyright Edward Kawas, The BioMoby Project
+ */
+package net.sf.taverna.t2.activities.biomoby.actions;
+
+import java.awt.BorderLayout;
+import java.awt.Component;
+
+import javax.swing.JPanel;
+
+
+/**
+ * This class contains some methods that are useful in creating a consistent JPanel
+ * for displaying information or actions for biomoby services and datatypes.
+ *
+ * @author Edward Kawas
+ * @author Stuart Owen = initial port from T1 to T2
+ *
+ */
+public class SimpleActionFrame extends JPanel {
+
+ private static final long serialVersionUID = -6611234116434482238L;
+
+
+ private String name = "";
+ public SimpleActionFrame(Component c, String name) {
+ super(new BorderLayout());
+ add(c, BorderLayout.CENTER);
+
+ this.name = name;
+ }
+
+
+
+ public String getName() {
+ return name;
+ }
+
+ public void onDisplay() {
+
+ }
+
+
+ }
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/fd2e9765/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/datatypedescriptions/BiomobyDatatypeDescription.java
----------------------------------------------------------------------
diff --git a/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/datatypedescriptions/BiomobyDatatypeDescription.java b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/datatypedescriptions/BiomobyDatatypeDescription.java
new file mode 100644
index 0000000..35df9b8
--- /dev/null
+++ b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/datatypedescriptions/BiomobyDatatypeDescription.java
@@ -0,0 +1,143 @@
+package net.sf.taverna.t2.activities.biomoby.datatypedescriptions;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.swing.Icon;
+
+import net.sf.taverna.t2.activities.biomoby.BiomobyObjectActivity;
+import net.sf.taverna.t2.activities.biomoby.BiomobyObjectActivityConfigurationBean;
+import net.sf.taverna.t2.activities.biomoby.query.BiomobyObjectActivityIcon;
+import net.sf.taverna.t2.servicedescriptions.ServiceDescription;
+import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
+
+public class BiomobyDatatypeDescription extends
+ ServiceDescription<BiomobyObjectActivityConfigurationBean> {
+
+ private String authorityName;
+ private String emailContact;
+ private String datatypeName;
+ private URI lsid;
+ private String parent;
+ private String[] lineage;
+
+ private URI endpoint;
+ private URI namespace;
+
+ @Override
+ public Class<? extends Activity<BiomobyObjectActivityConfigurationBean>> getActivityClass() {
+ return BiomobyObjectActivity.class;
+ }
+
+ @Override
+ public BiomobyObjectActivityConfigurationBean getActivityConfiguration() {
+ BiomobyObjectActivityConfigurationBean bean = new BiomobyObjectActivityConfigurationBean();
+ bean.setAuthorityName(getAuthorityName());
+ bean.setServiceName(getDatatypeName());
+ bean.setMobyEndpoint(getEndpoint().toASCIIString());
+ return bean;
+ }
+
+ public String getAuthorityName() {
+ return authorityName;
+ }
+
+ public void setAuthorityName(String authorityName) {
+ this.authorityName = authorityName;
+ }
+
+ public String getEmailContact() {
+ return emailContact;
+ }
+
+ public void setEmailContact(String emailContact) {
+ this.emailContact = emailContact;
+ }
+
+ public String getDatatypeName() {
+ return datatypeName;
+ }
+
+ public void setDatatypeName(String datatypeName) {
+ this.datatypeName = datatypeName;
+ }
+
+ public URI getLsid() {
+ return lsid;
+ }
+
+ public void setLsid(URI lsid) {
+ this.lsid = lsid;
+ }
+
+ public String getParent() {
+ return parent;
+ }
+
+ public void setParent(String parent) {
+ this.parent = parent;
+ }
+
+ public URI getEndpoint() {
+ return endpoint;
+ }
+
+ public void setEndpoint(URI endpoint) {
+ this.endpoint = endpoint;
+ }
+
+ public URI getNamespace() {
+ return namespace;
+ }
+
+ public void setNamespace(URI namespace) {
+ this.namespace = namespace;
+ }
+
+ public String[] getLineage() {
+ return lineage;
+ }
+
+ public void setLineage(String[] lineage) {
+ this.lineage = lineage;
+ }
+
+ @Override
+ public String getName() {
+ return getDatatypeName();
+ }
+
+ @Override
+ protected List<Object> getIdentifyingData() {
+ return Arrays.<Object> asList(getNamespace(), getEndpoint(), getAuthorityName(),
+ getDatatypeName());
+ }
+
+ @Override
+ public List<String> getPath() {
+ ArrayList<String> list = new ArrayList<String>();
+ list.add("Biomoby @ " + getEndpoint());
+ list.add("MOBY Objects");
+ list.addAll(Arrays.asList(getLineage()));
+ return list;
+ }
+
+ @Override
+ public Icon getIcon() {
+ return new BiomobyObjectActivityIcon().getIcon(new BiomobyObjectActivity());
+ }
+
+ @Override
+ public String toString() {
+ return getName();
+ }
+
+ // public Edit getInsertionEdit(Dataflow dataflow, Processor p, Activity a) {
+ // if (a instanceof BiomobyObjectActivity) {
+ // return new AddUpstreamObjectEdit(dataflow, p, (BiomobyObjectActivity) a);
+ // }
+ // return null;
+ // }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/fd2e9765/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/edits/AddBiomobyCollectionDataTypeEdit.java
----------------------------------------------------------------------
diff --git a/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/edits/AddBiomobyCollectionDataTypeEdit.java b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/edits/AddBiomobyCollectionDataTypeEdit.java
new file mode 100644
index 0000000..8e02195
--- /dev/null
+++ b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/edits/AddBiomobyCollectionDataTypeEdit.java
@@ -0,0 +1,60 @@
+/**
+ * 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
+ * USA.
+ *
+ */
+package net.sf.taverna.t2.activities.biomoby.edits;
+
+import net.sf.taverna.t2.activities.biomoby.BiomobyActivity;
+import net.sf.taverna.t2.workflowmodel.Dataflow;
+import net.sf.taverna.t2.workflowmodel.Edits;
+
+/**
+ * @author Stuart Owen
+ *
+ */
+public class AddBiomobyCollectionDataTypeEdit extends
+ AddBiomobyDataTypeEdit {
+
+ private final String theCollectionName;
+
+ /**
+ * @param dataflow
+ * @param activity
+ * @param objectName
+ */
+ public AddBiomobyCollectionDataTypeEdit(Dataflow dataflow,
+ BiomobyActivity activity, String objectName, String theCollectionName, Edits edits) {
+ super(dataflow, activity, objectName, edits);
+ this.theCollectionName = theCollectionName;
+ }
+
+ @Override
+ protected String determineInputPortName(String defaultName,String objectName) {
+ return defaultName
+ + "(Collection - '"
+ + (theCollectionName.equals("") ? "MobyCollection"
+ : theCollectionName)
+ + "')";
+ }
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/fd2e9765/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/edits/AddBiomobyConsumingServiceEdit.java
----------------------------------------------------------------------
diff --git a/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/edits/AddBiomobyConsumingServiceEdit.java b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/edits/AddBiomobyConsumingServiceEdit.java
new file mode 100644
index 0000000..e13c208
--- /dev/null
+++ b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/edits/AddBiomobyConsumingServiceEdit.java
@@ -0,0 +1,236 @@
+/**
+ * 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
+ * USA.
+ *
+ */
+package net.sf.taverna.t2.activities.biomoby.edits;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.biomoby.registry.meta.Registry;
+import org.biomoby.shared.MobyDataType;
+
+import net.sf.taverna.t2.activities.biomoby.BiomobyActivity;
+import net.sf.taverna.t2.activities.biomoby.BiomobyActivityConfigurationBean;
+import net.sf.taverna.t2.activities.biomoby.BiomobyObjectActivity;
+import net.sf.taverna.t2.workflowmodel.CompoundEdit;
+import net.sf.taverna.t2.workflowmodel.Dataflow;
+import net.sf.taverna.t2.workflowmodel.Edit;
+import net.sf.taverna.t2.workflowmodel.EditException;
+import net.sf.taverna.t2.workflowmodel.Edits;
+import net.sf.taverna.t2.workflowmodel.EventForwardingOutputPort;
+import net.sf.taverna.t2.workflowmodel.EventHandlingInputPort;
+import net.sf.taverna.t2.workflowmodel.InputPort;
+import net.sf.taverna.t2.workflowmodel.OutputPort;
+import net.sf.taverna.t2.workflowmodel.ProcessorInputPort;
+import net.sf.taverna.t2.workflowmodel.ProcessorOutputPort;
+import net.sf.taverna.t2.workflowmodel.impl.AbstractDataflowEdit;
+import net.sf.taverna.t2.workflowmodel.impl.DataflowImpl;
+import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
+import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityInputPort;
+import net.sf.taverna.t2.workflowmodel.utils.Tools;
+
+/**
+ * @author Stuart Owen
+ *
+ */
+public class AddBiomobyConsumingServiceEdit extends AbstractDataflowEdit {
+
+ private final BiomobyObjectActivity activity;
+ private final String serviceName;
+ private Edits edits;
+ Edit<?> compoundEdit = null;
+ Edit<?> linkEdit = null;
+ private final String authority;
+ private final OutputPort outputPort;
+
+ /**
+ * @param dataflow
+ */
+ public AddBiomobyConsumingServiceEdit(Dataflow dataflow,
+ BiomobyObjectActivity activity, String serviceName,String authority,OutputPort outputPort, Edits edits) {
+ super(dataflow);
+
+ this.activity = activity;
+ this.serviceName = serviceName;
+ this.authority = authority;
+ this.outputPort = outputPort;
+ this.edits = edits;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * net.sf.taverna.t2.workflowmodel.impl.AbstractEdit#doEditAction(java.lang
+ * .Object)
+ */
+ @Override
+ protected void doEditAction(DataflowImpl dataflow) throws EditException {
+ String defaultName = serviceName;
+ String name = Tools
+ .uniqueProcessorName(defaultName, dataflow);
+
+ List<Edit<?>> editList = new ArrayList<Edit<?>>();
+
+ net.sf.taverna.t2.workflowmodel.Processor sinkProcessor = edits
+ .createProcessor(name);
+
+ BiomobyActivityConfigurationBean bean = new BiomobyActivityConfigurationBean();
+ bean.setAuthorityName(authority);
+ bean.setServiceName(serviceName);
+ bean.setMobyEndpoint(activity.getConfiguration().getMobyEndpoint());
+ BiomobyActivity boActivity = new BiomobyActivity();
+ editList.add(edits.getConfigureActivityEdit(boActivity, bean));
+
+ editList.add(edits.getDefaultDispatchStackEdit(sinkProcessor));
+
+ Edit<?> addActivityToProcessorEdit = edits.getAddActivityEdit(
+ sinkProcessor, boActivity);
+ editList.add(addActivityToProcessorEdit);
+
+ editList.add(edits.getAddProcessorEdit(dataflow, sinkProcessor));
+
+ compoundEdit = new CompoundEdit(editList);
+ compoundEdit.doEdit();
+
+ net.sf.taverna.t2.workflowmodel.Processor sourceProcessor = Tools.getProcessorsWithActivityOutputPort(dataflow, outputPort).iterator().next();
+
+ List<Edit<?>> linkEditList = new ArrayList<Edit<?>>();
+
+ EventForwardingOutputPort sourcePort = null;
+ //FIXME: there is an assumption here that the processor will contain only 1 activity.
+ if (outputPort != null) {
+ sourcePort = getSourcePort(sourceProcessor, sourceProcessor.getActivityList().get(0), outputPort.getName(), linkEditList);
+ }
+ else {
+ sourcePort = getSourcePort(sourceProcessor, sourceProcessor.getActivityList().get(0), sourceProcessor.getOutputPorts().get(0).getName(), linkEditList);
+ }
+ // get the input port that isnt called 'input'
+ String inputPortName = "";
+ for (ActivityInputPort aip : sinkProcessor.getActivityList().get(0).getInputPorts()) {
+ if (!aip.getName().equalsIgnoreCase("input")) {
+ // try to match the datatype to an input port
+ String dtName = activity.getMobyObject().getName();
+ String sinkDtname = aip.getName();
+ if (sinkDtname.indexOf("(") > 0)
+ sinkDtname = sinkDtname.substring(0, sinkDtname.indexOf("("));
+ // are the datatype names exactly the same?
+ if (dtName.equals(sinkDtname)) {
+ inputPortName = aip.getName();
+ break;
+ }
+ // check for the name in the datatypes lineage
+ MobyDataType sinkDt = MobyDataType.getDataType(dtName,
+ new Registry(
+ activity.getCentral().getRegistryEndpoint(),
+ activity.getCentral().getRegistryEndpoint(),
+ activity.getCentral().getRegistryNamespace())
+ );
+ // check the lineage of the sinkdt for dtname
+ for (MobyDataType lineage : sinkDt.getLineage()) {
+ if (lineage.getName().equals(sinkDtname)) {
+ inputPortName = aip.getName();
+ break;
+ }
+ }
+ // are we done?
+ if (!inputPortName.trim().equals(""))
+ break;
+ }
+ }
+ // if inputPortName is not set, then just pick the first one
+ if (inputPortName.trim().equals("")) {
+ inputPortName = sinkProcessor.getActivityList().get(0).getInputPorts().iterator().next().getName();
+ }
+ EventHandlingInputPort sinkPort = getSinkPort(sinkProcessor, boActivity, inputPortName, linkEditList);
+ if (sinkPort==null) {
+ throw new EditException("No valid input called '"+inputPortName+"' found for Biomoby consuming service");
+ }
+ linkEditList.add(Tools
+ .getCreateAndConnectDatalinkEdit(
+ dataflow,
+ sourcePort, sinkPort, edits));
+ linkEdit = new CompoundEdit(linkEditList);
+ linkEdit.doEdit();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * net.sf.taverna.t2.workflowmodel.impl.AbstractEdit#undoEditAction(java
+ * .lang.Object)
+ */
+ @Override
+ protected void undoEditAction(DataflowImpl subjectImpl) {
+ if (linkEdit!=null && linkEdit.isApplied())
+ linkEdit.undo();
+ if (compoundEdit!=null && compoundEdit.isApplied())
+ compoundEdit.undo();
+ }
+
+ private EventHandlingInputPort getSinkPort(
+ net.sf.taverna.t2.workflowmodel.Processor processor,
+ Activity<?> activity, String portName, List<Edit<?>> editList) {
+ InputPort activityPort = net.sf.taverna.t2.workflowmodel.utils.Tools
+ .getActivityInputPort(activity, portName);
+ // check if processor port exists
+ EventHandlingInputPort input = net.sf.taverna.t2.workflowmodel.utils.Tools
+ .getProcessorInputPort(processor, activity, activityPort);
+ if (input == null) {
+ // port doesn't exist so create a processor port and map it
+ ProcessorInputPort processorInputPort = edits
+ .createProcessorInputPort(processor,
+ activityPort.getName(), activityPort.getDepth());
+ editList.add(edits.getAddProcessorInputPortEdit(processor,
+ processorInputPort));
+ editList.add(edits.getAddActivityInputPortMappingEdit(activity,
+ activityPort.getName(), activityPort.getName()));
+ input = processorInputPort;
+ }
+ return input;
+ }
+
+ private EventForwardingOutputPort getSourcePort(
+ net.sf.taverna.t2.workflowmodel.Processor processor,
+ Activity<?> activity, String portName, List<Edit<?>> editList) {
+ OutputPort activityPort = net.sf.taverna.t2.workflowmodel.utils.Tools
+ .getActivityOutputPort(activity, portName);
+ // check if processor port exists
+ EventForwardingOutputPort output = net.sf.taverna.t2.workflowmodel.utils.Tools
+ .getProcessorOutputPort(processor, activity, activityPort);
+ if (output == null) {
+ // port doesn't exist so create a processor port and map it
+ ProcessorOutputPort processorOutputPort = edits
+ .createProcessorOutputPort(processor, activityPort
+ .getName(), activityPort.getDepth(), activityPort
+ .getGranularDepth());
+ editList.add(edits.getAddProcessorOutputPortEdit(processor,
+ processorOutputPort));
+ editList.add(edits.getAddActivityOutputPortMappingEdit(activity,
+ activityPort.getName(), activityPort.getName()));
+ output = processorOutputPort;
+ }
+ return output;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/fd2e9765/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/edits/AddBiomobyDataTypeEdit.java
----------------------------------------------------------------------
diff --git a/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/edits/AddBiomobyDataTypeEdit.java b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/edits/AddBiomobyDataTypeEdit.java
new file mode 100644
index 0000000..e13c264
--- /dev/null
+++ b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/edits/AddBiomobyDataTypeEdit.java
@@ -0,0 +1,207 @@
+/*******************************************************************************
+ * This file is a component of the Taverna project, and is licensed under the
+ * GNU LGPL. Copyright Edward Kawas, The BioMoby Project
+ ******************************************************************************/
+package net.sf.taverna.t2.activities.biomoby.edits;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sf.taverna.t2.activities.biomoby.BiomobyActivity;
+import net.sf.taverna.t2.activities.biomoby.BiomobyObjectActivity;
+import net.sf.taverna.t2.activities.biomoby.BiomobyObjectActivityConfigurationBean;
+import net.sf.taverna.t2.workflowmodel.CompoundEdit;
+import net.sf.taverna.t2.workflowmodel.Dataflow;
+import net.sf.taverna.t2.workflowmodel.Edit;
+import net.sf.taverna.t2.workflowmodel.EditException;
+import net.sf.taverna.t2.workflowmodel.Edits;
+import net.sf.taverna.t2.workflowmodel.EventForwardingOutputPort;
+import net.sf.taverna.t2.workflowmodel.EventHandlingInputPort;
+import net.sf.taverna.t2.workflowmodel.InputPort;
+import net.sf.taverna.t2.workflowmodel.OutputPort;
+import net.sf.taverna.t2.workflowmodel.ProcessorInputPort;
+import net.sf.taverna.t2.workflowmodel.ProcessorOutputPort;
+import net.sf.taverna.t2.workflowmodel.impl.AbstractDataflowEdit;
+import net.sf.taverna.t2.workflowmodel.impl.DataflowImpl;
+import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
+import net.sf.taverna.t2.workflowmodel.utils.Tools;
+
+/**
+ * @author Stuart Owen
+ *
+ */
+public class AddBiomobyDataTypeEdit extends AbstractDataflowEdit {
+
+ private final BiomobyActivity activity;
+ private Edits edits;
+ private final String objectName;
+
+ private Edit<?> compoundEdit = null;
+ private Edit<?> linkEdit = null;
+ private Edit<?> upstreamObjectEdit = null;
+
+
+ public AddBiomobyDataTypeEdit(Dataflow dataflow,BiomobyActivity activity,String objectName, Edits edits) {
+ super(dataflow);
+ this.activity = activity;
+ this.objectName = objectName;
+ this.edits = edits;
+
+ }
+
+
+
+
+
+ /* (non-Javadoc)
+ * @see net.sf.taverna.t2.workflowmodel.impl.AbstractDataflowEdit#doEditAction(net.sf.taverna.t2.workflowmodel.impl.DataflowImpl)
+ */
+ @Override
+ protected void doEditAction(DataflowImpl dataflow) throws EditException {
+ List<Edit<?>> editList = new ArrayList<Edit<?>>();
+
+
+ String defaultName = objectName;
+ defaultName = defaultName.split("\\(")[0];
+ String name = Tools.uniqueProcessorName(objectName, dataflow);
+
+ BiomobyObjectActivityConfigurationBean configBean = new BiomobyObjectActivityConfigurationBean();
+ configBean.setMobyEndpoint(activity
+ .getConfiguration()
+ .getMobyEndpoint());
+ configBean.setAuthorityName("");
+ configBean.setServiceName(defaultName);
+
+
+ net.sf.taverna.t2.workflowmodel.Processor sourceProcessor = edits
+ .createProcessor(name);
+ BiomobyObjectActivity boActivity = new BiomobyObjectActivity();
+ Edit<?> configureActivityEdit = edits
+ .getConfigureActivityEdit(
+ boActivity, configBean);
+ editList.add(configureActivityEdit);
+
+ editList
+ .add(edits
+ .getDefaultDispatchStackEdit(sourceProcessor));
+
+ Edit<?> addActivityToProcessorEdit = edits
+ .getAddActivityEdit(
+ sourceProcessor,
+ boActivity);
+ editList
+ .add(addActivityToProcessorEdit);
+
+ String inputPortName = determineInputPortName(defaultName,objectName);
+
+ editList.add(edits.getAddProcessorEdit(
+ dataflow,
+ sourceProcessor));
+
+ compoundEdit = new CompoundEdit(
+ editList);
+ compoundEdit.doEdit();
+
+ net.sf.taverna.t2.workflowmodel.Processor sinkProcessor = Tools
+ .getProcessorsWithActivity(
+ dataflow,
+ activity).iterator()
+ .next();
+
+ List<Edit<?>> linkEditList = new ArrayList<Edit<?>>();
+ EventHandlingInputPort sinkPort = getSinkPort(
+ sinkProcessor, activity,
+ inputPortName, linkEditList);
+ EventForwardingOutputPort sourcePort = getSourcePort(
+ sourceProcessor, boActivity,
+ "mobyData", linkEditList);
+
+ linkEditList.add(Tools
+ .getCreateAndConnectDatalinkEdit(
+ dataflow,
+ sourcePort, sinkPort, edits));
+ linkEdit = new CompoundEdit(linkEditList);
+ linkEdit.doEdit();
+
+ if (!(defaultName.equalsIgnoreCase("Object")
+ || defaultName.equalsIgnoreCase("String")
+ || defaultName.equalsIgnoreCase("Integer")
+ || defaultName.equalsIgnoreCase("Float")
+ || defaultName.equalsIgnoreCase("DateTime"))) {
+ upstreamObjectEdit=new AddUpstreamObjectEdit(dataflow,sourceProcessor,boActivity, edits);
+ upstreamObjectEdit.doEdit();
+
+ }
+ }
+
+ protected String determineInputPortName(String defaultName,String objectName) {
+ String inputPortName = objectName
+ .replaceAll("'", "");
+ if (inputPortName.indexOf("()") > 0)
+ inputPortName = inputPortName
+ .replaceAll("\\(\\)",
+ "\\(_ANON_\\)");
+ return inputPortName;
+ }
+
+ /* (non-Javadoc)
+ * @see net.sf.taverna.t2.workflowmodel.impl.AbstractDataflowEdit#undoEditAction(net.sf.taverna.t2.workflowmodel.impl.DataflowImpl)
+ */
+ @Override
+ protected void undoEditAction(DataflowImpl dataflow) {
+ if (linkEdit!=null && linkEdit.isApplied())
+ linkEdit.undo();
+ if (compoundEdit!=null && compoundEdit.isApplied())
+ compoundEdit.undo();
+ if (upstreamObjectEdit!=null && upstreamObjectEdit.isApplied()) {
+ upstreamObjectEdit.undo();
+ }
+
+ }
+
+ private EventHandlingInputPort getSinkPort(
+ net.sf.taverna.t2.workflowmodel.Processor processor,
+ Activity<?> activity, String portName, List<Edit<?>> editList) {
+ InputPort activityPort = net.sf.taverna.t2.workflowmodel.utils.Tools
+ .getActivityInputPort(activity, portName);
+ // check if processor port exists
+ EventHandlingInputPort input = net.sf.taverna.t2.workflowmodel.utils.Tools
+ .getProcessorInputPort(processor, activity, activityPort);
+ if (input == null) {
+ // port doesn't exist so create a processor port and map it
+ ProcessorInputPort processorInputPort = edits
+ .createProcessorInputPort(processor,
+ activityPort.getName(), activityPort.getDepth());
+ editList.add(edits.getAddProcessorInputPortEdit(processor,
+ processorInputPort));
+ editList.add(edits.getAddActivityInputPortMappingEdit(activity,
+ activityPort.getName(), activityPort.getName()));
+ input = processorInputPort;
+ }
+ return input;
+ }
+
+ private EventForwardingOutputPort getSourcePort(
+ net.sf.taverna.t2.workflowmodel.Processor processor,
+ Activity<?> activity, String portName, List<Edit<?>> editList) {
+ OutputPort activityPort = net.sf.taverna.t2.workflowmodel.utils.Tools
+ .getActivityOutputPort(activity, portName);
+ // check if processor port exists
+ EventForwardingOutputPort output = net.sf.taverna.t2.workflowmodel.utils.Tools
+ .getProcessorOutputPort(processor, activity, activityPort);
+ if (output == null) {
+ // port doesn't exist so create a processor port and map it
+ ProcessorOutputPort processorOutputPort = edits
+ .createProcessorOutputPort(processor, activityPort
+ .getName(), activityPort.getDepth(), activityPort
+ .getGranularDepth());
+ editList.add(edits.getAddProcessorOutputPortEdit(processor,
+ processorOutputPort));
+ editList.add(edits.getAddActivityOutputPortMappingEdit(activity,
+ activityPort.getName(), activityPort.getName()));
+ output = processorOutputPort;
+ }
+ return output;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/fd2e9765/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/edits/AddMobyParseDatatypeEdit.java
----------------------------------------------------------------------
diff --git a/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/edits/AddMobyParseDatatypeEdit.java b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/edits/AddMobyParseDatatypeEdit.java
new file mode 100644
index 0000000..43bc61f
--- /dev/null
+++ b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/edits/AddMobyParseDatatypeEdit.java
@@ -0,0 +1,220 @@
+/**
+ * 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
+ * USA.
+ *
+ */
+package net.sf.taverna.t2.activities.biomoby.edits;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sf.taverna.t2.activities.biomoby.BiomobyActivity;
+import net.sf.taverna.t2.activities.biomoby.MobyParseDatatypeActivity;
+import net.sf.taverna.t2.activities.biomoby.MobyParseDatatypeActivityConfigurationBean;
+import net.sf.taverna.t2.workflowmodel.CompoundEdit;
+import net.sf.taverna.t2.workflowmodel.Dataflow;
+import net.sf.taverna.t2.workflowmodel.Edit;
+import net.sf.taverna.t2.workflowmodel.EditException;
+import net.sf.taverna.t2.workflowmodel.Edits;
+import net.sf.taverna.t2.workflowmodel.EventForwardingOutputPort;
+import net.sf.taverna.t2.workflowmodel.EventHandlingInputPort;
+import net.sf.taverna.t2.workflowmodel.InputPort;
+import net.sf.taverna.t2.workflowmodel.OutputPort;
+import net.sf.taverna.t2.workflowmodel.Processor;
+import net.sf.taverna.t2.workflowmodel.ProcessorInputPort;
+import net.sf.taverna.t2.workflowmodel.ProcessorOutputPort;
+import net.sf.taverna.t2.workflowmodel.impl.AbstractDataflowEdit;
+import net.sf.taverna.t2.workflowmodel.impl.DataflowImpl;
+import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
+import net.sf.taverna.t2.workflowmodel.utils.Tools;
+
+/**
+ * @author Stuart Owen
+ *
+ */
+public class AddMobyParseDatatypeEdit extends AbstractDataflowEdit {
+
+ private final BiomobyActivity activity;
+ private final String objectName;
+ private final boolean isCollection;
+ private final String potentialCollectionString;
+
+ private Edit<?> compoundEdit = null;
+ private Edit<?> linkEdit = null;
+
+ private Edits edits;
+
+ /**
+ * @param dataflow
+ */
+ public AddMobyParseDatatypeEdit(Dataflow dataflow,
+ BiomobyActivity activity, String objectName, boolean isCollection,
+ String potentialCollectionString, Edits edits) {
+ super(dataflow);
+ this.activity = activity;
+ this.objectName = objectName;
+ this.isCollection = isCollection;
+ this.potentialCollectionString = potentialCollectionString;
+ this.edits = edits;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * net.sf.taverna.t2.workflowmodel.impl.AbstractEdit#doEditAction(java.lang
+ * .Object)
+ */
+ @Override
+ protected void doEditAction(DataflowImpl dataflow) throws EditException {
+
+ List<Edit<?>> editList = new ArrayList<Edit<?>>();
+
+ String defaultName = objectName;
+ if (defaultName.indexOf("(") > 0)
+ defaultName = defaultName.substring(0, defaultName.indexOf("("));
+
+ String name = Tools
+ .uniqueProcessorName("Parse Moby Data(" + defaultName + ")",
+ dataflow);
+
+ String articlename = "";
+ if (isCollection) {
+ articlename = potentialCollectionString.substring(
+ potentialCollectionString.indexOf("('") + 2,
+ potentialCollectionString.lastIndexOf("'"));
+ } else {
+ articlename = objectName.substring(objectName.indexOf("'") + 1,
+ objectName.lastIndexOf("'"));
+ }
+
+ MobyParseDatatypeActivityConfigurationBean bean = new MobyParseDatatypeActivityConfigurationBean();
+ bean.setArticleNameUsedByService(articlename);
+ bean.setRegistryEndpoint(activity.getConfiguration().getMobyEndpoint());
+ bean.setDatatypeName(defaultName);
+ MobyParseDatatypeActivity mobyDatatypeActivity = new MobyParseDatatypeActivity();
+
+ editList
+ .add(edits.getConfigureActivityEdit(mobyDatatypeActivity, bean));
+
+ net.sf.taverna.t2.workflowmodel.Processor sinkProcessor = edits
+ .createProcessor(name);
+
+ editList.add(edits.getDefaultDispatchStackEdit(sinkProcessor));
+
+ Edit<?> addActivityToProcessorEdit = edits.getAddActivityEdit(
+ sinkProcessor, mobyDatatypeActivity);
+ editList.add(addActivityToProcessorEdit);
+
+ editList.add(edits.getAddProcessorEdit(dataflow, sinkProcessor));
+
+ compoundEdit = new CompoundEdit(editList);
+ compoundEdit.doEdit();
+
+ Processor sourceProcessor = Tools.getProcessorsWithActivity(dataflow,
+ activity).iterator().next();
+
+ List<Edit<?>> linkEditList = new ArrayList<Edit<?>>();
+
+ String inputName = mobyDatatypeActivity.getInputPorts().iterator()
+ .next().getName();
+ EventHandlingInputPort sinkPort = getSinkPort(sinkProcessor,
+ mobyDatatypeActivity, inputName, linkEditList);
+
+
+ String outputPortName;
+ if (isCollection) {
+ outputPortName = defaultName + "(Collection - '"
+ + (articlename.equals("") ? "MobyCollection" : articlename)
+ + "' As Simples)";
+ }
+ else {
+ outputPortName = defaultName +"(" + articlename + ")";
+ }
+ EventForwardingOutputPort sourcePort = getSourcePort(sourceProcessor,
+ activity, outputPortName, linkEditList);
+ linkEditList.add(Tools.getCreateAndConnectDatalinkEdit(dataflow,
+ sourcePort, sinkPort, edits));
+ linkEdit = new CompoundEdit(linkEditList);
+ linkEdit.doEdit();
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * net.sf.taverna.t2.workflowmodel.impl.AbstractEdit#undoEditAction(java
+ * .lang.Object)
+ */
+ @Override
+ protected void undoEditAction(DataflowImpl subjectImpl) {
+ if (linkEdit != null && linkEdit.isApplied())
+ linkEdit.undo();
+ if (compoundEdit != null && compoundEdit.isApplied())
+ compoundEdit.undo();
+ }
+
+ private EventHandlingInputPort getSinkPort(
+ net.sf.taverna.t2.workflowmodel.Processor processor,
+ Activity<?> activity, String portName, List<Edit<?>> editList) {
+ InputPort activityPort = net.sf.taverna.t2.workflowmodel.utils.Tools
+ .getActivityInputPort(activity, portName);
+ // check if processor port exists
+ EventHandlingInputPort input = net.sf.taverna.t2.workflowmodel.utils.Tools
+ .getProcessorInputPort(processor, activity, activityPort);
+ if (input == null) {
+ // port doesn't exist so create a processor port and map it
+ ProcessorInputPort processorInputPort = edits
+ .createProcessorInputPort(processor,
+ activityPort.getName(), activityPort.getDepth());
+ editList.add(edits.getAddProcessorInputPortEdit(processor,
+ processorInputPort));
+ editList.add(edits.getAddActivityInputPortMappingEdit(activity,
+ activityPort.getName(), activityPort.getName()));
+ input = processorInputPort;
+ }
+ return input;
+ }
+
+ private EventForwardingOutputPort getSourcePort(
+ net.sf.taverna.t2.workflowmodel.Processor processor,
+ Activity<?> activity, String portName, List<Edit<?>> editList) {
+ OutputPort activityPort = net.sf.taverna.t2.workflowmodel.utils.Tools
+ .getActivityOutputPort(activity, portName);
+ // check if processor port exists
+ EventForwardingOutputPort output = net.sf.taverna.t2.workflowmodel.utils.Tools
+ .getProcessorOutputPort(processor, activity, activityPort);
+ if (output == null) {
+ // port doesn't exist so create a processor port and map it
+ ProcessorOutputPort processorOutputPort = edits
+ .createProcessorOutputPort(processor, activityPort
+ .getName(), activityPort.getDepth(), activityPort
+ .getGranularDepth());
+ editList.add(edits.getAddProcessorOutputPortEdit(processor,
+ processorOutputPort));
+ editList.add(edits.getAddActivityOutputPortMappingEdit(activity,
+ activityPort.getName(), activityPort.getName()));
+ output = processorOutputPort;
+ }
+ return output;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/fd2e9765/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/edits/AddUpstreamObjectEdit.java
----------------------------------------------------------------------
diff --git a/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/edits/AddUpstreamObjectEdit.java b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/edits/AddUpstreamObjectEdit.java
new file mode 100644
index 0000000..fea1860
--- /dev/null
+++ b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/edits/AddUpstreamObjectEdit.java
@@ -0,0 +1,216 @@
+/**
+ * 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
+ * USA.
+ *
+ */
+package net.sf.taverna.t2.activities.biomoby.edits;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sf.taverna.t2.activities.biomoby.BiomobyObjectActivity;
+import net.sf.taverna.t2.activities.biomoby.BiomobyObjectActivityConfigurationBean;
+import net.sf.taverna.t2.workflowmodel.CompoundEdit;
+import net.sf.taverna.t2.workflowmodel.Dataflow;
+import net.sf.taverna.t2.workflowmodel.Edit;
+import net.sf.taverna.t2.workflowmodel.EditException;
+import net.sf.taverna.t2.workflowmodel.Edits;
+import net.sf.taverna.t2.workflowmodel.EventForwardingOutputPort;
+import net.sf.taverna.t2.workflowmodel.EventHandlingInputPort;
+import net.sf.taverna.t2.workflowmodel.InputPort;
+import net.sf.taverna.t2.workflowmodel.OutputPort;
+import net.sf.taverna.t2.workflowmodel.Processor;
+import net.sf.taverna.t2.workflowmodel.ProcessorInputPort;
+import net.sf.taverna.t2.workflowmodel.ProcessorOutputPort;
+import net.sf.taverna.t2.workflowmodel.impl.AbstractDataflowEdit;
+import net.sf.taverna.t2.workflowmodel.impl.DataflowImpl;
+import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
+import net.sf.taverna.t2.workflowmodel.utils.Tools;
+
+import org.apache.log4j.Logger;
+
+/**
+ * @author Stuart Owen
+ *
+ */
+public class AddUpstreamObjectEdit extends AbstractDataflowEdit {
+
+ private static Logger logger = Logger.getLogger(AddUpstreamObjectEdit.class);
+
+ private final Processor sinkProcessor;
+ private final BiomobyObjectActivity activity;
+ private Edits edits;
+
+ private List<Edit<?>> subEdits = new ArrayList<Edit<?>>();
+
+ /**
+ * @param dataflow
+ */
+ public AddUpstreamObjectEdit(Dataflow dataflow, Processor sinkProcessor,
+ BiomobyObjectActivity activity, Edits edits) {
+ super(dataflow);
+ this.sinkProcessor = sinkProcessor;
+ this.activity = activity;
+ this.edits = edits;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * net.sf.taverna.t2.workflowmodel.impl.AbstractDataflowEdit#doEditAction
+ * (net.sf.taverna.t2.workflowmodel.impl.DataflowImpl)
+ */
+ @Override
+ protected void doEditAction(DataflowImpl dataflow) throws EditException {
+ subEdits.clear();
+
+ for (InputPort inputPort : activity.getInputPorts()) {
+ // ignore article name, id, namespace, value
+ if (inputPort.getName().equals("namespace")
+ || inputPort.getName().equals("id")
+ || inputPort.getName().equals("article name")
+ || inputPort.getName().equals("value")) {
+ continue;
+ }
+ List<Edit<?>> editList = new ArrayList<Edit<?>>();
+ String defaultName = inputPort.getName().split("\\(")[0];
+
+ String name = Tools
+ .uniqueProcessorName(inputPort.getName(), dataflow);
+
+ BiomobyObjectActivityConfigurationBean configBean = new BiomobyObjectActivityConfigurationBean();
+ configBean.setMobyEndpoint(activity.getConfiguration()
+ .getMobyEndpoint());
+ configBean.setAuthorityName("");
+ configBean.setServiceName(defaultName);
+
+ net.sf.taverna.t2.workflowmodel.Processor sourceProcessor = edits
+ .createProcessor(name);
+ BiomobyObjectActivity boActivity = new BiomobyObjectActivity();
+ Edit<?> configureActivityEdit = edits.getConfigureActivityEdit(
+ boActivity, configBean);
+ editList.add(configureActivityEdit);
+
+ editList.add(edits.getDefaultDispatchStackEdit(sourceProcessor));
+
+ Edit<?> addActivityToProcessorEdit = edits.getAddActivityEdit(
+ sourceProcessor, boActivity);
+ editList.add(addActivityToProcessorEdit);
+
+
+
+ editList.add(edits.getAddProcessorEdit(dataflow, sourceProcessor));
+
+ CompoundEdit compoundEdit = new CompoundEdit(editList);
+ subEdits.add(compoundEdit);
+ compoundEdit.doEdit();
+
+
+ List<Edit<?>> linkEditList = new ArrayList<Edit<?>>();
+
+ EventForwardingOutputPort sourcePort = getSourcePort(
+ sourceProcessor, boActivity, "mobyData", linkEditList);
+ EventHandlingInputPort sinkPort = getSinkPort(sinkProcessor, activity, inputPort.getName(), linkEditList);
+ linkEditList.add(Tools.getCreateAndConnectDatalinkEdit(dataflow,
+ sourcePort, sinkPort, edits));
+ CompoundEdit linkEdit = new CompoundEdit(linkEditList);
+ subEdits.add(linkEdit);
+ linkEdit.doEdit();
+
+ if (!(defaultName.equalsIgnoreCase("Object")
+ || name.equalsIgnoreCase("String")
+ || name.equalsIgnoreCase("Integer") || name
+ .equalsIgnoreCase("DateTime"))) {
+ Edit upstreamObjectEdit = new AddUpstreamObjectEdit(dataflow,
+ sourceProcessor, boActivity, edits);
+ subEdits.add(upstreamObjectEdit);
+ upstreamObjectEdit.doEdit();
+ }
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * net.sf.taverna.t2.workflowmodel.impl.AbstractDataflowEdit#undoEditAction
+ * (net.sf.taverna.t2.workflowmodel.impl.DataflowImpl)
+ */
+ @Override
+ protected void undoEditAction(DataflowImpl dataflow) {
+ if (subEdits != null && subEdits.size() > 0) {
+ for (int i = subEdits.size() - 1; i >= 0; i--) {
+ Edit<?> edit = subEdits.get(i);
+ if (edit.isApplied())
+ edit.undo();
+ }
+ }
+
+
+ }
+
+ private EventHandlingInputPort getSinkPort(
+ net.sf.taverna.t2.workflowmodel.Processor processor,
+ Activity<?> activity, String portName, List<Edit<?>> editList) {
+ InputPort activityPort = net.sf.taverna.t2.workflowmodel.utils.Tools
+ .getActivityInputPort(activity, portName);
+ // check if processor port exists
+ EventHandlingInputPort input = net.sf.taverna.t2.workflowmodel.utils.Tools
+ .getProcessorInputPort(processor, activity, activityPort);
+ if (input == null) {
+ // port doesn't exist so create a processor port and map it
+ ProcessorInputPort processorInputPort = edits
+ .createProcessorInputPort(processor,
+ activityPort.getName(), activityPort.getDepth());
+ editList.add(edits.getAddProcessorInputPortEdit(processor,
+ processorInputPort));
+ editList.add(edits.getAddActivityInputPortMappingEdit(activity,
+ activityPort.getName(), activityPort.getName()));
+ input = processorInputPort;
+ }
+ return input;
+ }
+
+ private EventForwardingOutputPort getSourcePort(
+ net.sf.taverna.t2.workflowmodel.Processor processor,
+ Activity<?> activity, String portName, List<Edit<?>> editList) {
+ OutputPort activityPort = net.sf.taverna.t2.workflowmodel.utils.Tools
+ .getActivityOutputPort(activity, portName);
+ // check if processor port exists
+ EventForwardingOutputPort output = net.sf.taverna.t2.workflowmodel.utils.Tools
+ .getProcessorOutputPort(processor, activity, activityPort);
+ if (output == null) {
+ // port doesn't exist so create a processor port and map it
+ ProcessorOutputPort processorOutputPort = edits
+ .createProcessorOutputPort(processor, activityPort
+ .getName(), activityPort.getDepth(), activityPort
+ .getGranularDepth());
+ editList.add(edits.getAddProcessorOutputPortEdit(processor,
+ processorOutputPort));
+ editList.add(edits.getAddActivityOutputPortMappingEdit(activity,
+ activityPort.getName(), activityPort.getName()));
+ output = processorOutputPort;
+ }
+ return output;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/fd2e9765/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/menu/BiomobyActivityDetailsMenuAction.java
----------------------------------------------------------------------
diff --git a/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/menu/BiomobyActivityDetailsMenuAction.java b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/menu/BiomobyActivityDetailsMenuAction.java
new file mode 100644
index 0000000..cee5420
--- /dev/null
+++ b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/menu/BiomobyActivityDetailsMenuAction.java
@@ -0,0 +1,40 @@
+package net.sf.taverna.t2.activities.biomoby.menu;
+
+import javax.swing.Action;
+
+import net.sf.taverna.t2.activities.biomoby.BiomobyActivity;
+import net.sf.taverna.t2.activities.biomoby.actions.MobyServiceDetailsAction;
+import net.sf.taverna.t2.workbench.activitytools.AbstractConfigureActivityMenuAction;
+import net.sf.taverna.t2.workbench.edits.EditManager;
+import net.sf.taverna.t2.workbench.file.FileManager;
+import net.sf.taverna.t2.workflowmodel.Edits;
+
+public class BiomobyActivityDetailsMenuAction extends
+ AbstractConfigureActivityMenuAction<BiomobyActivity> {
+
+ private static final String CONFIGURE_BIOMOBY_DETAILS = "Browse Biomoby service details";
+ private EditManager editManager;
+ private FileManager fileManager;
+
+ public BiomobyActivityDetailsMenuAction() {
+ super(BiomobyActivity.class);
+ }
+
+ @Override
+ protected Action createAction() {
+ MobyServiceDetailsAction configAction = new MobyServiceDetailsAction(
+ findActivity(), getParentFrame(), editManager, fileManager);
+ configAction.putValue(Action.NAME, CONFIGURE_BIOMOBY_DETAILS);
+ addMenuDots(configAction);
+ return configAction;
+ }
+
+ public void setEditManager(EditManager editManager) {
+ this.editManager = editManager;
+ }
+
+ public void setFileManager(FileManager fileManager) {
+ this.fileManager = fileManager;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/fd2e9765/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/menu/BiomobyActivityParserMenuAction.java
----------------------------------------------------------------------
diff --git a/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/menu/BiomobyActivityParserMenuAction.java b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/menu/BiomobyActivityParserMenuAction.java
new file mode 100644
index 0000000..b760bbc
--- /dev/null
+++ b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/menu/BiomobyActivityParserMenuAction.java
@@ -0,0 +1,41 @@
+package net.sf.taverna.t2.activities.biomoby.menu;
+
+import javax.swing.Action;
+
+import net.sf.taverna.t2.activities.biomoby.BiomobyActivity;
+import net.sf.taverna.t2.activities.biomoby.actions.MobyParserAction;
+import net.sf.taverna.t2.workbench.activitytools.AbstractConfigureActivityMenuAction;
+import net.sf.taverna.t2.workbench.edits.EditManager;
+import net.sf.taverna.t2.workbench.file.FileManager;
+
+public class BiomobyActivityParserMenuAction extends
+ AbstractConfigureActivityMenuAction<BiomobyActivity> {
+
+ private static final String ADD_BIOMOBY_PARSER = "Add Biomoby parser";
+
+ private EditManager editManager;
+
+ private FileManager fileManager;
+
+ public BiomobyActivityParserMenuAction() {
+ super(BiomobyActivity.class);
+ }
+
+ @Override
+ protected Action createAction() {
+ MobyParserAction configAction = new MobyParserAction(
+ findActivity(), getParentFrame(), editManager, fileManager);
+ configAction.putValue(Action.NAME, ADD_BIOMOBY_PARSER);
+ addMenuDots(configAction);
+ return configAction;
+ }
+
+ public void setEditManager(EditManager editManager) {
+ this.editManager = editManager;
+ }
+
+ public void setFileManager(FileManager fileManager) {
+ this.fileManager = fileManager;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/fd2e9765/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/menu/ConfigureBiomobyMenuAction.java
----------------------------------------------------------------------
diff --git a/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/menu/ConfigureBiomobyMenuAction.java b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/menu/ConfigureBiomobyMenuAction.java
new file mode 100644
index 0000000..b86df2a
--- /dev/null
+++ b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/menu/ConfigureBiomobyMenuAction.java
@@ -0,0 +1,52 @@
+package net.sf.taverna.t2.activities.biomoby.menu;
+
+import javax.swing.Action;
+
+import net.sf.taverna.t2.activities.biomoby.BiomobyActivity;
+import net.sf.taverna.t2.activities.biomoby.actions.BiomobyActivityConfigurationAction;
+import net.sf.taverna.t2.workbench.activityicons.ActivityIconManager;
+import net.sf.taverna.t2.workbench.activitytools.AbstractConfigureActivityMenuAction;
+import net.sf.taverna.t2.workbench.edits.EditManager;
+import net.sf.taverna.t2.workbench.file.FileManager;
+
+public class ConfigureBiomobyMenuAction extends
+ AbstractConfigureActivityMenuAction<BiomobyActivity> {
+
+ private EditManager editManager;
+ private FileManager fileManager;
+ private ActivityIconManager activityIconManager;
+
+ public ConfigureBiomobyMenuAction() {
+ super(BiomobyActivity.class);
+ }
+
+ @Override
+ protected Action createAction() {
+ BiomobyActivity a = findActivity();
+ Action result = null;
+ result = new BiomobyActivityConfigurationAction(a, getParentFrame(), editManager,
+ fileManager, activityIconManager);
+ result.putValue(Action.NAME, "Configure");
+ addMenuDots(result);
+ return result;
+ }
+
+ public boolean isEnabled() {
+ BiomobyActivity activity = findActivity();
+ return (super.isEnabled() && (activity.getMobyService() != null) && activity
+ .containsSecondaries());
+ }
+
+ public void setEditManager(EditManager editManager) {
+ this.editManager = editManager;
+ }
+
+ public void setFileManager(FileManager fileManager) {
+ this.fileManager = fileManager;
+ }
+
+ public void setActivityIconManager(ActivityIconManager activityIconManager) {
+ this.activityIconManager = activityIconManager;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/fd2e9765/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/query/BiomobyActivityIcon.java
----------------------------------------------------------------------
diff --git a/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/query/BiomobyActivityIcon.java b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/query/BiomobyActivityIcon.java
new file mode 100644
index 0000000..2c28c32
--- /dev/null
+++ b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/query/BiomobyActivityIcon.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * This file is a component of the Taverna project, and is licensed under the
+ * GNU LGPL. Copyright Edward Kawas, The BioMoby Project
+ ******************************************************************************/
+package net.sf.taverna.t2.activities.biomoby.query;
+
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+
+import net.sf.taverna.t2.activities.biomoby.BiomobyActivity;
+import net.sf.taverna.t2.workbench.activityicons.ActivityIconSPI;
+import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
+
+/**
+ *
+ * @author Alex Nenadic
+ *
+ */
+public class BiomobyActivityIcon implements ActivityIconSPI{
+
+ public int canProvideIconScore(Activity<?> activity) {
+ if (activity.getClass().getName().equals(BiomobyActivity.class.getName()))
+ return DEFAULT_ICON + 1;
+ else
+ return NO_ICON;
+ }
+
+ public Icon getIcon(Activity<?> activity) {
+ return getBiomobyIcon();
+ }
+
+ public static Icon getBiomobyIcon() {
+ return new ImageIcon(BiomobyActivityIcon.class.getResource("/registry.gif"));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/fd2e9765/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/query/BiomobyActivityItem.java
----------------------------------------------------------------------
diff --git a/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/query/BiomobyActivityItem.java b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/query/BiomobyActivityItem.java
new file mode 100644
index 0000000..a799280
--- /dev/null
+++ b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/query/BiomobyActivityItem.java
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * This file is a component of the Taverna project, and is licensed under the
+ * GNU LGPL. Copyright Edward Kawas, The BioMoby Project
+ ******************************************************************************/
+package net.sf.taverna.t2.activities.biomoby.query;
+
+
+public class BiomobyActivityItem /*extends AbstractActivityItem */{
+
+ String registryUrl;
+ String serviceName;
+ String authorityName;
+ String registryUri;
+ String category;
+ String serviceType;
+
+ public String getRegistryUri() {
+ return registryUri;
+ }
+
+ public void setRegistryUri(String registryUri) {
+ this.registryUri = registryUri;
+ }
+
+ public String getRegistryUrl() {
+ return registryUrl;
+ }
+
+ public void setRegistryUrl(String registryUrl) {
+ this.registryUrl = registryUrl;
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ public String getAuthorityName() {
+ return authorityName;
+ }
+
+ public void setAuthorityName(String authorityName) {
+ this.authorityName = authorityName;
+ }
+
+// @Override
+// public Object getConfigBean() {
+// BiomobyActivityConfigurationBean bean = new BiomobyActivityConfigurationBean();
+// bean.setAuthorityName(getAuthorityName());
+// bean.setServiceName(getServiceName());
+// bean.setMobyEndpoint(getRegistryUrl());
+// return bean;
+// }
+//
+// @Override
+// public Icon getIcon() {
+// return BiomobyActivityIcon.getBiomobyIcon();
+// }
+//
+// @Override
+// public Activity<?> getUnconfiguredActivity() {
+// return new BiomobyActivity();
+// }
+
+ public String getType() {
+ return "Biomoby";
+ }
+
+ @Override
+ public String toString() {
+ return getServiceName();
+ }
+
+ public String getCategory() {
+ return category;
+ }
+
+ public void setCategory(String category) {
+ this.category = category;
+ }
+
+ public String getServiceType() {
+ return serviceType;
+ }
+
+ public void setServiceType(String serviceType) {
+ this.serviceType = serviceType;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/fd2e9765/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/query/BiomobyObjectActivityIcon.java
----------------------------------------------------------------------
diff --git a/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/query/BiomobyObjectActivityIcon.java b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/query/BiomobyObjectActivityIcon.java
new file mode 100644
index 0000000..f4575e4
--- /dev/null
+++ b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/query/BiomobyObjectActivityIcon.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * This file is a component of the Taverna project, and is licensed under the
+ * GNU LGPL. Copyright Edward Kawas, The BioMoby Project
+ ******************************************************************************/
+package net.sf.taverna.t2.activities.biomoby.query;
+
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+
+import net.sf.taverna.t2.activities.biomoby.BiomobyObjectActivity;
+import net.sf.taverna.t2.workbench.activityicons.ActivityIconSPI;
+import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
+
+/**
+ *
+ * @author Alex Nenadic
+ *
+ */
+public class BiomobyObjectActivityIcon implements ActivityIconSPI{
+
+ public int canProvideIconScore(Activity<?> activity) {
+ if (activity.getClass().getName().equals(BiomobyObjectActivity.class.getName()))
+ return DEFAULT_ICON + 1;
+ else
+ return NO_ICON;
+ }
+
+ public Icon getIcon(Activity<?> activity) {
+ return new ImageIcon(BiomobyObjectActivityIcon.class.getResource("/biomoby_object.png"));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/fd2e9765/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/query/BiomobyObjectActivityItem.java
----------------------------------------------------------------------
diff --git a/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/query/BiomobyObjectActivityItem.java b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/query/BiomobyObjectActivityItem.java
new file mode 100644
index 0000000..1e50d37
--- /dev/null
+++ b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/query/BiomobyObjectActivityItem.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * This file is a component of the Taverna project, and is licensed under the
+ * GNU LGPL. Copyright Edward Kawas, The BioMoby Project
+ ******************************************************************************/
+package net.sf.taverna.t2.activities.biomoby.query;
+
+
+/**
+ *
+ * @author Alex Nenadic
+ * @author Stuart Owen
+ *
+ */
+public class BiomobyObjectActivityItem /*extends AbstractActivityItem*/ {
+
+ String registryUrl;
+ String serviceName;
+ String authorityName;
+ String registryUri;
+
+ public String getRegistryUri() {
+ return registryUri;
+ }
+
+ public void setRegistryUri(String registryUri) {
+ this.registryUri = registryUri;
+ }
+
+ public String getRegistryUrl() {
+ return registryUrl;
+ }
+
+ public void setRegistryUrl(String registryUrl) {
+ this.registryUrl = registryUrl;
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ public String getAuthorityName() {
+ return authorityName;
+ }
+
+ public void setAuthorityName(String authorityName) {
+ this.authorityName = authorityName;
+ }
+
+// @Override
+// public Object getConfigBean() {
+// BiomobyObjectActivityConfigurationBean bean = new BiomobyObjectActivityConfigurationBean();
+// bean.setAuthorityName(getAuthorityName());
+// bean.setServiceName(getServiceName());
+// bean.setMobyEndpoint(getRegistryUrl());
+// return bean;
+// }
+//
+// @Override
+// public Icon getIcon() {
+// return new ImageIcon(BiomobyObjectActivityItem.class.getResource("/biomoby_object.png"));
+// }
+//
+// @Override
+// public Activity<?> getUnconfiguredActivity() {
+// return new BiomobyObjectActivity();
+// }
+
+ public String getType() {
+ return "Biomoby Object";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/fd2e9765/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/query/BiomobyQueryHelper.java
----------------------------------------------------------------------
diff --git a/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/query/BiomobyQueryHelper.java b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/query/BiomobyQueryHelper.java
new file mode 100644
index 0000000..e22b78c
--- /dev/null
+++ b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/query/BiomobyQueryHelper.java
@@ -0,0 +1,270 @@
+/*******************************************************************************
+ * This file is a component of the Taverna project, and is licensed under the
+ * GNU LGPL. Copyright Edward Kawas, The BioMoby Project
+ ******************************************************************************/
+package net.sf.taverna.t2.activities.biomoby.query;
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.List;
+import java.util.SortedMap;
+import java.util.SortedSet;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import net.sf.taverna.raven.appconfig.ApplicationRuntime;
+import net.sf.taverna.t2.activities.biomoby.GetOntologyThread;
+import net.sf.taverna.t2.activities.biomoby.datatypedescriptions.BiomobyDatatypeDescription;
+import net.sf.taverna.t2.activities.biomoby.servicedescriptions.BiomobyServiceDescription;
+import net.sf.taverna.t2.servicedescriptions.ServiceDescriptionProvider.FindServiceDescriptionsCallBack;
+
+import org.apache.log4j.Logger;
+import org.biomoby.client.CentralDigestCachedImpl;
+import org.biomoby.client.CentralImpl;
+import org.biomoby.shared.MobyDataType;
+import org.biomoby.shared.MobyException;
+import org.biomoby.shared.MobyService;
+import org.w3c.dom.Document;
+
+public class BiomobyQueryHelper {
+
+ private static Logger log = Logger.getLogger(BiomobyQueryHelper.class);
+
+ private String registryNamespace;
+ private String registryEndpoint;
+
+ private CentralDigestCachedImpl central;
+
+ private String DEFAULT_REGISTRY_ENDPOINT = CentralImpl.DEFAULT_ENDPOINT;
+
+ private String DEFAULT_REGISTRY_NAMESPACE = CentralImpl.DEFAULT_NAMESPACE;
+
+ private String remoteDatatypeRdfUrl = null;
+
+ private String remoteServiceRdfUrl = null;
+
+ private static final String CACHE_NAME = "moby-cache";
+
+ private ApplicationRuntime applicationRuntime = ApplicationRuntime
+ .getInstance();
+
+ public BiomobyQueryHelper(String registryEndpoint, String registryNamespace)
+ throws MobyException {
+ try {
+ if (registryNamespace != null)
+ this.registryNamespace = registryNamespace;
+ else
+ this.registryNamespace = DEFAULT_REGISTRY_NAMESPACE;
+ if (registryEndpoint != null)
+ this.registryEndpoint = registryEndpoint;
+ else
+ this.registryEndpoint = DEFAULT_REGISTRY_ENDPOINT;
+ String tavernaHome = null;
+ if (applicationRuntime.getApplicationHomeDir() != null) {
+ tavernaHome = applicationRuntime.getApplicationHomeDir()
+ .getAbsolutePath();
+ }
+ String cacheLoc = tavernaHome;
+ if (cacheLoc == null || cacheLoc.trim().length() == 0)
+ cacheLoc = "";
+ if (!cacheLoc.endsWith(System.getProperty("file.separator")))
+ cacheLoc += File.separator;
+
+ central = new CentralDigestCachedImpl(this.registryEndpoint,
+ this.registryNamespace, cacheLoc + CACHE_NAME);
+
+ } catch (MobyException e) {
+ //
+ log.warn("There was a problem in initializing the caching agent, therefor caching is disabled.",
+ e);
+ }
+ // now we try to speed up the loading of the datatypes ontology
+ try {
+ new GetOntologyThread(central.getRegistryEndpoint()).start();
+ } catch (Exception e) {
+ /* don't care if an exception occurs here ... */
+ }
+ // just call this to ensure that the registry is valid
+ // throws exception if it isnt
+ central.getResourceRefs();
+ }
+
+ /**
+ *
+ * @return an ArrayList of BiomobyActivityItem
+ * @throws MobyException
+ * if something goes wrong
+ */
+ public synchronized ArrayList<BiomobyActivityItem> getServices()
+ throws MobyException {
+ central.updateCache(CentralDigestCachedImpl.CACHE_PART_SERVICES);
+ MobyService[] services = central.getServices();
+ SortedMap<String, SortedSet<MobyService>> map = new TreeMap<String, SortedSet<MobyService>>();
+ for (MobyService service : services) {
+ String authority = service.getAuthority();
+ SortedSet<MobyService> set;
+ if (map.containsKey(authority)) {
+ set = map.remove(authority);
+ set.add(service);
+ map.put(authority, set);
+ } else {
+ set = new TreeSet<MobyService>(new Comparator<MobyService>() {
+ public int compare(MobyService o1, MobyService o2) {
+ return o1.getName().compareTo(o2.getName());
+ }
+ });
+ set.add(service);
+ map.put(authority, set);
+ }
+ }
+ ArrayList<BiomobyActivityItem> authorityList = new ArrayList<BiomobyActivityItem>();
+ for (String authority_name : map.keySet()) {
+ for (MobyService service : map.get(authority_name)) {
+ String serviceName = service.getName();
+ // if (service.getStatus() != MobyService.UNCHECKED) {
+ // f.setAlive((service.getStatus() & MobyService.ALIVE) == 2);
+ // }
+ BiomobyActivityItem item = makeActivityItem(registryEndpoint,
+ registryNamespace, authority_name, serviceName);
+ item.setCategory(service.getCategory());
+ item.setServiceType(service.getServiceType() == null ? "Service"
+ : service.getServiceType().getName());
+ authorityList.add(item);
+ }
+ }
+ return authorityList;
+
+ }
+
+ private BiomobyActivityItem makeActivityItem(String url, String uri,
+ String authorityName, String serviceName) {
+ BiomobyActivityItem item = new BiomobyActivityItem();
+ item.setAuthorityName(authorityName);
+ item.setServiceName(serviceName);
+ item.setRegistryUrl(url);
+ item.setRegistryUri(uri);
+ return item;
+ }
+
+ public String getRemoteDatatypeRdfUrl() {
+ return remoteDatatypeRdfUrl;
+ }
+
+ public String getRemoteServiceRdfUrl() {
+ return remoteServiceRdfUrl;
+ }
+
+ public static Document loadDocument(InputStream input) throws MobyException {
+ try {
+ DocumentBuilderFactory dbf = (DocumentBuilderFactory) DOCUMENT_BUILDER_FACTORIES
+ .get();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ return (db.parse(input));
+ } catch (Exception e) {
+ throw new MobyException("Problem with reading XML input: "
+ + e.toString(), e);
+ }
+ }
+
+ public static ThreadLocal<DocumentBuilderFactory> DOCUMENT_BUILDER_FACTORIES = new ThreadLocal<DocumentBuilderFactory>() {
+ protected synchronized DocumentBuilderFactory initialValue() {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ return dbf;
+ }
+ };
+
+ public void findServiceDescriptionsAsync(
+ FindServiceDescriptionsCallBack callBack) {
+ try {
+ central.updateCache(CentralDigestCachedImpl.CACHE_PART_SERVICES);
+ } catch (MobyException ex) {
+ callBack.fail("Can't update the Biomoby cache", ex);
+ return;
+ }
+ MobyService[] services;
+ try {
+ services = central.getServices();
+ } catch (MobyException ex) {
+ callBack.fail("Can't get BioMoby services", ex);
+ return;
+ }
+ List<BiomobyServiceDescription> serviceDescriptions = new ArrayList<BiomobyServiceDescription>();
+ for (MobyService service : services) {
+ BiomobyServiceDescription serviceDesc = new BiomobyServiceDescription();
+ serviceDesc.setEndpoint(URI.create(registryEndpoint));
+ serviceDesc.setNamespace(URI.create(registryNamespace));
+ serviceDesc.setAuthorityName(service.getAuthority());
+ serviceDesc.setServiceName(service.getName());
+ serviceDesc.setCategory(service.getCategory());
+ serviceDesc.setDescription(service.getDescription());
+ String lsid = service.getLSID();
+ if (lsid != null && lsid.length() > 0) {
+ serviceDesc.setLSID(URI.create(lsid));
+ }
+ serviceDesc.setEmailContact(service.getEmailContact());
+ serviceDesc.setServiceType(service.getServiceType() == null ? "Service"
+ : service.getServiceType().getName());
+ String signatureURL = service.getSignatureURL();
+ if (signatureURL != null && signatureURL.length() > 0) {
+ serviceDesc.setSignatureURI(URI.create(signatureURL));
+ }
+ serviceDescriptions.add(serviceDesc);
+ }
+ callBack.partialResults(serviceDescriptions);
+ callBack.partialResults(findDatatypeDescriptions());
+ callBack.finished();
+ }
+
+ public List<BiomobyDatatypeDescription> findDatatypeDescriptions() {
+ try {
+ central.updateCache(CentralDigestCachedImpl.CACHE_PART_DATATYPES);
+ } catch (MobyException ex) {
+
+ return new ArrayList<BiomobyDatatypeDescription>();
+ }
+ MobyDataType[] datatypes;
+ try {
+ datatypes = central.getDataTypes();
+ } catch (MobyException ex) {
+
+ return new ArrayList<BiomobyDatatypeDescription>();
+ }
+ List<BiomobyDatatypeDescription> datatypeDescriptions = new ArrayList<BiomobyDatatypeDescription>();
+ for (MobyDataType datatype : datatypes) {
+ BiomobyDatatypeDescription dataDesc = new BiomobyDatatypeDescription();
+ dataDesc.setAuthorityName(datatype.getAuthority());
+ dataDesc.setDatatypeName(datatype.getName());
+ dataDesc.setEmailContact(datatype.getEmailContact());
+ dataDesc.setEndpoint(URI.create(registryEndpoint));
+ dataDesc.setNamespace(URI.create(registryNamespace));
+ dataDesc.setParent(datatype.getParentName());
+ dataDesc.setDescription(datatype.getDescription());
+ String lsid = datatype.getLSID();
+ if (lsid != null && lsid.length() > 0) {
+ try {
+ dataDesc.setLsid(URI.create(lsid));
+ } catch (Exception e) {
+
+ }
+ }
+ ArrayList<String> lineage = new ArrayList<String>();
+ if (datatype.getParent() == null && !datatype.getName().equals("Object")) {
+ lineage.add("Object");
+ lineage.add(datatype.getName());
+ } else
+ for (MobyDataType d : datatype.getLineage())
+ if (!d.getName().equals(datatype.getName()))
+ lineage.add(d.getName());
+ dataDesc.setLineage(lineage.toArray(new String[]{}));
+ datatypeDescriptions.add(dataDesc);
+ }
+ return datatypeDescriptions;
+ }
+}