@@ -0,0 +1,1454 @@
+package org.jpos.qi.minigl;%0A%0Aimport com.vaadin.data.ValidationResult;%0Aimport com.vaadin.data.Validator;%0Aimport com.vaadin.data.ValueContext;%0Aimport com.vaadin.shared.ui.ErrorLevel;%0Aimport org.jpos.ee.DB;%0Aimport org.jpos.gl.Account;%0Aimport org.jpos.qi.QI;%0A%0Apublic class AccountValidator implements Validator%3CAccount%3E %7B%0A    private QI app;%0A    private Class clazz;%0A%0A    public AccountValidator (QI app, Class clazz) %7B%0A        super();%0A        this.app = app;%0A        this.clazz = clazz;%0A    %7D%0A%0A    @Override%0A    public ValidationResult apply (Account value, ValueContext context) %7B%0A        Account acct = null;%0A        if (!context.getHasValue().isPresent())%0A            return ValidationResult.ok();%0A        boolean isReadOnly = context.getHasValue().get().isReadOnly();%0A        if (isReadOnly)%0A            return ValidationResult.ok();%0A        if (value != null) %7B%0A            try %7B%0A                acct = DB.exec(db -%3E db.session().get(Account.class, value.getId()));%0A            %7D catch (Exception e) %7B%0A                app.getLog().createError(e.getMessage());%0A            %7D%0A        %7D%0A        if (acct == null)%0A            return ValidationResult.create(app.getMessage(%22errorMessage.willCreateAccountAndReceivables%22),%0A                    ErrorLevel.INFO);%0A        else if (clazz.isInstance(value))%0A            return ValidationResult.create(app.getMessage(%22errorMessage.accountExists%22), ErrorLevel.INFO);%0A        return ValidationResult.ok();%0A%0A    %7D%0A%7D%0A

Move Account validator to separate class to allow reusing it