Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/embl/ebi/escience/scufl/talisman/XScufl2Dot.java


1   /**
2    * This file is a component of the Taverna project,
3    * and is licensed under the GNU LGPL.
4    * Copyright Tom Oinn, EMBL-EBI
5    */
6   package org.embl.ebi.escience.scufl.talisman;
7   
8   import javax.servlet.http.HttpServletRequest;
9   import javax.servlet.http.HttpServletResponse;
10  import org.embl.ebi.escience.scufl.*;
11  import org.embl.ebi.escience.scufl.parser.XScuflFormatException;
12  import org.embl.ebi.escience.scufl.parser.XScuflParser;
13  import org.embl.ebi.escience.scufl.view.DotView;
14  import org.embl.ebi.escience.talisman.*;
15  
16  import java.lang.String;
17  
18  
19  
20  /**
21   * Provides a Talisman action plugin that parses
22   * an XScufl definition found in a named 'input' field and
23   * writes the dot format representation of it into 
24   * the 'output' field. The 'ports' field must contain
25   * one of 'all','bound' or 'none', and sets the policy
26   * for displaying the ports within processors in the graph.
27   * @author Tom Oinn
28   */
29  public class XScufl2Dot implements ActionWorker {
30  
31      public void process(HttpServletRequest request , HttpServletResponse response, Action action) 
32    throws AbortActionException, NodeResolutionException, UnknownResolutionProtocolException {
33  
34    Trigger trigger = (Trigger)action.getParent();
35  
36    // Get the fields
37    action.requireParameters("input,output,ports");
38    Field input = Resolver.getField(action.props.getProperty("input"),action);
39    Field output = Resolver.getField(action.props.getProperty("output"),action);
40    String portPolicyString = Resolver.getFieldValue(action.props.getProperty("ports"),action);
41    
42  
43    ScuflModel model = new ScuflModel();
44    DotView view = new DotView(model);
45    if (portPolicyString.equalsIgnoreCase("all")) {
46        view.setPortDisplay(DotView.ALL);
47    }
48    if (portPolicyString.equalsIgnoreCase("bound")) {
49        view.setPortDisplay(DotView.BOUND);
50    }
51    // Defaults to DotView.NONE
52  
53    try {
54        XScuflParser.populate(input.getValue(),model,null);
55        output.setValue(view.getDot());
56    }
57    catch (UnknownProcessorException proc) {
58        trigger.addError(proc.getMessage());
59        throw new AbortActionException();
60    }
61    catch (UnknownPortException port) {
62        trigger.addError(port.getMessage());
63        throw new AbortActionException();
64    }
65    catch (ProcessorCreationException pce) {
66         trigger.addError(pce.getMessage());
67        throw new AbortActionException();
68    }
69    catch (DataConstraintCreationException dce) {
70        trigger.addError(dce.getMessage());
71        throw new AbortActionException();
72    }
73    catch (DuplicateProcessorNameException dpne) {
74        trigger.addError(dpne.getMessage());
75        throw new AbortActionException();
76    }
77    catch (MalformedNameException mne) { 
78        trigger.addError(mne.getMessage());
79        throw new AbortActionException();
80    }
81    catch (XScuflFormatException xsfe) { 
82        trigger.addError(xsfe.getMessage());
83        throw new AbortActionException();
84    }
85    catch (ConcurrencyConstraintCreationException dce) {
86        trigger.addError(dce.getMessage());
87        throw new AbortActionException();
88    }
89    catch (DuplicateConcurrencyConstraintNameException dpne) {
90        trigger.addError(dpne.getMessage());
91        throw new AbortActionException();
92    }
93      }
94  
95  }