Coverage Report - org.kuali.rice.kew.doctype.DocumentTypeLookupableHelperServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
DocumentTypeLookupableHelperServiceImpl
0%
0/36
0%
0/24
7
 
 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.doctype;
 17  
 
 18  
 import java.util.ArrayList;
 19  
 import java.util.Collection;
 20  
 import java.util.Collections;
 21  
 import java.util.List;
 22  
 import java.util.Map;
 23  
 
 24  
 import org.apache.commons.lang.StringUtils;
 25  
 import org.kuali.rice.kew.doctype.bo.DocumentType;
 26  
 import org.kuali.rice.kew.service.KEWServiceLocator;
 27  
 import org.kuali.rice.kew.util.KEWPropertyConstants;
 28  
 import org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl;
 29  
 import org.kuali.rice.krad.bo.BusinessObject;
 30  
 import org.kuali.rice.krad.util.BeanPropertyComparator;
 31  
 import org.kuali.rice.krad.util.KRADConstants;
 32  
 
 33  
 /**
 34  
  * This is a description of what this class does - chb don't forget to fill this in.
 35  
  *
 36  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 37  
  *
 38  
  */
 39  0
 public class DocumentTypeLookupableHelperServiceImpl extends KualiLookupableHelperServiceImpl
 40  
 {
 41  
 
 42  
     private static final long serialVersionUID = -5162632536083995637L;
 43  
 
 44  
     /**
 45  
          * This overridden method ...
 46  
          *
 47  
          * @see org.kuali.rice.krad.lookup.KualiLookupableHelperServiceImpl#getSearchResultsHelper(java.util.Map, boolean)
 48  
          */
 49  
         @Override
 50  
         protected List<? extends BusinessObject> getSearchResultsHelper(Map<String, String> fieldValues, boolean unbounded)
 51  
         {
 52  0
         setBackLocation(fieldValues.get(KRADConstants.BACK_LOCATION));
 53  0
         setDocFormKey(fieldValues.get(KRADConstants.DOC_FORM_KEY));
 54  0
         setReferencesToRefresh(fieldValues.get(KRADConstants.REFERENCES_TO_REFRESH));
 55  
 
 56  0
         DocumentType documentType = loadDocumentTypeForSearch(fieldValues);
 57  
 
 58  0
         String descendHierarchyValue = fieldValues.get("descendHierarchy");
 59  0
         boolean descend = false;
 60  
 
 61  0
         if( "Y".equals(descendHierarchyValue) || "Yes".equals(descendHierarchyValue))
 62  
                 {
 63  0
                 descend = true;
 64  
                 }
 65  
 
 66  0
         Collection docTypesFound =
 67  
                 KEWServiceLocator.getDocumentTypeService().find(documentType, fieldValues.get("parentDocType.name"), descend);
 68  
 
 69  0
         List<? extends BusinessObject> searchResults =
 70  
                 new ArrayList<BusinessObject>( (Collection<? extends BusinessObject>)docTypesFound );
 71  
 
 72  
         // sort list if default sort column given
 73  0
         List defaultSortColumns = getDefaultSortColumns();
 74  0
         if (defaultSortColumns.size() > 0) {
 75  0
             Collections.sort(searchResults, new BeanPropertyComparator(getDefaultSortColumns(), true));
 76  
         }
 77  0
         return searchResults;
 78  
     }
 79  
 
 80  
         protected DocumentType loadDocumentTypeForSearch(Map<String, String> fieldValues) {
 81  0
         DocumentType documentType = new DocumentType();
 82  
 
 83  0
         String activeIndicator = (String) fieldValues.get(KEWPropertyConstants.ACTIVE);
 84  0
         String docTypeLabel = (String) fieldValues.get(KEWPropertyConstants.DOC_TYP_LABEL);
 85  0
         String documentTypeId = (String) fieldValues.get(KEWPropertyConstants.DOCUMENT_TYPE_ID);
 86  0
         String docTypeName = (String) fieldValues.get(KEWPropertyConstants.NAME);
 87  0
         String applicationId = (String) fieldValues.get(KEWPropertyConstants.APPLICATION_ID);
 88  
 
 89  0
         if ("Y".equals(activeIndicator)) {
 90  0
             documentType.setActive(Boolean.TRUE);
 91  0
         } else if ("N".equals(activeIndicator)) {
 92  0
             documentType.setActive(Boolean.FALSE);
 93  
         } else {
 94  0
             documentType.setActive(null);
 95  
         }
 96  
 
 97  0
         if (docTypeLabel != null && !"".equals(docTypeLabel.trim())) {
 98  0
             docTypeLabel = docTypeLabel.replace('*', '%');
 99  0
             documentType.setLabel("%" + docTypeLabel.trim() + "%");
 100  
         }
 101  0
         if (docTypeName != null && !"".equals(docTypeName.trim())) {
 102  0
             documentType.setName(docTypeName.trim());
 103  
         }
 104  
 
 105  0
         if (documentTypeId != null && !"".equals(documentTypeId.trim())) {
 106  0
                 documentType.setDocumentTypeId(documentTypeId.trim());
 107  
         }
 108  0
         if (!StringUtils.isBlank(applicationId)) {
 109  0
             documentType.setActualApplicationId(applicationId);
 110  
         }
 111  
 
 112  0
         return documentType;
 113  
     }
 114  
 }