Coverage Report - org.kuali.rice.kim.impl.role.RolePermissionBo
 
Classes in this File Line Coverage Branch Coverage Complexity
RolePermissionBo
84%
11/13
50%
2/4
0
 
 1  
 /*
 2  
  * Copyright 2006-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  
 
 17  
 package org.kuali.rice.kim.impl.role
 18  
 
 19  
 import javax.persistence.Column
 20  
 import javax.persistence.Entity
 21  
 import javax.persistence.FetchType
 22  
 import javax.persistence.Id
 23  
 import javax.persistence.JoinColumn;
 24  
 
 25  
 
 26  
 import javax.persistence.OneToOne;
 27  
 import javax.persistence.Table
 28  
 
 29  
 import org.hibernate.annotations.Type
 30  
 import org.kuali.rice.kim.api.role.RolePermission
 31  
 import org.kuali.rice.kim.api.role.RolePermissionContract
 32  
 import org.kuali.rice.kim.impl.permission.PermissionBo
 33  
 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase
 34  
 
 35  
 @Entity
 36  
 @Table(name="KRIM_ROLE_PERM_T")
 37  
 public class RolePermissionBo extends PersistableBusinessObjectBase implements RolePermissionContract {
 38  
     private static final long serialVersionUID = 1L;
 39  
 
 40  
     @Id
 41  
         @Column(name="ROLE_PERM_ID")
 42  
         String id
 43  
 
 44  
         @Column(name="ROLE_ID")
 45  
         String roleId;
 46  
         
 47  
         @Column(name="PERM_ID")
 48  
         String permissionId
 49  
         
 50  
         @Column(name="ACTV_IND")
 51  
         @Type(type="yes_no")
 52  
         boolean active
 53  
 
 54  
         @OneToOne(targetEntity=PermissionBo.class,cascade=[],fetch=FetchType.EAGER)
 55  
         @JoinColumn(name = "PERM_ID", insertable = false, updatable = false)
 56  
         PermissionBo permission;
 57  
                 
 58  
     /**
 59  
      * Converts a mutable bo to its immutable counterpart
 60  
      * @param bo the mutable business object
 61  
      * @return the immutable object
 62  
      */
 63  
     static RolePermission to(RolePermissionBo bo) {
 64  2
         if (bo == null) {
 65  0
             return null
 66  
         }
 67  
 
 68  2
         return RolePermission.Builder.create(bo).build();
 69  
     }
 70  
 
 71  
     /**
 72  
      * Converts a immutable object to its mutable counterpart
 73  
      * @param im immutable object
 74  
      * @return the mutable bo
 75  
      */
 76  
     static RolePermissionBo from(RolePermission im) {
 77  2
         if (im == null) {
 78  0
             return null
 79  
         }
 80  
 
 81  2
         RolePermissionBo bo = new RolePermissionBo()
 82  2
         bo.id = im.id
 83  2
                 bo.roleId = im.roleId
 84  2
                 bo.permissionId = im.permissionId
 85  2
                 bo.active = im.active
 86  2
         bo.versionNumber = im.versionNumber
 87  2
                 bo.objectId = im.objectId;
 88  
 
 89  2
         return bo
 90  
     }
 91  
 
 92  
 }