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;
}
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;
}
Aggregations