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 javax.persistence.Column; 019import javax.persistence.Entity; 020import javax.persistence.Id; 021import javax.persistence.Table; 022import javax.persistence.Transient; 023import javax.persistence.UniqueConstraint; 024 025import org.eclipse.persistence.annotations.Index; 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",uniqueConstraints= { 038 @UniqueConstraint(name="KRNS_DOC_HDR_TC0",columnNames="OBJ_ID") 039}) 040public class DocumentHeader extends PersistableBusinessObjectBaseAdapter { 041 private static final long serialVersionUID = 2302690966928882488L; 042 043 @Id 044 @Column(name="DOC_HDR_ID",length=14) 045 protected String documentNumber; 046 @Column(name="FDOC_DESC",length=255) 047 protected String documentDescription; 048 049 @Index(name="KRNS_DOC_HDR_TI3") 050 @Column(name="ORG_DOC_HDR_ID",length=10) 051 protected String organizationDocumentNumber; 052 @Column(name="TMPL_DOC_HDR_ID",length=14) 053 protected String documentTemplateNumber; 054 @Column(name="EXPLANATION",length=400) 055 protected String explanation; 056 057 @Transient 058 private WorkflowDocument workflowDocument; 059 060 /** 061 * Constructor - creates empty instances of dependent objects 062 * 063 */ 064 public DocumentHeader() { 065 super(); 066 } 067 068 /** 069 * Returns an instance of the the {@link WorkflowDocument} associated with this document header. 070 * The workflowDocument provides the core client interface for interacting with the KEW workflow module. 071 * @return workflowDocument 072 */ 073 public WorkflowDocument getWorkflowDocument() { 074 if (workflowDocument == null) { 075 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."); 076 } 077 078 return workflowDocument; 079 } 080 081 /** 082 * Returns whether this document header has a {@link WorkflowDocument} associated with it. 083 * @return true if the workflowDocument is not null 084 */ 085 public boolean hasWorkflowDocument() { 086 return (workflowDocument != null); 087 } 088 089 090 /** 091 * Associates a {@link WorkflowDocument} with this document header. 092 * @param workflowDocument 093 */ 094 public void setWorkflowDocument(WorkflowDocument workflowDocument) { 095 this.workflowDocument = workflowDocument; 096 } 097 098 /** 099 * 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}