org.kuali.rice.kew.rule.xmlrouting
Class StandardGenericXMLRuleAttribute

java.lang.Object
  extended by org.kuali.rice.kew.rule.xmlrouting.StandardGenericXMLRuleAttribute
All Implemented Interfaces:
Serializable, WorkflowAttributeXmlValidator, WorkflowRuleAttribute, XmlConfiguredAttribute, GenericXMLRuleAttribute
Direct Known Subclasses:
KualiXmlRuleAttributeImpl

public class StandardGenericXMLRuleAttribute
extends Object
implements GenericXMLRuleAttribute, WorkflowAttributeXmlValidator

A generic WorkflowAttribute implementation that can be defined completely by XML.

  1. This attribute implementation takes "properties" defined on the the WorkflowAttributeDefinition and maps them to the param map of GenericXMLRuleAttribute, which relate directly to a set of fields defined by the XML <routingConfig> configuration.
  2. Application of the properties defined on the WorkflowAttributeDefinition to the actual attribute is performed in ObjectDefinitionResolver.invokeProperties(Object, java.util.Collection)
  3. These params are then used to perform one of either EITHER: Currently, only parameters that match fields configured in the routingConfig are honored (the others are ignored) (NOTE: to make this even more reusable we might want to consider generating content for all parameters, even those that do not have corresponding fields)
  4. The routingConfig element defines a set of fieldDefs, each of which may have an xpathexpression for field evaluation. This xpathexpression is used to determine whether the attribute's isMatch(DocumentContent, List) will succeed. Each fieldDef may also have a validation element which supplies a regular expression against which to validate the field value (given by the param map)

Author:
Kuali Rice Team (rice.collab@kuali.org)
See Also:
Serialized Form

Constructor Summary
StandardGenericXMLRuleAttribute()
           
 
Method Summary
protected  List<String> extractExpressionsToEvaluate(XPath xpath, DocumentContent docContent, List<RuleExtension> ruleExtensions)
          Extracts the xPath expressions that should be evaluated in order to determine whether or not the rule matches.
 Element getConfigXML()
           
 String getDocContent()
          Returns a String containing this Attribute's routingData values, formatted as a series of XML tags.
 Map getParamMap()
           
 List getRoutingDataRows()
          RoutingDataRows contain Rows describing the UI-level presentation of the ruleData fields used to determine where a given document would be routed according to the associated rule.
 List getRuleExtensionValues()
          Returns the List of RuleExtensionValue objects associated with this Rule, each of which contains the name and value of one of the parameters used by this Attribute to control when the associated Rule gets evaluated.
 List getRuleRows()
          Each Row contains Fields describing the UI-level presentation of a single RuleExtensionValue.
 boolean isEvaluateForMissingExtensions()
           
 boolean isMatch(DocumentContent docContent, List<RuleExtension> ruleExtensions)
          Returns true if this Attribute finds a match in the given DocContent.
 boolean isRequired()
          Returns true if the extensionValues on this Attribute must be filled in before the associated Rule can be persisted.
 void setEvaluateForMissingExtensions(boolean evaluateForMissingExtensions)
          Sets whether or not to evaluate expressions if the extension corresponding to that expressions is not present on the rule.
 void setExtensionDefinition(ExtensionDefinition extensionDefinition)
           
 void setParamMap(Map paramMap)
           
 void setRequired(boolean required)
          Sets the required flag for this Attribute to true.
 List<? extends RemotableAttributeErrorContract> validateClientRoutingData()
          called after client has set properties on the attribute for 'xmlizing'.
 List<RemotableAttributeError> validateRoutingData(Map paramMap)
          Validates routingData values in the incoming map.
 List<WorkflowServiceError> validateRuleData(Map paramMap)
          Validates ruleExtension values in the incoming map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StandardGenericXMLRuleAttribute

public StandardGenericXMLRuleAttribute()
Method Detail

setExtensionDefinition

public void setExtensionDefinition(ExtensionDefinition extensionDefinition)
Specified by:
setExtensionDefinition in interface XmlConfiguredAttribute

isMatch

public boolean isMatch(DocumentContent docContent,
                       List<RuleExtension> ruleExtensions)
Description copied from interface: WorkflowRuleAttribute
Returns true if this Attribute finds a match in the given DocContent. If true, the associated document will be routed to the users specifed by the UNF The isMatch method is responsible for determining whether content in a document matches content saved in workflow, thus determining whether to fire a rule or not. The isMatch method takes a DocumentContent object and a list of rule extension objects and returns a Boolean. The DocumentContent object contains the data in XML format that will be compared with the rules saved in workflow. Rule extension objects come from a potential rule that may match the document content on this eDoc. The potential rule is selected based on the Document Type and Rule Templates associated with this eDoc. Each rule extension object contains a list of rule extension value objects which have the data we will use in key value format to compare to the document content. The key will be determined by a unique string assigned by this attribute. The Value is determined when a rule is created and data is entered for the particular key. If a match is found, this method returns true and the eDoc will be routed based on this rule. If no match is found, the method returns false and the eDoc will not be routed based on this rule.

