[jboss-svn-commits] JBL Code SVN: r18710 - in labs/jbossrules/trunk/drools-decisiontables/src: main/java/org/drools/decisiontable/parser and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Mar 5 19:58:39 EST 2008
Author: michael.neale at jboss.com
Date: 2008-03-05 19:58:39 -0500 (Wed, 05 Mar 2008)
New Revision: 18710
Removed:
labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Duration.java
labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/model/DurationTest.java
Modified:
labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Rule.java
labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DefaultRuleSheetListener.java
labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/model/RuleRenderTest.java
Log:
JBRULES-1496 Duration not rendering correctly
Deleted: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Duration.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Duration.java 2008-03-05 20:53:57 UTC (rev 18709)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Duration.java 2008-03-06 00:58:39 UTC (rev 18710)
@@ -1,49 +0,0 @@
-package org.drools.decisiontable.model;
-
-/*
- * Copyright 2005 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/**
- * @author <a href="mailto:ricardo.rojas at bluesoft.cl"> Ricardo Rojas </a>
- *
- */
-public class Duration extends DRLElement
- implements
- DRLJavaEmitter {
-
- public String _snippet;
-
- /**
- * @param snippet
- * The snippet to set.
- */
- public void setSnippet(final String snippet) {
- this._snippet = snippet;
- }
-
- public String getSnippet() {
- return this._snippet;
- }
-
- public void renderDRL(final DRLOutput out) {
- if ( isCommented() ) {
- out.writeLine( "#" + getComment() );
- }
- out.writeLine( "\tduration " + this._snippet );
-
- }
-}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Rule.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Rule.java 2008-03-05 20:53:57 UTC (rev 18709)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Rule.java 2008-03-06 00:58:39 UTC (rev 18710)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,7 +23,7 @@
/**
* @author <a href="mailto:michael.neale at gmail.com"> Michael Neale </a>
- *
+ *
* Represents a rule.
*/
public class Rule extends DRLElement
@@ -36,7 +36,7 @@
private String _name;
- private Duration _duration; // RIK: New variable to the Rule class (Defines
+ private String _duration; // RIK: New variable to the Rule class (Defines
// a Duration tag for the rule)
private String _description; // RIK: New variable to the Rule class (Set
@@ -63,10 +63,10 @@
/**
* Create a new rule. Note that the rule name should be post-fixed with the row number,
* as one way of providing tracability for errors back to the originating spreadsheet.
- * @param name The name of the rule. This may be used to calculate DRL row error
+ * @param name The name of the rule. This may be used to calculate DRL row error
* to Spreadsheet row error (just need to keep track of output lines, and map spreadsheetRow to a start
* and end range in the rendered output).
- * @param salience
+ * @param salience
* @param spreadsheetRow The phyical row number from the spreadsheet.
*/
public Rule(final String name,
@@ -224,13 +224,13 @@
return this._description;
}
- public void setDuration(final Duration value) // Set the duration of the rule
+ public void setDuration(final String value) // Set the duration of the rule
{
this._duration = value;
}
public String getDuration() {
- return this._duration.getSnippet();
+ return this._duration;
}
public void setActivationGroup(final String value) // Set the duration of the rule
@@ -265,7 +265,7 @@
}
/**
- * @return The row in the spreadsheet this represents.
+ * @return The row in the spreadsheet this represents.
* This can be handy when mapping a line error from Parser back to the rule row.
* Will need to have a map of ranges of line numbers that each rule covers.
* Then can find out the rule that cause it, and this will give the row number to report.
Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DefaultRuleSheetListener.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DefaultRuleSheetListener.java 2008-03-05 20:53:57 UTC (rev 18709)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DefaultRuleSheetListener.java 2008-03-06 00:58:39 UTC (rev 18710)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -26,7 +26,6 @@
import org.drools.decisiontable.model.Condition;
import org.drools.decisiontable.model.Consequence;
-import org.drools.decisiontable.model.Duration;
import org.drools.decisiontable.model.Global;
import org.drools.decisiontable.model.Import;
import org.drools.decisiontable.model.Package;
@@ -36,26 +35,26 @@
/**
* @author <a href="mailto:shaun.addison at gmail.com"> Shaun Addison </a><a
* href="mailto:michael.neale at gmail.com"> Michael Neale </a>
- *
+ *
* Define a ruleset spreadsheet which contains one or more decision tables.
- *
+ *
* Stay calm, deep breaths... this is a little bit scary, its where it all
* happens.
- *
+ *
* A table is identifed by a cell beginning with the text "RuleTable". The first
* row after the table identifier defines the column type: either a condition
* ("C") or consequence ("A" for action), and so on.
- *
+ *
* The second row contains ObjectType declarations (optionally, or can be left blank).
* If cells are merged, then all snippets below the merged bit will become part of
* the same column as seperate constraints.
- *
+ *
* The third row identifies the java code block associated with the condition
* or consequence. This code block will include a parameter marker for the
* attribute defined by that column.
- *
+ *
* The third row is a label for the attribute associated with that column.
- *
+ *
* All subsequent rows identify rules with the set.
*/
public class DefaultRuleSheetListener
@@ -155,7 +154,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see my.hssf.util.SheetListener#startSheet(java.lang.String)
*/
public void startSheet(final String name) {
@@ -164,7 +163,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see my.hssf.util.SheetListener#finishSheet()
*/
public void finishSheet() {
@@ -175,7 +174,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see my.hssf.util.SheetListener#newRow()
*/
public void newRow(final int rowNumber,
@@ -210,7 +209,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see my.hssf.util.SheetListener#newCell(int, int, java.lang.String)
*/
public void newCell(final int row,
@@ -372,7 +371,7 @@
* This is for handling a row where an object declaration may appear,
* this is the row immediately above the snippets.
* It may be blank, but there has to be a row here.
- *
+ *
* Merged cells have "special meaning" which is why this is so freaking hard.
* A future refactor may be to move away from an "event" based listener.
*/
@@ -537,7 +536,7 @@
this._currentRule.setNoLoop( value );
} else if ( actionType.type == ActionType.RULEFLOWGROUP ) {
this._currentRule.setRuleFlowGroup( value );
- }
+ }
else if ( actionType.type == ActionType.DURATION ) // if the actionType
// type is DURATION
// then creates a
@@ -571,15 +570,12 @@
}
- // 08 - 16 - 2005 RIK: This function creates a new DURATION
+ // 08 - 16 - 2005 RIK: This function creates a new DURATION
private void createDuration(final int column,
final String value,
final ActionType actionType) {
- final Duration dur = new Duration();
- dur.setSnippet( value );
- dur.setComment( cellComment( column ) );
- this._currentRule.setDuration( dur );
+ this._currentRule.setDuration( value );
}
private boolean isCellValueEmpty(final String value) {
Deleted: labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/model/DurationTest.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/model/DurationTest.java 2008-03-05 20:53:57 UTC (rev 18709)
+++ labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/model/DurationTest.java 2008-03-06 00:58:39 UTC (rev 18710)
@@ -1,38 +0,0 @@
-package org.drools.decisiontable.model;
-
-/*
- * Copyright 2005 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import junit.framework.TestCase;
-
-public class DurationTest extends TestCase {
-
- /**
- * Test basic rendering and parsing of arguments
- */
- public void testDurationRender() {
- final Duration duration = new Duration();
- duration.setSnippet( "1234" );
- final DRLOutput out = new DRLOutput();
- duration.renderDRL( out );
- final String res = out.getDRL();
- System.out.println( res );
- assertEquals( "\tduration 1234\n",
- res );
-
- }
-
-}
Modified: labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/model/RuleRenderTest.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/model/RuleRenderTest.java 2008-03-05 20:53:57 UTC (rev 18709)
+++ labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/model/RuleRenderTest.java 2008-03-06 00:58:39 UTC (rev 18710)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,7 +20,7 @@
/**
* @author <a href="mailto:michael.neale at gmail.com"> Michael Neale</a>
- *
+ *
* Tests how the rule parse tree renders itself to a rule XML fragment.
*/
public class RuleRenderTest extends TestCase {
@@ -58,25 +58,26 @@
assertTrue( drl.indexOf( "#rule comments" ) > -1 );
}
-
+
public void testAttributes() throws Exception {
Rule rule = new Rule("la", new Integer(42), 2);
-
+
rule.setActivationGroup( "foo" );
rule.setNoLoop( "true" );
rule.setRuleFlowGroup( "ruleflowgroup" );
-
+ rule.setDuration("42");
DRLOutput out = new DRLOutput();
rule.renderDRL( out );
-
+
String result = out.toString();
-
+
assertTrue(result.indexOf( "ruleflow-group \"ruleflowgroup\"" ) > -1 );
assertTrue(result.indexOf( "no-loop true" ) > -1);
assertTrue(result.indexOf( "activation-group \"foo\"" ) > -1);
-
- }
+ assertTrue(result.indexOf( "duration 42" ) > -1);
+ }
+
public void testSalienceCalculator() {
final int rowNumber = 2;
final int salience = Rule.calcSalience( rowNumber );
@@ -119,7 +120,7 @@
}
/**
- * This checks that if the rule has "nil" salience, then
+ * This checks that if the rule has "nil" salience, then
* no salience value should be put in the rule definition.
* This allows default salience to work as advertised.
*
More information about the jboss-svn-commits
mailing list