<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">"from" will iterate for you, exactly
      like "accumulate" counted the events. <br>
      If you need more details, please consult the documentation<br>
      <br>
      <br>
      On 03/10/2014 07:29 PM, Sandhya Sree wrote:<br>
    </div>
    <blockquote
cite="mid:CAJftt0HD6EHL0R8zSEHgLREwND_wjhdD-XfeojxSFOHN1gnhyQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">The problem here is even if multiple files are
        added, there is only one event object created. i want to have
        like say if 3 new files are added, 3 event objects must be
        created, and all three event objects must be added to
        List&lt;Event&gt; listOfEvents.&nbsp;
        <div>
          <br>
        </div>
        <div><br>
        </div>
        <div>Thanks.</div>
      </div>
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote">On Mon, Mar 10, 2014 at 11:48 PM,
          Davide Sottara <span dir="ltr">&lt;<a moz-do-not-send="true"
              href="mailto:dsotty@gmail.com" target="_blank">dsotty@gmail.com</a>&gt;</span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div bgcolor="#FFFFFF" text="#000000">
              <div>The "accumulates" should not be in the "then" part of
                a rule (see my previous email).<br>
                That rule gave you two lists, in the variables $plus and
                $mins, that you can use in the consequence.<br>
                <br>
                If you need to process each file separately, you may
                want to do something like this:<br>
                <br>
                <div><font face="arial, sans-serif">rule "new file"</font></div>
                <div class="">
                  <div><font face="arial, sans-serif">when</font></div>
                  <div><font face="arial, sans-serif">&nbsp; &nbsp; FileData($old
                      : fileOld, $new : fileNew, fileOld != fileNew)</font></div>
                </div>
                <div><font face="arial, sans-serif">&nbsp;&nbsp;&nbsp;</font><font
                    face="arial, sans-serif"><font face="arial,
                      sans-serif"> $newFile : String( this not memberOf
                      $old ) from $new</font><br>
                  </font></div>
                <div> <font face="arial, sans-serif">then&nbsp;&nbsp; <br>
                    &nbsp;&nbsp; // create new event for a new file : new
                    Event(...)<br>
                    &nbsp;&nbsp; // add to list : Event.listOfEvents.add(...)<br>
                  </font></div>
                <font face="arial, sans-serif">end</font>
                <div><br>
                </div>
                You'll need another rule for the files that have been
                removed.<br>
                <br>
                Notice that your Event class has no way to distinguish
                "added" from "removed" files, you may want to<br>
                add a boolean or something there.<br>
                Best<br>
                Davide
                <div>
                  <div class="h5"><br>
                    <br>
                    On 03/10/2014 07:04 PM, Sandhya Sree wrote:<br>
                  </div>
                </div>
              </div>
              <blockquote type="cite">
                <div>
                  <div class="h5">
                    <div dir="ltr">hi,
                      <div>im new to drools..im trying to create a
                        project as follows. i have a class called
                        Monitor &nbsp;which monitors a folder and creates two
                        lists called fileOld( which is the list of
                        filenames in that folder at time t1) &nbsp;and
                        fileNew(which is the list of filenames in that
                        folder at time t2). i have another class called
                        FileData which contains two members fileOld and
                        fileNew (list of strings) with getters,setters
                        and constructor. fileOld and fileNew from
                        Monitor Class are passed to FileData class.</div>
                      <div><br>
                      </div>
                      <div>i also have another class called Event which
                        is as follows:</div>
                      <div>
                        <div>public class Event {</div>
                        <div><span style="white-space:pre-wrap"> </span></div>
                        <div><span style="white-space:pre-wrap"> </span>
                          public static String name;</div>
                        <div><span style="white-space:pre-wrap"> </span>
                          private &nbsp;File source;</div>
                        <div><span style="white-space:pre-wrap"> </span>
                          private &nbsp;Date timeStamp;</div>
                        <div>&nbsp; &nbsp; &nbsp; &nbsp; public &nbsp;static &nbsp;List&lt;Event&gt;
                          listOfEvents = new ArrayList&lt;Event&gt;();</div>
                        <div><span style="white-space:pre-wrap"> </span></div>
                        <div><span style="white-space:pre-wrap"> </span>&nbsp;</div>
                        <div><span style="white-space:pre-wrap"> </span>public

                          Event(String name, File source, Date
                          timeStamp) {</div>
                        <div><span style="white-space:pre-wrap"> </span><a
                            moz-do-not-send="true"
                            href="http://this.name" target="_blank">this.name</a>
                          = name;</div>
                        <div><span style="white-space:pre-wrap"> </span>this.source

                          = source;</div>
                        <div><span style="white-space:pre-wrap"> </span>this.timeStamp

                          = timeStamp;</div>
                        <div><span style="white-space:pre-wrap"> </span>}</div>
                        <div><span style="white-space:pre-wrap"> </span></div>
                        <div><span style="white-space:pre-wrap"> </span></div>
                        <div><span style="white-space:pre-wrap"> </span>public

                          String getName() {</div>
                        <div><span style="white-space:pre-wrap"> </span>return

                          name;</div>
                        <div><span style="white-space:pre-wrap"> </span>}</div>
                        <div><span style="white-space:pre-wrap"> </span>public

                          void setName(String name) {</div>
                        <div><span style="white-space:pre-wrap"> </span><a
                            moz-do-not-send="true"
                            href="http://this.name" target="_blank">this.name</a>
                          = name;</div>
                        <div><span style="white-space:pre-wrap"> </span>}</div>
                        <div><span style="white-space:pre-wrap"> </span>public

                          File getSource() {</div>
                        <div><span style="white-space:pre-wrap"> </span>return

                          source;</div>
                        <div><span style="white-space:pre-wrap"> </span>}</div>
                        <div><span style="white-space:pre-wrap"> </span>public

                          void setSource(File source) {</div>
                        <div><span style="white-space:pre-wrap"> </span>this.source

                          = source;</div>
                        <div><span style="white-space:pre-wrap"> </span>}</div>
                        <div><span style="white-space:pre-wrap"> </span>public

                          Date getTimeStamp() {</div>
                        <div><span style="white-space:pre-wrap"> </span>return

                          timeStamp;</div>
                        <div><span style="white-space:pre-wrap"> </span>}</div>
                        <div><span style="white-space:pre-wrap"> </span>public

                          void setTimeStamp(Date timeStamp) {</div>
                        <div><span style="white-space:pre-wrap"> </span>this.timeStamp

                          = timeStamp;</div>
                        <div><span style="white-space:pre-wrap"> </span>}</div>
                        <div><span style="white-space:pre-wrap"> </span></div>
                      </div>
                      <div><br>
                      </div>
                      <div>now i have to compare these two lists(fileOld
                        and fileNew) in a rule file and if they are not
                        equal i have to create an event object for every
                        file added and deleted and put it in the
                        List&lt;Event&gt; listOfEvents.</div>
                      <div><br>
                      </div>
                      <div>here is my rule file:</div>
                      <div><br>
                      </div>
                      <div>
                        <div><span
                            style="font-family:arial,sans-serif;font-size:13px">r</span><font
                            face="arial, sans-serif">rule "files are
                            equal"</font></div>
                        <div><span style="font-family:arial,sans-serif">&nbsp;
                            &nbsp; when&nbsp;</span></div>
                        <div><font face="arial, sans-serif">&nbsp; &nbsp; &nbsp; &nbsp;
                            &nbsp;FileData( fileOld == fileNew)</font></div>
                        <div><font face="arial, sans-serif">&nbsp; &nbsp; then</font></div>
                        <div><font face="arial, sans-serif">&nbsp; &nbsp; &nbsp;
                            &nbsp;System.out.println("files are equal");</font></div>
                        <div><font face="arial, sans-serif">&nbsp; &nbsp; </font><span
                            style="font-family:arial,sans-serif">end</span></div>
                        <div><font face="arial, sans-serif"><br>
                          </font></div>
                        <div><font face="arial, sans-serif"><br>
                          </font></div>
                        <div><font face="arial, sans-serif">rule "files
                            not equal"</font></div>
                        <div><font face="arial, sans-serif">when</font></div>
                        <div><font face="arial, sans-serif">&nbsp; &nbsp;
                            FileData($old : fileOld, $new : fileNew,
                            fileOld != fileNew)</font></div>
                        <div><font face="arial, sans-serif">&nbsp; &nbsp;&nbsp;</font></div>
                        <div> <font face="arial, sans-serif">then</font></div>
                        <div><font face="arial, sans-serif">&nbsp;
                            &nbsp;accumulate( $s : String( this not memberOf
                            $old ) from $new, $plus : collectList( $s )
                            )&nbsp;</font></div>
                        <div><font face="arial, sans-serif">&nbsp;
                            &nbsp;accumulate( $t : String( this not memberOf
                            $new ) from $old, $mins : collectList( $t )
                            )&nbsp;</font></div>
                        <div><font face="arial, sans-serif">&nbsp;
                            &nbsp;System.out.println("files added:" + $plus
                            );&nbsp;</font></div>
                        <div><font face="arial, sans-serif">&nbsp;
                            &nbsp;System.out.println( "files deleted:" +
                            $mins );</font></div>
                        <div> <font face="arial, sans-serif">end</font></div>
                      </div>
                      <div><br>
                      </div>
                      <div><br>
                      </div>
                      <div><br>
                      </div>
                      <div>how can i loop through each of the file added
                        or deleted and create an Event Class object for
                        every file added and deleted &nbsp;and finally add
                        all the created objects to List&lt;Event&gt;
                        listOfEvents..</div>
                      <div><br>
                      </div>
                      <div><br>
                      </div>
                      <div>Thanks.</div>
                    </div>
                    <br>
                    <fieldset></fieldset>
                    <br>
                  </div>
                </div>
                <pre>_______________________________________________
rules-users mailing list
<a moz-do-not-send="true" href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>
<a moz-do-not-send="true" href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a></pre>
              </blockquote>
              <br>
            </div>
            <br>
            _______________________________________________<br>
            rules-users mailing list<br>
            <a moz-do-not-send="true"
              href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
            <a moz-do-not-send="true"
              href="https://lists.jboss.org/mailman/listinfo/rules-users"
              target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
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>
    <br>
  </body>
</html>