Re: [rules-users] (no subject)

2014-03-10 Thread Mauricio Salatino
Can you please elaborate about why do you want to do that? what's the point
of having a list inside of the Event class that will contain the same event?

The Then side of the rule is pure java.. so you just do
event.getEvents().add(event);

but I don't see the point of doing that.

Regards


On Mon, Mar 10, 2014 at 10:31 AM, Sandhya Sree
sandhyachinna...@gmail.comwrote:

 hi ,

 i have a class called Event which is as follows:

 public class Event {
  private  String name;
  private  File source;
  private  Date timeStamp;
 public static ListEvent listOfEvents;

 public Event(String name, File source, Date timeStamp) {
  this.name = name;
 this.source = source;
 this.timeStamp = timeStamp;
  }
  public String getName() {
  return name;
 }
 public void setName(String name) {
  this.name = name;
 }
 public File getSource() {
  return source;
 }
 public void setSource(File source) {
  this.source = source;
 }
 public Date getTimeStamp() {
  return timeStamp;
 }
 public void setTimeStamp(Date timeStamp) {
  this.timeStamp = timeStamp;
 }


  public void display()
  {
  System.out.println(name +  + in folder:  + source +  on  +
 timeStamp );
   }



 there are also some other classes associated with my project.. i have a
 rules file which computes the size of a folder and creates an object of
 Event class. every time this object of Event class is created i wwant to
 put it in a ListEvent.. how can i do this..

 my rules is as follows:

 rule size
 when
   $p:  RuleContext($size: getOldContext().getParent().getUsableSpace() 
 (30*1024*1024))

 then
Event event = new Event(folder almost full,
 $p.getOldContext().getParent(), new Date());
event.display();
..here i want to put this event into the ListEvent declared in
 Event Class.

   end



 thanks,
 Sandhya

 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
 - MyJourney @ http://salaboy.com http://salaboy.wordpress.com
 - Co-Founder @ http://www.jugargentina.org
 - Co-Founder @ http://www.jbug.com.ar

 - Salatino Salaboy Mauricio -
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Re: [rules-users] (no subject)

2014-03-10 Thread Sandhya Sree
Actually, il have to use this ListEvent in another class and then print
listEvent after every rule execution cycle.


On Mon, Mar 10, 2014 at 4:05 PM, Mauricio Salatino sala...@gmail.comwrote:

 Can you please elaborate about why do you want to do that? what's the
 point of having a list inside of the Event class that will contain the same
 event?

 The Then side of the rule is pure java.. so you just do
 event.getEvents().add(event);

 but I don't see the point of doing that.

 Regards


 On Mon, Mar 10, 2014 at 10:31 AM, Sandhya Sree sandhyachinna...@gmail.com
  wrote:

 hi ,

 i have a class called Event which is as follows:

 public class Event {
  private  String name;
  private  File source;
  private  Date timeStamp;
 public static ListEvent listOfEvents;

 public Event(String name, File source, Date timeStamp) {
  this.name = name;
 this.source = source;
 this.timeStamp = timeStamp;
  }
  public String getName() {
  return name;
 }
 public void setName(String name) {
  this.name = name;
 }
 public File getSource() {
  return source;
 }
 public void setSource(File source) {
  this.source = source;
 }
 public Date getTimeStamp() {
  return timeStamp;
 }
 public void setTimeStamp(Date timeStamp) {
  this.timeStamp = timeStamp;
 }


  public void display()
  {
  System.out.println(name +  + in folder:  + source +  on  +
 timeStamp );
   }



 there are also some other classes associated with my project.. i have a
 rules file which computes the size of a folder and creates an object of
 Event class. every time this object of Event class is created i wwant to
 put it in a ListEvent.. how can i do this..

 my rules is as follows:

 rule size
 when
   $p:  RuleContext($size: getOldContext().getParent().getUsableSpace() 
 (30*1024*1024))

 then
Event event = new Event(folder almost full,
 $p.getOldContext().getParent(), new Date());
event.display();
..here i want to put this event into the ListEvent declared in
 Event Class.

   end



 thanks,
 Sandhya

 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




 --
  - MyJourney @ http://salaboy.com http://salaboy.wordpress.com
  - Co-Founder @ http://www.jugargentina.org
  - Co-Founder @ http://www.jbug.com.ar

  - Salatino Salaboy Mauricio -

 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Re: [rules-users] (no subject)

2014-03-10 Thread Wolfgang Laun
Seeing that the list is static you can use the usual way for accessing
a static class member:

Event.listOfEvent.add( ... );

@Mauricio: It's not unusual to maintain a static collection (even
though there may be better ways, esp. with Drools).



On 10/03/2014, Mauricio Salatino sala...@gmail.com wrote:
 Can you please elaborate about why do you want to do that? what's the point
 of having a list inside of the Event class that will contain the same
 event?

 The Then side of the rule is pure java.. so you just do
 event.getEvents().add(event);

 but I don't see the point of doing that.

 Regards


 On Mon, Mar 10, 2014 at 10:31 AM, Sandhya Sree
 sandhyachinna...@gmail.comwrote:

 hi ,

 i have a class called Event which is as follows:

 public class Event {
  private  String name;
  private  File source;
  private  Date timeStamp;
 public static ListEvent listOfEvents;

 public Event(String name, File source, Date timeStamp) {
  this.name = name;
 this.source = source;
 this.timeStamp = timeStamp;
  }
  public String getName() {
  return name;
 }
 public void setName(String name) {
  this.name = name;
 }
 public File getSource() {
  return source;
 }
 public void setSource(File source) {
  this.source = source;
 }
 public Date getTimeStamp() {
  return timeStamp;
 }
 public void setTimeStamp(Date timeStamp) {
  this.timeStamp = timeStamp;
 }


  public void display()
  {
  System.out.println(name +  + in folder:  + source +  on  +
 timeStamp );
   }



 there are also some other classes associated with my project.. i have a
 rules file which computes the size of a folder and creates an object of
 Event class. every time this object of Event class is created i wwant to
 put it in a ListEvent.. how can i do this..

 my rules is as follows:

 rule size
 when
   $p:  RuleContext($size: getOldContext().getParent().getUsableSpace() 
 (30*1024*1024))

 then
Event event = new Event(folder almost full,
 $p.getOldContext().getParent(), new Date());
event.display();
..here i want to put this event into the ListEvent declared in
 Event Class.

   end



 thanks,
 Sandhya

 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




 --
  - MyJourney @ http://salaboy.com http://salaboy.wordpress.com
  - Co-Founder @ http://www.jugargentina.org
  - Co-Founder @ http://www.jbug.com.ar

  - Salatino Salaboy Mauricio -

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] (no subject)

2014-03-10 Thread Sandhya Sree
im getting the following error on doing that

Exception in thread pool-2-thread-1 Exception executing consequence for
rule size in com.net: java.lang.NullPointerException

what might be the problem?



On Mon, Mar 10, 2014 at 4:16 PM, Wolfgang Laun wolfgang.l...@gmail.comwrote:

 Seeing that the list is static you can use the usual way for accessing
 a static class member:

 Event.listOfEvent.add( ... );

 @Mauricio: It's not unusual to maintain a static collection (even
 though there may be better ways, esp. with Drools).



 On 10/03/2014, Mauricio Salatino sala...@gmail.com wrote:
  Can you please elaborate about why do you want to do that? what's the
 point
  of having a list inside of the Event class that will contain the same
  event?
 
  The Then side of the rule is pure java.. so you just do
  event.getEvents().add(event);
 
  but I don't see the point of doing that.
 
  Regards
 
 
  On Mon, Mar 10, 2014 at 10:31 AM, Sandhya Sree
  sandhyachinna...@gmail.comwrote:
 
  hi ,
 
  i have a class called Event which is as follows:
 
  public class Event {
   private  String name;
   private  File source;
   private  Date timeStamp;
  public static ListEvent listOfEvents;
 
  public Event(String name, File source, Date timeStamp) {
   this.name = name;
  this.source = source;
  this.timeStamp = timeStamp;
   }
   public String getName() {
   return name;
  }
  public void setName(String name) {
   this.name = name;
  }
  public File getSource() {
   return source;
  }
  public void setSource(File source) {
   this.source = source;
  }
  public Date getTimeStamp() {
   return timeStamp;
  }
  public void setTimeStamp(Date timeStamp) {
   this.timeStamp = timeStamp;
  }
 
 
   public void display()
   {
   System.out.println(name +  + in folder:  + source +  on  +
  timeStamp );
}
 
 
 
  there are also some other classes associated with my project.. i have a
  rules file which computes the size of a folder and creates an object of
  Event class. every time this object of Event class is created i wwant to
  put it in a ListEvent.. how can i do this..
 
  my rules is as follows:
 
  rule size
  when
$p:  RuleContext($size: getOldContext().getParent().getUsableSpace() 
  (30*1024*1024))
 
  then
 Event event = new Event(folder almost full,
  $p.getOldContext().getParent(), new Date());
 event.display();
 ..here i want to put this event into the ListEvent declared in
  Event Class.
 
end
 
 
 
  thanks,
  Sandhya
 
  ___
  rules-users mailing list
  rules-users@lists.jboss.org
  https://lists.jboss.org/mailman/listinfo/rules-users
 
 
 
 
  --
   - MyJourney @ http://salaboy.com http://salaboy.wordpress.com
   - Co-Founder @ http://www.jugargentina.org
   - Co-Founder @ http://www.jbug.com.ar
 
   - Salatino Salaboy Mauricio -
 
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Re: [rules-users] (no subject)

2014-03-10 Thread Mauricio Salatino
Please copy the entire stack trace.. what you have copied doesn't mean
anything besides that there is something wrong.


On Mon, Mar 10, 2014 at 1:29 PM, Sandhya Sree sandhyachinna...@gmail.comwrote:

 im getting the following error on doing that

 Exception in thread pool-2-thread-1 Exception executing consequence for
 rule size in com.net: java.lang.NullPointerException

 what might be the problem?



 On Mon, Mar 10, 2014 at 4:16 PM, Wolfgang Laun wolfgang.l...@gmail.comwrote:

 Seeing that the list is static you can use the usual way for accessing
 a static class member:

 Event.listOfEvent.add( ... );

 @Mauricio: It's not unusual to maintain a static collection (even
 though there may be better ways, esp. with Drools).



 On 10/03/2014, Mauricio Salatino sala...@gmail.com wrote:
  Can you please elaborate about why do you want to do that? what's the
 point
  of having a list inside of the Event class that will contain the same
  event?
 
  The Then side of the rule is pure java.. so you just do
  event.getEvents().add(event);
 
  but I don't see the point of doing that.
 
  Regards
 
 
  On Mon, Mar 10, 2014 at 10:31 AM, Sandhya Sree
  sandhyachinna...@gmail.comwrote:
 
  hi ,
 
  i have a class called Event which is as follows:
 
  public class Event {
   private  String name;
   private  File source;
   private  Date timeStamp;
  public static ListEvent listOfEvents;
 
  public Event(String name, File source, Date timeStamp) {
   this.name = name;
  this.source = source;
  this.timeStamp = timeStamp;
   }
   public String getName() {
   return name;
  }
  public void setName(String name) {
   this.name = name;
  }
  public File getSource() {
   return source;
  }
  public void setSource(File source) {
   this.source = source;
  }
  public Date getTimeStamp() {
   return timeStamp;
  }
  public void setTimeStamp(Date timeStamp) {
   this.timeStamp = timeStamp;
  }
 
 
   public void display()
   {
   System.out.println(name +  + in folder:  + source +  on  +
  timeStamp );
}
 
 
 
  there are also some other classes associated with my project.. i have a
  rules file which computes the size of a folder and creates an object of
  Event class. every time this object of Event class is created i wwant
 to
  put it in a ListEvent.. how can i do this..
 
  my rules is as follows:
 
  rule size
  when
$p:  RuleContext($size: getOldContext().getParent().getUsableSpace()
 
  (30*1024*1024))
 
  then
 Event event = new Event(folder almost full,
  $p.getOldContext().getParent(), new Date());
 event.display();
 ..here i want to put this event into the ListEvent declared in
  Event Class.
 
end
 
 
 
  thanks,
  Sandhya
 
  ___
  rules-users mailing list
  rules-users@lists.jboss.org
  https://lists.jboss.org/mailman/listinfo/rules-users
 
 
 
 
  --
   - MyJourney @ http://salaboy.com http://salaboy.wordpress.com
   - Co-Founder @ http://www.jugargentina.org
   - Co-Founder @ http://www.jbug.com.ar
 
   - Salatino Salaboy Mauricio -
 
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users



 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
 - MyJourney @ http://salaboy.com http://salaboy.wordpress.com
 - Co-Founder @ http://www.jugargentina.org
 - Co-Founder @ http://www.jbug.com.ar

 - Salatino Salaboy Mauricio -
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Re: [rules-users] (no subject)

2014-03-10 Thread Sandhya Sree
Exception in thread pool-2-thread-1 Exception executing consequence for
rule size in com.net: java.lang.NullPointerException
at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1297)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1221)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1456)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230)
at com.net.RuleExecutor.execute(RuleExecutor.java:18)
at com.net.DirectoryMonitor.run(DirectoryMonitor.java:39)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.NullPointerException
at
com.net.Rule_size_dc2a47e2812648e69eb9581eda931496.defaultConsequence(Rule_size_dc2a47e2812648e69eb9581eda931496.java:9)
at
com.net.Rule_size_dc2a47e2812648e69eb9581eda931496DefaultConsequenceInvokerGenerated.evaluate(Unknown
Source)
at
com.net.Rule_size_dc2a47e2812648e69eb9581eda931496DefaultConsequenceInvoker.evaluate(Unknown
Source)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1287)


