[jboss-svn-commits] JBL Code SVN: r31368 - in labs/jbossrules/trunk: drools-compiler/src/test/java/org/drools/guvnor/modeldriven and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Feb 3 00:50:16 EST 2010
Author: KrisVerlaenen
Date: 2010-02-03 00:50:15 -0500 (Wed, 03 Feb 2010)
New Revision: 31368
Modified:
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl/ConnectiveConstraint.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl/SingleFieldConstraint.java
labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/guvnor/modeldriven/RuleModelTest.java
labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/rulebuilder/ui/ConstraintValueEditor.java
Log:
JBIDE-5664: Unable to specify additional restriction in when part of Drools rule using Guided Rule Editor
- ConstraintValueEditor now also supports connective constraints
Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl/ConnectiveConstraint.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl/ConnectiveConstraint.java 2010-02-02 22:51:41 UTC (rev 31367)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl/ConnectiveConstraint.java 2010-02-03 05:50:15 UTC (rev 31368)
@@ -9,12 +9,18 @@
public ConnectiveConstraint() {
}
- public ConnectiveConstraint(final String opr,
+ public ConnectiveConstraint(final String fieldName,
+ final String fieldType,
+ final String opr,
final String val) {
+ this.fieldName = fieldName;
+ this.fieldType = fieldType;
this.operator = opr;
this.value = val;
}
public String operator;
+ public String fieldName;
+ public String fieldType;
}
Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl/SingleFieldConstraint.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl/SingleFieldConstraint.java 2010-02-02 22:51:41 UTC (rev 31367)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl/SingleFieldConstraint.java 2010-02-03 05:50:15 UTC (rev 31368)
@@ -41,13 +41,13 @@
*/
public void addNewConnective() {
if ( this.connectives == null ) {
- this.connectives = new ConnectiveConstraint[]{new ConnectiveConstraint()};
+ this.connectives = new ConnectiveConstraint[]{new ConnectiveConstraint(this.fieldName, this.fieldType, null, null)};
} else {
final ConnectiveConstraint[] newList = new ConnectiveConstraint[this.connectives.length + 1];
for ( int i = 0; i < this.connectives.length; i++ ) {
newList[i] = this.connectives[i];
}
- newList[this.connectives.length] = new ConnectiveConstraint();
+ newList[this.connectives.length] = new ConnectiveConstraint(this.fieldName, this.fieldType, null, null);
this.connectives = newList;
}
}
Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/guvnor/modeldriven/RuleModelTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/guvnor/modeldriven/RuleModelTest.java 2010-02-02 22:51:41 UTC (rev 31367)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/guvnor/modeldriven/RuleModelTest.java 2010-02-03 05:50:15 UTC (rev 31368)
@@ -117,12 +117,12 @@
cons[0].fieldBinding = "qbc";
cons[0].fieldType = "String";
cons[0].connectives = new ConnectiveConstraint[1];
- cons[0].connectives[0] = new ConnectiveConstraint("&", "x");
+ cons[0].connectives[0] = new ConnectiveConstraint("age", "String", "&", "x");
cons[0].connectives[0].constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
cons[1] = new SingleFieldConstraint("make");
cons[1].fieldType = "Long";
cons[1].connectives = new ConnectiveConstraint[1];
- cons[1].connectives[0] = new ConnectiveConstraint("=", "2");
+ cons[1].connectives[0] = new ConnectiveConstraint("make", "Long", "=", "2");
cons[1].connectives[0].constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
@@ -340,7 +340,7 @@
cons[1] = new SingleFieldConstraint("make");
cons[0].fieldBinding = "qbc";
cons[0].connectives = new ConnectiveConstraint[1];
- cons[0].connectives[0] = new ConnectiveConstraint("&", "x");
+ cons[0].connectives[0] = new ConnectiveConstraint("age", null, "&", "x");
cons[0].connectives[0].constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
final FactPattern other = new FactPattern("House");
@@ -413,12 +413,12 @@
cons[0].fieldBinding = "qbc";
cons[0].fieldType = "String";
cons[0].connectives = new ConnectiveConstraint[1];
- cons[0].connectives[0] = new ConnectiveConstraint("&", "x");
+ cons[0].connectives[0] = new ConnectiveConstraint("age", "String", "&", "x");
cons[0].connectives[0].constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
cons[1] = new SingleFieldConstraint("make");
cons[1].fieldType = "Long";
cons[1].connectives = new ConnectiveConstraint[1];
- cons[1].connectives[0] = new ConnectiveConstraint("=", "2");
+ cons[1].connectives[0] = new ConnectiveConstraint("make", "Long", "=", "2");
cons[1].connectives[0].constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
final FactPattern other = new FactPattern("House");
Modified: labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/rulebuilder/ui/ConstraintValueEditor.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/rulebuilder/ui/ConstraintValueEditor.java 2010-02-02 22:51:41 UTC (rev 31367)
+++ labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/rulebuilder/ui/ConstraintValueEditor.java 2010-02-03 05:50:15 UTC (rev 31368)
@@ -5,6 +5,7 @@
import org.drools.eclipse.DroolsEclipsePlugin;
import org.drools.guvnor.client.modeldriven.DropDownData;
import org.drools.guvnor.client.modeldriven.SuggestionCompletionEngine;
+import org.drools.guvnor.client.modeldriven.brl.ConnectiveConstraint;
import org.drools.guvnor.client.modeldriven.brl.FactPattern;
import org.drools.guvnor.client.modeldriven.brl.ISingleFieldConstraint;
import org.drools.guvnor.client.modeldriven.brl.SingleFieldConstraint;
@@ -123,10 +124,21 @@
final ISingleFieldConstraint c,
GridData gd) {
- String fieldName = ((SingleFieldConstraint) c).fieldName;
+ String fieldName = null;
+ if (c instanceof SingleFieldConstraint) {
+ fieldName = ((SingleFieldConstraint) c).fieldName;
+ } else if (c instanceof ConnectiveConstraint) {
+ fieldName = ((ConnectiveConstraint) c).fieldName;
+ }
+ String fieldType = null;
+ if (c instanceof SingleFieldConstraint) {
+ fieldType = ((SingleFieldConstraint) c).fieldType;
+ } else if (c instanceof ConnectiveConstraint) {
+ fieldType = ((ConnectiveConstraint) c).fieldType;
+ }
DropDownData enums = null;
boolean found = false;
- if ( ((SingleFieldConstraint) c).fieldType.equals( SuggestionCompletionEngine.TYPE_BOOLEAN )) {
+ if ( fieldType.equals( SuggestionCompletionEngine.TYPE_BOOLEAN )) {
enums = DropDownData.create(new String[]{"true", "false"});
}else
{
More information about the jboss-svn-commits
mailing list