View Javadoc

1   /*
2    * Copyright (c) 2005, The K-Wf Grid Consortium
3    * Fraunhofer Institute for Computer Architecture and Software Technology
4    * See http://www.kwfgrid.eu and http://www.first.fraunhofer.de for more details.
5    */
6   package net.kwfgrid.gworkflowdl.protocol.calls;
7   
8   import net.kwfgrid.gworkflowdl.protocol.structure.*;
9   
10  import java.io.IOException;
11  
12  import org.xmlpull.v1.XmlSerializer;
13  
14  /***
15     Modification that removes an outputPlace to a transition.
16   */
17  public class TransitionRemoveOutEdge extends AbstractMethodCall {
18      protected ProtocolEdge _edge;
19      protected ProtocolTransition _transition;
20      protected int _index;
21      protected String _placeid;
22  
23      public TransitionRemoveOutEdge(ProtocolTransition transition, ProtocolEdge edge) {
24  	super(transition.getRoot());
25  	_edge = edge;
26  	_transition = transition;
27  	_index = -1;
28  	_placeid = null;
29      }
30  
31      public TransitionRemoveOutEdge(ProtocolTransition transition, int index) {
32  	this (transition, (ProtocolEdge)transition.getOutEdges()[index]);
33  	_index = index;
34      }
35  
36      public TransitionRemoveOutEdge(ProtocolTransition transition, String placeID) {
37  	this (transition, (ProtocolEdge)transition.getOutEdge(placeID));
38  	_placeid = placeID;
39      }
40      
41      public void marshal(IMethodCallMarshaller encoder, XmlSerializer serializer) throws IOException {
42  	encoder.marshalTransitionRemoveOutEdge(serializer, _transition, _edge);
43      }
44  
45      public Object execute() {
46  	if (_index==-1)
47  	    _transition.__removeOutEdge(_placeid);
48  	else 
49  	    _transition.__removeOutEdge(_index);
50  	setExecuted();
51  	return null;
52      }
53  }