Search in sources :

Example 1 with AsciiNameValidation

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

the class GlusterStorageModel method validate.

@Override
public boolean validate() {
    getGlusterVolumes().validateSelectedItem(new IValidation[] { new NotEmptyValidation(), new LengthValidation(128) });
    getVfsType().validateEntity(new IValidation[] { new NotEmptyValidation(), new AsciiNameValidation() });
    if (getLinkGlusterVolume().getEntity()) {
        return getGlusterVolumes().getIsValid() && getVfsType().getIsValid();
    } else {
        return super.validate();
    }
}
Also used : NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) AsciiNameValidation(org.ovirt.engine.ui.uicommonweb.validation.AsciiNameValidation) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation)

Example 2 with AsciiNameValidation

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

the class ExternalSubnetModel method validate.

public boolean validate() {
    getName().validateEntity(new IValidation[] { new NotEmptyValidation(), new AsciiNameValidation() });
    boolean ipv4 = getIpVersion().getSelectedItem() == IpVersion.IPV4;
    getCidr().validateEntity(new IValidation[] { ipv4 ? new CidrValidation() : new NotEmptyValidation() });
    getIpVersion().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
    getGateway().setIsValid(true);
    if (StringHelper.isNotNullOrEmpty(getGateway().getEntity()) && ipv4) {
        getGateway().validateEntity(new IValidation[] { new Ipv4AddressValidation() });
    }
    boolean dnsServersValid = true;
    for (EntityModel<String> dnsServer : getDnsServers().getItems()) {
        dnsServer.setIsValid(true);
        if (StringHelper.isNotNullOrEmpty(dnsServer.getEntity()) && ipv4) {
            dnsServer.validateEntity(new IValidation[] { new Ipv4AddressValidation() });
        }
        dnsServersValid &= dnsServer.getIsValid();
    }
    return getName().getIsValid() && getCidr().getIsValid() && getIpVersion().getIsValid() && getGateway().getIsValid() && dnsServersValid;
}
Also used : CidrValidation(org.ovirt.engine.ui.uicommonweb.validation.CidrValidation) Ipv4AddressValidation(org.ovirt.engine.ui.uicommonweb.validation.Ipv4AddressValidation) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) AsciiNameValidation(org.ovirt.engine.ui.uicommonweb.validation.AsciiNameValidation)

Example 3 with AsciiNameValidation

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

the class NetworkModel method validate.

private boolean validate() {
    LengthValidation tempVar = new LengthValidation();
    tempVar.setMaxLength(BusinessEntitiesDefinitions.NETWORK_NAME_SIZE);
    RegexValidation tempVar2 = new RegexValidation();
    tempVar2.setIsNegate(true);
    // $NON-NLS-1$
    tempVar2.setExpression("^(bond)");
    tempVar2.setMessage(ConstantsManager.getInstance().getConstants().networkNameStartMsg());
    getName().validateEntity(new IValidation[] { new NotEmptyValidation(), tempVar, tempVar2 });
    LengthValidation tempVar3 = new LengthValidation();
    tempVar3.setMaxLength(40);
    getDescription().validateEntity(new IValidation[] { tempVar3 });
    getComment().validateEntity(new IValidation[] { new SpecialAsciiI18NOrNoneValidation() });
    getVLanTag().setIsValid(true);
    if (getHasVLanTag().getEntity()) {
        IntegerValidation tempVar4 = new IntegerValidation();
        tempVar4.setMinimum(0);
        tempVar4.setMaximum(4094);
        getVLanTag().validateEntity(new IValidation[] { new NotEmptyValidation(), tempVar4 });
    }
    IntegerValidation tempVar5 = new IntegerValidation();
    tempVar5.setMinimum(68);
    getMtu().validateEntity(new IValidation[] { new NotEmptyValidation(), tempVar5 });
    getDnsConfigurationModel().validate();
    getExternalProviders().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
    boolean subnetValid = true;
    if (getExternal().getEntity() && getCreateSubnet().getEntity()) {
        subnetValid = getSubnetModel().validate();
    }
    boolean profilesValid = true;
    Iterable<VnicProfileModel> profiles = getProfiles().getItems();
    for (VnicProfileModel profileModel : profiles) {
        if (!profileModel.validate()) {
            profilesValid = false;
        }
    }
    getNetworkLabel().validateSelectedItem(new IValidation[] { new AsciiNameValidation() });
    setValidTab(TabName.GENERAL_TAB, isGeneralTabValid());
    setValidTab(TabName.SUBNET_TAB, subnetValid);
    setValidTab(TabName.PROFILES_TAB, profilesValid);
    ValidationCompleteEvent.fire(getEventBus(), this);
    return allTabsValid();
}
Also used : RegexValidation(org.ovirt.engine.ui.uicommonweb.validation.RegexValidation) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) SpecialAsciiI18NOrNoneValidation(org.ovirt.engine.ui.uicommonweb.validation.SpecialAsciiI18NOrNoneValidation) NewVnicProfileModel(org.ovirt.engine.ui.uicommonweb.models.profiles.NewVnicProfileModel) VnicProfileModel(org.ovirt.engine.ui.uicommonweb.models.profiles.VnicProfileModel) AsciiNameValidation(org.ovirt.engine.ui.uicommonweb.validation.AsciiNameValidation) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) IntegerValidation(org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation)

