Search in sources :

Example 31 with NotEmptyValidation

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

the class UnitVmModel method validate.

public boolean validate(boolean templateWithVersionRequired) {
    resetTabsValidity();
    getInstanceTypes().setIsValid(true);
    getInstanceTypes().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
    getDataCenterWithClustersList().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
    getOSType().validateSelectedItem(new NotEmptyValidation[] { new NotEmptyValidation() });
    DataCenterWithCluster dataCenterWithCluster = getDataCenterWithClustersList().getSelectedItem();
    StoragePool dataCenter = dataCenterWithCluster == null ? null : dataCenterWithCluster.getDataCenter();
    if (dataCenter != null && dataCenter.getQuotaEnforcementType() == QuotaEnforcementTypeEnum.HARD_ENFORCEMENT) {
        getQuota().validateSelectedItem(new IValidation[] { new NotEmptyQuotaValidation() });
    }
    if (getOSType().getIsValid()) {
        validateNaming();
        getVmId().setIsValid(true);
        if (getVmId().getIsAvailable() && !StringHelper.isNullOrEmpty(getVmId().getEntity())) {
            getVmId().validateEntity(new IValidation[] { new GuidValidation() });
        }
        getComment().validateEntity(new IValidation[] { new SpecialAsciiI18NOrNoneValidation() });
        setValidTab(TabName.GENERAL_TAB, isValidTab(TabName.GENERAL_TAB) && getVmId().getIsValid() && getComment().getIsValid());
    }
    if (templateWithVersionRequired) {
        getTemplateWithVersion().validateSelectedItem(new IValidation[] { new NotEmptyValidation(), createEachDiskAHasStorageDomainValidation() });
    }
    getDisksAllocationModel().validateEntity(new IValidation[] {});
    getCdImage().setIsValid(true);
    if (getCdImage().getIsChangable()) {
        getCdImage().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
    }
    if (getIsLinuxOS()) {
        getKernel_path().validateEntity(new IValidation[] { new NoTrimmingWhitespacesValidation() });
        getInitrd_path().validateEntity(new IValidation[] { new NoTrimmingWhitespacesValidation() });
        getKernel_parameters().validateEntity(new IValidation[] { new NoTrimmingWhitespacesValidation() });
        // initrd path and kernel params require kernel path to be filled
        if (StringHelper.isNullOrEmpty(getKernel_path().getEntity())) {
            if (!StringHelper.isNullOrEmpty(getInitrd_path().getEntity())) {
                getInitrd_path().getInvalidityReasons().add(constants.initrdPathInvalid());
                getInitrd_path().setIsValid(false);
                getKernel_path().getInvalidityReasons().add(constants.initrdPathInvalid());
                getKernel_path().setIsValid(false);
            }
            if (!StringHelper.isNullOrEmpty(getKernel_parameters().getEntity())) {
                getKernel_parameters().getInvalidityReasons().add(constants.kernelParamsInvalid());
                getKernel_parameters().setIsValid(false);
                getKernel_path().getInvalidityReasons().add(constants.kernelParamsInvalid());
                getKernel_path().setIsValid(false);
            }
        }
    }
    if (!getBehavior().isBlankTemplateBehavior()) {
        setValidTab(TabName.GENERAL_TAB, isValidTab(TabName.GENERAL_TAB) && getDataCenterWithClustersList().getIsValid() && getTemplateWithVersion().getIsValid());
    }
    setValidTab(TabName.HOST_TAB, isValidTab(TabName.HOST_TAB) && getMigrationDowntime().getIsValid());
    boolean diskAliasesValid = getDisksAllocationModel().getIsValid();
    setValidTab(TabName.RESOURCE_ALLOCATION_TAB, isValidTab(TabName.RESOURCE_ALLOCATION_TAB) && getCpuSharesAmount().getIsValid() && diskAliasesValid);
    setValidTab(TabName.BOOT_OPTIONS_TAB, getCdImage().getIsValid() && getKernel_path().getIsValid());
    boolean vmInitIsValid = getVmInitModel().validate();
    setValidTab(TabName.INITIAL_RUN_TAB, vmInitIsValid);
    getIcon().validateEntity(new IValidation[] { new IconWithOsDefaultValidation() });
    setValidTab(TabName.ICON_TAB, getIcon().getIsValid());
    boolean hwPartValid = validateHwPart();
    boolean isValid = hwPartValid && vmInitIsValid && allTabsValid();
    getValid().setEntity(isValid);
    fireValidationCompleteEvent();
    return isValid;
}
Also used : GuidValidation(org.ovirt.engine.ui.uicommonweb.validation.GuidValidation) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) IconWithOsDefaultValidation(org.ovirt.engine.ui.uicommonweb.validation.IconWithOsDefaultValidation) NoTrimmingWhitespacesValidation(org.ovirt.engine.ui.uicommonweb.validation.NoTrimmingWhitespacesValidation) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) SpecialAsciiI18NOrNoneValidation(org.ovirt.engine.ui.uicommonweb.validation.SpecialAsciiI18NOrNoneValidation) NotEmptyQuotaValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyQuotaValidation)

