001/**
002 * Copyright 2005-2016 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.rule;
017
018import org.kuali.rice.kew.api.rule.RoleName;
019import org.kuali.rice.kew.api.rule.RuleTemplateAttribute;
020import org.kuali.rice.kew.rule.bo.RuleTemplateAttributeBo;
021
022import java.util.List;
023import java.util.Map;
024
025/**
026 * Handles communication between {@link org.kuali.rice.kew.framework.rule.attribute.WorkflowRuleAttributeHandlerService}
027 * endpoints in order to invoke {@link WorkflowRuleAttribute} code which might be hosted from various applications.
028 *
029 * @author Kuali Rice Team (rice.collab@kuali.org)
030 */
031public interface WorkflowRuleAttributeMediator {
032
033    /**
034     * Returns rule row configuration for the workflow rule attribute defined on the given RuleTemplateAttribute. These
035     * are the rows which show up on the rule and rule delegation maintenance screen when creating or editing a rule
036     * or rule delegation which uses the given attribute, as well as on the inquiry for the rule.
037     *
038     * <p>Will use the supplied parameters to populate the WorkflowRuleAttribute by running the validateRuleData method
039     * on that attribute. The result of this call contains any validation errors, the Row objects as constructed by the
040     * attribute, and the final values for the rule extensions after validation and processing has been executed.</p>
041     *
042     * @param parameters a map of parameters to pass to the backend WorkflowRuleAttribute for validation, may be null or
043     *                   an empty map
044     * @param ruleTemplateAttribute the RuleTemplateAttribute which defines the ExtensionDefinition for the
045     *                              WorkflowRuleAttribute against which to validate and retrieve the rows, as well as
046     *                              the required flag which should be passed to the attribute
047     *
048     * @return the result of validating and retrieving rule rows, will never return null
049     */
050    WorkflowRuleAttributeRows getRuleRows(Map<String, String> parameters, RuleTemplateAttribute ruleTemplateAttribute);
051
052    /**
053     * Equivalent to {@link #getRuleRows(java.util.Map, org.kuali.rice.kew.rule.bo.RuleTemplateAttributeBo)} but takes
054     * a {@link RuleTemplateAttributeBo} instead of a {@link RuleTemplateAttribute}. Exists primarily for convenience of
055     * the calling code.
056     */
057    WorkflowRuleAttributeRows getRuleRows(Map<String, String> parameters, RuleTemplateAttributeBo ruleTemplateAttribute);
058
059    /**
060     * Returns rule attribute row configuration for the workflow rule attribute defined on the given RuleTemplateAttribute.
061     * These are the rows which show up on the Routing Report screen when using a RuleTemplate which includes the 
062     * given RuleTemplateAttribute.
063     *
064     * <p>Will use the supplied parameters to populate the WorkflowRuleAttribute by running the validateRoutingData method
065     * on that attribute.  The result of this call contains any validation errors, the Row objects as constructed by the
066     * attribute, and the final values for the rule extensions after validation and processing has been executed.</p>
067     *
068     * @param parameters a map of parameters to pass to the backend WorkflowRuleAttribute for validation, may be null or
069     *                   an empty map
070     * @param ruleTemplateAttribute the RuleTemplateAttribute which defines the ExtensionDefinition for the
071     *                              WorkflowRuleAttribute against which to validate and retrieve the search rows, as
072     *                              well as the required flag which should be passed to the attribute
073     *
074     * @return the result of validating and retrieving rule search rows, will never return null
075     */
076    WorkflowRuleAttributeRows getRoutingDataRows(Map<String, String> parameters, RuleTemplateAttribute ruleTemplateAttribute);
077
078    /**
079     * Equivalent to {@link #getRoutingDataRows(java.util.Map, org.kuali.rice.kew.rule.bo.RuleTemplateAttributeBo)} but takes
080     * a {@link RuleTemplateAttributeBo} instead of a {@link RuleTemplateAttribute}. Exists primarily for convenience of
081     * the calling code.
082     */
083    WorkflowRuleAttributeRows getRoutingDataRows(Map<String, String> parameters, RuleTemplateAttributeBo ruleTemplateAttribute);
084
085    /**
086     * Returns rule search row configuration for the workflow rule attribute defined on the given RuleTemplateAttribute.
087     * These are the rows which show up on the rule and rule delegation lookup screen when searching for rules
088     * or rule delegations using a RuleTemplate which includes the given RuleTemplateAttribute.
089     *
090     * <p>Will use the supplied parameters to populate the WorkflowRuleAttribute by running the validateRuleData method
091     * on that attribute (or if the attribute implements WorkflowRuleSearchAttribute, will execute validateSearchData).
092     * The result of this call contains any validation errors, the Row objects as constructed by the attribute, and the
093     * final values for the rule extensions after validation and processing has been executed.</p>
094     *
095     * @param parameters a map of parameters to pass to the backend WorkflowRuleAttribute for validation, may be null or
096     *                   an empty map
097     * @param ruleTemplateAttribute the RuleTemplateAttribute which defines the ExtensionDefinition for the
098     *                              WorkflowRuleAttribute against which to validate and retrieve the search rows, as
099     *                              well as the required flag which should be passed to the attribute
100     *
101     * @return the result of validating and retrieving rule search rows, will never return null
102     */
103    WorkflowRuleAttributeRows getSearchRows(Map<String, String> parameters, RuleTemplateAttribute ruleTemplateAttribute);
104
105    /**
106     * Equivalent to call {@link #getSearchRows(java.util.Map, org.kuali.rice.kew.api.rule.RuleTemplateAttribute)} but
107     * passes a custom value for the required flag that is passed to the attribute instead of using the one defined by
108     * the given {@link org.kuali.rice.kew.api.rule.RuleTemplateAttribute#isRequired()}. The main use case for this
109     * is in the case of a lookup where it's desirable to disable required validation for search fields that have not
110     * been filled in (in that case a value of "false" would be passed as the last argument to this method).
111     */
112    WorkflowRuleAttributeRows getSearchRows(Map<String, String> parameters, RuleTemplateAttribute ruleTemplateAttribute, boolean required);
113
114    /**
115     * Returns the list of role names as defined on the {@link RoleAttribute} defined by the given rule template
116     * attribute. In this case that the defined rule template attribute does not represent a role attribute or does
117     * not return any role names, this method will return an empty list.
118     *
119     * @param ruleTemplateAttribute the RuleTemplateAttribute which defines the ExtensionDefinition for the
120     *                              RoleAttribute from which to fetch the role names
121     *
122     * @retun the list of role names from the attribute, or an empty list if none are defined, will never return null
123     */
124    List<RoleName> getRoleNames(RuleTemplateAttributeBo ruleTemplateAttribute);
125
126}
127
128