Specified by:
isMatch in interface WorkflowRuleAttribute

extractExpressionsToEvaluate

protected List<String> extractExpressionsToEvaluate(XPath xpath,
                                                    DocumentContent docContent,
                                                    List<RuleExtension> ruleExtensions)
Extracts the xPath expressions that should be evaluated in order to determine whether or not the rule matches. THis should take into account the value of evaluateForMissingExtensions.


getRuleRows

public List getRuleRows()
Description copied from interface: WorkflowRuleAttribute
Each Row contains Fields describing the UI-level presentation of a single RuleExtensionValue.

A single Row may contain more than one actual Field instance, but Fields beyond the first one are there to provide context for the display and evaluation of the first one.

The getRuleRows method returns a list of rows that contain Fields describing the UI-level presentation of a single RuleExtensionValue for the creation of a rule. A single row may contain more than one actual Field object, but Fields beyond the first one are there to provide context for the display and evaluation of the first one. For example, a secondary field may be a lookupable or a searchable valid values object. An individual field consists of a field label, a field help url, a field type, whether a lookupable is associated with this field, a property name, a property value, valid values, the name of the lookupable, and the default lookupable name for this field. The field label is a short title that will display on the jsp describing what data to enter for this field. The field help url is optional, but will pop open in a new window the url entered. The field type is the type of field to display (e.g. hidden, text, drop down, radio, quickfinder (lookupable), lookup result only (this type is needed for the lookupable, but does not actually render on the jsp), and finally drop down refresh (this type is a drop down box that when it's value changes another drop down box's valid values will be changed as well)). The lookupable indicator determines whether this field will have a lookupable (valid value search) associated with it. The property name is the name of the field when rendered on the jsp. This needs to be unique when compared to other field names on the jsp. The property value is the value entered into the text box or other field type on the jsp. This value will be empty when creating the field and populated during form submission. A List of valid values is optional and needed to populate drop down boxes or radio buttons. This list consists of KeyValue objects which the key will be the value passed in on submission and the label will be what is display on the jsp. The lookupable is the name of the lookable service to be called for this field. The default lookupable name is the name of the field on the lookupable itself. This may be the same of the property name of the field. This is needed when field conversions are needed. If the lookupable returns a key that doesn't match a property name on the jsp it needs to be converted to one that does. So if the property name is different than the default lookupable name, the lookupable will convert the return key to the property name of the field. Example: say by default a lookupable returns "color=red" on the url. The default lookupable name would be "color" and if you needed a different name for this property on the jsp such as "wallcolor", the lookupable will now return "wallcolor=red" instead of the default "color=red". The default lookupable name also is the key for rule extension values. When an extension value is saved the value comes from the UI and the key from this field. If this field is left null, then the property name of the field will become the key stored in the database for the extension value. A row can also consist of a group label and number of rows for this label to span for this attribute. If a group label is present, it will display on the rule creation jsp and group together the individual rows for this attribute. The total rows number will rowspan the group label across the rows of this attribute. NOTE: the group label and number of rows to span must be specified on each row object for the display to work correctly.

Additionally, it is very important that the List of Row objects is reconstructed every time getRuleRows is called. This is because the code which processes these Rows will set the propertyValue directly on the Field objects contained within. Essentially, this means the Rows and Fields should not be constructed once inside of the attribute and cached statically, but instead be recreated each time this method is called.

Specified by:
getRuleRows in interface WorkflowRuleAttribute

getRoutingDataRows

public List getRoutingDataRows()
Description copied from interface: WorkflowRuleAttribute
RoutingDataRows contain Rows describing the UI-level presentation of the ruleData fields used to determine where a given document would be routed according to the associated rule.

The getRoutingDataRows method returns a list of rows that contain Fields describing the UI-level presentation of a single RuleExtensionValue for the routing report feature. These rows are used to determine where an eDoc would route if these values were entered. They are constructed the same way rule rows are described above and a lot of times are identical.

Additionally, it is very important that the List of Row objects is reconstructed every time getRoutingDataRows is called. This is because the code which processes these Rows will set the propertyValue directly on the Field objects contained within. Essentially, this means the Rows and Fields should not be constructed once inside of the attribute and cached statically, but instead be recreated each time this method is called.

Specified by:
getRoutingDataRows in interface WorkflowRuleAttribute

getDocContent

