Search in sources :

Example 1 with ValidationResult

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);
}
Also used : RegexValidation(org.ovirt.engine.ui.uicommonweb.validation.RegexValidation) ValidationResult(org.ovirt.engine.ui.uicommonweb.validation.ValidationResult)

Example 2 with ValidationResult

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();
}
Also used : StorageFormatType(org.ovirt.engine.core.common.businessentities.StorageFormatType) ValidationResult(org.ovirt.engine.ui.uicommonweb.validation.ValidationResult)

Example 3 with ValidationResult

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());
}
Also used : NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) ValidationResult(org.ovirt.engine.ui.uicommonweb.validation.ValidationResult)

Aggregations

ValidationResult (org.ovirt.engine.ui.uicommonweb.validation.ValidationResult)3 StorageFormatType (org.ovirt.engine.core.common.businessentities.StorageFormatType)1 NotEmptyValidation (org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation)1 RegexValidation (org.ovirt.engine.ui.uicommonweb.validation.RegexValidation)1