Search in sources :

Example 1 with TransitionPresenter

use of org.guvnor.ala.ui.client.widget.pipeline.transition.TransitionPresenter 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 TransitionPresenter

use of org.guvnor.ala.ui.client.widget.pipeline.transition.TransitionPresenter 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 TransitionPresenter

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

the class RuntimePresenterTest method setUp.

@Before
public void setUp() {
    runtimeServiceCaller = new CallerMock<>(runtimeService);
    presenter = spy(new RuntimePresenter(view, pipelinePresenter, stagePresenterInstance, transitionPresenterInstance, actionItemPresenterInstance, actionItemSeparatorPresenterInstance, runtimeServiceCaller, notificationEvent, popupHelper, translationService) {

        @Override
        protected StagePresenter newStagePresenter() {
            StagePresenter stagePresenter = mock(StagePresenter.class);
            when(stagePresenterInstance.get()).thenReturn(stagePresenter);
            stagePresenters.add(stagePresenter);
            return super.newStagePresenter();
        }

        @Override
        protected TransitionPresenter newTransitionPresenter() {
            TransitionPresenter transitionPresenter = mock(TransitionPresenter.class);
            when(transitionPresenterInstance.get()).thenReturn(transitionPresenter);
            transitionPresenters.add(transitionPresenter);
            return super.newTransitionPresenter();
        }

        @Override
        protected RuntimeActionItemPresenter newActionItemPresenter() {
            RuntimeActionItemPresenter actionItemPresenter = mock(RuntimeActionItemPresenter.class);
            RuntimeActionItemPresenter.View view = mock(RuntimeActionItemPresenter.View.class);
            when(actionItemPresenter.getView()).thenReturn(view);
            when(actionItemPresenterInstance.get()).thenReturn(actionItemPresenter);
            actionItemPresenters.add(actionItemPresenter);
            return super.newActionItemPresenter();
        }

        @Override
        protected RuntimeActionItemSeparatorPresenter newSeparatorItem() {
            RuntimeActionItemSeparatorPresenter separatorItemPresenter = mock(RuntimeActionItemSeparatorPresenter.class);
            RuntimeActionItemSeparatorPresenter.View view = mock(RuntimeActionItemSeparatorPresenter.View.class);
            when(separatorItemPresenter.getView()).thenReturn(view);
            when(actionItemSeparatorPresenterInstance.get()).thenReturn(separatorItemPresenter);
            separatorItemPresenters.add(separatorItemPresenter);
            return super.newSeparatorItem();
        }
    });
    presenter.init();
    verify(view, times(1)).init(presenter);
    verify(actionItemPresenterInstance, times(4)).get();
    verify(actionItemSeparatorPresenterInstance, times(2)).get();
    startActionPresenter = actionItemPresenters.get(0);
    stopActionPresenter = actionItemPresenters.get(1);
    deleteActionPresenter = actionItemPresenters.get(2);
    showErrorActionPresenter = actionItemPresenters.get(3);
    separatorPresenter = separatorItemPresenters.get(0);
    secondarySeparatorPresenter = separatorItemPresenters.get(1);
}
Also used : TransitionPresenter(org.guvnor.ala.ui.client.widget.pipeline.transition.TransitionPresenter) StagePresenter(org.guvnor.ala.ui.client.widget.pipeline.stage.StagePresenter) RuntimeActionItemPresenter(org.guvnor.ala.ui.client.provider.status.runtime.actions.RuntimeActionItemPresenter) RuntimeActionItemSeparatorPresenter(org.guvnor.ala.ui.client.provider.status.runtime.actions.RuntimeActionItemSeparatorPresenter) Before(org.junit.Before)

Aggregations

StagePresenter (org.guvnor.ala.ui.client.widget.pipeline.stage.StagePresenter)3 TransitionPresenter (org.guvnor.ala.ui.client.widget.pipeline.transition.TransitionPresenter)3 PipelineStatus (org.guvnor.ala.ui.model.PipelineStatus)2 Stage (org.guvnor.ala.ui.model.Stage)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