Re: [rules-users] Equal shift assignment based on employment form

2013-11-14 Thread ns
Does anyone have any idea how to solve my problem? Thank you.



--
View this message in context: 
http://drools.46999.n3.nabble.com/Equal-shift-assignment-based-on-employment-form-tp4026746p4026778.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] How can I iterate through the ArrayList

2013-11-14 Thread Govind J. Parashar
Hi


Below have my java code and main method I want  to fire rule for all value of 
STATUS   how to write drl for this 

I am passing  awaitingActionList to rule

public static void main(String args[]) throws Exception {
  
KnowledgeBase kbase = readKnowledgeBase();  
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
 
AwaitingAction action = new AwaitingAction();
AwaitingActionList awaitingActionList = new AwaitingActionList();
ListAwaitingAction list = new ArrayListAwaitingAction();
action.setStatus(CU);
action.setValue(Create User);
list.add(action);
action = new AwaitingAction();
action.setStatus(CLU);
action.setValue(Complete Request);
list.add(action);
action = new AwaitingAction();
action.setStatus(CP);
action.setValue(Create Position);
list.add(action);
awaitingActionList.setAwaitingActionsList(list);
for(AwaitingAction actionVO : awaitingActionList.getAwaitingActionsList())
{
System.out.println(VALUE:-- +actionVO.getValue()+
STATUS:-- +actionVO.getStatus()+   REDIRECT TO:-- +actionVO.getRedirect());
}   

ksession.insert(awaitingActionList);  
ksession.fireAllRules();  
ksession.dispose();  

  }



private static KnowledgeBase readKnowledgeBase() throws Exception {  
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();  
kbuilder.add(ResourceFactory.newClassPathResource(AwaitingAction.drl), 
ResourceType.DRL);  
KnowledgeBuilderErrors errors = kbuilder.getErrors();  
if (errors.size()  0) {  
  for (KnowledgeBuilderError error : errors) {  
System.err.println(error);  
  }  
  throw new IllegalArgumentException(Could not parse knowledge.);  
}  
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();  
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());  
return kbase;  
  }  
}  




public class AwaitingAction {

private String status;
private String value;
private String redirect;
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getRedirect() {
return redirect;
}
public void setRedirect(String redirect) {
this.redirect = redirect;
}



public class AwaitingActionList {

public ListAwaitingAction awaitingActionsList =  new 
ArrayListAwaitingAction();

public ListAwaitingAction getAwaitingActionsList() {
return awaitingActionsList;
}

public void setAwaitingActionsList(ListAwaitingAction 
awaitingActionsList) {
this.awaitingActionsList = awaitingActionsList;
}


}




-Original Message-
From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Wolfgang Laun
Sent: 14 November 2013 05:08
To: Rules Users List
Subject: Re: [rules-users] How can I iterate through the ArrayList

You may have to phrase your question more accurately in order to get an answer.

Do you want the rule to fire if some, or if all, value fields of the 
AwaitingAction have some value? Once or for each AwaitingAction? Or do you want 
it to fire once if at least one, or if all, AwaitingActions of all 
AwaitingActionLists have a field value with some specific value?

Also, would you consider inserting also the AwaitingAction objects as facts, 
not only the AwaitingActionList?

-W



On 13/11/2013, Govind J. Parashar govind.paras...@mastek.com wrote:
 HI,

 I have a AwaitingActionList Object which has a awaitingActionsList 
 Object which has a ArrayList of AwaitingAction Objects. How can I 
 iterate through the ArrayList to get to check each object 
 AwaitingAction .value in the drl file.

 Java refrence file attached

 Thanks
 Govind
 MASTEK LTD.
 In the US, we're called MAJESCOMASTEK

 ~~
 
