Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2005-2013 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 package org.kuali.rice.kew.routemodule;
 import java.util.List;

A RouteModule that generates requests for responsibilities statically defined in the config block of the node.

Kuali Rice Team (
 public class InlineRequestsRouteModule extends FlexRMAdapter {
     private static final Logger LOG = Logger.getLogger(InlineRequestsRouteModule.class);

This overridden method is used to decipher the inline xpath and responsibilities of a route node definition and use them to create action reqeusts

     public List<ActionRequestValuefindActionRequests(RouteContext contextthrows Exception {
         // comment this out while implementing the meta-rules stuff
         // re-implement later
         List<ActionRequestValueactionRequests = new ArrayList<ActionRequestValue>();
         RouteNodeInstance currentNode = context.getNodeInstance();
         String contentFragment = currentNode.getRouteNode().getContentFragment();
         // parse with JDOM to reuse RuleXmlParser
         Document doc = XmlHelper.trimSAXXml(new ByteArrayInputStream(contentFragment.getBytes()));
         Element root = doc.getRootElement();
         List<StringruleAttributeNames = new ArrayList<String>();
         List<StringruleAttributeClassNames = new ArrayList<String>();
         List<StringxpathExpressions = new ArrayList<String>();
         // get the list of ruleAttributes to use
         Element ruleAttributes = root.getChild("ruleAttributes");
         if (ruleAttributes != null) {
             for (Object o : ruleAttributes.getChildren("name")) {
                 Element e = (Elemento;
             for (Object o : ruleAttributes.getChildren("className")) {
                 Element e = (Elemento;
         // get the list of xpath expressions to verify
         for (Object oroot.getChildren("match")) {
             Element e = (Elemento;
         if ( (ruleAttributeNames.isEmpty()) && (ruleAttributeClassNames.isEmpty()) && (xpathExpressions.isEmpty()) ) {
             throw new RuntimeException("Match xpath expression not specified (should be parse-time exception...)");
         List<WorkflowRuleAttributeattributes = new ArrayList<WorkflowRuleAttribute>();
        for (String attributeName : ruleAttributeNames) {
        for (String attributeClassName : ruleAttributeClassNames) {
        // at this point if we have no xpath expressions or attributes we cannot match
        if (attributes.isEmpty() && xpathExpressions.isEmpty()) {
            return actionRequests;
        Boolean match = .;
        if (!xpathExpressions.isEmpty()) {
            XPath xpath = XPathHelper.newXPath();
            for (String xpathExpression : xpathExpressions) {
                match &= (Booleanxpath.evaluate(xpathExpressioncontext.getDocumentContent().getDocument(), .);
        for (WorkflowRuleAttribute workflowAttribute : attributes) {
            // no rule extensions to pass in below because we have no rule... simple attribute matching only
            match &= workflowAttribute.isMatch(context.getDocumentContent(), Collections.<RuleExtension>emptyList());
        if (match.booleanValue()) {
//            LOG.debug("Expression '" + xpathExpression + "' matched document '" + context.getDocumentContent().getDocContent() + "'");
        } else {
            // return an empty list because we didn't find a match using the given xpath
//            LOG.debug("Expression '" + xpathExpression + "' did NOT match document '" + context.getDocumentContent().getDocContent() + "'");
            return actionRequests;
        RuleXmlParser parser = new RuleXmlParser();
        ActionRequestFactory arf = new ActionRequestFactory(context.getDocument(), currentNode);
        // this rule is only used to obtain description, forceAction flag, and the rulebasevalues id, which may be null
        RuleBaseValues fakeRule = new RuleBaseValues();
        fakeRule.setDescription("a fake rule");
        for (Object oroot.getChildren("responsibility".)) {
            Element e = (Elemento;
            RuleResponsibilityBo responsibility = parser.parseResponsibility(efakeRule);
        if (responsibilities.isEmpty()) {
            throw new RuntimeException("No responsibilities found on node " + currentNode.getName());
        makeActionRequests(arfresponsibilitiescontext,, context.getDocument(), nullnull);
        return actionRequests;
    public String toString() {
        return "InlineRequestsRouteModule";
    private WorkflowRuleAttribute getRuleAttributeByName(String ruleAttributeName) {
        return materializeRuleAttribute(KewApiServiceLocator.getExtensionRepositoryService().getExtensionByName(
    private List<WorkflowRuleAttributegetRuleAttributeByClassName(String ruleAttributeClassName) {
        List<ExtensionDefinitionextensionDefinitions = 
        List<WorkflowRuleAttributeworkflowRuleAttributes = new ArrayList<WorkflowRuleAttribute>();
        for (ExtensionDefinition extension : extensionDefinitions) {
        return workflowRuleAttributes;
    private WorkflowRuleAttribute materializeRuleAttribute(ExtensionDefinition extensionDefinition) {
        if (extensionDefinition != null) {
            if (..equals(extensionDefinition.getType())) {
                ObjectDefinition objDef = new ObjectDefinition(extensionDefinition.getResourceDescriptor(), extensionDefinition.getApplicationId());
                return (WorkflowRuleAttribute) GlobalResourceLoader.getObject(objDef);
            } else if (..equals(extensionDefinition.getType())) {
                ObjectDefinition objDef = new ObjectDefinition(extensionDefinition.getResourceDescriptor(), extensionDefinition.getApplicationId());
                WorkflowRuleAttribute workflowAttribute = (WorkflowRuleAttribute) GlobalResourceLoader.getObject(objDef);
                //required to make it work because ruleAttribute XML is required to construct custom columns
                return workflowAttribute;
        return null;
New to GrepCode? Check out our FAQ X