Search in sources :

Example 1 with DeployContentDialog2

use of org.jboss.hal.client.deployment.dialog.DeployContentDialog2 in project console by hal.

the class ServerGroupDeploymentColumn method addDeploymentFromContentRepository.

private void addDeploymentFromContentRepository() {
    Outcome<FlowContext> outcome = new Outcome<FlowContext>() {

        @Override
        public void onError(FlowContext context, Throwable error) {
            MessageEvent.fire(eventBus, Message.error(resources.messages().loadContentError(), error.getMessage()));
        }

        @Override
        public void onSuccess(FlowContext context) {
            // extract content which is not deployed on statementContext.selectedServerGroup()
            String serverGroup = statementContext.selectedServerGroup();
            List<Content> content = context.pop();
            List<Content> undeployedContentOnSelectedServerGroup = content.stream().filter(c -> !c.isDeployedTo(serverGroup)).collect(toList());
            if (undeployedContentOnSelectedServerGroup.isEmpty()) {
                MessageEvent.fire(eventBus, Message.warning(resources.messages().allContentAlreadyDeployedToServerGroup(serverGroup)));
            } else {
                new DeployContentDialog2(serverGroup, undeployedContentOnSelectedServerGroup, resources, (sg, cnt, enable) -> {
                    List<Operation> operations = cnt.stream().map(c -> {
                        ResourceAddress resourceAddress = new ResourceAddress().add(SERVER_GROUP, serverGroup).add(DEPLOYMENT, c.getName());
                        return new Operation.Builder(resourceAddress, ADD).param(RUNTIME_NAME, c.getRuntimeName()).param(ENABLED, enable).build();
                    }).collect(toList());
                    if (enable) {
                        progress.get().reset();
                        progress.get().tick();
                    }
                    dispatcher.execute(new Composite(operations), (CompositeResult cr) -> {
                        if (enable) {
                            progress.get().finish();
                        }
                        refresh(Ids.serverGroupDeployment(serverGroup, cnt.get(0).getName()));
                        MessageEvent.fire(eventBus, Message.success(resources.messages().contentDeployed2(serverGroup)));
                    });
                }).show();
            }
        }
    };
    series(new FlowContext(progress.get()), new LoadContent(dispatcher)).subscribe(outcome);
}
Also used : LoadContent(org.jboss.hal.client.deployment.DeploymentTasks.LoadContent) Provider(javax.inject.Provider) Environment(org.jboss.hal.config.Environment) Constraint(org.jboss.hal.meta.security.Constraint) ItemActionFactory(org.jboss.hal.core.finder.ItemActionFactory) StatementContext(org.jboss.hal.meta.StatementContext) ItemDisplay(org.jboss.hal.core.finder.ItemDisplay) LoadDeploymentsFromRunningServer(org.jboss.hal.client.deployment.DeploymentTasks.LoadDeploymentsFromRunningServer) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) Icons(org.jboss.hal.resources.Icons) CheckDeployment(org.jboss.hal.client.deployment.DeploymentTasks.CheckDeployment) UploadDeploymentStep(org.jboss.hal.client.deployment.wizard.UploadDeploymentStep) DeployContentDialog2(org.jboss.hal.client.deployment.dialog.DeployContentDialog2) UploadOrReplace(org.jboss.hal.client.deployment.DeploymentTasks.UploadOrReplace) HTMLElement(elemental2.dom.HTMLElement) TopologyTasks.runningServers(org.jboss.hal.core.runtime.TopologyTasks.runningServers) Message(org.jboss.hal.spi.Message) Metadata(org.jboss.hal.meta.Metadata) Places(org.jboss.hal.core.mvp.Places) Names(org.jboss.hal.resources.Names) DeploymentState(org.jboss.hal.client.deployment.wizard.DeploymentState) ServerActions(org.jboss.hal.core.runtime.server.ServerActions) DeploymentContext(org.jboss.hal.client.deployment.wizard.DeploymentContext) CrudOperations(org.jboss.hal.core.CrudOperations) AddUnmanagedDialog(org.jboss.hal.client.deployment.dialog.AddUnmanagedDialog) OK(org.jboss.hal.core.deployment.Deployment.Status.OK) ReadServerGroupDeployments(org.jboss.hal.client.deployment.DeploymentTasks.ReadServerGroupDeployments) NAMES(org.jboss.hal.client.deployment.wizard.DeploymentState.NAMES) List(java.util.List) Status(org.jboss.hal.core.deployment.Deployment.Status) MetadataRegistry(org.jboss.hal.meta.MetadataRegistry) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) CLEAR_SELECTION(org.jboss.hal.core.finder.FinderColumn.RefreshMode.CLEAR_SELECTION) Flow.series(org.jboss.hal.flow.Flow.series) Finder(org.jboss.hal.core.finder.Finder) Footer(org.jboss.hal.spi.Footer) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) ServerGroupDeployment(org.jboss.hal.core.deployment.ServerGroupDeployment) AsyncColumn(org.jboss.hal.spi.AsyncColumn) MessageEvent(org.jboss.hal.spi.MessageEvent) SuccessfulOutcome(org.jboss.hal.core.SuccessfulOutcome) ColumnAction(org.jboss.hal.core.finder.ColumnAction) ItemAction(org.jboss.hal.core.finder.ItemAction) CONTENT_TEMPLATE(org.jboss.hal.client.deployment.ContentColumn.CONTENT_TEMPLATE) AddServerGroupDeployment(org.jboss.hal.client.deployment.DeploymentTasks.AddServerGroupDeployment) FlowContext(org.jboss.hal.flow.FlowContext) Outcome(org.jboss.hal.flow.Outcome) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) Task(org.jboss.hal.flow.Task) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) JsHelper(org.jboss.hal.js.JsHelper) Progress(org.jboss.hal.flow.Progress) AddressTemplate(org.jboss.hal.meta.AddressTemplate) CONTENT_ADDRESS(org.jboss.hal.client.deployment.ContentColumn.CONTENT_ADDRESS) AddUnmanagedDeployment(org.jboss.hal.client.deployment.DeploymentTasks.AddUnmanagedDeployment) UPLOAD(org.jboss.hal.client.deployment.wizard.DeploymentState.UPLOAD) RESTORE_SELECTION(org.jboss.hal.core.finder.FinderColumn.RefreshMode.RESTORE_SELECTION) FinderColumn(org.jboss.hal.core.finder.FinderColumn) ModelNodeHelper.properties(org.jboss.hal.dmr.ModelNodeHelper.properties) ItemsProvider(org.jboss.hal.core.finder.ItemsProvider) ColumnActionFactory(org.jboss.hal.core.finder.ColumnActionFactory) Requires(org.jboss.hal.spi.Requires) CompositeResult(org.jboss.hal.dmr.CompositeResult) Operation(org.jboss.hal.dmr.Operation) NamesStep(org.jboss.hal.client.deployment.wizard.NamesStep) Ids(org.jboss.hal.resources.Ids) Wizard(org.jboss.hal.ballroom.wizard.Wizard) EventBus(com.google.web.bindery.event.shared.EventBus) CSS.pfIcon(org.jboss.hal.resources.CSS.pfIcon) ItemMonitor(org.jboss.hal.core.finder.ItemMonitor) Content(org.jboss.hal.core.deployment.Content) Composite(org.jboss.hal.dmr.Composite) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) Collectors.toList(java.util.stream.Collectors.toList) NameTokens(org.jboss.hal.meta.token.NameTokens) Resources(org.jboss.hal.resources.Resources) SERVER_GROUP_DEPLOYMENT_ADDRESS(org.jboss.hal.client.deployment.ServerGroupDeploymentColumn.SERVER_GROUP_DEPLOYMENT_ADDRESS) LoadContent(org.jboss.hal.client.deployment.DeploymentTasks.LoadContent) Composite(org.jboss.hal.dmr.Composite) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) CompositeResult(org.jboss.hal.dmr.CompositeResult) Operation(org.jboss.hal.dmr.Operation) FlowContext(org.jboss.hal.flow.FlowContext) SuccessfulOutcome(org.jboss.hal.core.SuccessfulOutcome) Outcome(org.jboss.hal.flow.Outcome) LoadContent(org.jboss.hal.client.deployment.DeploymentTasks.LoadContent) Content(org.jboss.hal.core.deployment.Content) DeployContentDialog2(org.jboss.hal.client.deployment.dialog.DeployContentDialog2) List(java.util.List) ArrayList(java.util.ArrayList) Collectors.toList(java.util.stream.Collectors.toList)

