Search in sources :

Example 61 with NotEmptyValidation

use of org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation in project ovirt-engine by oVirt.

the class NewDiskModel method validate.

@Override
public boolean validate() {
    if (getDiskStorageType().getEntity() == DiskStorageType.LUN && getSanStorageModelBase() != null) {
        getSanStorageModelBase().validate();
        if (!getSanStorageModelBase().getIsValid()) {
            return false;
        }
        ArrayList<String> partOfSdLunsMessages = getSanStorageModelBase().getPartOfSdLunsMessages();
        if (!partOfSdLunsMessages.isEmpty() && !getSanStorageModelBase().isForce()) {
            forceCreationWarning(partOfSdLunsMessages);
            return false;
        }
    }
    StorageType storageType = getStorageDomain().getSelectedItem() == null ? StorageType.UNKNOWN : getStorageDomain().getSelectedItem().getStorageType();
    IntegerValidation sizeValidation = new IntegerValidation();
    sizeValidation.setMinimum(getMinimumDiskSize());
    if (storageType.isBlockDomain()) {
        sizeValidation.setMaximum((Integer) AsyncDataProvider.getInstance().getConfigValuePreConverted(ConfigValues.MaxBlockDiskSize));
    }
    getSize().validateEntity(new IValidation[] { new NotEmptyValidation(), sizeValidation });
    getStorageDomain().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
    return super.validate() && getSize().getIsValid() && getStorageDomain().getIsValid();
}
Also used : StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) IntegerValidation(org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation)

Example 62 with NotEmptyValidation

use of org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation in project ovirt-engine by oVirt.

the class ImportVmModel method validateName.

private boolean validateName(final ImportVmData data) {
    final int maxNameLength = getMaxNameLength();
    VmImportGeneralModel model = (VmImportGeneralModel) getDetailModels().get(0);
    EntityModel<String> vmName = new EntityModel<>(data.getVm().getName());
    vmName.validateEntity(new IValidation[] { new NotEmptyValidation(), new LengthValidation(maxNameLength), new I18NNameValidation(), new UniqueNameValidator(data), value -> isNameExistsInTheSystem(vmName.getEntity()) ? ValidationResult.fail(ConstantsManager.getInstance().getConstants().nameMustBeUniqueInvalidReason()) : ValidationResult.ok() });
    data.setError(vmName.getIsValid() ? null : ConstantsManager.getInstance().getConstants().invalidName());
    // Updating the 'name' model in general sub-tab
    model.getName().setInvalidityReasons(vmName.getInvalidityReasons());
    model.getName().setIsValid(vmName.getIsValid());
    return vmName.getIsValid();
}
Also used : EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) I18NNameValidation(org.ovirt.engine.ui.uicommonweb.validation.I18NNameValidation)

Example 63 with NotEmptyValidation

use of org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation in project ovirt-engine by oVirt.

the class ImportVmsModel method validateVmwareConfiguration.

private boolean validateVmwareConfiguration() {
    getvCenter().validateEntity(new IValidation[] { new NotEmptyValidation(), new LengthValidation(255), new HostAddressValidation() });
    getEsx().validateEntity(new IValidation[] { new NotEmptyValidation(), new LengthValidation(255), new HostAddressValidation() });
    getVmwareDatacenter().validateEntity(new IValidation[] { new NotEmptyValidation() });
    getUsername().validateEntity(new IValidation[] { new NotEmptyValidation(), new NameAndOptionalDomainValidation() });
    getPassword().validateEntity(new IValidation[] { new NotEmptyValidation() });
    return getvCenter().getIsValid() && getEsx().getIsValid() && getVmwareDatacenter().getIsValid() && getUsername().getIsValid() && getPassword().getIsValid();
}
Also used : NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) HostAddressValidation(org.ovirt.engine.ui.uicommonweb.validation.HostAddressValidation) NameAndOptionalDomainValidation(org.ovirt.engine.ui.uicommonweb.validation.NameAndOptionalDomainValidation) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation)

Example 64 with NotEmptyValidation

use of org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation in project ovirt-engine by oVirt.

the class ImportVmsModel method validateKvmConfiguration.

private boolean validateKvmConfiguration() {
    getKvmUri().validateEntity(new IValidation[] { new NotEmptyValidation(), new LengthValidation(255) });
    getKvmUsername().validateEntity(new IValidation[] { new NotEmptyValidation() });
    getKvmPassword().validateEntity(new IValidation[] { new NotEmptyValidation() });
    return getKvmUri().getIsValid() && getKvmUsername().getIsValid() && getKvmPassword().getIsValid();
}
Also used : NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation)

Example 65 with NotEmptyValidation

use of org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation in project ovirt-engine by oVirt.

the class UnitVmModel method validateNaming.

private boolean validateNaming() {
    getName().validateEntity(new IValidation[] { new NotEmptyValidation(), new LengthValidation(getBehavior().getMaxNameLength()), getBehavior().getNameAllowedCharactersIValidation() });
    getDescription().validateEntity(new IValidation[] { new LengthValidation(DESCRIPTION_MAX_LIMIT), new SpecialAsciiI18NOrNoneValidation() });
    final boolean isValid = getName().getIsValid() && getDescription().getIsValid();
    setValidTab(TabName.GENERAL_TAB, isValidTab(TabName.GENERAL_TAB) && isValid);
    return isValid;
}
Also used : NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) SpecialAsciiI18NOrNoneValidation(org.ovirt.engine.ui.uicommonweb.validation.SpecialAsciiI18NOrNoneValidation) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation)

Aggregations

NotEmptyValidation (org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation)66 LengthValidation (org.ovirt.engine.ui.uicommonweb.validation.LengthValidation)31 IntegerValidation (org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation)21 AsciiNameValidation (org.ovirt.engine.ui.uicommonweb.validation.AsciiNameValidation)11 SpecialAsciiI18NOrNoneValidation (org.ovirt.engine.ui.uicommonweb.validation.SpecialAsciiI18NOrNoneValidation)9 HostAddressValidation (org.ovirt.engine.ui.uicommonweb.validation.HostAddressValidation)7 IValidation (org.ovirt.engine.ui.uicommonweb.validation.IValidation)7 AsciiOrNoneValidation (org.ovirt.engine.ui.uicommonweb.validation.AsciiOrNoneValidation)6 RegexValidation (org.ovirt.engine.ui.uicommonweb.validation.RegexValidation)6 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)4 StorageType (org.ovirt.engine.core.common.businessentities.storage.StorageType)4 I18NNameValidation (org.ovirt.engine.ui.uicommonweb.validation.I18NNameValidation)4 ArrayList (java.util.ArrayList)3 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)3 Arrays (java.util.Arrays)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Set (java.util.Set)2 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)2 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)2