View Javadoc
1   /**
2    * Copyright 2005-2015 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.engine.node;
17  
18  import java.util.Collection;
19  
20  /**
21   * The criteria defining parameters to a search through a document's node graph.
22   *
23   * @author Kuali Rice Team (rice.collab@kuali.org)
24   */
25  public class NodeGraphSearchCriteria {
26  
27  	// search directions
28  	public static final int SEARCH_DIRECTION_FORWARD = 1;
29  	public static final int SEARCH_DIRECTION_BACKWARD = 2;
30  	public static final int SEARCH_DIRECTION_BOTH = 3;
31  	
32  	private int searchDirection = SEARCH_DIRECTION_FORWARD;
33  	private Collection startingNodeInstances;
34  	private NodeMatcher matcher;
35  	
36  	public NodeGraphSearchCriteria(int searchDirection, Collection startingNodeInstances, NodeMatcher matcher) {
37  		if (startingNodeInstances == null || startingNodeInstances.isEmpty()) {
38  			throw new IllegalArgumentException("Starting node instances were empty.  At least one starting node instance must be specified in order to perform a search.");
39  		}
40  		this.searchDirection = searchDirection;
41  		this.startingNodeInstances = startingNodeInstances;
42  		this.matcher = matcher;
43  	}
44  	
45  	public NodeGraphSearchCriteria(int searchDirection, Collection startingNodeInstances, String nodeName) {
46  		this(searchDirection, startingNodeInstances, new NodeNameMatcher(nodeName));
47  	}
48  
49  	public NodeMatcher getMatcher() {
50  		return matcher;
51  	}
52  
53  	public Collection getStartingNodeInstances() {
54  		return startingNodeInstances;
55  	}
56  	
57  	public int getSearchDirection() {
58  		return searchDirection;
59  	}
60  	
61  }