Coverage Report - org.kuali.rice.kew.routemodule.service.impl.RouteModuleServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
RouteModuleServiceImpl
0%
0/25
0%
0/18
5
 
 1  
 /*
 2  
  * Copyright 2005-2007 The Kuali Foundation
 3  
  *
 4  
  *
 5  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  *
 9  
  * http://www.opensource.org/licenses/ecl2.php
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.kuali.rice.kew.routemodule.service.impl;
 18  
 
 19  
 import org.apache.log4j.Logger;
 20  
 import org.kuali.rice.core.reflect.ObjectDefinition;
 21  
 import org.kuali.rice.core.resourceloader.GlobalResourceLoader;
 22  
 import org.kuali.rice.kew.actionrequest.ActionRequestValue;
 23  
 import org.kuali.rice.kew.engine.node.RouteNode;
 24  
 import org.kuali.rice.kew.exception.ResourceUnavailableException;
 25  
 import org.kuali.rice.kew.exception.WorkflowRuntimeException;
 26  
 import org.kuali.rice.kew.role.RoleRouteModule;
 27  
 import org.kuali.rice.kew.routemodule.FlexRMAdapter;
 28  
 import org.kuali.rice.kew.routemodule.RouteModule;
 29  
 import org.kuali.rice.kew.routemodule.RouteModuleRemote;
 30  
 import org.kuali.rice.kew.routemodule.RouteModuleRemoteAdapter;
 31  
 import org.kuali.rice.kew.routemodule.service.RouteModuleService;
 32  
 import org.kuali.rice.kew.util.KEWConstants;
 33  
 
 34  
 
 35  
 /**
 36  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 37  
  */
 38  0
 public class RouteModuleServiceImpl implements RouteModuleService {
 39  
 
 40  0
     private static final Logger LOG = Logger.getLogger(RouteModuleServiceImpl.class);
 41  
 
 42  
     public RouteModule findRouteModule(RouteNode node) throws ResourceUnavailableException {
 43  0
         String routeMethodName = node.getRouteMethodName();
 44  0
         LOG.debug("Finding route module for routeMethodName="+routeMethodName+" at route level "+node.getRouteNodeName());
 45  0
         RouteModule routeModule = null;
 46  
         // default to FlexRM module if the routeMethodName is null
 47  0
         if (routeMethodName == null || node.isFlexRM()) {
 48  0
             routeModule = getFlexRMRouteModule(routeMethodName);
 49  
         } else {
 50  0
             routeModule = getRouteModule(routeMethodName);
 51  
         }
 52  0
         return routeModule;
 53  
     }
 54  
 
 55  
     public RouteModule findRouteModule(ActionRequestValue actionRequest) throws ResourceUnavailableException {
 56  0
             if (!actionRequest.getResolveResponsibility()) {
 57  0
                     return new RoleRouteModule();
 58  
             }
 59  0
         if (actionRequest.getNodeInstance() == null) {
 60  0
             return null;
 61  
         }
 62  0
         return findRouteModule(actionRequest.getNodeInstance().getRouteNode());
 63  
     }
 64  
 
 65  
     private RouteModule getRouteModule(String routeMethodName) throws ResourceUnavailableException {
 66  0
         if (routeMethodName == null) {
 67  0
             return null;
 68  0
         } else if ("".equals(routeMethodName.trim()) || KEWConstants.ROUTE_LEVEL_NO_ROUTE_MODULE.equals(routeMethodName)) {
 69  0
                 return null;
 70  
         }
 71  0
         Object routeModule = GlobalResourceLoader.getObject(new ObjectDefinition(routeMethodName));//SpringServiceLocator.getExtensionService().getRouteModule(routeMethodName);
 72  0
         if (routeModule instanceof RouteModule) {
 73  0
             return (RouteModule)routeModule;
 74  0
         } else if (routeModule instanceof RouteModuleRemote) {
 75  0
             return new RouteModuleRemoteAdapter((RouteModuleRemote)routeModule);
 76  
         }
 77  0
         throw new WorkflowRuntimeException("Could not locate the Route Module with the given name: " + routeMethodName);
 78  
     }
 79  
 
 80  
     private RouteModule getFlexRMRouteModule(String ruleTemplateName) {
 81  0
         return new FlexRMAdapter();
 82  
     }
 83  
 
 84  
 
 85  
 }