Ignore:
Timestamp:
01/12/11 14:40:59 (9 years ago)
Author:
aivar
Message:

You can now create a workflow, save to XML, create another workflow from that XML, and then run this workflow. Tested in PluginWiringTest.java.

Location:
branches/maven/projects/deep-zoom-plugin/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/maven/projects/deep-zoom-plugin/src/main/java/loci/workflow/WorkFlow.java

    r7511 r7516  
    139139                    throw new XMLException("Missing <name> within <module>"); 
    140140                } 
    141                 System.out.println("module XML is [" + tag.getRemainder() + "]"); 
    142141                IModule module = m_moduleFactory.create(tag.getRemainder()); 
    143142                add(module); 
     
    239238                } 
    240239                String destXML = tag.getContent(); 
    241                 ModuleAndName destCAN = parseModuleAndName(xmlHelper, destXML); 
    242  
    243                 wireInput(inName, destCAN.getModule(), destCAN.getName()); 
     240                ModuleAndName destMAN = parseModuleAndName(xmlHelper, destXML); 
     241 
     242                wireInput(inName, destMAN.getModule(), destMAN.getName()); 
    244243            } 
    245244 
     
    291290                wireOutput(outName, srcMAN.getModule(), srcMAN.getName()); 
    292291            } 
     292             
     293            // finish the wiring 
     294            finalize(); 
     295             
    293296            success = true; 
    294297        } 
     
    434437    private boolean isWiredAsInput(IModule module, String name) { 
    435438        boolean found = false; 
    436         for (Wire wire: m_wires) { 
    437             if (wire.getDest().equals(module) && wire.getDestName().equals(name)) { 
     439 
     440        // is this already an input? 
     441        for (String inName : m_inputNames) { 
     442            if (m_inputModules.get(inName).equals(module) 
     443                    && m_inputModuleNames.get(inName).equals(name)) { 
    438444                found = true; 
     445            } 
     446        } 
     447 
     448        if (!found) { 
     449            // is this the destination of some internal wire? 
     450            for (Wire wire: m_wires) { 
     451                if (wire.getDest().equals(module) && wire.getDestName().equals(name)) { 
     452                    found = true; 
     453                } 
    439454            } 
    440455        } 
     
    444459    private boolean isWiredAsOutput(IModule module, String name) { 
    445460        boolean found = false; 
    446         for (Wire wire: m_wires) { 
    447             if (wire.getSource().equals(module) && wire.getSourceName().equals(name)) { 
    448                 found = true; 
     461 
     462        // is this already an output? 
     463        if (null != m_outputModuleNames.get(name)) { //TODO see wireOutput; this is inadequate 
     464            found = true; 
     465        } 
     466 
     467        if (!found) { 
     468            // is this the source of some internal wire? 
     469            for (Wire wire: m_wires) { 
     470                if (wire.getSource().equals(module) && wire.getSourceName().equals(name)) { 
     471                    found = true; 
     472                } 
    449473            } 
    450474        } 
     
    495519 
    496520        // associate source name with output name 
    497         m_outputModuleNames.put(sourceName, outName); 
     521        m_outputModuleNames.put(sourceName, outName); //TODO WRONG!!! sourceName is not unique for all modules 
    498522 
    499523        // listen for source name from source module 
  • branches/maven/projects/deep-zoom-plugin/src/main/java/loci/workflow/plugin/PluginScheduler.java

    r7509 r7516  
    9191     */ 
    9292    public void chain(IPluginLauncher out, String outName, IPluginLauncher in, String inName) { 
    93        // build a fully-qualified destination name 
    94        String fullInName = in.uniqueName(inName); 
     93        // patch for test components that don't actually have a launcher 
     94        if (null == in) { 
     95            return; 
     96        } 
    9597 
    96        // make sure there is a queue for this name 
    97        getQueue(fullInName); 
     98        // build a fully-qualified destination name 
     99        String fullInName = in.uniqueName(inName); 
    98100 
    99        // within the source plugin instance, save the association of its output 
    100        // name with fully-qualified input name 
    101        out.associate(outName, fullInName); 
     101        // make sure there is a queue for this name 
     102        getQueue(fullInName); 
     103 
     104        // within the source plugin instance, save the association of its output 
     105        // name with fully-qualified input name 
     106        out.associate(outName, fullInName); 
    102107    } 
    103108 
  • branches/maven/projects/deep-zoom-plugin/src/test/java/loci/workflow/PluginWiringTest.java

    r7512 r7516  
    1010import junit.framework.TestSuite; 
    1111 
     12import loci.util.xmllight.XMLException; 
    1213import loci.workflow.plugin.ItemWrapper; 
    1314 
     
    1718 */ 
    1819public class PluginWiringTest extends TestCase { 
     20    String m_xml; 
     21 
    1922    /** 
    2023     * Create the test case 
     
    4851        workflow.finalize(); 
    4952 
     53        // roundtrip workflow to/from XML 
     54        String xml = workflow.toXML(); 
     55        IModule workflow2 = null; 
     56        try { 
     57            workflow2 = ModuleFactory.getInstance().create(xml); 
     58        } 
     59        catch (XMLException e) { 
     60            System.out.println("XML problem " + e.getMessage()); 
     61        } 
     62 
    5063        // create input item, start workflow 
    5164        ItemWrapper item = new ItemWrapper("HELLO"); 
    52         workflow.input(item); 
     65        workflow2.input(item); 
    5366 
    5467        System.out.println("workflow [" + workflow.toXML() + "]"); 
Note: See TracChangeset for help on using the changeset viewer.