org.jboss.as.console.client.shared.general.validation.NicValidation Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of switchyard-console-as7-core
Show all versions of switchyard-console-as7-core
Bundles the core AS7 console as a GWT module. Includes minor customizations to support extensions.
package org.jboss.as.console.client.shared.general.validation;
import org.jboss.as.console.client.Console;
import org.jboss.as.console.client.shared.general.model.Interface;
import java.util.Map;
import java.util.Set;
/**
* Validates the nic constraints
*
* @author Heiko Braun
* @date 11/15/11
*/
class NicValidation extends AbstractValidationStep {
private static final String NIC = "nic";
private static final String NIC_MATCH = "nicMatch";
@Override
public boolean doesApplyTo(Interface entity, Map changedValues) {
Map clean = clearChangeset(changedValues);
boolean hasSetValues = isSet(entity.getNic()) || isSet(entity.getNicMatch());
boolean relevantChanges = false;
Set keys = clean.keySet();
for(String key : keys)
{
if(key.equals(NIC) || key.equals(NIC_MATCH))
{
relevantChanges = true;
break;
}
}
return hasSetValues || relevantChanges;
}
@Override
protected DecisionTree buildDecisionTree(Interface entity, Map changedValues) {
final Map changeset = clearChangeset(changedValues);
final DecisionTree tree = new DecisionTree(entity);
// INET ADDRESS
tree.createRoot(1,"Is Nic name set?", new Decision() {
@Override
public boolean evaluate(Interface entity) {
return isSet(entity.getNic());
}
});
tree.yes(1, 2, "Anything conflicts with Nic name?", new Decision() {
@Override
public boolean evaluate(Interface entity) {
Map properties = asProperties(entity);
properties.remove(NIC);
return !isEmpty(properties);
}
});
tree.no(1, 3, "Is Nic Match set?", new Decision() {
@Override
public boolean evaluate(Interface entity) {
return isSet(entity.getNicMatch());
}
});
tree.no(2, 4, "Success: Nic", SUCCESS);
tree.yes(2, 5, Console.CONSTANTS.interfaces_err_nic_set(), FAILURE);
tree.yes(3, 6, "Anything conflicts with Nic Match?", new Decision() {
@Override
public boolean evaluate(Interface entity) {
Map properties = asProperties(entity);
properties.remove(NIC_MATCH);
return !isEmpty(properties);
}
});
tree.no(3, 7, "Failure: Neither Nic nor Nic Match set", FAILURE);
tree.yes(6, 8, Console.CONSTANTS.interfaces_err_nicmatch_set(), FAILURE);
tree.no(6, 9, "Success: Nic Match", SUCCESS);
return tree;
}
}