[jboss-svn-commits] JBL Code SVN: r35629 - in labs/jbossrules/trunk/drools-ide-common/src: main/java/org/drools/ide/common/client/modeldriven/testing and 5 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Oct 21 01:37:04 EDT 2010
Author: Rikkola
Date: 2010-10-21 01:37:03 -0400 (Thu, 21 Oct 2010)
New Revision: 35629
Modified:
labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/ide/common/client/modeldriven/dt/ActionCol.java
labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/ide/common/client/modeldriven/dt/ActionInsertFactCol.java
labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/ide/common/client/modeldriven/dt/ActionSetFieldCol.java
labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/ide/common/client/modeldriven/dt/ConditionCol.java
labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/ide/common/client/modeldriven/dt/DTColumnConfig.java
labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/ide/common/client/modeldriven/dt/GuidedDecisionTable.java
labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/ide/common/client/modeldriven/testing/ExecutionTrace.java
labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/ide/common/server/util/GuidedDTDRLPersistence.java
labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/testframework/ScenarioRunner.java
labs/jbossrules/trunk/drools-ide-common/src/test/java/org/drools/ide/common/modeldriven/dt/GuidedDecisionTableTest.java
labs/jbossrules/trunk/drools-ide-common/src/test/java/org/drools/ide/common/server/util/GuidedDTDRLPersistenceTest.java
labs/jbossrules/trunk/drools-ide-common/src/test/java/org/drools/ide/common/server/util/GuidedDTXMLPersistenceTest.java
labs/jbossrules/trunk/drools-ide-common/src/test/java/org/drools/testframework/ScenarioRunnerTest.java
Log:
[#GUVNOR-678] Web decision table: 'Group by column' select box content doesn't update as columns are added/removed
Modified: labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/ide/common/client/modeldriven/dt/ActionCol.java
===================================================================
--- labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/ide/common/client/modeldriven/dt/ActionCol.java 2010-10-21 04:45:41 UTC (rev 35628)
+++ labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/ide/common/client/modeldriven/dt/ActionCol.java 2010-10-21 05:37:03 UTC (rev 35629)
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright 2010 JBoss Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,13 +16,20 @@
package org.drools.ide.common.client.modeldriven.dt;
-
public class ActionCol extends DTColumnConfig {
- /**
- * The header to be displayed.
- */
- public String header;
+ private static final long serialVersionUID = 501l;
+ /**
+ * The header to be displayed.
+ */
+ private String header;
+ public void setHeader(String header) {
+ this.header = header;
+ }
+ public String getHeader() {
+ return header;
+ }
+
}
Modified: labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/ide/common/client/modeldriven/dt/ActionInsertFactCol.java
===================================================================
--- labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/ide/common/client/modeldriven/dt/ActionInsertFactCol.java 2010-10-21 04:45:41 UTC (rev 35628)
+++ labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/ide/common/client/modeldriven/dt/ActionInsertFactCol.java 2010-10-21 05:37:03 UTC (rev 35629)
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright 2010 JBoss Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,34 +18,75 @@
public class ActionInsertFactCol extends ActionCol {
- /**
- * The fact type (class) that is to be created.
- * eg Driver, Person, Cheese.
- */
- public String factType;
+ private static final long serialVersionUID = 510l;
- /**
- * The bound name of the variable to be effected.
- * If the same name appears twice, is it merged into the same action.
- */
- public String boundName;
+ /**
+ * The fact type (class) that is to be created.
+ * eg Driver, Person, Cheese.
+ */
+ private String factType;
- /**
- * The field on the fact being effected.
- */
- public String factField;
+ /**
+ * The bound name of the variable to be effected.
+ * If the same name appears twice, is it merged into the same action.
+ */
+ private String boundName;
- /**
- * Same as the type in ActionFieldValue - eg, either a String, or Numeric.
- * Refers to the data type of the literal value in the cell.
- * Refer to the types in SuggestionCompletionEngine.
- */
- public String type;
+ /**
+ * The field on the fact being effected.
+ */
+ private String factField;
- /**
- * An optional comman separated list of values.
- */
- public String valueList;
+ /**
+ * Same as the type in ActionFieldValue - eg, either a String, or Numeric.
+ * Refers to the data type of the literal value in the cell.
+ * Refer to the types in SuggestionCompletionEngine.
+ */
+ private String type;
+ /**
+ * An optional comman separated list of values.
+ */
+ private String valueList;
+ public void setFactType(String factType) {
+ this.factType = factType;
+ }
+
+ public String getFactType() {
+ return factType;
+ }
+
+ public void setBoundName(String boundName) {
+ this.boundName = boundName;
+ }
+
+ public String getBoundName() {
+ return boundName;
+ }
+
+ public void setFactField(String factField) {
+ this.factField = factField;
+ }
+
+ public String getFactField() {
+ return factField;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setValueList(String valueList) {
+ this.valueList = valueList;
+ }
+
+ public String getValueList() {
+ return valueList;
+ }
+
}
Modified: labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/ide/common/client/modeldriven/dt/ActionSetFieldCol.java
===================================================================
--- labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/ide/common/client/modeldriven/dt/ActionSetFieldCol.java 2010-10-21 04:45:41 UTC (rev 35628)
+++ labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/ide/common/client/modeldriven/dt/ActionSetFieldCol.java 2010-10-21 05:37:03 UTC (rev 35629)
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright 2010 JBoss Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,32 +18,73 @@
public class ActionSetFieldCol extends ActionCol {
- /**
- * The bound name of the variable to be effected.
- * If the same name appears twice, is it merged into the same action.
- */
- public String boundName;
+ private static final long serialVersionUID = 510l;
- /**
- * The field on the fact being effected.
- */
- public String factField;
+ /**
+ * The bound name of the variable to be effected.
+ * If the same name appears twice, is it merged into the same action.
+ */
+ private String boundName;
- /**
- * Same as the type in ActionFieldValue - eg, either a String, or Numeric.
- * Refers to the data type of the literal value in the cell.
- * These values come from SuggestionCompletionEngine.
- */
- public String type;
+ /**
+ * The field on the fact being effected.
+ */
+ private String factField;
- /**
- * An optional comma separated list of values.
- */
- public String valueList;
+ /**
+ * Same as the type in ActionFieldValue - eg, either a String, or Numeric.
+ * Refers to the data type of the literal value in the cell.
+ * These values come from SuggestionCompletionEngine.
+ */
+ private String type;
+ /**
+ * An optional comma separated list of values.
+ */
+ private String valueList;
- /**
- * This will be true if it is meant to be a modify to the engine, when in inferencing mode.
- */
- public boolean update = false;
+ /**
+ * This will be true if it is meant to be a modify to the engine, when in inferencing mode.
+ */
+ private boolean update = false;
+
+ public void setValueList(String valueList) {
+ this.valueList = valueList;
+ }
+
+ public String getValueList() {
+ return valueList;
+ }
+
+ public void setBoundName(String boundName) {
+ this.boundName = boundName;
+ }
+
+ public String getBoundName() {
+ return boundName;
+ }
+
+ public void setFactField(String factField) {
+ this.factField = factField;
+ }
+
+ public String getFactField() {
+ return factField;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setUpdate(boolean update) {
+ this.update = update;
+ }
+
+ public boolean isUpdate() {
+ return update;
+ }
}
Modified: labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/ide/common/client/modeldriven/dt/ConditionCol.java
===================================================================
--- labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/ide/common/client/modeldriven/dt/ConditionCol.java 2010-10-21 04:45:41 UTC (rev 35628)
+++ labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/ide/common/client/modeldriven/dt/ConditionCol.java 2010-10-21 05:37:03 UTC (rev 35629)
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright 2010 JBoss Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -25,20 +25,22 @@
*/
public class ConditionCol extends DTColumnConfig {
- /**
+ private static final long serialVersionUID = 510l;
+
+ /**
* What is displayed at the top
*/
- public String header;
+ private String header;
/**
* The type of the fact - class - eg Driver, Person, Cheese etc.
*/
- public String factType;
+ private String factType;
/**
* The name that this gets referenced as. Multiple columns with the same name mean their constraints will be combined.
*/
- public String boundName;
+ private String boundName;
/**
* The type of the value that is in the cell, eg if it is a formula, or literal value etc.
@@ -47,23 +49,79 @@
* TYPE_RET_VALUE
* TYPE_PREDICATE (in this case, the field and operator are ignored).
*/
- public int constraintValueType;
+ private int constraintValueType;
/**
* The field of the fact that this pertains to (if its a predicate, ignore it).
*/
- public String factField;
+ private String factField;
/**
* The operator to use to compare the field with the value (unless its a predicate, in which case this is ignored).
*/
- public String operator;
+ private String operator;
/**
* A comma separated list of valid values. Optional.
*/
- public String valueList;
+ private String valueList;
+ public void setHeader(String header) {
+ this.header = header;
+ }
+
+ public String getHeader() {
+ return header;
+ }
+
+ public void setFactType(String factType) {
+ this.factType = factType;
+ }
+
+ public String getFactType() {
+ return factType;
+ }
+
+ public void setBoundName(String boundName) {
+ this.boundName = boundName;
+ }
+
+ public String getBoundName() {
+ return boundName;
+ }
+
+ public void setConstraintValueType(int constraintValueType) {
+ this.constraintValueType = constraintValueType;
+ }
+
+ public int getConstraintValueType() {
+ return constraintValueType;
+ }
+
+ public void setFactField(String factField) {
+ this.factField = factField;
+ }
+
+ public String getFactField() {
+ return factField;
+ }
+
+ public void setOperator(String operator) {
+ this.operator = operator;
+ }
+
+ public String getOperator() {
+ return operator;
+ }
+
+ public void setValueList(String valueList) {
+ this.valueList = valueList;
+ }
+
+ public String getValueList() {
+ return valueList;
+ }
+
}
Modified: labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/ide/common/client/modeldriven/dt/DTColumnConfig.java
===================================================================
--- labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/ide/common/client/modeldriven/dt/DTColumnConfig.java 2010-10-21 04:45:41 UTC (rev 35628)
+++ labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/ide/common/client/modeldriven/dt/DTColumnConfig.java 2010-10-21 05:37:03 UTC (rev 35629)
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright 2010 JBoss Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,32 +18,75 @@
import org.drools.ide.common.client.modeldriven.brl.PortableObject;
-public class DTColumnConfig implements PortableObject {
+public class DTColumnConfig
+ implements
+ PortableObject {
- /**
- * If this is not -1, then this is the width which will be displayed.
- */
- public int width = -1;
+ private static final long serialVersionUID = 510l;
+ /**
+ * If this is not -1, then this is the width which will be displayed.
+ */
+ private int width = -1;
/**
* For a default value ! Will still be in the array of course, just use this value if its empty.
*/
- public String defaultValue = null;
+ private String defaultValue = null;
/**
* to hide the column (eg if it has a mandatory default).
*/
- public boolean hideColumn = false;
-
+ private boolean hideColumn = false;
+
/**
* to use the row number as number for the salience attribute.
*/
- public boolean useRowNumber = false;
-
+ private boolean useRowNumber = false;
+
/**
* to use the reverse order of the row number as the salience attribute.
*/
- public boolean reverseOrder = false;
+ private boolean reverseOrder = false;
+ public void setWidth(int width) {
+ this.width = width;
+ }
+
+ public int getWidth() {
+ return width;
+ }
+
+ public void setDefaultValue(String defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ public String getDefaultValue() {
+ return defaultValue;
+ }
+
+ public void setHideColumn(boolean hideColumn) {
+ this.hideColumn = hideColumn;
+ }
+
+ public boolean isHideColumn() {
+ return hideColumn;
+ }
+
+ public void setUseRowNumber(boolean useRowNumber) {
+ this.useRowNumber = useRowNumber;
+ }
+
+ public boolean isUseRowNumber() {
+ return useRowNumber;
+ }
+
+ public void setReverseOrder(boolean reverseOrder) {
+ this.reverseOrder = reverseOrder;
+ }
+
+ public boolean isReverseOrder() {
+ return reverseOrder;
+ }
+
}
Modified: labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/ide/common/client/modeldriven/dt/GuidedDecisionTable.java
===================================================================
--- labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/ide/common/client/modeldriven/dt/GuidedDecisionTable.java 2010-10-21 04:45:41 UTC (rev 35628)
+++ labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/ide/common/client/modeldriven/dt/GuidedDecisionTable.java 2010-10-21 05:37:03 UTC (rev 35629)
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright 2010 JBoss Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -36,223 +36,283 @@
*
* @author Michael Neale
*/
-public class GuidedDecisionTable implements PortableObject {
+public class GuidedDecisionTable
+ implements
+ PortableObject {
- /**
- * Number of internal elements before ( used for offsets in serialization )
- */
- public static final int INTERNAL_ELEMENTS = 2;
+ private static final long serialVersionUID = 510l;
- /**
- * The name - obviously.
- */
- public String tableName;
+ /**
+ * Number of internal elements before ( used for offsets in serialization )
+ */
+ public static final int INTERNAL_ELEMENTS = 2;
- public String parentName;
+ /**
+ * The name - obviously.
+ */
+ private String tableName;
- // metadata defined for table ( will be represented as a column per table
- // row of DATA
- private List<MetadataCol> metadataCols;
+ private String parentName;
- public List<AttributeCol> attributeCols = new ArrayList<AttributeCol>();
+ // metadata defined for table ( will be represented as a column per table
+ // row of DATA
+ private List<MetadataCol> metadataCols;
- public List<ConditionCol> conditionCols = new ArrayList<ConditionCol>();
+ private List<AttributeCol> attributeCols = new ArrayList<AttributeCol>();
- public List<ActionCol> actionCols = new ArrayList<ActionCol>();
+ private List<ConditionCol> conditionCols = new ArrayList<ConditionCol>();
- /**
- * First column is always row number. Second column is description.
- * Subsequent ones follow the above column definitions: attributeCols, then
- * conditionCols, then actionCols, in that order, left to right.
- */
- public String[][] data = new String[0][0];
+ private List<ActionCol> actionCols = new ArrayList<ActionCol>();
- /**
- * The width to display the description column.
- */
- public int descriptionWidth = -1;
+ /**
+ * First column is always row number. Second column is description.
+ * Subsequent ones follow the above column definitions: attributeCols, then
+ * conditionCols, then actionCols, in that order, left to right.
+ */
+ private String[][] data = new String[0][0];
- public String groupField;
+ /**
+ * The width to display the description column.
+ */
+ private int descriptionWidth = -1;
- // TODO: add in precondition(s)
+ private String groupField;
- public GuidedDecisionTable() {
- }
+ public GuidedDecisionTable() {
+ }
- // /**
- // * Will return an attribute col, or condition or action, depending on what
- // column is requested.
- // * This works through attributes, conditions and then actions, in left to
- // right manner.
- // */
- // public DTColumnConfig getColumnConfiguration(int index) {
- // if (index < attributeCols.size()) {
- // return (DTColumnConfig) attributeCols.get(index);
- // } else if (index < attributeCols.size() + conditionCols.size()) {
- // return (DTColumnConfig) conditionCols.get(index - attributeCols.size());
- // } else {
- // return (DTColumnConfig) actionCols.get(index - attributeCols.size() -
- // conditionCols.size());
- // }
- // }
+ /**
+ * This will return a list of valid values. if there is no such
+ * "enumeration" of values, then it will return an empty array.
+ */
+ public String[] getValueList(DTColumnConfig col,
+ SuggestionCompletionEngine sce) {
+ if ( col instanceof AttributeCol ) {
+ AttributeCol at = (AttributeCol) col;
+ if ( "no-loop".equals( at.attr ) || "enabled".equals( at.attr ) ) {
+ return new String[]{"true", "false"};
+ }
+ } else if ( col instanceof ConditionCol ) {
+ // conditions: if its a formula etc, just return String[0],
+ // otherwise check with the sce
+ ConditionCol c = (ConditionCol) col;
+ if ( c.getConstraintValueType() == BaseSingleFieldConstraint.TYPE_RET_VALUE || c.getConstraintValueType() == BaseSingleFieldConstraint.TYPE_PREDICATE ) {
+ return new String[0];
+ } else {
+ if ( c.getValueList() != null && !"".equals( c.getValueList() ) ) {
+ return c.getValueList().split( "," );
+ } else {
+ String[] r = sce.getEnumValues( c.getFactType(),
+ c.getFactField() );
+ return (r != null) ? r : new String[0];
+ }
+ }
+ } else if ( col instanceof ActionSetFieldCol ) {
+ ActionSetFieldCol c = (ActionSetFieldCol) col;
+ if ( c.getValueList() != null && !"".equals( c.getValueList() ) ) {
+ return c.getValueList().split( "," );
+ } else {
+ String[] r = sce.getEnumValues( getBoundFactType( c.getBoundName() ),
+ c.getFactField() );
+ return (r != null) ? r : new String[0];
+ }
+ } else if ( col instanceof ActionInsertFactCol ) {
+ ActionInsertFactCol c = (ActionInsertFactCol) col;
+ if ( c.getValueList() != null && !"".equals( c.getValueList() ) ) {
+ return c.getValueList().split( "," );
+ } else {
+ String[] r = sce.getEnumValues( c.getFactType(),
+ c.getFactField() );
+ return (r != null) ? r : new String[0];
+ }
+ }
- /**
- * This will return a list of valid values. if there is no such
- * "enumeration" of values, then it will return an empty array.
- */
- public String[] getValueList(DTColumnConfig col, SuggestionCompletionEngine sce) {
- if (col instanceof AttributeCol) {
- AttributeCol at = (AttributeCol) col;
- if ("no-loop".equals(at.attr) || "enabled".equals(at.attr)) {
- return new String[] { "true", "false" };
- }
- } else if (col instanceof ConditionCol) {
- // conditions: if its a formula etc, just return String[0],
- // otherwise check with the sce
- ConditionCol c = (ConditionCol) col;
- if (c.constraintValueType == BaseSingleFieldConstraint.TYPE_RET_VALUE
- || c.constraintValueType == BaseSingleFieldConstraint.TYPE_PREDICATE) {
- return new String[0];
- } else {
- if (c.valueList != null && !"".equals(c.valueList)) {
- return c.valueList.split(",");
- } else {
- String[] r = sce.getEnumValues(c.factType, c.factField);
- return (r != null) ? r : new String[0];
- }
- }
- } else if (col instanceof ActionSetFieldCol) {
- ActionSetFieldCol c = (ActionSetFieldCol) col;
- if (c.valueList != null && !"".equals(c.valueList)) {
- return c.valueList.split(",");
- } else {
- String[] r = sce.getEnumValues(getBoundFactType(c.boundName), c.factField);
- return (r != null) ? r : new String[0];
- }
- } else if (col instanceof ActionInsertFactCol) {
- ActionInsertFactCol c = (ActionInsertFactCol) col;
- if (c.valueList != null && !"".equals(c.valueList)) {
- return c.valueList.split(",");
- } else {
- String[] r = sce.getEnumValues(c.factType, c.factField);
- return (r != null) ? r : new String[0];
- }
- }
+ return new String[0];
+ }
- return new String[0];
- }
+ public String getType(DTColumnConfig col,
+ SuggestionCompletionEngine sce) {
+ String type = null;
+ if ( col instanceof AttributeCol ) {
+ AttributeCol at = (AttributeCol) col;
+ type = at.attr;
+ } else if ( col instanceof ConditionCol ) {
+ ConditionCol c = (ConditionCol) col;
+ type = sce.getFieldType( c.getFactType(),
+ c.getFactField() );
+ } else if ( col instanceof ActionSetFieldCol ) {
+ ActionSetFieldCol c = (ActionSetFieldCol) col;
+ type = sce.getFieldType( getBoundFactType( c.getBoundName() ),
+ c.getFactField() );
+ } else if ( col instanceof ActionInsertFactCol ) {
+ ActionInsertFactCol c = (ActionInsertFactCol) col;
+ type = sce.getFieldType( c.getFactType(),
+ c.getFactField() );
+ }
- public String getType(DTColumnConfig col, SuggestionCompletionEngine sce) {
- String type = null;
- if (col instanceof AttributeCol) {
- AttributeCol at = (AttributeCol) col;
- type = at.attr;
- } else if (col instanceof ConditionCol) {
- ConditionCol c = (ConditionCol) col;
- type = sce.getFieldType(c.factType, c.factField);
- } else if (col instanceof ActionSetFieldCol) {
- ActionSetFieldCol c = (ActionSetFieldCol) col;
- type = sce.getFieldType(getBoundFactType(c.boundName), c.factField);
- } else if (col instanceof ActionInsertFactCol) {
- ActionInsertFactCol c = (ActionInsertFactCol) col;
- type = sce.getFieldType(c.factType, c.factField);
- }
-
- return type;
- }
-
- private String getBoundFactType(String boundName) {
- for (Iterator<ConditionCol> iterator = conditionCols.iterator(); iterator.hasNext();) {
- ConditionCol c = iterator.next();
- if (c.boundName.equals(boundName)) {
- return c.factType;
- }
- }
- return null;
- }
+ return type;
+ }
- public boolean isNumeric(DTColumnConfig col, SuggestionCompletionEngine sce) {
- if (col instanceof AttributeCol) {
- AttributeCol at = (AttributeCol) col;
- return "salience".equals(at.attr);
- } else if (col instanceof ConditionCol) {
- ConditionCol c = (ConditionCol) col;
- if (c.constraintValueType == BaseSingleFieldConstraint.TYPE_LITERAL) {
- if (c.operator == null || "".equals(c.operator)) {
- return false;
- }
- String ft = sce.getFieldType(c.factType, c.factField);
- if (ft != null && ft.equals(SuggestionCompletionEngine.TYPE_NUMERIC)) {
- return true;
- }
- }
- } else if (col instanceof ActionSetFieldCol) {
- ActionSetFieldCol c = (ActionSetFieldCol) col;
- String ft = sce.getFieldType(getBoundFactType(c.boundName), c.factField);
- if (ft != null && ft.equals(SuggestionCompletionEngine.TYPE_NUMERIC)) {
- return true;
- }
- } else if (col instanceof ActionInsertFactCol) {
- ActionInsertFactCol c = (ActionInsertFactCol) col;
- String ft = sce.getFieldType(c.factType, c.factField);
- if (ft != null && ft.equals(SuggestionCompletionEngine.TYPE_NUMERIC)) {
- return true;
- }
- }
- // we can reuse text filter from guided editor to enforce this for data
- // entry.
- return false;
- }
+ private String getBoundFactType(String boundName) {
+ for ( Iterator<ConditionCol> iterator = getConditionCols().iterator(); iterator.hasNext(); ) {
+ ConditionCol c = iterator.next();
+ if ( c.getBoundName().equals( boundName ) ) {
+ return c.getFactType();
+ }
+ }
+ return null;
+ }
- public void setMetadataCols(List<MetadataCol> metadataCols) {
- this.metadataCols = metadataCols;
- }
+ public boolean isNumeric(DTColumnConfig col,
+ SuggestionCompletionEngine sce) {
+ if ( col instanceof AttributeCol ) {
+ AttributeCol at = (AttributeCol) col;
+ return "salience".equals( at.attr );
+ } else if ( col instanceof ConditionCol ) {
+ ConditionCol c = (ConditionCol) col;
+ if ( c.getConstraintValueType() == BaseSingleFieldConstraint.TYPE_LITERAL ) {
+ if ( c.getOperator() == null || "".equals( c.getOperator() ) ) {
+ return false;
+ }
+ String ft = sce.getFieldType( c.getFactType(),
+ c.getFactField() );
+ if ( ft != null && ft.equals( SuggestionCompletionEngine.TYPE_NUMERIC ) ) {
+ return true;
+ }
+ }
+ } else if ( col instanceof ActionSetFieldCol ) {
+ ActionSetFieldCol c = (ActionSetFieldCol) col;
+ String ft = sce.getFieldType( getBoundFactType( c.getBoundName() ),
+ c.getFactField() );
+ if ( ft != null && ft.equals( SuggestionCompletionEngine.TYPE_NUMERIC ) ) {
+ return true;
+ }
+ } else if ( col instanceof ActionInsertFactCol ) {
+ ActionInsertFactCol c = (ActionInsertFactCol) col;
+ String ft = sce.getFieldType( c.getFactType(),
+ c.getFactField() );
+ if ( ft != null && ft.equals( SuggestionCompletionEngine.TYPE_NUMERIC ) ) {
+ return true;
+ }
+ }
+ // we can reuse text filter from guided editor to enforce this for data
+ // entry.
+ return false;
+ }
- public List<MetadataCol> getMetadataCols() {
- if (null == metadataCols) {
- metadataCols = new ArrayList<MetadataCol>();
- }
- return metadataCols;
- }
+ public void setMetadataCols(List<MetadataCol> metadataCols) {
+ this.metadataCols = metadataCols;
+ }
- /**
- * Locate index of attribute name if it exists
- *
- * @param attributeName
- * Name of metadata we are looking for
- * @return index of attribute name or -1 if not found
- */
- public int getMetadataColIndex(String attributeName) {
+ public List<MetadataCol> getMetadataCols() {
+ if ( null == metadataCols ) {
+ metadataCols = new ArrayList<MetadataCol>();
+ }
+ return metadataCols;
+ }
- for (int i = 0; metadataCols != null && i < metadataCols.size(); i++) {
- if (attributeName.equals(metadataCols.get(i).attr)) {
- return i;
- }
- }
- return -1;
- }
+ /**
+ * Locate index of attribute name if it exists
+ *
+ * @param attributeName
+ * Name of metadata we are looking for
+ * @return index of attribute name or -1 if not found
+ */
+ public int getMetadataColIndex(String attributeName) {
- /**
- * Update all rows of metadata with value it attribute is present
- *
- * @param attributeName
- * Name of metadata we are looking for
- * @return true if values update, false if not
- */
- public boolean updateMetadata(String attributeName, String newValue) {
+ for ( int i = 0; metadataCols != null && i < metadataCols.size(); i++ ) {
+ if ( attributeName.equals( metadataCols.get( i ).attr ) ) {
+ return i;
+ }
+ }
+ return -1;
+ }
- // see if metaData exists for
- int metaIndex = getMetadataColIndex(attributeName);
- if (metaIndex < 0)
- return false;
+ /**
+ * Update all rows of metadata with value it attribute is present
+ *
+ * @param attributeName
+ * Name of metadata we are looking for
+ * @return true if values update, false if not
+ */
+ public boolean updateMetadata(String attributeName,
+ String newValue) {
- for (int i = 0; i < data.length; i++) {
+ // see if metaData exists for
+ int metaIndex = getMetadataColIndex( attributeName );
+ if ( metaIndex < 0 ) return false;
- String[] row = data[i];
+ for ( int i = 0; i < getData().length; i++ ) {
- row[GuidedDecisionTable.INTERNAL_ELEMENTS + metaIndex] = newValue;
- }
- return true;
- }
+ String[] row = getData()[i];
+ row[GuidedDecisionTable.INTERNAL_ELEMENTS + metaIndex] = newValue;
+ }
+ return true;
+ }
+
+ public void setGroupField(String groupField) {
+ this.groupField = groupField;
+ }
+
+ public String getGroupField() {
+ return groupField;
+ }
+
+ public void setTableName(String tableName) {
+ this.tableName = tableName;
+ }
+
+ public String getTableName() {
+ return tableName;
+ }
+
+ public void setParentName(String parentName) {
+ this.parentName = parentName;
+ }
+
+ public String getParentName() {
+ return parentName;
+ }
+
+ public void setAttributeCols(List<AttributeCol> attributeCols) {
+ this.attributeCols = attributeCols;
+ }
+
+ public List<AttributeCol> getAttributeCols() {
+ return attributeCols;
+ }
+
+ public void setConditionCols(List<ConditionCol> conditionCols) {
+ this.conditionCols = conditionCols;
+ }
+
+ public List<ConditionCol> getConditionCols() {
+ return conditionCols;
+ }
+
+ public void setActionCols(List<ActionCol> actionCols) {
+ this.actionCols = actionCols;
+ }
+
+ public List<ActionCol> getActionCols() {
+ return actionCols;
+ }
+
+ public void setData(String[][] data) {
+ this.data = data;
+ }
+
+ public String[][] getData() {
+ return data;
+ }
+
+ public void setDescriptionWidth(int descriptionWidth) {
+ this.descriptionWidth = descriptionWidth;
+ }
+
+ public int getDescriptionWidth() {
+ return descriptionWidth;
+ }
+
}
Modified: labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/ide/common/client/modeldriven/testing/ExecutionTrace.java
===================================================================
--- labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/ide/common/client/modeldriven/testing/ExecutionTrace.java 2010-10-21 04:45:41 UTC (rev 35628)
+++ labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/ide/common/client/modeldriven/testing/ExecutionTrace.java 2010-10-21 05:37:03 UTC (rev 35629)
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright 2010 JBoss Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,34 +23,66 @@
* This will be used to filter the rule engines behaviour under test.
* @author Michael Neale
*/
-public class ExecutionTrace implements Fixture {
+public class ExecutionTrace
+ implements
+ Fixture {
+ private static final long serialVersionUID = 510l;
+ /**
+ * This is the simulated date - leaving it as null means it will use
+ * the current time.
+ */
+ private Date scenarioSimulatedDate = null;
- /**
- * This is the simulated date - leaving it as null means it will use
- * the current time.
- */
- public Date scenarioSimulatedDate = null;
+ /**
+ * The time taken for execution.
+ */
+ private Long executionTimeResult;
+ /**
+ * This is pretty obvious really. The total firing count of all rules.
+ */
+ private Long numberOfRulesFired;
- /**
- * The time taken for execution.
- */
- public Long executionTimeResult;
+ /**
+ * A summary of the rules fired.
+ */
+ private String[] rulesFired;
- /**
- * This is pretty obvious really. The total firing count of all rules.
- */
- public Long numberOfRulesFired;
+ public ExecutionTrace() {
+ }
- /**
- * A summary of the rules fired.
- */
- public String[] rulesFired;
+ public void setScenarioSimulatedDate(Date scenarioSimulatedDate) {
+ this.scenarioSimulatedDate = scenarioSimulatedDate;
+ }
- public ExecutionTrace() {}
+ public Date getScenarioSimulatedDate() {
+ return scenarioSimulatedDate;
+ }
+ public void setExecutionTimeResult(Long executionTimeResult) {
+ this.executionTimeResult = executionTimeResult;
+ }
+ public Long getExecutionTimeResult() {
+ return executionTimeResult;
+ }
+ public void setNumberOfRulesFired(Long numberOfRulesFired) {
+ this.numberOfRulesFired = numberOfRulesFired;
+ }
+
+ public Long getNumberOfRulesFired() {
+ return numberOfRulesFired;
+ }
+
+ public void setRulesFired(String[] rulesFired) {
+ this.rulesFired = rulesFired;
+ }
+
+ public String[] getRulesFired() {
+ return rulesFired;
+ }
+
}
Modified: labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/ide/common/server/util/GuidedDTDRLPersistence.java
===================================================================
--- labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/ide/common/server/util/GuidedDTDRLPersistence.java 2010-10-21 04:45:41 UTC (rev 35628)
+++ labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/ide/common/server/util/GuidedDTDRLPersistence.java 2010-10-21 05:37:03 UTC (rev 35629)
@@ -57,21 +57,21 @@
StringBuilder sb = new StringBuilder();
- for (int i = 0; i < dt.data.length; i++) {
- String[] row = dt.data[i];
+ for (int i = 0; i < dt.getData().length; i++) {
+ String[] row = dt.getData()[i];
String num = row[0];
String desc = row[1];
RuleModel rm = new RuleModel();
- rm.name = getName(dt.tableName, num);
+ rm.name = getName(dt.getTableName(), num);
doMetadata(dt.getMetadataCols(), row, rm);
- doAttribs(dt.getMetadataCols().size(), dt.attributeCols, row, rm);
- doConditions(dt.getMetadataCols().size() + dt.attributeCols.size(), dt.conditionCols, row, rm);
- doActions(dt.getMetadataCols().size() + dt.attributeCols.size() + dt.conditionCols.size(), dt.actionCols, row, rm);
+ doAttribs(dt.getMetadataCols().size(), dt.getAttributeCols(), row, rm);
+ doConditions(dt.getMetadataCols().size() + dt.getAttributeCols().size(), dt.getConditionCols(), row, rm);
+ doActions(dt.getMetadataCols().size() + dt.getAttributeCols().size() + dt.getConditionCols().size(), dt.getActionCols(), row, rm);
- if(dt.parentName != null){
- rm.parentName = dt.parentName;
+ if(dt.getParentName() != null){
+ rm.parentName = dt.getParentName();
}
sb.append("#from row number: " + (i + 1) + "\n");
@@ -91,22 +91,22 @@
ActionCol c = actionCols.get(i);
String cell = row[condAndAttrs + i + GuidedDecisionTable.INTERNAL_ELEMENTS];
if (!validCell(cell)) {
- cell = c.defaultValue;
+ cell = c.getDefaultValue();
}
if (validCell(cell)) {
if (c instanceof ActionInsertFactCol) {
ActionInsertFactCol ac = (ActionInsertFactCol)c;
- LabelledAction a = findByLabelledAction(actions, ac.boundName);
+ LabelledAction a = findByLabelledAction(actions, ac.getBoundName());
if (a == null) {
a = new LabelledAction();
- a.boundName = ac.boundName;
- ActionInsertFact ins = new ActionInsertFact(ac.factType);
- ins.setBoundName( ac.boundName );
+ a.boundName = ac.getBoundName();
+ ActionInsertFact ins = new ActionInsertFact(ac.getFactType());
+ ins.setBoundName( ac.getBoundName() );
a.action = ins;
actions.add(a);
}
ActionInsertFact ins = (ActionInsertFact) a.action;
- ActionFieldValue val = new ActionFieldValue(ac.factField, cell, ac.type);
+ ActionFieldValue val = new ActionFieldValue(ac.getFactField(), cell, ac.getType());
ins.addFieldValue(val);
} else if (c instanceof ActionRetractFactCol) {
ActionRetractFactCol rf = (ActionRetractFactCol)c;
@@ -119,25 +119,25 @@
}
} else if (c instanceof ActionSetFieldCol) {
ActionSetFieldCol sf = (ActionSetFieldCol)c;
- LabelledAction a = findByLabelledAction(actions, sf.boundName);
+ LabelledAction a = findByLabelledAction(actions, sf.getBoundName());
if (a == null) {
a = new LabelledAction();
- a.boundName = sf.boundName;
- if (!sf.update) {
- a.action = new ActionSetField(sf.boundName);
+ a.boundName = sf.getBoundName();
+ if (!sf.isUpdate()) {
+ a.action = new ActionSetField(sf.getBoundName());
} else {
- a.action = new ActionUpdateField(sf.boundName);
+ a.action = new ActionUpdateField(sf.getBoundName());
}
actions.add(a);
- } else if (sf.update && !(a.action instanceof ActionUpdateField)) {
+ } else if (sf.isUpdate() && !(a.action instanceof ActionUpdateField)) {
//lets swap it out for an update as the user has asked for it.
ActionSetField old = (ActionSetField) a.action;
- ActionUpdateField update = new ActionUpdateField(sf.boundName);
+ ActionUpdateField update = new ActionUpdateField(sf.getBoundName());
update.fieldValues = old.fieldValues;
a.action = update;
}
ActionSetField asf = (ActionSetField) a.action;
- ActionFieldValue val = new ActionFieldValue(sf.factField, cell, sf.type);
+ ActionFieldValue val = new ActionFieldValue(sf.getFactField(), cell, sf.getType());
asf.addFieldValue(val);
}
}
@@ -168,27 +168,27 @@
if (!validCell(cell)) {
//try default value
- cell = c.defaultValue;
+ cell = c.getDefaultValue();
}
if (validCell(cell)) {
//get or create the pattern it belongs too
- FactPattern fp = findByFactPattern(patterns, c.boundName);
+ FactPattern fp = findByFactPattern(patterns, c.getBoundName());
if (fp == null) {
- fp = new FactPattern(c.factType);
- fp.boundName = c.boundName;
+ fp = new FactPattern(c.getFactType());
+ fp.boundName = c.getBoundName();
patterns.add(fp);
}
//now add the constraint from this cell
- switch (c.constraintValueType) {
+ switch (c.getConstraintValueType()) {
case BaseSingleFieldConstraint.TYPE_LITERAL:
case BaseSingleFieldConstraint.TYPE_RET_VALUE:
- SingleFieldConstraint sfc = new SingleFieldConstraint(c.factField);
- if (no(c.operator)) {
+ SingleFieldConstraint sfc = new SingleFieldConstraint(c.getFactField());
+ if (no(c.getOperator())) {
String[] a = cell.split("\\s");
if (a.length > 1) {
@@ -198,30 +198,30 @@
sfc.setValue(cell);
}
} else {
- sfc.setOperator(c.operator);
- if (c.operator.equals("in")) {
+ sfc.setOperator(c.getOperator());
+ if (c.getOperator().equals("in")) {
sfc.setValue(makeInList(cell));
} else {
sfc.setValue(cell);
}
}
- sfc.setConstraintValueType(c.constraintValueType);
+ sfc.setConstraintValueType(c.getConstraintValueType());
fp.addConstraint(sfc);
break;
case BaseSingleFieldConstraint.TYPE_PREDICATE:
SingleFieldConstraint pred = new SingleFieldConstraint();
- pred.setConstraintValueType(c.constraintValueType);
- if (c.factField != null && c.factField.indexOf("$param") > -1) {
+ pred.setConstraintValueType(c.getConstraintValueType());
+ if (c.getFactField() != null && c.getFactField().indexOf("$param") > -1) {
//handle interpolation
- pred.setValue(c.factField.replace("$param", cell));
+ pred.setValue(c.getFactField().replace("$param", cell));
} else {
pred.setValue(cell);
}
fp.addConstraint(pred);
break;
default:
- throw new IllegalArgumentException("Unknown constraintValueType: " + c.constraintValueType);
+ throw new IllegalArgumentException("Unknown constraintValueType: " + c.getConstraintValueType());
}
}
}
@@ -268,8 +268,8 @@
String cell = row[j + GuidedDecisionTable.INTERNAL_ELEMENTS + numOfMeta];
if (validCell(cell)) {
attribs.add(new RuleAttribute(at.attr, cell));
- } else if (at.defaultValue != null) {
- attribs.add(new RuleAttribute(at.attr, at.defaultValue));
+ } else if (at.getDefaultValue() != null) {
+ attribs.add(new RuleAttribute(at.attr, at.getDefaultValue()));
}
}
if (attribs.size() > 0) {
Modified: labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/testframework/ScenarioRunner.java
===================================================================
--- labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/testframework/ScenarioRunner.java 2010-10-21 04:45:41 UTC (rev 35628)
+++ labs/jbossrules/trunk/drools-ide-common/src/main/java/org/drools/testframework/ScenarioRunner.java 2010-10-21 05:37:03 UTC (rev 35629)
@@ -207,9 +207,9 @@
this.workingMemory.fireAllRules( listener.getAgendaFilter( ruleList,
scenario.inclusive ),
scenario.maxRuleFirings );
- executionTrace.executionTimeResult = System.currentTimeMillis() - time;
- executionTrace.numberOfRulesFired = listener.totalFires;
- executionTrace.rulesFired = listener.getRulesFiredSummary();
+ executionTrace.setExecutionTimeResult( System.currentTimeMillis() - time );
+ executionTrace.setNumberOfRulesFired( listener.totalFires );
+ executionTrace.setRulesFired( listener.getRulesFiredSummary() );
} else if ( fixture instanceof Expectation ) {
doPopulate( toPopulate );
@@ -249,9 +249,9 @@
private void applyTimeMachine(final InternalWorkingMemory wm,
ExecutionTrace executionTrace) {
- if ( executionTrace.scenarioSimulatedDate != null ) {
+ if ( executionTrace.getScenarioSimulatedDate() != null ) {
final Calendar now = Calendar.getInstance();
- now.setTimeInMillis( executionTrace.scenarioSimulatedDate.getTime() );
+ now.setTimeInMillis( executionTrace.getScenarioSimulatedDate().getTime() );
wm.setTimeMachine( new TimeMachine() {
@Override
public Calendar getNow() {
Modified: labs/jbossrules/trunk/drools-ide-common/src/test/java/org/drools/ide/common/modeldriven/dt/GuidedDecisionTableTest.java
===================================================================
--- labs/jbossrules/trunk/drools-ide-common/src/test/java/org/drools/ide/common/modeldriven/dt/GuidedDecisionTableTest.java 2010-10-21 04:45:41 UTC (rev 35628)
+++ labs/jbossrules/trunk/drools-ide-common/src/test/java/org/drools/ide/common/modeldriven/dt/GuidedDecisionTableTest.java 2010-10-21 05:37:03 UTC (rev 35629)
@@ -95,64 +95,64 @@
//add cols for LHS
ConditionCol c1 = new ConditionCol();
- c1.boundName = "c1";
- c1.factType = "Driver";
- c1.factField = "name";
- c1.constraintValueType = BaseSingleFieldConstraint.TYPE_LITERAL;
- dt.conditionCols.add(c1);
+ c1.setBoundName( "c1" );
+ c1.setFactType( "Driver" );
+ c1.setFactField( "name" );
+ c1.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
+ dt.getConditionCols().add(c1);
ConditionCol c1_ = new ConditionCol();
- c1_.boundName = "c1";
- c1_.factType = "Driver";
- c1_.factField = "name";
- c1_.constraintValueType = BaseSingleFieldConstraint.TYPE_RET_VALUE;
+ c1_.setBoundName( "c1" );
+ c1_.setFactType( "Driver" );
+ c1_.setFactField( "name" );
+ c1_.setConstraintValueType( BaseSingleFieldConstraint.TYPE_RET_VALUE );
- dt.conditionCols.add(c1_);
+ dt.getConditionCols().add(c1_);
ConditionCol c1__ = new ConditionCol();
- c1__.boundName = "c1";
- c1__.factType = "Driver";
- c1__.factField = "name";
- c1__.constraintValueType = BaseSingleFieldConstraint.TYPE_LITERAL;
- c1__.valueList = "one,two,three";
- dt.conditionCols.add(c1__);
+ c1__.setBoundName( "c1" );
+ c1__.setFactType( "Driver" );
+ c1__.setFactField( "name" );
+ c1__.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
+ c1__.setValueList( "one,two,three" );
+ dt.getConditionCols().add(c1__);
ConditionCol c2 = new ConditionCol();
- c2.boundName = "c2";
- c2.factType = "Driver";
- c2.factField = "nothing";
- c2.constraintValueType = BaseSingleFieldConstraint.TYPE_LITERAL;
- dt.conditionCols.add(c2);
+ c2.setBoundName( "c2" );
+ c2.setFactType( "Driver" );
+ c2.setFactField( "nothing" );
+ c2.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
+ dt.getConditionCols().add(c2);
ActionSetFieldCol asf = new ActionSetFieldCol();
- asf.boundName = "c1";
- asf.factField = "name";
- dt.actionCols.add(asf);
+ asf.setBoundName( "c1" );
+ asf.setFactField( "name" );
+ dt.getActionCols().add(asf);
ActionInsertFactCol ins = new ActionInsertFactCol();
- ins.boundName = "x";
- ins.factField = "rating";
- ins.factType = "Person";
- dt.actionCols.add(ins);
+ ins.setBoundName( "x" );
+ ins.setFactField( "rating" );
+ ins.setFactType( "Person" );
+ dt.getActionCols().add(ins);
ActionInsertFactCol ins_ = new ActionInsertFactCol();
- ins_.boundName = "x";
- ins_.factField = "rating";
- ins_.factType = "Person";
- ins_.valueList = "one,two,three";
- dt.actionCols.add(ins_);
+ ins_.setBoundName( "x" );
+ ins_.setFactField( "rating" );
+ ins_.setFactType( "Person" );
+ ins_.setValueList( "one,two,three" );
+ dt.getActionCols().add(ins_);
ActionSetFieldCol asf_ = new ActionSetFieldCol();
- asf_.boundName = "c1";
- asf_.factField = "goo";
- dt.actionCols.add(asf_);
+ asf_.setBoundName( "c1" );
+ asf_.setFactField( "goo" );
+ dt.getActionCols().add(asf_);
ActionSetFieldCol asf__ = new ActionSetFieldCol();
- asf__.boundName = "c1";
- asf__.factField = "goo";
- asf__.valueList = "one,two,three";
- dt.actionCols.add(asf__);
+ asf__.setBoundName( "c1" );
+ asf__.setFactField( "goo" );
+ asf__.setValueList( "one,two,three" );
+ dt.getActionCols().add(asf__);
SuggestionCompletionEngine sce = new SuggestionCompletionEngine();
@@ -204,7 +204,7 @@
AttributeCol at = new AttributeCol();
at.attr = "no-loop";
- dt.attributeCols.add(at);
+ dt.getAttributeCols().add(at);
r = dt.getValueList(at, sce);
assertEquals(2, r.length);
@@ -239,53 +239,53 @@
AttributeCol at_ = new AttributeCol();
at_.attr = "enabled";
- dt.attributeCols.add(at);
- dt.attributeCols.add(at_);
+ dt.getAttributeCols().add(at);
+ dt.getAttributeCols().add(at_);
ConditionCol c1 = new ConditionCol();
- c1.boundName = "c1";
- c1.factType = "Driver";
- c1.factField = "name";
- c1.operator = "==";
- c1.constraintValueType = BaseSingleFieldConstraint.TYPE_LITERAL;
- dt.conditionCols.add(c1);
+ c1.setBoundName( "c1" );
+ c1.setFactType( "Driver" );
+ c1.setFactField( "name" );
+ c1.setOperator( "==" );
+ c1.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
+ dt.getConditionCols().add(c1);
ConditionCol c1_ = new ConditionCol();
- c1_.boundName = "c1";
- c1_.factType = "Driver";
- c1_.factField = "age";
- c1_.operator = "==";
- c1_.constraintValueType = BaseSingleFieldConstraint.TYPE_LITERAL;
- dt.conditionCols.add(c1_);
+ c1_.setBoundName( "c1" );
+ c1_.setFactType( "Driver" );
+ c1_.setFactField( "age" );
+ c1_.setOperator( "==" );
+ c1_.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
+ dt.getConditionCols().add(c1_);
ConditionCol c2 = new ConditionCol();
- c2.boundName = "c1";
- c2.factType = "Driver";
- c2.factField = "age";
- c2.constraintValueType = BaseSingleFieldConstraint.TYPE_LITERAL;
- dt.conditionCols.add(c2);
+ c2.setBoundName( "c1" );
+ c2.setFactType( "Driver" );
+ c2.setFactField( "age" );
+ c2.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
+ dt.getConditionCols().add(c2);
ActionSetFieldCol a = new ActionSetFieldCol();
- a.boundName = "c1";
- a.factField = "name";
- dt.actionCols.add(a);
+ a.setBoundName( "c1" );
+ a.setFactField( "name" );
+ dt.getActionCols().add(a);
ActionSetFieldCol a2 = new ActionSetFieldCol();
- a2.boundName = "c1";
- a2.factField = "age";
- dt.actionCols.add(a2);
+ a2.setBoundName( "c1" );
+ a2.setFactField( "age" );
+ dt.getActionCols().add(a2);
ActionInsertFactCol ins = new ActionInsertFactCol();
- ins.boundName = "x";
- ins.factType = "Driver";
- ins.factField = "name";
- dt.actionCols.add(ins);
+ ins.setBoundName( "x" );
+ ins.setFactType( "Driver" );
+ ins.setFactField( "name" );
+ dt.getActionCols().add(ins);
ActionInsertFactCol ins_ = new ActionInsertFactCol();
- ins_.boundName = "x";
- ins_.factType = "Driver";
- ins_.factField = "age";
- dt.actionCols.add(ins_);
+ ins_.setBoundName( "x" );
+ ins_.setFactType( "Driver" );
+ ins_.setFactField( "age" );
+ dt.getActionCols().add(ins_);
assertTrue(dt.isNumeric(at, sce));
assertFalse(dt.isNumeric(at_, sce));
@@ -320,69 +320,69 @@
AttributeCol enabledAttribute = new AttributeCol();
enabledAttribute.attr = "enabled";
- dt.attributeCols.add(salienceAttribute);
- dt.attributeCols.add(enabledAttribute);
+ dt.getAttributeCols().add(salienceAttribute);
+ dt.getAttributeCols().add(enabledAttribute);
ConditionCol conditionColName = new ConditionCol();
- conditionColName.boundName = "c1";
- conditionColName.factType = "Driver";
- conditionColName.factField = "name";
- conditionColName.operator = "==";
- conditionColName.constraintValueType = BaseSingleFieldConstraint.TYPE_LITERAL;
- dt.conditionCols.add(conditionColName);
+ conditionColName.setBoundName( "c1" );
+ conditionColName.setFactType( "Driver" );
+ conditionColName.setFactField( "name" );
+ conditionColName.setOperator( "==" );
+ conditionColName.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
+ dt.getConditionCols().add(conditionColName);
ConditionCol conditionColAge = new ConditionCol();
- conditionColAge.boundName = "c1";
- conditionColAge.factType = "Driver";
- conditionColAge.factField = "age";
- conditionColAge.operator = "==";
- conditionColAge.constraintValueType = BaseSingleFieldConstraint.TYPE_LITERAL;
- dt.conditionCols.add(conditionColAge);
+ conditionColAge.setBoundName( "c1" );
+ conditionColAge.setFactType( "Driver" );
+ conditionColAge.setFactField( "age" );
+ conditionColAge.setOperator( "==" );
+ conditionColAge.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
+ dt.getConditionCols().add(conditionColAge);
ConditionCol conditionColDate = new ConditionCol();
- conditionColDate.boundName = "c1";
- conditionColDate.factType = "Driver";
- conditionColDate.factField = "date";
- conditionColDate.operator = "==";
- conditionColDate.constraintValueType = BaseSingleFieldConstraint.TYPE_LITERAL;
- dt.conditionCols.add(conditionColDate);
+ conditionColDate.setBoundName( "c1" );
+ conditionColDate.setFactType( "Driver" );
+ conditionColDate.setFactField( "date" );
+ conditionColDate.setOperator( "==" );
+ conditionColDate.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
+ dt.getConditionCols().add(conditionColDate);
ConditionCol conditionColApproved = new ConditionCol();
- conditionColApproved.boundName = "c1";
- conditionColApproved.factType = "Driver";
- conditionColApproved.factField = "approved";
- conditionColApproved.operator = "==";
- conditionColApproved.constraintValueType = BaseSingleFieldConstraint.TYPE_LITERAL;
- dt.conditionCols.add(conditionColApproved);
+ conditionColApproved.setBoundName( "c1" );
+ conditionColApproved.setFactType( "Driver" );
+ conditionColApproved.setFactField( "approved" );
+ conditionColApproved.setOperator( "==" );
+ conditionColApproved.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
+ dt.getConditionCols().add(conditionColApproved);
ConditionCol conditionColAge2 = new ConditionCol();
- conditionColAge2.boundName = "c1";
- conditionColAge2.factType = "Driver";
- conditionColAge2.factField = "age";
- conditionColAge2.constraintValueType = BaseSingleFieldConstraint.TYPE_LITERAL;
- dt.conditionCols.add(conditionColAge2);
+ conditionColAge2.setBoundName( "c1" );
+ conditionColAge2.setFactType( "Driver" );
+ conditionColAge2.setFactField( "age" );
+ conditionColAge2.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
+ dt.getConditionCols().add(conditionColAge2);
ActionSetFieldCol a = new ActionSetFieldCol();
- a.boundName = "c1";
- a.factField = "name";
- dt.actionCols.add(a);
+ a.setBoundName( "c1" );
+ a.setFactField( "name" );
+ dt.getActionCols().add(a);
ActionSetFieldCol a2 = new ActionSetFieldCol();
- a2.boundName = "c1";
- a2.factField = "age";
- dt.actionCols.add(a2);
+ a2.setBoundName( "c1" );
+ a2.setFactField( "age" );
+ dt.getActionCols().add(a2);
ActionInsertFactCol ins = new ActionInsertFactCol();
- ins.boundName = "x";
- ins.factType = "Driver";
- ins.factField = "name";
- dt.actionCols.add(ins);
+ ins.setBoundName( "x" );
+ ins.setFactType( "Driver" );
+ ins.setFactField( "name" );
+ dt.getActionCols().add(ins);
ActionInsertFactCol ins_ = new ActionInsertFactCol();
- ins_.boundName = "x";
- ins_.factType = "Driver";
- ins_.factField = "age";
- dt.actionCols.add(ins_);
+ ins_.setBoundName( "x" );
+ ins_.setFactType( "Driver" );
+ ins_.setFactField( "age" );
+ dt.getActionCols().add(ins_);
assertEquals("salience", dt.getType(salienceAttribute, sce));
assertEquals("enabled", dt.getType(enabledAttribute, sce));
@@ -402,17 +402,17 @@
//add cols for LHS
ConditionCol c1 = new ConditionCol();
- c1.boundName = "c1";
- c1.factType = "Driver";
- c1.constraintValueType = BaseSingleFieldConstraint.TYPE_LITERAL;
- dt.conditionCols.add(c1);
+ c1.setBoundName( "c1" );
+ c1.setFactType( "Driver" );
+ c1.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
+ dt.getConditionCols().add(c1);
ConditionCol c2 = new ConditionCol();
- c2.boundName = "c2";
- c2.factType = "Driver";
- c2.constraintValueType = BaseSingleFieldConstraint.TYPE_LITERAL;
- c2.valueList = "a,b,c";
- dt.conditionCols.add(c2);
+ c2.setBoundName( "c2" );
+ c2.setFactType( "Driver" );
+ c2.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
+ c2.setValueList( "a,b,c" );
+ dt.getConditionCols().add(c2);
SuggestionCompletionEngine sce = new SuggestionCompletionEngine();
@@ -429,10 +429,10 @@
//add cols for LHS
ConditionCol c1 = new ConditionCol();
- c1.boundName = "c1";
- c1.factType = "Driver";
- c1.constraintValueType = BaseSingleFieldConstraint.TYPE_LITERAL;
- dt.conditionCols.add(c1);
+ c1.setBoundName( "c1" );
+ c1.setFactType( "Driver" );
+ c1.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
+ dt.getConditionCols().add(c1);
SuggestionCompletionEngine sce = new SuggestionCompletionEngine();
Modified: labs/jbossrules/trunk/drools-ide-common/src/test/java/org/drools/ide/common/server/util/GuidedDTDRLPersistenceTest.java
===================================================================
--- labs/jbossrules/trunk/drools-ide-common/src/test/java/org/drools/ide/common/server/util/GuidedDTDRLPersistenceTest.java 2010-10-21 04:45:41 UTC (rev 35628)
+++ labs/jbossrules/trunk/drools-ide-common/src/test/java/org/drools/ide/common/server/util/GuidedDTDRLPersistenceTest.java 2010-10-21 05:37:03 UTC (rev 35629)
@@ -47,78 +47,78 @@
public void test2Rules() throws Exception {
GuidedDecisionTable dt = new GuidedDecisionTable();
- dt.tableName = "michael";
+ dt.setTableName( "michael" );
AttributeCol attr = new AttributeCol();
attr.attr = "salience";
- attr.defaultValue = "66";
- dt.attributeCols.add(attr);
+ attr.setDefaultValue( "66" );
+ dt.getAttributeCols().add(attr);
ConditionCol con = new ConditionCol();
- con.boundName = "f1";
- con.constraintValueType = BaseSingleFieldConstraint.TYPE_LITERAL;
- con.factField = "age";
- con.factType = "Driver";
- con.header = "Driver f1 age";
- con.operator = "==";
- dt.conditionCols.add(con);
+ con.setBoundName( "f1" );
+ con.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
+ con.setFactField( "age" );
+ con.setFactType( "Driver" );
+ con.setHeader( "Driver f1 age" );
+ con.setOperator( "==" );
+ dt.getConditionCols().add(con);
ConditionCol con2 = new ConditionCol();
- con2.boundName = "f1";
- con2.constraintValueType = BaseSingleFieldConstraint.TYPE_LITERAL;
- con2.factField = "name";
- con2.factType = "Driver";
- con2.header = "Driver f1 name";
- con2.operator = "==";
- dt.conditionCols.add(con2);
+ con2.setBoundName( "f1" );
+ con2.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
+ con2.setFactField( "name" );
+ con2.setFactType( "Driver" );
+ con2.setHeader( "Driver f1 name" );
+ con2.setOperator( "==" );
+ dt.getConditionCols().add(con2);
ConditionCol con3 = new ConditionCol();
- con3.boundName = "f1";
- con3.constraintValueType = BaseSingleFieldConstraint.TYPE_RET_VALUE;
- con3.factField = "rating";
- con3.factType = "Driver";
- con3.header = "Driver rating";
- con3.operator = "==";
- dt.conditionCols.add(con3);
+ con3.setBoundName( "f1" );
+ con3.setConstraintValueType( BaseSingleFieldConstraint.TYPE_RET_VALUE );
+ con3.setFactField( "rating" );
+ con3.setFactType( "Driver" );
+ con3.setHeader( "Driver rating" );
+ con3.setOperator( "==" );
+ dt.getConditionCols().add(con3);
ConditionCol con4 = new ConditionCol();
- con4.boundName = "f2";
- con4.constraintValueType = BaseSingleFieldConstraint.TYPE_PREDICATE;
- con4.factType = "Driver";
- con4.header = "Driver 2 pimp";
- con4.factField = "(not needed)";
- dt.conditionCols.add(con4);
+ con4.setBoundName( "f2" );
+ con4.setConstraintValueType( BaseSingleFieldConstraint.TYPE_PREDICATE );
+ con4.setFactType( "Driver" );
+ con4.setHeader( "Driver 2 pimp" );
+ con4.setFactField( "(not needed)" );
+ dt.getConditionCols().add(con4);
ActionInsertFactCol ins = new ActionInsertFactCol();
- ins.boundName = "ins";
- ins.factType = "Cheese";
- ins.factField = "price";
- ins.type = SuggestionCompletionEngine.TYPE_NUMERIC;
- dt.actionCols.add(ins);
+ ins.setBoundName( "ins" );
+ ins.setFactType( "Cheese" );
+ ins.setFactField( "price" );
+ ins.setType( SuggestionCompletionEngine.TYPE_NUMERIC );
+ dt.getActionCols().add(ins);
ActionRetractFactCol ret = new ActionRetractFactCol();
ret.boundName = "f2";
- dt.actionCols.add(ret);
+ dt.getActionCols().add(ret);
ActionSetFieldCol set = new ActionSetFieldCol();
- set.boundName = "f1";
- set.factField = "goo1";
- set.type = SuggestionCompletionEngine.TYPE_STRING;
- dt.actionCols.add(set);
+ set.setBoundName( "f1" );
+ set.setFactField( "goo1" );
+ set.setType( SuggestionCompletionEngine.TYPE_STRING );
+ dt.getActionCols().add(set);
ActionSetFieldCol set2 = new ActionSetFieldCol();
- set2.boundName = "f1";
- set2.factField = "goo2";
- set2.defaultValue = "whee";
- set2.type = SuggestionCompletionEngine.TYPE_STRING;
- dt.actionCols.add(set2);
+ set2.setBoundName( "f1" );
+ set2.setFactField( "goo2" );
+ set2.setDefaultValue( "whee" );
+ set2.setType( SuggestionCompletionEngine.TYPE_STRING );
+ dt.getActionCols().add(set2);
- dt.data = new String[][] {
+ dt.setData( new String[][] {
new String[] {"1", "desc", "42", "33", "michael", "age * 0.2", "age > 7", "6.60", "true", "gooVal1", null},
new String[] {"2", "desc", "", "39", "bob", "age * 0.3", "age > 7", "6.60", "", "gooVal1", ""}
- };
+ } );
@@ -139,78 +139,78 @@
public void testInterpolate() {
GuidedDecisionTable dt = new GuidedDecisionTable();
- dt.tableName = "michael";
+ dt.setTableName( "michael" );
AttributeCol attr = new AttributeCol();
attr.attr = "salience";
- attr.defaultValue = "66";
- dt.attributeCols.add(attr);
+ attr.setDefaultValue( "66" );
+ dt.getAttributeCols().add(attr);
ConditionCol con = new ConditionCol();
- con.boundName = "f1";
- con.constraintValueType = BaseSingleFieldConstraint.TYPE_LITERAL;
- con.factField = "age";
- con.factType = "Driver";
- con.header = "Driver f1 age";
- con.operator = "==";
- dt.conditionCols.add(con);
+ con.setBoundName( "f1" );
+ con.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
+ con.setFactField( "age" );
+ con.setFactType( "Driver" );
+ con.setHeader( "Driver f1 age" );
+ con.setOperator( "==" );
+ dt.getConditionCols().add(con);
ConditionCol con2 = new ConditionCol();
- con2.boundName = "f1";
- con2.constraintValueType = BaseSingleFieldConstraint.TYPE_LITERAL;
- con2.factField = "name";
- con2.factType = "Driver";
- con2.header = "Driver f1 name";
- con2.operator = "==";
- dt.conditionCols.add(con2);
+ con2.setBoundName( "f1" );
+ con2.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
+ con2.setFactField( "name" );
+ con2.setFactType( "Driver" );
+ con2.setHeader( "Driver f1 name" );
+ con2.setOperator( "==" );
+ dt.getConditionCols().add(con2);
ConditionCol con3 = new ConditionCol();
- con3.boundName = "f1";
- con3.constraintValueType = BaseSingleFieldConstraint.TYPE_RET_VALUE;
- con3.factField = "rating";
- con3.factType = "Driver";
- con3.header = "Driver rating";
- con3.operator = "==";
- dt.conditionCols.add(con3);
+ con3.setBoundName( "f1" );
+ con3.setConstraintValueType( BaseSingleFieldConstraint.TYPE_RET_VALUE );
+ con3.setFactField( "rating" );
+ con3.setFactType( "Driver" );
+ con3.setHeader( "Driver rating" );
+ con3.setOperator( "==" );
+ dt.getConditionCols().add(con3);
ConditionCol con4 = new ConditionCol();
- con4.boundName = "f2";
- con4.constraintValueType = BaseSingleFieldConstraint.TYPE_PREDICATE;
- con4.factType = "Driver";
- con4.header = "Driver 2 pimp";
- con4.factField = "this.hasSomething($param)";
- dt.conditionCols.add(con4);
+ con4.setBoundName( "f2" );
+ con4.setConstraintValueType( BaseSingleFieldConstraint.TYPE_PREDICATE );
+ con4.setFactType( "Driver" );
+ con4.setHeader( "Driver 2 pimp" );
+ con4.setFactField( "this.hasSomething($param)" );
+ dt.getConditionCols().add(con4);
ActionInsertFactCol ins = new ActionInsertFactCol();
- ins.boundName = "ins";
- ins.factType = "Cheese";
- ins.factField = "price";
- ins.type = SuggestionCompletionEngine.TYPE_NUMERIC;
- dt.actionCols.add(ins);
+ ins.setBoundName( "ins" );
+ ins.setFactType( "Cheese" );
+ ins.setFactField( "price" );
+ ins.setType( SuggestionCompletionEngine.TYPE_NUMERIC );
+ dt.getActionCols().add(ins);
ActionRetractFactCol ret = new ActionRetractFactCol();
ret.boundName = "f2";
- dt.actionCols.add(ret);
+ dt.getActionCols().add(ret);
ActionSetFieldCol set = new ActionSetFieldCol();
- set.boundName = "f1";
- set.factField = "goo1";
- set.type = SuggestionCompletionEngine.TYPE_STRING;
- dt.actionCols.add(set);
+ set.setBoundName( "f1" );
+ set.setFactField( "goo1" );
+ set.setType( SuggestionCompletionEngine.TYPE_STRING );
+ dt.getActionCols().add(set);
ActionSetFieldCol set2 = new ActionSetFieldCol();
- set2.boundName = "f1";
- set2.factField = "goo2";
- set2.defaultValue = "whee";
- set2.type = SuggestionCompletionEngine.TYPE_STRING;
- dt.actionCols.add(set2);
+ set2.setBoundName( "f1" );
+ set2.setFactField( "goo2" );
+ set2.setDefaultValue( "whee" );
+ set2.setType( SuggestionCompletionEngine.TYPE_STRING );
+ dt.getActionCols().add(set2);
- dt.data = new String[][] {
+ dt.setData( new String[][] {
new String[] {"1", "desc", "42", "33", "michael", "age * 0.2", "BAM", "6.60", "true", "gooVal1", null},
new String[] {"2", "desc", "", "39", "bob", "age * 0.3", "BAM", "6.60", "", "gooVal1", ""}
- };
+ } );
@@ -231,78 +231,78 @@
public void testInOperator() {
GuidedDecisionTable dt = new GuidedDecisionTable();
- dt.tableName = "michael";
+ dt.setTableName( "michael" );
AttributeCol attr = new AttributeCol();
attr.attr = "salience";
- attr.defaultValue = "66";
- dt.attributeCols.add(attr);
+ attr.setDefaultValue( "66" );
+ dt.getAttributeCols().add(attr);
ConditionCol con = new ConditionCol();
- con.boundName = "f1";
- con.constraintValueType = BaseSingleFieldConstraint.TYPE_LITERAL;
- con.factField = "age";
- con.factType = "Driver";
- con.header = "Driver f1 age";
- con.operator = "==";
- dt.conditionCols.add(con);
+ con.setBoundName( "f1" );
+ con.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
+ con.setFactField( "age" );
+ con.setFactType( "Driver" );
+ con.setHeader( "Driver f1 age" );
+ con.setOperator( "==" );
+ dt.getConditionCols().add(con);
ConditionCol con2 = new ConditionCol();
- con2.boundName = "f1";
- con2.constraintValueType = BaseSingleFieldConstraint.TYPE_LITERAL;
- con2.factField = "name";
- con2.factType = "Driver";
- con2.header = "Driver f1 name";
- con2.operator = "in";
- dt.conditionCols.add(con2);
+ con2.setBoundName( "f1" );
+ con2.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
+ con2.setFactField( "name" );
+ con2.setFactType( "Driver" );
+ con2.setHeader( "Driver f1 name" );
+ con2.setOperator( "in" );
+ dt.getConditionCols().add(con2);
ConditionCol con3 = new ConditionCol();
- con3.boundName = "f1";
- con3.constraintValueType = BaseSingleFieldConstraint.TYPE_RET_VALUE;
- con3.factField = "rating";
- con3.factType = "Driver";
- con3.header = "Driver rating";
- con3.operator = "==";
- dt.conditionCols.add(con3);
+ con3.setBoundName( "f1" );
+ con3.setConstraintValueType( BaseSingleFieldConstraint.TYPE_RET_VALUE );
+ con3.setFactField( "rating" );
+ con3.setFactType( "Driver" );
+ con3.setHeader( "Driver rating" );
+ con3.setOperator( "==" );
+ dt.getConditionCols().add(con3);
ConditionCol con4 = new ConditionCol();
- con4.boundName = "f2";
- con4.constraintValueType = BaseSingleFieldConstraint.TYPE_PREDICATE;
- con4.factType = "Driver";
- con4.header = "Driver 2 pimp";
- con4.factField = "(not needed)";
- dt.conditionCols.add(con4);
+ con4.setBoundName( "f2" );
+ con4.setConstraintValueType( BaseSingleFieldConstraint.TYPE_PREDICATE );
+ con4.setFactType( "Driver" );
+ con4.setHeader( "Driver 2 pimp" );
+ con4.setFactField( "(not needed)" );
+ dt.getConditionCols().add(con4);
ActionInsertFactCol ins = new ActionInsertFactCol();
- ins.boundName = "ins";
- ins.factType = "Cheese";
- ins.factField = "price";
- ins.type = SuggestionCompletionEngine.TYPE_NUMERIC;
- dt.actionCols.add(ins);
+ ins.setBoundName( "ins" );
+ ins.setFactType( "Cheese" );
+ ins.setFactField( "price" );
+ ins.setType( SuggestionCompletionEngine.TYPE_NUMERIC );
+ dt.getActionCols().add(ins);
ActionRetractFactCol ret = new ActionRetractFactCol();
ret.boundName = "f2";
- dt.actionCols.add(ret);
+ dt.getActionCols().add(ret);
ActionSetFieldCol set = new ActionSetFieldCol();
- set.boundName = "f1";
- set.factField = "goo1";
- set.type = SuggestionCompletionEngine.TYPE_STRING;
- dt.actionCols.add(set);
+ set.setBoundName( "f1" );
+ set.setFactField( "goo1" );
+ set.setType( SuggestionCompletionEngine.TYPE_STRING );
+ dt.getActionCols().add(set);
ActionSetFieldCol set2 = new ActionSetFieldCol();
- set2.boundName = "f1";
- set2.factField = "goo2";
- set2.defaultValue = "whee";
- set2.type = SuggestionCompletionEngine.TYPE_STRING;
- dt.actionCols.add(set2);
+ set2.setBoundName( "f1" );
+ set2.setFactField( "goo2" );
+ set2.setDefaultValue( "whee" );
+ set2.setType( SuggestionCompletionEngine.TYPE_STRING );
+ dt.getActionCols().add(set2);
- dt.data = new String[][] {
+ dt.setData( new String[][] {
new String[] {"1", "desc", "42", "33", "michael, manik", "age * 0.2", "age > 7", "6.60", "true", "gooVal1", null},
new String[] {"2", "desc", "", "39", "bob, frank", "age * 0.3", "age > 7", "6.60", "", "gooVal1", ""}
- };
+ } );
@@ -416,33 +416,33 @@
List<ConditionCol> cols = new ArrayList<ConditionCol>();
ConditionCol col = new ConditionCol();
- col.boundName = "p1";
- col.factType = "Person";
- col.factField = "name";
- col.constraintValueType = BaseSingleFieldConstraint.TYPE_LITERAL;
- col.operator = "==";
+ col.setBoundName( "p1" );
+ col.setFactType( "Person" );
+ col.setFactField( "name" );
+ col.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
+ col.setOperator( "==" );
cols.add(col);
ConditionCol col2 = new ConditionCol();
- col2.boundName = "p1";
- col2.factType = "Person";
- col2.factField = "age";
- col2.constraintValueType = BaseSingleFieldConstraint.TYPE_RET_VALUE;
- col2.operator = "<";
+ col2.setBoundName( "p1" );
+ col2.setFactType( "Person" );
+ col2.setFactField( "age" );
+ col2.setConstraintValueType( BaseSingleFieldConstraint.TYPE_RET_VALUE );
+ col2.setOperator( "<" );
cols.add(col2);
ConditionCol col3 = new ConditionCol();
- col3.boundName = "p1";
- col3.factType = "Person";
- col3.constraintValueType = BaseSingleFieldConstraint.TYPE_PREDICATE;
+ col3.setBoundName( "p1" );
+ col3.setFactType( "Person" );
+ col3.setConstraintValueType( BaseSingleFieldConstraint.TYPE_PREDICATE );
cols.add(col3);
ConditionCol col4 = new ConditionCol();
- col4.boundName = "c";
- col4.factType = "Cheese";
- col4.factField = "type";
- col4.operator = "==";
- col4.constraintValueType = BaseSingleFieldConstraint.TYPE_LITERAL;
+ col4.setBoundName( "c" );
+ col4.setFactType( "Cheese" );
+ col4.setFactField( "type" );
+ col4.setOperator( "==" );
+ col4.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
cols.add(col4);
RuleModel rm = new RuleModel();
@@ -492,17 +492,17 @@
List<ActionCol> cols = new ArrayList<ActionCol>();
ActionSetFieldCol asf1 = new ActionSetFieldCol();
- asf1.boundName = "a";
- asf1.factField = "field1";
+ asf1.setBoundName( "a" );
+ asf1.setFactField( "field1" );
- asf1.type = SuggestionCompletionEngine.TYPE_STRING;
+ asf1.setType( SuggestionCompletionEngine.TYPE_STRING );
cols.add(asf1);
ActionSetFieldCol asf2 = new ActionSetFieldCol();
- asf2.boundName = "a";
- asf2.factField = "field2";
- asf2.update = true;
- asf2.type = SuggestionCompletionEngine.TYPE_NUMERIC;
+ asf2.setBoundName( "a" );
+ asf2.setFactField( "field2" );
+ asf2.setUpdate( true );
+ asf2.setType( SuggestionCompletionEngine.TYPE_NUMERIC );
cols.add(asf2);
ActionRetractFactCol ret = new ActionRetractFactCol();
@@ -510,17 +510,17 @@
cols.add(ret);
ActionInsertFactCol ins1 = new ActionInsertFactCol();
- ins1.boundName = "ins";
- ins1.factType = "Cheese";
- ins1.factField = "price";
- ins1.type = SuggestionCompletionEngine.TYPE_NUMERIC;
+ ins1.setBoundName( "ins" );
+ ins1.setFactType( "Cheese" );
+ ins1.setFactField( "price" );
+ ins1.setType( SuggestionCompletionEngine.TYPE_NUMERIC );
cols.add(ins1);
ActionInsertFactCol ins2 = new ActionInsertFactCol();
- ins2.boundName = "ins";
- ins2.factType = "Cheese";
- ins2.factField = "type";
- ins2.type = SuggestionCompletionEngine.TYPE_NUMERIC;
+ ins2.setBoundName( "ins" );
+ ins2.setFactType( "Cheese" );
+ ins2.setFactField( "type" );
+ ins2.setType( SuggestionCompletionEngine.TYPE_NUMERIC );
cols.add(ins2);
@@ -565,21 +565,21 @@
public void testNoConstraints() {
GuidedDecisionTable dt = new GuidedDecisionTable();
ConditionCol c = new ConditionCol();
- c.boundName = "x";
- c.factType = "Context";
- c.constraintValueType = BaseSingleFieldConstraint.TYPE_LITERAL;
- dt.conditionCols.add(c);
+ c.setBoundName( "x" );
+ c.setFactType( "Context" );
+ c.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
+ dt.getConditionCols().add(c);
ActionSetFieldCol asf = new ActionSetFieldCol();
- asf.boundName = "x";
- asf.factField = "age";
- asf.type = "String";
+ asf.setBoundName( "x" );
+ asf.setFactField( "age" );
+ asf.setType( "String" );
- dt.actionCols.add(asf);
+ dt.getActionCols().add(asf);
String[][] data = new String[][] {
new String[] {"1", "desc", "y", "old"}
};
- dt.data = data;
+ dt.setData( data );
String drl = GuidedDTDRLPersistence.getInstance().marshal(dt);
@@ -589,9 +589,9 @@
assertTrue(drl.indexOf("x.setAge") > drl.indexOf("Context( )"));
assertFalse(drl.indexOf("update( x );") > -1);
- dt.data = new String[][] {
+ dt.setData( new String[][] {
new String[] {"1", "desc", "", "old"}
- };
+ } );
drl = GuidedDTDRLPersistence.getInstance().marshal(dt);
assertEquals(-1, drl.indexOf("Context( )"));
@@ -601,22 +601,22 @@
public void testUpdateModify() {
GuidedDecisionTable dt = new GuidedDecisionTable();
ConditionCol c = new ConditionCol();
- c.boundName = "x";
- c.factType = "Context";
- c.constraintValueType = BaseSingleFieldConstraint.TYPE_LITERAL;
- dt.conditionCols.add(c);
+ c.setBoundName( "x" );
+ c.setFactType( "Context" );
+ c.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
+ dt.getConditionCols().add(c);
ActionSetFieldCol asf = new ActionSetFieldCol();
- asf.boundName = "x";
- asf.factField = "age";
- asf.type = "String";
- asf.update = true;
+ asf.setBoundName( "x" );
+ asf.setFactField( "age" );
+ asf.setType( "String" );
+ asf.setUpdate( true );
- dt.actionCols.add(asf);
+ dt.getActionCols().add(asf);
String[][] data = new String[][] {
new String[] {"1", "desc", "y", "old"}
};
- dt.data = data;
+ dt.setData( data );
String drl = GuidedDTDRLPersistence.getInstance().marshal(dt);
@@ -626,9 +626,9 @@
assertTrue(drl.indexOf("x.setAge") > drl.indexOf("Context( )"));
- dt.data = new String[][] {
+ dt.setData( new String[][] {
new String[] {"1", "desc", "", "old"}
- };
+ } );
drl = GuidedDTDRLPersistence.getInstance().marshal(dt);
assertEquals(-1, drl.indexOf("Context( )"));
@@ -643,11 +643,11 @@
List<ConditionCol> cols = new ArrayList<ConditionCol>();
ConditionCol col2 = new ConditionCol();
- col2.boundName = "p1";
- col2.factType = "Person";
- col2.factField = "age";
- col2.constraintValueType = BaseSingleFieldConstraint.TYPE_LITERAL;
- col2.operator = "";
+ col2.setBoundName( "p1" );
+ col2.setFactType( "Person" );
+ col2.setFactField( "age" );
+ col2.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
+ col2.setOperator( "" );
cols.add(col2);
Modified: labs/jbossrules/trunk/drools-ide-common/src/test/java/org/drools/ide/common/server/util/GuidedDTXMLPersistenceTest.java
===================================================================
--- labs/jbossrules/trunk/drools-ide-common/src/test/java/org/drools/ide/common/server/util/GuidedDTXMLPersistenceTest.java 2010-10-21 04:45:41 UTC (rev 35628)
+++ labs/jbossrules/trunk/drools-ide-common/src/test/java/org/drools/ide/common/server/util/GuidedDTXMLPersistenceTest.java 2010-10-21 05:37:03 UTC (rev 35629)
@@ -43,22 +43,22 @@
GuidedDecisionTable dt = new GuidedDecisionTable();
- dt.actionCols.add(new ActionInsertFactCol());
+ dt.getActionCols().add(new ActionInsertFactCol());
ActionSetFieldCol set = new ActionSetFieldCol();
- set.factField = "foo";
- dt.actionCols.add(set);
+ set.setFactField( "foo" );
+ dt.getActionCols().add(set);
dt.getMetadataCols().add(new MetadataCol());
- dt.attributeCols.add(new AttributeCol());
+ dt.getAttributeCols().add(new AttributeCol());
- dt.conditionCols.add(new ConditionCol());
+ dt.getConditionCols().add(new ConditionCol());
- dt.data = new String[][] {
+ dt.setData( new String[][] {
new String[] {"hola"}
- };
- dt.tableName = "blah";
- dt.descriptionWidth = 42;
+ } );
+ dt.setTableName( "blah" );
+ dt.setDescriptionWidth( 42 );
String xml = GuidedDTXMLPersistence.getInstance().marshal(dt);
@@ -70,12 +70,12 @@
GuidedDecisionTable dt_ = GuidedDTXMLPersistence.getInstance().unmarshal(xml);
assertNotNull(dt_);
- assertEquals(42, dt_.descriptionWidth);
- assertEquals("blah", dt_.tableName);
+ assertEquals(42, dt_.getDescriptionWidth());
+ assertEquals("blah", dt_.getTableName());
assertEquals(1, dt_.getMetadataCols().size());
- assertEquals(1, dt_.attributeCols.size());
- assertEquals(2, dt_.actionCols.size());
- assertEquals(1, dt_.conditionCols.size());
+ assertEquals(1, dt_.getAttributeCols().size());
+ assertEquals(2, dt_.getActionCols().size());
+ assertEquals(1, dt_.getConditionCols().size());
}
@@ -83,17 +83,17 @@
String xml = BRLPersistenceTest.loadResource("ExistingDecisionTable.xml");
GuidedDecisionTable dt_ = GuidedDTXMLPersistence.getInstance().unmarshal(xml);
assertNotNull(dt_);
- assertEquals(42, dt_.descriptionWidth);
- assertEquals("blah", dt_.tableName);
+ assertEquals(42, dt_.getDescriptionWidth());
+ assertEquals("blah", dt_.getTableName());
assertEquals(1, dt_.getMetadataCols().size());
- assertEquals(1, dt_.attributeCols.size());
- assertEquals(2, dt_.actionCols.size());
- assertEquals(1, dt_.conditionCols.size());
+ assertEquals(1, dt_.getAttributeCols().size());
+ assertEquals(2, dt_.getActionCols().size());
+ assertEquals(1, dt_.getConditionCols().size());
- assertTrue(dt_.actionCols.get(1) instanceof ActionSetFieldCol );
- ActionSetFieldCol asf = (ActionSetFieldCol) dt_.actionCols.get(1);
- assertEquals("foo", asf.factField);
- assertEquals(false, asf.update);
+ assertTrue(dt_.getActionCols().get(1) instanceof ActionSetFieldCol );
+ ActionSetFieldCol asf = (ActionSetFieldCol) dt_.getActionCols().get(1);
+ assertEquals("foo", asf.getFactField());
+ assertEquals(false, asf.isUpdate());
}
}
Modified: labs/jbossrules/trunk/drools-ide-common/src/test/java/org/drools/testframework/ScenarioRunnerTest.java
===================================================================
--- labs/jbossrules/trunk/drools-ide-common/src/test/java/org/drools/testframework/ScenarioRunnerTest.java 2010-10-21 04:45:41 UTC (rev 35628)
+++ labs/jbossrules/trunk/drools-ide-common/src/test/java/org/drools/testframework/ScenarioRunnerTest.java 2010-10-21 05:37:03 UTC (rev 35629)
@@ -791,14 +791,14 @@
assertTrue( future > time );
ExecutionTrace ext = new ExecutionTrace();
- ext.scenarioSimulatedDate = new Date( "10-Jul-1974" );
+ ext.setScenarioSimulatedDate( new Date( "10-Jul-1974" ) );
sc.fixtures.add( ext );
run = new ScenarioRunner( sc,
null,
wm );
tm = run.workingMemory.getTimeMachine();
- long expected = ext.scenarioSimulatedDate.getTime();
+ long expected = ext.getScenarioSimulatedDate().getTime();
assertEquals( expected,
tm.getNow().getTimeInMillis() );
Thread.sleep( 50 );
@@ -945,7 +945,7 @@
(InternalWorkingMemory) wm );
assertEquals( 2,
- executionTrace.numberOfRulesFired.intValue() );
+ executionTrace.getNumberOfRulesFired().intValue() );
assertSame( run.scenario,
sc );
@@ -963,9 +963,9 @@
Thread.sleep( 50 );
assertTrue( (new Date()).after( sc.lastRunResult ) );
- assertTrue( executionTrace.executionTimeResult != null );
+ assertTrue( executionTrace.getExecutionTimeResult() != null );
- assertTrue( executionTrace.rulesFired.length > 0 );
+ assertTrue( executionTrace.getRulesFired().length > 0 );
}
@@ -1037,7 +1037,7 @@
(InternalWorkingMemory) wm );
assertEquals( sc.maxRuleFirings,
- executionTrace.numberOfRulesFired.intValue() );
+ executionTrace.getNumberOfRulesFired().intValue() );
}
@@ -1097,7 +1097,7 @@
(InternalWorkingMemory) wm );
assertEquals( 1,
- executionTrace.numberOfRulesFired.intValue() );
+ executionTrace.getNumberOfRulesFired().intValue() );
assertSame( run.scenario,
sc );
@@ -1162,7 +1162,7 @@
(InternalWorkingMemory) wm );
assertEquals( 0,
- executionTrace.numberOfRulesFired.intValue() );
+ executionTrace.getNumberOfRulesFired().intValue() );
assertSame( run.scenario,
sc );
@@ -1190,7 +1190,7 @@
(InternalWorkingMemory) wm );
assertEquals( 1,
- executionTrace.numberOfRulesFired.intValue() );
+ executionTrace.getNumberOfRulesFired().intValue() );
assertSame( run.scenario,
sc );
More information about the jboss-svn-commits
mailing list