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.client;
7   
8   import net.kwfgrid.gworkflowdl.protocol.structure.ProtocolWorkflow;
9   import net.kwfgrid.gworkflowdl.structure.Workflow;
10  
11  import java.rmi.RemoteException;
12  
13  /***
14     Implementation of <code>Workflow</code> interface for the client side of a distributed workflow structure.
15   */
16  public class ClientWorkflow extends ProtocolWorkflow implements IClientRootObject {
17      protected IClientDelegate _protocoldelegate;
18      protected int _versionnumber;
19  
20      /***
21         Constructor.
22         @param delegate The workflow implementation used as a delegate by this workflow.
23         @param protocoldelegate The delegate to use for protocol operations.
24       */
25      protected ClientWorkflow(Workflow delegate, IClientDelegate protocoldelegate) {
26  	super(delegate, protocoldelegate);
27  	_protocoldelegate = protocoldelegate;	
28  	_versionnumber = -1;
29      }
30  
31      public int getVersionNumber() {
32  	return _versionnumber;
33      }
34  
35      public void setVersionNumber(int version) {
36  	_versionnumber = version;
37      }
38  
39      /***
40       * Only makes update of workflow if status is NOT completed or terminated.
41       * @throws RemoteException
42       */
43      public void update() throws RemoteException {
44          String status = getProperties().get("status");
45          if (status != null) {
46              if (status.equals("COMPLETED") || status.equals("TERMINATED")) {
47                  return;
48              }
49          }
50          _protocoldelegate.update(this);
51      }
52  }