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 org.kuali.rice.kew.api.document.DocumentLinkContract;
19  import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
20  
21  import javax.persistence.Column;
22  import javax.persistence.Entity;
23  import javax.persistence.GeneratedValue;
24  import javax.persistence.Id;
25  import javax.persistence.NamedQueries;
26  import javax.persistence.NamedQuery;
27  import javax.persistence.Table;
28  import java.io.Serializable;
29  
30  
31  
32  
33  
34  
35  
36  
37  @Entity
38  @Table(name="KREW_DOC_LNK_T")
39  @NamedQueries({
40      @NamedQuery(name="DocumentLink.GetLinkedDocument",query="select dl from DocumentLink dl WHERE dl.orgnDocId = "
41          + ":orgnDocId and dl.destDocId = :destDocId"),
42      @NamedQuery(name="DocumentLink.GetLinkedDocumentsByDocId",query="select dl from DocumentLink dl "
43              + "WHERE dl.orgnDocId = :orgnDocId"),
44      @NamedQuery(name="DocumentLink.GetOutgoingLinkedDocumentsByDocId",query="select dl from DocumentLink dl "
45                  + "WHERE dl.destDocId = :destDocId")
46  })
47  public class DocumentLink implements Serializable, DocumentLinkContract {
48  
49  	private static final long serialVersionUID = 551926904795633010L;
50  	
51  	@Id
52      @PortableSequenceGenerator(name="KREW_DOC_LNK_S")
53  	@GeneratedValue(generator="KREW_DOC_LNK_S")
54  	@Column(name="DOC_LNK_ID")
55  	private String docLinkId;
56  
57      @Column(name="ORGN_DOC_ID")
58  	private String orgnDocId;
59  
60      @Column(name="DEST_DOC_ID")
61  	private String destDocId;
62      
63  	
64  
65  
66  	public String getDocLinkId() {
67  		return this.docLinkId;
68  	}
69  
70  	
71  
72  
73  	public void setDocLinkId(String docLinkId) {
74  		this.docLinkId = docLinkId;
75  	}
76  
77  	
78  
79  
80  	public String getOrgnDocId() {
81  		return this.orgnDocId;
82  	}
83  
84  	
85  
86  
87  	public void setOrgnDocId(String orgnDocId) {
88  		this.orgnDocId = orgnDocId;
89  	}
90  
91  	
92  
93  
94  	public String getDestDocId() {
95  		return this.destDocId;
96  	}
97  
98  	
99  
100 
101 	public void setDestDocId(String destDocId) {
102 		this.destDocId = destDocId;
103 	}
104 
105 	
106 	
107 	@Override
108 	public String getId() {
109 		if (getDocLinkId() == null) {
110 			return null;
111 		}
112 		return getDocLinkId().toString();
113 	}
114 
115 	@Override
116 	public String getOriginatingDocumentId() {
117 		return getOrgnDocId();
118 	}
119 
120 	@Override
121 	public String getDestinationDocumentId() {
122 		return getDestDocId();
123 	}
124 	
125 	public static org.kuali.rice.kew.api.document.DocumentLink to(DocumentLink documentLinkBo) {
126 		if (documentLinkBo == null) {
127 			return null;
128 		}
129 		return org.kuali.rice.kew.api.document.DocumentLink.Builder.create(documentLinkBo).build();
130 	}
131 
132 	public static DocumentLink from(org.kuali.rice.kew.api.document.DocumentLink documentLink) {
133 		if (documentLink == null) {
134 			return null;
135 		}
136 		DocumentLink documentLinkBo = new DocumentLink();
137 		if (documentLink.getId() != null) {
138 			documentLinkBo.setDocLinkId(documentLink.getId());
139 		}
140 		documentLinkBo.setOrgnDocId(documentLink.getOriginatingDocumentId());
141 		documentLinkBo.setDestDocId(documentLink.getDestinationDocumentId());
142 		return documentLinkBo;
143 	}
144 	
145 }