Coverage Report - org.kuali.student.lum.workflow.search.OrgSearchAttribute
 
Classes in this File Line Coverage Branch Coverage Complexity
OrgSearchAttribute
0%
0/29
0%
0/6
14
 
 1  
 /**
 2  
  * Copyright 2010 The Kuali Foundation Licensed under the
 3  
  * Educational Community License, Version 2.0 (the "License"); you may
 4  
  * not use this file except in compliance with the License. You may
 5  
  * obtain a copy of the License at
 6  
  *
 7  
  * http://www.osedu.org/licenses/ECL-2.0
 8  
  *
 9  
  * Unless required by applicable law or agreed to in writing,
 10  
  * software distributed under the License is distributed on an "AS IS"
 11  
  * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 12  
  * or implied. See the License for the specific language governing
 13  
  * permissions and limitations under the License.
 14  
  */
 15  
 
 16  
 package org.kuali.student.lum.workflow.search;
 17  
 
 18  
 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
 19  
 import org.kuali.rice.kew.api.document.DocumentWithContent;
 20  
 import org.kuali.rice.kew.api.document.attribute.DocumentAttribute;
 21  
 import org.kuali.rice.kew.api.extension.ExtensionDefinition;
 22  
 import org.kuali.rice.kew.docsearch.SearchableAttributeValue;
 23  
 import org.kuali.rice.kew.doctype.service.impl.DocumentTypeServiceImpl;
 24  
 import org.kuali.rice.krad.workflow.attribute.KualiXmlSearchableAttributeImpl;
 25  
 import org.kuali.student.common.exceptions.*;
 26  
 import org.kuali.student.core.organization.dto.OrgInfo;
 27  
 import org.kuali.student.core.organization.service.OrganizationService;
 28  
 
 29  
 import javax.xml.namespace.QName;
 30  
 import java.util.List;
 31  
 
 32  
 /**
 33  
  * Extension for CluCreditCourse documents searches that converts Organization ID to the Organization Long Name
 34  
  * @author lindholm
 35  
  *
 36  
  */
 37  0
 public class OrgSearchAttribute extends KualiXmlSearchableAttributeImpl {
 38  0
     private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DocumentTypeServiceImpl.class);
 39  
 
 40  
     private static final long serialVersionUID = 1L;
 41  
 
 42  
     // TODO: RICE=M9 UPGRADE check that replacing getDocumentAttributes with extractDocumentAttributes is really the intended behavior
 43  
         @SuppressWarnings("unchecked")
 44  
         @Override
 45  
         public List<DocumentAttribute> extractDocumentAttributes(ExtensionDefinition extensionDefinition, DocumentWithContent documentSearchContext) {
 46  0
                 OrganizationService orgService = null;
 47  0
                 List<DocumentAttribute> attributeValues = super.extractDocumentAttributes(extensionDefinition, documentSearchContext);
 48  0
                 for (DocumentAttribute value : attributeValues) {
 49  0
                         String orgId = (String)value.getValue();
 50  0
                         if (orgId != null) {
 51  
                                 try {
 52  0
                                         if (orgService == null) {
 53  0
                                                 orgService = (OrganizationService) GlobalResourceLoader.getService(new QName("http://student.kuali.org/wsdl/organization","OrganizationService"));
 54  
                                         }
 55  0
                                         OrgInfo orgInfo = orgService.getOrganization(orgId);
 56  
             //        TODO: RICE-M7 UPGRADE I think this is correct but I'm not sure
 57  0
                                         ((SearchableAttributeValue)value).setupAttributeValue(orgInfo.getShortName());
 58  0
                                 } catch (DoesNotExistException e) {
 59  0
                                         LOG.error(e);
 60  0
                                         throw new RuntimeException(e);
 61  0
                                 } catch (InvalidParameterException e) {
 62  0
                                         LOG.error(e);
 63  0
                                         throw new RuntimeException(e);
 64  0
                                 } catch (MissingParameterException e) {
 65  0
                                         LOG.error(e);
 66  0
                                         throw new RuntimeException(e);
 67  0
                                 } catch (OperationFailedException e) {
 68  0
                                         LOG.error(e);
 69  0
                                         throw new RuntimeException(e);
 70  0
                                 } catch (PermissionDeniedException e) {
 71  0
                                         LOG.error(e);
 72  0
                                         throw new RuntimeException(e);
 73  0
                                 }
 74  
                         }
 75  0
                 }
 76  0
                 return attributeValues;
 77  
         }
 78  
 }