Search in sources :

Example 1 with OperationFactory

use of org.jboss.hal.core.OperationFactory in project console by hal.

the class ResourceAdapterView method saveConfiguration.

void saveConfiguration(Form<ModelNode> form, Map<String, Object> changedValues) {
    changedValues.remove(CONFIG_PROPERTIES);
    changedValues.remove(WM_SECURITY_MAPPING_GROUPS);
    changedValues.remove(WM_SECURITY_MAPPING_USERS);
    ResourceAddress address = SELECTED_RESOURCE_ADAPTER_TEMPLATE.resolve(selectionAwareStatementContext);
    OperationFactory operationFactory = new OperationFactory();
    Metadata metadata = mbuiContext.metadataRegistry().lookup(RESOURCE_ADAPTER_TEMPLATE);
    Composite operations = operationFactory.fromChangeSet(address, changedValues, metadata);
    Operation groupMappings = mappingsOperation(address, form, WM_SECURITY_MAPPING_GROUPS);
    if (groupMappings != null) {
        operations.add(groupMappings);
    }
    Operation userMappings = mappingsOperation(address, form, WM_SECURITY_MAPPING_USERS);
    if (userMappings != null) {
        operations.add(userMappings);
    }
    FormItem<Map<String, String>> formItem = form.getFormItem(CONFIG_PROPERTIES);
    Map<String, String> configProperties = formItem != null ? formItem.getValue() : Collections.emptyMap();
    mbuiContext.po().saveWithProperties(Names.RESOURCE_ADAPTER, presenter.getResourceAdapter(), address, operations, CONFIG_PROPERTIES, configProperties, () -> presenter.reload());
}
Also used : Composite(org.jboss.hal.dmr.Composite) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) Metadata(org.jboss.hal.meta.Metadata) Operation(org.jboss.hal.dmr.Operation) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map) OperationFactory(org.jboss.hal.core.OperationFactory)

Example 2 with OperationFactory

use of org.jboss.hal.core.OperationFactory in project console by hal.

the class SocketBindingGroupPresenter method saveClientMapping.

void saveClientMapping(Metadata metadata, ModelNode clientMapping, Map<String, Object> changedValues) {
    ResourceAddress address = SELECTED_TEMPLATE.append(INBOUND.templateSuffix()).resolve(statementContext, inbound);
    OperationFactory operationFactory = new OperationFactory(name -> CLIENT_MAPPINGS + "[" + clientMapping.get(INDEX).asInt() + "]." + name);
    Composite operations = operationFactory.fromChangeSet(address, changedValues, metadata);
    dispatcher.execute(operations, (CompositeResult result) -> {
        MessageEvent.fire(getEventBus(), Message.success(resources.messages().modifySingleResourceSuccess(Names.CLIENT_MAPPING)));
        reloadClientMappings();
    });
}
Also used : Composite(org.jboss.hal.dmr.Composite) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) CompositeResult(org.jboss.hal.dmr.CompositeResult) OperationFactory(org.jboss.hal.core.OperationFactory)

Example 3 with OperationFactory

use of org.jboss.hal.core.OperationFactory in project console by hal.

the class HostPresenter method saveHeader.

@Override
public void saveHeader(int pathIndex, int index, String header, Metadata metadata, Map<String, Object> changedValues, SafeHtml successMessage) {
    ResourceAddress address = HTTP_INTERFACE_TEMPLATE.resolve(statementContext);
    OperationFactory operationFactory = new OperationFactory(name -> constantsHeadersIndex(pathIndex) + DOT + headersIndex(index) + DOT + name);
    Composite composite = operationFactory.fromChangeSet(address, changedValues, metadata);
    dispatcher.execute(composite, (CompositeResult result) -> {
        reloadHeaders(pathIndex);
        MessageEvent.fire(getEventBus(), Message.success(successMessage));
    });
}
Also used : Composite(org.jboss.hal.dmr.Composite) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) CompositeResult(org.jboss.hal.dmr.CompositeResult) OperationFactory(org.jboss.hal.core.OperationFactory)

Example 4 with OperationFactory

use of org.jboss.hal.core.OperationFactory in project console by hal.

the class StandaloneServerPresenter method saveHeader.

@Override
public void saveHeader(int pathIndex, int index, String header, Metadata metadata, Map<String, Object> changedValues, SafeHtml successMessage) {
    ResourceAddress address = HTTP_INTERFACE_TEMPLATE.resolve(statementContext);
    OperationFactory operationFactory = new OperationFactory(name -> constantsHeadersIndex(pathIndex) + DOT + headersIndex(index) + DOT + name);
    Composite composite = operationFactory.fromChangeSet(address, changedValues, metadata);
    dispatcher.execute(composite, (CompositeResult result) -> {
        reloadHeaders(pathIndex);
        MessageEvent.fire(getEventBus(), Message.success(successMessage));
    });
}
Also used : Composite(org.jboss.hal.dmr.Composite) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) CompositeResult(org.jboss.hal.dmr.CompositeResult) OperationFactory(org.jboss.hal.core.OperationFactory)

Aggregations

OperationFactory (org.jboss.hal.core.OperationFactory)4 Composite (org.jboss.hal.dmr.Composite)4 ResourceAddress (org.jboss.hal.dmr.ResourceAddress)4 CompositeResult (org.jboss.hal.dmr.CompositeResult)3 Map (java.util.Map)1 Collectors.toMap (java.util.stream.Collectors.toMap)1 Operation (org.jboss.hal.dmr.Operation)1 Metadata (org.jboss.hal.meta.Metadata)1