Coverage Report - org.kuali.rice.kew.service.impl.DocumentTypeResponsibilityTypeServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
DocumentTypeResponsibilityTypeServiceImpl
0%
0/20
0%
0/14
4.5
 
 1  
 /*
 2  
  * Copyright 2007-2009 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.service.impl;
 17  
 
 18  
 import java.util.ArrayList;
 19  
 import java.util.HashMap;
 20  
 import java.util.List;
 21  
 import java.util.Map;
 22  
 
 23  
 import org.kuali.rice.kew.doctype.service.DocumentTypeService;
 24  
 import org.kuali.rice.kew.service.KEWServiceLocator;
 25  
 import org.kuali.rice.kim.bo.impl.KimAttributes;
 26  
 import org.kuali.rice.kim.bo.role.dto.KimResponsibilityInfo;
 27  
 import org.kuali.rice.kim.bo.types.dto.AttributeSet;
 28  
 import org.kuali.rice.kim.service.support.KimResponsibilityTypeService;
 29  
 import org.kuali.rice.kim.service.support.impl.KimResponsibilityTypeServiceBase;
 30  
 import org.kuali.rice.kim.util.KimCommonUtils;
 31  
 
 32  
 /**
 33  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 34  
  */
 35  0
 public class DocumentTypeResponsibilityTypeServiceImpl extends
 36  
                 KimResponsibilityTypeServiceBase implements KimResponsibilityTypeService {
 37  
         DocumentTypeService documentTypeService;
 38  
         protected String exactMatchStringAttributeName;
 39  
 
 40  
         {
 41  0
                 requiredAttributes.add( KimAttributes.DOCUMENT_TYPE_NAME );
 42  0
                 checkRequiredAttributes = true;
 43  0
         }
 44  
         
 45  
         @Override
 46  
         protected List<KimResponsibilityInfo> performResponsibilityMatches(
 47  
                         AttributeSet requestedDetails,
 48  
                         List<KimResponsibilityInfo> responsibilitiesList) {
 49  0
                 Map<String, List<KimResponsibilityInfo>> potentialDocumentTypeMatches = new HashMap<String, List<KimResponsibilityInfo>>();
 50  0
                 for (KimResponsibilityInfo responsibility : responsibilitiesList) {
 51  0
                         if ((exactMatchStringAttributeName == null)
 52  
                                         || responsibility
 53  
                                                         .getDetails()
 54  
                                                         .get(exactMatchStringAttributeName)
 55  
                                                         .equals(
 56  
                                                                         requestedDetails
 57  
                                                                                         .get(exactMatchStringAttributeName))) {
 58  0
                                 if (!potentialDocumentTypeMatches.containsKey(responsibility
 59  
                                                 .getDetails().get(KimAttributes.DOCUMENT_TYPE_NAME))) {
 60  0
                                         potentialDocumentTypeMatches.put(
 61  
                                                         responsibility.getDetails().get(
 62  
                                                                         KimAttributes.DOCUMENT_TYPE_NAME),
 63  
                                                         new ArrayList<KimResponsibilityInfo>());
 64  
                                 }
 65  0
                                 potentialDocumentTypeMatches.get(
 66  
                                                 responsibility.getDetails().get(
 67  
                                                                 KimAttributes.DOCUMENT_TYPE_NAME)).add(
 68  
                                                 responsibility);
 69  
                         }
 70  
                 }
 71  0
                 List<KimResponsibilityInfo> matchingResponsibilities = new ArrayList<KimResponsibilityInfo>();
 72  0
                 if (potentialDocumentTypeMatches.containsKey(requestedDetails
 73  
                                 .get(KimAttributes.DOCUMENT_TYPE_NAME))) {
 74  0
                         matchingResponsibilities
 75  
                                         .addAll(potentialDocumentTypeMatches.get(requestedDetails
 76  
                                                         .get(KimAttributes.DOCUMENT_TYPE_NAME)));
 77  
                 } else {
 78  0
                         String closestParentDocumentTypeName = KimCommonUtils.getClosestParentDocumentTypeName(
 79  
                                         getDocumentTypeService().findByName(
 80  
                                                         requestedDetails
 81  
                                                                         .get(KimAttributes.DOCUMENT_TYPE_NAME)),
 82  
                                         potentialDocumentTypeMatches.keySet());
 83  0
                         if (closestParentDocumentTypeName != null) {
 84  0
                                 matchingResponsibilities.addAll(potentialDocumentTypeMatches
 85  
                                                 .get(closestParentDocumentTypeName));
 86  
                         }
 87  
                 }
 88  0
                 return matchingResponsibilities;
 89  
         }
 90  
 
 91  
         public DocumentTypeService getDocumentTypeService() {
 92  0
                 if (documentTypeService == null) {
 93  0
                         documentTypeService = KEWServiceLocator.getDocumentTypeService();
 94  
                 }
 95  0
                 return this.documentTypeService;
 96  
         }
 97  
 }