Search in sources :

Example 6 with Metadata

use of org.jboss.hal.meta.Metadata in project console by hal.

the class MailSessionPresenter method launchAddServer.

void launchAddServer() {
    SortedSet<String> availableServers = new TreeSet<>(asList(SMTP.toUpperCase(), IMAP.toUpperCase(), POP3.toUpperCase()));
    ResourceAddress selectedSessionAddress = SELECTED_MAIL_SESSION_TEMPLATE.resolve(statementContext);
    Operation serverNamesOp = new Operation.Builder(selectedSessionAddress, READ_CHILDREN_NAMES_OPERATION).param(CHILD_TYPE, SERVER).build();
    dispatcher.execute(serverNamesOp, serversResult -> {
        Set<String> existingServers = serversResult.asList().stream().map(node -> node.asString().toUpperCase()).collect(toSet());
        availableServers.removeAll(existingServers);
        if (availableServers.isEmpty()) {
            MessageEvent.fire(getEventBus(), Message.error(resources.messages().allMailServersExist()));
        } else {
            FormItem<String> serverTypeItem;
            if (availableServers.size() == 1) {
                serverTypeItem = new TextBoxItem(ModelDescriptionConstants.SERVER_TYPE, resources.constants().type());
                serverTypeItem.setValue(availableServers.first());
                serverTypeItem.setEnabled(false);
            } else {
                serverTypeItem = new SingleSelectBoxItem(ModelDescriptionConstants.SERVER_TYPE, resources.constants().type(), new ArrayList<>(availableServers), false);
                serverTypeItem.setRequired(true);
            }
            Metadata metadata = metadataRegistry.lookup(AddressTemplates.SERVER_TEMPLATE);
            Form<ModelNode> form = new ModelNodeForm.Builder<>(Ids.MAIL_SERVER_DIALOG, metadata).unboundFormItem(serverTypeItem, 0).include(OUTBOUND_SOCKET_BINDING_REF, USERNAME, PASSWORD, "ssl", "tls").fromRequestProperties().requiredOnly().unsorted().build();
            form.getFormItem(OUTBOUND_SOCKET_BINDING_REF).registerSuggestHandler(new ReadChildrenAutoComplete(dispatcher, statementContext, AddressTemplates.SOCKET_BINDING_TEMPLATE));
            AddResourceDialog dialog = new AddResourceDialog(resources.messages().addResourceTitle(Names.SERVER), form, (name, modelNode) -> {
                String serverType = serverTypeItem.getValue().toLowerCase();
                ResourceAddress address = SELECTED_MAIL_SESSION_TEMPLATE.append(SERVER + EQUALS + serverType).resolve(statementContext);
                Operation operation = new Operation.Builder(address, ModelDescriptionConstants.ADD).payload(modelNode).build();
                dispatcher.execute(operation, result -> {
                    MessageEvent.fire(getEventBus(), Message.success(resources.messages().addResourceSuccess(Names.SERVER, serverType)));
                    reload();
                });
            });
            dialog.show();
        }
    });
}
Also used : SupportsExpertMode(org.jboss.hal.core.mvp.SupportsExpertMode) ModelNode(org.jboss.hal.dmr.ModelNode) SortedSet(java.util.SortedSet) StatementContext(org.jboss.hal.meta.StatementContext) MessageEvent(org.jboss.hal.spi.MessageEvent) ProxyPlace(com.gwtplatform.mvp.client.proxy.ProxyPlace) AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) TextBoxItem(org.jboss.hal.ballroom.form.TextBoxItem) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) Message(org.jboss.hal.spi.Message) FinishReset(org.jboss.hal.ballroom.form.Form.FinishReset) HasPresenter(org.jboss.hal.core.mvp.HasPresenter) Metadata(org.jboss.hal.meta.Metadata) Names(org.jboss.hal.resources.Names) Nullable(javax.annotation.Nullable) ApplicationFinderPresenter(org.jboss.hal.core.mvp.ApplicationFinderPresenter) Collectors.toSet(java.util.stream.Collectors.toSet) Requires(org.jboss.hal.spi.Requires) CrudOperations(org.jboss.hal.core.CrudOperations) ProxyCodeSplit(com.gwtplatform.mvp.client.annotations.ProxyCodeSplit) Operation(org.jboss.hal.dmr.Operation) NameToken(com.gwtplatform.mvp.client.annotations.NameToken) Ids(org.jboss.hal.resources.Ids) Set(java.util.Set) FinderPathFactory(org.jboss.hal.core.finder.FinderPathFactory) EventBus(com.google.web.bindery.event.shared.EventBus) SingleSelectBoxItem(org.jboss.hal.ballroom.form.SingleSelectBoxItem) ReadChildrenAutoComplete(org.jboss.hal.ballroom.autocomplete.ReadChildrenAutoComplete) FinderPath(org.jboss.hal.core.finder.FinderPath) PlaceRequest(com.gwtplatform.mvp.shared.proxy.PlaceRequest) AddressTemplates(org.jboss.hal.client.configuration.subsystem.mail.AddressTemplates) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) FormItem(org.jboss.hal.ballroom.form.FormItem) MetadataRegistry(org.jboss.hal.meta.MetadataRegistry) SelectionAwareStatementContext(org.jboss.hal.meta.SelectionAwareStatementContext) NameTokens(org.jboss.hal.meta.token.NameTokens) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) Resources(org.jboss.hal.resources.Resources) HalView(org.jboss.hal.core.mvp.HalView) Finder(org.jboss.hal.core.finder.Finder) NamedNode(org.jboss.hal.dmr.NamedNode) Form(org.jboss.hal.ballroom.form.Form) AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) SingleSelectBoxItem(org.jboss.hal.ballroom.form.SingleSelectBoxItem) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) ArrayList(java.util.ArrayList) Metadata(org.jboss.hal.meta.Metadata) Operation(org.jboss.hal.dmr.Operation) TextBoxItem(org.jboss.hal.ballroom.form.TextBoxItem) TreeSet(java.util.TreeSet) ModelNode(org.jboss.hal.dmr.ModelNode) ReadChildrenAutoComplete(org.jboss.hal.ballroom.autocomplete.ReadChildrenAutoComplete)

