use of org.ovirt.engine.ui.uicommonweb.validation.ValidationResult in project ovirt-engine by oVirt.
the class KeyValueModel method setKeyValueString.
public void setKeyValueString(List<String> lines) {
if (lines == null) {
return;
}
allKeyValueMap = new HashMap<>();
allRegExKeys = new HashMap<>();
RegexValidation regexValidation = new RegexValidation();
// $NON-NLS-1$
regexValidation.setExpression("\\^\\((([a-zA-Z0-9_]+[|]+)*)[a-zA-Z0-9_]+\\)\\$");
String[] splitLine;
for (String line : lines) {
if (line.isEmpty()) {
continue;
}
splitLine = line.split(KEY_VALUE_DELIMETER, 2);
String key = splitLine[0];
allKeyValueMap.put(key, splitLine[1]);
ValidationResult valid = regexValidation.validate(allKeyValueMap.get(key));
if (valid.getSuccess()) {
String[] values = allKeyValueMap.get(key).substring(2, allKeyValueMap.get(key).length() - 2).split(// $NON-NLS-1$
"\\|");
allRegExKeys.put(key, Arrays.asList(values));
}
}
deserialize(saveEntity);
}
use of org.ovirt.engine.ui.uicommonweb.validation.ValidationResult in project ovirt-engine by oVirt.
the class UploadImageModel method validate.
public boolean validate() {
boolean uploadImageIsValid;
setIsValid(true);
getInvalidityReasons().clear();
getImageInfoModel().getInvalidityReasons().clear();
if (getImageSourceLocalEnabled().getEntity()) {
getImagePath().validateEntity(new IValidation[] { value -> {
ValidationResult result = new ValidationResult();
if (value == null || StringHelper.isNullOrEmpty((String) value)) {
result.setSuccess(false);
result.getReasons().add(constants.emptyImagePath());
}
return result;
} });
StorageFormatType storageFormatType = getDiskModel().getStorageDomain().getSelectedItem().getStorageFormat();
uploadImageIsValid = getImagePath().getIsValid() && getImageInfoModel().validate(storageFormatType, getImageSize());
getInvalidityReasons().addAll(getImagePath().getInvalidityReasons());
getInvalidityReasons().addAll(getImageInfoModel().getInvalidityReasons());
} else {
// TODO remote/download
uploadImageIsValid = false;
}
return uploadImageIsValid && diskModel.validate();
}
use of org.ovirt.engine.ui.uicommonweb.validation.ValidationResult in project ovirt-engine by oVirt.
the class StorageModel method validateListItems.
private void validateListItems(ListModel<?> listModel) {
ValidationResult result = new NotEmptyValidation().validate(listModel.getSelectedItem());
listModel.setIsValid(result.getSuccess());
listModel.getInvalidityReasons().addAll(result.getReasons());
}
Aggregations