Example 32 with NotEmptyValidation

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

the class NetworkFilterParameterModel method validate.

public void validate() {
    RegexValidation nameValidation = new RegexValidation();
    // $NON-NLS-1$
    nameValidation.setExpression("^[a-zA-Z0-9_]+$");
    RegexValidation valueValidation = new RegexValidation();
    // $NON-NLS-1$
    valueValidation.setExpression("^[a-zA-Z0-9_\\.:]+$");
    name.validateEntity(new IValidation[] { new NotEmptyValidation(), nameValidation });
    value.validateEntity(new IValidation[] { new NotEmptyValidation(), valueValidation });
    setIsValid(name.getIsValid() && value.getIsValid());
}
Also used : RegexValidation(org.ovirt.engine.ui.uicommonweb.validation.RegexValidation) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation)

Example 33 with NotEmptyValidation

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

the class PoolModelBehaviorBase method validate.

@Override
public boolean validate() {
    boolean isNew = getModel().getIsNew();
    int maxAllowedVms = getMaxVmsInPool();
    int assignedVms = getModel().getAssignedVms().asConvertible().integer();
    int futureNumOfDesktops = (isNew ? 0 : assignedVms) + getModel().getNumOfDesktops().getEntity();
    getModel().getNumOfDesktops().validateEntity(new IValidation[] { new NotEmptyValidation(), new LengthValidation(4), new IntegerValidation(isNew ? 1 : 0, isNew ? maxAllowedVms : maxAllowedVms - assignedVms) });
    getModel().getPrestartedVms().validateEntity(new IValidation[] { new NotEmptyValidation(), new IntegerValidation(0, futureNumOfDesktops) });
    getModel().getMaxAssignedVmsPerUser().validateEntity(new IValidation[] { new NotEmptyValidation(), new IntegerValidation(1, futureNumOfDesktops) });
    getModel().setValidTab(TabName.GENERAL_TAB, getModel().isValidTab(TabName.GENERAL_TAB) && getModel().getName().getIsValid() && getModel().getNumOfDesktops().getIsValid() && getModel().getPrestartedVms().getIsValid() && getModel().getMaxAssignedVmsPerUser().getIsValid());
    getModel().setValidTab(TabName.POOL_TAB, true);
    if (getModel().getSpiceProxyEnabled().getEntity()) {
        getModel().getSpiceProxy().validateEntity(new IValidation[] { new HostWithProtocolAndPortAddressValidation() });
    } else {
        getModel().getSpiceProxy().setIsValid(true);
    }
    return super.validate() && getModel().getName().getIsValid() && getModel().getNumOfDesktops().getIsValid() && getModel().getPrestartedVms().getIsValid() && getModel().getMaxAssignedVmsPerUser().getIsValid() && getModel().getSpiceProxy().getIsValid();
}
Also used : HostWithProtocolAndPortAddressValidation(org.ovirt.engine.ui.uicommonweb.validation.HostWithProtocolAndPortAddressValidation) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) IntegerValidation(org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation)

Example 34 with NotEmptyValidation

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

the class FenceAgentModel method validatePmModels.

/**
 * Validate the Power Management related Entity Models.
 */
public void validatePmModels() {
    EntityModel<String> ip = getManagementIp();
    EntityModel<String> userName = getPmUserName();
    EntityModel<String> password = getPmPassword();
    ListModel<String> type = getPmType();
    EntityModel<Integer> port = getPmPort();
    ip.validateEntity(new IValidation[] { new NotEmptyValidation(), new HostAddressValidation() });
    userName.validateEntity(new IValidation[] { new NotEmptyValidation() });
    password.validateEntity(new IValidation[] { new NotEmptyValidation(), new LengthValidation(50) });
    type.validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
    port.validateEntity(new IValidation[] { new IntegerValidation(1, 65535) });
}
Also used : NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) HostAddressValidation(org.ovirt.engine.ui.uicommonweb.validation.HostAddressValidation) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) IntegerValidation(org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation)

Example 35 with NotEmptyValidation

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

the class InstallModel method validate.

public boolean validate(boolean isOVirt) {
    getOVirtISO().setIsValid(true);
    getUserPassword().setIsValid(true);
    if (isOVirt) {
        getOVirtISO().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
    } else {
        if (getAuthenticationMethod() == AuthenticationMethod.Password) {
            getUserPassword().validateEntity(new IValidation[] { new NotEmptyValidation() });
        }
    }
    getNetworkProviderModel().validate();
    return getUserPassword().getIsValid() && getOVirtISO().getIsValid() && getNetworkProviderModel().getIsValid() && getHostedEngineHostModel().getIsValid();
}
Also used : NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation)

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