On Mon, Mar 10, 2014 at 7:08 PM, Mauricio Salatino sala...@gmail.comwrote:

 Please copy the entire stack trace.. what you have copied doesn't mean
 anything besides that there is something wrong.


 On Mon, Mar 10, 2014 at 1:29 PM, Sandhya Sree 
 sandhyachinna...@gmail.comwrote:

 im getting the following error on doing that

 Exception in thread pool-2-thread-1 Exception executing consequence for
 rule size in com.net: java.lang.NullPointerException

 what might be the problem?



 On Mon, Mar 10, 2014 at 4:16 PM, Wolfgang Laun 
 wolfgang.l...@gmail.comwrote:

 Seeing that the list is static you can use the usual way for accessing
 a static class member:

 Event.listOfEvent.add( ... );

 @Mauricio: It's not unusual to maintain a static collection (even
 though there may be better ways, esp. with Drools).



 On 10/03/2014, Mauricio Salatino sala...@gmail.com wrote:
  Can you please elaborate about why do you want to do that? what's the
 point
  of having a list inside of the Event class that will contain the same
  event?
 
  The Then side of the rule is pure java.. so you just do
  event.getEvents().add(event);
 
  but I don't see the point of doing that.
 
  Regards
 
 
  On Mon, Mar 10, 2014 at 10:31 AM, Sandhya Sree
  sandhyachinna...@gmail.comwrote:
 
  hi ,
 
  i have a class called Event which is as follows:
 
  public class Event {
   private  String name;
   private  File source;
   private  Date timeStamp;
  public static ListEvent listOfEvents;
 
  public Event(String name, File source, Date timeStamp) {
   this.name = name;
  this.source = source;
  this.timeStamp = timeStamp;
   }
   public String getName() {
   return name;
  }
  public void setName(String name) {
   this.name = name;
  }
  public File getSource() {
   return source;
  }
  public void setSource(File source) {
   this.source = source;
  }
  public Date getTimeStamp() {
   return timeStamp;
  }
  public void setTimeStamp(Date timeStamp) {
   this.timeStamp = timeStamp;
  }
 
 
   public void display()
   {
   System.out.println(name +  + in folder:  + source +  on  +
  timeStamp );
}
 
 
 
  there are also some other classes associated with my project.. i have
 a
  rules file which computes the size of a folder and creates an object
 of
  Event class. every time this object of Event class is created i wwant
 to
  put it in a ListEvent.. how can i do this..
 
  my rules is as follows:
 
  rule size
  when
$p:  RuleContext($size:
 getOldContext().getParent().getUsableSpace() 
  (30*1024*1024))
 
  then
 Event event = new Event(folder almost full,
  $p.getOldContext().getParent(), new Date());
 event.display();
 ..here i want to put this event into the ListEvent declared
 in
  Event Class.
 
end
 
 
 
  thanks,
  Sandhya
 
  ___
  rules-users mailing list
  rules-users@lists.jboss.org
  https://lists.jboss.org/mailman/listinfo/rules-users
 
 
 
 
  --
   - MyJourney @ http://salaboy.com http://salaboy.wordpress.com
   - Co-Founder @ http://www.jugargentina.org
   - Co-Founder @ http://www.jbug.com.ar
 
   - Salatino Salaboy Mauricio -
 
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users



 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users



Re: [rules-users] (no subject)

2014-03-10 Thread Mauricio Salatino
If the list inside  Event has never being initialised it will throw a null
point exception.. so you need to make sure that the list
is initialised properly.

Regards


On Mon, Mar 10, 2014 at 1:43 PM, Sandhya Sree sandhyachinna...@gmail.comwrote:

 Exception in thread pool-2-thread-1 Exception executing consequence for
 rule size in com.net: java.lang.NullPointerException
  at
 org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
  at
 org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1297)
 at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1221)
  at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1456)
 at
 org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710)
  at
 org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674)
 at
 org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230)
  at com.net.RuleExecutor.execute(RuleExecutor.java:18)
 at com.net.DirectoryMonitor.run(DirectoryMonitor.java:39)
  at
 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
 at
 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
  at java.lang.Thread.run(Thread.java:744)
 Caused by: java.lang.NullPointerException
 at
 com.net.Rule_size_dc2a47e2812648e69eb9581eda931496.defaultConsequence(Rule_size_dc2a47e2812648e69eb9581eda931496.java:9)
  at
 com.net.Rule_size_dc2a47e2812648e69eb9581eda931496DefaultConsequenceInvokerGenerated.evaluate(Unknown
 Source)
 at
 com.net.Rule_size_dc2a47e2812648e69eb9581eda931496DefaultConsequenceInvoker.evaluate(Unknown
 Source)
  at
 org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1287)


 On Mon, Mar 10, 2014 at 7:08 PM, Mauricio Salatino sala...@gmail.comwrote:

 Please copy the entire stack trace.. what you have copied doesn't mean
 anything besides that there is something wrong.


 On Mon, Mar 10, 2014 at 1:29 PM, Sandhya Sree sandhyachinna...@gmail.com
  wrote:

 im getting the following error on doing that

 Exception in thread pool-2-thread-1 Exception executing consequence
 for rule size in com.net: java.lang.NullPointerException

 what might be the problem?



 On Mon, Mar 10, 2014 at 4:16 PM, Wolfgang Laun 
 wolfgang.l...@gmail.comwrote:

 Seeing that the list is static you can use the usual way for accessing
 a static class member:

 Event.listOfEvent.add( ... );

 @Mauricio: It's not unusual to maintain a static collection (even
 though there may be better ways, esp. with Drools).



 On 10/03/2014, Mauricio Salatino sala...@gmail.com wrote:
  Can you please elaborate about why do you want to do that? what's the
 point
  of having a list inside of the Event class that will contain the same
  event?
 
  The Then side of the rule is pure java.. so you just do
  event.getEvents().add(event);
 
  but I don't see the point of doing that.
 
  Regards
 
 
  On Mon, Mar 10, 2014 at 10:31 AM, Sandhya Sree
  sandhyachinna...@gmail.comwrote:
 
  hi ,
 
  i have a class called Event which is as follows:
 
  public class Event {
   private  String name;
   private  File source;
   private  Date timeStamp;
  public static ListEvent listOfEvents;
 
  public Event(String name, File source, Date timeStamp) {
   this.name = name;
  this.source = source;
  this.timeStamp = timeStamp;
   }
   public String getName() {
   return name;
  }
  public void setName(String name) {
   this.name = name;
  }
  public File getSource() {
   return source;
  }
  public void setSource(File source) {
   this.source = source;
  }
  public Date getTimeStamp() {
   return timeStamp;
  }
  public void setTimeStamp(Date timeStamp) {
   this.timeStamp = timeStamp;
  }
 
 
   public void display()
   {
   System.out.println(name +  + in folder:  + source +  on  +
  timeStamp );
}
 
 
 
  there are also some other classes associated with my project.. i
 have a
  rules file which computes the size of a folder and creates an object
 of
  Event class. every time this object of Event class is created i
 wwant to
  put it in a ListEvent.. how can i do this..
 
  my rules is as follows:
 
  rule size
  when
$p:  RuleContext($size:
 getOldContext().getParent().getUsableSpace() 
  (30*1024*1024))
 
  then
 Event event = new Event(folder almost full,
  $p.getOldContext().getParent(), new Date());
 event.display();
 ..here i want to put this event into the ListEvent declared
 in
  Event Class.
 
end
 
 
 
  thanks,
  Sandhya
 
  ___
  rules-users mailing list
  rules-users@lists.jboss.org
  https://lists.jboss.org/mailman/listinfo/rules-users
 
 
 
 
  --
   - MyJourney @ http://salaboy.com http://salaboy.wordpress.com
   - Co-Founder @ http://www.jugargentina.org
   - Co-Founder @ http://www.jbug.com.ar
 
   - Salatino Salaboy Mauricio -
 
 

Re: [rules-users] (no subject)

2014-03-10 Thread Sandhya Sree
Thanks :)
i got it :-)


