Search in sources :

Example 21 with Composite

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());
}
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 22 with Composite

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);
}
Also used : Composite(org.jboss.hal.dmr.Composite) JsIgnore(jsinterop.annotations.JsIgnore)

Example 23 with Composite

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);
}
Also used : Composite(org.jboss.hal.dmr.Composite) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) JsIgnore(jsinterop.annotations.JsIgnore)

Example 24 with Composite

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);
}
Also used : Composite(org.jboss.hal.dmr.Composite) JsIgnore(jsinterop.annotations.JsIgnore)

Example 25 with Composite

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);
}
Also used : Provider(javax.inject.Provider) StatementContext(org.jboss.hal.meta.StatementContext) AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) JsPropertyMap(jsinterop.base.JsPropertyMap) FormItemValidation(org.jboss.hal.ballroom.form.FormItemValidation) Single(rx.Single) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) Message(org.jboss.hal.spi.Message) Metadata(org.jboss.hal.meta.Metadata) Collectors.toSet(java.util.stream.Collectors.toSet) Set(java.util.Set) List(java.util.List) MetadataProcessor(org.jboss.hal.meta.processing.MetadataProcessor) Callback(org.jboss.hal.spi.Callback) StreamSupport.stream(java.util.stream.StreamSupport.stream) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) Footer(org.jboss.hal.spi.Footer) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) ModelNode(org.jboss.hal.dmr.ModelNode) Iterables(com.google.common.collect.Iterables) MessageEvent(org.jboss.hal.spi.MessageEvent) SuccessfulMetadataCallback(org.jboss.hal.meta.processing.SuccessfulMetadataCallback) JsMethod(jsinterop.annotations.JsMethod) JsCallback(org.jboss.hal.ballroom.JsCallback) Inject(javax.inject.Inject) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) Property(org.jboss.hal.dmr.Property) JsHelper(org.jboss.hal.js.JsHelper) Progress(org.jboss.hal.flow.Progress) AddressTemplate(org.jboss.hal.meta.AddressTemplate) JsFunction(jsinterop.annotations.JsFunction) EsParam(org.jboss.hal.spi.EsParam) JsType(jsinterop.annotations.JsType) Nullable(javax.annotation.Nullable) CompositeResult(org.jboss.hal.dmr.CompositeResult) Operation(org.jboss.hal.dmr.Operation) Ids(org.jboss.hal.resources.Ids) EventBus(com.google.web.bindery.event.shared.EventBus) DialogFactory(org.jboss.hal.ballroom.dialog.DialogFactory) Composite(org.jboss.hal.dmr.Composite) JsIgnore(jsinterop.annotations.JsIgnore) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) Collectors.toList(java.util.stream.Collectors.toList) FormItem(org.jboss.hal.ballroom.form.FormItem) Resources(org.jboss.hal.resources.Resources) Collections(java.util.Collections) Form(org.jboss.hal.ballroom.form.Form) Composite(org.jboss.hal.dmr.Composite) Operation(org.jboss.hal.dmr.Operation) JsIgnore(jsinterop.annotations.JsIgnore)

Aggregations

Composite (org.jboss.hal.dmr.Composite)81 Operation (org.jboss.hal.dmr.Operation)53 CompositeResult (org.jboss.hal.dmr.CompositeResult)50 ResourceAddress (org.jboss.hal.dmr.ResourceAddress)43 ModelNode (org.jboss.hal.dmr.ModelNode)39 ArrayList (java.util.ArrayList)25 List (java.util.List)24 Dispatcher (org.jboss.hal.dmr.dispatch.Dispatcher)22 AddressTemplate (org.jboss.hal.meta.AddressTemplate)22 ModelDescriptionConstants (org.jboss.hal.dmr.ModelDescriptionConstants)21 StatementContext (org.jboss.hal.meta.StatementContext)20 Inject (javax.inject.Inject)19 EventBus (com.google.web.bindery.event.shared.EventBus)18 Metadata (org.jboss.hal.meta.Metadata)18 Ids (org.jboss.hal.resources.Ids)17 Resources (org.jboss.hal.resources.Resources)17 Message (org.jboss.hal.spi.Message)17 MessageEvent (org.jboss.hal.spi.MessageEvent)17 Collectors.toList (java.util.stream.Collectors.toList)16 Provider (javax.inject.Provider)16