<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Darko,&nbsp; thanks for the reply.&nbsp; I'm new to both JAVA and Drools, so any
pointers in either are appreciated.<br>
<br>
I was trying to use the compareTo method but can't figure out the right
syntax to make drools happy.&nbsp; In my original examples I was using
'CompareTo' while your answer has lowercase 'c' in 'compareTo'.&nbsp; In
either case I'm still failing to compile.&nbsp; Using your suggested code I
get the following:<br>
&nbsp;&nbsp;&nbsp; [22,56]: unknown:22:56 Unexpected token '$mp1'<br>
<br>
Based on the following from the drools documentation:<br>
<blockquote>6.5.2.1.1.1.&nbsp;JavaBeans as facts<br>
A field is an accessible method on the object. If your model objects
follow the java bean pattern, then fields are exposed using "getXXX" or
"isXXX" methods (these are methods that take no arguments, and return
something). You can access fields either by using the bean-name
convention (so "getType" can be accessed as "type") - we use the
standard jdk Introspector class to do this mapping.<br>
</blockquote>
I didn't think I could use any compare that took an argument unless I
used the eval function.<br>
<br>
Charles<br>
<br>
<blockquote
 cite="mid:200807041600.m64G04Xk020461@chief.prod.atl2.jboss.com"
 type="cite">
  <pre wrap="">Hi Charles,

This sounds rather like a JAVA question, but well

1. You should use the compareTo method, inherited from Comparable.

2. about the rules itself, it should be more something like
$A1 : ActionArchive($mp1 : mediaPool);
$A2 : ActionArchive(this != $A1,  mediaPool.compareTo($mp1) &lt; 0);

3. Having a huge number of actionArchives, you might want to consider storing them as an arra in a global variable and using the from operator in your rule.

Hope this helps,
Darko


-------- Original-Nachricht --------
  </pre>
  <blockquote type="cite">
    <pre wrap="">Datum: Thu, 03 Jul 2008 17:17:51 -0500
Von: Charles Binford <a class="moz-txt-link-rfc2396E" href="mailto:Charles.Binford@sun.com">&lt;Charles.Binford@sun.com&gt;</a>
An: <a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
Betreff: [rules-users] Comparing Strings (sort order)
    </pre>
  </blockquote>
  <pre wrap=""><!---->
  </pre>
  <blockquote type="cite">
    <pre wrap="">I'm trying to figure out how to compare strings in drools.  I'd prefer 
to just be able to say something like:
when
  obj(member &gt; "string")
....

This doesn't work because the &gt; or &lt; operations are not allowed (though 
I saw in a May 6th post Edson gave a pointer to how to add it.)  Next I 
tried using eval().  Based on everything I've read this should work.  My 
problem is getting the syntax correct.  My object "ActionArchive" has a 
member called "mediaPool".  I'd like to choose the one with the lowest 
(alphabetically) mediaPool string.

Try one.....
rule "testme"
    when
        $ar : ActionArchive($mp : mediaPool)
        not (eval (ActionArchive(getMediaPool().CompareTo($mp)) &lt; 0))
    then
        System.out.println("low mp= " + $ar.getMediaPool());
end
-----------
Rule Compilation error : [Rule name=junk, agendaGroup=MAIN, salience=0, 
no-loop=false]
    rules/Rule_testme_0.java (8:997) : The method getMediaPool() is 
undefined for the type Rule_junk_0


Try two......
rule "testme"
    when
        $ar : ActionArchive($mp : mediaPool)
        not (eval (ActionArchive(mediaPool.CompareTo($mp)) &lt; 0))
    then
        System.out.println("low mp= " + $ar.getMediaPool());
end
-----------
Rule Compilation error : [Rule name=testme, agendaGroup=MAIN, 
salience=0, no-loop=false]
    rules/Rule_testme_0.java (8:999) : mediaPool cannot be resolved

Thanks for any pointers.
Charles
p.s. consider this a vote for adding &gt; &lt; support for Strings....
_______________________________________________
rules-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a>
    </pre>
  </blockquote>
  <pre wrap=""><!---->
  </pre>
  <br>
</blockquote>
</body>
</html>