 Opinions expressed in this e-mail are those of the individual and not 
 that of Mastek Limited, unless specifically indicated to that effect. 
 Mastek Limited does not accept any responsibility or liability for it. 
 This e-mail and attachments (if any) transmitted with it are 
 confidential and/or privileged and solely for the use of the intended 
 person or entity to which it is addressed. Any review, 
 re-transmission, dissemination or other use of or taking of any action 
 in reliance upon this information by persons or entities other than 
 the intended recipient is prohibited. This e-mail and its attachments 
 have been scanned for the presence of 

[rules-users] 5.6.0.CR1 gives a NullPointerException in after evaluator

2013-11-14 Thread abr
Hi everyone,

I tried to switch from 5.5.0.Final to 5.6.0.CR1 and got a null pointer
exception in the evaluation of the after evaluator.
(Exact method is:
/org.drools.base.evaluators.AfterEvaluatorDefinition.AfterEvaluator.evaluate(InternalWorkingMemory,
InternalReadAccessor, InternalFactHandle, InternalReadAccessor,
InternalFactHandle)/ )

When debugging, the exception occurs at the very first line of the method,
in:
/if ( extractor1.isNullValue( workingMemory, handle1.getObject() ) || 
extractor2.isNullValue( workingMemory, handle2.getObject() ) ) {
return false;
}
/
The cause of the exception is that handle1 is null.

The rule where the exception occurs looks like:
/MyFact(
fromdate before[ 0d ] $min,
( todate == null || todate after[ 0d ] $max ) )
/

When the exception occurs, /MyFact.fromdate/ is not null, /$min/ is not
null, /MyFact.todate/ is null, /$max/ is not null.
In AfterEvaluator.evaluate : /extractor1/ refers to /MyFact.todate/,
/extractor2/ refers to /$max/, /handle1/ is null, /handle2/ refers to the
fact including the attribute to which /$max/ variable is bound to.

Of course, this worked fine in 5.5.0.Final.
I couldn't test this out in Drools 6.0.0.CR5 because I have dependencies to
drools-spring JAR that does not exist anymore in 6.0.0.CR5.

Is it simple to fix this problem?

Thanks in advance.

Best,
Alexis



--
View this message in context: 
http://drools.46999.n3.nabble.com/5-6-0-CR1-gives-a-NullPointerException-in-after-evaluator-tp4026780.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] How can I iterate through the ArrayList

2013-11-14 Thread Wolfgang Laun
rule fire for each AwaitingAction
when
   $aal: AwaitingActionList()
   $aa: AwaitingAction() from $aal.getAwaitingActionsList()
then
System.out.println( $aa.getStatus() );
end

Or you can itrerate over the list on the RHS:

rule fire for each AwaitingActionList
when
   $aal: AwaitingActionList()
then
for( Object obj: $aal.getAwaitingActionsList() ){
AwaitingAction aa = (AwaitingAction)obj;
System.out.println( aa.getStatus() );
}
end

-W


On 14/11/2013, Govind J. Parashar govind.paras...@mastek.com wrote:
 Hi


 Below have my java code and main method I want  to fire rule for all value
 of STATUS   how to write drl for this

 I am passing  awaitingActionList to rule

 public static void main(String args[]) throws Exception {
   
 KnowledgeBase kbase = readKnowledgeBase();
 StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

 AwaitingAction action = new AwaitingAction();
 AwaitingActionList awaitingActionList = new AwaitingActionList();
 ListAwaitingAction list = new ArrayListAwaitingAction();
 action.setStatus(CU);
 action.setValue(Create User);
 list.add(action);
 action = new AwaitingAction();
 action.setStatus(CLU);
 action.setValue(Complete Request);
 list.add(action);
 action = new AwaitingAction();
 action.setStatus(CP);
 action.setValue(Create Position);
 list.add(action);
 awaitingActionList.setAwaitingActionsList(list);
 for(AwaitingAction actionVO :
 awaitingActionList.getAwaitingActionsList())
   {
   System.out.println(VALUE:-- +actionVO.getValue()+
 STATUS:--
 +actionVO.getStatus()+   REDIRECT TO:-- +actionVO.getRedirect());
   }   

 ksession.insert(awaitingActionList);
 ksession.fireAllRules();
 ksession.dispose();

   }