On Mon, Mar 10, 2014 at 7:18 PM, Mauricio Salatino sala...@gmail.comwrote:

 If the list inside  Event has never being initialised it will throw a
 null point exception.. so you need to make sure that the list
 is initialised properly.

 Regards


 On Mon, Mar 10, 2014 at 1:43 PM, Sandhya Sree 
 sandhyachinna...@gmail.comwrote:

 Exception in thread pool-2-thread-1 Exception executing consequence for
 rule size in com.net: java.lang.NullPointerException
  at
 org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
  at
 org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1297)
 at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1221)
  at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1456)
 at
 org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710)
  at
 org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674)
 at
 org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230)
  at com.net.RuleExecutor.execute(RuleExecutor.java:18)
 at com.net.DirectoryMonitor.run(DirectoryMonitor.java:39)
  at
 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
 at
 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
  at java.lang.Thread.run(Thread.java:744)
 Caused by: java.lang.NullPointerException
 at
 com.net.Rule_size_dc2a47e2812648e69eb9581eda931496.defaultConsequence(Rule_size_dc2a47e2812648e69eb9581eda931496.java:9)
  at
 com.net.Rule_size_dc2a47e2812648e69eb9581eda931496DefaultConsequenceInvokerGenerated.evaluate(Unknown
 Source)
 at
 com.net.Rule_size_dc2a47e2812648e69eb9581eda931496DefaultConsequenceInvoker.evaluate(Unknown
 Source)
  at
 org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1287)


 On Mon, Mar 10, 2014 at 7:08 PM, Mauricio Salatino sala...@gmail.comwrote:

 Please copy the entire stack trace.. what you have copied doesn't mean
 anything besides that there is something wrong.


 On Mon, Mar 10, 2014 at 1:29 PM, Sandhya Sree 
 sandhyachinna...@gmail.com wrote:

 im getting the following error on doing that

 Exception in thread pool-2-thread-1 Exception executing consequence
 for rule size in com.net: java.lang.NullPointerException

 what might be the problem?



 On Mon, Mar 10, 2014 at 4:16 PM, Wolfgang Laun wolfgang.l...@gmail.com
  wrote:

 Seeing that the list is static you can use the usual way for accessing
 a static class member:

 Event.listOfEvent.add( ... );

 @Mauricio: It's not unusual to maintain a static collection (even
 though there may be better ways, esp. with Drools).



 On 10/03/2014, Mauricio Salatino sala...@gmail.com wrote:
  Can you please elaborate about why do you want to do that? what's
 the point
  of having a list inside of the Event class that will contain the same
  event?
 
  The Then side of the rule is pure java.. so you just do
  event.getEvents().add(event);
 
  but I don't see the point of doing that.
 
  Regards
 
 
  On Mon, Mar 10, 2014 at 10:31 AM, Sandhya Sree
  sandhyachinna...@gmail.comwrote:
 
  hi ,
 
  i have a class called Event which is as follows:
 
  public class Event {
   private  String name;
   private  File source;
   private  Date timeStamp;
  public static ListEvent listOfEvents;
 
  public Event(String name, File source, Date timeStamp) {
   this.name = name;
  this.source = source;
  this.timeStamp = timeStamp;
   }
   public String getName() {
   return name;
  }
  public void setName(String name) {
   this.name = name;
  }
  public File getSource() {
   return source;
  }
  public void setSource(File source) {
   this.source = source;
  }
  public Date getTimeStamp() {
   return timeStamp;
  }
  public void setTimeStamp(Date timeStamp) {
   this.timeStamp = timeStamp;
  }
 
 
   public void display()
   {
   System.out.println(name +  + in folder:  + source +  on  +
  timeStamp );
}
 
 
 
  there are also some other classes associated with my project.. i
 have a
  rules file which computes the size of a folder and creates an
 object of
  Event class. every time this object of Event class is created i
 wwant to
  put it in a ListEvent.. how can i do this..
 
  my rules is as follows:
 
  rule size
  when
$p:  RuleContext($size:
 getOldContext().getParent().getUsableSpace() 
  (30*1024*1024))
 
  then
 Event event = new Event(folder almost full,
  $p.getOldContext().getParent(), new Date());
 event.display();
 ..here i want to put this event into the ListEvent
 declared in
  Event Class.
 
end
 
 
 
  thanks,
  Sandhya
 
  ___
  rules-users mailing list
  rules-users@lists.jboss.org
  https://lists.jboss.org/mailman/listinfo/rules-users
 
 
 
 
  --
   - MyJourney @ http://salaboy.com http://salaboy.wordpress.com
   - Co-Founder @ 

Re: [rules-users] (no subject)

2014-03-10 Thread Wolfgang Laun
Initializing references to objects is always a good idea to avoid NPE.
-W

On 10/03/2014, Sandhya Sree sandhyachinna...@gmail.com wrote:
 im getting the following error on doing that

 Exception in thread pool-2-thread-1 Exception executing consequence for
 rule size in com.net: java.lang.NullPointerException

 what might be the problem?



 On Mon, Mar 10, 2014 at 4:16 PM, Wolfgang Laun
 wolfgang.l...@gmail.comwrote:

 Seeing that the list is static you can use the usual way for accessing
 a static class member:

 Event.listOfEvent.add( ... );

 @Mauricio: It's not unusual to maintain a static collection (even
 though there may be better ways, esp. with Drools).



 On 10/03/2014, Mauricio Salatino sala...@gmail.com wrote:
  Can you please elaborate about why do you want to do that? what's the
 point
  of having a list inside of the Event class that will contain the same
  event?
 
  The Then side of the rule is pure java.. so you just do
  event.getEvents().add(event);
 
  but I don't see the point of doing that.
 
  Regards
 
 
  On Mon, Mar 10, 2014 at 10:31 AM, Sandhya Sree
  sandhyachinna...@gmail.comwrote:
 
  hi ,
 
  i have a class called Event which is as follows:
 
  public class Event {
   private  String name;
   private  File source;
   private  Date timeStamp;
  public static ListEvent listOfEvents;
 
  public Event(String name, File source, Date timeStamp) {
   this.name = name;
  this.source = source;
  this.timeStamp = timeStamp;
   }
   public String getName() {
   return name;
  }
  public void setName(String name) {
   this.name = name;
  }
  public File getSource() {
   return source;
  }
  public void setSource(File source) {
   this.source = source;
  }
  public Date getTimeStamp() {
   return timeStamp;
  }
  public void setTimeStamp(Date timeStamp) {
   this.timeStamp = timeStamp;
  }
 
 
   public void display()
   {
   System.out.println(name +  + in folder:  + source +  on  +
  timeStamp );
}
 
 
 
  there are also some other classes associated with my project.. i have
  a
  rules file which computes the size of a folder and creates an object
  of
  Event class. every time this object of Event class is created i wwant
  to
  put it in a ListEvent.. how can i do this..
 
  my rules is as follows:
 
  rule size
  when
$p:  RuleContext($size: getOldContext().getParent().getUsableSpace()
  
  (30*1024*1024))
 
  then
 Event event = new Event(folder almost full,
  $p.getOldContext().getParent(), new Date());
 event.display();
 ..here i want to put this event into the ListEvent declared
  in
  Event Class.
 
end
 
 
 
  thanks,
  Sandhya
 
  ___
  rules-users mailing list
  rules-users@lists.jboss.org
  https://lists.jboss.org/mailman/listinfo/rules-users
 
 
 
 
  --
   - MyJourney @ http://salaboy.com http://salaboy.wordpress.com
   - Co-Founder @ http://www.jugargentina.org
   - Co-Founder @ http://www.jbug.com.ar
 
   - Salatino Salaboy Mauricio -
 
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users


___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Test Classpath setup question

2014-03-10 Thread balazs.molnar
In KModuleBeanFactoryPostProcessor there are statements like 

this: configFilePath = getClass().getResource(/).getPath();

which do not necessarily resolve to the path where the rule resources are.
Replacing this code with one that looks for the rule packages location
worked for me.



--
View this message in context: 
http://drools.46999.n3.nabble.com/Test-Classpath-setup-question-tp4028583p4028611.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] DSL: Unable to Expand Error - Even things that shouldn't be expanded.

2014-03-10 Thread SrjTx
Ok, this should make it happen

1) Add new Guided Rule
2) Tick Use DSL
3) Click OK
4) Add a DSL sentence
5) Validated rule - OK
6) Viewed Source - OK
7) Saved - OK
8) Re-opened - OK
*9) Add a raw DRL to the then clause
10) Save and publish.  You should see error in server.log*