Aggregations

SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)1 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 EventBus (com.google.web.bindery.event.shared.EventBus)1 HTMLElement (elemental2.dom.HTMLElement)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Collectors.toList (java.util.stream.Collectors.toList)1 Inject (javax.inject.Inject)1 Provider (javax.inject.Provider)1 Wizard (org.jboss.hal.ballroom.wizard.Wizard)1 CONTENT_ADDRESS (org.jboss.hal.client.deployment.ContentColumn.CONTENT_ADDRESS)1 CONTENT_TEMPLATE (org.jboss.hal.client.deployment.ContentColumn.CONTENT_TEMPLATE)1 AddServerGroupDeployment (org.jboss.hal.client.deployment.DeploymentTasks.AddServerGroupDeployment)1 AddUnmanagedDeployment (org.jboss.hal.client.deployment.DeploymentTasks.AddUnmanagedDeployment)1 CheckDeployment (org.jboss.hal.client.deployment.DeploymentTasks.CheckDeployment)1 LoadContent (org.jboss.hal.client.deployment.DeploymentTasks.LoadContent)1 LoadDeploymentsFromRunningServer (org.jboss.hal.client.deployment.DeploymentTasks.LoadDeploymentsFromRunningServer)1 ReadServerGroupDeployments (org.jboss.hal.client.deployment.DeploymentTasks.ReadServerGroupDeployments)1 UploadOrReplace (org.jboss.hal.client.deployment.DeploymentTasks.UploadOrReplace)1 SERVER_GROUP_DEPLOYMENT_ADDRESS (org.jboss.hal.client.deployment.ServerGroupDeploymentColumn.SERVER_GROUP_DEPLOYMENT_ADDRESS)1