1
2
3
4
5
6
7
8
9 package org.kuali.student.lum.workflow.search;
10
11 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
12 import org.kuali.rice.kew.api.document.DocumentWithContent;
13 import org.kuali.rice.kew.api.document.attribute.DocumentAttribute;
14 import org.kuali.rice.kew.api.extension.ExtensionDefinition;
15 import org.kuali.rice.kew.docsearch.SearchableAttributeValue;
16 import org.kuali.rice.kew.doctype.service.impl.DocumentTypeServiceImpl;
17 import org.kuali.rice.krad.workflow.attribute.KualiXmlSearchableAttributeImpl;
18 import org.kuali.student.r2.common.exceptions.*;
19 import org.kuali.student.r2.core.organization.dto.OrgInfo;
20 import org.kuali.student.r2.core.organization.service.OrganizationService;
21
22 import javax.xml.namespace.QName;
23 import java.util.List;
24
25
26
27
28
29
30 public class OrgSearchAttribute extends KualiXmlSearchableAttributeImpl {
31 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DocumentTypeServiceImpl.class);
32
33 private static final long serialVersionUID = 1L;
34
35
36
37 @SuppressWarnings("unchecked")
38 @Override
39 public List<DocumentAttribute> extractDocumentAttributes(ExtensionDefinition extensionDefinition, DocumentWithContent documentSearchContext) {
40 OrganizationService orgService = null;
41 List<DocumentAttribute> attributeValues = super.extractDocumentAttributes(extensionDefinition, documentSearchContext);
42 for (DocumentAttribute value : attributeValues) {
43 String orgId = (String) value.getValue();
44 if (orgId != null) {
45 try {
46 if (orgService == null) {
47 orgService = (OrganizationService) GlobalResourceLoader.getService(new QName("http://student.kuali.org/wsdl/organization", "OrganizationService"));
48 }
49 OrgInfo orgInfo = orgService.getOrg(orgId, null);
50
51 ((SearchableAttributeValue) value).setupAttributeValue(orgInfo.getShortName());
52 } catch (DoesNotExistException e) {
53 LOG.error(e);
54 throw new RuntimeException(e);
55 } catch (InvalidParameterException e) {
56 LOG.error(e);
57 throw new RuntimeException(e);
58 } catch (MissingParameterException e) {
59 LOG.error(e);
60 throw new RuntimeException(e);
61 } catch (OperationFailedException e) {
62 LOG.error(e);
63 throw new RuntimeException(e);
64 } catch (PermissionDeniedException e) {
65 LOG.error(e);
66 throw new RuntimeException(e);
67 }
68 }
69 }
70 return attributeValues;
71 }
72 }