001    /*
002     * Copyright 2005-2008 The Kuali Foundation
003     * 
004     * 
005     * Licensed under the Educational Community License, Version 2.0 (the "License");
006     * you may not use this file except in compliance with the License.
007     * You may obtain a copy of the License at
008     * 
009     * http://www.opensource.org/licenses/ecl2.php
010     * 
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    package org.kuali.rice.kew.engine.node;
018    
019    import java.util.Collection;
020    
021    /**
022     * The criteria defining parameters to a search through a document's node graph.
023     *
024     * @author Kuali Rice Team (rice.collab@kuali.org)
025     */
026    public class NodeGraphSearchCriteria {
027    
028            // search directions
029            public static final int SEARCH_DIRECTION_FORWARD = 1;
030            public static final int SEARCH_DIRECTION_BACKWARD = 2;
031            public static final int SEARCH_DIRECTION_BOTH = 3;
032            
033            private int searchDirection = SEARCH_DIRECTION_FORWARD;
034            private Collection startingNodeInstances;
035            private NodeMatcher matcher;
036            
037            public NodeGraphSearchCriteria(int searchDirection, Collection startingNodeInstances, NodeMatcher matcher) {
038                    if (startingNodeInstances == null || startingNodeInstances.isEmpty()) {
039                            throw new IllegalArgumentException("Starting node instances were empty.  At least one starting node instance must be specified in order to perform a search.");
040                    }
041                    this.searchDirection = searchDirection;
042                    this.startingNodeInstances = startingNodeInstances;
043                    this.matcher = matcher;
044            }
045            
046            public NodeGraphSearchCriteria(int searchDirection, Collection startingNodeInstances, String nodeName) {
047                    this(searchDirection, startingNodeInstances, new NodeNameMatcher(nodeName));
048            }
049    
050            public NodeMatcher getMatcher() {
051                    return matcher;
052            }
053    
054            public Collection getStartingNodeInstances() {
055                    return startingNodeInstances;
056            }
057            
058            public int getSearchDirection() {
059                    return searchDirection;
060            }
061            
062    }