|  1 |     | 
     | 
  |  2 |     | 
     | 
  |  3 |     | 
     | 
  |  4 |     | 
     | 
  |  5 |     | 
     | 
  |  6 |     | 
     | 
  |  7 |     | 
     | 
  |  8 |     | 
     | 
  |  9 |     | 
     | 
  |  10 |     | 
     | 
  |  11 |     | 
     | 
  |  12 |     | 
     | 
  |  13 |     | 
     | 
  |  14 |     | 
     | 
  |  15 |     | 
     | 
  |  16 |     | 
   package org.kuali.rice.kim.bo.types.impl;  | 
  |  17 |     | 
     | 
  |  18 |     | 
   import org.hibernate.annotations.Type;  | 
  |  19 |     | 
   import org.kuali.rice.kim.bo.types.dto.KimTypeAttributeInfo;  | 
  |  20 |     | 
   import org.kuali.rice.kim.bo.types.dto.KimTypeInfo;  | 
  |  21 |     | 
   import org.kuali.rice.kns.bo.PersistableBusinessObjectBase;  | 
  |  22 |     | 
     | 
  |  23 |     | 
   import javax.persistence.*;  | 
  |  24 |     | 
   import java.util.ArrayList;  | 
  |  25 |     | 
   import java.util.List;  | 
  |  26 |     | 
     | 
  |  27 |     | 
     | 
  |  28 |     | 
     | 
  |  29 |     | 
     | 
  |  30 |     | 
   @Entity  | 
  |  31 |     | 
   @Table(name="KRIM_TYP_T")  | 
  |  32 |     | 
   @NamedQueries({ | 
  |  33 |     | 
     @NamedQuery(name="KimTypeImpl.FindByKimTypeId", query="select kt from KimTypeImpl kt where kt.kimTypeId = :kimTypeId"),  | 
  |  34 |     | 
     @NamedQuery(name="KimTypeImpl.FindByKimTypeName", query="select kt from KimTypeImpl kt where kt.name = :name and kt.namespaceCode = :namespaceCode")  | 
  |  35 |     | 
   })  | 
  |  36 |     | 
   public class KimTypeImpl extends PersistableBusinessObjectBase { | 
  |  37 |     | 
     | 
  |  38 |     | 
           private static final long serialVersionUID = 7752050088434254168L;  | 
  |  39 |     | 
           @Id  | 
  |  40 |     | 
           @Column(name="KIM_TYP_ID")  | 
  |  41 |     | 
           protected String kimTypeId;  | 
  |  42 |     | 
           @Column(name="NM")  | 
  |  43 |     | 
           protected String name;  | 
  |  44 |     | 
           @Column(name="NMSPC_CD")  | 
  |  45 |     | 
           protected String namespaceCode;  | 
  |  46 |     | 
           @Column(name="SRVC_NM")  | 
  |  47 |     | 
           protected String kimTypeServiceName;  | 
  |  48 |     | 
           @Type(type="yes_no")  | 
  |  49 |     | 
           @Column(name="ACTV_IND")  | 
  |  50 |     | 
           protected boolean active;  | 
  |  51 |     | 
     | 
  |  52 |     | 
           @OneToMany(targetEntity=KimTypeAttributeImpl.class,cascade={CascadeType.ALL},fetch=FetchType.EAGER) | 
  |  53 |     | 
           @JoinColumn(name="KIM_TYP_ID", insertable=false, updatable=false)  | 
  |  54 |     | 
           protected List<KimTypeAttributeImpl> attributeDefinitions;  | 
  |  55 |     | 
     | 
  |  56 |    0 |            public KimTypeImpl() { | 
  |  57 |    0 |                    attributeDefinitions = new ArrayList<KimTypeAttributeImpl> ();  | 
  |  58 |    0 |            }  | 
  |  59 |     | 
     | 
  |  60 |     | 
           public List<KimTypeAttributeImpl> getAttributeDefinitions() { | 
  |  61 |    0 |                    return attributeDefinitions;  | 
  |  62 |     | 
           }  | 
  |  63 |     | 
     | 
  |  64 |     | 
           public String getKimTypeId() { | 
  |  65 |    0 |                    return kimTypeId;  | 
  |  66 |     | 
           }  | 
  |  67 |     | 
     | 
  |  68 |     | 
           public String getKimTypeServiceName() { | 
  |  69 |    0 |                    return kimTypeServiceName;  | 
  |  70 |     | 
           }  | 
  |  71 |     | 
     | 
  |  72 |     | 
           public String getName() { | 
  |  73 |    0 |                    return name;  | 
  |  74 |     | 
           }  | 
  |  75 |     | 
     | 
  |  76 |     | 
           public void setAttributeDefinitions(List<KimTypeAttributeImpl> attributeDefinitions) { | 
  |  77 |    0 |                    this.attributeDefinitions = attributeDefinitions;  | 
  |  78 |    0 |            }  | 
  |  79 |     | 
     | 
  |  80 |     | 
           public void setKimTypeServiceName(String kimTypeServiceName) { | 
  |  81 |    0 |                    this.kimTypeServiceName = kimTypeServiceName;  | 
  |  82 |    0 |            }  | 
  |  83 |     | 
     | 
  |  84 |     | 
           public void setName(String name) { | 
  |  85 |    0 |                    this.name = name;  | 
  |  86 |    0 |            }  | 
  |  87 |     | 
     | 
  |  88 |     | 
             | 
  |  89 |     | 
     | 
  |  90 |     | 
     | 
  |  91 |     | 
           public boolean isActive() { | 
  |  92 |    0 |                    return active;  | 
  |  93 |     | 
           }  | 
  |  94 |     | 
     | 
  |  95 |     | 
             | 
  |  96 |     | 
     | 
  |  97 |     | 
     | 
  |  98 |     | 
           public void setActive(boolean active) { | 
  |  99 |    0 |                    this.active = active;  | 
  |  100 |    0 |            }  | 
  |  101 |     | 
     | 
  |  102 |     | 
           public String getNamespaceCode() { | 
  |  103 |    0 |                    return this.namespaceCode;  | 
  |  104 |     | 
           }  | 
  |  105 |     | 
     | 
  |  106 |     | 
           public void setNamespaceCode(String namespaceCode) { | 
  |  107 |    0 |                    this.namespaceCode = namespaceCode;  | 
  |  108 |    0 |            }  | 
  |  109 |     | 
     | 
  |  110 |     | 
           public void setKimTypeId(String kimTypeId) { | 
  |  111 |    0 |                    this.kimTypeId = kimTypeId;  | 
  |  112 |    0 |            }  | 
  |  113 |     | 
     | 
  |  114 |     | 
           public KimTypeInfo toInfo() { | 
  |  115 |    0 |                    KimTypeInfo info = new KimTypeInfo();  | 
  |  116 |    0 |                    info.setKimTypeId( kimTypeId );  | 
  |  117 |    0 |                    info.setName( name );  | 
  |  118 |    0 |                    info.setKimTypeServiceName(kimTypeServiceName);  | 
  |  119 |    0 |                    info.setNamespaceCode(namespaceCode);  | 
  |  120 |    0 |                    List<KimTypeAttributeInfo> attribs = new ArrayList<KimTypeAttributeInfo>();   | 
  |  121 |    0 |                    info.setAttributeDefinitions( attribs );  | 
  |  122 |    0 |                    for ( KimTypeAttributeImpl attribImpl : getAttributeDefinitions() ) { | 
  |  123 |    0 |                            attribs.add( makeAttributeInfo(attribImpl) );  | 
  |  124 |     | 
                   }                  | 
  |  125 |    0 |                    return info;  | 
  |  126 |     | 
           }  | 
  |  127 |     | 
     | 
  |  128 |     | 
           protected KimTypeAttributeInfo makeAttributeInfo( KimTypeAttributeImpl attribImpl ) { | 
  |  129 |    0 |                    KimTypeAttributeInfo attrib = new KimTypeAttributeInfo();  | 
  |  130 |    0 |                    attrib.setAttributeName( attribImpl.getKimAttribute().getAttributeName() );  | 
  |  131 |    0 |                    attrib.setSortCode( attribImpl.getSortCode() );  | 
  |  132 |    0 |                    attrib.setComponentName( attribImpl.getKimAttribute().getComponentName() );  | 
  |  133 |    0 |                    attrib.setNamespaceCode( attribImpl.getKimAttribute().getNamespaceCode() );  | 
  |  134 |    0 |                    attrib.setAttributeLabel( attribImpl.getKimAttribute().getAttributeLabel() );  | 
  |  135 |    0 |                    attrib.setKimAttributeId( attribImpl.getKimAttributeId() );  | 
  |  136 |    0 |                    return attrib;  | 
  |  137 |     | 
           }  | 
  |  138 |     | 
             | 
  |  139 |     | 
             | 
  |  140 |     | 
     | 
  |  141 |     | 
     | 
  |  142 |     | 
     | 
  |  143 |     | 
     | 
  |  144 |     | 
           public KimTypeAttributeInfo getAttributeDefinition(String kimAttributeId) { | 
  |  145 |    0 |                    if ( kimAttributeId == null ) { | 
  |  146 |    0 |                            return null;  | 
  |  147 |     | 
                   }  | 
  |  148 |    0 |                    for ( KimTypeAttributeImpl def : getAttributeDefinitions() ) { | 
  |  149 |    0 |                            if ( def.kimAttributeId.equals( kimAttributeId ) ) { | 
  |  150 |    0 |                                    return makeAttributeInfo(def);  | 
  |  151 |     | 
                           }  | 
  |  152 |     | 
                   }  | 
  |  153 |    0 |                    return null;  | 
  |  154 |     | 
           }  | 
  |  155 |     | 
   }  |