Eli Mesika has uploaded a new change for review.

Change subject: core:fixing step numbering for steps and sub-steps
......................................................................

core:fixing step numbering for steps and sub-steps

When a step is added to a job, it should get its step_number value
according to the existing steps already added to the job.
The same is for adding sub-step to an exiting step.

This patch fix a problem in adding step/sub-step when all added
steps/sub-steps get a 0 for the step_number value.

This resulted in incorrect order of steps and sub-steps in the UI while
steps where ordered by the step_number but this had no affect
since the step_number was always 0.

Change-Id: Ic72e9ab64160116f4fbac3f3b2cdea63db7b9c75
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1143035
Signed-off-by: Eli Mesika <emes...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddStepCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/job/JobRepository.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/job/JobRepositoryImpl.java
3 files changed, 20 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/22/33622/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddStepCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddStepCommand.java
index 3551222..258580d 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddStepCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddStepCommand.java
@@ -5,6 +5,7 @@
 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.job.JobRepositoryFactory;
 import org.ovirt.engine.core.common.action.AddStepParameters;
 import org.ovirt.engine.core.common.errors.VdcBllMessages;
 import org.ovirt.engine.core.common.job.Job;
@@ -52,6 +53,7 @@
         if (parentStep == null) { // A step that is directly under a job
                 context.setJob(job);
                 context.setExecutionMethod(ExecutionMethod.AsJob);
+                JobRepositoryFactory.getJobRepository().loadJobSteps(job);
                 Step step = ExecutionHandler.addStep(context, 
getParameters().getStepType(), getParameters().getDescription(), true);
                 setActionReturnValue(step.getId());
                 setSucceeded(true);
@@ -59,6 +61,7 @@
         else {// this is a sub-step
                 context.setStep(parentStep);
                 context.setExecutionMethod(ExecutionMethod.AsStep);
+                
JobRepositoryFactory.getJobRepository().loadParentStepSteps(parentStep);
                 Step step = ExecutionHandler.addSubStep(context, parentStep, 
getParameters().getStepType(), getParameters().getDescription(), true);
                 setActionReturnValue(step.getId());
                 setSucceeded(true);
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/job/JobRepository.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/job/JobRepository.java
index bf5cc84..268b455 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/job/JobRepository.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/job/JobRepository.java
@@ -85,6 +85,14 @@
     void loadJobSteps(Job job);
 
     /**
+     * Update the {@link Step} entity with its Steps.
+     *
+     * @param step
+     *            The job to update with its steps(can't be <code>null</code>).
+     */
+    void loadParentStepSteps(Step step);
+
+    /**
      * Handles the status of uncompleted jobs and their steps:
      * <li>Job without Steps that have tasks will be marked as {@code 
ExecutionStatus.UNKNOWN}
      * <li>Job with Steps that have tasks will be remained as is to be process 
by the {@code AsyncTaskManager}.
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/job/JobRepositoryImpl.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/job/JobRepositoryImpl.java
index c167dff..832f9a6 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/job/JobRepositoryImpl.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/job/JobRepositoryImpl.java
@@ -125,6 +125,15 @@
         }
     }
 
+    @Override
+    public void loadParentStepSteps(final Step step) {
+        List<Step> steps = stepDao.getStepsByParentStepId(step.getId());
+        if (!steps.isEmpty()) {
+            step.setSteps(steps);
+        }
+    }
+
+
     /**
      * Gets a list of {@link Step} entities ordered by:
      * <li> parent step id, preceded by nulls


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic72e9ab64160116f4fbac3f3b2cdea63db7b9c75
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5
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