use of jsinterop.annotations.JsIgnore in project console by hal.
the class ModelNodeHelper method asEnumValue.
@JsIgnore
public static <E extends Enum<E>> E asEnumValue(ModelNode modelNode, Function<String, E> valueOf, E defaultValue) {
E value = defaultValue;
String converted = LOWER_HYPHEN.to(UPPER_UNDERSCORE, modelNode.asString());
try {
value = valueOf.apply(converted);
} catch (IllegalArgumentException ignored) {
}
return value;
}
use of jsinterop.annotations.JsIgnore in project console by hal.
the class Metadata method forOperation.
@JsIgnore
public Metadata forOperation(String name) {
ModelNode payload = new ModelNode();
payload.get(DESCRIPTION).set(failSafeGet(description, OPERATIONS + "/" + name + "/" + DESCRIPTION));
payload.get(ATTRIBUTES).set(failSafeGet(description, OPERATIONS + "/" + name + "/" + REQUEST_PROPERTIES));
SecurityContext parentContext = this.securityContext.get();
SecurityContext operationContext = new SecurityContext(new ModelNode()) {
@Override
public boolean isReadable() {
return parentContext.isExecutable(name);
}
@Override
public boolean isWritable() {
return parentContext.isExecutable(name);
}
@Override
public boolean isReadable(String attribute) {
// if the operation is executable all of its request properties are readable as well
return isReadable();
}
@Override
public boolean isWritable(String attribute) {
// if the operation is executable all of its request properties are writable as well
return isWritable();
}
@Override
public boolean isExecutable(String operation) {
return parentContext.isExecutable(operation);
}
};
return new Metadata(template, () -> operationContext, new ResourceDescription(payload), capabilities);
}
use of jsinterop.annotations.JsIgnore in project console by hal.
the class Metadata method forComplexAttribute.
/**
* Creates a new metadata instance based on this metadata with the attributes taken from the specified complex attribute.
* The resource description will only include the attributes but no operations!
*
* @param prefixLabel if {@code true} the labels of the attributes of the complex attribute are prefixed with name of the
* complex attribute.
*/
@JsIgnore
public Metadata forComplexAttribute(String name, boolean prefixLabel) {
ModelNode payload = new ModelNode();
payload.get(DESCRIPTION).set(failSafeGet(description, ATTRIBUTES + "/" + name + "/" + DESCRIPTION));
payload.get(REQUIRED).set(failSafeGet(description, ATTRIBUTES + "/" + name + "/" + REQUIRED));
payload.get(NILLABLE).set(failSafeGet(description, ATTRIBUTES + "/" + name + "/" + NILLABLE));
Property complexAttribute = description.findAttribute(ATTRIBUTES, name);
if (complexAttribute != null && complexAttribute.getValue().hasDefined(VALUE_TYPE)) {
complexAttribute.getValue().get(VALUE_TYPE).asPropertyList().forEach(nestedProperty -> {
// The nested name is *always* just the nested property name,
// since it's used when building the DMR operations
String nestedName = nestedProperty.getName();
ModelNode nestedDescription = nestedProperty.getValue();
// up by LabelBuilder.label(Property)
if (prefixLabel) {
nestedDescription.get(HAL_LABEL).set(name + "-" + nestedProperty.getName());
}
payload.get(ATTRIBUTES).get(nestedName).set(nestedDescription);
});
}
SecurityContext parentContext = this.securityContext.get();
SecurityContext attributeContext = new SecurityContext(new ModelNode()) {
@Override
public boolean isReadable() {
return parentContext.isReadable(name);
}
@Override
public boolean isWritable() {
return parentContext.isWritable(name);
}
@Override
public boolean isReadable(String attribute) {
// if the complex attribute is readable all nested attributes are readable as well
return isReadable();
}
@Override
public boolean isWritable(String attribute) {
// if the complex attribute is writable all nested attributes are writable as well
return isWritable();
}
@Override
public boolean isExecutable(String operation) {
return parentContext.isExecutable(operation);
}
};
return new Metadata(template, () -> attributeContext, new ResourceDescription(payload), capabilities);
}
use of jsinterop.annotations.JsIgnore in project console by hal.
the class ComplexAttributeOperations method add.
// ------------------------------------------------------ (c)reate operation
/**
* Writes the payload to the complex attribute in the specified resource. After the resource has been updated, a success
* 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 payload the optional payload for the complex attribute (may be null or undefined)
* @param callback the callback executed after the resource has been added
*/
@JsIgnore
public void add(String resource, String complexAttribute, String type, AddressTemplate template, @Nullable ModelNode payload, Callback callback) {
ResourceAddress address = template.resolve(statementContext, resource);
add(complexAttribute, type, address, payload, callback);
}
use of jsinterop.annotations.JsIgnore 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);
}
Aggregations