Coverage Report - org.kuali.rice.kim.dao.impl.KimRoleDaoOjb
 
Classes in this File Line Coverage Branch Coverage Complexity
KimRoleDaoOjb
0%
0/428
0%
0/318
5.969
 
 1  
 /*
 2  
  * Copyright 2007-2008 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.dao.impl;
 17  
 
 18  
 import org.apache.commons.collections.CollectionUtils;
 19  
 import org.apache.commons.lang.StringUtils;
 20  
 import org.apache.ojb.broker.query.Criteria;
 21  
 import org.apache.ojb.broker.query.Query;
 22  
 import org.apache.ojb.broker.query.QueryFactory;
 23  
 import org.apache.ojb.broker.query.ReportQueryByCriteria;
 24  
 import org.kuali.rice.core.api.criteria.Predicate;
 25  
 import org.kuali.rice.core.api.criteria.QueryByCriteria;
 26  
 import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
 27  
 import org.kuali.rice.core.util.AttributeSet;
 28  
 import org.kuali.rice.kim.api.entity.principal.Principal;
 29  
 import org.kuali.rice.kim.api.group.GroupMember;
 30  
 import org.kuali.rice.kim.api.responsibility.Responsibility;
 31  
 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
 32  
 import org.kuali.rice.kim.bo.Role;
 33  
 
 34  
 import org.kuali.rice.kim.bo.entity.dto.KimEntityDefaultInfo;
 35  
 import org.kuali.rice.kim.bo.impl.RoleImpl;
 36  
 import org.kuali.rice.kim.bo.role.dto.KimPermissionInfo;
 37  
 import org.kuali.rice.kim.bo.role.dto.RoleMemberCompleteInfo;
 38  
 import org.kuali.rice.kim.bo.role.dto.RoleMembershipInfo;
 39  
 import org.kuali.rice.kim.bo.role.impl.KimDelegationImpl;
 40  
 import org.kuali.rice.kim.bo.role.impl.KimDelegationMemberImpl;
 41  
 import org.kuali.rice.kim.bo.role.impl.RoleMemberAttributeDataImpl;
 42  
 import org.kuali.rice.kim.bo.role.impl.RoleMemberImpl;
 43  
 import org.kuali.rice.kim.dao.KimRoleDao;
 44  
 import org.kuali.rice.kim.util.KIMPropertyConstants;
 45  
 import org.kuali.rice.kim.util.KimConstants;
 46  
 import static org.kuali.rice.core.api.criteria.PredicateFactory.*;
 47  
 
 48  
 import java.util.ArrayList;
 49  
 import java.util.Collection;
 50  
 import java.util.HashMap;
 51  
 import java.util.List;
 52  
 import java.util.Map;
 53  
 import java.util.Map.Entry;
 54  
 
 55  
 /**
 56  
  * This is a description of what this class does - jonathan don't forget to fill
 57  
  * this in.
 58  
  *
 59  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 60  
  *
 61  
  */
 62  0
 public class KimRoleDaoOjb extends PlatformAwareDaoBaseOjb implements KimRoleDao {
 63  
 
 64  
         /**
 65  
          * Adds SubCriteria to the Query Criteria using the role qualification passed in 
 66  
          * 
 67  
          * @param c The Query Criteria object to be used 
 68  
          * @param qualification The role qualification
 69  
          */
 70  
         private void addSubCriteriaBasedOnRoleQualification(Criteria c, AttributeSet qualification) {
 71  0
                 if(qualification != null && CollectionUtils.isNotEmpty(qualification.keySet())) {
 72  0
                         for(Map.Entry<String, String> qualifier : qualification.entrySet()) {
 73  0
                         Criteria subCrit = new Criteria();
 74  0
                         if(StringUtils.isNotEmpty(qualifier.getValue())) {
 75  0
                                         String value = (qualifier.getValue()).replace('*', '%');
 76  0
                                         subCrit.addLike("attributeValue", value);
 77  0
                                         subCrit.addEqualTo("kimAttributeId", qualifier.getKey());
 78  0
                                         ReportQueryByCriteria subQuery = QueryFactory.newReportQuery(RoleMemberAttributeDataImpl.class, subCrit);
 79  0
                                         c.addExists(subQuery);
 80  
                         }
 81  0
                         }
 82  
                 }
 83  0
         }
 84  
         
 85  
         /**
 86  
          * @see org.kuali.rice.kim.dao.KimRoleDao#getRolePrincipalsForPrincipalIdAndRoleIds(java.util.Collection,
 87  
          *      java.lang.String, org.kuali.rice.core.util.AttributeSet)
 88  
          */
 89  
         @SuppressWarnings("unchecked")
 90  
         public List<RoleMemberImpl> getRolePrincipalsForPrincipalIdAndRoleIds( Collection<String> roleIds, String principalId, AttributeSet qualification) {
 91  
 
 92  0
                 Criteria c = new Criteria();
 93  
 
 94  0
                 if ( roleIds != null ) {
 95  0
                         c.addIn(KIMPropertyConstants.RoleMember.ROLE_ID, roleIds);
 96  
                 }
 97  0
                 if(principalId!=null)
 98  0
                         c.addEqualTo(KIMPropertyConstants.RoleMember.MEMBER_ID, principalId);
 99  0
                 c.addEqualTo( KIMPropertyConstants.RoleMember.MEMBER_TYPE_CODE, Role.PRINCIPAL_MEMBER_TYPE );
 100  0
                 addSubCriteriaBasedOnRoleQualification(c, qualification);
 101  
                 
 102  0
                 Query query = QueryFactory.newQuery(RoleMemberImpl.class, c);
 103  0
                 Collection<RoleMemberImpl> coll = getPersistenceBrokerTemplate().getCollectionByQuery(query);
 104  0
                 ArrayList<RoleMemberImpl> results = new ArrayList<RoleMemberImpl>( coll.size() );
 105  0
                 for ( RoleMemberImpl rm : coll ) {
 106  0
                         if ( rm.isActive() ) {
 107  0
                                 results.add(rm);
 108  
                         }
 109  
                 }
 110  0
                 return results;
 111  
         }
 112  
 
 113  
         public List<GroupMember> getGroupPrincipalsForPrincipalIdAndGroupIds( Collection<String> groupIds, String principalId) {
 114  0
             List<String> groupIdValues = new ArrayList<String>();
 115  0
             List<GroupMember> groupPrincipals = new ArrayList<GroupMember>();
 116  0
             if (groupIds != null
 117  
                     && principalId == null) {
 118  0
                 groupIdValues = new ArrayList<String>(groupIds);
 119  0
             } else if (principalId != null) {
 120  0
                 groupIdValues = KimApiServiceLocator.getGroupService().getGroupIdsForPrincipal(principalId);
 121  
             }
 122  0
             if (groupIdValues != null
 123  
                     && groupIdValues.size() > 0) {
 124  0
                 Collection<GroupMember> groupMembershipInfos = KimApiServiceLocator.getGroupService().getMembers(groupIdValues);
 125  0
             for (GroupMember groupMembershipInfo : groupMembershipInfos) {
 126  0
                 if (principalId != null) {
 127  0
                     if (StringUtils.equals(groupMembershipInfo.getTypeCode(), Role.PRINCIPAL_MEMBER_TYPE)
 128  
                             && StringUtils.equals(principalId, groupMembershipInfo.getMemberId())
 129  
                             && groupMembershipInfo.isActive()) {
 130  0
                         groupPrincipals.add(groupMembershipInfo);
 131  
                     }
 132  
                 } else {
 133  0
                     groupPrincipals.add(groupMembershipInfo);
 134  
                 }
 135  
             }
 136  
             }
 137  0
             return groupPrincipals;
 138  
         }
 139  
 
 140  
         public List<GroupMember> getGroupMembers(Collection<String> groupIds) {
 141  0
             List<String> groupIdValues = new ArrayList<String>();
 142  0
             List<GroupMember> groupMembers = new ArrayList<GroupMember>();
 143  0
             if (groupIds != null) {
 144  0
                 groupIdValues = new ArrayList<String>(groupIds);
 145  
 
 146  0
                 if (groupIdValues != null
 147  
                         && groupIdValues.size() > 0) {
 148  0
                 Collection<GroupMember> groupMembershipInfos = KimApiServiceLocator.getGroupService().getMembers(groupIdValues);
 149  
                     //Collection<GroupMember> groupMembershipInfos = KimApiServiceLocator.getGroupService().g.getGroupMembers(groupIdValues);
 150  
 
 151  0
                 if (!CollectionUtils.isEmpty(groupMembershipInfos)) {
 152  0
                     for (GroupMember groupMembershipInfo : groupMembershipInfos) {
 153  0
                         if (StringUtils.equals(groupMembershipInfo.getTypeCode(), Role.GROUP_MEMBER_TYPE)
 154  
                                 && groupMembershipInfo.isActive()) {
 155  0
                             groupMembers.add(groupMembershipInfo);
 156  
                         }
 157  
                     }
 158  
                     }
 159  
                 }
 160  
             }
 161  0
             return groupMembers;
 162  
         }
 163  
 
 164  
         /**
 165  
          * @see org.kuali.rice.kim.dao.KimRoleDao#getRoleGroupsForGroupIdsAndRoleIds(java.util.Collection,
 166  
          *      java.util.Collection, org.kuali.rice.core.util.AttributeSet)
 167  
          */
 168  
         @SuppressWarnings("unchecked")
 169  
         public List<RoleMemberImpl> getRoleGroupsForGroupIdsAndRoleIds( Collection<String> roleIds, Collection<String> groupIds, AttributeSet qualification ) {
 170  0
                 Criteria c = new Criteria();
 171  0
                 if(roleIds!=null && !roleIds.isEmpty())
 172  0
                         c.addIn(KIMPropertyConstants.RoleMember.ROLE_ID, roleIds);
 173  0
                 if(groupIds!=null && !groupIds.isEmpty())
 174  0
                         c.addIn(KIMPropertyConstants.RoleMember.MEMBER_ID, groupIds);
 175  0
                 c.addEqualTo( KIMPropertyConstants.RoleMember.MEMBER_TYPE_CODE, Role.GROUP_MEMBER_TYPE );
 176  0
                 addSubCriteriaBasedOnRoleQualification(c, qualification);
 177  
                 
 178  0
                 Query query = QueryFactory.newQuery(RoleMemberImpl.class, c);
 179  0
                 Collection<RoleMemberImpl> coll = getPersistenceBrokerTemplate().getCollectionByQuery(query);
 180  0
                 ArrayList<RoleMemberImpl> results = new ArrayList<RoleMemberImpl>( coll.size() );
 181  0
                 for ( RoleMemberImpl rm : coll ) {
 182  0
                         if ( rm.isActive() ) {
 183  0
                                 results.add(rm);
 184  
                         }
 185  
                 }
 186  0
                 return results;
 187  
         }
 188  
 
 189  
         @SuppressWarnings("unchecked")
 190  
         public Map<String,KimDelegationImpl> getDelegationImplMapFromRoleIds(Collection<String> roleIds) {
 191  0
                 HashMap<String,KimDelegationImpl> results = new HashMap<String, KimDelegationImpl>();
 192  0
                 if ( roleIds != null && !roleIds.isEmpty() ) {
 193  0
                         Criteria c = new Criteria();
 194  0
                         c.addIn(KIMPropertyConstants.Delegation.ROLE_ID, roleIds);
 195  0
                         c.addEqualTo(KIMPropertyConstants.Delegation.ACTIVE, Boolean.TRUE);
 196  0
                         Query query = QueryFactory.newQuery(KimDelegationImpl.class, c);
 197  0
                         Collection<KimDelegationImpl> coll = getPersistenceBrokerTemplate().getCollectionByQuery(query);
 198  0
                         for ( KimDelegationImpl dele : coll ) {
 199  0
                                 results.put( dele.getDelegationId(), dele);
 200  
                         }
 201  
                 }
 202  0
                 return results;
 203  
         }
 204  
 
 205  
         @SuppressWarnings("unchecked")
 206  
         public List<KimDelegationImpl> getDelegationImplsForRoleIds(Collection<String> roleIds) {
 207  0
                 List<KimDelegationImpl> results = new ArrayList<KimDelegationImpl>();
 208  0
                 if ( roleIds != null && !roleIds.isEmpty() ) {
 209  0
                         Criteria c = new Criteria();
 210  0
                         c.addIn(KIMPropertyConstants.Delegation.ROLE_ID, roleIds);
 211  0
                         c.addEqualTo(KIMPropertyConstants.Delegation.ACTIVE, Boolean.TRUE);
 212  0
                         Query query = QueryFactory.newQuery(KimDelegationImpl.class, c);
 213  0
                         Collection<KimDelegationImpl> coll = getPersistenceBrokerTemplate().getCollectionByQuery(query);
 214  0
                         for ( KimDelegationImpl dele : coll ) {
 215  0
                                 results.add(dele);
 216  
                         }
 217  
                 }
 218  0
                 return results;
 219  
         }
 220  
 
 221  
         /**
 222  
          * This overridden method ...
 223  
          *
 224  
          * @see org.kuali.rice.kim.dao.KimRoleDao#getDelegationPrincipalsForPrincipalIdAndDelegationIds(java.util.Collection,
 225  
          *      java.lang.String)
 226  
          */
 227  
         @SuppressWarnings("unchecked")
 228  
         public List<KimDelegationMemberImpl> getDelegationPrincipalsForPrincipalIdAndDelegationIds(
 229  
                         Collection<String> delegationIds, String principalId) {
 230  0
                 Criteria c = new Criteria();
 231  
 
 232  0
                 if(principalId!=null)
 233  0
                         c.addEqualTo(KIMPropertyConstants.DelegationMember.MEMBER_ID, principalId);
 234  0
                 c.addEqualTo( KIMPropertyConstants.DelegationMember.MEMBER_TYPE_CODE, Role.PRINCIPAL_MEMBER_TYPE );
 235  0
                 if(delegationIds!=null && !delegationIds.isEmpty())
 236  0
                         c.addIn(KIMPropertyConstants.DelegationMember.DELEGATION_ID, delegationIds);
 237  0
                 Query query = QueryFactory.newQuery(KimDelegationMemberImpl.class, c);
 238  0
                 Collection<KimDelegationMemberImpl> coll = getPersistenceBrokerTemplate().getCollectionByQuery(query);
 239  0
                 ArrayList<KimDelegationMemberImpl> results = new ArrayList<KimDelegationMemberImpl>( coll.size() );
 240  0
                 for ( KimDelegationMemberImpl rm : coll ) {
 241  0
                         if ( rm.isActive() ) {
 242  0
                                 results.add(rm);
 243  
                         }
 244  
                 }
 245  0
                 return results;
 246  
         }
 247  
 
 248  
         /**
 249  
          * This overridden method ...
 250  
          *
 251  
          * @see org.kuali.rice.kim.dao.KimRoleDao#getDelegationGroupsForGroupIdsAndDelegationIds(java.util.Collection,
 252  
          *      java.util.List)
 253  
          */
 254  
         @SuppressWarnings("unchecked")
 255  
         public List<KimDelegationMemberImpl> getDelegationGroupsForGroupIdsAndDelegationIds(
 256  
                         Collection<String> delegationIds, List<String> groupIds) {
 257  0
                 Criteria c = new Criteria();
 258  0
                 if(delegationIds!=null && !delegationIds.isEmpty())
 259  0
                         c.addIn(KIMPropertyConstants.DelegationMember.DELEGATION_ID, delegationIds);
 260  0
                 if(groupIds!=null && !groupIds.isEmpty())
 261  0
                         c.addIn(KIMPropertyConstants.DelegationMember.MEMBER_ID, groupIds);
 262  0
                 c.addEqualTo( KIMPropertyConstants.DelegationMember.MEMBER_TYPE_CODE, Role.GROUP_MEMBER_TYPE );
 263  0
                 Query query = QueryFactory.newQuery(KimDelegationMemberImpl.class, c);
 264  0
                 Collection<KimDelegationMemberImpl> coll = getPersistenceBrokerTemplate().getCollectionByQuery(query);
 265  0
                 ArrayList<KimDelegationMemberImpl> results = new ArrayList<KimDelegationMemberImpl>( coll.size() );
 266  0
                 for ( KimDelegationMemberImpl rm : coll ) {
 267  0
                         if ( rm.isActive() ) {
 268  0
                                 results.add(rm);
 269  
                         }
 270  
                 }
 271  0
                 return results;
 272  
         }
 273  
 
 274  
         /**
 275  
          * @see org.kuali.rice.kim.dao.KimRoleDao#getRoleMembersForRoleIds(Collection, String, org.kuali.rice.core.util.AttributeSet)
 276  
          */
 277  
         @SuppressWarnings("unchecked")
 278  
         public List<RoleMemberImpl> getRoleMembersForRoleIds( Collection<String> roleIds, String memberTypeCode, AttributeSet qualification ) {
 279  0
                 Criteria c = new Criteria();
 280  
 
 281  0
                 if(roleIds!=null && !roleIds.isEmpty())
 282  0
                         c.addIn(KIMPropertyConstants.RoleMember.ROLE_ID, roleIds);
 283  0
                 if ( memberTypeCode != null ) {
 284  0
                         c.addEqualTo( KIMPropertyConstants.RoleMember.MEMBER_TYPE_CODE, memberTypeCode );
 285  
                 }
 286  0
                 addSubCriteriaBasedOnRoleQualification(c, qualification);
 287  
                 
 288  0
                 Query query = QueryFactory.newQuery(RoleMemberImpl.class, c);
 289  0
                 Collection<RoleMemberImpl> coll = getPersistenceBrokerTemplate().getCollectionByQuery(query);
 290  0
                 ArrayList<RoleMemberImpl> results = new ArrayList<RoleMemberImpl>( coll.size() );
 291  0
                 for ( RoleMemberImpl rm : coll ) {
 292  0
                         if ( rm.isActive() ) {
 293  0
                                 results.add(rm);
 294  
                         }
 295  
                 }
 296  0
                 return results;
 297  
         }
 298  
 
 299  
         /**
 300  
          * @see org.kuali.rice.kim.dao.KimRoleDao#getRoleMembersForRoleIds(Collection, String, org.kuali.rice.core.util.AttributeSet)
 301  
          */
 302  
         @SuppressWarnings("unchecked")
 303  
         public List<RoleMemberImpl> getRoleMembershipsForRoleIdsAsMembers( Collection<String> roleIds, AttributeSet qualification) {
 304  0
                 Criteria c = new Criteria();
 305  
 
 306  0
                 if(roleIds!=null && !roleIds.isEmpty())
 307  0
                         c.addIn(KIMPropertyConstants.RoleMember.MEMBER_ID, roleIds);
 308  0
                 c.addEqualTo( KIMPropertyConstants.RoleMember.MEMBER_TYPE_CODE, KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE);
 309  0
                 addSubCriteriaBasedOnRoleQualification(c, qualification);
 310  
                 
 311  0
                 Query query = QueryFactory.newQuery(RoleMemberImpl.class, c);
 312  0
                 Collection<RoleMemberImpl> coll = getPersistenceBrokerTemplate().getCollectionByQuery(query);
 313  0
                 ArrayList<RoleMemberImpl> results = new ArrayList<RoleMemberImpl>( coll.size() );
 314  0
                 for ( RoleMemberImpl rm : coll ) {
 315  0
                         if ( rm.isActive() ) {
 316  0
                                 results.add(rm);
 317  
                         }
 318  
                 }
 319  0
                 return results;
 320  
         }
 321  
         
 322  
         /**
 323  
          * @see org.kuali.rice.kim.dao.KimRoleDao#getRoleMembersForRoleIds(Collection, String, org.kuali.rice.core.util.AttributeSet)
 324  
          */
 325  
         @SuppressWarnings("unchecked")
 326  
         public List<RoleMemberImpl> getRoleMembershipsForMemberId(String memberType, String memberId, AttributeSet qualification) {
 327  0
                 Criteria c = new Criteria();
 328  0
                 List<RoleMemberImpl> parentRoleMembers = new ArrayList<RoleMemberImpl>();
 329  
 
 330  0
                 if(StringUtils.isEmpty(memberId)
 331  
                                 || StringUtils.isEmpty(memberType)) {
 332  0
                         return parentRoleMembers;
 333  
                 }
 334  
                 
 335  0
                 c.addEqualTo(KIMPropertyConstants.RoleMember.MEMBER_ID, memberId);
 336  0
                 c.addEqualTo( KIMPropertyConstants.RoleMember.MEMBER_TYPE_CODE, memberType);
 337  0
                 addSubCriteriaBasedOnRoleQualification(c, qualification);
 338  
                 
 339  0
                 Query query = QueryFactory.newQuery(RoleMemberImpl.class, c);
 340  0
                 Collection<RoleMemberImpl> coll = getPersistenceBrokerTemplate().getCollectionByQuery(query);
 341  0
                 ArrayList<RoleMemberImpl> results = new ArrayList<RoleMemberImpl>( coll.size() );
 342  0
                 for ( RoleMemberImpl rm : coll ) {
 343  0
                         if ( rm.isActive() ) {
 344  0
                                 results.add(rm);
 345  
                         }
 346  
                 }
 347  0
                 return results;
 348  
         }
 349  
 
 350  
         @SuppressWarnings("unchecked")
 351  
         public List<RoleMemberImpl> getRoleMembersForRoleIdsWithFilters( Collection<String> roleIds, String principalId, List<String> groupIds, AttributeSet qualification) {
 352  0
                 Criteria c = new Criteria();
 353  
 
 354  0
                 if(roleIds!=null && !roleIds.isEmpty())
 355  0
                         c.addIn(KIMPropertyConstants.RoleMember.ROLE_ID, roleIds);
 356  0
                 Criteria orSet = new Criteria();
 357  0
                 orSet.addEqualTo( KIMPropertyConstants.RoleMember.MEMBER_TYPE_CODE, Role.ROLE_MEMBER_TYPE );
 358  0
                 Criteria principalCheck = new Criteria();
 359  0
                 if(principalId!=null)
 360  0
                         principalCheck.addEqualTo(KIMPropertyConstants.RoleMember.MEMBER_ID, principalId);
 361  0
                 principalCheck.addEqualTo( KIMPropertyConstants.RoleMember.MEMBER_TYPE_CODE, Role.PRINCIPAL_MEMBER_TYPE );
 362  0
                 orSet.addOrCriteria( principalCheck );
 363  0
                 Criteria groupCheck = new Criteria();
 364  0
                 if(groupIds!=null && !groupIds.isEmpty())
 365  0
                         groupCheck.addIn(KIMPropertyConstants.RoleMember.MEMBER_ID, groupIds);
 366  0
                 groupCheck.addEqualTo( KIMPropertyConstants.RoleMember.MEMBER_TYPE_CODE, Role.GROUP_MEMBER_TYPE );
 367  0
                 orSet.addOrCriteria( groupCheck );
 368  0
                 c.addAndCriteria( orSet );
 369  0
                 addSubCriteriaBasedOnRoleQualification(c, qualification);
 370  
                 
 371  0
                 Query query = QueryFactory.newQuery(RoleMemberImpl.class, c);
 372  0
                 Collection<RoleMemberImpl> coll = getPersistenceBrokerTemplate().getCollectionByQuery(query);
 373  0
                 ArrayList<RoleMemberImpl> results = new ArrayList<RoleMemberImpl>( coll.size() );
 374  0
                 for ( RoleMemberImpl rm : coll ) {
 375  0
                         if ( rm.isActive() ) {
 376  0
                                 results.add(rm);
 377  
                         }
 378  
                 }
 379  0
                 return results;
 380  
         }
 381  
 
 382  
         /**
 383  
          * @see org.kuali.rice.kim.dao.KimRoleDao#getDelegationMembersForDelegationIds(java.util.List)
 384  
          */
 385  
         @SuppressWarnings("unchecked")
 386  
         public Map<String,List<KimDelegationMemberImpl>> getDelegationMembersForDelegationIds(
 387  
                         List<String> delegationIds) {
 388  0
                 Criteria c = new Criteria();
 389  0
                 if(delegationIds!=null && !delegationIds.isEmpty())
 390  0
                         c.addIn(KIMPropertyConstants.DelegationMember.DELEGATION_ID, delegationIds);
 391  0
                 Query query = QueryFactory.newQuery(KimDelegationMemberImpl.class, c);
 392  0
                 Collection<KimDelegationMemberImpl> coll = getPersistenceBrokerTemplate().getCollectionByQuery(query);
 393  0
                 HashMap<String,List<KimDelegationMemberImpl>> result = new HashMap<String,List<KimDelegationMemberImpl>>();
 394  0
                 for ( KimDelegationMemberImpl dp : coll ) {
 395  0
                         if ( dp.isActive() ) {
 396  0
                                 if ( !result.containsKey( dp.getDelegationId() ) ) {
 397  0
                                         result.put( dp.getDelegationId(), new ArrayList<KimDelegationMemberImpl>() );
 398  
                                 }
 399  0
                                 result.get( dp.getDelegationId() ).add( dp );
 400  
                         }
 401  
                 }
 402  0
                 return result;
 403  
         }
 404  
 
 405  
     public List<RoleImpl> getRoles(Map<String,String> fieldValues) {
 406  0
         Criteria crit = new Criteria();
 407  0
         Map<String,Map<String,String>> critMap = setupCritMaps(fieldValues);
 408  
 
 409  
 //        BusinessObjectEntry boEntry = KNSServiceLocatorInternal.getDataDictionaryService().getDataDictionary().getBusinessObjectEntry("org.kuali.rice.kim.bo.impl.RoleImpl");
 410  
 //      List lookupNames = boEntry.getLookupDefinition().getLookupFieldNames();
 411  0
         Map<String,String> lookupNames = critMap.get("lookupNames");
 412  0
         for (Entry<String, String> entry : lookupNames.entrySet()) {
 413  0
                 if (StringUtils.isNotBlank(entry.getValue())) {
 414  0
                                 if (!entry.getKey().equals(KIMPropertyConstants.Principal.PRINCIPAL_NAME)) {
 415  0
                                         addLikeToCriteria(crit, entry.getKey(), entry.getValue());
 416  
                                 } else {
 417  0
                                                 List roleIds = getRoleIdsForPrincipalName(entry.getValue());
 418  0
                                         if (roleIds!=null && !roleIds.isEmpty()) {
 419  0
                                                 crit.addIn(KIMPropertyConstants.Role.ROLE_ID, roleIds);
 420  
                                         } else {
 421  
                                         // TODO : if no role id found that means principalname not matched, need to do something to force to return empty list
 422  0
                                                 roleIds.add("NOTFOUND");
 423  0
                                                 crit.addIn(KIMPropertyConstants.Role.ROLE_ID, roleIds);
 424  
                                         }
 425  0
                         }
 426  
                 }
 427  
         }
 428  0
                 if (!critMap.get("attr").isEmpty()) {
 429  0
                     String kimTypeId=null;
 430  0
                 for (Map.Entry<String,String> entry : fieldValues.entrySet()) {
 431  0
                         if (entry.getKey().equals("kimTypeId")) {
 432  0
                                 kimTypeId=entry.getValue();
 433  0
                                 break;
 434  
                         }
 435  
                 }
 436  0
                         setupAttrCriteria(crit, critMap.get("attr"),kimTypeId);
 437  
                 }
 438  0
                 if (!critMap.get("perm").isEmpty()) {
 439  0
                         crit.addExists(setupPermCriteria(critMap.get("perm")));
 440  
                 }
 441  0
                 if (!critMap.get("resp").isEmpty()) {
 442  0
                         crit.addExists(setupRespCriteria(critMap.get("resp")));
 443  
                 }
 444  0
                 if (!critMap.get("group").isEmpty()) {
 445  0
                         crit.addExists(setupGroupCriteria(critMap.get("group")));
 446  
                 }
 447  
 
 448  0
         Query q = QueryFactory.newQuery(RoleImpl.class, crit);
 449  
 
 450  0
         return (List)getPersistenceBrokerTemplate().getCollectionByQuery(q);
 451  
     }
 452  
 
 453  
     
 454  
     private List<String> getPrincipalIdsForPrincipalName(String principalName){
 455  0
             Map<String, String> criteria = new HashMap<String, String>();
 456  0
         criteria.put("principals.principalName", principalName);
 457  0
         List<? extends KimEntityDefaultInfo> entities = KimApiServiceLocator.getIdentityService().lookupEntityDefaultInfo(criteria, false);
 458  
 
 459  0
         List<String> principalIds = new ArrayList<String>();
 460  0
         for (KimEntityDefaultInfo entity : entities) {
 461  0
             for (Principal principal : entity.getPrincipals()) {
 462  0
                 principalIds.add(principal.getPrincipalId());
 463  
             }
 464  
         }
 465  
 
 466  0
         return principalIds;
 467  
 
 468  
     }
 469  
 
 470  
     private List<String> getRoleIdsForPrincipalName(String value) {
 471  0
             String principalName = value.replace('*', '%');
 472  0
                 List<String> roleIds = new ArrayList<String>();
 473  0
                 Criteria memberSubCrit = new Criteria();
 474  0
         Map<String, String> criteria = new HashMap<String, String>();
 475  0
         criteria.put("principals.principalName", principalName);
 476  0
         List<? extends KimEntityDefaultInfo> entities = KimApiServiceLocator.getIdentityService().lookupEntityDefaultInfo(criteria, false);
 477  0
         if (entities == null
 478  
                 || entities.size() == 0) {
 479  0
             return roleIds;
 480  
         }
 481  
 
 482  0
         List<String> principalIds = new ArrayList<String>();
 483  0
         for (KimEntityDefaultInfo entity : entities) {
 484  0
             for (Principal principal : entity.getPrincipals()) {
 485  0
                 principalIds.add(principal.getPrincipalId());
 486  
             }
 487  
         }
 488  0
         if(principalIds!=null && !principalIds.isEmpty()){
 489  0
                 memberSubCrit.addEqualTo(KIMPropertyConstants.RoleMember.MEMBER_TYPE_CODE, Role.PRINCIPAL_MEMBER_TYPE);
 490  0
                 memberSubCrit.addIn(KIMPropertyConstants.RoleMember.MEMBER_ID, principalIds);
 491  
 
 492  0
                         ReportQueryByCriteria memberSubQuery = QueryFactory.newReportQuery(RoleMemberImpl.class, memberSubCrit);
 493  0
                         for (RoleMemberImpl roleMbr : (List<RoleMemberImpl>)getPersistenceBrokerTemplate().getCollectionByQuery(memberSubQuery)) {
 494  0
                                 if (roleMbr.isActive() && !roleIds.contains(roleMbr.getRoleId())) {
 495  0
                                         roleIds.add(roleMbr.getRoleId());
 496  
                                 }
 497  
                         }
 498  
         }
 499  
 
 500  0
                 List<String> groupIds = new ArrayList<String>();
 501  0
                 for (String principalId : principalIds) {
 502  0
                     List<String> principalGroupIds = KimApiServiceLocator.getGroupService().getGroupIdsForPrincipal(principalId);
 503  0
                     for (String groupId : principalGroupIds) {
 504  0
                         if (!groupIds.contains(groupId)) {
 505  0
                             groupIds.add(groupId);
 506  
                         }
 507  
                     }
 508  0
                 }
 509  
 
 510  0
         if(groupIds!=null && !groupIds.isEmpty()){
 511  0
                 Criteria grpRoleCrit = new Criteria();
 512  0
                 grpRoleCrit.addEqualTo(KIMPropertyConstants.RoleMember.MEMBER_TYPE_CODE, Role.GROUP_MEMBER_TYPE);
 513  0
                 grpRoleCrit.addIn(KIMPropertyConstants.RoleMember.MEMBER_ID, groupIds);
 514  
 
 515  0
                 ReportQueryByCriteria memberSubQuery = QueryFactory.newReportQuery(RoleMemberImpl.class, grpRoleCrit);
 516  
 
 517  0
                         for (RoleMemberImpl roleMbr : (List<RoleMemberImpl>)getPersistenceBrokerTemplate().getCollectionByQuery(memberSubQuery)) {
 518  0
                                 if (roleMbr.isActive() && !roleIds.contains(roleMbr.getRoleId()) ) {
 519  0
                                         roleIds.add(roleMbr.getRoleId());
 520  
                                 }
 521  
                         }
 522  
         }
 523  
 
 524  0
             return roleIds;
 525  
     }
 526  
 
 527  
     private Map setupCritMaps(Map<String,String> fieldValues) {
 528  0
             Map <String, Map> critMap = new HashMap();
 529  0
         List permFieldName = new ArrayList();
 530  0
         permFieldName.add("permName");
 531  0
         permFieldName.add("permNamespaceCode");
 532  0
         permFieldName.add("permTmplName");
 533  0
         permFieldName.add("permTmplNamespaceCode");
 534  0
         List respFieldName = new ArrayList();
 535  0
         respFieldName.add("respName");
 536  0
         respFieldName.add("respNamespaceCode");
 537  0
         respFieldName.add("respTmplName");
 538  0
         respFieldName.add("respTmplNamespaceCode");
 539  0
         Map<String,String> permFieldMap = new HashMap<String,String>();
 540  0
         Map<String,String> respFieldMap = new HashMap<String,String>();
 541  0
         Map<String,String> attrFieldMap = new HashMap<String,String>();
 542  0
         Map<String,String> groupFieldMap = new HashMap<String,String>();
 543  0
         Map<String,String> lookupNamesMap = new HashMap<String,String>();
 544  
 
 545  0
         for (Entry<String, String> entry : fieldValues.entrySet()) {
 546  0
                 if (StringUtils.isNotBlank(entry.getValue())) {
 547  0
                             String nameValue = entry.getValue().replace('*', '%');
 548  0
                         if (permFieldName.contains(entry.getKey())) {
 549  0
                                 permFieldMap.put(entry.getKey(), nameValue);
 550  0
                         } else if (respFieldName.contains(entry.getKey())) {
 551  0
                                 respFieldMap.put(entry.getKey(), nameValue);
 552  0
                         } else if (entry.getKey().startsWith(KimConstants.AttributeConstants.GROUP_NAME)) {
 553  0
                                 groupFieldMap.put(entry.getKey(), nameValue);
 554  0
                         } else if (entry.getKey().contains(".")) {
 555  0
                                 attrFieldMap.put(entry.getKey(), nameValue);
 556  
                         } else {
 557  0
                                 lookupNamesMap.put(entry.getKey(), nameValue);
 558  
                         }
 559  0
                 }
 560  
         }
 561  
 
 562  0
         critMap.put("perm", permFieldMap);
 563  0
         critMap.put("resp", respFieldMap);
 564  0
         critMap.put("group", groupFieldMap);
 565  0
         critMap.put("attr", attrFieldMap);
 566  0
         critMap.put("lookupNames", lookupNamesMap);
 567  0
         return critMap;
 568  
     }
 569  
 
 570  
 
 571  
     private void setupAttrCriteria(Criteria crit, Map<String,String> attrCrit, String kimTypeId) {
 572  0
         for (Entry<String, String> entry : attrCrit.entrySet()) {
 573  0
                         Criteria subCrit = new Criteria();
 574  0
                         addLikeToCriteria(subCrit, "attributes.attributeValue",entry.getValue());
 575  0
                         addEqualToCriteria(subCrit, "attributes.kimAttributeId",entry.getKey().substring(entry.getKey().indexOf(".")+1, entry.getKey().length()));
 576  0
                         addEqualToCriteria(subCrit, "attributes.kimTypeId", kimTypeId);
 577  0
                         subCrit.addEqualToField("roleId", Criteria.PARENT_QUERY_PREFIX + "roleId");
 578  0
                         crit.addExists(QueryFactory.newReportQuery(RoleMemberImpl.class, subCrit));
 579  0
         }
 580  0
     }
 581  
 
 582  
     private ReportQueryByCriteria setupPermCriteria(Map<String,String> permCrit) {
 583  
 
 584  0
             Map<String,String> searchCrit = new HashMap<String, String>();
 585  
 
 586  0
         for (Entry<String, String> entry : permCrit.entrySet()) {
 587  0
                 if (entry.getKey().equals("permTmplName") || entry.getKey().equals("permTmplNamespaceCode")) {
 588  0
                         if (entry.getKey().equals("permTmplName")) {
 589  0
                                 searchCrit.put("template." + KimConstants.UniqueKeyConstants.PERMISSION_TEMPLATE_NAME,entry.getValue());
 590  
 
 591  
                         } else {
 592  0
                                 searchCrit.put("template." + KimConstants.UniqueKeyConstants.NAMESPACE_CODE,entry.getValue());
 593  
                         }
 594  
                 }
 595  
 
 596  0
                 if (entry.getKey().equals("permName") || entry.getKey().equals("permNamespaceCode")) {
 597  0
                         if (entry.getKey().equals("permName")) {
 598  0
                                 searchCrit.put(KimConstants.UniqueKeyConstants.PERMISSION_NAME, entry.getValue());
 599  
                         } else {
 600  0
                                 searchCrit.put(KimConstants.UniqueKeyConstants.NAMESPACE_CODE,entry.getValue());
 601  
 
 602  
                         }
 603  
                 }
 604  
         }
 605  
 
 606  0
         List<KimPermissionInfo> permList = KimApiServiceLocator.getPermissionService().lookupPermissions(searchCrit, true);
 607  0
         List<String> roleIds = null;
 608  
 
 609  0
         if(permList != null && !permList.isEmpty()){
 610  0
                 roleIds = KimApiServiceLocator.getPermissionService().getRoleIdsForPermissions(permList);
 611  
         }
 612  
 
 613  0
         if(roleIds == null || roleIds.isEmpty()){
 614  0
                 roleIds = new ArrayList<String>();
 615  0
                 roleIds.add("-1"); // this forces a blank return.
 616  
         }
 617  
 
 618  0
         Criteria memberSubCrit = new Criteria();
 619  0
         memberSubCrit.addIn("roleId", roleIds);
 620  0
         memberSubCrit.addEqualToField("roleId", Criteria.PARENT_QUERY_PREFIX + "roleId");
 621  0
                 return QueryFactory.newReportQuery(RoleImpl.class, memberSubCrit);
 622  
 
 623  
     }
 624  
 
 625  
     private ReportQueryByCriteria setupRespCriteria(Map<String,String> respCrit) {
 626  
 
 627  
 
 628  0
         List<Predicate> inner = new ArrayList<Predicate>();
 629  0
         for (Entry<String, String> entry : respCrit.entrySet()) {
 630  0
             if (entry.getKey().equals("respTmplName") || entry.getKey().equals("respTmplNamespaceCode")) {
 631  
                         final Predicate tmpl;
 632  0
                 if (entry.getKey().equals("respTmplName")) {
 633  0
                                 tmpl = equal("template." + KimConstants.UniqueKeyConstants.RESPONSIBILITY_TEMPLATE_NAME, entry.getValue());
 634  
                         } else {
 635  0
                                 tmpl = equal("template." + KimConstants.UniqueKeyConstants.NAMESPACE_CODE, entry.getValue());
 636  
                         }
 637  0
                 inner.add(tmpl);
 638  
                 }
 639  
 
 640  0
                 if (entry.getKey().equals("respName") || entry.getKey().equals("respNamespaceCode")) {
 641  
                         final Predicate other;
 642  0
                 if (entry.getKey().equals("respName")) {
 643  0
                                 other = equal(KimConstants.UniqueKeyConstants.RESPONSIBILITY_NAME, entry.getValue());
 644  
                         } else {
 645  0
                                 other = equal(KimConstants.UniqueKeyConstants.NAMESPACE_CODE,entry.getValue());
 646  
                         }
 647  0
                 inner.add(other);
 648  0
                 }
 649  
         }
 650  0
         QueryByCriteria.Builder builder = QueryByCriteria.Builder.create();
 651  0
         builder.setPredicates(inner.toArray(new Predicate[] {}));
 652  
 
 653  0
         List<Responsibility> kriList = KimApiServiceLocator.getResponsibilityService().findResponsibilities(builder.build()).getResults();
 654  0
         List<String> roleIds = new ArrayList<String>();
 655  
 
 656  0
         for(Responsibility kri : kriList){
 657  0
                 roleIds.addAll(KimApiServiceLocator.getResponsibilityService().getRoleIdsForResponsibility(kri.getId(), null));
 658  
         }
 659  
 
 660  0
         if(roleIds == null || roleIds.isEmpty()){
 661  0
                 roleIds = new ArrayList<String>();
 662  0
                 roleIds.add("-1"); // this forces a blank return.
 663  
         }
 664  
 
 665  0
         Criteria memberSubCrit = new Criteria();
 666  0
         memberSubCrit.addIn("roleId", roleIds);
 667  0
         memberSubCrit.addEqualToField("roleId", Criteria.PARENT_QUERY_PREFIX + "roleId");
 668  0
                 return QueryFactory.newReportQuery(RoleImpl.class, memberSubCrit);
 669  
 
 670  
     }
 671  
 
 672  
     private ReportQueryByCriteria setupGroupCriteria(Map<String,String> groupCrit) {
 673  
 
 674  0
             Map<String,String> searchCrit = new HashMap<String, String>();
 675  0
         for (Entry<String, String> entry : groupCrit.entrySet()) {
 676  0
                         if (entry.getKey().equals(KimConstants.AttributeConstants.GROUP_NAME)) {
 677  0
                                 searchCrit.put(entry.getKey(), entry.getValue());
 678  
                         } else { // the namespace code for the group field is named something besides the default. Set it to the default.
 679  0
                                 searchCrit.put(KimConstants.AttributeConstants.NAMESPACE_CODE, entry.getValue());
 680  
                         }
 681  
         }
 682  
 
 683  0
         Criteria crit = new Criteria();
 684  
 
 685  0
         List<String> groupIds = KimApiServiceLocator.getGroupService().lookupGroupIds(searchCrit);
 686  
 
 687  0
         if(groupIds == null || groupIds.isEmpty()){
 688  0
                 groupIds = new ArrayList<String>();
 689  0
                 groupIds.add("-1");  // this forces a blank return.
 690  
         }
 691  0
         crit.addIn("memberId", groupIds);
 692  0
         crit.addEqualToField("roleId", Criteria.PARENT_QUERY_PREFIX + "roleId");
 693  
 
 694  0
                 return QueryFactory.newReportQuery(RoleMemberImpl.class, crit);
 695  
 
 696  
     }
 697  
 
 698  
     private void addLikeToCriteria(Criteria criteria, String propertyName, String propertyValue){
 699  0
             String[] keyValues = getCaseInsensitiveValues(propertyName, propertyValue);
 700  0
                    criteria.addLike(keyValues[0], keyValues[1]);
 701  0
     }
 702  
 
 703  
     private void addEqualToCriteria(Criteria criteria, String propertyName, String propertyValue){
 704  0
             String[] keyValues = getCaseInsensitiveValues(propertyName, propertyValue);
 705  0
                    criteria.addEqualTo(keyValues[0], keyValues[1]);
 706  0
     }
 707  
 
 708  
     private String[] getCaseInsensitiveValues(String propertyName, String propertyValue){
 709  0
             String[] keyValues = new String[2];
 710  0
             keyValues[0] = propertyName==null?"":getDbPlatform().getUpperCaseFunction() + "(" + propertyName + ")";
 711  0
             keyValues[1] = propertyValue==null?"":propertyValue.toUpperCase();
 712  0
             return keyValues;
 713  
     }
 714  
 
 715  
     @SuppressWarnings("unchecked")
 716  
         protected List<RoleMemberImpl> getRoleMemberImpls(Map<String, String> fieldValues){
 717  0
                 Criteria queryCriteria = new Criteria();
 718  0
                 List<String> memberIds = new ArrayList<String>();
 719  0
                 if(hasExtraRoleMemberCriteria(fieldValues)){
 720  0
                         String memberName = fieldValues.get(KimConstants.KimUIConstants.MEMBER_NAME);
 721  0
                         String memberNamespaceCode = fieldValues.get(KimConstants.KimUIConstants.MEMBER_NAMESPACE_CODE);
 722  
                         //Only name or namespace fields are provided in search
 723  
                         //member type code is not provided
 724  0
                         List<RoleImpl> roles = getRoleMembersRoles(memberNamespaceCode, memberName);
 725  0
                         if(roles!=null){
 726  0
                                 for(RoleImpl role: roles)
 727  0
                                         memberIds.add(role.getRoleId());
 728  
                         }
 729  
 
 730  0
                         memberIds.addAll(this.getPrincipalIdsForPrincipalName(memberName));
 731  
 
 732  0
                         memberIds.addAll(getRoleMembersGroupIds(memberNamespaceCode, memberName));
 733  
 
 734  0
                 if(memberIds!=null && !memberIds.isEmpty())
 735  0
                         queryCriteria.addIn(KIMPropertyConstants.RoleMember.MEMBER_ID, memberIds);
 736  
                 }
 737  0
                 if(hasCoreRoleMemberCriteria(fieldValues)){
 738  0
                     String roleMemberId = fieldValues.get(KimConstants.PrimaryKeyConstants.ROLE_MEMBER_ID);
 739  0
                         String roleId = fieldValues.get(KimConstants.PrimaryKeyConstants.ROLE_ID);
 740  0
                         String memberId = fieldValues.get(KimConstants.PrimaryKeyConstants.MEMBER_ID);
 741  0
                         String memberTypeCode = fieldValues.get(KIMPropertyConstants.KimMember.MEMBER_TYPE_CODE);
 742  0
                         String activeFromDate = fieldValues.get(KIMPropertyConstants.KimMember.ACTIVE_FROM_DATE);
 743  0
                         String activeToDate = fieldValues.get(KIMPropertyConstants.KimMember.ACTIVE_TO_DATE);
 744  
                         //role member id, role id, member id, member type code, active dates are provided in search
 745  0
                         if(StringUtils.isNotEmpty(roleMemberId))
 746  0
                                 addEqualToCriteria(queryCriteria, KimConstants.PrimaryKeyConstants.ROLE_MEMBER_ID, roleMemberId);
 747  0
                         if(StringUtils.isNotEmpty(roleId))
 748  0
                                 addEqualToCriteria(queryCriteria, KimConstants.PrimaryKeyConstants.ROLE_ID, roleId);
 749  0
                         if(StringUtils.isNotEmpty(memberId))
 750  0
                                 addEqualToCriteria(queryCriteria, KimConstants.PrimaryKeyConstants.MEMBER_ID, memberId);
 751  0
                         if(StringUtils.isNotEmpty(memberTypeCode))
 752  0
                                 addEqualToCriteria(queryCriteria, KIMPropertyConstants.KimMember.MEMBER_TYPE_CODE, memberTypeCode);
 753  0
                         if(StringUtils.isNotEmpty(activeFromDate))
 754  0
                                 queryCriteria.addGreaterOrEqualThan(KIMPropertyConstants.KimMember.ACTIVE_FROM_DATE, activeFromDate);
 755  0
                         if(StringUtils.isNotEmpty(activeToDate))
 756  0
                                 queryCriteria.addLessOrEqualThan(KIMPropertyConstants.KimMember.ACTIVE_TO_DATE, activeToDate);
 757  
                 }
 758  0
         Query q = QueryFactory.newQuery(RoleMemberImpl.class, queryCriteria);
 759  0
         return (List<RoleMemberImpl>)getPersistenceBrokerTemplate().getCollectionByQuery(q);
 760  
     }
 761  
 
 762  
     public List<RoleMembershipInfo> getRoleMembers(Map<String,String> fieldValues) {
 763  0
             List<RoleMemberImpl> roleMembers = getRoleMemberImpls(fieldValues);
 764  0
         List<RoleMembershipInfo> roleMemberships = new ArrayList<RoleMembershipInfo>();
 765  
         RoleMembershipInfo roleMembership;
 766  0
         for(RoleMemberImpl roleMember: roleMembers){
 767  0
                 roleMembership = new RoleMembershipInfo(roleMember.getRoleId(), roleMember.getRoleMemberId(), roleMember.getMemberId(), roleMember.getMemberTypeCode(), roleMember.getQualifier() );
 768  0
                 roleMemberships.add(roleMembership);
 769  
         }
 770  0
         return roleMemberships;
 771  
     }
 772  
 
 773  
     public List<RoleMemberCompleteInfo> getRoleMembersCompleteInfo(Map<String,String> fieldValues) {
 774  0
             List<RoleMemberImpl> roleMembers = getRoleMemberImpls(fieldValues);
 775  0
         List<RoleMemberCompleteInfo> roleMembersCompleteInfo = new ArrayList<RoleMemberCompleteInfo>();
 776  
         RoleMemberCompleteInfo roleMemberCompleteInfo;
 777  0
         for(RoleMemberImpl roleMember: roleMembers){
 778  0
                 roleMemberCompleteInfo = new RoleMemberCompleteInfo(
 779  
                                 roleMember.getRoleId(), roleMember.getRoleMemberId(), roleMember.getMemberId(),
 780  
                                 roleMember.getMemberTypeCode(), roleMember.getActiveFromDate(), roleMember.getActiveToDate(),
 781  
                                 roleMember.getQualifier() );
 782  0
                 roleMembersCompleteInfo.add(roleMemberCompleteInfo);
 783  
         }
 784  0
         return roleMembersCompleteInfo;
 785  
     }
 786  
 
 787  
     private boolean hasCoreRoleMemberCriteria(Map<String, String> fieldValues){
 788  0
                 return StringUtils.isNotEmpty(fieldValues.get(KimConstants.PrimaryKeyConstants.ROLE_MEMBER_ID)) ||
 789  
                                 StringUtils.isNotEmpty(fieldValues.get(KimConstants.PrimaryKeyConstants.ROLE_ID)) ||
 790  
                                 StringUtils.isNotEmpty(fieldValues.get(KimConstants.PrimaryKeyConstants.MEMBER_ID)) ||
 791  
                                 StringUtils.isNotEmpty(fieldValues.get(KIMPropertyConstants.KimMember.MEMBER_TYPE_CODE)) ||
 792  
                                 StringUtils.isNotEmpty(fieldValues.get(KIMPropertyConstants.KimMember.ACTIVE_FROM_DATE)) ||
 793  
                                 StringUtils.isNotEmpty(fieldValues.get(KIMPropertyConstants.KimMember.ACTIVE_TO_DATE));
 794  
     }
 795  
 
 796  
     private boolean hasExtraRoleMemberCriteria(Map<String, String> fieldValues){
 797  0
             return StringUtils.isNotEmpty(fieldValues.get(KimConstants.KimUIConstants.MEMBER_NAME)) ||
 798  
                             StringUtils.isNotEmpty(fieldValues.get(KimConstants.KimUIConstants.MEMBER_NAMESPACE_CODE));
 799  
     }
 800  
 
 801  
     @SuppressWarnings("unchecked")
 802  
         private List<RoleImpl> getRoleMembersRoles(String memberNamespaceCode, String memberName){
 803  0
                 Criteria queryCriteria = new Criteria();
 804  0
                 addEqualToCriteria(queryCriteria, KimConstants.UniqueKeyConstants.NAMESPACE_CODE, memberNamespaceCode);
 805  0
                 addEqualToCriteria(queryCriteria, KimConstants.UniqueKeyConstants.ROLE_NAME, memberName);
 806  0
                 Query q = QueryFactory.newQuery(RoleImpl.class, queryCriteria);
 807  0
                 return (List<RoleImpl>)getPersistenceBrokerTemplate().getCollectionByQuery(q);
 808  
     }
 809  
 
 810  
     private List<String> getRoleMembersGroupIds(String memberNamespaceCode, String memberName){
 811  
 
 812  0
             Map<String,String> searchCrit = new HashMap<String, String>();
 813  0
             searchCrit.put(KimConstants.AttributeConstants.GROUP_NAME, memberName);
 814  0
             searchCrit.put(KimConstants.AttributeConstants.NAMESPACE_CODE, memberNamespaceCode);
 815  
 
 816  0
             return KimApiServiceLocator.getGroupService().lookupGroupIds(searchCrit);
 817  
     }
 818  
 }