 private static KnowledgeBase readKnowledgeBase() throws Exception {
 KnowledgeBuilder kbuilder =
 KnowledgeBuilderFactory.newKnowledgeBuilder();
 kbuilder.add(ResourceFactory.newClassPathResource(AwaitingAction.drl),
 ResourceType.DRL);
 KnowledgeBuilderErrors errors = kbuilder.getErrors();
 if (errors.size()  0) {
   for (KnowledgeBuilderError error : errors) {
 System.err.println(error);
   }
   throw new IllegalArgumentException(Could not parse knowledge.);
 }
 KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
 kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
 return kbase;
   }
 }




 public class AwaitingAction {

   private String status;
   private String value;
   private String redirect;
   public String getStatus() {
   return status;
   }
   public void setStatus(String status) {
   this.status = status;
   }
   public String getValue() {
   return value;
   }
   public void setValue(String value) {
   this.value = value;
   }
   public String getRedirect() {
   return redirect;
   }
   public void setRedirect(String redirect) {
   this.redirect = redirect;
   }



 public class AwaitingActionList {

   public ListAwaitingAction awaitingActionsList =  new
 ArrayListAwaitingAction();

   public ListAwaitingAction getAwaitingActionsList() {
   return awaitingActionsList;
   }

   public void setAwaitingActionsList(ListAwaitingAction
 awaitingActionsList) {
   this.awaitingActionsList = awaitingActionsList;
   }

   
 }




 -Original Message-
 From: rules-users-boun...@lists.jboss.org
 [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Wolfgang Laun
 Sent: 14 November 2013 05:08
 To: Rules Users List
 Subject: Re: [rules-users] How can I iterate through the ArrayList

 You may have to phrase your question more accurately in order to get an
 answer.

 Do you want the rule to fire if some, or if all, value fields of the
 AwaitingAction have some value? Once or for each AwaitingAction? Or do you
 want it to fire once if at least one, or if all, AwaitingActions of all
 AwaitingActionLists have a field value with some specific value?

 Also, would you consider inserting also the AwaitingAction objects as facts,
 not only the AwaitingActionList?

 -W



 On 13/11/2013, Govind J. Parashar govind.paras...@mastek.com wrote:
 HI,

 I have a AwaitingActionList Object which has a awaitingActionsList
 Object which has a ArrayList of AwaitingAction Objects. How can I
 iterate through the ArrayList to get to check each object
 AwaitingAction .value in the drl file.

 Java refrence file attached

 Thanks
 Govind
 MASTEK LTD.
 In the US, we're called MAJESCOMASTEK

 ~~
 
 Opinions expressed in this e-mail are those of the individual and not
 that of Mastek Limited, unless specifically indicated to that effect.
 Mastek Limited does not 

[rules-users] Drools 5.5 Property Reactive on Maps

2013-11-14 Thread gboro54
So I have an object with a map like follows:

protected ConcurrentMapString, Double accumulations = new
ConcurrentHashMapString, Double();

I wrote a convince method on the class that will look up the value in the
map and add to it if it exists and 
if not there will put it in the map:

@Modifies({ accumulations  })
public void addToAccumulation(String code, long volume) {
if (accumulations .containsKey(code)) {
Double value = accumulations .get(code) + volume;
accumulations .put(code, value);

} else {
accumulations .putIfAbsent(code, new Double(volume));
}
}

I have a rule to listen on the change of this filed on the object(i.e
accumulations[someCode]!=null) but 
when I modify the object the rule doesn't fire. I have added
@PropertyReactive to the Object and build the kbase as follows:

Properties props = new Properties();
props.setProperty(drools.dialect.java.compiler, JANINO);

KnowledgeBuilderConfiguration config = KnowledgeBuilderFactory
.newKnowledgeBuilderConfiguration(props);
config.setOption(PropertySpecificOption.ALWAYS);


Any insight into why this may not work?




--
View this message in context: 
http://drools.46999.n3.nabble.com/Drools-5-5-Property-Reactive-on-Maps-tp4026782.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] Drools 5.5 Property Reactive on Maps

2013-11-14 Thread gboro54
So if the property lives in the parent abstract class and that is where the
method existed. If I move the method to the child with the annotation
@Modifies it works. 

Any ideas why putting that in the parent abstract would not be honored?  



--
View this message in context: 
http://drools.46999.n3.nabble.com/Drools-5-5-Property-Reactive-on-Maps-tp4026782p4026783.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