[jboss-svn-commits] JBL Code SVN: r20160 - in labs/jbossrules/trunk/drools-jbrms/src: main/java/org/drools/brms/server and 1 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sun May 25 21:09:34 EDT 2008


Author: jervisliu
Date: 2008-05-25 21:09:33 -0400 (Sun, 25 May 2008)
New Revision: 20160

Modified:
   labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/ruleeditor/NewAssetWizard.java
   labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/server/ServiceImplementation.java
   labs/jbossrules/trunk/drools-jbrms/src/test/java/org/drools/brms/server/ServiceImplementationTest.java
Log:
JBRULES-1292: BRMS ignores "initial description" entered when creating new "Business rule using a DSL (text editor)" rule


Modified: labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/ruleeditor/NewAssetWizard.java
===================================================================
--- labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/ruleeditor/NewAssetWizard.java	2008-05-25 20:36:16 UTC (rev 20159)
+++ labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/ruleeditor/NewAssetWizard.java	2008-05-26 01:09:33 UTC (rev 20160)
@@ -52,8 +52,6 @@
     private boolean showCats;
     private String format;
 
-
-
     /** This is used when creating a new rule. */
     public NewAssetWizard(EditItemEvent afterCreate, boolean showCats, String format, String title) {
         super("images/new_wiz.gif", title);
@@ -76,6 +74,23 @@
 
         description.setVisibleLines( 4 );
         description.setWidth( "100%" );
+        //initial description
+        if (format == AssetFormats.DSL_TEMPLATE_RULE) {
+        	description.setText("A dsl is a language mapping from a domain specific language to the rule language.");
+        } else if (format == AssetFormats.ENUMERATION) {
+        	description.setText( "An enumeration is a mapping from fields to a list of values." +
+                    "This will mean the rule editor will show a drop down for fields, instead of a text box." +
+                    "The format of this is: 'FactType.fieldName ': ['Value1', 'Value2']\n" +
+                    "You can add more mappings by adding in more lines. " +
+                    "\nFor example:\n\n" +
+                    "'Person.sex' : ['M', 'F']\n" +
+                     "'Person.rating' : ['High', 'Low']\n\n" +
+                     "You can also ad display aliases (so the value used in the rule is separate to the one displayed:\n"  +
+                    "'Person.sex' : ['M=Male', 'F=Female']\n" +
+                    "in the above case, the 'M=Male' means that 'Male' will be displayed as an item in a drop down box, but the value 'M' will be used in the rule. "
+                    );
+        }
+        
         addAttribute("Initial description:", description);
 
         Button ok = new Button( "OK" );

Modified: labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/server/ServiceImplementation.java
===================================================================
--- labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/server/ServiceImplementation.java	2008-05-25 20:36:16 UTC (rev 20159)
+++ labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/server/ServiceImplementation.java	2008-05-26 01:09:33 UTC (rev 20160)
@@ -225,7 +225,6 @@
                                         AssetItem asset) {
         if (format.equals( AssetFormats.DSL_TEMPLATE_RULE )) {
             asset.updateContent( "when\n\nthen\n" );
-            asset.updateDescription( "A dsl is a language mapping from a domain specific language to the rule language." );
         } else if (format.equals( AssetFormats.FUNCTION )) {
             asset.updateContent( "function <returnType> " + ruleName + "(<args here>) {\n\n\n}" );
         } else if (format.equals( AssetFormats.DSL )) {
@@ -236,17 +235,6 @@
             asset.updateBinaryContentAttachment( this.getClass().getResourceAsStream( "/SampleDecisionTable.xls" ) );
             asset.updateBinaryContentAttachmentFileName( "SampleDecisionTable.xls" );
         } else if (format.equals( AssetFormats.ENUMERATION )) {
-            asset.updateDescription( "An enumeration is a mapping from fields to a list of values." +
-                    "This will mean the rule editor will show a drop down for fields, instead of a text box." +
-                    "The format of this is: 'FactType.fieldName ': ['Value1', 'Value2']\n" +
-                    "You can add more mappings by adding in more lines. " +
-                    "\nFor example:\n\n" +
-                    "'Person.sex' : ['M', 'F']\n" +
-                     "'Person.rating' : ['High', 'Low']\n\n" +
-                     "You can also ad display aliases (so the value used in the rule is separate to the one displayed:\n"  +
-                    "'Person.sex' : ['M=Male', 'F=Female']\n" +
-                    "in the above case, the 'M=Male' means that 'Male' will be displayed as an item in a drop down box, but the value 'M' will be used in the rule. "
-                    );
         }
     }
 

Modified: labs/jbossrules/trunk/drools-jbrms/src/test/java/org/drools/brms/server/ServiceImplementationTest.java
===================================================================
--- labs/jbossrules/trunk/drools-jbrms/src/test/java/org/drools/brms/server/ServiceImplementationTest.java	2008-05-25 20:36:16 UTC (rev 20159)
+++ labs/jbossrules/trunk/drools-jbrms/src/test/java/org/drools/brms/server/ServiceImplementationTest.java	2008-05-26 01:09:33 UTC (rev 20160)
@@ -206,7 +206,22 @@
 		assertEquals("DUPLICATE", uuid);
 
 	}
+	
+	public void testCreateNewRule() throws Exception {
+		ServiceImplementation impl = getService();
+		impl.repository.createPackage("testCreateNewRule", "desc");
+		impl.createCategory("", "testCreateNewRule", "this is a cat");
 
+		String uuid = impl.createNewRule("testCreateNewRuleName",
+				"an initial desc", "testCreateNewRule", "testCreateNewRule",
+				AssetFormats.DSL_TEMPLATE_RULE);
+		assertNotNull(uuid);
+		assertFalse("".equals(uuid));
+
+		AssetItem dtItem = impl.repository.loadAssetByUUID(uuid);
+		assertEquals(dtItem.getDescription(), "an initial desc");
+	}
+	
 	public void testRuleTableLoad() throws Exception {
 		ServiceImplementation impl = getService();
 		TableConfig conf = impl




More information about the jboss-svn-commits mailing list