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.api.reflect.ObjectDefinition;
 21  
 import org.kuali.rice.core.api.reflect.ObjectDefinition;
 22  
 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
 23  
 import org.kuali.rice.kew.actionrequest.ActionRequestValue;
 24  
 import org.kuali.rice.kew.api.WorkflowRuntimeException;
 25  
 import org.kuali.rice.kew.engine.node.RouteNode;
 26  
 import org.kuali.rice.kew.exception.ResourceUnavailableException;
 27  
 import org.kuali.rice.kew.role.RoleRouteModule;
 28  
 import org.kuali.rice.kew.routemodule.FlexRMAdapter;
 29  
 import org.kuali.rice.kew.routemodule.RouteModule;
 30  
 import org.kuali.rice.kew.routemodule.RouteModuleRemote;
 31  
 import org.kuali.rice.kew.routemodule.RouteModuleRemoteAdapter;
 32  
 import org.kuali.rice.kew.routemodule.service.RouteModuleService;
 33  
 import org.kuali.rice.kew.util.KEWConstants;
 34  
 
 35  
 
 36  
 /**
 37  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 38  
  */
 39  0
 public class RouteModuleServiceImpl implements RouteModuleService {
 40  
 
 41  0
     private static final Logger LOG = Logger.getLogger(RouteModuleServiceImpl.class);
 42  
 
 43  
     public RouteModule findRouteModule(RouteNode node) throws ResourceUnavailableException {
 44  0
         String routeMethodName = node.getRouteMethodName();
 45  0
         LOG.debug("Finding route module for routeMethodName="+routeMethodName+" at route level "+node.getRouteNodeName());
 46  0
         RouteModule routeModule = null;
 47  
         // default to FlexRM module if the routeMethodName is null
 48  0
         if (routeMethodName == null || node.isFlexRM()) {
 49  0
             routeModule = getFlexRMRouteModule(routeMethodName);
 50  
         } else {
 51  0
             routeModule = getRouteModule(routeMethodName);
 52  
         }
 53  0
         return routeModule;
 54  
     }
 55  
 
 56  
     public RouteModule findRouteModule(ActionRequestValue actionRequest) throws ResourceUnavailableException {
 57  0
             if (!actionRequest.getResolveResponsibility()) {
 58  0
                     return new RoleRouteModule();
 59  
             }
 60  0
         if (actionRequest.getNodeInstance() == null) {
 61  0
             return null;
 62  
         }
 63  0
         return findRouteModule(actionRequest.getNodeInstance().getRouteNode());
 64  
     }
 65  
 
 66  
     private RouteModule getRouteModule(String routeMethodName) throws ResourceUnavailableException {
 67  0
         if (routeMethodName == null) {
 68  0
             return null;
 69  0
         } else if ("".equals(routeMethodName.trim()) || KEWConstants.ROUTE_LEVEL_NO_ROUTE_MODULE.equals(routeMethodName)) {
 70  0
                 return null;
 71  
         }
 72  0
         Object routeModule = GlobalResourceLoader.getObject(new ObjectDefinition(routeMethodName));//SpringServiceLocator.getExtensionService().getRouteModule(routeMethodName);
 73  0
         if (routeModule instanceof RouteModule) {
 74  0
             return (RouteModule)routeModule;
 75  0
         } else if (routeModule instanceof RouteModuleRemote) {
 76  0
             return new RouteModuleRemoteAdapter((RouteModuleRemote)routeModule);
 77  
         }
 78  0
         throw new WorkflowRuntimeException("Could not locate the Route Module with the given name: " + routeMethodName);
 79  
     }
 80  
 
 81  
     private RouteModule getFlexRMRouteModule(String ruleTemplateName) {
 82  0
         return new FlexRMAdapter();
 83  
     }
 84  
 
 85  
 
 86  
 }