Search in sources :

Example 1 with StagePresenter

use of org.guvnor.ala.ui.client.widget.pipeline.stage.StagePresenter in project kie-wb-common by kiegroup.

the class RuntimePresenter method onStageStatusChange.

public void onStageStatusChange(@Observes final StageStatusChangeEvent event) {
    if (isFromCurrentPipeline(event.getPipelineExecutionTraceKey())) {
        PipelineExecutionTrace trace = item.getPipelineTrace();
        Stage currentStage = currentStages.stream().filter(step -> event.getStage().equals(step.getName())).findFirst().orElse(null);
        if (currentStage != null) {
            StagePresenter stagePresenter = stagePresenters.get(currentStage);
            stagePresenter.setState(buildStageState(event.getStatus()));
        } else {
            Stage stage = new Stage(item.getPipelineTrace().getPipeline().getKey(), event.getStage());
            PipelineStatus stageStatus = event.getStatus();
            StagePresenter stagePresenter = newStagePresenter();
            stagePresenter.setup(stage);
            stagePresenter.setState(buildStageState(stageStatus));
            if (!currentStages.isEmpty()) {
                TransitionPresenter transitionPresenter = newTransitionPresenter();
                currentTransitions.add(transitionPresenter);
                pipelinePresenter.addStage(transitionPresenter.getView());
            }
            pipelinePresenter.addStage(stagePresenter.getView());
            currentStages.add(stage);
            stagePresenters.put(stage, stagePresenter);
        }
        trace.setStageStatus(event.getStage(), event.getStatus());
    }
}
Also used : TransitionPresenter(org.guvnor.ala.ui.client.widget.pipeline.transition.TransitionPresenter) PipelineStatus(org.guvnor.ala.ui.model.PipelineStatus) PipelineExecutionTrace(org.guvnor.ala.ui.model.PipelineExecutionTrace) StagePresenter(org.guvnor.ala.ui.client.widget.pipeline.stage.StagePresenter) Stage(org.guvnor.ala.ui.model.Stage)

Example 2 with StagePresenter

use of org.guvnor.ala.ui.client.widget.pipeline.stage.StagePresenter in project kie-wb-common by kiegroup.

the class RuntimePresenter method setupPipeline.

private void setupPipeline(final PipelineExecutionTrace trace) {
    clearPipeline();
    boolean showStep = true;
    Pipeline pipeline = trace.getPipeline();
    for (int i = 0; showStep && i < pipeline.getStages().size(); i++) {
        Stage stage = pipeline.getStages().get(i);
        PipelineStatus stageStatus = trace.getStageStatus(stage.getName());
        showStep = showStage(stageStatus);
        if (showStep) {
            if (i > 0) {
                TransitionPresenter transitionPresenter = newTransitionPresenter();
                currentTransitions.add(transitionPresenter);
                pipelinePresenter.addStage(transitionPresenter.getView());
            }
            final StagePresenter stagePresenter = newStagePresenter();
            stagePresenter.setup(stage);
            stagePresenter.setState(buildStageState(stageStatus));
            pipelinePresenter.addStage(stagePresenter.getView());
            currentStages.add(stage);
            stagePresenters.put(stage, stagePresenter);
        }
    }
}
Also used : TransitionPresenter(org.guvnor.ala.ui.client.widget.pipeline.transition.TransitionPresenter) PipelineStatus(org.guvnor.ala.ui.model.PipelineStatus) StagePresenter(org.guvnor.ala.ui.client.widget.pipeline.stage.StagePresenter) Stage(org.guvnor.ala.ui.model.Stage) Pipeline(org.guvnor.ala.ui.model.Pipeline)

Example 3 with StagePresenter

use of org.guvnor.ala.ui.client.widget.pipeline.stage.StagePresenter in project kie-wb-common by kiegroup.

the class RuntimePresenterSetupsTest method verifyPipelineWasSet.

/**
 * Verify that the pipeline was properly drawn on screen.
 * @param trace the trace to test.
 * @param displayableStages list of stages that we know by construction must be displayed.
 */
private void verifyPipelineWasSet(PipelineExecutionTrace trace, List<Stage> displayableStages) {
    int stagesSize = displayableStages.size();
    int transitionsSize = stagesSize > 0 ? (stagesSize - 1) : 0;
    for (int i = 0; i < displayableStages.size(); i++) {
        StagePresenter stagePresenter = stagePresenters.get(i);
        verify(stagePresenter, times(1)).setup(displayableStages.get(i));
    }
    verify(stagePresenterInstance, times(stagesSize)).get();
    verify(transitionPresenterInstance, times(transitionsSize)).get();
    verify(pipelinePresenter, times(stagesSize + transitionsSize)).addStage(Mockito.<IsElement>any());
}
Also used : StagePresenter(org.guvnor.ala.ui.client.widget.pipeline.stage.StagePresenter)