Example 7 with Metadata

use of org.jboss.hal.meta.Metadata in project console by hal.

the class RemoteCacheContainerPresenter method addRemoteCluster.

// ------------------------------------------------------ remote cluster
void addRemoteCluster() {
    Metadata metadata = metadataRegistry.lookup(REMOTE_CLUSTER_TEMPLATE);
    AddResourceDialog dialog = new AddResourceDialog(Ids.REMOTE_CLUSTER_ADD, resources.messages().addResourceTitle(Names.REMOTE_CLUSTER), metadata, (name, model) -> crud.add(Names.REMOTE_CLUSTER, name, remoteClusterAddress(name), model, (n, a) -> reload()));
    dialog.show();
}
Also used : AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) SupportsExpertMode(org.jboss.hal.core.mvp.SupportsExpertMode) ModelNode(org.jboss.hal.dmr.ModelNode) AddressTemplates(org.jboss.hal.client.configuration.subsystem.infinispan.AddressTemplates) StatementContext(org.jboss.hal.meta.StatementContext) MessageEvent(org.jboss.hal.spi.MessageEvent) ProxyPlace(com.gwtplatform.mvp.client.proxy.ProxyPlace) AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) Inject(javax.inject.Inject) Map(java.util.Map) Message(org.jboss.hal.spi.Message) FinishReset(org.jboss.hal.ballroom.form.Form.FinishReset) HasPresenter(org.jboss.hal.core.mvp.HasPresenter) Metadata(org.jboss.hal.meta.Metadata) INVALIDATION(org.jboss.hal.client.configuration.subsystem.infinispan.NearCache.INVALIDATION) Names(org.jboss.hal.resources.Names) ApplicationFinderPresenter(org.jboss.hal.core.mvp.ApplicationFinderPresenter) Requires(org.jboss.hal.spi.Requires) CrudOperations(org.jboss.hal.core.CrudOperations) ProxyCodeSplit(com.gwtplatform.mvp.client.annotations.ProxyCodeSplit) Operation(org.jboss.hal.dmr.Operation) NameToken(com.gwtplatform.mvp.client.annotations.NameToken) Ids(org.jboss.hal.resources.Ids) FinderPathFactory(org.jboss.hal.core.finder.FinderPathFactory) EventBus(com.google.web.bindery.event.shared.EventBus) FinderPath(org.jboss.hal.core.finder.FinderPath) PlaceRequest(com.gwtplatform.mvp.shared.proxy.PlaceRequest) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) MetadataRegistry(org.jboss.hal.meta.MetadataRegistry) SelectionAwareStatementContext(org.jboss.hal.meta.SelectionAwareStatementContext) NameTokens(org.jboss.hal.meta.token.NameTokens) Resources(org.jboss.hal.resources.Resources) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) HalView(org.jboss.hal.core.mvp.HalView) Finder(org.jboss.hal.core.finder.Finder) Form(org.jboss.hal.ballroom.form.Form) Metadata(org.jboss.hal.meta.Metadata)

