Eli Mesika has uploaded a new change for review.

Change subject: [WIP] core: Adding AddExternalStepCommand
......................................................................

[WIP] core: Adding AddExternalStepCommand

Change-Id: I014a4911873ebe7c8dc37b6504655b377d73da3e
Signed-off-by: Eli Mesika <emes...@redhat.com>
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=872719
---
A 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddExternalStepCommand.java
A 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/AddExternalStepParameters.java
2 files changed, 134 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/27/15227/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddExternalStepCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddExternalStepCommand.java
new file mode 100644
index 0000000..00fa519
--- /dev/null
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddExternalStepCommand.java
@@ -0,0 +1,75 @@
+package org.ovirt.engine.core.bll;
+
+import java.util.List;
+
+import org.ovirt.engine.core.bll.job.ExecutionContext;
+import org.ovirt.engine.core.bll.job.ExecutionContext.ExecutionMethod;
+import org.ovirt.engine.core.bll.job.ExecutionHandler;
+import org.ovirt.engine.core.bll.utils.PermissionSubject;
+import org.ovirt.engine.core.common.action.AddExternalStepParameters;
+import org.ovirt.engine.core.common.job.Job;
+import org.ovirt.engine.core.common.job.Step;
+import org.ovirt.engine.core.common.job.StepEnum;
+import org.ovirt.engine.core.dal.dbbroker.DbFacade;
+
+public class AddExternalStepCommand <T extends AddExternalStepParameters> 
extends CommandBase<T>{
+
+    private Job job;
+    private Step parentStep;
+
+    public AddExternalStepCommand(T parameters) {
+        super(parameters);
+    }
+
+    @Override
+    protected boolean canDoAction() {
+        boolean retValue=true;
+        job = DbFacade.getInstance().getJobDao().get(getParameters().getId());
+        if (job != null) {
+            if (!job.isExternal()) {
+                retValue = false;
+                //TODO message
+            }
+        }
+        else {
+            parentStep = 
DbFacade.getInstance().getStepDao().get(getParameters().getId());
+        }
+        if (job == null && parentStep == null) {
+            retValue=false;
+            //TODO message
+        }
+        return retValue;
+    }
+
+    /**
+     *
+     */
+    private static final long serialVersionUID = 1L;
+
+    @Override
+    protected void executeCommand() {
+        ExecutionContext context = new ExecutionContext();
+        context.setMonitored(true);
+        if (parentStep == null) { // A step that is directly under a job
+                context.setJob(job);
+                context.setExecutionMethod(ExecutionMethod.AsJob);
+                Step step = 
ExecutionHandler.addStep(context,StepEnum.EXECUTING, 
getParameters().getDescription(), true);
+                setActionReturnValue(step.getId());
+                setSucceeded(true);
+        }
+        else {// this is a sub-step
+                context.setStep(parentStep);
+                context.setExecutionMethod(ExecutionMethod.AsStep);
+                Step step = ExecutionHandler.addSubStep(context, parentStep, 
StepEnum.EXECUTING, getParameters().getDescription(), true);
+                setActionReturnValue(step.getId());
+                setSucceeded(true);
+        }
+    }
+
+    @Override
+    public List<PermissionSubject> getPermissionCheckSubjects() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/AddExternalStepParameters.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/AddExternalStepParameters.java
new file mode 100644
index 0000000..c23f47e
--- /dev/null
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/AddExternalStepParameters.java
@@ -0,0 +1,59 @@
+package org.ovirt.engine.core.common.action;
+
+import org.ovirt.engine.core.common.job.JobExecutionStatus;
+import org.ovirt.engine.core.common.job.StepEnum;
+import org.ovirt.engine.core.compat.Guid;
+
+public class AddExternalStepParameters extends VdcActionParametersBase{
+
+    /**
+     *
+     */
+    private static final long serialVersionUID = 1L;
+
+    private Guid id;
+    private String description;
+    private StepEnum stepType;
+    private JobExecutionStatus status;
+
+    public Guid getId() {
+        return id;
+    }
+
+    public void setId(Guid id) {
+        this.id = id;
+    }
+
+    public JobExecutionStatus getStatus() {
+        return status;
+    }
+
+    public void setStatus(JobExecutionStatus status) {
+        this.status = status;
+    }
+
+    public StepEnum getStepType() {
+        return stepType;
+    }
+
+    public void setStepType(StepEnum stepType) {
+        this.stepType = stepType;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public AddExternalStepParameters(Guid id, String description, StepEnum 
stepType, JobExecutionStatus status) {
+        super();
+        this.id = id;
+        this.description = description;
+        this.stepType = stepType;
+        this.status = status;
+        this.setId(id);
+    }
+}


--
To view, visit http://gerrit.ovirt.org/15227
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I014a4911873ebe7c8dc37b6504655b377d73da3e
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Eli Mesika <emes...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to