Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
HierarchicalNamedRuleSelector |
|
| 3.0;3 |
1 | /* | |
2 | * Copyright 2007-2008 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.rule; | |
17 | ||
18 | import org.apache.log4j.Logger; | |
19 | import org.kuali.rice.kew.engine.RouteContext; | |
20 | import org.kuali.rice.kew.engine.node.RouteNodeInstance; | |
21 | import org.kuali.rice.kew.engine.node.hierarchyrouting.HierarchyRoutingNode; | |
22 | import org.kuali.rice.kew.exception.WorkflowException; | |
23 | import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue; | |
24 | import org.kuali.rice.kew.util.Utilities; | |
25 | ||
26 | import java.sql.Timestamp; | |
27 | import java.util.Map; | |
28 | ||
29 | ||
30 | /** | |
31 | * Derives the rule name to select based on node instance state configured by a governing | |
32 | * HierarchyRoutingNode and the HierarchyRoutingNode name. E.g.: | |
33 | * <pre> | |
34 | * <dynamic name="hierarchy"> | |
35 | * <type>org.kuali.rice.kew.engine.node.hierarchyrouting.HierarchyRoutingNode</type> | |
36 | * <hierarchyProvider>org.kuali.rice.kew.engine.node.hierarchyrouting.SimpleHierarchyProvider</hierarchyProvider> | |
37 | * <ruleSelector>HierarchicalNamed</ruleSelector> | |
38 | * </dynamic> | |
39 | * </pre> | |
40 | * If <code>org.kuali.rice.kew.engine.node.hierarchyrouting.SimpleHierarchyProvider</code> supplied stops named 'a', 'b', and 'c', the rules | |
41 | * selected would be 'hierarchy-a', 'hierarchy-b', and 'hierarchy-c', respectively. | |
42 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
43 | */ | |
44 | 0 | public class HierarchicalNamedRuleSelector extends NamedRuleSelector { |
45 | 0 | private static final Logger LOG = Logger.getLogger(HierarchicalNamedRuleSelector.class); |
46 | @Override | |
47 | protected String getName(RouteContext context, DocumentRouteHeaderValue routeHeader, RouteNodeInstance nodeInstance, | |
48 | String selectionCriterion, Timestamp effectiveDate) throws WorkflowException { | |
49 | 0 | Map<String, String> cfgMap = Utilities.getKeyValueCollectionAsMap(nodeInstance.getState()); |
50 | 0 | String stop_id = cfgMap.get(HierarchyRoutingNode.STOP_ID); |
51 | 0 | if (stop_id == null) { |
52 | 0 | LOG.warn("STOP ID from nodeInstance was NULL: " + nodeInstance); |
53 | 0 | return null; |
54 | } | |
55 | 0 | LOG.info("STOP ID from nodeInstance: " + nodeInstance.getRouteNodeInstanceId() + ": " + stop_id); |
56 | 0 | return nodeInstance.getProcess().getRouteNode().getRouteNodeName() + "-" + stop_id; |
57 | } | |
58 | } |