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