Coverage Report - org.kuali.rice.kim.impl.permission.PermissionDaoJpa
 
Classes in this File Line Coverage Branch Coverage Complexity
PermissionDaoJpa
0%
0/17
0%
0/6
2.333
 
 1  
 /*
 2  
  * Copyright 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.impl.permission;
 17  
 
 18  
 import java.util.ArrayList;
 19  
 import java.util.Collection;
 20  
 import java.util.List;
 21  
 
 22  
 import javax.persistence.EntityManager;
 23  
 import javax.persistence.PersistenceContext;
 24  
 
 25  
 import org.kuali.rice.core.framework.persistence.jpa.criteria.Criteria;
 26  
 import org.kuali.rice.core.framework.persistence.jpa.criteria.QueryByCriteria;
 27  
 import org.kuali.rice.kim.bo.role.KimPermission;
 28  
 import org.kuali.rice.kim.bo.role.impl.RolePermissionImpl;
 29  
 import org.kuali.rice.kim.dao.KimPermissionDao;
 30  
 ;
 31  
 
 32  
 /**
 33  
  * This is a description of what this class does - kellerj don't forget to fill this in. 
 34  
  * 
 35  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 36  
  *
 37  
  */
 38  0
 public class PermissionDaoJpa implements KimPermissionDao {
 39  
 
 40  
     @PersistenceContext(unitName="kim-unit")
 41  
     private EntityManager entityManager;
 42  
     
 43  
         /**
 44  
          * @see org.kuali.rice.kim.dao.KimPermissionDao#getRoleIdsForPermissions(java.util.Collection)
 45  
          */
 46  
         @SuppressWarnings("unchecked")
 47  
         public List<String> getRoleIdsForPermissions(Collection<? extends KimPermission> permissions) {
 48  0
                 if ( permissions.isEmpty() ) {
 49  0
                         return new ArrayList<String>(0);
 50  
                 }
 51  0
                 List<String> permissionIds = new ArrayList<String>( permissions.size() );
 52  0
                 for ( KimPermission kp : permissions ) {
 53  0
                         permissionIds.add( kp.getPermissionId() );
 54  
                 }
 55  0
                 Criteria c = new Criteria(RolePermissionImpl.class.getName());
 56  0
                 c.in( "permissionId", permissionIds );
 57  0
                 c.eq( "active", true );
 58  
                 
 59  0
                 ArrayList<RolePermissionImpl> coll = (ArrayList<RolePermissionImpl>) new QueryByCriteria(entityManager, c).toQuery().getResultList();
 60  0
                 List<String> roleIds = new ArrayList<String>( coll.size() );
 61  0
                 for ( RolePermissionImpl rp : coll ) {
 62  0
                         roleIds.add( rp.getRoleId() );
 63  
                 }
 64  0
                 return roleIds;
 65  
         }
 66  
 
 67  
         public EntityManager getEntityManager() {
 68  0
         return this.entityManager;
 69  
     }
 70  
 
 71  
     public void setEntityManager(EntityManager entityManager) {
 72  0
         this.entityManager = entityManager;
 73  0
     }
 74  
 }