001/**
002 * Copyright 2005-2017 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 */
016package org.kuali.rice.kew.engine.node.hierarchyrouting;
017
018import java.util.List;
019
020import org.kuali.rice.kew.engine.RouteContext;
021import org.kuali.rice.kew.engine.node.RouteNode;
022import org.kuali.rice.kew.engine.node.RouteNodeInstance;
023
024
025/**
026 * HierarchyProvider is responsible for exposing the hierarchy that the HierarchyRoutingNode
027 * climbs/descends.
028 * @author Kuali Rice Team (rice.collab@kuali.org)
029 */
030public interface HierarchyProvider {
031    /**
032     * Marker interface for objects the represent a "stop" or "node" in a hierarchy.
033     * E.g. "unit"
034     */
035    public interface Stop { }
036
037    /**
038     * Initializer for the hierarchy provider.
039     * @param nodeInstance the HierarchyRouteNode instance
040     * @param context the RouteContext (nodeInstance may NOT be the HierarchyRouteNode instance; e.g. when transitioning into)
041     */
042    public void init(RouteNodeInstance nodeInstance, RouteContext context);
043    
044    /**
045     * Find all leaf stops in the xml and convert them into a list of Stop objects
046     * @param context the RouteContext
047     * @return List Stop objects
048     */
049    public List<Stop> getLeafStops(RouteContext context);
050
051    /**
052     * @param nodeInstance the node instance
053     * @return whether stop state is associated with the specified node instance
054     */
055    public boolean hasStop(RouteNodeInstance nodeInstance);
056
057    /**
058     * Returns the Stop at the specified routeNodeInstance, or null if the node instance
059     * is not associated with a Stop
060     * @param nodeInstance the node instance to check
061     * @return the Stop at the route node instance
062     */
063    public Stop getStop(RouteNodeInstance nodeInstance);
064
065    /**
066     * Set any state necessary on the request node instance for a given stop.  E.g. for chart/org routing
067     * set the org and chart in the node state
068     * @param requestNodeInstance the request node instance
069     * @param stop the stop for the request node
070     */
071    public void setStop(RouteNodeInstance requestNodeInstance, Stop stop);
072
073    /**
074     * @param stop the stop
075     * @return a a string that can be used to uniquely identify the stop.  E.g. for chart/org routing,
076     * the chart and org
077     */
078    public String getStopIdentifier(Stop stop);
079
080    /**
081     * @param stopId the stop identifier
082     * @return the Stop by stop identifier
083     */
084    public Stop getStopByIdentifier(String stopId);
085    
086
087    /**
088     * @param stop a stop
089     * @return the parent stop of the specified stop
090     */
091    public Stop getParent(Stop stop);
092
093    /**
094     * @param stop the stop
095     * @return whether the given stop is the root stop, i.e. has no parents
096     */
097    public boolean isRoot(Stop stop);
098    
099    /**
100     * @param a one stop
101     * @param b another stop
102     * @return whether stops are equivalent
103     */
104    public boolean equals(Stop a, Stop b);
105
106    /**
107     * Configures the single request node definition/prototype used for all node instances
108     * @param hiearchyNodeInstance the hierarchy node instance
109     * @param node the request node definition/prototype
110     */
111    public void configureRequestNode(RouteNodeInstance hiearchyNodeInstance, RouteNode node);
112}