View Javadoc
1   /**
2    * Copyright 2005-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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   * Server side bean for DocumentLinkDAO 
32   * 
33   * @author Kuali Rice Team (kuali-rice@googlegroups.com)
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  	 * @return the docLinkId
65  	 */
66  	public String getDocLinkId() {
67  		return this.docLinkId;
68  	}
69  
70  	/**
71  	 * @param docLinkId the docLinkId to set
72  	 */
73  	public void setDocLinkId(String docLinkId) {
74  		this.docLinkId = docLinkId;
75  	}
76  
77  	/**
78  	 * @return the orgnDocId
79  	 */
80  	public String getOrgnDocId() {
81  		return this.orgnDocId;
82  	}
83  
84  	/**
85  	 * @param orgnDocId the orgnDocId to set
86  	 */
87  	public void setOrgnDocId(String orgnDocId) {
88  		this.orgnDocId = orgnDocId;
89  	}
90  
91  	/**
92  	 * @return the destDocId
93  	 */
94  	public String getDestDocId() {
95  		return this.destDocId;
96  	}
97  
98  	/**
99  	 * @param destDocId the destDocId to set
100 	 */
101 	public void setDestDocId(String destDocId) {
102 		this.destDocId = destDocId;
103 	}
104 
105 	// new contract methods for Rice 2.0
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 }