use of org.jboss.hal.dmr.Composite 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());
}
use of org.jboss.hal.dmr.Composite in project console by hal.
the class ComplexAttributeOperations method save.
/**
* Writes the changed values to the list-type complex attribute. After the complex attribute has been saved a standard
* success message is fired and the specified callback is executed.
* <p>
* If the change set is empty, a warning message is fired and the specified callback is executed.
*
* @param complexAttribute the name of the complex attribute
* @param type the human readable name of the complex attribute
* @param index the index for the list-type complex attribute
* @param address the fq address for the operation
* @param changedValues the changed values / payload for the operation
* @param metadata the metadata for the complex attribute
* @param callback the callback executed after the resource has been saved
*/
@JsIgnore
public void save(String complexAttribute, String type, int index, ResourceAddress address, Map<String, Object> changedValues, Metadata metadata, Callback callback) {
Composite operations = operationFactory(complexAttribute, index).fromChangeSet(address, changedValues, metadata);
crud.save(operations, resources.messages().modifySingleResourceSuccess(type), callback);
}
use of org.jboss.hal.dmr.Composite in project console by hal.
the class ComplexAttributeOperations method reset.
/**
* Undefines all non required attributes in the specified form. After the attributes in the complex attribute have been
* undefined a standard success message is fired and the specified callback is executed.
* <p>
* If the form contains only required attributes, a warning message is fired and the specified callback is executed.
*
* @param resource the resource name
* @param complexAttribute the name of the complex attribute
* @param type the human readable name of the complex attribute
* @param template the address template which is resolved against the current statement context and the resource name to get
* the resource address for the operation
* @param form the form which should be reset
* @param callback the callback executed after the resource has been saved
*/
@JsIgnore
public <T> void reset(String resource, String complexAttribute, String type, AddressTemplate template, Metadata metadata, Form<T> form, Callback callback) {
Set<String> attributes = stream(form.getBoundFormItems().spliterator(), false).map(FormItem::getName).collect(toSet());
ResourceAddress address = template.resolve(statementContext, resource);
Composite composite = operationFactory(complexAttribute).resetResource(address, attributes, metadata);
reset(type, composite, callback);
}
use of org.jboss.hal.dmr.Composite in project console by hal.
the class CrudOperations method save.
// ------------------------------------------------------ (u)pdate using address
/**
* Writes the changed values to the specified resource. After the resource has been saved a standard success message is
* fired and the specified callback is executed.
* <p>
* If the change set is empty, a warning message is fired and the specified callback is executed.
*
* @param type the human readable resource type used in the success message
* @param name the resource name
* @param address the fq address for the operation
* @param changedValues the changed values / payload for the operation
* @param metadata the metadata of the attributes in the change set
* @param callback the callback executed after the resource has been saved
*/
@JsIgnore
public void save(String type, String name, ResourceAddress address, Map<String, Object> changedValues, Metadata metadata, Callback callback) {
Composite operations = operationFactory.fromChangeSet(address, changedValues, metadata);
save(operations, resources.messages().modifyResourceSuccess(type, name), callback);
}
use of org.jboss.hal.dmr.Composite in project console by hal.
the class CrudOperations method readChildren.
/**
* Read multiple different child resources using a composite operation. The steps in the composite result map to the
* position of the resource in the {@code resources} collection.
*
* @param address the fq address for the {@code read-children-resource} operation
* @param resources the child resources (not human readable, but the actual child resource name!)
* @param callback the callback which gets the composite result
*/
@JsIgnore
public void readChildren(ResourceAddress address, Iterable<String> resources, ReadCompositeCallback callback) {
List<Operation> operations = stream(resources.spliterator(), false).map(resource -> new Operation.Builder(address, READ_CHILDREN_RESOURCES_OPERATION).param(CHILD_TYPE, resource).build()).collect(toList());
dispatcher.execute(new Composite(operations), callback::execute);
}
Aggregations