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.kew.routeheader; 017 018import org.kuali.rice.core.api.util.xml.XmlJotter; 019 020import javax.persistence.Basic; 021import javax.persistence.Column; 022import javax.persistence.Entity; 023import javax.persistence.FetchType; 024import javax.persistence.Id; 025import javax.persistence.Lob; 026import javax.persistence.NamedQuery; 027import javax.persistence.Table; 028import java.io.Serializable; 029 030@Entity 031@Table(name="KREW_DOC_HDR_CNTNT_T") 032@NamedQuery(name="DocumentRouteHeaderValueContent.FindByDocumentId", query="select d from DocumentRouteHeaderValueContent as d where d.documentId = :documentId") 033public class DocumentRouteHeaderValueContent implements Serializable { 034 035 /** 036 * 037 */ 038 private static final long serialVersionUID = 1L; 039 @Id 040 @Column(name="DOC_HDR_ID") 041 private String documentId; 042 @Lob 043 @Basic(fetch=FetchType.LAZY) 044 @Column(name="DOC_CNTNT_TXT") 045 private String documentContent; 046 047 public DocumentRouteHeaderValueContent() {} 048 049 public DocumentRouteHeaderValueContent(String documentId) { 050 this.documentId = documentId; 051 } 052 053 public String getDocumentContent() { 054 return documentContent; 055 } 056 public void setDocumentContent(String documentContent) { 057 this.documentContent = documentContent; 058 } 059 public String getDocumentId() { 060 return documentId; 061 } 062 public void setDocumentId(String documentId) { 063 this.documentId = documentId; 064 } 065 066 public static org.kuali.rice.kew.api.document.DocumentContent to(DocumentRouteHeaderValueContent content) { 067 if (content == null) { 068 return null; 069 } 070 org.kuali.rice.kew.api.document.DocumentContent.Builder builder = org.kuali.rice.kew.api.document.DocumentContent.Builder.create(content.getDocumentId()); 071 // initialize the content fields 072 builder.setApplicationContent(""); 073 builder.setAttributeContent(""); 074 builder.setSearchableContent(""); 075 DocumentContent documentContent = new StandardDocumentContent(content.getDocumentContent()); 076 if (documentContent.getApplicationContent() != null) { 077 builder.setApplicationContent(XmlJotter.jotNode(documentContent.getApplicationContent())); 078 } 079 if (documentContent.getAttributeContent() != null) { 080 builder.setAttributeContent(XmlJotter.jotNode(documentContent.getAttributeContent())); 081 } 082 if (documentContent.getSearchableContent() != null) { 083 builder.setSearchableContent(XmlJotter.jotNode(documentContent.getSearchableContent())); 084 } 085 return builder.build(); 086 } 087 088} 089