View Javadoc

1   /**
2    * Copyright 2005-2013 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.routeheader;
17  
18  import org.kuali.rice.core.api.util.xml.XmlJotter;
19  
20  import javax.persistence.Basic;
21  import javax.persistence.Column;
22  import javax.persistence.Entity;
23  import javax.persistence.FetchType;
24  import javax.persistence.Id;
25  import javax.persistence.Lob;
26  import javax.persistence.NamedQuery;
27  import javax.persistence.Table;
28  import java.io.Serializable;
29  
30  @Entity
31  @Table(name="KREW_DOC_HDR_CNTNT_T")
32  @NamedQuery(name="DocumentRouteHeaderValueContent.FindByDocumentId", query="select d from DocumentRouteHeaderValueContent as d where d.documentId = :documentId")
33  public class DocumentRouteHeaderValueContent implements Serializable {
34  
35  	/**
36  	 * 
37  	 */
38  	private static final long serialVersionUID = 1L;
39  	@Id
40  	@Column(name="DOC_HDR_ID")
41  	private String documentId;
42  	@Lob
43  	@Basic(fetch=FetchType.LAZY)
44  	@Column(name="DOC_CNTNT_TXT")
45  	private String documentContent;
46  		
47  	public DocumentRouteHeaderValueContent() {}
48  	
49  	public DocumentRouteHeaderValueContent(String documentId) {
50  		this.documentId = documentId;
51  	}
52  	
53  	public String getDocumentContent() {
54  		return documentContent;
55  	}
56  	public void setDocumentContent(String documentContent) {
57  		this.documentContent = documentContent;
58  	}
59  	public String getDocumentId() {
60  		return documentId;
61  	}
62  	public void setDocumentId(String documentId) {
63  		this.documentId = documentId;
64  	}
65  	
66  	public static org.kuali.rice.kew.api.document.DocumentContent to(DocumentRouteHeaderValueContent content) {
67  		if (content == null) {
68  			return null;
69  		}
70  		org.kuali.rice.kew.api.document.DocumentContent.Builder builder = org.kuali.rice.kew.api.document.DocumentContent.Builder.create(content.getDocumentId());
71  		// initialize the content fields
72  		builder.setApplicationContent("");
73  		builder.setAttributeContent("");
74  		builder.setSearchableContent("");
75  		DocumentContent documentContent = new StandardDocumentContent(content.getDocumentContent());
76  		if (documentContent.getApplicationContent() != null) {
77  			builder.setApplicationContent(XmlJotter.jotNode(documentContent.getApplicationContent()));
78  		}
79  		if (documentContent.getAttributeContent() != null) {
80  			builder.setAttributeContent(XmlJotter.jotNode(documentContent.getAttributeContent()));
81  		}
82  		if (documentContent.getSearchableContent() != null) {
83  			builder.setSearchableContent(XmlJotter.jotNode(documentContent.getSearchableContent()));
84  		}
85  		return builder.build();
86  	}
87  
88  }
89