View Javadoc

1   /**
2    * Copyright 2005-2012 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 org.kuali.rice.core.api.exception.RiceRuntimeException;
19  
20  import javax.persistence.Column;
21  import javax.persistence.Entity;
22  import javax.persistence.Id;
23  import javax.persistence.Table;
24  import javax.persistence.Transient;
25  
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")
38  public class DocumentHeader extends PersistableBusinessObjectBase {
39  
40      @Id
41  	@Column(name="DOC_HDR_ID")
42  	private String documentNumber;
43      @Column(name="FDOC_DESC")
44  	private String documentDescription;
45      @Column(name="ORG_DOC_HDR_ID")
46  	private String organizationDocumentNumber;
47      @Column(name="TMPL_DOC_HDR_ID")
48  	private String documentTemplateNumber;
49      @Column(name="EXPLANATION")
50  	private String explanation;
51      
52      @Transient
53      private WorkflowDocument workflowDocument;
54  
55      /**
56       * Constructor - creates empty instances of dependent objects
57       * 
58       */
59      public DocumentHeader() {
60          super();
61      }
62  
63      /**
64       * Returns an instance of the the {@link WorkflowDocument} associated with this document header.
65       * The workflowDocument provides the core client interface for interacting with the KEW workflow module.
66       * @return workflowDocument
67       */
68      public WorkflowDocument getWorkflowDocument() {
69          if (workflowDocument == null) {
70              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.");
71          }
72  
73          return workflowDocument;
74      }
75  
76      /**
77       * Returns whether this document header has a {@link WorkflowDocument} associated with it.
78       * @return true if the workflowDocument is not null
79       */
80      public boolean hasWorkflowDocument() {
81          return (workflowDocument != null);
82      }
83  
84  
85      /**
86       * Associates a {@link WorkflowDocument} with this document header.
87       * @param workflowDocument
88       */
89      public void setWorkflowDocument(WorkflowDocument workflowDocument) {
90          this.workflowDocument = workflowDocument;
91      }
92  
93      /**
94       * Returns the documentNumber (also known as the docuementHeaderId). This is a unique identifier for the document.
95       * @return the documentNumber
96       */
97      public String getDocumentNumber() {
98          return this.documentNumber;
99      }
100 
101     /**
102      * Sets the documentNumber for this document. It serves as a unique identifier for the document.
103      * @param documentNumber the documentNumber to set
104      */
105     public void setDocumentNumber(String documentNumber) {
106         this.documentNumber = documentNumber;
107     }
108 
109     /**
110      * Returns the description text for this document.
111      * @return the documentDescription
112      */
113     public String getDocumentDescription() {
114         return this.documentDescription;
115     }
116 
117     /**
118      * Sets the description text for this document.
119      * @param documentDescription the documentDescription to set
120      */
121     public void setDocumentDescription(String documentDescription) {
122         this.documentDescription = documentDescription;
123     }
124 
125     /**
126      * Returns the organizationDocumentNumber. This identifier is one that may be used by a client to refer to the document.
127      * @return the organizationDocumentNumber
128      */
129     public String getOrganizationDocumentNumber() {
130         return this.organizationDocumentNumber;
131     }
132 
133     /**
134      * Sets the value of the organizationDocumentNumber
135      * @param organizationDocumentNumber the organizationDocumentNumber to set
136      */
137     public void setOrganizationDocumentNumber(String organizationDocumentNumber) {
138         this.organizationDocumentNumber = organizationDocumentNumber;
139     }
140 
141     /**
142      * Returns the documentTemplateNumber. It identifies the document template associated with this document.
143      * @return the documentTemplateNumber
144      */
145     public String getDocumentTemplateNumber() {
146         return this.documentTemplateNumber;
147     }
148 
149     /**
150      * Associates this document with a document template.
151      * @param documentTemplateNumber the id of the documentTemplate associated with this document
152      */
153     public void setDocumentTemplateNumber(String documentTemplateNumber) {
154         this.documentTemplateNumber = documentTemplateNumber;
155     }
156 
157     /**
158      * Gets the explanation attribute. This text provides additional information about the purpose of the document.
159      * @return Returns the explanation.
160      */
161     public String getExplanation() {
162         return explanation;
163     }
164 
165     /**
166      * Sets the explanation attribute value.
167      * @param explanation The explanation text string.
168      */
169     public void setExplanation(String explanation) {
170         this.explanation = explanation;
171     }
172 
173 }