[rules-users] How to get objects inserted in the rule trhough Rest

Antonio Anderson Souza antonioams at gmail.com
Tue May 15 18:25:43 EDT 2012


Dear All,

I'm using Drools integrated to Camel trough Rest, but I'm unable to receive
objects inserted in the session by the rules, I'm inserting the fact
acordos.Acordo and in the "then" section of the rule I create new facts to
be returned to my app in this case is the fact acordos.Retorno, but I'm
unable to access this facts in the Rest response

Does anybody have some clue how to get these objects inserted?

Follow bellow what I'm sending, receiving and my rule:

Rule Definition:
package acordos

declare Acordo
 dataReserva: java.util.Date
dataEmbarque: java.util.Date
 gds: String
ciaAerea: String
 tipoAcordo: String
conexao: String
 origem: String
destino: String
 empresa: String
unidade: String
 cliente: String
end

declare Retorno
codAcordo: String
end

#generated from Decision Table
import teste.*;
import java.util.Date;
# rule values at C18, header at C13
rule "tabelaTeste(Acordo acordo)_18"
salience 65518
 when
Acordo(getDataReserva().after(new Date("22-Oct-2009")),
getDataReserva().before(new Date("31-Dec-2015")),
getDataEmbarque().after(new Date("1-Jan-2012")),
getDataEmbarque().before(new Date("31-Dec-2012")), gds == "1", ciaAerea ==
"AA", tipoAcordo == "1", getOrigem() in ("Brasil"), getDestino()
in("América do Norte","Brasil","Estados Unidos","Canadá","Ásia","América
Central","América do Sul","Mexico","Europa","Caribe"))
 then
System.out.println("teteteetetet");
 Retorno _retorno = new Retorno();
_retorno.setCodAcordo("PEB06");
 insert(_retorno);
end


Rest request:
curl  -v -H "Content-Type: text/plain" --data "
  <batch-execution lookup=\"ksession1\">
    <insert out-identifier=\"message\">
      <acordos.Acordo>
        <dataReserva>2012-01-30 08:00:00.000 -0300</dataReserva>
        <dataEmbarque>2012-01-30 08:00:00.000 -0300</dataEmbarque>
        <gds>1</gds>
        <ciaAerea>AA</ciaAerea>
        <conexao></conexao>
        <origem>Brasil</origem>
        <destino>Brasil</destino>
        <tipoAcordo>1</tipoAcordo>
      </acordos.Acordo>
      <acordos.Retorno>
        <codAcordo></codAcordo>
      </acordos.Retorno>
    </insert>
    <fire-all-rules out-identifier=\"firedActivations\" />
  </batch-execution>"
http://localhost:8080/drools-camel-server-5.4.0.Final/kservice/rest/execute

Rest Response:
< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< Date: Tue, 15 May 2012 22:20:00 GMT
< Content-Type: text/plain
< Content-Length: 528
<
* Connection #0 to host localhost left intact
* Closing connection #0
<?xml version='1.0' encoding='UTF-8'?><execution-results><result
identifier="message"><acordos.Acordo><dataReserva>2012-01-30 11:00:00.0
UTC</dataReserva><dataEmbarque>2012-01-30 11:00:00.0
UTC</dataEmbarque><gds>1</gds><ciaAerea>AA</ciaAerea><tipoAcordo>1</tipoAcordo><conexao></conexao><origem>Brasil</origem><destino>Brasil</destino></acordos.Acordo></result><result
identifier="firedActivations"><int>1</int></result><fact-handle
identifier="message"
external-form="0:2:1717445911:1717445911:2:DEFAULT"/></execution-results>

Best Regards,

Antonio Anderson Souza

 <http://174.129.217.139:8080/makecallclient/callme?p=YXNvdXphQHZvaWNlLmJyYXN0ZWwuY29tLmJy>

Blog <http://www.antonioams.com> - Twitter <http://twitter.com/antonioams>-
LinkedIn <http://br.linkedin.com/in/antonioams> -
Facebook<http://www.facebook.com/antonioams>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20120515/77592d75/attachment.html 


More information about the rules-users mailing list