|  1 |     | 
     | 
  |  2 |     | 
     | 
  |  3 |     | 
     | 
  |  4 |     | 
     | 
  |  5 |     | 
     | 
  |  6 |     | 
     | 
  |  7 |     | 
     | 
  |  8 |     | 
     | 
  |  9 |     | 
     | 
  |  10 |     | 
     | 
  |  11 |     | 
     | 
  |  12 |     | 
     | 
  |  13 |     | 
     | 
  |  14 |     | 
     | 
  |  15 |     | 
     | 
  |  16 |     | 
     | 
  |  17 |     | 
     | 
  |  18 |     | 
   package org.kuali.rice.kim.impl.role;  | 
  |  19 |     | 
     | 
  |  20 |     | 
     | 
  |  21 |     | 
   import javax.persistence.CascadeType  | 
  |  22 |     | 
   import javax.persistence.Column  | 
  |  23 |     | 
   import javax.persistence.Entity  | 
  |  24 |     | 
   import javax.persistence.FetchType  | 
  |  25 |     | 
   import javax.persistence.Id  | 
  |  26 |     | 
   import javax.persistence.JoinColumn  | 
  |  27 |     | 
   import javax.persistence.OneToMany  | 
  |  28 |     | 
   import javax.persistence.Table  | 
  |  29 |     | 
   import javax.persistence.Transient  | 
  |  30 |     | 
   import org.hibernate.annotations.Fetch  | 
  |  31 |     | 
   import org.hibernate.annotations.FetchMode  | 
  |  32 |     | 
   import org.hibernate.annotations.Type  | 
  |  33 |     | 
   import org.kuali.rice.kim.api.role.Role  | 
  |  34 |     | 
   import org.kuali.rice.kim.api.role.RoleContract  | 
  |  35 |     | 
   import org.kuali.rice.kim.api.services.KimApiServiceLocator  | 
  |  36 |     | 
   import org.kuali.rice.kim.api.type.KimTypeInfoService  | 
  |  37 |     | 
   import org.kuali.rice.kim.impl.type.KimTypeBo  | 
  |  38 |     | 
   import org.kuali.rice.krad.bo.PersistableBusinessObjectBase  | 
  |  39 |     | 
   import org.springframework.util.AutoPopulatingList  | 
  |  40 |     | 
     | 
  |  41 |     | 
   @Entity  | 
  |  42 |     | 
   @Table(name = "KRIM_ROLE_T")  | 
  |  43 |     | 
   public class RoleBo extends PersistableBusinessObjectBase implements RoleContract { | 
  |  44 |     | 
     | 
  |  45 |     | 
       private static final long serialVersionUID = 1L;  | 
  |  46 |     | 
     | 
  |  47 |     | 
       @Id  | 
  |  48 |     | 
       @Column(name = "ROLE_ID")  | 
  |  49 |     | 
       String id;  | 
  |  50 |     | 
     | 
  |  51 |     | 
       @Column(name = "ROLE_NM")  | 
  |  52 |     | 
       String name;  | 
  |  53 |     | 
     | 
  |  54 |     | 
       @Column(name = "DESC_TXT", length = 4000)  | 
  |  55 |     | 
       String description;  | 
  |  56 |     | 
     | 
  |  57 |     | 
       @Type(type = "yes_no")  | 
  |  58 |     | 
       @Column(name = "ACTV_IND")  | 
  |  59 |     | 
       boolean active;  | 
  |  60 |     | 
     | 
  |  61 |     | 
       @Column(name = "KIM_TYP_ID")  | 
  |  62 |     | 
       String kimTypeId;  | 
  |  63 |     | 
     | 
  |  64 |     | 
       @Column(name = "NMSPC_CD")  | 
  |  65 |     | 
       String namespaceCode;  | 
  |  66 |     | 
     | 
  |  67 |     | 
       @OneToMany(targetEntity = RoleMemberBo.class, cascade = [CascadeType.MERGE, CascadeType.REFRESH], fetch = FetchType.EAGER)  | 
  |  68 |     | 
       @Fetch(value = FetchMode.SELECT)  | 
  |  69 |     | 
       @JoinColumn(name = "ROLE_ID", insertable = false, updatable = false)  | 
  |  70 |    1 |        List<RoleMemberBo> members = new AutoPopulatingList(RoleMemberBo.class);  | 
  |  71 |     | 
     | 
  |  72 |     | 
       @Transient  | 
  |  73 |     | 
       String principalName;  | 
  |  74 |     | 
     | 
  |  75 |     | 
       @Transient  | 
  |  76 |     | 
       String groupNamespaceCode;  | 
  |  77 |     | 
     | 
  |  78 |     | 
       @Transient  | 
  |  79 |     | 
       String groupName;  | 
  |  80 |     | 
     | 
  |  81 |     | 
       @Transient  | 
  |  82 |     | 
       String permNamespaceCode;  | 
  |  83 |     | 
     | 
  |  84 |     | 
       @Transient  | 
  |  85 |     | 
       String permName;  | 
  |  86 |     | 
     | 
  |  87 |     | 
       @Transient  | 
  |  88 |     | 
       String permTmplNamespaceCode;  | 
  |  89 |     | 
     | 
  |  90 |     | 
       @Transient  | 
  |  91 |     | 
       String permTmplName;  | 
  |  92 |     | 
     | 
  |  93 |     | 
       @Transient  | 
  |  94 |     | 
       String respNamespaceCode;  | 
  |  95 |     | 
     | 
  |  96 |     | 
       @Transient  | 
  |  97 |     | 
       String respName;  | 
  |  98 |     | 
     | 
  |  99 |     | 
       @Transient  | 
  |  100 |     | 
       String respTmplNamespaceCode;  | 
  |  101 |     | 
     | 
  |  102 |     | 
       @Transient  | 
  |  103 |     | 
       String respTmplName;  | 
  |  104 |     | 
     | 
  |  105 |     | 
       protected List<String> getMembersOfType(String memberTypeCode) { | 
  |  106 |    0 |            List<String> roleMembers = new ArrayList<String>();  | 
  |  107 |    0 |            for (RoleMemberBo member: getMembers()) { | 
  |  108 |    0 |                if (member.getMemberTypeCode().equals(memberTypeCode)  | 
  |  109 |    0 |                        && member.isActive()) { | 
  |  110 |    0 |                    roleMembers.add(member.getMemberId());  | 
  |  111 |     | 
               }  | 
  |  112 |     | 
           }  | 
  |  113 |    0 |            return roleMembers;  | 
  |  114 |     | 
       }  | 
  |  115 |     | 
     | 
  |  116 |     | 
       public KimTypeBo getKimRoleType() { | 
  |  117 |    0 |            return KimTypeBo.from(getTypeInfoService().getKimType(kimTypeId));  | 
  |  118 |     | 
       }  | 
  |  119 |     | 
     | 
  |  120 |     | 
       private transient static KimTypeInfoService kimTypeInfoService;  | 
  |  121 |     | 
     | 
  |  122 |     | 
       protected KimTypeInfoService getTypeInfoService() { | 
  |  123 |    0 |            if (kimTypeInfoService == null) { | 
  |  124 |    0 |                kimTypeInfoService = KimApiServiceLocator.getKimTypeInfoService();  | 
  |  125 |     | 
           }  | 
  |  126 |    0 |            return kimTypeInfoService;  | 
  |  127 |     | 
       }  | 
  |  128 |     | 
     | 
  |  129 |     | 
     | 
  |  130 |     | 
       public static Role to(RoleBo bo) { | 
  |  131 |    0 |            if (bo == null) {return null;} | 
  |  132 |    1 |            return Role.Builder.create(bo).build()  | 
  |  133 |     | 
       }  | 
  |  134 |     | 
     | 
  |  135 |     | 
       public static RoleBo from(Role immutable) { | 
  |  136 |    0 |            if (immutable == null) {return null} | 
  |  137 |    0 |            RoleBo bo = new RoleBo()  | 
  |  138 |    0 |            bo.id = immutable.id;  | 
  |  139 |    0 |            bo.name = immutable.name  | 
  |  140 |    0 |            bo.namespaceCode = immutable.namespaceCode  | 
  |  141 |    0 |            bo.description = immutable.description  | 
  |  142 |    0 |            bo.kimTypeId = immutable.kimTypeId  | 
  |  143 |    0 |            bo.active = immutable.active  | 
  |  144 |    0 |            bo.versionNumber = immutable.versionNumber  | 
  |  145 |     | 
       }  | 
  |  146 |     | 
   }  |