Coverage Report - org.kuali.rice.kew.impl.actionlist.ActionListCustomizationHandlerServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
ActionListCustomizationHandlerServiceImpl
0%
0/26
0%
0/10
3.25
 
 1  
 /**
 2  
  * Copyright 2005-2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.kew.impl.actionlist;
 17  
 
 18  
 import java.util.ArrayList;
 19  
 import java.util.Collections;
 20  
 import java.util.List;
 21  
 
 22  
 import org.apache.commons.lang.StringUtils;
 23  
 import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
 24  
 import org.kuali.rice.kew.actionlist.CustomActionListAttribute;
 25  
 import org.kuali.rice.kew.api.action.ActionItem;
 26  
 import org.kuali.rice.kew.api.action.ActionItemCustomization;
 27  
 import org.kuali.rice.kew.api.extension.ExtensionDefinition;
 28  
 import org.kuali.rice.kew.api.extension.ExtensionRepositoryService;
 29  
 import org.kuali.rice.kew.api.extension.ExtensionUtils;
 30  
 import org.kuali.rice.kew.framework.actionlist.ActionListCustomizationHandlerService;
 31  
 
 32  
 /**
 33  
  * Reference implementation of the ActionListCustomizationHandlerService.
 34  
  * 
 35  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 36  
  */
 37  0
 public class ActionListCustomizationHandlerServiceImpl implements ActionListCustomizationHandlerService {
 38  
 
 39  0
     private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ActionListCustomizationHandlerServiceImpl.class);
 40  
             
 41  
     private ExtensionRepositoryService extensionRepositoryService;
 42  
     
 43  
     @Override
 44  
     public List<ActionItemCustomization> customizeActionList(String principalId, List<ActionItem> actionItems)
 45  
             throws RiceIllegalArgumentException {
 46  0
         if (StringUtils.isBlank(principalId)) {
 47  0
             throw new RiceIllegalArgumentException("principalId was null or blank");
 48  
         }
 49  0
         if (actionItems == null) {
 50  0
             actionItems = Collections.emptyList();
 51  
         }
 52  0
         List<ActionItemCustomization> actionItemCustomizations = new ArrayList<ActionItemCustomization>();
 53  
         // TODO Iterate through the list of Action Items. Return Action Item Customizations only for those Action Items which...    
 54  0
         for (ActionItem actionItem : actionItems) {
 55  
             // TODO Figure out how to properly load a CAL Attribute 
 56  
             // Load the CustomActionListAttribute
 57  0
             CustomActionListAttribute customActionListAttribute = loadAttribute("attributeName?");
 58  
             // Build the list of ActionItemCustomizations
 59  
             ActionItemCustomization actionItemCustomization;
 60  
             try {
 61  0
                 actionItemCustomization = ActionItemCustomization.Builder.create(customActionListAttribute.getLegalActions(principalId, actionItem), customActionListAttribute.getDocHandlerDisplayParameters(principalId, actionItem)).build();
 62  0
                 actionItemCustomizations.add(actionItemCustomization);
 63  0
             } catch (Exception e) {
 64  
                 // TODO give a better message like attribute name or something
 65  0
                 LOG.error("Problem loading custom action list attribute", e);
 66  0
             }           
 67  0
         }
 68  0
         return actionItemCustomizations;
 69  
     }
 70  
 
 71  
     /**
 72  
      * Loads CustomActionListAttribute implementation class via {@link ExtensionRepositoryService}
 73  
      * @param attributeName the CustomActionListAttribute name
 74  
      * @return instance of the CustomActionListAttribute implementation class
 75  
      * @throws RiceIllegalArgumentException if specified attribute name cannot be found or loaded
 76  
      */
 77  
     protected CustomActionListAttribute loadAttribute(String attributeName) {
 78  0
         ExtensionDefinition extensionDefinition = extensionRepositoryService.getExtensionByName(attributeName);
 79  0
         if (extensionDefinition == null) {
 80  0
             throw new RiceIllegalArgumentException("Failed to locate a CustomActionListAttribute with the given name: " + attributeName);
 81  
         }
 82  
         
 83  0
         CustomActionListAttribute customActionListAttribute = ExtensionUtils.loadExtension(extensionDefinition);
 84  0
         if (customActionListAttribute == null) {
 85  0
             throw new RiceIllegalArgumentException("Failed to load CustomActionListAttribute for: " + extensionDefinition);
 86  
         }
 87  0
         return (CustomActionListAttribute)customActionListAttribute;
 88  
     }
 89  
     
 90  
     /**
 91  
      * Loads RuleValidationAttribute implementation class via {@link ExtensionRepositoryService}
 92  
      * @param attributeName the RuleValidationAttribute name
 93  
      * @return instance of the RuleValidationAttribute implementation class
 94  
      * @throws RiceIllegalArgumentException if specified attribute name cannot be found or loaded
 95  
      */
 96  
 
 97  
     public ExtensionRepositoryService getExtensionRepositoryService() {
 98  0
         return extensionRepositoryService;
 99  
     }
 100  
 
 101  
     public void setExtensionRepositoryService(ExtensionRepositoryService extensionRepositoryService) {
 102  0
         this.extensionRepositoryService = extensionRepositoryService;
 103  0
     }
 104  
 }