1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.documentlink;
17
18 import java.io.Serializable;
19
20 import javax.persistence.Column;
21 import javax.persistence.Entity;
22 import javax.persistence.GeneratedValue;
23 import javax.persistence.Id;
24 import javax.persistence.Table;
25
26 import org.hibernate.annotations.GenericGenerator;
27 import org.hibernate.annotations.Parameter;
28 import org.kuali.rice.core.framework.persistence.jpa.OrmUtils;
29 import org.kuali.rice.kew.api.document.DocumentLinkContract;
30 import org.kuali.rice.kew.service.KEWServiceLocator;
31
32
33
34
35
36
37
38
39 @Entity
40 @Table(name="KREW_DOC_LNK_T")
41
42 public class DocumentLink implements Serializable, DocumentLinkContract {
43
44 private static final long serialVersionUID = 551926904795633010L;
45
46 @Id
47 @GeneratedValue(generator="KREW_DOC_LNK_S")
48 @GenericGenerator(name="KREW_DOC_LNK_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={
49 @Parameter(name="sequence_name",value="KREW_DOC_LNK_S"),
50 @Parameter(name="value_column",value="id")
51 })
52 @Column(name="DOC_LNK_ID")
53 private String docLinkId;
54 @Column(name="ORGN_DOC_ID")
55 private String orgnDocId;
56 @Column(name="DEST_DOC_ID")
57 private String destDocId;
58
59
60
61
62 public String getDocLinkId() {
63 return this.docLinkId;
64 }
65
66
67
68
69 public void setDocLinkId(String docLinkId) {
70 this.docLinkId = docLinkId;
71 }
72
73
74
75
76 public String getOrgnDocId() {
77 return this.orgnDocId;
78 }
79
80
81
82
83 public void setOrgnDocId(String orgnDocId) {
84 this.orgnDocId = orgnDocId;
85 }
86
87
88
89
90 public String getDestDocId() {
91 return this.destDocId;
92 }
93
94
95
96
97 public void setDestDocId(String destDocId) {
98 this.destDocId = destDocId;
99 }
100
101
102 public void beforeInsert(){
103 OrmUtils.populateAutoIncValue(this, KEWServiceLocator.getEntityManagerFactory().createEntityManager());
104 }
105
106
107
108 @Override
109 public String getId() {
110 if (getDocLinkId() == null) {
111 return null;
112 }
113 return getDocLinkId().toString();
114 }
115
116 @Override
117 public String getOriginatingDocumentId() {
118 return getOrgnDocId();
119 }
120
121 @Override
122 public String getDestinationDocumentId() {
123 return getDestDocId();
124 }
125
126 public static org.kuali.rice.kew.api.document.DocumentLink to(DocumentLink documentLinkBo) {
127 if (documentLinkBo == null) {
128 return null;
129 }
130 return org.kuali.rice.kew.api.document.DocumentLink.Builder.create(documentLinkBo).build();
131 }
132
133 public static DocumentLink from(org.kuali.rice.kew.api.document.DocumentLink documentLink) {
134 if (documentLink == null) {
135 return null;
136 }
137 DocumentLink documentLinkBo = new DocumentLink();
138 if (documentLink.getId() != null) {
139 documentLinkBo.setDocLinkId(documentLink.getId());
140 }
141 documentLinkBo.setOrgnDocId(documentLink.getOriginatingDocumentId());
142 documentLinkBo.setDestDocId(documentLink.getDestinationDocumentId());
143 return documentLinkBo;
144 }
145
146 }