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);
}
Aggregations