2 package com
.interrupt
.bookkeeping
.workflow
;
4 import com
.interrupt
.bob
.base
.IBob
;
5 import com
.interrupt
.bookkeeping
.cc
.bkell
.Bkell
;
6 import com
.interrupt
.bookkeeping
.exception
.WorkflowException
;
7 import com
.interrupt
.bookkeeping
.util
.Util
;
9 import org
.apache
.log4j
.Logger
;
10 import org
.xml
.sax
.helpers
.AttributesImpl
;
13 public class StateManager
{
15 private Logger logger
= Logger
.getLogger(StateManager
.class);
16 public StateManager() {}
18 /* transition to the appripriate state
19 * if state is 1) null or 2) non of these, it goes to the 'open' state
21 public void transition(IBob ibob
, String destination
) throws WorkflowException
{
23 // getting the 'state' value of the IBob object
24 String sstate
= (ibob
.getAttributes()).getValue("state");
28 //throw new WorkflowException("Cannot find attribute 'state'");
31 if(destination
== null) {
32 throw new WorkflowException("destination is NULL");
34 logger
.debug("-- transition > Class["+ibob
.getClass()+"] > sstate["+sstate
+"] > destination["+destination
+"]");
37 if(sstate
.equals(Util
.OPEN_STATE
) &&
38 destination
.equals(Util
.CLOSED_STATE
)) {
40 estate
= Util
.CLOSED_STATE
;
42 else if(sstate
.equals(Util
.CLOSED_STATE
) &&
43 destination
.equals(Util
.REVERSED_STATE
)) {
45 estate
= Util
.REVERSED_STATE
;
47 else if(sstate
.equals(Util
.CLOSED_STATE
) &&
48 destination
.equals(Util
.REVERSE_CLOSED_STATE
)) {
50 estate
= Util
.REVERSE_CLOSED_STATE
;
52 else if(sstate
.equals(Util
.CLOSED_STATE
) &&
53 destination
.equals(Util
.REMOVED_STATE
)) {
55 estate
= Util
.REMOVED_STATE
;
57 else if(sstate
.equals(Util
.REVERSED_STATE
)) {
58 // if this has been removed, do nothing
59 estate
= Util
.REVERSED_STATE
;
61 else if(sstate
.equals(Util
.REMOVED_STATE
)) {
62 // if this has been removed, do nothing
63 estate
= Util
.REMOVED_STATE
;
66 estate
= Util
.OPEN_STATE
;
69 int index
= (ibob
.getAttributes()).getIndex("state");
70 ((AttributesImpl
)ibob
.getAttributes()).setValue(index
,estate
);