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