Coverage Report - org.kuali.rice.kew.engine.node.FYIByUniversityId
 
Classes in this File Line Coverage Branch Coverage Complexity
FYIByUniversityId
0%
0/31
0%
0/14
4.333
 
 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.engine.node;
 17  
 
 18  
 import org.apache.commons.lang.StringUtils;
 19  
 import org.apache.log4j.Logger;
 20  
 import org.jdom.Element;
 21  
 import org.kuali.rice.core.api.util.xml.XmlHelper;
 22  
 import org.kuali.rice.kew.api.WorkflowRuntimeException;
 23  
 import org.kuali.rice.kew.engine.RouteContext;
 24  
 import org.kuali.rice.kew.engine.RouteHelper;
 25  
 import org.kuali.rice.kew.exception.WorkflowServiceErrorException;
 26  
 import org.kuali.rice.kew.routeheader.DocumentContent;
 27  
 import org.kuali.rice.kew.routeheader.StandardDocumentContent;
 28  
 import org.kuali.rice.kew.service.KEWServiceLocator;
 29  
 import org.kuali.rice.kew.api.KewApiConstants;
 30  
 import org.kuali.rice.kim.api.identity.Person;
 31  
 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
 32  
 
 33  
 import java.util.ArrayList;
 34  
 import java.util.Collection;
 35  
 import java.util.Iterator;
 36  
 
 37  
 
 38  
 /**
 39  
  * A node which will generate an FYI request to a university ID specified in the document content.
 40  
  *
 41  
  * @deprecated Use {@link org.kuali.rice.kew.rule.UniversityIdRoleAttribute} instead
 42  
  *
 43  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 44  
  */
 45  0
 public class FYIByUniversityId extends RequestActivationNode {
 46  0
     private static final Logger LOG = Logger.getLogger(FYIByUniversityId.class);
 47  
 
 48  
         public SimpleResult process(RouteContext context, RouteHelper helper)
 49  
                         throws Exception {
 50  
 
 51  0
         LOG.debug("processing FYIByUniversityId node");
 52  0
         Element rootElement = getRootElement(new StandardDocumentContent(context.getDocument().getDocContent()));
 53  0
                  Collection<Element> fieldElements = XmlHelper.findElements(rootElement, "field");
 54  0
         Iterator<Element> elementIter = fieldElements.iterator();
 55  0
         while (elementIter.hasNext()) {
 56  0
                 Element field = (Element) elementIter.next();
 57  0
                 Element version = field.getParentElement();
 58  0
                 if (version.getAttribute("current").getValue().equals("true")) {
 59  0
                         LOG.debug("Looking for studentUid field:  " + field.getAttributeValue("name"));
 60  0
                        if (field.getAttribute("name")!= null && field.getAttributeValue("name").equals("studentUid")) {
 61  0
                                String employeeId = field.getChildText("value");
 62  0
                             LOG.debug("Should send an FYI to employee ID:  " + employeeId);
 63  0
                                if (!StringUtils.isBlank(employeeId)) {
 64  0
                                        Person person = KimApiServiceLocator.getPersonService().getPerson(employeeId);
 65  
 
 66  0
                                        if (person == null) {
 67  0
                                                throw new WorkflowRuntimeException("Failed to locate a Person with the given employee ID: " + employeeId);
 68  
                                        }
 69  0
                                        if (!context.isSimulation()) {
 70  0
                                                KEWServiceLocator.getWorkflowDocumentService().adHocRouteDocumentToPrincipal(person.getPrincipalId(), context.getDocument(), KewApiConstants.ACTION_REQUEST_FYI_REQ, null, null, "Notification Request", person.getPrincipalId(), "Notification Request", true, null);
 71  
                                        }
 72  
                                        //wfDoc.adHocRouteDocumentToPrincipal(KewApiConstants.ACTION_REQUEST_FYI_REQ, "Notification Request", new EmplIdVO(field.getChildText("value")), "Notification Request", true);
 73  0
                                 LOG.debug("Sent FYI using the adHocRouteDocumentToPrincipal function to UniversityID:  " + person.getEmployeeId());
 74  0
                                 break;
 75  
                        }
 76  
                 }
 77  
         }
 78  0
         }
 79  0
                 return super.process(context, helper);
 80  
         }
 81  
 
 82  
 
 83  
     private static Element getRootElement(DocumentContent docContent) {
 84  0
         Element rootElement = null;
 85  
         try {
 86  0
             rootElement = XmlHelper.buildJDocument(docContent.getDocument()).getRootElement();
 87  0
         } catch (Exception e) {
 88  0
             throw new WorkflowServiceErrorException("Invalid XML submitted", new ArrayList<Object>());
 89  0
         }
 90  0
         return rootElement;
 91  
     }
 92  
 
 93  
 
 94  
         protected Object getService(String serviceName) {
 95  0
                 return KEWServiceLocator.getService(serviceName);
 96  
         }
 97  
 
 98  
 
 99  
 }
 100  
 
 101