[jboss-jira] [JBoss JIRA] Commented: (JBRULES-695) Cannot reference a global in a query.

Jack Curtin (JIRA) jira-events at lists.jboss.org
Tue Feb 27 15:19:35 EST 2007


    [ http://jira.jboss.com/jira/browse/JBRULES-695?page=comments#action_12354477 ] 
            
Jack Curtin commented on JBRULES-695:
-------------------------------------

Edson,
I tried your recommended workaround and it worked.  Thanks for your quick response on this issue.
Jack

> Cannot reference a global in a query.
> -------------------------------------
>
>                 Key: JBRULES-695
>                 URL: http://jira.jboss.com/jira/browse/JBRULES-695
>             Project: JBoss Rules
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>    Affects Versions: 3.0.5, 3.0.4
>         Environment: Windows XP using JBoss Eclipse IDE with drools plugin.
>            Reporter: Jack Curtin
>         Assigned To: Edson Tirelli
>             Fix For: 3.1-m2
>
>
> I have a query that references a global, and I get the following error during startup:
> org.drools.rule.InvalidRulePackage: Unable to return Declaration for identifier 'gbl_deletecardnumber'
> Relevant code from rule file follows:
> import java.lang.String;
> import com.m2syscorp.i24card.rulesengine.facts.CardHolder;
> global String gbl_deletecardnumber
> query "delete cardholder"
>      cardholderobj : CardHolder (cardnum == gbl_deletecardnumber)
> end;
> Relevant Java code follows:
> public class CardHolder implements Serializable {
>     private String cardnum;
> 	public String getCardnum() {
> 		return cardnum;
> 	}
> 	public void setCardnum(String cardnum) {
> 		this.cardnum = cardnum;
> 	}
> }
>     public void deleteCardHolderFromWorkingMemory(WorkingMemory workingMemory, String sDeleteCardNumber) {
>     	
>     	workingMemory.setGlobal("gbl_deletecardnumber", sDeleteCardNumber);    	
>     	QueryResults results = workingMemory.getQueryResults("delete cardholder");
>     	for (Iterator it = results.iterator(); it.hasNext(); ) {
>     		QueryResult result = (QueryResult) it.next();
>     		CardHolder chDelObj = (CardHolder) result.get("cardholderobj");
>     		FactHandle fhCardHolder = workingMemory.getFactHandle(chDelObj);
>     		workingMemory.retractObject(fhCardHolder);
>     		break;  // should only be one matching CardHolder object.
>     	}
>     }
> As you can see from the Java code, my goal is to be able to set the global variable gbl_deletecardnumber with a card number string, call the query which will find the CardHolder object with the matching card number, and then retract that object.

-- 
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