public boolean removeItem(final PipelineExecutionTraceKey pipelineExecutionTraceKey) { final Optional<RuntimePresenter> value = currentItems.stream() .filter(presenter -> !presenter.getItem().isRuntime() && presenter.getItem().getPipelineTrace() != null && pipelineExecutionTraceKey.equals(presenter.getItem().getPipelineTrace().getKey())) .findFirst(); value.ifPresent(this::removeItem); return value.isPresent(); }
@PostConstruct public void init() { view.init(this); startAction = newActionItemPresenter(); stopAction = newActionItemPresenter(); deleteAction = newActionItemPresenter(); separator = newSeparatorItem(); secondarySeparator = newSeparatorItem(); showErrorAction = newActionItemPresenter(); }
public void setup(final RuntimeListItem runtimeListItem) { this.item = runtimeListItem; clearPipeline(); if (item.isRuntime()) { setupRuntime(runtimeListItem); } else { setupPipelineTrace(runtimeListItem); } view.addExpandedContent(pipelinePresenter.getView()); }
@Test public void testOnOtherPipelineExecutionStopped() { preparePipelineExecutionTraceSetup(); PipelineExecutionTraceKey otherKey = mock(PipelineExecutionTraceKey.class); RuntimeListItem item = new RuntimeListItem(RUNTIME_NAME, trace); presenter.setup(item); presenter.onPipelineExecutionChange(new PipelineExecutionChangeEvent(PipelineExecutionChange.STOPPED, otherKey)); verify(presenter, never()).refresh(any(PipelineExecutionTraceKey.class)); }
@Test public void testOnOtherRuntimeStopped() { prepareRuntime(); RuntimeKey otherKey = mock(RuntimeKey.class); presenter.onRuntimeChangeEvent(new RuntimeChangeEvent(RuntimeChange.STOPPED, otherKey)); verify(presenter, never()).refresh(any(RuntimeKey.class)); }
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); } } }
private RemoteCallback<RuntimeListItem> getLoadItemSuccessCallback() { return runtimeListItem -> { if (runtimeListItem != null) { setup(runtimeListItem); } }; }
@Test public void testRemoveExistingPipelineExecution() { PipelineExecutionTraceKey keyToRemove = mock(PipelineExecutionTraceKey.class); List<RuntimeListItem> items = mockItems(ITEMS_COUNT); //pick an arbitrary element as the existing pipeline execution. int index = 2; RuntimeListItem item = items.get(index); PipelineExecutionTrace pipelineExecutionTrace = mock(PipelineExecutionTrace.class); when(pipelineExecutionTrace.getKey()).thenReturn(keyToRemove); when(item.isRuntime()).thenReturn(false); when(item.getPipelineTrace()).thenReturn(pipelineExecutionTrace); presenter.setupItems(items); for (int i = 0; i < ITEMS_COUNT; i++) { when(runtimePresenters.get(i).getItem()).thenReturn(items.get(i)); } assertTrue(presenter.removeItem(keyToRemove)); verify(runtimePresenterInstance, times(1)).destroy(runtimePresenters.get(index)); verify(view, times(1)).removeListItem(runtimePresenters.get(index).getView()); }
public void onStageStatusChange(@Observes final StageStatusChangeEvent event) { if (isFromCurrentPipeline(event.getPipelineExecutionTraceKey())) { PipelineExecutionTrace trace = item.getPipelineTrace(); Stage currentStage = currentStages.stream(). 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());
/** * 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(); }
public void onPipelineStatusChange(@Observes final PipelineStatusChangeEvent event) { if (isFromCurrentPipeline(event.getPipelineExecutionTraceKey())) { processPipelineStatus(event.getStatus()); if (PipelineStatus.FINISHED.equals(event.getStatus()) && !PipelineStatus.FINISHED.equals(item.getPipelineTrace().getPipelineStatus())) { refresh(event.getPipelineExecutionTraceKey()); } } }
private void removeItem(final RuntimePresenter item) { view.removeListItem(item.getView()); currentItems.remove(item); runtimePresenterInstance.destroy(item); }
protected void forceDeleteRuntime() { confirmAndExecute(translationService.getTranslation(RuntimePresenter_RuntimeConfirmForcedDeleteTitle), translationService.getTranslation(RuntimePresenter_RuntimeConfirmForcedDeleteMessage), () -> { popupHelper.showBusyIndicator(translationService.getTranslation(RuntimePresenter_RuntimeDeletingForcedMessage)); runtimeService.call(getDeleteRuntimeSuccessCallback(), getDefaultErrorCallback(true)).deleteRuntime(item.getRuntime().getKey(), true); } ); }
public void onRuntimeChangeEvent(@Observes final RuntimeChangeEvent event) { if ((event.isStart() || event.isStop()) && isFromCurrentRuntime(event.getRuntimeKey())) { refresh(event.getRuntimeKey()); } }
protected void stopPipeline() { confirmAndExecute(translationService.getTranslation(RuntimePresenter_PipelineExecutionConfirmStopTitle), translationService.getTranslation(RuntimePresenter_PipelineExecutionConfirmStopMessage), () -> { if (item.isRuntime()) { popupHelper.showInformationPopup(translationService.getTranslation(RuntimePresenter_PipelineExecutionAlreadyStoppedMessage)); } else { runtimeService.call(getStopPipelineSuccessCallback(), getDefaultErrorCallback()).stopPipelineExecution(item.getPipelineTrace().getKey()); } }); }
protected void deletePipeline() { confirmAndExecute(translationService.getTranslation(RuntimePresenter_PipelineExecutionConfirmDeleteTitle), translationService.getTranslation(RuntimePresenter_PipelineExecutionConfirmDeleteMessage), () -> runtimeService.call(getDeletePipelineSuccessCallback(), getDefaultErrorCallback()).deletePipelineExecution(item.getPipelineTrace().getKey())); }
protected void deleteRuntime() { confirmAndExecute(translationService.getTranslation(RuntimePresenter_RuntimeConfirmDeleteTitle), translationService.getTranslation(RuntimePresenter_RuntimeConfirmDeleteMessage), () -> { popupHelper.showBusyIndicator(translationService.getTranslation(RuntimePresenter_RuntimeDeletingMessage)); runtimeService.call(getDeleteRuntimeSuccessCallback(), getDeleteRuntimeErrorCallback()).deleteRuntime(item.getRuntime().getKey(), false); } ); }
protected void stopRuntime() { confirmAndExecute(translationService.getTranslation(RuntimePresenter_RuntimeConfirmStopTitle), translationService.getTranslation(RuntimePresenter_RuntimeConfirmStopMessage), () -> { popupHelper.showBusyIndicator(translationService.getTranslation(RuntimePresenter_RuntimeStoppingMessage)); runtimeService.call(getStopRuntimeSuccessCallback(), getDefaultErrorCallback(true)).stopRuntime(item.getRuntime().getKey()); }); }
public void onPipelineExecutionChange(@Observes final PipelineExecutionChangeEvent event) { if (event.isStop() && isFromCurrentPipeline(event.getPipelineExecutionTraceKey())) { refresh(event.getPipelineExecutionTraceKey()); } }