Coverage Report - org.kuali.rice.kew.impl.document.search.DocumentSearchCriteriaBo
 
Classes in this File Line Coverage Branch Coverage Complexity
DocumentSearchCriteriaBo
0%
0/32
0%
0/18
0
 
 1  
 /**
 2  
  * Copyright 2005-2011 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.impl.document.search
 17  
 
 18  
 import org.kuali.rice.krad.bo.BusinessObject
 19  
 import org.kuali.rice.kew.doctype.bo.DocumentType
 20  
 import org.kuali.rice.kew.service.KEWServiceLocator
 21  
 
 22  
 import org.kuali.rice.kim.api.services.KimApiServiceLocator
 23  
 import org.kuali.rice.kim.api.identity.Person
 24  
 import org.kuali.rice.kew.api.document.search.DocumentSearchResult
 25  
 import org.kuali.rice.kew.api.document.Document
 26  
 
 27  
 import org.kuali.rice.kew.api.document.DocumentStatus
 28  
 import java.sql.Timestamp
 29  
 
 30  
 /**
 31  
  * Defines the business object that specifies the criteria used on document searches.
 32  
  *
 33  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 34  
  */
 35  
 class DocumentSearchCriteriaBo implements BusinessObject {
 36  
 
 37  
     String documentTypeName
 38  
     String documentId
 39  
     String statusCode
 40  
     String applicationDocumentId
 41  
     String applicationDocumentStatus
 42  
     String title
 43  
     String initiatorPrincipalName
 44  
     String viewerPrincipalName
 45  
     String groupViewerName
 46  
     String groupViewerId
 47  
     String approverPrincipalName
 48  
     String routeNodeName
 49  
     String routeNodeLogic
 50  
     Timestamp dateCreated
 51  
     Timestamp dateLastModified
 52  
     Timestamp dateApproved
 53  
     Timestamp dateFinalized
 54  
     String saveName
 55  
 
 56  
     void refresh() {
 57  
         // nothing to refresh
 58  
     }
 59  
 
 60  
     DocumentType getDocumentType() {
 61  0
         if (documentTypeName == null) {
 62  0
             return null
 63  
         }
 64  0
             return KEWServiceLocator.getDocumentTypeService().findByName(documentTypeName)
 65  
     }
 66  
 
 67  
     Person getInitiatorPerson() {
 68  0
         if (initiatorPrincipalName == null) {
 69  0
             return null
 70  
         }
 71  0
         return KimApiServiceLocator.getPersonService().getPersonByPrincipalName(initiatorPrincipalName)
 72  
     }
 73  
 
 74  
     Person getApproverPerson() {
 75  0
         if (approverPrincipalName == null) {
 76  0
             return null
 77  
         }
 78  0
         return KimApiServiceLocator.getPersonService().getPersonByPrincipalName(approverPrincipalName)
 79  
     }
 80  
 
 81  
     Person getViewerPerson() {
 82  0
         if (viewerPrincipalName == null) {
 83  0
             return null
 84  
         }
 85  0
         return KimApiServiceLocator.getPersonService().getPersonByPrincipalName(viewerPrincipalName)
 86  
     }
 87  
 
 88  
 
 89  
     String getStatusLabel() {
 90  0
         if (statusCode == null) {
 91  0
             return ""
 92  
         }
 93  0
         return DocumentStatus.fromCode(statusCode).getLabel()
 94  
     }
 95  
 
 96  
     String getDocumentTypeLabel() {
 97  0
         DocumentType documentType = getDocumentType()
 98  0
         if (documentType != null) {
 99  0
             return documentType.getLabel()
 100  
         }
 101  0
         return ""
 102  
     }
 103  
 
 104  
     /**
 105  
      * Returns the route image which can be used to construct the route log link in custom lookup helper code.
 106  
      */
 107  
     String getRouteLog() {
 108  0
         return "<img alt=\"Route Log for Document\" src=\"images/my_route_log.gif\"/>";
 109  
     }
 110  
 
 111  
     void populateFromDocumentSearchResult(DocumentSearchResult result) {
 112  0
         Document document = result.document
 113  0
         documentTypeName = document.documentTypeName
 114  0
         documentId = document.documentId
 115  0
         statusCode = document.status.code
 116  0
         applicationDocumentId = document.applicationDocumentId
 117  0
         applicationDocumentStatus = document.applicationDocumentStatus
 118  0
         title = document.title
 119  0
         initiatorPrincipalName = principalIdToName(document.initiatorPrincipalId)
 120  0
         dateCreated = new Timestamp(document.dateCreated.getMillis())
 121  
     }
 122  
 
 123  
     private String principalIdToName(String principalId) {
 124  0
         if (principalId.trim()) {
 125  0
             return KimApiServiceLocator.getIdentityService().getPrincipal(principalId).getPrincipalName()
 126  
         }
 127  0
         return null
 128  
     }
 129  
 
 130  
 }