<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    Thank you for your answer.<br>
    Yes it's what i have done as i didn't find a better idea. User will
    have to enter it but if the DSL is clear shouldn't be a problem.<br>
    <br>
    In fact 1 rule will be something like :<br>
    - Find a map with properties 'prop1' = "value1" and store it in
    variable $m1 (because i will need access in the Then part also)<br>
    - Find a map with properties 'prop1' = "value1" (and different then
    $m1) and store it in variable $m2.<br>
    - And using properties 'unixTimestampInSecond' and
    'unixTimestampInMillisecond' (so complete timestamp in Millisecond =
    'unixTimestampInSecond' * 1000 + 'unixTimestampInMillisecond') of
    the 2 Maps, $m1 has to be before $m2.<br>
    <br>
    So i use 2 times this one to find $m1 and $m2 : <tt>[when]The
      property {key:ENUM:Map.properties} of the map <b>{mapVar}</b> is
      {value}=<b>{mapVar} </b>: Map((this["{key}"] == "{value}"))</tt><br>
    <br>
    Then this one to drop the case when the Map would be the same : <tt>[when]The
      map <b>{mapVar1}</b> is not map </tt><tt><b>{mapVar2}</b></tt><tt>
      =<b> eval ({mapVar1}</b>["id"] != </tt><tt><b>{mapVar2}</b>["id"]</tt><tt>))</tt><b><br>
    </b><br>
    Then i can do something like : <tt>[when]The map <b>{mapVar1}</b>
      is before </tt><tt><b>{mapVar2}</b></tt><tt> =<b> eval
        (orderTimeStamp(</b></tt>(Long) <tt><b>{mapVar1}</b>["</tt>unixTimestampInSecond<tt>"],
    </tt>(Long) <tt><b>{mapVar1}</b>["</tt>unixTimestampInMillisecond<tt>"],
    </tt>(Long) <tt><b>{mapVar2}</b>["</tt> unixTimestampInSecond<tt>"],
    </tt>(Long) <tt> </tt><tt><b>{mapVar2}</b>["</tt>unixTimestampInMillisecond<tt>"]</tt><tt>))</tt><b><br>
    </b><br>
    where i would have a function <tt><b>:    <br>
        function Boolean orderTimeStamp(Long a, Long b, Long c, Long d)</b></tt>
    <br>
    {<br>
        Long timestamp1 = a*1000+b;<br>
        Long timestamp2 = c*1000+d;<br>
    <br>
        if (timestamp1 &lt;= timestamp2)<br>
            return true;<br>
        else<br>
            return false;<br>
    }<br>
    <br>
    I will rethink of POJO but i think, it will be more ennoying to
    update any change. I will need a reference to these maps in almost
    every case in the THEN clause so not a big problem finally.<br>
    <br>
    <br>
    For the second question :<br>
    <br>
    In fact i have to make rules using these Enum and DSL and put rules
    in their specific files.<br>
    For example now i am working with 4 different drl files :<br>
    <br>
    - file1.drl which contains rule1, rule2, rule3, rule4<br>
    - file2.drl which contains rule5, rule6, rule7, rule8<br>
    - file3.drl which contains rule9, rule10, rule11, rule12<br>
    - file4.drl which contains rule13, rule14, rule15, rule16<br>
    <br>
    These files have to have this specific name and the name cannot
    change because the java code use this name to load the drl file in
    the session.<br>
    <br>
    To put each rule in its specific file, do i have to create a package
    per file and name the package with the name of the file i want? And
    copy Enum and DSL in each package or can i put this in global? Or
    maybe be is there a better way i didn't find?<br>
    <br>
    <br>
    To use the Test Scenario, do you know if we have to do special
    things? I tried to add Maps in the Given part and run the scenario
    but i get an error ; "unable to find constructor for java.util.Map"
    and the same if i put a boolean, string...   Is the Guvnor Test
    Scenario not able to find java class and how to make it reachable? <br>
    I have already tried Test Scenario with adding object for which i
    gave a Pojo but never with basic java type.<br>
    <br>
    Thanks again<br>
    <br>
    <br>
    Le 4/03/2011 11:50, Vincent Legendre a écrit :
    <blockquote cite="mid:4D70C3E1.7050106@eurodecision.com" type="cite">
      <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
      <title></title>
      For your problem of different instances of a map : If you want to
      match 2 maps, and compare them, your have to set a placeholder in
      your DSL to set the variable's name<br>
      <tt>[when]The property {key:ENUM:Map.properties} of the map <b>{mapVar}</b>
        is {value}=<b>{mapVar} </b>: Map((this["{key}"] == "{value}"))</tt><br>
      <br>
      <b> </b>And another DSL phrase to check that instances are
      different<br>
      <tt>[when]The map <b>{mapVar1}</b> is not map </tt><tt><b>{mapVar2}</b></tt><tt>
        =<b> eval ({mapVar1}</b>["id"] != </tt><tt><b>{mapVar2}</b>["id"]</tt><tt>))</tt><b><br>
      </b><br>
      But it will force your users to handle variables. I can't see
      simpler way for doing that with DSL.<br>
      <br>
      You may consider completely another way. If your property lists
      are constant (and they are because you can create static enums),
      you can write a simple program to generate the corresponding POJOs
      (which contains the map inside them and use it in set/get methods
      for corresponding key) and create a jar with them. <br>
      Each POJO will then have its fields listed automatically in Guided
      Editor, which will prevent you for writing complex DSL and enums,
      and provide a good way for users to edit rules. For instance, you
      can bind an object to a variable only if you need it (with DSL you
      are forced to bind a variable at each time you use the phrase),
      and you can use other operator (not only equals) without writing a
      new DSL phrase.<br>
      <br>
      <br>
      I did not understand this question :<br>
      <br>
      <blockquote
        cite="mid:AANLkTinGDk7Jk634QwBC4aMquVUX12fKYEVMzjbBNEm+@mail.gmail.com"
        type="cite">I have to put my rules in 4 drl files separate (i
        know which rules go in which drl file), is the only way to
        create a different package for each drl file i want? And to put
        the Enum and DSL part in Global if i have to use it for the 4
        files? If i want a precise name for my drl file, i have to give
        this exact name to the package?<br>
      </blockquote>
      But yes, a DSL (and enums) is specific to its package.<br>
      <br>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
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>
  </body>
</html>