001    /**
002     * Copyright 2005-2011 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.rice.kew.actions;
017    
018    import java.util.ArrayList;
019    import java.util.List;
020    
021    import org.kuali.rice.kew.engine.RouteContext;
022    import org.kuali.rice.kew.engine.RouteHelper;
023    import org.kuali.rice.kew.engine.node.SplitNode;
024    import org.kuali.rice.kew.engine.node.SplitResult;
025    
026    /**
027     * This is a test split class that always returns "False". 
028     * 
029     * @author Kuali Rice Team (rice.collab@kuali.org)
030     *
031     */
032    public class SimpleBooleanSplitNode implements SplitNode {
033             private static org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory.getLog(SimpleBooleanSplitNode.class);
034    
035                /**
036                 * This method will look up the document being routed, if it is an instance of ResearchDocumentBase
037                 * it will call answerSplitNodeQuestion on it passing the name of the route node.  The default implementation (currently)
038                 * throws an UnsupportedOperationException for any input. If one wishes to support the SplitNode for a given document, the
039                 * method should be overridden and return boolean T/F based on which of the branches ( always names "True" and "False" ) 
040                 * KEW should route to based upon the name of the split node.
041                 * 
042                 * @see org.kuali.rice.kew.engine.node.SimpleNode#process(org.kuali.rice.kew.engine.RouteContext, org.kuali.rice.kew.engine.RouteHelper)
043                 */
044                
045                public SplitResult process(RouteContext context, RouteHelper helper ) throws Exception {
046                   return this.booleanToSplitResult(false);
047                }
048                
049                
050                /**
051                 * Converts a boolean value to SplitResult where the branch name is "True" or "False" based on the value of the given boolean
052                 * @param b a boolean to convert to a SplitResult
053                 * @return the converted SplitResult
054                 */
055                protected SplitResult booleanToSplitResult(boolean b) {
056                    List<String> branches = new ArrayList<String>();
057                    final String branchName = b ? "True" : "False";
058                    branches.add(branchName);
059                    return new SplitResult(branches);
060                }
061    
062    }