restarting jboss fixes it.



--
View this message in context: 
http://drools.46999.n3.nabble.com/DSL-Unable-to-Expand-Error-Even-things-that-shouldn-t-be-expanded-tp4027749p4028612.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] NullPointerException with LeftTupleIndexHashTable.remove()

2014-03-10 Thread nxv
Hi,

This issue has been fixed in version: 6.1.0.Beta1

Nicolas-Xavier

Le 10/03/2014 16:34, iqextremer [via Drools] a écrit :
 I am also suffering the same issue, wonder if there is any resolution 
 on this yet?

 
 If you reply to this email, your message will be added to the 
 discussion below:
 http://drools.46999.n3.nabble.com/NullPointerException-with-LeftTupleIndexHashTable-remove-tp4028133p4028613.html
  

 To unsubscribe from NullPointerException with 
 LeftTupleIndexHashTable.remove(), click here 
 http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=4028133code=bnh2YW5kZXJsaW5kZW5AZ21haWwuY29tfDQwMjgxMzN8LTY5OTE5Nzg5Nw==.
 NAML 
 http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
  






--
View this message in context: 
http://drools.46999.n3.nabble.com/NullPointerException-with-LeftTupleIndexHashTable-remove-tp4028133p4028615.html
Sent from the Drools: User forum mailing list archive at Nabble.com.___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

