lenya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andr...@apache.org
Subject cvs commit: cocoon-lenya/src/java/org/apache/lenya/cms/workflow/impl WorkflowImpl.java
Date Fri, 30 May 2003 14:58:00 GMT
andreas     2003/05/30 07:58:00

  Modified:    src/java/org/apache/lenya/cms/workflow/impl
                        WorkflowImpl.java
  Log:
  managing states separately
  
  Revision  Changes    Path
  1.4       +20 -11    cocoon-lenya/src/java/org/apache/lenya/cms/workflow/impl/WorkflowImpl.java
  
  Index: WorkflowImpl.java
  ===================================================================
  RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/workflow/impl/WorkflowImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- WorkflowImpl.java	28 May 2003 15:33:15 -0000	1.3
  +++ WorkflowImpl.java	30 May 2003 14:58:00 -0000	1.4
  @@ -6,7 +6,9 @@
   
   package org.apache.lenya.cms.workflow.impl;
   
  +import java.util.HashMap;
   import java.util.HashSet;
  +import java.util.Map;
   import java.util.Set;
   import org.apache.lenya.cms.workflow.State;
   import org.apache.lenya.cms.workflow.Transition;
  @@ -21,6 +23,7 @@
       /** Creates a new instance of WorkflowImpl */
       public WorkflowImpl(State initialState) {
           this.initialState = initialState;
  +        addState(initialState);
       }
   
       private State initialState;
  @@ -34,6 +37,11 @@
       }
   
       private Set transitions = new HashSet();
  +    private Map states = new HashMap();
  +    
  +    private void addState(State state) {
  +        states.put(((StateImpl) state).getId(), state);
  +    }
   
       /**
        * Adds a transition.
  @@ -41,6 +49,8 @@
       protected void addTransition(TransitionImpl transition) {
           assert transition != null;
           transitions.add(transition);
  +        addState(transition.getSource());
  +        addState(transition.getDestination());
       }
   
       protected TransitionImpl[] getTransitions() {
  @@ -81,16 +91,15 @@
        * @return <code>true</code> if the state is contained, <code>false</code>
otherwise.
        */
       protected boolean containsState(State state) {
  -        Transition transitions[] = getTransitions();
  -        boolean result = false;
  -        for (int i = 0; i < transitions.length; i++) {
  -            TransitionImpl transition = (TransitionImpl) transitions[i];
  -            if (transition.getSource().equals(state)
  -                || transition.getDestination().equals(state)) {
  -                result = true;
  -            }
  -        }
  -        return result;
  +        return states.containsValue(state);
       }
  -
  +    
  +    protected State[] getStates() {
  +        return (State[]) states.values().toArray(new State[states.size()]);
  +    }
  +    
  +    protected State getState(String name) {
  +        return (State) states.get(name); 
  +    }
  +    
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-cvs-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-cvs-help@cocoon.apache.org


Mime
View raw message