1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kim.impl.identity.name;
17
18 import org.kuali.rice.kim.api.identity.name.EntityName;
19 import org.kuali.rice.krad.data.jpa.eclipselink.PortableSequenceGenerator;
20
21 import javax.persistence.Column;
22 import javax.persistence.Entity;
23 import javax.persistence.FetchType;
24 import javax.persistence.GeneratedValue;
25 import javax.persistence.Id;
26 import javax.persistence.JoinColumn;
27 import javax.persistence.ManyToOne;
28 import javax.persistence.Table;
29 import java.sql.Timestamp;
30
31 @Entity
32 @Table(name = "KRIM_ENTITY_NM_T")
33 public class EntityNameBo extends EntityNameBase {
34 private static final long serialVersionUID = -1449221117942310530L;
35 @Id
36 @GeneratedValue(generator = "KRIM_ENTITY_NM_ID_S")
37 @PortableSequenceGenerator(name = "KRIM_ENTITY_NM_ID_S")
38 @Column(name = "ENTITY_NM_ID")
39 private String id;
40 @ManyToOne(targetEntity = EntityNameTypeBo.class, fetch = FetchType.EAGER, cascade = {})
41 @JoinColumn(
42 name = "NM_TYP_CD", insertable = false, updatable = false)
43 private EntityNameTypeBo nameType;
44
45 public static EntityName to(EntityNameBo bo) {
46 if (bo == null) {
47 return null;
48 }
49
50 return EntityName.Builder.create(bo).build();
51 }
52
53
54
55
56
57
58
59 public static EntityNameBo from(EntityName immutable) {
60 if (immutable == null) {
61 return null;
62 }
63
64 EntityNameBo bo = new EntityNameBo();
65 bo.setId(immutable.getId());
66 bo.setActive(immutable.isActive());
67
68 bo.setEntityId(immutable.getEntityId());
69 bo.setNameType(EntityNameTypeBo.from(immutable.getNameType()));
70 if (immutable.getNameType() != null) {
71 bo.setNameCode(immutable.getNameType().getCode());
72 }
73
74 bo.setFirstName(immutable.getFirstNameUnmasked());
75 bo.setLastName(immutable.getLastNameUnmasked());
76 bo.setMiddleName(immutable.getMiddleNameUnmasked());
77 bo.setNamePrefix(immutable.getNamePrefixUnmasked());
78 bo.setNameTitle(immutable.getNameTitleUnmasked());
79 bo.setNameSuffix(immutable.getNameSuffixUnmasked());
80 bo.setNoteMessage(immutable.getNoteMessage());
81 if (immutable.getNameChangedDate() != null) {
82 bo.setNameChangedDate(new Timestamp(immutable.getNameChangedDate().getMillis()));
83 }
84
85 bo.setDefaultValue(immutable.isDefaultValue());
86 bo.setVersionNumber(immutable.getVersionNumber());
87 bo.setObjectId(immutable.getObjectId());
88
89 return bo;
90 }
91
92 @Override
93 public EntityNameTypeBo getNameType() {
94 return this.nameType;
95 }
96
97 public void setNameType(EntityNameTypeBo nameType) {
98 this.nameType = nameType;
99 }
100
101
102 @Override
103 public String getId() {
104 return id;
105 }
106
107 public void setId(String id) {
108 this.id = id;
109 }
110
111
112 }