commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@apache.org
Subject cvs commit: jakarta-commons-sandbox/workflow/src/test/org/apache/commons/workflow/base BaseActivityTestCase.java
Date Sun, 16 Dec 2001 02:29:30 GMT
craigmcc    01/12/15 18:29:30

  Modified:    workflow/src/java/org/apache/commons/workflow Activity.java
                        Step.java
               workflow/src/java/org/apache/commons/workflow/base
                        BaseActivity.java BaseContext.java BaseStep.java
               workflow/src/java/org/apache/commons/workflow/core
                        AndStep.java GotoStep.java NotAndStep.java
                        NotOrStep.java OrStep.java
               workflow/src/java/org/apache/commons/workflow/web
                        GotoStep.java
               workflow/src/test/org/apache/commons/workflow/base
                        BaseActivityTestCase.java
  Added:       workflow/src/java/org/apache/commons/workflow Block.java
                        Owner.java
               workflow/src/java/org/apache/commons/workflow/base
                        BaseBlock.java
  Log:
  Refactor slightly to prepare for the introduction of nested Steps for
  better expression of conditional and iteration functionality:
  - Create new Owner interface that abstracts out of Activity
    the management of the set of Steps associated with that Activity.
  - Create new Block interface that extends both Step and Owner.
    This will be the class used for Step implementations that require
    support for nested steps
  - Create new BaseBlock convenience class for Block implementations.
  - Graduate the BaseStep.findStep(String id) method up to being part
    of the Owner interface, and therefore implemented in BaseActivity
    and BaseBlock.
  
  These changes should have minimal impact on Step implementations that
  extend BaseStep, and slightly more impact if you are implementing the Step
  interface directly.
  
  TODO:  The activity execution logic in BaseContext does *not* yet know
  anything special about Block versus Step.  There are also no implemented
  Block implementations yet.  Doing so will define how to handle the
  decisions of whether to execute the nested Steps in a block when the
  owning Block is first entered (conditional execution), and whether the
  nested Steps should be repeated (iteration).
  
  NOTE:  All current unit tests still pass.
  
  Revision  Changes    Path
  1.4       +5 -47     jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/Activity.java
  
  Index: Activity.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/Activity.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Activity.java	2001/08/22 01:01:49	1.3
  +++ Activity.java	2001/12/16 02:29:29	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/Activity.java,v
1.3 2001/08/22 01:01:49 craigmcc Exp $
  - * $Revision: 1.3 $
  - * $Date: 2001/08/22 01:01:49 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/Activity.java,v
1.4 2001/12/16 02:29:29 craigmcc Exp $
  + * $Revision: 1.4 $
  + * $Date: 2001/12/16 02:29:29 $
    *
    * ====================================================================
    * 
  @@ -69,23 +69,17 @@
    * within the <code>execute()</code> method of a <code>Context</code>
