Coverage Report - org.kuali.rice.kew.engine.simulation.SimulationActionToTake
 
Classes in this File Line Coverage Branch Coverage Complexity
SimulationActionToTake
0%
0/26
0%
0/8
2
 
 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.simulation;
 17  
 
 18  
 import java.io.Serializable;
 19  
 
 20  
 import org.apache.commons.lang.StringUtils;
 21  
 import org.kuali.rice.kew.api.action.RoutingReportActionToTake;
 22  
 import org.kuali.rice.kew.service.KEWServiceLocator;
 23  
 import org.kuali.rice.kim.api.identity.Person;
 24  
 import org.kuali.rice.kim.api.identity.principal.Principal;
 25  
 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
 26  
 
 27  
 /**
 28  
  * An object represnting an action to take in the simulation engine
 29  
  *
 30  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 31  
  */
 32  
 public class SimulationActionToTake implements Serializable {
 33  
         private static final long serialVersionUID = 5212455086079117671L;
 34  
 
 35  
         private String actionToPerform;
 36  
     private Person user;
 37  
     private String nodeName;
 38  
 
 39  0
     public SimulationActionToTake() {
 40  0
     }
 41  
 
 42  
         public String getActionToPerform() {
 43  0
                 return actionToPerform;
 44  
         }
 45  
 
 46  
         public void setActionToPerform(String actionToPerform) {
 47  0
                 this.actionToPerform = actionToPerform;
 48  0
         }
 49  
 
 50  
         public String getNodeName() {
 51  0
                 return nodeName;
 52  
         }
 53  
 
 54  
         public void setNodeName(String nodeName) {
 55  0
                 this.nodeName = nodeName;
 56  0
         }
 57  
 
 58  
         public Person getUser() {
 59  0
                 return user;
 60  
         }
 61  
 
 62  
         public void setUser(Person user) {
 63  0
                 this.user = user;
 64  0
         }
 65  
 
 66  
     public static SimulationActionToTake from(RoutingReportActionToTake actionToTake) {
 67  0
         if (actionToTake == null) {
 68  0
             return null;
 69  
         }
 70  0
         SimulationActionToTake simActionToTake = new SimulationActionToTake();
 71  0
         simActionToTake.setNodeName(actionToTake.getNodeName());
 72  0
         if (StringUtils.isBlank(actionToTake.getActionToPerform())) {
 73  0
             throw new IllegalArgumentException("ReportActionToTakeVO must contain an action taken code and does not");
 74  
         }
 75  0
         simActionToTake.setActionToPerform(actionToTake.getActionToPerform());
 76  0
         if (actionToTake.getPrincipalId() == null) {
 77  0
             throw new IllegalArgumentException("ReportActionToTakeVO must contain a principalId and does not");
 78  
         }
 79  0
         Principal kPrinc = KEWServiceLocator.getIdentityHelperService().getPrincipal(actionToTake.getPrincipalId());
 80  0
         Person user = KimApiServiceLocator.getPersonService().getPerson(kPrinc.getPrincipalId());
 81  0
         if (user == null) {
 82  0
             throw new IllegalStateException("Could not locate Person for the given id: " + actionToTake.getPrincipalId());
 83  
         }
 84  0
         simActionToTake.setUser(user);
 85  0
         return simActionToTake;
 86  
     }
 87  
 
 88  
 }