]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/tasks/SlcManager.java
Remove the Task suffix
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.simple / src / main / java / org / argeo / slc / core / execution / tasks / SlcManager.java
1 package org.argeo.slc.core.execution.tasks;
2
3 import java.lang.reflect.Method;
4 import java.util.UUID;
5
6 import org.argeo.slc.SlcException;
7 import org.argeo.slc.deploy.DeployedSystem;
8 import org.argeo.slc.deploy.DeployedSystemManager;
9 import org.argeo.slc.process.SlcExecution;
10 import org.argeo.slc.process.SlcExecutionRelated;
11 import org.argeo.slc.process.SlcExecutionStep;
12 import org.argeo.slc.structure.StructureRegistry;
13
14 public class SlcManager implements Runnable, SlcExecutionRelated {
15 private String uuid;
16 private String slcExecutionUuid;
17 private String slcExecutionStepUuid;
18
19 private String action;
20 private DeployedSystemManager<DeployedSystem> manager;
21
22 public final void run() {
23 uuid = UUID.randomUUID().toString();
24 executeActions(StructureRegistry.ALL);
25 }
26
27 protected void executeActions(String mode) {
28 try {
29 Method method = manager.getClass().getMethod(action, null);
30 method.invoke(manager, null);
31 } catch (Exception e) {
32 throw new SlcException("Cannot execute action " + action
33 + " for manager " + manager, e);
34 }
35 }
36
37 public void setAction(String action) {
38 this.action = action;
39 }
40
41 public void setManager(DeployedSystemManager<DeployedSystem> manager) {
42 this.manager = manager;
43 }
44
45 public String getUuid() {
46 return uuid;
47 }
48
49 public void setUuid(String uuid) {
50 this.uuid = uuid;
51 }
52
53 public String getSlcExecutionUuid() {
54 return slcExecutionUuid;
55 }
56
57 public void setSlcExecutionUuid(String slcExecutionUuid) {
58 this.slcExecutionUuid = slcExecutionUuid;
59 }
60
61 public String getSlcExecutionStepUuid() {
62 return slcExecutionStepUuid;
63 }
64
65 public void setSlcExecutionStepUuid(String slcExecutionStepUuid) {
66 this.slcExecutionStepUuid = slcExecutionStepUuid;
67 }
68
69 public void notifySlcExecution(SlcExecution slcExecution) {
70 if (slcExecution != null) {
71 slcExecutionUuid = slcExecution.getUuid();
72 SlcExecutionStep step = slcExecution.currentStep();
73 if (step != null) {
74 slcExecutionStepUuid = step.getUuid();
75 }
76 }
77 }
78 }