that
    * is utilizing this <code>Activity</code> definition.</p>
    *
  - * @version $Revision: 1.3 $ $Date: 2001/08/22 01:01:49 $
  + * @version $Revision: 1.4 $ $Date: 2001/12/16 02:29:29 $
    * @author Craig R. McClanahan
    */
   
  -public interface Activity {
  +public interface Activity extends Owner {
   
   
       // ------------------------------------------------------------- Properties
   
   
       /**
  -     * Return the first Step associated with this Activity.
  -     */
  -    public Step getFirstStep();
  -
  -
  -    /**
        * Return the unique identifier (within this Activity) of this Step.
        */
       public String getId();
  @@ -99,43 +93,7 @@
       public void setId(String id);
   
   
  -    /**
  -     * Return the last Step associated with this Activity.
  -     */
  -    public Step getLastStep();
  -
  -
       // --------------------------------------------------------- Public Methods
  -
  -
  -    /**
  -     * Add a new Step to the end of the sequence of Steps associated with
  -     * this Activity.
  -     *
  -     * @param step The new step to be added
  -     */
  -    public void addStep(Step step);
  -
  -
  -    /**
  -     * Clear any existing Steps associated with this Activity.
  -     */
  -    public void clear();
  -
  -
  -    /**
  -     * Return the set of Steps associated with this Activity.
  -     */
  -    public Step[] getSteps();
  -
  -
  -    /**
  -     * Set the set of Steps associated with this Activity, replacing any
  -     * existing ones.
  -     *
  -     * @param steps The new set of steps.
  -     */
  -    public void setSteps(Step steps[]);
   
   
   }
  
  
  
  1.2       +21 -21    jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/Step.java
  
  Index: Step.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/Step.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Step.java	2001/08/13 21:15:03	1.1
  +++ Step.java	2001/12/16 02:29:29	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/Step.java,v
1.1 2001/08/13 21:15:03 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/08/13 21:15:03 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/Step.java,v
1.2 2001/12/16 02:29:29 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2001/12/16 02:29:29 $
    *
    * ====================================================================
    * 
  @@ -69,7 +69,7 @@
    * method -- everything else about a Step is part of its static definition,
    * which is shared among all users of the owning Activity.</p>
    *
  - * @version $Revision: 1.1 $ $Date: 2001/08/13 21:15:03 $
  + * @version $Revision: 1.2 $ $Date: 2001/12/16 02:29:29 $
    * @author Craig R. McClanahan
    */
   
  @@ -80,55 +80,55 @@
   
   
       /**
  -     * Return the Activity that owns this Step.
  +     * Return the unique identifier (within this Activity) of this Step.
        */
  -    public Activity getActivity();
  +    public String getId();
   
   
       /**
  -     * Set the Activity that owns this Step.
  +     * Set the unique identifier (within this Activity) of this Step.
        *
  -     * @param activity The new owning Activity
  +     * @param id The new unique identifier
        */
  -    public void setActivity(Activity activity);
  +    public void setId(String id);
   
   
       /**
  -     * Return the unique identifier (within this Activity) of this Step.
  +     * Return the next Step in our associated Activity or Block.
        */
  -    public String getId();
  +    public Step getNextStep();
   
   
       /**
  -     * Set the unique identifier (within this Activity) of this Step.
  +     * Set the next Step in our associated Activity or Block.
        *
  -     * @param id The new unique identifier
  +     * @param nextStep The new next Step
        */
  -    public void setId(String id);
  +    public void setNextStep(Step nextStep);
   
   
       /**
  -     * Return the next Step in our associated Activity.
  +     * Return the Activity or Block that owns this Step.
        */
  -    public Step getNextStep();
  +    public Owner getOwner();
   
   
       /**
  -     * Set the next Step in our associated Activity.
  +     * Set the Activity or Block that owns this Step.
        *
  -     * @param nextStep The new next Step
  +     * @param owner The new owning Activity or Block
        */
  -    public void setNextStep(Step nextStep);
  +    public void setOwner(Owner owner);
   
   
       /**
  -     * Return the previous Step in our associated Activity.
  +     * Return the previous Step in our associated Activity or Block.
        */
       public Step getPreviousStep();
   
   
       /**
  -     * Set the previous Step in our associated Activity.
  +     * Set the previous Step in our associated Activity or Block.
        *
        * @param previousStep The new previous Step
        */
  
  
  
  1.1                  jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/Block.java
  
  Index: Block.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/Block.java,v
1.1 2001/12/16 02:29:29 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2001/12/16 02:29:29 $
   *
   * ====================================================================
   * 
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */ 
  
  package org.apache.commons.workflow;
  
  
  /**
   * <p>A <strong>Block</strong> is a Step that can include nested Steps.
   * It is used to create Step implementations supporting conditional
   * execution and iteration.</p>
   *
   * @version $Revision: 1.1 $ $Date: 2001/12/16 02:29:29 $
   * @author Craig R. McClanahan
   */
  
  public interface Block extends Owner, Step {
  
  
      // --------------------------------------------------------- Public Methods
  
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/Owner.java
  
  Index: Owner.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/Owner.java,v
1.1 2001/12/16 02:29:29 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2001/12/16 02:29:29 $
   *
   * ====================================================================
   * 
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */ 
  
  package org.apache.commons.workflow;
  
  
  /**
   * <p><strong>Owner</strong> represents the common characteristics of
Activities
   * and Blocks (that is, Steps that allow nested Steps, such as those that
   * implementat conditionals and iteration).</p>
   *
   * @version $Revision: 1.1 $ $Date: 2001/12/16 02:29:29 $
   * @author Craig R. McClanahan
   */
  
  public interface Owner {
  
  
      // ------------------------------------------------------------- Properties
  
  
      /**
       * Return the first Step associated with this Activity or Block.
       */
      public Step getFirstStep();
  
  
      /**
       * Return the last Step associated with this Activity or Block.
       */
      public Step getLastStep();
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Add a new Step to the end of the sequence of Steps associated with
       * this Activity or Block.
       *
       * @param step The new step to be added
       */
      public void addStep(Step step);
  
  
      /**
       * Clear any existing Steps associated with this Activity or Block.
       */
      public void clearSteps();
  
  
      /**
       * Return the identified Step from our current Activity or Block,
       * if it exists.  Otherwise, return <code>null</code>.
       *
       * @param id Identifier of the desired Step
       */
      public Step findStep(String id);
  
  
      /**
       * Return the set of Steps associated with this Activity or Block.
       */
      public Step[] getSteps();
  
  
      /**
       * Set the set of Steps associated with this Activity or Block,
       * replacing any existing ones.
       *
       * @param steps The new set of steps.
       */
      public void setSteps(Step steps[]);
  
  
  }
  
  
  
  1.5       +28 -8     jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/base/BaseActivity.java
  
  Index: BaseActivity.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/base/BaseActivity.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- BaseActivity.java	2001/08/22 01:01:49	1.4
  +++ BaseActivity.java	2001/12/16 02:29:29	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/base/BaseActivity.java,v
1.4 2001/08/22 01:01:49 craigmcc Exp $
  - * $Revision: 1.4 $
  - * $Date: 2001/08/22 01:01:49 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/base/BaseActivity.java,v
1.5 2001/12/16 02:29:29 craigmcc Exp $
  + * $Revision: 1.5 $
  + * $Date: 2001/12/16 02:29:29 $
    *
    * ====================================================================
    * 
  @@ -73,7 +73,7 @@
    * management of the static relationships of Steps to each other as part
    * of an owning Activity.</p>
    *
  - * @version $Revision: 1.4 $ $Date: 2001/08/22 01:01:49 $
  + * @version $Revision: 1.5 $ $Date: 2001/12/16 02:29:29 $
    * @author Craig R. McClanahan
    */
   
  @@ -146,7 +146,7 @@
       }
   
   
  -    // --------------------------------------------------------- Public Methods
  +    // ---------------------------------------------------------- Owner Methods
   
   
       /**
  @@ -157,7 +157,7 @@
        */
       public void addStep(Step step) {
   
  -        step.setActivity(this);
  +        step.setOwner(this);
           if (firstStep == null) {
               step.setPreviousStep(null);
               step.setNextStep(null);
  @@ -176,11 +176,12 @@
       /**
        * Clear any existing Steps associated with this Activity.
        */
  -    public void clear() {
  +    public void clearSteps() {
   
           Step current = firstStep;
           while (current != null) {
               Step next = current.getNextStep();
  +            current.setOwner(null);
               current.setPreviousStep(null);
               current.setNextStep(null);
               current = next;
  @@ -192,6 +193,25 @@
   
   
       /**
  +     * Return the identified Step from this Activity, if it exists.
  +     * Otherwise, return <code>null</code>.
  +     *
  +     * @param id Identifier of the desired Step
  +     */
  +    public Step findStep(String id) {
  +
  +        Step current = getFirstStep();
  +        while (current != null) {
  +            if (id.equals(current.getId()))
  +                return (current);
  +            current = current.getNextStep();
  +        }
  +        return (null);
  +
  +    }
  +
  +
  +    /**
        * Return the set of Steps associated with this Activity.
        */
       public Step[] getSteps() {
  @@ -216,7 +236,7 @@
        */
       public void setSteps(Step steps[]) {
   
  -        clear();
  +        clearSteps();
           for (int i = 0; i < steps.length; i++)
               addStep(steps[i]);
   
  
  
  
  1.11      +8 -6      jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/base/BaseContext.java
  
  Index: BaseContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/base/BaseContext.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- BaseContext.java	2001/08/27 05:57:26	1.10
  +++ BaseContext.java	2001/12/16 02:29:29	1.11
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/base/BaseContext.java,v
1.10 2001/08/27 05:57:26 craigmcc Exp $
  - * $Revision: 1.10 $
  - * $Date: 2001/08/27 05:57:26 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/base/BaseContext.java,v
1.11 2001/12/16 02:29:29 craigmcc Exp $
  + * $Revision: 1.11 $
  + * $Date: 2001/12/16 02:29:29 $
    *
    * ====================================================================
    * 
  @@ -84,7 +84,7 @@
    * class.  If it is used in a multiple thread environment, callers must
    * take suitable precations.</p>
    *
  - * @version $Revision: 1.10 $ $Date: 2001/08/27 05:57:26 $
  + * @version $Revision: 1.11 $ $Date: 2001/12/16 02:29:29 $
    * @author Craig R. McClanahan
    */
   
  @@ -575,7 +575,8 @@
                   // If there are active calls, resume the most recent one
                   try {
                       nextStep = (Step) calls.pop();
  -                    this.activity = nextStep.getActivity();
  +                    // FIXME - Update this for nested Steps!!!
  +                    this.activity = (Activity) nextStep.getOwner();
                   } catch (EmptyStackException e) {
                       ; // Can not happen
                   }
  @@ -713,8 +714,9 @@
        */
       public void setNextStep(Step nextStep) {
   
  +        // FIXME - Update for nested steps execution!
           if ((nextStep != null) &&
  -            (this.activity != nextStep.getActivity()))
  +            (this.activity != (Activity) nextStep.getOwner()))
               throw new IllegalArgumentException
                   ("Step is not part of the current Activity");
           this.nextStep = nextStep;
  
  
  
  1.3       +37 -56    jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/base/BaseStep.java
  
  Index: BaseStep.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/base/BaseStep.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BaseStep.java	2001/09/03 19:13:30	1.2
  +++ BaseStep.java	2001/12/16 02:29:29	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/base/BaseStep.java,v
1.2 2001/09/03 19:13:30 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2001/09/03 19:13:30 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/base/BaseStep.java,v
1.3 2001/12/16 02:29:29 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2001/12/16 02:29:29 $
    *
    * ====================================================================
    * 
  @@ -64,6 +64,7 @@
   
   import org.apache.commons.workflow.Activity;
   import org.apache.commons.workflow.Context;
  +import org.apache.commons.workflow.Owner;
   import org.apache.commons.workflow.Step;
   import org.apache.commons.workflow.StepException;
   
  @@ -74,7 +75,7 @@
    * relationships of Steps to each other, and to their owning Activity, but
    * requires the implementation to provide an <code>execute()</code> method.
    *
  - * @version $Revision: 1.2 $ $Date: 2001/09/03 19:13:30 $
  + * @version $Revision: 1.3 $ $Date: 2001/12/16 02:29:29 $
    * @author Craig R. McClanahan
    */
   
  @@ -85,13 +86,6 @@
   
   
       /**
  -     * The Activity that owns this Step.
  -     */
  -    protected Activity activity = null;
  -
  -
  -
  -    /**
        * The unique identifier (within this Activity) of this Step.
        */
       protected String id = null;
  @@ -104,6 +98,13 @@
   
   
       /**
  +     * The Activity or Block that owns this Step.
  +     */
  +    protected Owner owner = null;
  +
  +
  +
  +    /**
        * The previous Step in our associated Activity.
        */
       protected Step previousStep = null;
  @@ -114,73 +115,75 @@
   
   
       /**
  -     * Return the Activity that owns this Step.
  +     * Return the unique identifier (within this Activity or Block)
  +     * of this Step.
        */
  -    public Activity getActivity() {
  +    public String getId() {
   
  -        return (this.activity);
  +        return (this.id);
   
       }
   
   
       /**
  -     * Set the Activity that owns this Step.
  +     * Set the unique identifier (within this Activity or Block)
  +     * of this Step.
        *
  -     * @param activity The new owning Activity
  +     * @param id The new unique identifier
        */
  -    public void setActivity(Activity activity) {
  +    public void setId(String id) {
   
  -        this.activity = activity;
  +        this.id = id;
   
       }
   
   
       /**
  -     * Return the unique identifier (within this Activity) of this Step.
  +     * Return the next Step in our associated Activity or Block.
        */
  -    public String getId() {
  +    public Step getNextStep() {
   
  -        return (this.id);
  +        return (this.nextStep);
   
       }
   
   
       /**
  -     * Set the unique identifier (within this Activity) of this Step.
  +     * Set the next Step in our associated Activity or Block.
        *
  -     * @param id The new unique identifier
  +     * @param nextStep The new next Step
        */
  -    public void setId(String id) {
  +    public void setNextStep(Step nextStep) {
   
  -        this.id = id;
  +        this.nextStep = nextStep;
   
       }
   
   
       /**
  -     * Return the next Step in our associated Activity.
  +     * Return the Activity or Block that owns this Step.
        */
  -    public Step getNextStep() {
  +    public Owner getOwner() {
   
  -        return (this.nextStep);
  +        return (this.owner);
   
       }
   
   
       /**
  -     * Set the next Step in our associated Activity.
  +     * Set the Activity or Block that owns this Step.
        *
  -     * @param nextStep The new next Step
  +     * @param steps The new owning Activity or Block
        */
  -    public void setNextStep(Step nextStep) {
  +    public void setOwner(Owner owner) {
   
  -        this.nextStep = nextStep;
  +        this.owner = owner;
   
       }
   
   
       /**
  -     * Return the previous Step in our associated Activity.
  +     * Return the previous Step in our associated Activity or Block.
        */
       public Step getPreviousStep() {
   
  @@ -190,7 +193,7 @@
   
   
       /**
  -     * Set the previous Step in our associated Activity.
  +     * Set the previous Step in our associated Activity or Block.
        *
        * @param previousStep The new previous Step
        */
  @@ -213,28 +216,6 @@
        * @exception StepException if a processing error has occurred
        */
       public abstract void execute(Context context) throws StepException;
  -
  -
  -    // ------------------------------------------------------ Protected Methods
  -
  -
  -    /**
  -     * Return the identified Step from our current Activity, if it exists.
  -     * Otherwise, return <code>null</code>.
  -     *
  -     * @param id Identifier of the desired Step
  -     */
  -    protected Step findStep(String id) {
  -
  -        Step current = getActivity().getFirstStep();
  -        while (current != null) {
  -            if (id.equals(current.getId()))
  -                return (current);
  -            current = current.getNextStep();
  -        }
  -        return (null);
  -
  -    }
   
   
   }
  
  
  
  1.1                  jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/base/BaseBlock.java
  
  Index: BaseBlock.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/base/BaseBlock.java,v
1.1 2001/12/16 02:29:29 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2001/12/16 02:29:29 $
   *
   * ====================================================================
   * 
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */ 
  
  package org.apache.commons.workflow.base;
  
  
  import java.util.ArrayList;
  import org.apache.commons.workflow.Activity;
  import org.apache.commons.workflow.Block;
  import org.apache.commons.workflow.Context;
  import org.apache.commons.workflow.Owner;
  import org.apache.commons.workflow.Step;
  import org.apache.commons.workflow.StepException;
  
  
  /**
   * <p><strong>BaseBlock</strong> is a convenient base class for more
   * sophisticated <code>Block</code> implementations.  It includes management
   * of the static relationships of nested Steps for this Step (each of which
   * could conceptually also be a Block and have its own nested Steps).  Like
   * <code>BaseStep</code>, this implementation requires the implementation to
   * provide an <code>execute()</code> method.
   *
   * @version $Revision: 1.1 $ $Date: 2001/12/16 02:29:29 $
   * @author Craig R. McClanahan
   */
  
  public abstract class BaseBlock implements Block {
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      /**
       * The first Step associated with this Block.
       */
      protected Step firstStep = null;
  
  
      /**
       * The last Step associated with this Block.
       */
      protected Step lastStep = null;
  
  
      // ------------------------------------------------------------- Properties
  
  
      /**
       * Return the first Step associated with this Block.
       */
      public Step getFirstStep() {
  
          return (this.firstStep);
  
      }
  
  
      /**
       * Return the last Step associated with this Activity.
       */
      public Step getLastStep() {
  
          return (this.lastStep);
  
      }
  
  
      // ---------------------------------------------------------- Owner Methods
  
  
      /**
       * Add a new Step to the end of the sequence of Steps associated with
       * this Block.
       *
       * @param step The new step to be added
       */
      public void addStep(Step step) {
  
          step.setOwner(this);
          if (firstStep == null) {
              step.setPreviousStep(null);
              step.setNextStep(null);
              firstStep = step;
              lastStep = step;
          } else {
              step.setPreviousStep(lastStep);
              step.setNextStep(null);
              lastStep.setNextStep(step);
              lastStep = step;
          }
  
      }
  
  
      /**
       * Clear any existing Steps associated with this Block.
       */
      public void clearSteps() {
  
          Step current = firstStep;
          while (current != null) {
              Step next = current.getNextStep();
              current.setOwner(null);
              current.setPreviousStep(null);
              current.setNextStep(null);
              current = next;
          }
          firstStep = null;
          lastStep = null;
  
      }
  
  
      /**
       * Return the identified Step from this Block, if it exists.
       * Otherwise, return <code>null</code>.
       *
       * @param id Identifier of the desired Step
       */
      public Step findStep(String id) {
  
          Step current = getFirstStep();
          while (current != null) {
              if (id.equals(current.getId()))
                  return (current);
              current = current.getNextStep();
          }
          return (null);
  
      }
  
  
      /**
       * Return the set of Steps associated with this Block.
       */
      public Step[] getSteps() {
  
          ArrayList list = new ArrayList();
          Step currentStep = firstStep;
          while (currentStep != null) {
              list.add(currentStep);
              currentStep = currentStep.getNextStep();
          }
          Step steps[] = new Step[list.size()];
          return ((Step[]) list.toArray(steps));
  
      }
  
  
      /**
       * Set the set of Steps associated with this Block, replacing any
       * existing ones.
       *
       * @param steps The new set of steps.
       */
      public void setSteps(Step steps[]) {
  
          clearSteps();
          for (int i = 0; i < steps.length; i++)
              addStep(steps[i]);
  
      }
  
  
  }
  
  
  
  1.2       +5 -5      jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/core/AndStep.java
  
  Index: AndStep.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/core/AndStep.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AndStep.java	2001/08/26 03:38:11	1.1
  +++ AndStep.java	2001/12/16 02:29:29	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/core/AndStep.java,v
1.1 2001/08/26 03:38:11 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/08/26 03:38:11 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/core/AndStep.java,v
1.2 2001/12/16 02:29:29 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2001/12/16 02:29:29 $
    *
    * ====================================================================
    * 
  @@ -81,7 +81,7 @@
    *     should be transferred if the condition is met.</li>
    * </ul>
    *
  - * @version $Revision: 1.1 $ $Date: 2001/08/26 03:38:11 $
  + * @version $Revision: 1.2 $ $Date: 2001/12/16 02:29:29 $
    * @author Craig R. McClanahan
    */
   
  @@ -170,7 +170,7 @@
   
           // Conditionally forward control to the specified step
           if (condition) {
  -            Step next = findStep(this.step);
  +            Step next = getOwner().findStep(this.step);
               if (next == null)
                   throw new StepException("Cannot find step '" + step + "'",
                                           this);
  
  
  
  1.6       +5 -5      jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/core/GotoStep.java
  
  Index: GotoStep.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/core/GotoStep.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- GotoStep.java	2001/09/20 02:13:55	1.5
  +++ GotoStep.java	2001/12/16 02:29:29	1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/core/GotoStep.java,v
1.5 2001/09/20 02:13:55 craigmcc Exp $
  - * $Revision: 1.5 $
  - * $Date: 2001/09/20 02:13:55 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/core/GotoStep.java,v
1.6 2001/12/16 02:29:29 craigmcc Exp $
  + * $Revision: 1.6 $
  + * $Date: 2001/12/16 02:29:29 $
    *
    * ====================================================================
    * 
  @@ -78,7 +78,7 @@
    *     should be transferred.</li>
    * </ul>
    *
  - * @version $Revision: 1.5 $ $Date: 2001/09/20 02:13:55 $
  + * @version $Revision: 1.6 $ $Date: 2001/12/16 02:29:29 $
    * @author Craig R. McClanahan
    */
   
  @@ -156,7 +156,7 @@
       public void execute(Context context) throws StepException {
   
           // Locate the step to which we will transfer control
  -        Step next = findStep(this.step);
  +        Step next = getOwner().findStep(this.step);
           if (next == null)
               throw new StepException("Cannot find step '" + step + "'", this);
   
  
  
  
  1.2       +2 -2      jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/core/NotAndStep.java
  
  Index: NotAndStep.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/core/NotAndStep.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- NotAndStep.java	2001/11/18 22:19:13	1.1
  +++ NotAndStep.java	2001/12/16 02:29:29	1.2
  @@ -22,7 +22,7 @@
    *     should be transferred if the condition is not met.</li>
    * </ul>
    *
  - * @version $Revision: 1.1 $ $Date: 2001/11/18 22:19:13 $
  + * @version $Revision: 1.2 $ $Date: 2001/12/16 02:29:29 $
    * @author Preston Sheldon
    */
   
  @@ -103,7 +103,7 @@
   
           // Conditionally forward control to the specified step
           if (!condition) {
  -            Step next = findStep(this.step);
  +            Step next = getOwner().findStep(this.step);
               if (next == null)
                   throw new StepException("Cannot find step '" + step + "'",
                                           this);
  
  
  
  1.2       +2 -2      jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/core/NotOrStep.java
  
  Index: NotOrStep.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/core/NotOrStep.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- NotOrStep.java	2001/11/18 22:19:13	1.1
  +++ NotOrStep.java	2001/12/16 02:29:29	1.2
  @@ -22,7 +22,7 @@
    *     should be transferred if the condition is met.</li>
    * </ul>
    *
  - * @version $Revision: 1.1 $ $Date: 2001/11/18 22:19:13 $
  + * @version $Revision: 1.2 $ $Date: 2001/12/16 02:29:29 $
    * @author Preston Sheldon
    */
   
  @@ -106,7 +106,7 @@
   
           // Conditionally forward control to the specified step
           if (!condition) {
  -            Step next = findStep(this.step);
  +            Step next = getOwner().findStep(this.step);
               if (next == null)
                   throw new StepException("Cannot find step '" + step + "'",
                                           this);
  
  
  
  1.2       +5 -5      jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/core/OrStep.java
  
  Index: OrStep.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/core/OrStep.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- OrStep.java	2001/08/26 03:38:11	1.1
  +++ OrStep.java	2001/12/16 02:29:29	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/core/OrStep.java,v
1.1 2001/08/26 03:38:11 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/08/26 03:38:11 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/core/OrStep.java,v
1.2 2001/12/16 02:29:29 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2001/12/16 02:29:29 $
    *
    * ====================================================================
    * 
  @@ -81,7 +81,7 @@
    *     should be transferred if the condition is met.</li>
    * </ul>
    *
  - * @version $Revision: 1.1 $ $Date: 2001/08/26 03:38:11 $
  + * @version $Revision: 1.2 $ $Date: 2001/12/16 02:29:29 $
    * @author Craig R. McClanahan
    */
   
  @@ -173,7 +173,7 @@
   
           // Conditionally forward control to the specified step
           if (condition) {
  -            Step next = findStep(this.step);
  +            Step next = getOwner().findStep(this.step);
               if (next == null)
                   throw new StepException("Cannot find step '" + step + "'",
                                           this);
  
  
  
  1.3       +5 -5      jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/web/GotoStep.java
  
  Index: GotoStep.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/web/GotoStep.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- GotoStep.java	2001/09/20 02:13:55	1.2
  +++ GotoStep.java	2001/12/16 02:29:30	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/web/GotoStep.java,v
1.2 2001/09/20 02:13:55 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2001/09/20 02:13:55 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/web/GotoStep.java,v
1.3 2001/12/16 02:29:30 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2001/12/16 02:29:30 $
    *
    * ====================================================================
    * 
  @@ -86,7 +86,7 @@
    *     specified, a request parameter named <code>step</code> is used.</li>
    * </ul>
    *
  - * @version $Revision: 1.2 $ $Date: 2001/09/20 02:13:55 $
  + * @version $Revision: 1.3 $ $Date: 2001/12/16 02:29:30 $
    * @author Craig R. McClanahan
    */
   
  @@ -180,7 +180,7 @@
   
   
           // Locate the step to which we will transfer control
  -        Step next = findStep(id);
  +        Step next = getOwner().findStep(id);
           if (next == null)
               throw new StepException("Cannot find step '" + id + "'", this);
   
  
  
  
  1.3       +12 -12    jakarta-commons-sandbox/workflow/src/test/org/apache/commons/workflow/base/BaseActivityTestCase.java
  
  Index: BaseActivityTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/workflow/src/test/org/apache/commons/workflow/base/BaseActivityTestCase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BaseActivityTestCase.java	2001/08/18 20:30:52	1.2
  +++ BaseActivityTestCase.java	2001/12/16 02:29:30	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/workflow/src/test/org/apache/commons/workflow/base/BaseActivityTestCase.java,v
1.2 2001/08/18 20:30:52 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2001/08/18 20:30:52 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/workflow/src/test/org/apache/commons/workflow/base/BaseActivityTestCase.java,v
1.3 2001/12/16 02:29:30 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2001/12/16 02:29:30 $
    *
    * ====================================================================
    *
  @@ -78,7 +78,7 @@
    * Step execution (and therefore require a Context).</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2001/08/18 20:30:52 $
  + * @version $Revision: 1.3 $ $Date: 2001/12/16 02:29:30 $
    */
   
   public class BaseActivityTestCase extends TestCase {
  @@ -171,11 +171,11 @@
           Step steps[] = new Step[] { step0, step1, step2 };
           activity.setSteps(steps);
           assertEquals("step0 belongs to activity",
  -                     step0.getActivity(), activity);
  +                     (Activity) step0.getOwner(), activity);
           assertEquals("step1 belongs to activity",
  -                     step1.getActivity(), activity);
  +                     (Activity) step1.getOwner(), activity);
           assertEquals("step2 belongs to activity",
  -                     step2.getActivity(), activity);
  +                     (Activity) step2.getOwner(), activity);
   
           assertEquals("firstStep should be step 0", step0,
                        activity.getFirstStep());
  @@ -199,7 +199,7 @@
           assertEquals("steps[1] should be step 1", step1, steps[1]);
           assertEquals("steps[2] should be step 2", step2, steps[2]);
   
  -        activity.clear();
  +        activity.clearSteps();
           assertNull("firstStep should be null", activity.getFirstStep());
           assertNull("lastStep should be null", activity.getLastStep());
           steps = activity.getSteps();
  @@ -218,7 +218,7 @@
           Step step0 = new TestStep("Step 0");
           activity.addStep(step0);
           assertEquals("step0 belongs to activity",
  -                     step0.getActivity(), activity);
  +                     (Activity) step0.getOwner(), activity);
           assertEquals("firstStep should be step 0", step0,
                        activity.getFirstStep());
           assertEquals("lastStep should be step 0", step0,
  @@ -234,7 +234,7 @@
           Step step1 = new TestStep("Step 1");
           activity.addStep(step1);
           assertEquals("step1 belongs to activity",
  -                     step1.getActivity(), activity);
  +                     (Activity) step1.getOwner(), activity);
           assertEquals("firstStep should be step 0", step0,
                        activity.getFirstStep());
           assertEquals("lastStep should be step 1", step1,
  @@ -255,7 +255,7 @@
           Step step2 = new TestStep("Step 2");
           activity.addStep(step2);
           assertEquals("step2 belongs to activity",
  -                     step2.getActivity(), activity);
  +                     (Activity) step2.getOwner(), activity);
           assertEquals("firstStep should be step 0", step0,
                        activity.getFirstStep());
           assertEquals("lastStep should be step 2", step2,
  @@ -278,7 +278,7 @@
           assertEquals("steps[1] should be step 1", step1, steps[1]);
           assertEquals("steps[2] should be step 2", step2, steps[2]);
   
  -        activity.clear();
  +        activity.clearSteps();
           assertNull("firstStep should be null", activity.getFirstStep());
           assertNull("lastStep should be null", activity.getLastStep());
           steps = activity.getSteps();
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message