Coverage Report - org.kuali.rice.kew.framework.docsearch.DocumentSearchContext
 
Classes in this File Line Coverage Branch Coverage Complexity
DocumentSearchContext
0%
0/24
0%
0/8
2.143
DocumentSearchContext$Constants
0%
0/2
N/A
2.143
DocumentSearchContext$Elements
0%
0/1
N/A
2.143
 
 1  
 /*
 2  
  * Copyright 2007-2008 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.framework.docsearch;
 17  
 
 18  
 import org.apache.commons.lang.StringUtils;
 19  
 import org.kuali.rice.core.api.CoreConstants;
 20  
 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
 21  
 import org.kuali.rice.kew.api.document.Document;
 22  
 import org.kuali.rice.kew.api.document.DocumentContent;
 23  
 import org.w3c.dom.Element;
 24  
 
 25  
 import javax.xml.bind.annotation.XmlAccessType;
 26  
 import javax.xml.bind.annotation.XmlAccessorType;
 27  
 import javax.xml.bind.annotation.XmlAnyElement;
 28  
 import javax.xml.bind.annotation.XmlElement;
 29  
 import javax.xml.bind.annotation.XmlRootElement;
 30  
 import javax.xml.bind.annotation.XmlType;
 31  
 import java.io.Serializable;
 32  
 import java.util.Collection;
 33  
 
 34  
 /**
 35  
  * This class contains all the information needed for document search, validation and indexing. 
 36  
  * 
 37  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 38  
  *
 39  
  */
 40  
 @XmlRootElement(name = DocumentSearchContext.Constants.ROOT_ELEMENT_NAME)
 41  
 @XmlAccessorType(XmlAccessType.NONE)
 42  
 @XmlType(name = DocumentSearchContext.Constants.TYPE_NAME, propOrder = {
 43  
     DocumentSearchContext.Elements.DOCUMENT,
 44  
     DocumentSearchContext.Elements.DOCUMENT_CONTENT,
 45  
     DocumentSearchContext.Elements.DOCUMENT_TYPE_NAME,
 46  
     CoreConstants.CommonElements.FUTURE_ELEMENTS
 47  
 })
 48  
 public final class DocumentSearchContext extends AbstractDataTransferObject {
 49  
 
 50  
     @XmlElement(name = Elements.DOCUMENT, required = false)
 51  
         private final Document document;
 52  
 
 53  
     @XmlElement(name = Elements.DOCUMENT_CONTENT, required = false)
 54  
         private final DocumentContent documentContent;
 55  
 
 56  
     @XmlElement(name = Elements.DOCUMENT_TYPE_NAME, required = false)
 57  
     private final String documentTypeName;
 58  
 
 59  0
     @SuppressWarnings("unused")
 60  
     @XmlAnyElement
 61  
     private final Collection<Element> _futureElements = null;
 62  
 
 63  
     /**
 64  
      * Private constructor used only by JAXB.
 65  
      */
 66  0
     private DocumentSearchContext() {
 67  0
         this.document = null;
 68  0
         this.documentContent = null;
 69  0
         this.documentTypeName = null;
 70  0
     }
 71  
 
 72  0
     private DocumentSearchContext(Document document, DocumentContent documentContent, String documentTypeName) {
 73  0
         this.document = document;
 74  0
         this.documentContent = documentContent;
 75  0
         this.documentTypeName = documentTypeName;
 76  0
     }
 77  
 
 78  
     public static DocumentSearchContext createFullContext(Document document, DocumentContent documentContent, String documentTypeName) {
 79  0
         if (document == null) {
 80  0
             throw new IllegalArgumentException("document was null");
 81  
         }
 82  0
         if (documentContent == null) {
 83  0
             throw new IllegalArgumentException("documentContent was null");
 84  
         }
 85  0
         if (StringUtils.isBlank(documentTypeName)) {
 86  0
             throw new IllegalArgumentException("documentTypeName was null or blank");
 87  
         }
 88  0
         return new DocumentSearchContext(document, documentContent, documentTypeName);
 89  
     }
 90  
 
 91  
     public static DocumentSearchContext createDocumentTypeNameContext(String documentTypeName) {
 92  0
         if (StringUtils.isBlank(documentTypeName)) {
 93  0
             throw new IllegalArgumentException("documentTypeName was null or blank");
 94  
         }
 95  0
         return new DocumentSearchContext(null, null, documentTypeName);
 96  
     }
 97  
 
 98  
     public Document getDocument() {
 99  0
         return document;
 100  
     }
 101  
 
 102  
     public DocumentContent getDocumentContent() {
 103  0
         return documentContent;
 104  
     }
 105  
 
 106  
     public String getDocumentTypeName() {
 107  0
         return documentTypeName;
 108  
     }
 109  
 
 110  
     /**
 111  
      * Defines some internal constants used on this class.
 112  
      */
 113  0
     static class Constants {
 114  
         final static String ROOT_ELEMENT_NAME = "documentSearchContext";
 115  
         final static String TYPE_NAME = "DocumentSearchContextType";
 116  0
         final static String[] HASH_CODE_EQUALS_EXCLUDE = new String[] { CoreConstants.CommonElements.FUTURE_ELEMENTS };
 117  
     }
 118  
 
 119  
     /**
 120  
      * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
 121  
      */
 122  0
     static class Elements {
 123  
         final static String DOCUMENT = "document";
 124  
         final static String DOCUMENT_CONTENT = "documentContent";
 125  
         final static String DOCUMENT_TYPE_NAME = "documentTypeName";
 126  
     }
 127  
         
 128  
 }