IDEMPIERE-5698 - Improvement for display all events errors (#1807)

* IDEMPIERE-5698 - mprovement for display all events errors

* IDEMPIERE-5698 - Improvement for display all events errors in all methods of class
This commit is contained in:
Jose Leite 2023-04-28 11:55:43 -03:00 committed by GitHub
parent 1de363d65d
commit 61118b8877
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 33 additions and 9 deletions

View File

@ -17,6 +17,7 @@
package org.compiere.model;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
@ -267,8 +268,14 @@ public class ModelValidationEngine
EventManager.getInstance().sendEvent(event);
@SuppressWarnings("unchecked")
List<String> errors = (List<String>) event.getProperty(IEventManager.EVENT_ERROR_MESSAGES);
if (errors != null && !errors.isEmpty())
return errors.get(0);
if (errors != null && !errors.isEmpty()) {
Collections.reverse(errors);
StringBuilder eventErrors = new StringBuilder("");
for (String error : errors) {
eventErrors.append(error).append("<br>");
}
return eventErrors.toString();
}
if ((AD_User_ID == SystemIDs.USER_SYSTEM || AD_User_ID == SystemIDs.USER_SUPERUSER) && AD_Role_ID == SystemIDs.ROLE_SYSTEM)
; // don't validate for user system on role system
@ -406,8 +413,14 @@ public class ModelValidationEngine
EventManager.getInstance().sendEvent(event);
@SuppressWarnings("unchecked")
List<String> errors = (List<String>) event.getProperty(IEventManager.EVENT_ERROR_MESSAGES);
if (errors != null && !errors.isEmpty())
return errors.get(0);
if (errors != null && !errors.isEmpty()) {
Collections.reverse(errors);
StringBuilder eventErrors = new StringBuilder("");
for (String error : errors) {
eventErrors.append(error).append("<br>");
}
return eventErrors.toString();
}
return null;
} // fireModelChange
@ -573,9 +586,14 @@ public class ModelValidationEngine
EventManager.getInstance().sendEvent(event);
@SuppressWarnings("unchecked")
List<String> errors = (List<String>) event.getProperty(IEventManager.EVENT_ERROR_MESSAGES);
if (errors != null && !errors.isEmpty())
return errors.get(0);
if (errors != null && !errors.isEmpty()) {
Collections.reverse(errors);
StringBuilder eventErrors = new StringBuilder("");
for (String error : errors) {
eventErrors.append(error).append("<br>");
}
return eventErrors.toString();
}
return null;
} // fireDocValidate
@ -722,8 +740,14 @@ public class ModelValidationEngine
EventManager.getInstance().sendEvent(event);
@SuppressWarnings("unchecked")
List<String> errors = (List<String>) event.getProperty(IEventManager.EVENT_ERROR_MESSAGES);
if (errors != null && !errors.isEmpty())
return errors.get(0);
if (errors != null && !errors.isEmpty()) {
Collections.reverse(errors);
StringBuilder eventErrors = new StringBuilder("");
for (String error : errors) {
eventErrors.append(error).append("<br>");
}
return eventErrors.toString();
}
return null;
} // fireFactsValidate