Example 4 with AsciiNameValidation

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

the class QosModel method validate.

public boolean validate() {
    getName().validateEntity(new IValidation[] { new NotEmptyValidation(), new AsciiNameValidation() });
    getDescription().validateEntity(new IValidation[] { new AsciiOrNoneValidation() });
    getQosParametersModel().validate();
    setIsValid(getName().getIsValid() && getDescription().getIsValid() && getQosParametersModel().getIsValid());
    return getIsValid();
}
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)

Example 5 with AsciiNameValidation

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

the class VfsNicLabelModel method validate.

public void validate() {
    boolean res = true;
    Set<String> editedLabels = new HashSet<>();
    for (ListModel<String> labelModel : getItems()) {
        labelModel.validateSelectedItem(new IValidation[] { new AsciiNameValidation() });
        String label = labelModel.getSelectedItem();
        if (editedLabels.contains(label)) {
            labelModel.getInvalidityReasons().add(ConstantsManager.getInstance().getConstants().duplicateLabel());
            labelModel.setIsValid(false);
        }
        editedLabels.add(label);
        res &= labelModel.getIsValid();
    }
    setIsValid(res);
}
Also used : AsciiNameValidation(org.ovirt.engine.ui.uicommonweb.validation.AsciiNameValidation) HashSet(java.util.HashSet)

Aggregations

AsciiNameValidation (org.ovirt.engine.ui.uicommonweb.validation.AsciiNameValidation)12 NotEmptyValidation (org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation)11 LengthValidation (org.ovirt.engine.ui.uicommonweb.validation.LengthValidation)6 AsciiOrNoneValidation (org.ovirt.engine.ui.uicommonweb.validation.AsciiOrNoneValidation)3 IntegerValidation (org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation)2 SpecialAsciiI18NOrNoneValidation (org.ovirt.engine.ui.uicommonweb.validation.SpecialAsciiI18NOrNoneValidation)2 HashSet (java.util.HashSet)1 NewVnicProfileModel (org.ovirt.engine.ui.uicommonweb.models.profiles.NewVnicProfileModel)1 VnicProfileModel (org.ovirt.engine.ui.uicommonweb.models.profiles.VnicProfileModel)1 BrickMountPointValidation (org.ovirt.engine.ui.uicommonweb.validation.BrickMountPointValidation)1 CidrValidation (org.ovirt.engine.ui.uicommonweb.validation.CidrValidation)1 Ipv4AddressValidation (org.ovirt.engine.ui.uicommonweb.validation.Ipv4AddressValidation)1 RegexValidation (org.ovirt.engine.ui.uicommonweb.validation.RegexValidation)1