Thank you very much, Ferosh!

I think you code would be very helpful to me, I'm reading and analyzing it
now.

If I have any question about the code, I will send email again. ;)

Thanks again!

Huioon

2012/7/18 Ferosh Jacob <[email protected]>

>
> Hey Huioon
>
> I recently did  something similar for WSDL web services , Below is the
> TestCase I created.
> I had an issue because of a classloader,  I modified the source
> and rebuild the jar to solve that.
> Hope this helps, if this doesn't check the source code, especially the
> intergration test projects, dataflow- serialization ...
>
> Thanks
> Ferosh
>
>
>
> package gov.pnl.taverna;
>
> import java.io.File;
> import java.io.FileNotFoundException;
> import java.io.FileOutputStream;
> import java.io.IOException;
> import java.util.List;
> import java.util.Random;
>
> import net.sf.taverna.t2.activities.wsdl.WSDLActivity;
> import net.sf.taverna.t2.activities.wsdl.WSDLActivityConfigurationBean;
> import net.sf.taverna.t2.activities.wsdl.xmlsplitter.AddXMLSplitterEdit;
> import net.sf.taverna.t2.workflowmodel.Dataflow;
> import net.sf.taverna.t2.workflowmodel.DataflowInputPort;
> import net.sf.taverna.t2.workflowmodel.DataflowOutputPort;
> 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.DataflowImpl;
> import net.sf.taverna.t2.workflowmodel.impl.EditsImpl;
> import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
> import
> net.sf.taverna.t2.workflowmodel.processor.activity.ActivityConfigurationException;
> import
> net.sf.taverna.t2.workflowmodel.serialization.SerializationException;
> import net.sf.taverna.t2.workflowmodel.serialization.xml.XMLSerializer;
> import net.sf.taverna.t2.workflowmodel.serialization.xml.XMLSerializerImpl;
> import net.sf.taverna.t2.workflowmodel.utils.Tools;
>
> import org.jdom.output.XMLOutputter;
> import org.junit.Test;
>
> public class T2flowGeneratorTest {
>
>     public static final String wsdlLocation =
> "http://localhost:8080/java_first_jaxws-2.6.1/services/hello_world?wsdl";<http://localhost:8080/java_first_jaxws-2.6.1/services/hello_world?wsdl>
> ;
>     public static final String fileName =
> "/home/ferosh/research/workflow/sample-workflows/1.t2flow";
>
>     @Test
>     public void test() throws ActivityConfigurationException,
> EditException,
>             SerializationException, FileNotFoundException, IOException {
>         /*
>          * XMLInputSplitterActivity activity2 = new
> XMLInputSplitterActivity();
>          * XMLSplitterConfigurationBean bean = new
>          * XMLSplitterConfigurationBean();
>          */
>
>         Edits edits = new EditsImpl();
>
>         Dataflow dataflow = (DataflowImpl) edits.createDataflow();
>         String inputPortName = "I1";
>         String outputPortName = "O1";
>         DataflowInputPort ip =
> edits.createDataflowInputPort(inputPortName, 0,
>                 0, dataflow); //$NON-NLS-1$
>         edits.getAddDataflowInputPortEdit(dataflow, ip).doEdit();
>         DataflowOutputPort op =
> edits.createDataflowOutputPort(outputPortName,
>                 dataflow); //$NON-NLS-1$
>         edits.getAddDataflowOutputPortEdit(dataflow, op).doEdit();
>
>         // Processor p1= createProcessor(edits, dataflow, "saySomething",
>         // null,"parameters");
>
>         Processor p1 = createProcessor(edits, dataflow, "sayHi",
> "parameters",
>                 "parameters");
>
>         Processor p2 = createProcessor(edits, dataflow, "sayHi",
> "parameters",
>                 "parameters");
>
>         ProcessorInputPort procInp = getServiceInputPort(p1.getLocalName(),
>                 dataflow, "arg0", edits);
>         EventForwardingOutputPort sourcePort =
> getDataFlowInputPort(dataflow,
>                 inputPortName);
>         Tools.getCreateAndConnectDatalinkEdit(dataflow, sourcePort,
> procInp)
>                 .doEdit();
>
>         ProcessorOutputPort sourcePortO = getServiceOutputPort(
>                 p1.getLocalName(), dataflow, "return", edits);
>         ProcessorInputPort procInp1 =
> getServiceInputPort(p2.getLocalName(),
>                 dataflow, "arg0", edits);
>         Tools.getCreateAndConnectDatalinkEdit(dataflow, sourcePortO,
> procInp1)
>                 .doEdit();
>
>         ProcessorOutputPort sourcePort1 = getServiceOutputPort(
>                 p2.getLocalName(), dataflow, "return", edits);
>         EventHandlingInputPort sinkPort = getDataFlowOutputPort(dataflow,
>                 outputPortName);
>         Tools.getCreateAndConnectDatalinkEdit(dataflow, sourcePort1,
> sinkPort)
>                 .doEdit();
>
>         // Processor p3= createProcessor(edits, dataflow, "sayHi",
>         // "parameters","parameters");
>
>         printToFile(dataflow, fileName);
>     }
>
>     private ProcessorOutputPort getServiceOutputPort(String processorName,
>             Dataflow dataflow, String portName, Edits edits)
>             throws EditException {
>         String gen_Name = portName;
>         ;
>         Processor p2in = null;
>         List<? extends Processor> processors = dataflow.getProcessors();
>         for (Processor processor : processors) {
>             if (processor.getLocalName().equals(processorName + "_output"))
>                 p2in = processor;
>         }
>         Activity a = p2in.getActivityList().get(0);
>         OutputPort aOP = Tools.getActivityOutputPort(a, portName);
> //$NON-NLS-1$
>         ProcessorOutputPort procOutp =
> edits.createProcessorOutputPort(p2in,
>                 gen_Name, aOP.getDepth(), aOP.getGranularDepth());
>         edits.getAddProcessorOutputPortEdit(p2in, procOutp).doEdit();
>         edits.getAddActivityOutputPortMappingEdit(a, gen_Name, portName)
>                 .doEdit(); //$NON-NLS-1$ //$NON-NLS-2$
>         return procOutp;
>     }
>
>     private ProcessorInputPort getServiceInputPort(String processorName,
>             Dataflow dataflow, String portName, Edits edits)
>             throws EditException {
>         String gen_Name = portName;
>         Processor p2in = null;
>         List<? extends Processor> processors = dataflow.getProcessors();
>         for (Processor processor : processors) {
>             if (processor.getLocalName().equals(processorName + "_input"))
>                 p2in = processor;
>         }
>         Activity a = p2in.getActivityList().get(0);
>         InputPort aIP = Tools.getActivityInputPort(a, portName);
> //$NON-NLS-1$
>         ProcessorInputPort procInp = edits.createProcessorInputPort(p2in,
>                 gen_Name, aIP.getDepth());
>         edits.getAddProcessorInputPortEdit(p2in, procInp).doEdit();
>         edits.getAddActivityInputPortMappingEdit(a, gen_Name, portName)
>                 .doEdit(); //$NON-NLS-1$ //$NON-NLS-2$
>         return procInp;
>     }
>
>     private EventForwardingOutputPort getDataFlowInputPort(Dataflow
> dataflow,
>             String portName) {
>         List<? extends DataflowInputPort> iPorts =
> dataflow.getInputPorts();
>         DataflowInputPort inputPort = null;
>         for (DataflowInputPort port : iPorts) {
>             if (port.getName().equals(portName))
>                 inputPort = port;
>         }
>         if (inputPort == null)
>             throw new RuntimeException(" No input ports found for the
> name:"
>                     + portName);
>         EventForwardingOutputPort sourcePort = (inputPort)
>                 .getInternalOutputPort();
>         return sourcePort;
>     }
>
>     private EventHandlingInputPort getDataFlowOutputPort(Dataflow dataflow,
>             String portName) {
>         List<? extends DataflowOutputPort> iPorts =
> dataflow.getOutputPorts();
>         DataflowOutputPort inputPort = null;
>         for (DataflowOutputPort port : iPorts) {
>             if (port.getName().equals(portName))
>                 inputPort = port;
>         }
>         if (inputPort == null)
>             throw new RuntimeException(" No output ports found for the
> name:"
>                     + portName);
>         EventHandlingInputPort sinkPort =
> (inputPort).getInternalInputPort();
>         return sinkPort;
>     }
>
>     private void printToFile(Dataflow dataflow, String fileName)
>             throws IOException, SerializationException,
> FileNotFoundException {
>         XMLOutputter outputter = new XMLOutputter();
>
>         XMLSerializer serializer = new XMLSerializerImpl();
>         File file = new File(fileName);
>
>         outputter.output(serializer.serializeDataflow(dataflow),
>                 new FileOutputStream(file));
>     }
>
>     private Processor createProcessor(Edits edits, Dataflow dataflow,
>             String operation, String in, String out) throws EditException,
>             ActivityConfigurationException {
>         WSDLActivity activity = new WSDLActivity();
>         WSDLActivityConfigurationBean configBean = new
> WSDLActivityConfigurationBean();
>
>         configBean.setOperation(operation);
>         configBean.setWsdl(wsdlLocation);
>         activity.configure(configBean);
>
>         Processor p = edits.createProcessor(operation + new
> Random().nextInt());
>         edits.getDefaultDispatchStackEdit(p).doEdit();
>         edits.getAddActivityEdit(p, activity).doEdit();
>         edits.getMapProcessorPortsForActivityEdit(p).doEdit();
>         edits.getAddProcessorEdit(dataflow, p).doEdit();
>         if (in != null)
>             new AddXMLSplitterEdit(dataflow, activity, in, true).doEdit();
>         if (out != null)
>             new AddXMLSplitterEdit(dataflow, activity, out,
> false).doEdit();
>         return p;
>
>     }
>
> }
>
>
> On 12-07-18 01:00 AM, Huioon Kim wrote:
>
> Hi, all. I'm newbie in this mailing list. I'm a Korean user of Taverna, so
> please undertand my poor English. Nice to meet you all, anyway. :)
>
>  My question is that, is there any programatic way to create a t2flow
> workflow file? I can create it with the Taverna Workbench, but I want to do
> it with programming.
>
>  I installed the 'taverna-t2flow' Ruby gem, and explored the source code,
> but I couldn't find the way using it. It seems that I only can retrieve
> information from an existing t2flow workflow file. If I'm wrong, tell me
> please.
>
>  Thank you for reading! Any hint would be appreciated.
>
>  Huioon
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>
>
>
> _______________________________________________
> taverna-users mailing 
> [email protected][email protected]
> Web site: http://www.taverna.org.uk
> Mailing lists: http://www.taverna.org.uk/about/contact-us/
>
>
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> taverna-users mailing list
> [email protected]
> [email protected]
> Web site: http://www.taverna.org.uk
> Mailing lists: http://www.taverna.org.uk/about/contact-us/
>
>


-- 
=======================================================
Huioon Kim

Optical Nano Technology Laboratory (ONTL)
Dept. of Information and Communications (DIC)
Gwangu Institute of Science & Technology (GIST)
261 Cheomdan-gwagiro(Oryong-dong), Buk-go,
Gwanju, 500-712, Republic of Korea
Tel: +82-62-715-2257
Fax: +82-62-715-3143
E-mail: [email protected]
Homepage: http://pcandme.net
=======================================================
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
taverna-users mailing list
[email protected]
[email protected]
Web site: http://www.taverna.org.uk
Mailing lists: http://www.taverna.org.uk/about/contact-us/

Reply via email to