| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 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 | |
|
| 32 | |
|
| 33 | |
|
| 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 | |
|
| 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 | |
|
| 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 | |
} |