Search in sources :

Example 6 with SpecialAsciiI18NOrNoneValidation

use of org.ovirt.engine.ui.uicommonweb.validation.SpecialAsciiI18NOrNoneValidation 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 7 with SpecialAsciiI18NOrNoneValidation

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

the class ConfirmationModel method validate.

public boolean validate() {
    getLatch().setIsValid(true);
    if (getLatch().getIsAvailable() && !getLatch().getEntity()) {
        getLatch().getInvalidityReasons().add(ConstantsManager.getInstance().getConstants().youMustApproveTheActionByClickingOnThisCheckboxInvalidReason());
        getLatch().setIsValid(false);
    }
    getReason().validateEntity(new IValidation[] { new SpecialAsciiI18NOrNoneValidation() });
    return getLatch().getIsValid() && getReason().getIsValid();
}
Also used : SpecialAsciiI18NOrNoneValidation(org.ovirt.engine.ui.uicommonweb.validation.SpecialAsciiI18NOrNoneValidation)

Example 8 with SpecialAsciiI18NOrNoneValidation

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

the class DataCenterModel method validate.

public boolean validate() {
    getName().validateEntity(new IValidation[] { new NotEmptyValidation(), new LengthValidation(40), new LengthValidation(getMaxNameLength()), new AsciiNameValidation() });
    getVersion().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
    getDescription().validateEntity(new IValidation[] { new AsciiOrNoneValidation() });
    getComment().validateEntity(new IValidation[] { new SpecialAsciiI18NOrNoneValidation() });
    boolean validationResult = getName().getIsValid() && getDescription().getIsValid() && getComment().getIsValid() && getVersion().getIsValid();
    return validationResult;
}
Also used : AsciiOrNoneValidation(org.ovirt.engine.ui.uicommonweb.validation.AsciiOrNoneValidation) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) AsciiNameValidation(org.ovirt.engine.ui.uicommonweb.validation.AsciiNameValidation) SpecialAsciiI18NOrNoneValidation(org.ovirt.engine.ui.uicommonweb.validation.SpecialAsciiI18NOrNoneValidation) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation)

Example 9 with SpecialAsciiI18NOrNoneValidation

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

the class IscsiBondModel method validate.

private boolean validate() {
    getName().validateEntity(new IValidation[] { new NotEmptyValidation(), new I18NNameValidation(), new LengthValidation(50) });
    getDescription().validateEntity(new IValidation[] { new SpecialAsciiI18NOrNoneValidation(), new LengthValidation(4000) });
    if (getNetworks().getSelectedItems() == null || getNetworks().getSelectedItems().isEmpty()) {
        getInvalidityReasons().add(constants.noNetworksSelected());
        setIsValid(false);
    } else {
        setIsValid(true);
    }
    return getName().getIsValid() && getDescription().getIsValid() && getIsValid();
}
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) I18NNameValidation(org.ovirt.engine.ui.uicommonweb.validation.I18NNameValidation)

Example 10 with SpecialAsciiI18NOrNoneValidation

use of org.ovirt.engine.ui.uicommonweb.validation.SpecialAsciiI18NOrNoneValidation 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

SpecialAsciiI18NOrNoneValidation (org.ovirt.engine.ui.uicommonweb.validation.SpecialAsciiI18NOrNoneValidation)10 NotEmptyValidation (org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation)9 LengthValidation (org.ovirt.engine.ui.uicommonweb.validation.LengthValidation)7 IntegerValidation (org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation)3 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)2 AsciiNameValidation (org.ovirt.engine.ui.uicommonweb.validation.AsciiNameValidation)2 AsciiOrNoneValidation (org.ovirt.engine.ui.uicommonweb.validation.AsciiOrNoneValidation)2 NotEmptyQuotaValidation (org.ovirt.engine.ui.uicommonweb.validation.NotEmptyQuotaValidation)2 NewVnicProfileModel (org.ovirt.engine.ui.uicommonweb.models.profiles.NewVnicProfileModel)1 VnicProfileModel (org.ovirt.engine.ui.uicommonweb.models.profiles.VnicProfileModel)1 GuidValidation (org.ovirt.engine.ui.uicommonweb.validation.GuidValidation)1 HostAddressValidation (org.ovirt.engine.ui.uicommonweb.validation.HostAddressValidation)1 HostnameValidation (org.ovirt.engine.ui.uicommonweb.validation.HostnameValidation)1 I18NNameValidation (org.ovirt.engine.ui.uicommonweb.validation.I18NNameValidation)1 IconWithOsDefaultValidation (org.ovirt.engine.ui.uicommonweb.validation.IconWithOsDefaultValidation)1 NoTrimmingWhitespacesValidation (org.ovirt.engine.ui.uicommonweb.validation.NoTrimmingWhitespacesValidation)1 RegexValidation (org.ovirt.engine.ui.uicommonweb.validation.RegexValidation)1