View Javadoc

1   /*
2    * Copyright 2007-2010 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kew.actions;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import org.kuali.rice.kew.engine.RouteContext;
22  import org.kuali.rice.kew.engine.RouteHelper;
23  import org.kuali.rice.kew.engine.node.SplitNode;
24  import org.kuali.rice.kew.engine.node.SplitResult;
25  
26  /**
27   * This is a test split class that always returns "False". 
28   * 
29   * @author Kuali Rice Team (rice.collab@kuali.org)
30   *
31   */
32  public class SimpleBooleanSplitNode implements SplitNode {
33  	 private static org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory.getLog(SimpleBooleanSplitNode.class);
34  
35  	    /**
36  	     * This method will look up the document being routed, if it is an instance of ResearchDocumentBase
37  	     * it will call answerSplitNodeQuestion on it passing the name of the route node.  The default implementation (currently)
38  	     * throws an UnsupportedOperationException for any input. If one wishes to support the SplitNode for a given document, the
39  	     * method should be overridden and return boolean T/F based on which of the branches ( always names "True" and "False" ) 
40  	     * KEW should route to based upon the name of the split node.
41  	     * 
42  	     * @see org.kuali.rice.kew.engine.node.SimpleNode#process(org.kuali.rice.kew.engine.RouteContext, org.kuali.rice.kew.engine.RouteHelper)
43  	     */
44  	    
45  	    public SplitResult process(RouteContext context, RouteHelper helper ) throws Exception {
46  	       return this.booleanToSplitResult(false);
47  	    }
48  	    
49  	    
50  	    /**
51  	     * Converts a boolean value to SplitResult where the branch name is "True" or "False" based on the value of the given boolean
52  	     * @param b a boolean to convert to a SplitResult
53  	     * @return the converted SplitResult
54  	     */
55  	    protected SplitResult booleanToSplitResult(boolean b) {
56  	        List<String> branches = new ArrayList<String>();
57  	        final String branchName = b ? "True" : "False";
58  	        branches.add(branchName);
59  	        return new SplitResult(branches);
60  	    }
61  
62  }