On Tue, Jul 6, 2010 at 08:13, Dennis Neumann <[email protected]> wrote:
> It does not have to be a beanshell script. I have tried the example from
> the tutorial and it does not look that complicated.
> I tried to follow Stian's tip to use Dataflow.getInternalIdentifier().

> Now, Dataflow is an interface and the method is not static. How can I
> get the current Dataflow object from inside my activity plugin?

Unfortunately in the T2 workflow model workflow components don't know
where they live, so you'll  have to do a top-down search by going
through the processor of the running workflow and find the matching
activity. Unfortunately you can't just climb through the currently
'open' workflows, as when running a workflow we make a copy, to avoid
later design modifications affecting the running workflows.


Here's one suggestion for how you can 'climb out' of the activity, but
I must admit it is quite of a hack as our APIs don't really provide
this information:


// Note - not the one in workflowmodel.impl
import net.sf.taverna.t2.workflowmodel.utils.Tools;

// ..
public void executeAsynch(final Map<String, T2Reference> inputs,
                        final AsynchronousActivityCallback callback) {
                callback.requestRun(new Runnable() {
                        public void run() {
//..

StringBuffer result = new StringBuffer();
String procID = callback.getParentProcessIdentifier();
// facade0:Workflow1:Example_2:invocation2

String topFacadeId = procID.substring(0, procID.indexOf(":"));
// facade0

// Look up in a map of started workflow runs
WeakReference<WorkflowInstanceFacade> topFacadeRef =
WorkflowInstanceFacade.workflowRunFacades.get(topFacadeId);

WorkflowInstanceFacade topFacade = topFacadeRef.get();
// The facade wraps a particular workflow run
result.append("In run " + topFacade.getWorkflowRunId());

Dataflow topDataflow = topFacade.getDataflow();
result.append("\nInside top level workflow " + topDataflow.getIdentifier());
                        
// As Tools.getProcessorsWithActivity() don't search inside
// nested workflows, we'll cheat and use
// Tools.getProcessorsWithActivityInputPort() instead                           
ActivityInputPort activityInputPort = getInputPorts().iterator().next();

Collection<Processor> processors =
Tools.getProcessorsWithActivityInputPort(topDataflow,
activityInputPort);
for (Processor processor : processors) {
        // There should just really just be one match
        result.append("\nIn processor " + processor.getLocalName());
}

// Register outputs
Map<String, T2Reference> outputs = new HashMap<String, T2Reference>();
String simpleValue = result.toString();
T2Reference simpleRef = referenceService.register(simpleValue, 0,
true, context);
outputs.put(OUT_SIMPLE_OUTPUT, simpleRef);



Will output something like:


In run 87dfd290-86e2-4de9-8a6a-b58eebe1bfae
Inside top level workflow 1040ec85-1e6c-4389-9c79-7b398cd45277
In processor Example_1





> It looks like a typo, but the method is actually called
> getInternalIdentier()

It is a type, and we've fixed this for upcoming Taverna 2.2, where it
is now called getIdentifier()

-- 
Stian Soiland-Reyes, myGrid team
School of Computer Science
The University of Manchester

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
taverna-hackers mailing list
[email protected]
Web site: http://www.taverna.org.uk
Mailing lists: http://www.taverna.org.uk/about/contact-us/
Developers Guide: http://www.taverna.org.uk/developers/

Reply via email to