Coverage Report - org.kuali.rice.kim.document.IdentityManagementKimDocument
 
Classes in this File Line Coverage Branch Coverage Complexity
IdentityManagementKimDocument
0%
0/45
0%
0/18
2
 
 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.kim.document;
 17  
 
 18  
 import java.util.List;
 19  
 
 20  
 import org.apache.log4j.Logger;
 21  
 import org.kuali.rice.kew.util.KEWConstants;
 22  
 import org.kuali.rice.kim.bo.ui.RoleDocumentDelegation;
 23  
 import org.kuali.rice.kim.bo.ui.RoleDocumentDelegationMember;
 24  
 import org.kuali.rice.kim.util.KimConstants;
 25  
 import org.kuali.rice.kns.datadictionary.AttributeDefinition;
 26  
 import org.kuali.rice.kns.datadictionary.KimDataDictionaryAttributeDefinition;
 27  
 import org.kuali.rice.kns.datadictionary.KimNonDataDictionaryAttributeDefinition;
 28  
 import org.kuali.rice.kns.document.TransactionalDocumentBase;
 29  
 import org.kuali.rice.kns.service.KNSServiceLocator;
 30  
 import org.kuali.rice.kns.service.SequenceAccessorService;
 31  
 import org.kuali.rice.kns.util.TypedArrayList;
 32  
 
 33  
 /**
 34  
  * This is a description of what this class does - bhargavp don't forget to fill this in. 
 35  
  * 
 36  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 37  
  *
 38  
  */
 39  0
 public class IdentityManagementKimDocument extends TransactionalDocumentBase {
 40  
 
 41  0
         protected static final Logger LOG = Logger.getLogger(IdentityManagementKimDocument.class);
 42  
         
 43  0
         protected List<RoleDocumentDelegation> delegations = new TypedArrayList(RoleDocumentDelegation.class);
 44  0
         protected List<RoleDocumentDelegationMember> delegationMembers = new TypedArrayList(RoleDocumentDelegationMember.class);
 45  
 
 46  
         protected transient SequenceAccessorService sequenceAccessorService;
 47  
         
 48  
         protected void addDelegationMemberToDelegation(RoleDocumentDelegationMember delegationMember){
 49  
                 RoleDocumentDelegation delegation;
 50  0
                 if(KEWConstants.DELEGATION_PRIMARY.equals(delegationMember.getDelegationTypeCode())){
 51  0
                         delegation = getPrimaryDelegation();
 52  
                 } else{
 53  0
                         delegation = getSecondaryDelegation();
 54  
                 }
 55  0
                 delegationMember.setDelegationId(delegation.getDelegationId());
 56  0
                 delegation.getMembers().add(delegationMember);
 57  0
                 delegation.setRoleId(delegationMember.getRoleImpl().getRoleId());
 58  0
                 delegation.setKimTypeId(delegationMember.getRoleImpl().getKimTypeId());
 59  0
         }
 60  
 
 61  
         protected RoleDocumentDelegation getPrimaryDelegation(){
 62  0
                 RoleDocumentDelegation primaryDelegation = null;
 63  0
                 for(RoleDocumentDelegation delegation: getDelegations()){
 64  0
                         if(delegation.isDelegationPrimary())
 65  0
                                 primaryDelegation = delegation;
 66  
                 }
 67  0
                 if(primaryDelegation==null){
 68  0
                         primaryDelegation = new RoleDocumentDelegation();
 69  0
                         primaryDelegation.setDelegationId(getDelegationId());
 70  0
                         primaryDelegation.setDelegationTypeCode(KEWConstants.DELEGATION_PRIMARY);
 71  0
                         getDelegations().add(primaryDelegation);
 72  
                 }
 73  0
                 return primaryDelegation;
 74  
         }
 75  
 
 76  
         protected String getDelegationId(){
 77  0
                 return getSequenceAccessorService().getNextAvailableSequenceNumber(KimConstants.SequenceNames.KRIM_DLGN_ID_S).toString();
 78  
         }
 79  
         
 80  
         protected RoleDocumentDelegation getSecondaryDelegation(){
 81  0
                 RoleDocumentDelegation secondaryDelegation = null;
 82  0
                 for(RoleDocumentDelegation delegation: getDelegations()){
 83  0
                         if(delegation.isDelegationSecondary())
 84  0
                                 secondaryDelegation = delegation;
 85  
                 }
 86  0
                 if(secondaryDelegation==null){
 87  0
                         secondaryDelegation = new RoleDocumentDelegation();
 88  0
                         secondaryDelegation.setDelegationId(getDelegationId());
 89  0
                         secondaryDelegation.setDelegationTypeCode(KEWConstants.DELEGATION_SECONDARY);
 90  0
                         getDelegations().add(secondaryDelegation);
 91  
                 }
 92  0
                 return secondaryDelegation;
 93  
         }
 94  
 
 95  
         /**
 96  
          * @return the delegations
 97  
          */
 98  
         public List<RoleDocumentDelegation> getDelegations() {
 99  0
                 return this.delegations;
 100  
         }
 101  
 
 102  
         /**
 103  
          * @param delegations the delegations to set
 104  
          */
 105  
         public void setDelegations(List<RoleDocumentDelegation> delegations) {
 106  0
                 this.delegations = delegations;
 107  0
         }
 108  
 
 109  
         /**
 110  
          * @return the delegationMembers
 111  
          */
 112  
         public List<RoleDocumentDelegationMember> getDelegationMembers() {
 113  0
                 return this.delegationMembers;
 114  
         }
 115  
 
 116  
         /**
 117  
          * @param delegationMembers the delegationMembers to set
 118  
          */
 119  
         public void setDelegationMembers(
 120  
                         List<RoleDocumentDelegationMember> delegationMembers) {
 121  0
                 this.delegationMembers = delegationMembers;
 122  0
         }
 123  
         
 124  
         protected SequenceAccessorService getSequenceAccessorService(){
 125  0
                 if(this.sequenceAccessorService==null){
 126  0
                     this.sequenceAccessorService = KNSServiceLocator.getSequenceAccessorService();
 127  
                 }
 128  0
                 return this.sequenceAccessorService;
 129  
         }
 130  
 
 131  
     public String getKimAttributeDefnId(AttributeDefinition definition){
 132  0
             if (definition instanceof KimDataDictionaryAttributeDefinition) {
 133  0
                     return ((KimDataDictionaryAttributeDefinition)definition).getKimAttrDefnId();
 134  
             } else {
 135  0
                     return ((KimNonDataDictionaryAttributeDefinition)definition).getKimAttrDefnId();
 136  
             }
 137  
     }
 138  
 
 139  
 }