[rules-users] Drools pipeline API

2014-03-10 Thread GrantWang
Hi, I am new to Drools and have couple of questions:

1. I found the following in document:
 
The Drools pipeline API has several adapters and helpers to do that as well
as examples on how to do it.

Could someone please send me a link to this Drools pipeline API. I did a
search but couldn't find it.

2. I am looking to a way to load a DRL on the fly. All the examples I found
online is from 5.X:

File drl1 = new 
File(src/main/resources/rules/DroolsTest.drl); 
Resource resource1 = 
ResourceFactory.newInputStreamResource(new
FileInputStream(drl1));
KnowledgeBuilder builder = 
KnowledgeBuilderFactory.newKnowledgeBuilder();
builder.add(resource1, ResourceType.DRL);
KnowledgeBase kb = builder.newKnowledgeBase();
kSession = kb.newStatefulKnowledgeSession();
kSession.fireUntilHalt();

It works, but looks like the type KnowledgeBase is deprecated in 6.0. And I
couldn't find it in Kie API java doc. How can I do the same in 6.0? Also is
there a way I can monitor a directory? So that new rule files can be loaded
automatically after add into this directory (suppose I don't need to do
anything in my App since I used fireUntilHalt.)

Thanks a lot. 
 



--
View this message in context: 
http://drools.46999.n3.nabble.com/Drools-pipeline-API-tp4028616.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] looping in drools

