Search in sources :

Example 1 with NotNullIntegerValidation

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

the class ClusterModel method validate.

public boolean validate() {
    validateName();
    getDataCenter().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
    getCustomPropertySheet().setIsValid(getCustomPropertySheet().validate());
    setValidTab(TabName.CLUSTER_POLICY_TAB, getCustomPropertySheet().getIsValid());
    final IValidation[] versionValidations = new IValidation[] { new NotEmptyValidation() };
    getVersion().validateSelectedItem(versionValidations);
    getManagementNetwork().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
    getRngHwrngSourceRequired().setIsValid(true);
    boolean validService = true;
    if (getEnableOvirtService().getIsAvailable() && getEnableGlusterService().getIsAvailable()) {
        validService = getEnableOvirtService().getEntity() || getEnableGlusterService().getEntity();
    }
    getGlusterHostAddress().validateEntity(new IValidation[] { new NotEmptyValidation() });
    getGlusterHostPassword().validateEntity(new IValidation[] { new NotEmptyValidation() });
    if (!validService) {
        setMessage(ConstantsManager.getInstance().getConstants().clusterServiceValidationMsg());
    } else if (getIsImportGlusterConfiguration().getEntity() && getGlusterHostAddress().getIsValid() && getGlusterHostPassword().getIsValid() && !isFingerprintVerified()) {
        setMessage(ConstantsManager.getInstance().getConstants().fingerprintNotVerified());
    } else {
        setMessage(null);
    }
    if (getSpiceProxyEnabled().getEntity()) {
        getSpiceProxy().validateEntity(new IValidation[] { new HostWithProtocolAndPortAddressValidation() });
    } else {
        getSpiceProxy().setIsValid(true);
    }
    setValidTab(TabName.CONSOLE_TAB, getSpiceProxy().getIsValid());
    if (getSerialNumberPolicy().getSelectedSerialNumberPolicy() == SerialNumberPolicy.CUSTOM) {
        getSerialNumberPolicy().getCustomSerialNumber().validateEntity(new IValidation[] { new NotEmptyValidation() });
    } else {
        getSerialNumberPolicy().getCustomSerialNumber().setIsValid(true);
    }
    getMacPoolModel().validate();
    boolean generalTabValid = getName().getIsValid() && getDataCenter().getIsValid() && getCPU().getIsValid() && getManagementNetwork().getIsValid() && getVersion().getIsValid() && validService && getGlusterHostAddress().getIsValid() && getRngHwrngSourceRequired().getIsValid() && getGlusterHostPassword().getIsValid() && (!getIsImportGlusterConfiguration().getEntity() || (getGlusterHostAddress().getIsValid() && getGlusterHostPassword().getIsValid() && getSerialNumberPolicy().getCustomSerialNumber().getIsValid() && isFingerprintVerified()));
    setValidTab(TabName.GENERAL_TAB, generalTabValid);
    if (getVersion().getSelectedItem() != null) {
        if (AsyncDataProvider.getInstance().isMigrationPoliciesSupported(getVersion().getSelectedItem()) && MigrationBandwidthLimitType.CUSTOM.equals(getMigrationBandwidthLimitType().getSelectedItem())) {
            getCustomMigrationNetworkBandwidth().validateEntity(new IValidation[] { new NotNullIntegerValidation(0, Integer.MAX_VALUE) });
        } else {
            getCustomMigrationNetworkBandwidth().setIsValid(true);
        }
    }
    final boolean migrationTabValid = getMigrationBandwidthLimitType().getIsValid() && getCustomMigrationNetworkBandwidth().getIsValid();
    setValidTab(TabName.MIGRATION_TAB, migrationTabValid);
    boolean macPoolTabValid = getMacPoolModel().getIsValid();
    setValidTab(TabName.MAC_POOL_TAB, macPoolTabValid);
    ValidationCompleteEvent.fire(getEventBus(), this);
    return generalTabValid && macPoolTabValid && getCustomPropertySheet().getIsValid() && getSpiceProxy().getIsValid() && migrationTabValid;
}
Also used : IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) HostWithProtocolAndPortAddressValidation(org.ovirt.engine.ui.uicommonweb.validation.HostWithProtocolAndPortAddressValidation) NotNullIntegerValidation(org.ovirt.engine.ui.uicommonweb.validation.NotNullIntegerValidation) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation)

