[rules-users] Evaluating an attribute of an object in Arraylist
Rafael Alcemar
rafael.alcemar at gmail.com
Thu Sep 27 17:07:38 EDT 2007
Edson, could you write below an example for this case?
How Could I do it? Like this: *$list : ArrayList() from
locacoes(cliente == $motorista(nome) ) * or *$m: from
locacoes(cliente==$motorista(nome))*????
I'm really needing it, so sorry if my questions are very basic.
Thanks!
Rafael Alcemar
Edson Tirelli escreveu:
> Use the "from" CE. Something like:
>
> Fact( ... ) from yourGlobalList
>
>
> 2007/9/27, Rafael Alcemar <rafael.alcemar at gmail.com
> <mailto:rafael.alcemar at gmail.com>>:
>
> Rafael Alcemar escreveu:
> > Thanks for your answer but I forgot to say that I want to use the
> > gloabal variable *locacoes*. *locacoes *is an ArrayList containing a
> > list of umLocacaoImediata. How do I iterate over *locacoes* and
> > discover if there is an object with the same name of the variable
> > $motorista???
> >
> > Thanks!
> > Rafael Alcemar
> >
> > Chris Woodrow escreveu:
> >> Hi,
> >> Doesn't (client == $motorista.nome) work?
> >>
> >> 2007/9/26, Rafael Alcemar < rafael.alcemar at gmail.com
> <mailto:rafael.alcemar at gmail.com>
> >> <mailto:rafael.alcemar at gmail.com
> <mailto:rafael.alcemar at gmail.com>>>:
> >>
> >> Hello guys, i'm trying to seek an object in an ArrayList,
> but I
> >> don't know how I do it. I'm inserting this list as a global
> >> variable into drools, but I'd like to check if there is an
> ojbect
> >> in this list with a specific name. Could Anybody help me? The
> >> code is below:
> >>
> >> global java.util.List locacoes
> >>
> >> rule "Cliente pode alugar"
> >> when
> >> $motorista : umMotorista()
> >> // $list : ArrayList() from collect( umLocacaoImediata(
> >> cliente == $motorista(nome) ) )
> >> then
> >> $motorista.setPodeAlugar(false);
> >> System.out.println($motorista.getNome() + " já
> possui uma
> >> alocacao");
> >> update($motorista);
> >> end
> >>
> >> I'm trying to compare the attribute cliente from
> >> umLocacaoImediata with the attribute nome from motorista.
> How do
> >> I do it?
> >>
> >> If anybody can help me with the right way to do it, answer this
> >> mail, please.
> >>
> >> Rafael Alcemar
> >>
> >> _______________________________________________
> >> rules-users mailing list
> >> rules-users at lists.jboss.org
> <mailto:rules-users at lists.jboss.org>
> <mailto:rules-users at lists.jboss.org
> <mailto:rules-users at lists.jboss.org>>
> >> https://lists.jboss.org/mailman/listinfo/rules-users
> <https://lists.jboss.org/mailman/listinfo/rules-users>
> >>
> >>
> >>
> ------------------------------------------------------------------------
> >>
> >> _______________________________________________
> >> rules-users mailing list
> >> rules-users at lists.jboss.org <mailto:rules-users at lists.jboss.org>
> >> https://lists.jboss.org/mailman/listinfo/rules-users
> >>
> >
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org <mailto:rules-users at lists.jboss.org>
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
>
> --
> Edson Tirelli
> Software Engineer - JBoss Rules Core Developer
> Office: +55 11 3529-6000
> Mobile: +55 11 9287-5646
> JBoss, a division of Red Hat @ www.jboss.com <http://www.jboss.com>
> ------------------------------------------------------------------------
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
More information about the rules-users
mailing list