1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kim.impl.identity;
17
18 import javax.persistence.Column;
19 import javax.persistence.Id;
20 import javax.persistence.MappedSuperclass;
21
22 import org.kuali.rice.kim.api.identity.CodedAttribute;
23 import org.kuali.rice.kim.api.identity.CodedAttributeContract;
24 import org.kuali.rice.krad.bo.DataObjectBase;
25 import org.kuali.rice.krad.data.jpa.converters.BooleanYNConverter;
26
27 @MappedSuperclass
28 public abstract class CodedAttributeBo extends DataObjectBase implements CodedAttributeContract {
29 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(CodedAttributeBo.class);
30 private static final long serialVersionUID = -5023039880648352464L;
31 @Id
32 @Column(name = "CD")
33 private String code;
34 @Column(name = "NM")
35 private String name;
36 @javax.persistence.Convert(converter=BooleanYNConverter.class)
37 @Column(name = "ACTV_IND")
38 private boolean active;
39 @Column(name = "DISPLAY_SORT_CD")
40 private String sortCode;
41
42
43
44
45
46
47
48 public static <T extends CodedAttributeBo>CodedAttribute to(T bo) {
49 if (bo == null) {
50 return null;
51 }
52
53 return CodedAttribute.Builder.create(bo).build();
54 }
55
56
57
58
59
60
61
62
63 public static <T extends CodedAttributeBo> T from(Class<T> type, CodedAttribute immutable) {
64 if (immutable == null) {
65 return null;
66 }
67 T bo = null;
68 try {
69 bo = type.newInstance();
70
71 bo.setCode(immutable.getCode());
72 bo.setName(immutable.getName());
73 bo.setSortCode(immutable.getSortCode());
74 bo.setActive(immutable.isActive());
75 bo.setVersionNumber(immutable.getVersionNumber());
76 bo.setObjectId(immutable.getObjectId());
77 } catch (InstantiationException e) {
78 LOG.error(e.getMessage(), e);
79 } catch (IllegalAccessException e) {
80 LOG.error(e.getMessage(), e);
81 }
82 return bo;
83 }
84
85 @Override
86 public String getCode() {
87 return code;
88 }
89
90 public void setCode(String code) {
91 this.code = code;
92 }
93
94 @Override
95 public String getName() {
96 return name;
97 }
98
99 public void setName(String name) {
100 this.name = name;
101 }
102
103 @Override
104 public boolean isActive() {
105 return active;
106 }
107
108 public void setActive(boolean active) {
109 this.active = active;
110 }
111
112 @Override
113 public String getSortCode() {
114 return sortCode;
115 }
116
117 public void setSortCode(String sortCode) {
118 this.sortCode = sortCode;
119 }
120
121 public void refresh() {
122 }
123
124 }