Search in sources :

Example 66 with NotEmptyValidation

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

the class RunOnceModel method validate.

public boolean validate() {
    getIsoImage().setIsValid(true);
    if (getAttachIso().getEntity()) {
        getIsoImage().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
    }
    getFloppyImage().setIsValid(true);
    if (getAttachFloppy().getEntity()) {
        getFloppyImage().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
    }
    boolean customPropertyValidation = getCustomPropertySheet().validate();
    if (getIsLinuxOS()) {
        getKernelImage().validateSelectedItem(new IValidation[] { new NoTrimmingWhitespacesValidation() });
        getInitrdImage().validateSelectedItem(new IValidation[] { new NoTrimmingWhitespacesValidation() });
        getKernelParameters().validateEntity(new IValidation[] { new NoTrimmingWhitespacesValidation() });
        // initrd path and kernel params require kernel path to be filled
        if (StringHelper.isNullOrEmpty(getKernelImage().getSelectedItem())) {
            final UIConstants constants = ConstantsManager.getInstance().getConstants();
            if (!StringHelper.isNullOrEmpty(getInitrdImage().getSelectedItem())) {
                getInitrdImage().getInvalidityReasons().add(constants.initrdPathInvalid());
                getInitrdImage().setIsValid(false);
                getKernelImage().getInvalidityReasons().add(constants.initrdPathInvalid());
                getKernelImage().setIsValid(false);
            }
            if (!StringHelper.isNullOrEmpty(getKernelParameters().getEntity())) {
                getKernelParameters().getInvalidityReasons().add(constants.kernelParamsInvalid());
                getKernelParameters().setIsValid(false);
                getKernelImage().getInvalidityReasons().add(constants.kernelParamsInvalid());
                getKernelImage().setIsValid(false);
            }
        }
    }
    if (getIsAutoAssign().getEntity() != null && !getIsAutoAssign().getEntity()) {
        getDefaultHost().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
    } else {
        getDefaultHost().setIsValid(true);
    }
    getSysPrepPassword().setIsValid(true);
    getSysPrepPasswordVerification().setIsValid(true);
    if (getIsWindowsOS() && getIsSysprepEnabled().getEntity()) {
        getSysPrepPassword().validateEntity(new IValidation[] { new NotEmptyValidation(), new MatchFieldsValidator(getSysPrepPassword().getEntity(), getSysPrepPasswordVerification().getEntity()) });
    }
    boolean cloudInitIsValid = getVmInitModel().validate();
    getEmulatedMachine().validateSelectedItem(new IValidation[] { new I18NExtraNameOrNoneValidation(), new LengthValidation(BusinessEntitiesDefinitions.VM_EMULATED_MACHINE_SIZE) });
    getCustomCpu().validateSelectedItem(new IValidation[] { new I18NExtraNameOrNoneValidation(), new LengthValidation(BusinessEntitiesDefinitions.VM_CPU_NAME_SIZE) });
    return getIsoImage().getIsValid() && getFloppyImage().getIsValid() && getKernelImage().getIsValid() && getInitrdImage().getIsValid() && getKernelParameters().getIsValid() && getDefaultHost().getIsValid() && customPropertyValidation && cloudInitIsValid && getSysPrepPassword().getIsValid() && getEmulatedMachine().getIsValid() && getCustomCpu().getIsValid();
}
Also used : NoTrimmingWhitespacesValidation(org.ovirt.engine.ui.uicommonweb.validation.NoTrimmingWhitespacesValidation) MatchFieldsValidator(org.ovirt.engine.ui.uicommonweb.validation.MatchFieldsValidator) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) I18NExtraNameOrNoneValidation(org.ovirt.engine.ui.uicommonweb.validation.I18NExtraNameOrNoneValidation) 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