public String getDocContent()
Description copied from interface: WorkflowRuleAttribute
Returns a String containing this Attribute's routingData values, formatted as a series of XML tags. The returned tags need not be contained within a single top-level tag.

For example, DollarRangeAttribute returns a single tag containing its totalDollarAmount, thus:

 <totalDollarAmount>345</totalDollarAmount>
 

Specified by:
getDocContent in interface WorkflowRuleAttribute

getRuleExtensionValues

public List getRuleExtensionValues()
Description copied from interface: WorkflowRuleAttribute
Returns the List of RuleExtensionValue objects associated with this Rule, each of which contains the name and value of one of the parameters used by this Attribute to control when the associated Rule gets evaluated. RuleExtensionValues are assigned when the Rule is created.

For example, the DollarRangeAttribute has two associated RuleExtensionValues - its minimum and maximum values - which control when a rule containing that attribute gets evaluated.

The UI instantiates a Rule from a RuleTemplate, uses the RuleRows of all of that Rule's Attributes to build a form, uses user input to create a set of RuleExtensionValues which get persisted when the rule is persisted. To create a RuleExtensionValue object, instantiate a new object, set the key which will be located on the Rule's attribute, set the value which will be entered on the form from the UI side, and finally add each RuleExtensionValue object to a list. (Basically, given a configured/initialized attribute, marshalls out the RuleExtensionValues representing the current state of the attribute - Aaron Hamid FIXME)

Specified by:
getRuleExtensionValues in interface WorkflowRuleAttribute

validateRoutingData

public List<RemotableAttributeError> validateRoutingData(Map paramMap)
Description copied from interface: WorkflowRuleAttribute
Validates routingData values in the incoming map. Called by the UI during rule creation. This method is responsible for validating and setting the data entered on the form from the UI of the routing report to the Rule's attribute. The values will be in a Map with the key being the key of the RuleExtensionValue and the value being the value of the data entered from the UI. This method is used for the routing report which may have different fields than the rule data.

Specified by:
validateRoutingData in interface WorkflowRuleAttribute
Parameters:
paramMap - Map containing the names and values of the routing data for this Attribute

validateRuleData

public List<WorkflowServiceError> validateRuleData(Map paramMap)
Description copied from interface: WorkflowRuleAttribute
Validates ruleExtension values in the incoming map. Called by the UI during rule creation. This method is responsible for validating and setting the data entered on the form from the UI of the rule creation to the Rule's attribute. The values will be in a Map with the key being the key of the RuleExtensionValue and the value being the value of the data entered from the UI. This method is used for rule creation which may have different fields than the routing report data.

Specified by:
validateRuleData in interface WorkflowRuleAttribute
Parameters:
paramMap - Map containing the names and values of the rule extensions for this Attribute

setRequired

public void setRequired(boolean required)
Description copied from interface: WorkflowRuleAttribute
Sets the required flag for this Attribute to true. If required is true, the extensionValues for this Attribute must be filled in before the associated Rule can be persisted. This method sets a flag on whether this attribute is required or not. When a rule template is created, the rule's attribute can be required. This setting is then passed to the attribute by this method and can be used by the validateRuleData or validateRoutingData method as fit.

Specified by:
setRequired in interface WorkflowRuleAttribute

isRequired

public boolean isRequired()
Description copied from interface: WorkflowRuleAttribute
Returns true if the extensionValues on this Attribute must be filled in before the associated Rule can be persisted.

Specified by:
isRequired in interface WorkflowRuleAttribute

getConfigXML

public Element getConfigXML()

validateClientRoutingData

public List<? extends RemotableAttributeErrorContract> validateClientRoutingData()
Description copied from interface: WorkflowAttributeXmlValidator
called after client has set properties on the attribute for 'xmlizing'. Returns

Specified by:
validateClientRoutingData in interface WorkflowAttributeXmlValidator
Returns:
List objects

getParamMap

public Map getParamMap()
Specified by:
getParamMap in interface GenericXMLRuleAttribute

setParamMap

public void setParamMap(Map paramMap)
Specified by:
setParamMap in interface GenericXMLRuleAttribute

isEvaluateForMissingExtensions

public boolean isEvaluateForMissingExtensions()
Returns:
the evaluateForMissingExtensions

setEvaluateForMissingExtensions

public void setEvaluateForMissingExtensions(boolean evaluateForMissingExtensions)
Sets whether or not to evaluate expressions if the extension corresponding to that expressions is not present on the rule. The correspondence is made by comparing the name of the field declared on the fieldDef element and the name of the rule extension key. If this value is set to true then all xpath expressions defined on all fieldDefs will be evaluated regardless of whether or not the rule has a corresponding extension value.

By default this is false to preserve backward compatible behavior.



Copyright © 2005-2012 The Kuali Foundation. All Rights Reserved.