Coverage Report - org.kuali.rice.kew.dto.DocumentContentDTO
 
Classes in this File Line Coverage Branch Coverage Complexity
DocumentContentDTO
0%
0/48
0%
0/10
1.211
 
 1  
 /*
 2  
  * Copyright 2005-2008 The Kuali Foundation
 3  
  * 
 4  
  * 
 5  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  * 
 9  
  * http://www.opensource.org/licenses/ecl2.php
 10  
  * 
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.kuali.rice.kew.dto;
 18  
 
 19  
 import java.io.Serializable;
 20  
 import java.util.ArrayList;
 21  
 import java.util.List;
 22  
 
 23  
 import org.kuali.rice.kew.util.KEWConstants;
 24  
 
 25  
 
 26  
 /**
 27  
  * Represents document content broken up into all it's pieces.  This object is used both
 28  
  * to hold the state of the document content returned by the server, as well as to accumulate
 29  
  * and marshal changes made by the client application.  In the former case, no attribute
 30  
  * definitions will be supplied in this object by the server.  In the latter case, the client
 31  
  * may add attribute content to the document content by attaching attribute definitions, which
 32  
  * will be marshaled into the document content when an action is taken by the client on the document. 
 33  
  * These definition VOs will be transient and will not be returned again when content is refreshed
 34  
  * from the server.
 35  
  * 
 36  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 37  
  */
 38  
 public class DocumentContentDTO implements Serializable {
 39  
 
 40  
         private static final long serialVersionUID = -1008441110733007106L;
 41  0
     private String attributeContent = "";
 42  0
     private String applicationContent = "";
 43  0
     private String searchableContent = "";
 44  0
     private List<WorkflowAttributeDefinitionDTO> attributeDefinitions = new ArrayList<WorkflowAttributeDefinitionDTO>();
 45  0
     private List<WorkflowAttributeDefinitionDTO> searchableDefinitions = new ArrayList<WorkflowAttributeDefinitionDTO>();
 46  
     private String documentId;
 47  
     
 48  0
     private static final WorkflowAttributeDefinitionDTO[] ARRAY_TYPE = new WorkflowAttributeDefinitionDTO[0];
 49  
     
 50  0
     public DocumentContentDTO() {}    
 51  
     
 52  
     public String getApplicationContent() {
 53  0
         return applicationContent;
 54  
     }
 55  
     public void setApplicationContent(String applicationContent) {
 56  0
         this.applicationContent = applicationContent;
 57  0
     }
 58  
     public String getAttributeContent() {
 59  0
         return attributeContent;
 60  
     }
 61  
     public void setAttributeContent(String attributeContent) {
 62  0
         this.attributeContent = attributeContent;
 63  0
     }
 64  
     public String getSearchableContent() {
 65  0
         return searchableContent;
 66  
     }
 67  
     public void setSearchableContent(String searchableContent) {
 68  0
         this.searchableContent = searchableContent;
 69  0
     }
 70  
     public String getFullContent() {
 71  0
         StringBuffer fullContent = new StringBuffer();
 72  0
         fullContent.append("<").append(KEWConstants.DOCUMENT_CONTENT_ELEMENT).append(">");
 73  0
         if (!isEmpty(getApplicationContent())) {
 74  0
             fullContent.append("<").append(KEWConstants.APPLICATION_CONTENT_ELEMENT).append(">");
 75  0
             fullContent.append(getApplicationContent());
 76  0
             fullContent.append("</").append(KEWConstants.APPLICATION_CONTENT_ELEMENT).append(">");                
 77  
         }
 78  0
         fullContent.append(getAttributeContent());
 79  0
         fullContent.append(getSearchableContent());
 80  0
         fullContent.append("</").append(KEWConstants.DOCUMENT_CONTENT_ELEMENT).append(">");
 81  0
         return fullContent.toString();
 82  
     }
 83  
     
 84  
     public WorkflowAttributeDefinitionDTO[] getAttributeDefinitions() {
 85  0
         return (WorkflowAttributeDefinitionDTO[])attributeDefinitions.toArray(ARRAY_TYPE);
 86  
     }
 87  
     public void setAttributeDefinitions(WorkflowAttributeDefinitionDTO[] attributeDefinitions) {
 88  0
         this.attributeDefinitions = new ArrayList<WorkflowAttributeDefinitionDTO>();
 89  0
         for (int index = 0; index < attributeDefinitions.length; index++) {
 90  0
             this.attributeDefinitions.add(attributeDefinitions[index]);
 91  
         }
 92  0
     }
 93  
     public WorkflowAttributeDefinitionDTO[] getSearchableDefinitions() {
 94  0
         return (WorkflowAttributeDefinitionDTO[])searchableDefinitions.toArray(ARRAY_TYPE);
 95  
     }
 96  
     public void setSearchableDefinitions(WorkflowAttributeDefinitionDTO[] searchableDefinitions) {
 97  0
         this.searchableDefinitions = new ArrayList<WorkflowAttributeDefinitionDTO>();
 98  0
         for (int index = 0; index < searchableDefinitions.length; index++) {
 99  0
             this.searchableDefinitions.add(searchableDefinitions[index]);
 100  
         }
 101  0
     }
 102  
     
 103  
     public void addAttributeDefinition(WorkflowAttributeDefinitionDTO definition) {
 104  0
         attributeDefinitions.add(definition);
 105  0
     }
 106  
     
 107  
     public void removeAttributeDefinition(WorkflowAttributeDefinitionDTO definition) {
 108  0
         attributeDefinitions.remove(definition);
 109  0
     }
 110  
     
 111  
     public void addSearchableDefinition(WorkflowAttributeDefinitionDTO definition) {
 112  0
         searchableDefinitions.add(definition);
 113  0
     }
 114  
     
 115  
     public void removeSearchableDefinition(WorkflowAttributeDefinitionDTO definition) {
 116  0
         searchableDefinitions.remove(definition);
 117  0
     }
 118  
     
 119  
     public String getDocumentId() {
 120  0
                 return documentId;
 121  
         }
 122  
         public void setDocumentId(String documentId) {
 123  0
                 this.documentId = documentId;
 124  0
         }
 125  
         
 126  
         private boolean isEmpty(String value) {
 127  0
         return value == null || value.trim().equals("");
 128  
     }
 129  
 
 130  
 }