Coverage Report - org.kuali.rice.kew.docsearch.DocSearchUtils
 
Classes in this File Line Coverage Branch Coverage Complexity
DocSearchUtils
0%
0/172
0%
0/92
5.462
 
 1  
 /*
 2  
  * Copyright 2005-2007 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.docsearch;
 18  
 
 19  
 import org.apache.commons.lang.StringUtils;
 20  
 import org.kuali.rice.core.api.exception.RiceRuntimeException;
 21  
 import org.kuali.rice.core.api.reflect.ObjectDefinition;
 22  
 import org.kuali.rice.core.api.util.ClassLoaderUtils;
 23  
 import org.kuali.rice.core.api.util.RiceConstants;
 24  
 import org.kuali.rice.core.framework.resourceloader.ObjectDefinitionResolver;
 25  
 import org.kuali.rice.kew.api.WorkflowRuntimeException;
 26  
 import org.kuali.rice.kew.docsearch.web.SearchAttributeFormContainer;
 27  
 import org.kuali.rice.kew.doctype.bo.DocumentType;
 28  
 import org.kuali.rice.kew.doctype.service.DocumentTypeService;
 29  
 import org.kuali.rice.kew.service.KEWServiceLocator;
 30  
 import org.kuali.rice.kew.user.UserUtils;
 31  
 import org.kuali.rice.kns.web.ui.Field;
 32  
 import org.kuali.rice.kns.web.ui.Row;
 33  
 import org.kuali.rice.krad.UserSession;
 34  
 import org.kuali.rice.krad.util.GlobalVariables;
 35  
 
 36  
 import java.sql.Date;
 37  
 import java.sql.Timestamp;
 38  
 import java.util.ArrayList;
 39  
 import java.util.Arrays;
 40  
 import java.util.HashMap;
 41  
 import java.util.Iterator;
 42  
 import java.util.List;
 43  
 import java.util.Map;
 44  
 import java.util.StringTokenizer;
 45  
 
 46  
 
 47  
 /**
 48  
  * Various static utility methods for helping with Searcha.
 49  
  *
 50  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 51  
  */
 52  
 public final class DocSearchUtils {
 53  
 
 54  0
     private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DocSearchUtils.class);
 55  
 
 56  0
     public static final List<Class<? extends SearchableAttributeValue>> SEARCHABLE_ATTRIBUTE_BASE_CLASS_LIST =
 57  
             new ArrayList<Class<? extends SearchableAttributeValue>>();
 58  
     static {
 59  0
         SEARCHABLE_ATTRIBUTE_BASE_CLASS_LIST.add(SearchableAttributeStringValue.class);
 60  0
         SEARCHABLE_ATTRIBUTE_BASE_CLASS_LIST.add(SearchableAttributeFloatValue.class);
 61  0
         SEARCHABLE_ATTRIBUTE_BASE_CLASS_LIST.add(SearchableAttributeLongValue.class);
 62  0
         SEARCHABLE_ATTRIBUTE_BASE_CLASS_LIST.add(SearchableAttributeDateTimeValue.class);
 63  0
     }
 64  
 
 65  0
     private DocSearchUtils() {
 66  0
             throw new UnsupportedOperationException("do not call");
 67  
     }
 68  
     
 69  
     public static List<SearchableAttributeValue> getSearchableAttributeValueObjectTypes() {
 70  0
         List<SearchableAttributeValue> searchableAttributeValueClasses = new ArrayList<SearchableAttributeValue>();
 71  0
         for (Class<? extends SearchableAttributeValue> searchAttributeValueClass : SEARCHABLE_ATTRIBUTE_BASE_CLASS_LIST) {
 72  0
             ObjectDefinition objDef = new ObjectDefinition(searchAttributeValueClass);
 73  0
             SearchableAttributeValue attributeValue = (SearchableAttributeValue) ObjectDefinitionResolver.createObject(objDef, ClassLoaderUtils.getDefaultClassLoader(), false);
 74  0
             searchableAttributeValueClasses.add(attributeValue);
 75  0
         }
 76  0
         return searchableAttributeValueClasses;
 77  
     }
 78  
 
 79  
     public static SearchableAttributeValue getSearchableAttributeValueByDataTypeString(String dataType) {
 80  0
         SearchableAttributeValue returnableValue = null;
 81  0
         if (StringUtils.isBlank(dataType)) {
 82  0
             return returnableValue;
 83  
         }
 84  0
         for (SearchableAttributeValue attValue : getSearchableAttributeValueObjectTypes())
 85  
         {
 86  0
             if (dataType.equalsIgnoreCase(attValue.getAttributeDataType()))
 87  
             {
 88  0
                 if (returnableValue != null)
 89  
                 {
 90  0
                     String errorMsg = "Found two SearchableAttributeValue objects with same data type string ('" + dataType + "' while ignoring case):  " + returnableValue.getClass().getName() + " and " + attValue.getClass().getName();
 91  0
                     LOG.error("getSearchableAttributeValueByDataTypeString() " + errorMsg);
 92  0
                     throw new RuntimeException(errorMsg);
 93  
                 }
 94  0
                 LOG.debug("getSearchableAttributeValueByDataTypeString() SearchableAttributeValue class name is " + attValue.getClass().getName() + "... ojbConcreteClassName is " + attValue.getOjbConcreteClass());
 95  0
                 ObjectDefinition objDef = new ObjectDefinition(attValue.getClass());
 96  0
                 returnableValue = (SearchableAttributeValue) ObjectDefinitionResolver.createObject(objDef, ClassLoaderUtils.getDefaultClassLoader(), false);
 97  0
             }
 98  
         }
 99  0
         return returnableValue;
 100  
     }
 101  
 
 102  
 
 103  
     public static String getDisplayValueWithDateOnly(Timestamp value) {
 104  0
         return RiceConstants.getDefaultDateFormat().format(new Date(value.getTime()));
 105  
     }
 106  
 
 107  
     public static String getDisplayValueWithDateTime(Timestamp value) {
 108  0
         return RiceConstants.getDefaultDateAndTimeFormat().format(new Date(value.getTime()));
 109  
     }
 110  
 
 111  
 
 112  
 
 113  
     private static final String CURRENT_USER_PREFIX = "CURRENT_USER.";
 114  
 
 115  
     /**
 116  
      * Build List of searchable attributes from saved searchable attributes string
 117  
      *
 118  
      * @param searchableAttributeString
 119  
      *            String representation of searchable attributes
 120  
      * @param documentTypeName document type name
 121  
      * @return searchable attributes list
 122  
      */
 123  
     public static List<SearchAttributeCriteriaComponent> buildSearchableAttributesFromString(String searchableAttributeString, String documentTypeName) {
 124  0
         List<SearchAttributeCriteriaComponent> searchableAttributes = new ArrayList<SearchAttributeCriteriaComponent>();
 125  0
         Map<String, SearchAttributeCriteriaComponent> criteriaComponentsByKey = new HashMap<String, SearchAttributeCriteriaComponent>();
 126  
 
 127  0
         DocumentType docType = getDocumentType(documentTypeName);
 128  
 
 129  0
         if (docType != null) {
 130  
 
 131  0
             for (SearchableAttributeOld searchableAttribute : docType.getSearchableAttributesOld()) {
 132  
                     //KFSMI-1466 - DocumentSearchContext
 133  0
                 for (Row row : searchableAttribute.getSearchingRows(
 134  
                                 DocSearchUtils.getDocumentSearchContext("", docType.getName(), ""))) {
 135  0
                     for (Field field : row.getFields()) {
 136  0
                         if (field instanceof Field) {
 137  0
                             SearchableAttributeValue searchableAttributeValue = DocSearchUtils.getSearchableAttributeValueByDataTypeString(field.getFieldDataType());
 138  0
                             SearchAttributeCriteriaComponent sacc = new SearchAttributeCriteriaComponent(field.getPropertyName(), null, field.getPropertyName(), searchableAttributeValue);
 139  0
                             sacc.setRangeSearch(field.isMemberOfRange());
 140  0
                             sacc.setSearchInclusive(field.isInclusive());
 141  0
                             sacc.setSearchable(field.isIndexedForSearch());
 142  0
                             sacc.setLookupableFieldType(field.getFieldType());
 143  0
                             sacc.setCanHoldMultipleValues(Field.MULTI_VALUE_FIELD_TYPES.contains(field.getFieldType()));
 144  0
                             criteriaComponentsByKey.put(field.getPropertyName(), sacc);
 145  0
                         } else {
 146  0
                             throw new RiceRuntimeException("Fields must be of type org.kuali.rice.kew.docsearch.Field");
 147  
                         }
 148  
                     }
 149  
                 }
 150  
             }
 151  
         }
 152  
 
 153  0
         Map<String, List<String>> checkForMultiValueSearchableAttributes = new HashMap<String, List<String>>();
 154  0
         if ((searchableAttributeString != null) && (searchableAttributeString.trim().length() > 0)) {
 155  0
             StringTokenizer tokenizer = new StringTokenizer(searchableAttributeString, ",");
 156  0
             while (tokenizer.hasMoreTokens()) {
 157  0
                 String searchableAttribute = tokenizer.nextToken();
 158  0
                 int index = searchableAttribute.indexOf(":");
 159  0
                 if (index != -1) {
 160  0
                     String key = searchableAttribute.substring(0, index);
 161  
                     // String savedKey = key;
 162  
                     // if (key.indexOf(SearchableAttributeOld.RANGE_LOWER_BOUND_PROPERTY_PREFIX) == 0) {
 163  
                     // savedKey = key.substring(SearchableAttributeOld.RANGE_LOWER_BOUND_PROPERTY_PREFIX.length());
 164  
                     // } else if (key.indexOf(SearchableAttributeOld.RANGE_UPPER_BOUND_PROPERTY_PREFIX) == 0) {
 165  
                     // savedKey = key.substring(SearchableAttributeOld.RANGE_UPPER_BOUND_PROPERTY_PREFIX.length());
 166  
                     // }
 167  0
                     String value = searchableAttribute.substring(index + 1);
 168  0
                     if (value.startsWith(CURRENT_USER_PREFIX)) {
 169  0
                         String idType = value.substring(CURRENT_USER_PREFIX.length());
 170  0
                         UserSession session = GlobalVariables.getUserSession();
 171  0
                         String idValue = UserUtils.getIdValue(idType, session.getPerson());
 172  0
                         if (!StringUtils.isBlank(idValue)) {
 173  0
                             value = idValue;
 174  
                         }
 175  
                     }
 176  0
                     SearchAttributeCriteriaComponent critComponent = criteriaComponentsByKey.get(key);
 177  0
                     if (critComponent == null) {
 178  
                         // here we potentially have a change to the searchable attributes dealing with naming or ranges... so
 179  
                         // we just ignore the values
 180  0
                         continue;
 181  
                     }
 182  0
                     if (critComponent.getSearchableAttributeValue() == null) {
 183  0
                         String errorMsg = "Cannot find SearchableAttributeValue for given key '" + key + "'";
 184  0
                         LOG.error("buildSearchableAttributesFromString() " + errorMsg);
 185  0
                         throw new RuntimeException(errorMsg);
 186  
                     }
 187  0
                     if (critComponent.isCanHoldMultipleValues()) {
 188  
                         // should be multivalue
 189  0
                         if (checkForMultiValueSearchableAttributes.containsKey(key)) {
 190  0
                             List<String> keyList = checkForMultiValueSearchableAttributes.get(key);
 191  0
                             keyList.add(value);
 192  0
                             checkForMultiValueSearchableAttributes.put(key, keyList);
 193  0
                         } else {
 194  0
                             List<String> tempList = new ArrayList<String>();
 195  0
                             tempList.add(value);
 196  
                             // tempList.addAll(Arrays.asList(new String[]{value}));
 197  0
                             checkForMultiValueSearchableAttributes.put(key, tempList);
 198  0
                             searchableAttributes.add(critComponent);
 199  0
                         }
 200  
                     } else {
 201  
                         // should be single value
 202  0
                         if (checkForMultiValueSearchableAttributes.containsKey(key)) {
 203  
                             // attempting to use multiple values in a field that does not support it
 204  0
                             String error = "Attempting to add multiple values to a search attribute (key: '" + key + "') that does not suppor them";
 205  0
                             LOG.error("buildSearchableAttributesFromString() " + error);
 206  
                             // we don't blow chunks here in case an attribute has been altered from multi-value to
 207  
                             // non-multi-value
 208  
                         }
 209  0
                         critComponent.setValue(value);
 210  0
                         searchableAttributes.add(critComponent);
 211  
                     }
 212  
 
 213  
                 }
 214  0
             }
 215  0
             for (SearchAttributeCriteriaComponent criteriaComponent : searchableAttributes)
 216  
             {
 217  0
                 if (criteriaComponent.isCanHoldMultipleValues())
 218  
                 {
 219  0
                     List<String> values = checkForMultiValueSearchableAttributes.get(criteriaComponent.getFormKey());
 220  0
                     criteriaComponent.setValue(null);
 221  0
                     criteriaComponent.setValues(values);
 222  0
                 }
 223  
             }
 224  
         }
 225  
 
 226  0
         return searchableAttributes;
 227  
     }
 228  
 
 229  
     /**
 230  
      * This method takes the given <code>propertyFields</code> parameter and populates the {@link DocSearchCriteriaDTO}
 231  
      * object search attributes based on the document type name set on the <code>criteria</code> object.<br>
 232  
      * <br>
 233  
      * This is identical to calling {@link #addSearchableAttributesToCriteria(DocSearchCriteriaDTO, List, String, boolean)}
 234  
      * with a boolean value of false for the <code>setAttributesStrictly</code> parameter.
 235  
      *
 236  
      * @param criteria -
 237  
      *            The object that needs a list of {@link SearchAttributeCriteriaComponent} objects set up based on the
 238  
      *            document type name and <code>propertyFields</code> parameter
 239  
      * @param propertyFields -
 240  
      *            The list of {@link SearchAttributeFormContainer} objects that need to be converted to
 241  
      *            {@link SearchAttributeCriteriaComponent} objects and set on the <code>criteria</code> parameter
 242  
      * @param searchAttributesString -
 243  
      *            A potential string that must be parsed to use to set attributes on the <code>criteria</code> object
 244  
      */
 245  
     public static void addSearchableAttributesToCriteria(DocSearchCriteriaDTO criteria, List propertyFields, String searchAttributesString) {
 246  0
         addSearchableAttributesToCriteria(criteria, propertyFields, searchAttributesString, false);
 247  0
     }
 248  
 
 249  
     /**
 250  
      * This method takes the given <code>propertyFields</code> parameter and populates the {@link DocSearchCriteriaDTO}
 251  
      * object search attributes based on the document type name set on the <code>criteria</code> object.<br>
 252  
      * <br>
 253  
      * This is identical to calling {@link #addSearchableAttributesToCriteria(DocSearchCriteriaDTO, List, String, boolean)}
 254  
      * with a null value for the <code>searchAttributesString</code> parameter.
 255  
      *
 256  
      * @param criteria -
 257  
      *            The object that needs a list of {@link SearchAttributeCriteriaComponent} objects set up based on the
 258  
      *            document type name and <code>propertyFields</code> parameter
 259  
      * @param propertyFields -
 260  
      *            The list of {@link SearchAttributeFormContainer} objects that need to be converted to
 261  
      *            {@link SearchAttributeCriteriaComponent} objects and set on the <code>criteria</code> parameter
 262  
      * @param setAttributesStrictly -
 263  
      *            A boolean to specify whether to explicitly throw an error when a given value from
 264  
      *            <code>propertyFields</code> does not match a search attribute on the specified document type. If set to
 265  
      *            true an error with be thrown. If set to false the mismatch will be ignored.
 266  
      */
 267  
     public static void addSearchableAttributesToCriteria(DocSearchCriteriaDTO criteria, List propertyFields, boolean setAttributesStrictly) {
 268  0
         addSearchableAttributesToCriteria(criteria, propertyFields, null, setAttributesStrictly);
 269  0
     }
 270  
 
 271  
     /**
 272  
      * This method takes the given <code>propertyFields</code> parameter and populates the {@link DocSearchCriteriaDTO}
 273  
      * object search attributes based on the document type name set on the <code>criteria</code> object.
 274  
      *
 275  
      * @param criteria -
 276  
      *            The object that needs a list of {@link SearchAttributeCriteriaComponent} objects set up based on the
 277  
      *            document type name and <code>propertyFields</code> parameter
 278  
      * @param propertyFields -
 279  
      *            The list of {@link SearchAttributeFormContainer} objects that need to be converted to
 280  
      *            {@link SearchAttributeCriteriaComponent} objects and set on the <code>criteria</code> parameter
 281  
      * @param searchAttributesString -
 282  
      *            A potential string that must be parsed to use to set attributes on the <code>criteria</code> object
 283  
      * @param setAttributesStrictly -
 284  
      *            A boolean to specify whether to explicitly throw an error when a given value from
 285  
      *            <code>propertyFields</code> does not match a search attribute on the specified document type. If set to
 286  
      *            true an error with be thrown. If set to false the mismatch will be ignored.
 287  
      */
 288  
     public static void addSearchableAttributesToCriteria(DocSearchCriteriaDTO criteria, List propertyFields, String searchAttributesString, boolean setAttributesStrictly) {
 289  0
         if (criteria != null) {
 290  0
             DocumentType docType = getDocumentType(criteria.getDocTypeFullName());
 291  0
             if (docType == null) {
 292  0
                 return;
 293  
             }
 294  0
             criteria.getSearchableAttributes().clear();
 295  0
             Map<String, SearchAttributeCriteriaComponent> urlParameterSearchAttributesByFormKey = new HashMap<String, SearchAttributeCriteriaComponent>();
 296  0
             if (!StringUtils.isBlank(searchAttributesString)) {
 297  0
                 List<SearchAttributeCriteriaComponent> components = buildSearchableAttributesFromString(searchAttributesString, docType.getName());
 298  0
                 for (SearchAttributeCriteriaComponent component : components) {
 299  0
                     urlParameterSearchAttributesByFormKey.put(component.getFormKey(), component);
 300  0
                     criteria.addSearchableAttribute(component);
 301  
                 }
 302  
 //                docSearchForm.setSearchableAttributes(null);
 303  
             }
 304  0
             if (!propertyFields.isEmpty()) {
 305  0
                 Map<String, SearchAttributeCriteriaComponent> criteriaComponentsByFormKey = new HashMap<String, SearchAttributeCriteriaComponent>();
 306  0
                 for (SearchableAttributeOld searchableAttribute : docType.getSearchableAttributesOld()) {
 307  
                         //KFSMI-1466 - DocumentSearchContext
 308  0
                     for (Row row : searchableAttribute.getSearchingRows(
 309  
                                     DocSearchUtils.getDocumentSearchContext("", docType.getName(), ""))) {
 310  0
                         for (Field field : row.getFields()) {
 311  0
                             if (field instanceof Field) {
 312  0
                                 SearchableAttributeValue searchableAttributeValue = DocSearchUtils.getSearchableAttributeValueByDataTypeString(field.getFieldDataType());
 313  0
                                 SearchAttributeCriteriaComponent sacc = new SearchAttributeCriteriaComponent(field.getPropertyName(), null, field.getPropertyName(), searchableAttributeValue);
 314  0
                                 sacc.setRangeSearch(field.isMemberOfRange());
 315  0
                                 sacc.setSearchInclusive(field.isInclusive());
 316  0
                                 sacc.setLookupableFieldType(field.getFieldType());
 317  0
                                 sacc.setSearchable(field.isIndexedForSearch());
 318  0
                                 sacc.setCanHoldMultipleValues(Field.MULTI_VALUE_FIELD_TYPES.contains(field.getFieldType()));
 319  0
                                 criteriaComponentsByFormKey.put(field.getPropertyName(), sacc);
 320  0
                             } else {
 321  0
                                 throw new RiceRuntimeException("Fields must be of type org.kuali.rice.kew.docsearch.Field");
 322  
                             }
 323  
                         }
 324  
                     }
 325  
                 }
 326  0
                 for (Iterator iterator = propertyFields.iterator(); iterator.hasNext();) {
 327  0
                     SearchAttributeFormContainer propertyField = (SearchAttributeFormContainer) iterator.next();
 328  0
                     SearchAttributeCriteriaComponent sacc = criteriaComponentsByFormKey.get(propertyField.getKey());
 329  0
                     if (sacc != null) {
 330  0
                         if (sacc.getSearchableAttributeValue() == null) {
 331  0
                             String errorMsg = "Searchable attribute with form field key " + sacc.getFormKey() + " does not have a valid SearchableAttributeValue";
 332  0
                             LOG.error("addSearchableAttributesToCriteria() " + errorMsg);
 333  0
                             throw new RuntimeException(errorMsg);
 334  
                         }
 335  
                         // if the url parameter has already set up the search attribute change the propertyField
 336  0
                         if (urlParameterSearchAttributesByFormKey.containsKey(sacc.getFormKey())) {
 337  0
                             setupPropertyField(urlParameterSearchAttributesByFormKey.get(sacc.getFormKey()), propertyFields);
 338  
                         } else {
 339  
                             //if ((Field.CHECKBOX_YES_NO.equals(sacc.getLookupableFieldType())) && (!propertyField.isValueSet())) {
 340  
                                 // value was not set on the form so we must use the alternate value which for checkbox is the
 341  
                                 // 'unchecked' value
 342  
                             //    sacc.setValue(propertyField.getAlternateValue());
 343  
                             //} else
 344  0
                             if (Field.MULTI_VALUE_FIELD_TYPES.contains(sacc.getLookupableFieldType())) {
 345  
                                 // set the multivalue lookup indicator
 346  0
                                 sacc.setCanHoldMultipleValues(true);
 347  0
                                 if (propertyField.getValues() == null) {
 348  0
                                     sacc.setValues(new ArrayList<String>());
 349  
                                 } else {
 350  0
                                     sacc.setValues(Arrays.asList(propertyField.getValues()));
 351  
                                 }
 352  
                             } else {
 353  0
                                 sacc.setValue(propertyField.getValue());
 354  
                             }
 355  0
                             criteria.addSearchableAttribute(sacc);
 356  
                         }
 357  
                     } else {
 358  0
                         if (setAttributesStrictly) {
 359  0
                             String message = "Cannot find matching search attribute with key '" + propertyField.getKey() + "' on document type '" + docType.getName() + "'";
 360  0
                             LOG.error(message);
 361  0
                             throw new WorkflowRuntimeException(message);
 362  
                         }
 363  
                     }
 364  0
                 }
 365  
             }
 366  
         }
 367  0
     }
 368  
 
 369  
     public static void setupPropertyField(SearchAttributeCriteriaComponent searchableAttribute, List propertyFields) {
 370  0
         SearchAttributeFormContainer propertyField = getPropertyField(searchableAttribute.getFormKey(), propertyFields);
 371  0
         if (propertyField != null) {
 372  0
             propertyField.setValue(searchableAttribute.getValue());
 373  0
             if (searchableAttribute.getValues() != null) {
 374  0
                 propertyField.setValues(searchableAttribute.getValues().toArray(new String[searchableAttribute.getValues().size()]));
 375  
             }
 376  
         }
 377  0
     }
 378  
 
 379  
     public static SearchAttributeFormContainer getPropertyField(String key, List propertyFields) {
 380  0
         if (StringUtils.isBlank(key)) {
 381  0
             return null;
 382  
         }
 383  0
         for (Iterator iter = propertyFields.iterator(); iter.hasNext();) {
 384  0
             SearchAttributeFormContainer container = (SearchAttributeFormContainer) iter.next();
 385  0
             if (key.equals(container.getKey())) {
 386  0
                 return container;
 387  
             }
 388  0
         }
 389  0
         return null;
 390  
     }
 391  
 
 392  
     private static DocumentType getDocumentType(String docTypeName) {
 393  0
         if ((docTypeName != null && !"".equals(docTypeName))) {
 394  0
             return ((DocumentTypeService) KEWServiceLocator.getService(KEWServiceLocator.DOCUMENT_TYPE_SERVICE)).findByName(docTypeName);
 395  
         }
 396  0
         return null;
 397  
     }
 398  
 
 399  
     public static DocumentSearchContext getDocumentSearchContext(String documentId, String documentTypeName, String documentContent){
 400  0
             DocumentSearchContext documentSearchContext = new DocumentSearchContext();
 401  0
             documentSearchContext.setDocumentId(documentId);
 402  0
             documentSearchContext.setDocumentTypeName(documentTypeName);
 403  0
             documentSearchContext.setDocumentContent(documentContent);
 404  0
             return documentSearchContext;
 405  
     }
 406  
 }