[jboss-jira] [JBoss JIRA] Issue Comment Edited: (JBRULES-2597) Decision table only supports "." as decimal seperator

Lars R�ckemann (JIRA) jira-events at lists.jboss.org
Thu Jul 29 18:53:49 EDT 2010


    [ https://jira.jboss.org/browse/JBRULES-2597?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12541556#action_12541556 ] 

Lars R�ckemann edited comment on JBRULES-2597 at 7/29/10 6:53 PM:
------------------------------------------------------------------

In the meantime I've created a workaround which is working pretty fine for me. 
I added two additional Properties to my localized excel sheet: 
* DecimalPointIsComma 
* ActionArgumentSeparator

Then I modified DefaultRuleSheetListener as follows:

In method nextDataCell() I changed the last else if block to check if one of the new properties is set and change the cell value accordingly:

{code}
 [ ... ]
        } else if ( actionType.type == ActionType.CONDITION ) {
        	actionType.addCellValue( column, value );
        } else if ( actionType.type == ActionType.ACTION ) {
        	/** 
        	 * Lars Rueckemann: workaround for localized excel version using "," as decimal separator
        	 * Please specify Property: "DecimalPointIsComma = true" 
        	 */
        	String custValue = value;
        	if ( RuleSheetParserUtil.isStringMeaningTrue((String)getProperties().get("DecimalPointIsComma")) ) {
        		custValue = value.replace(',', '.');
        	} 
        	final String argSeparator = (String)getProperties().get("ActionArgumentSeparator");
        	if ( argSeparator != null && argSeparator.length() == 1 ) {
        		custValue = custValue.replace(argSeparator.toCharArray()[0], ',');
            }
        	actionType.addCellValue( column, custValue );
        }
[ ... ]
{code}

      was (Author: rueckemann):
    In the meantime I've created a workaround which is working pretty fine for me. 
I added an additional Property "DecimalPointIsComma" to my localized excel sheet and modified class DefaultRuleSheetListener as follows:

In method nextDataCell() I changed the last else if block to check if the new property is set and change the cell value accordingly:

 [ ... ]
        } else if ( actionType.type == ActionType.CONDITION || actionType.type == ActionType.ACTION ) {            
        	/** 
        	 * Lars Rueckemann: fix for localized excel version using "," as decimal seperator
        	 * Please specify Property: "DecimalPointIsComma = true" 
        	 */
        	if(RuleSheetParserUtil.isStringMeaningTrue((String)getProperties().get("DecimalPointIsComma")) && 
            		actionType.type == ActionType.ACTION) {
        		actionType.addCellValue( column, value.replace(',', '.'));
            } else {
        	  actionType.addCellValue( column, value );
            }
        }
[ ... ]

  
> Decision table only supports "." as decimal seperator
> -----------------------------------------------------
>
>                 Key: JBRULES-2597
>                 URL: https://jira.jboss.org/browse/JBRULES-2597
>             Project: Drools
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: drools-decisiontables
>    Affects Versions: 5.0.1.FINAL
>         Environment: localized version of Excel with decimal seperator set to "," instead of "." (German locale settings)
> Windows XP Pro
> MsOffice 2007 - Spreadsheet saved in MsOffice 2003 .xls format 
>            Reporter: Lars R�ckemann
>            Assignee: Mark Proctor
>         Attachments: TEST.xls
>
>
> In the german locale "," is used as decimal seperator. 
> When using a "," in a localized spreadsheet drools does not parse this as a number but tries to read two arguments instead. 
> Attached sheet has the following Rule Compilation error: 
>    The method set(String, Object) in the type RegelErgebnis is not applicable for the arguments (String, int, int)
> This error comes from coulumn G of the spreadsheet when trying to execute action: ergebnis.set(String, Object);
> This fails as $param is read as two int values instead of an Object.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       



More information about the jboss-jira mailing list