001/**
002 * Copyright 2005-2016 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.krad.bo;
017
018import org.kuali.rice.core.api.exception.RiceRuntimeException;
019
020import javax.persistence.Column;
021import javax.persistence.Entity;
022import javax.persistence.Id;
023import javax.persistence.Table;
024import javax.persistence.Transient;
025
026import org.kuali.rice.core.api.exception.RiceRuntimeException;
027import org.kuali.rice.kew.api.WorkflowDocument;
028
029/**
030 * Business Object representing a document header. The document header contains metadata about a document.
031 * This contains a reference to the template associated with the document.
032 * This also provides the access to the underlying {@link WorkflowDocument} associated with this document header.
033 * 
034 * @author Kuali Rice Team (rice.collab@kuali.org)
035 */
036@Entity
037@Table(name="KRNS_DOC_HDR_T")
038public class DocumentHeader extends PersistableBusinessObjectBase {
039
040    @Id
041        @Column(name="DOC_HDR_ID")
042        private String documentNumber;
043    @Column(name="FDOC_DESC")
044        private String documentDescription;
045    @Column(name="ORG_DOC_HDR_ID")
046        private String organizationDocumentNumber;
047    @Column(name="TMPL_DOC_HDR_ID")
048        private String documentTemplateNumber;
049    @Column(name="EXPLANATION")
050        private String explanation;
051    
052    @Transient
053    private WorkflowDocument workflowDocument;
054
055    /**
056     * Constructor - creates empty instances of dependent objects
057     * 
058     */
059    public DocumentHeader() {
060        super();
061    }
062
063    /**
064     * Returns an instance of the the {@link WorkflowDocument} associated with this document header.
065     * The workflowDocument provides the core client interface for interacting with the KEW workflow module.
066     * @return workflowDocument
067     */
068    public WorkflowDocument getWorkflowDocument() {
069        if (workflowDocument == null) {
070            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.");
071        }
072
073        return workflowDocument;
074    }
075
076    /**
077     * Returns whether this document header has a {@link WorkflowDocument} associated with it.
078     * @return true if the workflowDocument is not null
079     */
080    public boolean hasWorkflowDocument() {
081        return (workflowDocument != null);
082    }
083
084
085    /**
086     * Associates a {@link WorkflowDocument} with this document header.
087     * @param workflowDocument
088     */
089    public void setWorkflowDocument(WorkflowDocument workflowDocument) {
090        this.workflowDocument = workflowDocument;
091    }
092
093    /**
094     * Returns the documentNumber (also known as the docuementHeaderId). This is a unique identifier for the document.
095     * @return the documentNumber
096     */
097    public String getDocumentNumber() {
098        return this.documentNumber;
099    }
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}