2014-03-10 Thread Sandhya Sree
hi,
im new to drools..im trying to create a project as follows. i have a class
called Monitor  which monitors a folder and creates two lists called
fileOld( which is the list of filenames in that folder at time t1)  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.

i also have another class called Event which is as follows:
public class Event {
 public static String name;
 private  File source;
 private  Date timeStamp;
public  static  ListEvent listOfEvents = new ArrayListEvent();

public Event(String name, File source, Date timeStamp) {
this.name = name;
this.source = source;
this.timeStamp = timeStamp;
}
 public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public File getSource() {
return source;
}
public void setSource(File source) {
this.source = source;
}
public Date getTimeStamp() {
return timeStamp;
}
public void setTimeStamp(Date timeStamp) {
this.timeStamp = timeStamp;
}

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 ListEvent listOfEvents.

here is my rule file:

rrule files are equal
when
 FileData( fileOld == fileNew)
then
   System.out.println(files are equal);
end


rule files not equal
when
FileData($old : fileOld, $new : fileNew, fileOld != fileNew)

then
   accumulate( $s : String( this not memberOf $old ) from $new, $plus :
collectList( $s ) )
   accumulate( $t : String( this not memberOf $new ) from $old, $mins :
collectList( $t ) )
   System.out.println(files added: + $plus );
   System.out.println( files deleted: + $mins );
end



how can i loop through each of the file added or deleted and create an
Event Class object for every file added and deleted  and finally add all
the created objects to ListEvent listOfEvents..


Thanks.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Re: [rules-users] looping in drools

2014-03-10 Thread Davide Sottara
The accumulates should not be in the then part of a rule (see my
previous email).
That rule gave you two lists, in the variables $plus and $mins, that you
can use in the consequence.

If you need to process each file separately, you may want to do
something like this:

rule new file
when
FileData($old : fileOld, $new : fileNew, fileOld != fileNew)
   $newFile : String( this not memberOf $old ) from $new
then  
   // create new event for a new file : new Event(...)
   // add to list : Event.listOfEvents.add(...)
end

You'll need another rule for the files that have been removed.

Notice that your Event class has no way to distinguish added from
removed files, you may want to
add a boolean or something there.
Best
Davide

On 03/10/2014 07:04 PM, Sandhya Sree wrote:
 hi,
 im new to drools..im trying to create a project as follows. i have a
 class called Monitor  which monitors a folder and creates two lists
 called fileOld( which is the list of filenames in that folder at time
 t1)  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.

 i also have another class called Event which is as follows:
 public class Event {
 public static String name;
 private  File source;
 private  Date timeStamp;
 public  static  ListEvent listOfEvents = new ArrayListEvent();
  
 public Event(String name, File source, Date timeStamp) {
 this.name http://this.name = name;
 this.source = source;
 this.timeStamp = timeStamp;
 }
 public String getName() {
 return name;
 }
 public void setName(String name) {
 this.name http://this.name = name;
 }
 public File getSource() {
 return source;
 }
 public void setSource(File source) {
 this.source = source;
 }
 public Date getTimeStamp() {
 return timeStamp;
 }
 public void setTimeStamp(Date timeStamp) {
 this.timeStamp = timeStamp;
 }

 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 ListEvent listOfEvents.

 here is my rule file:

 rrule files are equal
 when 
  FileData( fileOld == fileNew)
 then
System.out.println(files are equal);
 end


 rule files not equal
 when
 FileData($old : fileOld, $new : fileNew, fileOld != fileNew)
 
 then
accumulate( $s : String( this not memberOf $old ) from $new, $plus
 : collectList( $s ) ) 
accumulate( $t : String( this not memberOf $new ) from $old, $mins
 : collectList( $t ) ) 
System.out.println(files added: + $plus ); 
System.out.println( files deleted: + $mins );
 end



 how can i loop through each of the file added or deleted and create an
 Event Class object for every file added and deleted  and finally add
 all the created objects to ListEvent listOfEvents..


 Thanks.


 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Re: [rules-users] looping in drools

2014-03-10 Thread Sandhya Sree
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
ListEvent listOfEvents.


Thanks.


On Mon, Mar 10, 2014 at 11:48 PM, Davide Sottara dso...@gmail.com wrote:

  The accumulates should not be in the then part of a rule (see my
 previous email).
 That rule gave you two lists, in the variables $plus and $mins, that you
 can use in the consequence.

 If you need to process each file separately, you may want to do something
 like this:

 rule new file
 when
 FileData($old : fileOld, $new : fileNew, fileOld != fileNew)
 $newFile : String( this not memberOf $old ) from $new
  then
// create new event for a new file : new Event(...)
// add to list : Event.listOfEvents.add(...)
  end

  You'll need another rule for the files that have been removed.

 Notice that your Event class has no way to distinguish added from
 removed files, you may want to
 add a boolean or something there.
 Best
 Davide


 On 03/10/2014 07:04 PM, Sandhya Sree wrote:

 hi,
 im new to drools..im trying to create a project as follows. i have a class
 called Monitor  which monitors a folder and creates two lists called
 fileOld( which is the list of filenames in that folder at time t1)  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.

  i also have another class called Event which is as follows:
  public class Event {
   public static String name;
  private  File source;
  private  Date timeStamp;
 public  static  ListEvent listOfEvents = new ArrayListEvent();

  public Event(String name, File source, Date timeStamp) {
  this.name = name;
  this.source = source;
  this.timeStamp = timeStamp;
  }
public String getName() {
  return name;
  }
  public void setName(String name) {
  this.name = name;
  }
  public File getSource() {
  return source;
  }
  public void setSource(File source) {
  this.source = source;
  }
  public Date getTimeStamp() {
  return timeStamp;
  }
  public void setTimeStamp(Date timeStamp) {
  this.timeStamp = timeStamp;
  }

  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 ListEvent listOfEvents.

  here is my rule file:

  rrule files are equal
 when
  FileData( fileOld == fileNew)
 then
System.out.println(files are equal);
 end


  rule files not equal
 when
 FileData($old : fileOld, $new : fileNew, fileOld != fileNew)

  then
accumulate( $s : String( this not memberOf $old ) from $new, $plus :
 collectList( $s ) )
accumulate( $t : String( this not memberOf $new ) from $old, $mins :
 collectList( $t ) )
System.out.println(files added: + $plus );
System.out.println( files deleted: + $mins );
  end



  how can i loop through each of the file added or deleted and create an
 Event Class object for every file added and deleted  and finally add all
 the created objects to ListEvent listOfEvents..


  Thanks.