Example 4 with StagePresenter

use of org.guvnor.ala.ui.client.widget.pipeline.stage.StagePresenter in project kie-wb-common by kiegroup.

the class RuntimePresenterSetupsTest method testOnStageStatusChangeNewStageChanged.

/**
 * an item with a pipeline execution trace was initially set and a new stage status not yet drawn has changed.
 */
@Test
public void testOnStageStatusChangeNewStageChanged() {
    preparePipelineExecutionTraceSetup();
    RuntimeListItem item = new RuntimeListItem(RUNTIME_NAME, trace);
    // setup the presenter.
    presenter.setup(item);
    int initialStagePresentersSize = stagePresenters.size();
    // emulate the next stage consecutive stage finishing.
    Stage stage = item.getPipelineTrace().getPipeline().getStages().get(displayableStages.size());
    presenter.onStageStatusChange(new StageStatusChangeEvent(trace.getKey(), stage.getName(), PipelineStatus.RUNNING));
    // an additional stage was added.
    verify(stagePresenterInstance, times(initialStagePresentersSize + 1)).get();
    // the newly stage is set to EXECUTING in the UI
    StagePresenter stagePresenter = stagePresenters.get(stagePresenters.size() - 1);
    verify(stagePresenter, times(1)).setup(stage);
    verify(stagePresenter, times(1)).setState(State.EXECUTING);
}
Also used : RuntimeListItem(org.guvnor.ala.ui.model.RuntimeListItem) StagePresenter(org.guvnor.ala.ui.client.widget.pipeline.stage.StagePresenter) Stage(org.guvnor.ala.ui.model.Stage) StageStatusChangeEvent(org.guvnor.ala.ui.events.StageStatusChangeEvent) Test(org.junit.Test)

Example 5 with StagePresenter

use of org.guvnor.ala.ui.client.widget.pipeline.stage.StagePresenter in project kie-wb-common by kiegroup.

the class RuntimePresenterSetupsTest method testOnStageStatusChangeLastVisibleStageChanged.

/**
 * an item with a pipeline execution trace was initially set and the last stage status has changed.
 */
@Test
public void testOnStageStatusChangeLastVisibleStageChanged() {
    preparePipelineExecutionTraceSetup();
    RuntimeListItem item = new RuntimeListItem(RUNTIME_NAME, trace);
    // setup the presenter.
    presenter.setup(item);
    int initialStagePresentersSize = stagePresenters.size();
    // emulate the last stage finishing.
    Stage stage = displayableStages.get(displayableStages.size() - 1);
    presenter.onStageStatusChange(new StageStatusChangeEvent(trace.getKey(), stage.getName(), PipelineStatus.FINISHED));
    // the last stage status was changed form EXECUTING to to DONE
    StagePresenter stagePresenter = stagePresenters.get(stagePresenters.size() - 1);
    verify(stagePresenter, times(1)).setState(State.EXECUTING);
    verify(stagePresenter, times(1)).setState(State.DONE);
    // no additional stages were added.
    verify(stagePresenterInstance, times(initialStagePresentersSize)).get();
}
Also used : RuntimeListItem(org.guvnor.ala.ui.model.RuntimeListItem) StagePresenter(org.guvnor.ala.ui.client.widget.pipeline.stage.StagePresenter) Stage(org.guvnor.ala.ui.model.Stage) StageStatusChangeEvent(org.guvnor.ala.ui.events.StageStatusChangeEvent) Test(org.junit.Test)

Aggregations

StagePresenter (org.guvnor.ala.ui.client.widget.pipeline.stage.StagePresenter)6 Stage (org.guvnor.ala.ui.model.Stage)4 TransitionPresenter (org.guvnor.ala.ui.client.widget.pipeline.transition.TransitionPresenter)3 StageStatusChangeEvent (org.guvnor.ala.ui.events.StageStatusChangeEvent)2 PipelineStatus (org.guvnor.ala.ui.model.PipelineStatus)2 RuntimeListItem (org.guvnor.ala.ui.model.RuntimeListItem)2 Test (org.junit.Test)2 RuntimeActionItemPresenter (org.guvnor.ala.ui.client.provider.status.runtime.actions.RuntimeActionItemPresenter)1 RuntimeActionItemSeparatorPresenter (org.guvnor.ala.ui.client.provider.status.runtime.actions.RuntimeActionItemSeparatorPresenter)1 Pipeline (org.guvnor.ala.ui.model.Pipeline)1 PipelineExecutionTrace (org.guvnor.ala.ui.model.PipelineExecutionTrace)1 Before (org.junit.Before)1