use of org.jboss.hal.meta.StatementContext in project console by hal.
the class ClusteringPresenter method addBridge.
void addBridge(ServerSubResource ssr) {
Metadata metadata = metadataRegistry.lookup(ssr.template);
NameItem nameItem = new NameItem();
Form<ModelNode> form = new ModelNodeForm.Builder<>(Ids.build(ssr.baseId, Ids.ADD), metadata).unboundFormItem(nameItem, 0).fromRequestProperties().include(QUEUE_NAME, DISCOVERY_GROUP, STATIC_CONNECTORS).unsorted().build();
List<AddressTemplate> templates = asList(SELECTED_SERVER_TEMPLATE.append(CONNECTOR + EQ_WILDCARD), SELECTED_SERVER_TEMPLATE.append(IN_VM_CONNECTOR + EQ_WILDCARD), SELECTED_SERVER_TEMPLATE.append(HTTP_CONNECTOR + EQ_WILDCARD), SELECTED_SERVER_TEMPLATE.append(REMOTE_CONNECTOR + EQ_WILDCARD));
form.getFormItem(DISCOVERY_GROUP).registerSuggestHandler(new ReadChildrenAutoComplete(dispatcher, statementContext, SELECTED_SERVER_TEMPLATE.append(DISCOVERY_GROUP + EQ_WILDCARD)));
form.getFormItem(STATIC_CONNECTORS).registerSuggestHandler(new ReadChildrenAutoComplete(dispatcher, statementContext, templates));
new AddResourceDialog(resources.messages().addResourceTitle(ssr.type), form, (name, model) -> {
name = nameItem.getValue();
ResourceAddress address = SELECTED_SERVER_TEMPLATE.append(ssr.resource + "=" + name).resolve(statementContext);
crud.add(ssr.type, name, address, model, (n, a) -> reload());
}).show();
}
use of org.jboss.hal.meta.StatementContext in project console by hal.
the class ConnectionPresenter method addHttpConnector.
void addHttpConnector() {
ServerSubResource ssr = ServerSubResource.HTTP_CONNECTOR;
Metadata metadata = metadataRegistry.lookup(ssr.template);
Form<ModelNode> form = new ModelNodeForm.Builder<>(Ids.build(ssr.baseId, Ids.ADD), metadata).unboundFormItem(new NameItem(), 0).fromRequestProperties().requiredOnly().build();
form.getFormItem(SOCKET_BINDING).registerSuggestHandler(new ReadChildrenAutoComplete(dispatcher, statementContext, AddressTemplate.of("/socket-binding-group=*/socket-binding=*")));
form.getFormItem(ENDPOINT).registerSuggestHandler(new ReadChildrenAutoComplete(dispatcher, statementContext, AddressTemplate.of("/{selected.profile}/subsystem=messaging-activemq/server=*/http-acceptor=*")));
new AddResourceDialog(ssr.type, form, (name, model) -> {
ResourceAddress address = SELECTED_SERVER_TEMPLATE.append(ssr.resource + EQ + name).resolve(statementContext);
crud.add(ssr.type, name, address, model, (n, a) -> reload());
}).show();
}
use of org.jboss.hal.meta.StatementContext in project console by hal.
the class ConnectionPresenter method addPooledConnectionFactory.
void addPooledConnectionFactory(ServerSubResource ssr) {
Metadata metadata = metadataRegistry.lookup(ssr.template);
NameItem nameItem = new NameItem();
Form<ModelNode> form = new ModelNodeForm.Builder<>(Ids.build(ssr.baseId, Ids.ADD), metadata).unboundFormItem(nameItem, 0).fromRequestProperties().include("entries", DISCOVERY_GROUP, CONNECTORS).unsorted().build();
List<AddressTemplate> templates = asList(SELECTED_SERVER_TEMPLATE.append(CONNECTOR + EQ_WILDCARD), SELECTED_SERVER_TEMPLATE.append(IN_VM_CONNECTOR + EQ_WILDCARD), SELECTED_SERVER_TEMPLATE.append(HTTP_CONNECTOR + EQ_WILDCARD), SELECTED_SERVER_TEMPLATE.append(REMOTE_CONNECTOR + EQ_WILDCARD));
form.getFormItem(DISCOVERY_GROUP).registerSuggestHandler(new ReadChildrenAutoComplete(dispatcher, statementContext, SELECTED_SERVER_TEMPLATE.append(DISCOVERY_GROUP + EQ_WILDCARD)));
form.getFormItem(CONNECTORS).registerSuggestHandler(new ReadChildrenAutoComplete(dispatcher, statementContext, templates));
new AddResourceDialog(resources.messages().addResourceTitle(ssr.type), form, (name, model) -> {
name = nameItem.getValue();
ResourceAddress address = SELECTED_SERVER_TEMPLATE.append(ssr.resource + EQ + name).resolve(statementContext);
crud.add(ssr.type, name, address, model, (n, a) -> reload());
}).show();
}
use of org.jboss.hal.meta.StatementContext 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();
}
});
}
use of org.jboss.hal.meta.StatementContext in project console by hal.
the class LoggingProfileView method init.
@PostConstruct
@SuppressWarnings("Duplicates")
void init() {
Constants constants = mbuiContext.resources().constants();
noRootLogger = new EmptyState.Builder(Ids.LOGGING_PROFILE + "-root-logger-empty", constants.noRootLogger()).description(constants.noRootLoggerDescription()).icon(fontAwesome("sitemap")).primaryAction(constants.add(), this::addRootLogger).build();
noRootLogger.element().classList.add(marginTopLarge);
// hack which relies on the element hierarchy given in the template. will break if you change that hierarchy.
rootLoggerForm.element().parentNode.appendChild(noRootLogger.element());
rootLoggerVisibility(false);
// --------------------------- json formatter
AddressTemplate jsonTemplate = LOGGING_PROFILE_TEMPLATE.append(JSON_FORMATTER_TEMPLATE.lastName() + EQ_WILDCARD);
LabelBuilder labelBuilder = new LabelBuilder();
Metadata jsonMetadata = mbuiContext.metadataRegistry().lookup(jsonTemplate);
Metadata jsonKeyOverridesMetadata = jsonMetadata.forComplexAttribute(KEY_OVERRIDES);
String jsonLabel = labelBuilder.label(jsonTemplate.lastName());
jsonFormatterTable = new ModelNodeTable.Builder<NamedNode>(Ids.build(LOGGING_PROFILE, JSON, FORMATTER, TABLE), jsonMetadata).button(constants.add(), table -> crud().add(Ids.build(LOGGING_PROFILE, JSON, FORMATTER, ADD), Names.JSON_FORMATTER, jsonTemplate.replaceWildcards(presenter.getLoggingProfile()), (name, address) -> presenter.reload()), Constraint.executable(jsonTemplate, ADD)).button(constants.remove(), table -> crud().remove(Names.JSON_FORMATTER, table.selectedRow().getName(), jsonTemplate.replaceWildcards(presenter.getLoggingProfile()), () -> presenter.reload()), Constraint.executable(jsonTemplate, REMOVE)).column(NAME, (cell, type, row, meta) -> row.getName()).build();
jsonFormatterForm = new ModelNodeForm.Builder<NamedNode>(Ids.build(LOGGING_PROFILE, JSON, FORMATTER, FORM), jsonMetadata).onSave((form, changedValues) -> mbuiContext.crud().save(jsonLabel, form.getModel().getName(), jsonTemplate.replaceWildcards(presenter.getLoggingProfile()), changedValues, () -> presenter.reload())).prepareReset(form -> mbuiContext.crud().reset(jsonLabel, jsonFormatterTable.selectedRow().getName(), jsonTemplate.replaceWildcards(presenter.getLoggingProfile()), form, jsonMetadata, () -> presenter.reload())).build();
jsonKeyOverridesForm = new ModelNodeForm.Builder<>(Ids.build(LOGGING_PROFILE, FORMATTER, JSON, KEY_OVERRIDES, FORM), jsonKeyOverridesMetadata).singleton(() -> {
StatementContext jsonStatementContext = new SelectionAwareStatementContext(mbuiContext.statementContext(), () -> jsonFormatterTable.hasSelection() ? jsonFormatterTable.selectedRow().getName() : null);
ResourceAddress address = jsonTemplate.resolve(jsonStatementContext, presenter.getLoggingProfile());
return new Operation.Builder(address, READ_ATTRIBUTE_OPERATION).param(NAME, KEY_OVERRIDES).build();
}, () -> presenter.addComplexObject(jsonLabel, jsonFormatterTable.selectedRow().getName(), KEY_OVERRIDES, jsonTemplate.replaceWildcards(presenter.getLoggingProfile()))).onSave((form, changedValues) -> presenter.saveComplexObject(jsonLabel, jsonFormatterTable.selectedRow().getName(), KEY_OVERRIDES, jsonTemplate.replaceWildcards(presenter.getLoggingProfile()), changedValues)).prepareReset(form -> presenter.resetComplexObject(jsonLabel, jsonFormatterTable.selectedRow().getName(), KEY_OVERRIDES, jsonTemplate.replaceWildcards(presenter.getLoggingProfile()), jsonKeyOverridesMetadata, form)).prepareRemove(form -> presenter.removeComplexObject(jsonLabel, jsonFormatterTable.selectedRow().getName(), KEY_OVERRIDES, jsonTemplate.replaceWildcards(presenter.getLoggingProfile()))).build();
Tabs jsonTabs = new Tabs(Ids.build(LOGGING_PROFILE, FORMATTER, JSON, TAB_CONTAINER));
jsonTabs.add(Ids.build(LOGGING_PROFILE, FORMATTER, JSON, ATTRIBUTES, TAB), constants.attributes(), jsonFormatterForm.element());
jsonTabs.add(Ids.build(LOGGING_PROFILE, FORMATTER, JSON, KEY_OVERRIDES, TAB), Names.KEY_OVERRIDES, jsonKeyOverridesForm.element());
HTMLElement jsonSection = section().add(h(1).textContent(Names.JSON_FORMATTER)).add(p().textContent(jsonMetadata.getDescription().getDescription())).add(jsonFormatterTable).add(jsonTabs).element();
registerAttachable(jsonFormatterTable, jsonFormatterForm, jsonKeyOverridesForm);
navigation.insertSecondary("logging-profile-formatter-item", Ids.build(LOGGING_PROFILE, FORMATTER, JSON, Ids.ITEM), null, Names.JSON_FORMATTER, jsonSection);
// --------------------------- xml formatter
AddressTemplate xmlTemplate = LOGGING_PROFILE_TEMPLATE.append(XML_FORMATTER_TEMPLATE.lastName() + EQ_WILDCARD);
Metadata xmlMetadata = mbuiContext.metadataRegistry().lookup(xmlTemplate);
Metadata xmlKeyOverridesMetadata = xmlMetadata.forComplexAttribute(KEY_OVERRIDES);
String xmlLabel = labelBuilder.label(xmlTemplate.lastName());
xmlFormatterTable = new ModelNodeTable.Builder<NamedNode>(Ids.build(LOGGING_PROFILE, XML, FORMATTER, TABLE), xmlMetadata).button(constants.add(), table -> crud().add(Ids.build(LOGGING_PROFILE, XML, FORMATTER, ADD), Names.XML_FORMATTER, xmlTemplate.replaceWildcards(presenter.getLoggingProfile()), (name, address) -> presenter.reload()), Constraint.executable(xmlTemplate, ADD)).button(constants.remove(), table -> crud().remove(Names.XML_FORMATTER, table.selectedRow().getName(), xmlTemplate.replaceWildcards(presenter.getLoggingProfile()), () -> presenter.reload()), Constraint.executable(xmlTemplate, REMOVE)).column(NAME, (cell, type, row, meta) -> row.getName()).build();
xmlFormatterForm = new ModelNodeForm.Builder<NamedNode>(Ids.build(LOGGING_PROFILE, XML, FORMATTER, FORM), xmlMetadata).onSave((form, changedValues) -> mbuiContext.crud().save(xmlLabel, form.getModel().getName(), xmlTemplate.replaceWildcards(presenter.getLoggingProfile()), changedValues, () -> presenter.reload())).prepareReset(form -> mbuiContext.crud().reset(xmlLabel, xmlFormatterTable.selectedRow().getName(), xmlTemplate.replaceWildcards(presenter.getLoggingProfile()), form, xmlMetadata, () -> presenter.reload())).build();
xmlKeyOverridesForm = new ModelNodeForm.Builder<>(Ids.build(LOGGING_PROFILE, FORMATTER, XML, KEY_OVERRIDES, FORM), xmlKeyOverridesMetadata).singleton(() -> {
StatementContext xmlStatementContext = new SelectionAwareStatementContext(mbuiContext.statementContext(), () -> xmlFormatterTable.hasSelection() ? xmlFormatterTable.selectedRow().getName() : null);
ResourceAddress address = xmlTemplate.resolve(xmlStatementContext, presenter.getLoggingProfile());
return new Operation.Builder(address, READ_ATTRIBUTE_OPERATION).param(NAME, KEY_OVERRIDES).build();
}, () -> presenter.addComplexObject(xmlLabel, xmlFormatterTable.selectedRow().getName(), KEY_OVERRIDES, xmlTemplate.replaceWildcards(presenter.getLoggingProfile()))).onSave((form, changedValues) -> presenter.saveComplexObject(xmlLabel, xmlFormatterTable.selectedRow().getName(), KEY_OVERRIDES, xmlTemplate.replaceWildcards(presenter.getLoggingProfile()), changedValues)).prepareReset(form -> presenter.resetComplexObject(xmlLabel, xmlFormatterTable.selectedRow().getName(), KEY_OVERRIDES, xmlTemplate.replaceWildcards(presenter.getLoggingProfile()), xmlKeyOverridesMetadata, form)).prepareRemove(form -> presenter.removeComplexObject(xmlLabel, xmlFormatterTable.selectedRow().getName(), KEY_OVERRIDES, xmlTemplate.replaceWildcards(presenter.getLoggingProfile()))).build();
Tabs xmlTabs = new Tabs(Ids.build(LOGGING_PROFILE, FORMATTER, XML, TAB_CONTAINER));
xmlTabs.add(Ids.build(LOGGING_PROFILE, FORMATTER, XML, ATTRIBUTES, TAB), constants.attributes(), xmlFormatterForm.element());
xmlTabs.add(Ids.build(LOGGING_PROFILE, FORMATTER, XML, KEY_OVERRIDES, TAB), Names.KEY_OVERRIDES, xmlKeyOverridesForm.element());
HTMLElement xmlSection = section().add(h(1).textContent(Names.XML_FORMATTER)).add(p().textContent(xmlMetadata.getDescription().getDescription())).add(xmlFormatterTable).add(xmlTabs).element();
registerAttachable(xmlFormatterTable, xmlFormatterForm, xmlKeyOverridesForm);
navigation.insertSecondary("logging-profile-formatter-item", Ids.build(LOGGING_PROFILE, FORMATTER, XML, Ids.ITEM), null, Names.XML_FORMATTER, xmlSection);
}
Aggregations