Search in sources :

Example 1 with UPLOAD

use of org.jboss.hal.client.patching.wizard.PatchState.UPLOAD in project console by hal.

the class ApplyPatchWizard method show.

public void show() {
    Messages messages = resources.messages();
    Wizard.Builder<PatchContext, PatchState> wb = new Wizard.Builder<>(messages.addResourceTitle(Names.PATCH), new PatchContext());
    checkServersState(servers -> {
        if (servers != null) {
            wb.addStep(CHECK_SERVERS, new CheckRunningServersStep(resources, servers, statementContext.selectedHost()));
        }
        wb.addStep(UPLOAD, new UploadPatchStep(resources)).addStep(CONFIGURE, new ConfigurationStep(metadata, resources)).onBack((context, currentState) -> {
            PatchState previous = null;
            switch(currentState) {
                case CHECK_SERVERS:
                    break;
                case UPLOAD:
                    previous = CHECK_SERVERS;
                    break;
                case CONFIGURE:
                    previous = UPLOAD;
                    break;
                default:
                    break;
            }
            return previous;
        }).onNext((context, currentState) -> {
            PatchState next = null;
            switch(currentState) {
                case CHECK_SERVERS:
                    next = UPLOAD;
                    break;
                case UPLOAD:
                    next = CONFIGURE;
                    break;
                case CONFIGURE:
                    break;
                default:
                    break;
            }
            return next;
        }).stayOpenAfterFinish().onFinish((wzd, context) -> {
            String name = context.file.name;
            wzd.showProgress(resources.constants().patchInProgress(), messages.patchInProgress(name));
            series(new FlowContext(progress.get()), new UploadPatch(statementContext, dispatcher, serverActions, context)).subscribe(new Outcome<FlowContext>() {

                @Override
                public void onError(FlowContext flowContext, Throwable error) {
                    wzd.showError(resources.constants().patchError(), messages.patchAddError(name, error.getMessage()), error.getMessage());
                }

                @Override
                public void onSuccess(FlowContext context) {
                    callback.execute();
                    wzd.showSuccess(resources.constants().patchSuccessful(), messages.patchSucessfullyApplied(name), messages.view(Names.PATCH), cxt -> {
                    /* nothing to do, content is already selected */
                    });
                }
            });
        });
        Wizard<PatchContext, PatchState> wizard = wb.build();
        wizard.show();
    });
}
Also used : Completable(rx.Completable) Provider(javax.inject.Provider) Environment(org.jboss.hal.config.Environment) StatementContext(org.jboss.hal.meta.StatementContext) Messages(org.jboss.hal.resources.Messages) UPLOAD(org.jboss.hal.client.patching.wizard.PatchState.UPLOAD) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) FlowContext(org.jboss.hal.flow.FlowContext) Outcome(org.jboss.hal.flow.Outcome) Property(org.jboss.hal.dmr.Property) Task(org.jboss.hal.flow.Task) Progress(org.jboss.hal.flow.Progress) PATCHING_TEMPLATE(org.jboss.hal.client.patching.PatchesColumn.PATCHING_TEMPLATE) Server(org.jboss.hal.core.runtime.server.Server) Metadata(org.jboss.hal.meta.Metadata) Names(org.jboss.hal.resources.Names) ServerActions(org.jboss.hal.core.runtime.server.ServerActions) Operation(org.jboss.hal.dmr.Operation) CONFIGURE(org.jboss.hal.client.patching.wizard.PatchState.CONFIGURE) Wizard(org.jboss.hal.ballroom.wizard.Wizard) CHECK_SERVERS(org.jboss.hal.client.patching.wizard.PatchState.CHECK_SERVERS) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) Callback(org.jboss.hal.spi.Callback) Resources(org.jboss.hal.resources.Resources) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) Flow.series(org.jboss.hal.flow.Flow.series) Messages(org.jboss.hal.resources.Messages) FlowContext(org.jboss.hal.flow.FlowContext) Wizard(org.jboss.hal.ballroom.wizard.Wizard)

Aggregations

Provider (javax.inject.Provider)1 Wizard (org.jboss.hal.ballroom.wizard.Wizard)1 PATCHING_TEMPLATE (org.jboss.hal.client.patching.PatchesColumn.PATCHING_TEMPLATE)1 CHECK_SERVERS (org.jboss.hal.client.patching.wizard.PatchState.CHECK_SERVERS)1 CONFIGURE (org.jboss.hal.client.patching.wizard.PatchState.CONFIGURE)1 UPLOAD (org.jboss.hal.client.patching.wizard.PatchState.UPLOAD)1 Environment (org.jboss.hal.config.Environment)1 Server (org.jboss.hal.core.runtime.server.Server)1 ServerActions (org.jboss.hal.core.runtime.server.ServerActions)1 ModelDescriptionConstants (org.jboss.hal.dmr.ModelDescriptionConstants)1 Operation (org.jboss.hal.dmr.Operation)1 Property (org.jboss.hal.dmr.Property)1 ResourceAddress (org.jboss.hal.dmr.ResourceAddress)1 Dispatcher (org.jboss.hal.dmr.dispatch.Dispatcher)1 Flow.series (org.jboss.hal.flow.Flow.series)1 FlowContext (org.jboss.hal.flow.FlowContext)1 Outcome (org.jboss.hal.flow.Outcome)1 Progress (org.jboss.hal.flow.Progress)1 Task (org.jboss.hal.flow.Task)1 Metadata (org.jboss.hal.meta.Metadata)1