Author: rareddy
Date: 2010-08-06 14:15:20 -0400 (Fri, 06 Aug 2010)
New Revision: 2424
Modified:
trunk/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
trunk/client/src/test/java/org/teiid/adminapi/impl/TestModelMetaData.java
Log:
TEIID-1006: in-correctly placing the VDB with warnings as "inactive", only
validation errors count as errors not the warnings.
Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java 2010-08-06
05:08:25 UTC (rev 2423)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java 2010-08-06
18:15:20 UTC (rev 2424)
@@ -39,6 +39,7 @@
import org.jboss.managed.api.annotation.ManagementProperties;
import org.jboss.managed.api.annotation.ManagementProperty;
import org.teiid.adminapi.Model;
+import org.teiid.adminapi.impl.ModelMetaData.ValidationError.Severity;
@XmlAccessorType(XmlAccessType.NONE)
@@ -206,11 +207,21 @@
@ManagementProperty(description = "Model Validity Errors", readOnly=true,
managed=true)
public List<ValidationError> getErrors(){
+ return getValidationErrors(Severity.ERROR);
+ }
+
+ public List<ValidationError> getValidationErrors(ValidationError.Severity
severity){
if (this.errors == null) {
return Collections.emptyList();
}
- return this.errors;
- }
+ List<ValidationError> list = new ArrayList<ValidationError>();
+ for (ValidationError ve: this.errors) {
+ if (Severity.valueOf(ve.severity) == severity) {
+ list.add(ve);
+ }
+ }
+ return list;
+ }
public void addError(String severity, String message) {
if (this.errors == null) {
Modified: trunk/client/src/test/java/org/teiid/adminapi/impl/TestModelMetaData.java
===================================================================
--- trunk/client/src/test/java/org/teiid/adminapi/impl/TestModelMetaData.java 2010-08-06
05:08:25 UTC (rev 2423)
+++ trunk/client/src/test/java/org/teiid/adminapi/impl/TestModelMetaData.java 2010-08-06
18:15:20 UTC (rev 2424)
@@ -27,6 +27,7 @@
import org.junit.Test;
import org.teiid.adminapi.Model;
+@SuppressWarnings("nls")
public class TestModelMetaData {
@Test
@@ -56,4 +57,13 @@
assertTrue(!model.getProperties().isEmpty());
}
+
+ public void testErrors() {
+ ModelMetaData m = new ModelMetaData();
+ m.addError("ERROR", "I am Error");
+ m.addError("WARNING", "I am warning");
+
+ assertFalse(m.getErrors().isEmpty());
+ assertEquals(1, m.getErrors().size());
+ }
}