1 /**
2 * Copyright 2005-2015 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.krad.bo;
17
18 import javax.persistence.Column;
19 import javax.persistence.Entity;
20 import javax.persistence.Id;
21 import javax.persistence.Table;
22 import javax.persistence.Transient;
23 import javax.persistence.UniqueConstraint;
24
25 import org.eclipse.persistence.annotations.Index;
26 import org.kuali.rice.core.api.exception.RiceRuntimeException;
27 import org.kuali.rice.kew.api.WorkflowDocument;
28
29 /**
30 * Business Object representing a document header. The document header contains metadata about a document.
31 * This contains a reference to the template associated with the document.
32 * This also provides the access to the underlying {@link WorkflowDocument} associated with this document header.
33 *
34 * @author Kuali Rice Team (rice.collab@kuali.org)
35 */
36 @Entity
37 @Table(name="KRNS_DOC_HDR_T",uniqueConstraints= {
38 @UniqueConstraint(name="KRNS_DOC_HDR_TC0",columnNames="OBJ_ID")
39 })
40 public class DocumentHeader extends PersistableBusinessObjectBaseAdapter {
41 private static final long serialVersionUID = 2302690966928882488L;
42
43 @Id
44 @Column(name="DOC_HDR_ID",length=14)
45 protected String documentNumber;
46 @Column(name="FDOC_DESC",length=255)
47 protected String documentDescription;
48
49 @Index(name="KRNS_DOC_HDR_TI3")
50 @Column(name="ORG_DOC_HDR_ID",length=10)
51 protected String organizationDocumentNumber;
52 @Column(name="TMPL_DOC_HDR_ID",length=14)
53 protected String documentTemplateNumber;
54 @Column(name="EXPLANATION",length=400)
55 protected String explanation;
56
57 @Transient
58 private WorkflowDocument workflowDocument;
59
60 /**
61 * Constructor - creates empty instances of dependent objects
62 *
63 */
64 public DocumentHeader() {
65 super();
66 }
67
68 /**
69 * Returns an instance of the the {@link WorkflowDocument} associated with this document header.
70 * The workflowDocument provides the core client interface for interacting with the KEW workflow module.
71 * @return workflowDocument
72 */
73 public WorkflowDocument getWorkflowDocument() {
74 if (workflowDocument == null) {
75 throw new RiceRuntimeException("The workflow document is null. This indicates that the DocumentHeader has not been initialized properly. This can be caused by not retrieving a document using the DocumentService.");
76 }
77
78 return workflowDocument;
79 }
80
81 /**
82 * Returns whether this document header has a {@link WorkflowDocument} associated with it.
83 * @return true if the workflowDocument is not null
84 */
85 public boolean hasWorkflowDocument() {
86 return (workflowDocument != null);
87 }
88
89
90 /**
91 * Associates a {@link WorkflowDocument} with this document header.
92 * @param workflowDocument
93 */
94 public void setWorkflowDocument(WorkflowDocument workflowDocument) {
95 this.workflowDocument = workflowDocument;
96 }
97
98 /**
99 * Returns the documentNumber (also known as the docuementHeaderId). This is a unique identifier for the document.
100 * @return the documentNumber
101 */
102 public String getDocumentNumber() {
103 return this.documentNumber;
104 }
105
106 /**
107 * Sets the documentNumber for this document. It serves as a unique identifier for the document.
108 * @param documentNumber the documentNumber to set
109 */
110 public void setDocumentNumber(String documentNumber) {
111 this.documentNumber = documentNumber;
112 }
113
114 /**
115 * Returns the description text for this document.
116 * @return the documentDescription
117 */
118 public String getDocumentDescription() {
119 return this.documentDescription;
120 }
121
122 /**
123 * Sets the description text for this document.
124 * @param documentDescription the documentDescription to set
125 */
126 public void setDocumentDescription(String documentDescription) {
127 this.documentDescription = documentDescription;
128 }
129
130 /**
131 * Returns the organizationDocumentNumber. This identifier is one that may be used by a client to refer to the document.
132 * @return the organizationDocumentNumber
133 */
134 public String getOrganizationDocumentNumber() {
135 return this.organizationDocumentNumber;
136 }
137
138 /**
139 * Sets the value of the organizationDocumentNumber
140 * @param organizationDocumentNumber the organizationDocumentNumber to set
141 */
142 public void setOrganizationDocumentNumber(String organizationDocumentNumber) {
143 this.organizationDocumentNumber = organizationDocumentNumber;
144 }
145
146 /**
147 * Returns the documentTemplateNumber. It identifies the document template associated with this document.
148 * @return the documentTemplateNumber
149 */
150 public String getDocumentTemplateNumber() {
151 return this.documentTemplateNumber;
152 }
153
154 /**
155 * Associates this document with a document template.
156 * @param documentTemplateNumber the id of the documentTemplate associated with this document
157 */
158 public void setDocumentTemplateNumber(String documentTemplateNumber) {
159 this.documentTemplateNumber = documentTemplateNumber;
160 }
161
162 /**
163 * Gets the explanation attribute. This text provides additional information about the purpose of the document.
164 * @return Returns the explanation.
165 */
166 public String getExplanation() {
167 return explanation;
168 }
169
170 /**
171 * Sets the explanation attribute value.
172 * @param explanation The explanation text string.
173 */
174 public void setExplanation(String explanation) {
175 this.explanation = explanation;
176 }
177
178 }