Example 8 with Metadata

use of org.jboss.hal.meta.Metadata in project console by hal.

the class RemoteCacheContainerPresenter method resetInvalidationNearCache.

void resetInvalidationNearCache(Form<ModelNode> form) {
    Metadata metadata = metadataRegistry.lookup(REMOTE_CACHE_CONTAINER_TEMPLATE.append("near-cache=invalidation"));
    crud.resetSingleton(Names.INVALIDATION, nearCacheAddress(INVALIDATION), form, metadata, this::reload);
}
Also used : Metadata(org.jboss.hal.meta.Metadata)

Example 9 with Metadata

use of org.jboss.hal.meta.Metadata in project console by hal.

the class RemoteCacheContainerPresenter method resetRemoteCacheContainer.

void resetRemoteCacheContainer(Form<ModelNode> form) {
    ResourceAddress address = SELECTED_REMOTE_CACHE_CONTAINER_TEMPLATE.resolve(statementContext);
    Metadata metadata = metadataRegistry.lookup(REMOTE_CACHE_CONTAINER_TEMPLATE);
    crud.reset(Names.REMOTE_CACHE_CONTAINER, remoteCacheContainer, address, form, metadata, new FinishReset<ModelNode>(form) {

        @Override
        public void afterReset(Form<ModelNode> form) {
            reload();
        }
    });
}
Also used : ResourceAddress(org.jboss.hal.dmr.ResourceAddress) Metadata(org.jboss.hal.meta.Metadata) ModelNode(org.jboss.hal.dmr.ModelNode)

Example 10 with Metadata

use of org.jboss.hal.meta.Metadata in project console by hal.

the class RemoteCacheContainerPresenter method saveRemoteCluster.

void saveRemoteCluster(String name, Map<String, Object> changedValues) {
    Metadata metadata = metadataRegistry.lookup(REMOTE_CLUSTER_TEMPLATE);
    crud.save(Names.REMOTE_CLUSTER, name, remoteClusterAddress(name), changedValues, metadata, this::reload);
}
Also used : Metadata(org.jboss.hal.meta.Metadata)

Aggregations

Metadata (org.jboss.hal.meta.Metadata)281 ResourceAddress (org.jboss.hal.dmr.ResourceAddress)146 ModelNode (org.jboss.hal.dmr.ModelNode)128 ModelNodeForm (org.jboss.hal.core.mbui.form.ModelNodeForm)95 AddResourceDialog (org.jboss.hal.core.mbui.dialog.AddResourceDialog)80 NamedNode (org.jboss.hal.dmr.NamedNode)73 Ids (org.jboss.hal.resources.Ids)70 Form (org.jboss.hal.ballroom.form.Form)68 Names (org.jboss.hal.resources.Names)67 ModelDescriptionConstants (org.jboss.hal.dmr.ModelDescriptionConstants)63 Resources (org.jboss.hal.resources.Resources)60 List (java.util.List)59 Operation (org.jboss.hal.dmr.Operation)59 AddressTemplate (org.jboss.hal.meta.AddressTemplate)59 Inject (javax.inject.Inject)52 Map (java.util.Map)51 StatementContext (org.jboss.hal.meta.StatementContext)51 Dispatcher (org.jboss.hal.dmr.dispatch.Dispatcher)50 EventBus (com.google.web.bindery.event.shared.EventBus)49 MetadataRegistry (org.jboss.hal.meta.MetadataRegistry)46