[jboss-jira] [JBoss JIRA] Updated: (JBRULES-372) QueryResult.get fires ClassCastException when using the string argument

Giovanni Cuccu (JIRA) jira-events at jboss.com
Fri Jul 14 08:55:11 EDT 2006


     [ http://jira.jboss.com/jira/browse/JBRULES-372?page=all ]

Giovanni Cuccu updated JBRULES-372:
-----------------------------------

    Attachment: QueryResults.java

I tried to fix the issue (I edited line 48 inserting declarations[i] instead of declarations)and the error consequent to the first fix in QueryResult

> QueryResult.get fires ClassCastException when using the string argument
> -----------------------------------------------------------------------
>
>                 Key: JBRULES-372
>                 URL: http://jira.jboss.com/jira/browse/JBRULES-372
>             Project: JBoss Rules
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>         Environment: JBoss Rules 3.0.1 and JBoss Rules as downloaded from svn trunk as of 12/07/06 
>            Reporter: Giovanni Cuccu
>         Assigned To: Mark Proctor
>         Attachments: QueryResults.java
>
>
> here is the simple test case:
> package simpletest;
> public class AssertedObject {
> 	private String value;
> 	public String getValue() {
> 		return value;
> 	}
> 	public void setValue(String value) {
> 		this.value = value;
> 	}
> 	public AssertedObject(String value) {
> 		// TODO Auto-generated constructor stub
> 		this.value = value;
> 	}
> 	
> 	
> }
> package simpletest;
> import simpletest.AssertedObject;
> rule rule1
> 	when
> 	then
> 		assert( new AssertedObject( "value1") );
> 		assert( new AssertedObject( "value2") );
> end
> query "assertedobjquery" 
>     assertedobj : AssertedObject( value=="value1" )
> end
> package simpletest;
> import java.io.InputStreamReader;
> import java.util.HashMap;
> import java.util.Iterator;
> import java.util.Map;
> import mit.rules.test.Prestazione;
> import mit.rules.test.StrutturaErogante;
> import mit.rules.test.TempiAttesa;
> import mit.rules.test.TestRules;
> import org.drools.QueryResult;
> import org.drools.QueryResults;
> import org.drools.RuleBase;
> import org.drools.RuleBaseFactory;
> import org.drools.WorkingMemory;
> import org.drools.audit.WorkingMemoryFileLogger;
> import org.drools.compiler.PackageBuilder;
> public class TestQuery {
> 	public static void main(String[] args) throws Exception {
> 		// TODO Auto-generated method stub
> 	    final PackageBuilder builder = new PackageBuilder();
> 		builder.addPackageFromDrl( new InputStreamReader( TestQuery.class.getResourceAsStream( "testquery.drl" ) ) );
> 		
> 		final RuleBase ruleBase = RuleBaseFactory.newRuleBase();
> 		ruleBase.addPackage( builder.getPackage() );
> 		
> 		final WorkingMemory workingMemory = ruleBase.newWorkingMemory();
> 		fireRules(workingMemory);
> 		        
> 	}
> 	
> 	public static void fireRules(WorkingMemory workingMemory) {
> 		final WorkingMemoryFileLogger logger = new WorkingMemoryFileLogger( workingMemory );
> 		logger.setFileName( "log/testquery" );
> 		
> 		workingMemory.fireAllRules();
> 		QueryResults results = workingMemory.getQueryResults( "assertedobjquery" );
> 		if (results==null || !results.iterator().hasNext()) {
> 			System.err.println("Empty list");
> 		} else {
> 			for ( Iterator it = results.iterator(); it.hasNext(); ) {
> 			    QueryResult result = ( QueryResult )it.next();;
> 			    AssertedObject assertedObject=(AssertedObject)result.get( "assertedobj" );
> 				System.out.println("AssertedObject with value " + assertedObject.getValue());
> 			}		
> 		}
> 		logger.writeToDisk();	
> 	}
> }

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

        



More information about the jboss-jira mailing list