 ___
 rules-users mailing 
 listrules-users@lists.jboss.orghttps://lists.jboss.org/mailman/listinfo/rules-users



 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Re: [rules-users] looping in drools

2014-03-10 Thread Davide Sottara
from will iterate for you, exactly like accumulate counted the events.
If you need more details, please consult the documentation


On 03/10/2014 07:29 PM, Sandhya Sree wrote:
 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 ListEvent listOfEvents. 


 Thanks.


 On Mon, Mar 10, 2014 at 11:48 PM, Davide Sottara dso...@gmail.com
 mailto:dso...@gmail.com wrote:

 The accumulates should not be in the then part of a rule (see
 my previous email).
 That rule gave you two lists, in the variables $plus and $mins,
 that you can use in the consequence.

 If you need to process each file separately, you may want to do
 something like this:

 rule new file
 when
 FileData($old : fileOld, $new : fileNew, fileOld != fileNew)
$newFile : String( this not memberOf $old ) from $new
 then  
// create new event for a new file : new Event(...)
// add to list : Event.listOfEvents.add(...)
 end

 You'll need another rule for the files that have been removed.

 Notice that your Event class has no way to distinguish added
 from removed files, you may want to
 add a boolean or something there.
 Best
 Davide


 On 03/10/2014 07:04 PM, Sandhya Sree wrote:
 hi,
 im new to drools..im trying to create a project as follows. i
 have a class called Monitor  which monitors a folder and creates
 two lists called fileOld( which is the list of filenames in that
 folder at time t1)  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.

 i also have another class called Event which is as follows:
 public class Event {
 public static String name;
 private  File source;
 private  Date timeStamp;
 public  static  ListEvent listOfEvents = new
 ArrayListEvent();
  
 public Event(String name, File source, Date timeStamp) {
 this.name http://this.name = name;
 this.source = source;
 this.timeStamp = timeStamp;
 }
 public String getName() {
 return name;
 }
 public void setName(String name) {
 this.name http://this.name = name;
 }
 public File getSource() {
 return source;
 }
 public void setSource(File source) {
 this.source = source;
 }
 public Date getTimeStamp() {
 return timeStamp;
 }
 public void setTimeStamp(Date timeStamp) {
 this.timeStamp = timeStamp;
 }

 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
 ListEvent listOfEvents.

 here is my rule file:

 rrule files are equal
 when 
  FileData( fileOld == fileNew)
 then
System.out.println(files are equal);
 end


 rule files not equal
 when
 FileData($old : fileOld, $new : fileNew, fileOld != fileNew)
 
 then
accumulate( $s : String( this not memberOf $old ) from $new,
 $plus : collectList( $s ) ) 
accumulate( $t : String( this not memberOf $new ) from $old,
 $mins : collectList( $t ) ) 
System.out.println(files added: + $plus ); 
System.out.println( files deleted: + $mins );
 end



 how can i loop through each of the file added or deleted and
 create an Event Class object for every file added and deleted
  and finally add all the created objects to ListEvent
 listOfEvents..


 Thanks.


 ___
 rules-users mailing list
 rules-users@lists.jboss.org mailto:rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users


 ___
 rules-users mailing list
 rules-users@lists.jboss.org mailto:rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Re: [rules-users] looping in drools

2014-03-10 Thread Sandhya Sree
i tried this :

rule new file
when
FileData($old : fileOld, $new : fileNew, fileOld != fileNew)
$newFile : String( this not memberOf $old ) from $new
then
event : Event(file added, filename, new Date()) from $plus
Event.listOfEvents.add(event);
event.display();
end


this gives the following error:
The method Event(String, File, Date) is undefined for the type
Rule_new_file_0c90fff8d9b74b439ab79971b13b75ac
 Syntax error on token from, ; expected
 $plus cannot be resolved to a type
 Syntax error on token ., ; expected
 listOfEvents cannot be resolved


On Tue, Mar 11, 2014 at 12:09 AM, Davide Sottara dso...@gmail.com wrote:

  from will iterate for you, exactly like accumulate counted the
 events.
 If you need more details, please consult the documentation



 On 03/10/2014 07:29 PM, Sandhya Sree wrote:

 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
 ListEvent listOfEvents.


  Thanks.


 On Mon, Mar 10, 2014 at 11:48 PM, Davide Sottara dso...@gmail.com wrote:

  The accumulates should not be in the then part of a rule (see my
 previous email).
 That rule gave you two lists, in the variables $plus and $mins, that you
 can use in the consequence.

 If you need to process each file separately, you may want to do something
 like this:

 rule new file
  when
 FileData($old : fileOld, $new : fileNew, fileOld != fileNew)
  $newFile : String( this not memberOf $old ) from $new
  then
// create new event for a new file : new Event(...)
// add to list : Event.listOfEvents.add(...)
  end

  You'll need another rule for the files that have been removed.

 Notice that your Event class has no way to distinguish added from
 removed files, you may want to
 add a boolean or something there.
 Best
 Davide


 On 03/10/2014 07:04 PM, Sandhya Sree wrote:

  hi,
 im new to drools..im trying to create a project as follows. i have a
 class called Monitor  which monitors a folder and creates two lists called
 fileOld( which is the list of filenames in that folder at time t1)  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.

  i also have another class called Event which is as follows:
  public class Event {
   public static String name;
  private  File source;
  private  Date timeStamp;
 public  static  ListEvent listOfEvents = new ArrayListEvent();

  public Event(String name, File source, Date timeStamp) {
  this.name = name;
  this.source = source;
  this.timeStamp = timeStamp;
  }
public String getName() {
  return name;
  }
  public void setName(String name) {
  this.name = name;
  }
  public File getSource() {
  return source;
  }
  public void setSource(File source) {
  this.source = source;
  }
  public Date getTimeStamp() {
  return timeStamp;
  }
  public void setTimeStamp(Date timeStamp) {
  this.timeStamp = timeStamp;
  }

  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 ListEvent listOfEvents.

  here is my rule file:

  rrule files are equal
 when
  FileData( fileOld == fileNew)
 then
System.out.println(files are equal);
 end


  rule files not equal
 when
 FileData($old : fileOld, $new : fileNew, fileOld != fileNew)

  then
accumulate( $s : String( this not memberOf $old ) from $new, $plus :
 collectList( $s ) )
accumulate( $t : String( this not memberOf $new ) from $old, $mins :
 collectList( $t ) )
System.out.println(files added: + $plus );
System.out.println( files deleted: + $mins );
  end



  how can i loop through each of the file added or deleted and create an
 Event Class object for every file added and deleted  and finally add all
 the created objects to ListEvent listOfEvents..


  Thanks.


  ___
 rules-users mailing 
 listrules-users@lists.jboss.orghttps://lists.jboss.org/mailman/listinfo/rules-users



 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




