Coverage Report - org.kuali.rice.kew.impl.actionlist.ActionListServiceNewImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
ActionListServiceNewImpl
0%
0/27
0%
0/14
2.8
 
 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 org.apache.commons.lang.StringUtils;
 19  
 import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
 20  
 import org.kuali.rice.kew.api.action.ActionItem;
 21  
 import org.kuali.rice.kew.api.actionlist.ActionListService;
 22  
 import org.kuali.rice.kew.service.KEWServiceLocator;
 23  
 
 24  
 import java.util.ArrayList;
 25  
 import java.util.Collection;
 26  
 import java.util.List;
 27  
 
 28  
 /**
 29  
  * Reference implementation of the {@link org.kuali.rice.kew.api.actionlist.ActionListService} api.
 30  
  *
 31  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 32  
  *
 33  
  */
 34  0
 public class ActionListServiceNewImpl implements ActionListService {
 35  
 
 36  
     @Override
 37  
     public Integer getUserActionItemCount(String principalId) {
 38  0
         incomingParamCheck(principalId, "principalId");
 39  0
         return Integer.valueOf(KEWServiceLocator.getActionListService().getCount(principalId));
 40  
     }
 41  
 
 42  
     @Override
 43  
     public List<ActionItem> getActionItemsForPrincipal(String principalId) {
 44  0
         incomingParamCheck(principalId, "principalId");
 45  0
         Collection<org.kuali.rice.kew.actionitem.ActionItem> actionItems
 46  
                 = KEWServiceLocator.getActionListService().getActionList(principalId, null);
 47  0
         List<ActionItem> actionItemVOs = new ArrayList<ActionItem>(actionItems.size());
 48  0
         for (org.kuali.rice.kew.actionitem.ActionItem actionItem : actionItems) {
 49  0
             actionItemVOs.add(org.kuali.rice.kew.actionitem.ActionItem.to(actionItem));
 50  
         }
 51  0
         return actionItemVOs;
 52  
     }
 53  
 
 54  
     @Override
 55  
     public List<ActionItem> getAllActionItems(String documentId) {
 56  0
         incomingParamCheck(documentId, "documentId");
 57  0
         Collection<org.kuali.rice.kew.actionitem.ActionItem> actionItems
 58  
                 = KEWServiceLocator.getActionListService().getActionListForSingleDocument(documentId);
 59  0
         List<ActionItem> actionItemVOs = new ArrayList<ActionItem>(actionItems.size());
 60  0
         for (org.kuali.rice.kew.actionitem.ActionItem actionItem : actionItems) {
 61  0
             actionItemVOs.add(org.kuali.rice.kew.actionitem.ActionItem.to(actionItem));
 62  
         }
 63  0
         return actionItemVOs;
 64  
     }
 65  
 
 66  
     @Override
 67  
     public List<ActionItem> getActionItems(String documentId, List<String> actionRequestedCodes) {
 68  0
         incomingParamCheck(documentId, "documentId");
 69  0
         List<ActionItem> actionItems = getAllActionItems(documentId);
 70  0
         List<ActionItem> matchingActionitems = new ArrayList<ActionItem>();
 71  0
         for (ActionItem actionItemVO : actionItems) {
 72  0
             if (actionRequestedCodes.contains(actionItemVO.getActionRequestCd())) {
 73  0
                 matchingActionitems.add(actionItemVO);
 74  
             }
 75  
         }
 76  0
         return matchingActionitems;
 77  
     }
 78  
 
 79  
     private void incomingParamCheck(Object object, String name) {
 80  0
         if (object == null) {
 81  0
             throw new RiceIllegalArgumentException(name + " was null");
 82  0
         } else if (object instanceof String
 83  
                 && StringUtils.isBlank((String) object)) {
 84  0
             throw new RiceIllegalArgumentException(name + " was blank");
 85  
         }
 86  0
     }
 87  
 }