1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
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 | |
|
29 | |
|
30 | |
|
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 | |
} |