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 http://www.opensource.org/licenses/ecl2.php 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.impl.rule.attribute;
 
 
 import java.util.List;
 import java.util.Map;

Reference implementation of WorkflowRuleAttributeHandlerService.

Author(s):
Kuali Rice Team (rice.collab@kuali.org)
 
 
 
     @Override
     public WorkflowRuleAttributeFields getRuleFields(Map<StringStringparameters,
                                                      ExtensionDefinition extensionDefinition,
                                                      boolean required)
             throws RiceIllegalArgumentException {
         if (parameters == null) {
             parameters = new HashMap<StringString>();
         }
         WorkflowRuleAttribute attribute = loadAttribute(extensionDefinition);
         attribute.setRequired(required);
         List<RemotableAttributeErrorerrors = attribute.validateRuleData(parameters);
         List<RemotableAttributeFieldfields = FieldUtils.convertRowsToAttributeFields(attribute.getRuleRows());
         List<RuleExtensionValueruleExtensionValues = attribute.getRuleExtensionValues();
         Map<StringStringruleExtensionValuesMap = new HashMap<StringString>();
         for (RuleExtensionValue ruleExtensionValue : ruleExtensionValues) {
             ruleExtensionValuesMap.put(ruleExtensionValue.getKey(), ruleExtensionValue.getValue());
         }
         return WorkflowRuleAttributeFields.create(errorsfieldsruleExtensionValuesMap);
     }
 
     @Override
                                                        ExtensionDefinition extensionDefinition,
                                                        boolean required)
             throws RiceIllegalArgumentException {
         if (parameters == null) {
             parameters = new HashMap<StringString>();
         }
         WorkflowRuleAttribute attribute = loadAttribute(extensionDefinition);
         attribute.setRequired(required);
         List<RemotableAttributeErrorerrors;
         List<RowsearchRows;
         if (attribute instanceof WorkflowRuleSearchAttribute) {
             errors = ((WorkflowRuleSearchAttribute)attribute).validateSearchData(parameters);
             searchRows = ((WorkflowRuleSearchAttribute)attribute).getSearchRows();
         } else {
             errors = attribute.validateRuleData(parameters);
             searchRows = attribute.getRuleRows();
         }
         List<RemotableAttributeFieldfields = FieldUtils.convertRowsToAttributeFields(searchRows);
         List<RuleExtensionValueruleExtensionValues = attribute.getRuleExtensionValues();
         Map<StringStringruleExtensionValuesMap = new HashMap<StringString>();
         for (RuleExtensionValue ruleExtensionValue : ruleExtensionValues) {
             ruleExtensionValuesMap.put(ruleExtensionValue.getKey(), ruleExtensionValue.getValue());
         }
         return WorkflowRuleAttributeFields.create(errorsfieldsruleExtensionValuesMap);
    }
    @Override
                                                    ExtensionDefinition extensionDefinition,
                                                    boolean required)
          throws RiceIllegalArgumentException {
        if (parameters == null) {
            parameters = new HashMap<StringString>();
        }
        WorkflowRuleAttribute attribute = loadAttribute(extensionDefinition);
        attribute.setRequired(required);
        List<RemotableAttributeErrorallErrors = attribute.validateRoutingData(parameters);
        List<RemotableAttributeErrorruleDataErrors = attribute.validateRuleData(parameters);
        for (RemotableAttributeError error : ruleDataErrors) {
            allErrors.add(error);
        }
        List<RemotableAttributeFieldfields = FieldUtils.convertRowsToAttributeFields(attribute.getRoutingDataRows());
        List<RuleExtensionValueruleExtensionValues = attribute.getRuleExtensionValues();
        Map<StringStringruleExtensionValuesMap = new HashMap<StringString>();
        for (RuleExtensionValue ruleExtensionValue : ruleExtensionValues) {
            ruleExtensionValuesMap.put(ruleExtensionValue.getKey(), ruleExtensionValue.getValue());
        }
        return WorkflowRuleAttributeFields.create(allErrorsfieldsruleExtensionValuesMap);
    }
    
    @Override
    public List<RoleNamegetRoleNames(ExtensionDefinition extensionDefinition) {
        WorkflowRuleAttribute attribute = loadAttribute(extensionDefinition);
        if (attribute instanceof RoleAttribute) {
            RoleAttribute roleAttribute = (RoleAttributeattribute;
            List<RoleNameroleNames = roleAttribute.getRoleNames();
            if (CollectionUtils.isNotEmpty(roleNames)) {
                return ModelObjectUtils.createImmutableCopy(roleNames);
            }
      	}
        return Collections.emptyList();
    }
    private WorkflowRuleAttribute loadAttribute(ExtensionDefinition extensionDefinition) {
        if (extensionDefinition == null) {
            throw new RiceIllegalArgumentException("extensionDefinition was null or blank");
        }
        Object attribute = ExtensionUtils.loadExtension(extensionDefinition);
        if (attribute == null) {
            throw new RiceIllegalArgumentException("Failed to load WorkflowRuleAttribute for: " + extensionDefinition);
        }
        if (!WorkflowRuleAttribute.class.isAssignableFrom(attribute.getClass())) {
            throw new RiceIllegalArgumentException("Failed to locate a WorkflowRuleAttribute with the given name: " + extensionDefinition.getName());
        }
        if (attribute instanceof XmlConfiguredAttribute) {
            ((XmlConfiguredAttributeattribute).setExtensionDefinition(extensionDefinition);
        }
        return (WorkflowRuleAttributeattribute;
    }
        return ;
    }
    public void setExtensionRepositoryService(ExtensionRepositoryService extensionRepositoryService) {
        this. = extensionRepositoryService;
    }
New to GrepCode? Check out our FAQ X