 ___
 rules-users mailing 
 listrules-users@lists.jboss.orghttps://lists.jboss.org/mailman/listinfo/rules-users



 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

___
rules-users mailing list
rules-users@lists.jboss.org

Re: [rules-users] looping in drools

2014-03-10 Thread Wolfgang Laun
Will you please, please, PLEASE have a short look at the Drools
documentation, available just for the effort of reading it? This will
tell you that accumulate and from are constructs to be used on the
left hand side of a rule and NOT on the right hand side, where (with
the exception of a few additional statements) everything is plain old
Java code.

Cheers
-WL

On 10/03/2014, Sandhya Sree sandhyachinna...@gmail.com wrote:
 i tried this :

 rule new file
 when
 FileData($old : fileOld, $new : fileNew, fileOld != fileNew)
 $newFile : String( this not memberOf $old ) from $new
 then
 event : Event(file added, filename, new Date()) from $plus
 Event.listOfEvents.add(event);
 event.display();
 end


 this gives the following error:
 The method Event(String, File, Date) is undefined for the type
 Rule_new_file_0c90fff8d9b74b439ab79971b13b75ac
  Syntax error on token from, ; expected
  $plus cannot be resolved to a type
  Syntax error on token ., ; expected
  listOfEvents cannot be resolved


 On Tue, Mar 11, 2014 at 12:09 AM, Davide Sottara dso...@gmail.com wrote:

  from will iterate for you, exactly like accumulate counted the
 events.
 If you need more details, please consult the documentation



 On 03/10/2014 07:29 PM, Sandhya Sree wrote:

 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
 ListEvent listOfEvents.


  Thanks.


 On Mon, Mar 10, 2014 at 11:48 PM, Davide Sottara dso...@gmail.com
 wrote:

  The accumulates should not be in the then part of a rule (see my
 previous email).
 That rule gave you two lists, in the variables $plus and $mins, that you
 can use in the consequence.

 If you need to process each file separately, you may want to do
 something
 like this:

 rule new file
  when
 FileData($old : fileOld, $new : fileNew, fileOld != fileNew)
  $newFile : String( this not memberOf $old ) from $new
  then
// create new event for a new file : new Event(...)
// add to list : Event.listOfEvents.add(...)
  end

  You'll need another rule for the files that have been removed.

 Notice that your Event class has no way to distinguish added from
 removed files, you may want to
 add a boolean or something there.
 Best
 Davide


 On 03/10/2014 07:04 PM, Sandhya Sree wrote:

  hi,
 im new to drools..im trying to create a project as follows. i have a
 class called Monitor  which monitors a folder and creates two lists
 called
 fileOld( which is the list of filenames in that folder at time t1)  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.

  i also have another class called Event which is as follows:
  public class Event {
   public static String name;
  private  File source;
  private  Date timeStamp;
 public  static  ListEvent listOfEvents = new
 ArrayListEvent();

  public Event(String name, File source, Date timeStamp) {
  this.name = name;
  this.source = source;
  this.timeStamp = timeStamp;
  }
public String getName() {
  return name;
  }
  public void setName(String name) {
  this.name = name;
  }
  public File getSource() {
  return source;
  }
  public void setSource(File source) {
  this.source = source;
  }
  public Date getTimeStamp() {
  return timeStamp;
  }
  public void setTimeStamp(Date timeStamp) {
  this.timeStamp = timeStamp;
  }

  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 ListEvent listOfEvents.

  here is my rule file:

  rrule files are equal
 when
  FileData( fileOld == fileNew)
 then
System.out.println(files are equal);
 end


  rule files not equal
 when
 FileData($old : fileOld, $new : fileNew, fileOld != fileNew)

  then
accumulate( $s : String( this not memberOf $old ) from $new, $plus :
 collectList( $s ) )
accumulate( $t : String( this not memberOf $new ) from $old, $mins :
 collectList( $t ) )
System.out.println(files added: + $plus );
System.out.println( files deleted: + $mins );
  end



  how can i loop through each of the file added or deleted and create an
 Event Class object for every file added and deleted  and finally add all
 the created objects to ListEvent listOfEvents..


  Thanks.


  ___
 rules-users mailing
 listrules-users@lists.jboss.orghttps://lists.jboss.org/mailman/listinfo/rules-users



 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




 

Re: [rules-users] Drools pipeline API

2014-03-10 Thread Mark Proctor
pipeline was deprecated years ago.

Use camel.

Mark
On 10 Mar 2014, at 16:25, GrantWang grant.w...@intrado.com wrote:

 Hi, I am new to Drools and have couple of questions:
 
 1. I found the following in document:
 
 The Drools pipeline API has several adapters and helpers to do that as well
 as examples on how to do it.
 
 Could someone please send me a link to this Drools pipeline API. I did a
 search but couldn't find it.
 
 2. I am looking to a way to load a DRL on the fly. All the examples I found
 online is from 5.X:
 
   File drl1 = new 
 File(src/main/resources/rules/DroolsTest.drl); 
   Resource resource1 = 
 ResourceFactory.newInputStreamResource(new
 FileInputStream(drl1));
   KnowledgeBuilder builder = 
 KnowledgeBuilderFactory.newKnowledgeBuilder();
   builder.add(resource1, ResourceType.DRL);
   KnowledgeBase kb = builder.newKnowledgeBase();
   kSession = kb.newStatefulKnowledgeSession();
kSession.fireUntilHalt();
 
 It works, but looks like the type KnowledgeBase is deprecated in 6.0. And I
 couldn't find it in Kie API java doc. How can I do the same in 6.0? Also is
 there a way I can monitor a directory? So that new rule files can be loaded
 automatically after add into this directory (suppose I don't need to do
 anything in my App since I used fireUntilHalt.)
 
 Thanks a lot. 
 
 
 
 
 --
 View this message in context: 
 http://drools.46999.n3.nabble.com/Drools-pipeline-API-tp4028616.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users


___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Drools pipeline API

2014-03-10 Thread GrantWang
Thanks, Mark.

Would you please help with my 2nd question, i.e. the best way to monitor
several directories and load DRL files on the fly in Drools 6.0 release?

Best regards.



--
View this message in context: 
http://drools.46999.n3.nabble.com/Drools-pipeline-API-tp4028616p4028625.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Large data sets

2014-03-10 Thread Raja Sekhar
Hi
Is it a good approach to apply rules on large data-sets ranging 100,000 to
50 million records Of course it depends upon the logic written in the rule
conditions and consequences.

-- 
Raja Sekhar Amirapu
--
If any anyone can do it, i can do it. If no one else can do it, i must do
it
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users