Example 2 with NotNullIntegerValidation

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

the class UnitVmModel method validateHwPart.

public boolean validateHwPart() {
    getMigrationDowntime().validateEntity(new IValidation[] { new NotNullIntegerValidation(0, Integer.MAX_VALUE) });
    getTotalCPUCores().validateEntity(new IValidation[] { new NotEmptyValidation(), new IntegerValidation(1, behavior.maxCpus), new TotalCpuCoresComposableValidation() });
    if (getIsAutoAssign().getEntity() != null && !getIsAutoAssign().getEntity()) {
        getDefaultHost().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
    } else {
        getDefaultHost().setIsValid(true);
    }
    if (getCpuSharesAmount().getIsAvailable()) {
        getCpuSharesAmount().validateEntity(new IValidation[] { new NotEmptyValidation(), new IntegerValidation(0, 262144) });
    }
    boolean customPropertySheetValid = getCustomPropertySheet().validate();
    setValidTab(TabName.CUSTOM_PROPERTIES_TAB, customPropertySheetValid);
    if (getSerialNumberPolicy().getSelectedSerialNumberPolicy() == SerialNumberPolicy.CUSTOM) {
        getSerialNumberPolicy().getCustomSerialNumber().validateEntity(new IValidation[] { new NotEmptyValidation() });
    } else {
        getSerialNumberPolicy().getCustomSerialNumber().setIsValid(true);
    }
    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) });
    setValidTab(TabName.CONSOLE_TAB, getUsbPolicy().getIsValid() && getNumOfMonitors().getIsValid() && getSpiceProxy().getIsValid());
    setValidTab(TabName.HOST_TAB, getMigrationDowntime().getIsValid());
    getRngBytes().validateEntity(new IValidation[] { new IntegerValidation(0, Integer.MAX_VALUE), new RngDevValidation() });
    getRngPeriod().validateEntity(new IValidation[] { new IntegerValidation(0, Integer.MAX_VALUE) });
    setValidTab(TabName.TAB_RNG, getRngBytes().getIsValid() && getRngPeriod().getIsValid());
    // Minimum 'Physical Memory Guaranteed' is 1MB
    validateMemorySize(getMemSize(), Integer.MAX_VALUE, 1);
    if (getMemSize().getIsValid()) {
        validateMemorySize(getMinAllocatedMemory(), getMemSize().getEntity(), 1);
    }
    validateMaxMemorySize();
    validateMemoryAlignment(getMemSize());
    setValidTab(TabName.RESOURCE_ALLOCATION_TAB, getMinAllocatedMemory().getIsValid());
    setValidTab(TabName.SYSTEM_TAB, getMemSize().getIsValid() && getMaxMemorySize().getIsValid() && getTotalCPUCores().getIsValid() && getSerialNumberPolicy().getCustomSerialNumber().getIsValid() && getEmulatedMachine().getIsValid() && getCustomCpu().getIsValid());
    /*
         * This should be run at very end of the validation process otherwise general validation can override more
         * strict checks in behaviors
         */
    boolean behaviorValid = behavior.validate();
    boolean isValid = behaviorValid && allTabsValid();
    return isValid;
}
Also used : NotNullIntegerValidation(org.ovirt.engine.ui.uicommonweb.validation.NotNullIntegerValidation) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) I18NExtraNameOrNoneValidation(org.ovirt.engine.ui.uicommonweb.validation.I18NExtraNameOrNoneValidation) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) IntegerValidation(org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation) NotNullIntegerValidation(org.ovirt.engine.ui.uicommonweb.validation.NotNullIntegerValidation)

Aggregations

NotEmptyValidation (org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation)2 NotNullIntegerValidation (org.ovirt.engine.ui.uicommonweb.validation.NotNullIntegerValidation)2 HostWithProtocolAndPortAddressValidation (org.ovirt.engine.ui.uicommonweb.validation.HostWithProtocolAndPortAddressValidation)1 I18NExtraNameOrNoneValidation (org.ovirt.engine.ui.uicommonweb.validation.I18NExtraNameOrNoneValidation)1 IValidation (org.ovirt.engine.ui.uicommonweb.validation.IValidation)1 IntegerValidation (org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation)1 LengthValidation (org.ovirt.engine.ui.uicommonweb.validation.LengthValidation)1