All the values from one list must be present in other
by Suvek
I tried looking for similar posts but could not find any that fits the
requirements.
Really speaking this is a 2 part question.
What I need to do is compare 2 lists and ensure that all the fields inside
the reference list are present in passed in list.
following is the simplified version of test that I want to perform...
$requiredAddressTypes : List() from [ AddressType.BUSINESS,
AddressType.FOREIGN_BUSINESS ]
$taxpayer : Taxpayer(taxpayerType == TaxpayerType.FOREIGN_BUISINESS &&
addresses.size > 0,
$addresses : addresses)
1 - Based on the taxpayer type I need to ensure that ALL the
requiredAddressTypes must be present, how can I achieve this?
2 - is the this statement correct ? ($requiredAddressTypes : List() from [
AddressType.BUSINESS, AddressType.FOREIGN_BUSINESS ])
--
View this message in context: http://drools.46999.n3.nabble.com/All-the-values-from-one-list-must-be-pr...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 6 months
Persistence in fireUntilHalt() loop
by Alberto R. Galdo
Hi,
We're running an application that uses Drools + JBPM 5 + Drools
integration our set-up can be seen as:
Some rule fires and creates a JBPM process ( a fact gets inserted into
drools using "kcontext.getKnowledgeRuntime().startProcess("testProcess")"
). We have a problem with the persistence of this processes. Persistence is
implemented with JPA and JTA. Our application runs with fireUntilHalt() and
when a process is launched from the consequence of any of the rules the
persistence of the process fails. If the application runs with
fireAllRules(), the persistence works like a charm.
The error shown is as follow:
Exception in thread "Thread-5" Exception executing consequence for rule
"Run Process" in com.sample: java.lang.NullPointerException
at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1101)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1029)
at org.drools.common.DefaultAgenda.fireUntilHalt(DefaultAgenda.java:1229)
at
org.drools.common.AbstractWorkingMemory.fireUntilHalt(AbstractWorkingMemory.java:754)
at
org.drools.common.AbstractWorkingMemory.fireUntilHalt(AbstractWorkingMemory.java:730)
at
org.drools.command.runtime.rule.FireUntilHaltCommand$1.run(FireUntilHaltCommand.java:50)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NullPointerException
at
org.jbpm.persistence.processinstance.JPAProcessInstanceManager.addProcessInstance(JPAProcessInstanceManager.java:44)
at
org.jbpm.process.instance.AbstractProcessInstanceFactory.createProcessInstance(AbstractProcessInstanceFactory.java:36)
at
org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:182)
at
org.jbpm.process.instance.ProcessRuntimeImpl.createProcessInstance(ProcessRuntimeImpl.java:154)
at
org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:135)
at
org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:130)
at
org.drools.common.AbstractWorkingMemory.startProcess(AbstractWorkingMemory.java:1074)
at
org.drools.impl.StatefulKnowledgeSessionImpl.startProcess(StatefulKnowledgeSessionImpl.java:301)
at com.sample.Rule_Run_Process.defaultConsequence(Rule_Run_Process.java:9)
at com.sample.Rule_Run_ProcessDefaultConsequenceInvoker.evaluate(Unknown
Source)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1091)
... 6 more
The problem is in this function:
public void addProcessInstance(ProcessInstance processInstance) {
ProcessInstanceInfo processInstanceInfo = new ProcessInstanceInfo(
processInstance, this.kruntime.getEnvironment() );
ProcessPersistenceContext context
= ((ProcessPersistenceContextManager)
this.kruntime.getEnvironment()
.get( EnvironmentName.PERSISTENCE_CONTEXT_MANAGER ))
.getProcessPersistenceContext();
// @PrePersist added to ProcessInstanceInfo because of this
context.persist( processInstanceInfo );
((org.jbpm.process.instance.ProcessInstance)
processInstance).setId( processInstanceInfo.getId() );
processInstanceInfo.updateLastReadDate();
internalAddProcessInstance(processInstance);
}
We think after that persist sentence, the entity manager would have to run
a flush sentence for the process instance is inserted into database and get
the ID.
Greets.
13 years, 7 months
System problems
by paco
I am using Drools 5.4.0, guvnor 5.3.0 and default database.
I imported the rules with XML file (550 KB) in Guvnor. After I can check,
validate and test (with run analysis button) the rules without problems.
Everything works fine.
After when I import ed other rules XML file (30,000 KB), I realized that the
system becomes too slow and obviously I can no longer veifier, validate or
test my rules.
Please suggest
--
View this message in context: http://drools.46999.n3.nabble.com/System-problems-tp4018363.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 7 months
Continuous Planning values for task planning
by Josef Bajada
Hi,
I am new to Drools and Drools Planner, so apologies if I am asking anything
obvious.
My objective is to implement a simple (for now) planner which schedules
tasks according to 2 main criteria:
- Their duration (in seconds)
- Their dependencies on other tasks (e.g. Hard Constraint that Task B has
to start between 180 and 200 seconds after Task A finishes).
Since there are gaps between dependent tasks as part of the hard
constraints other tasks can be fitted in between dependent tasks.
So the Solver needs to find the optimal start time for each task that
satisfies the hard constraints, and in the shortest total timeline possible
to complete all tasks (soft constraint).
The main problem I am finding is that this start time, which is essentially
the planning variable is a continuous variable.
Chapter 4 of the Drools documentation mentions very briefly (Section
4.3.4.1) that planning variables can be continuous, but there does not
seem to be any more details about how to achieve this.
Even if the planning variable was discrete (say bins of 5 second
intervals), there is no upper bound as such.
How is it best to handle such planning variables in Drools Planner?
thanks,
josef
13 years, 7 months
Use of Otherwise in converted decision table in Guvnor.
by Manasi
Hi,
1) I am using new feature of Guvnor 5.4 i.e converting from decision table
in excel format to Guvnor web Decision Table format.
After excel decision table is converted to Guvnor web Decision table format
,I am not able to use *'Otherwise'* feature for rows in guvnor decision
table.
If Guvnor decision table is created manually then only I am able to use
*Otherwise* in rows.
2) Also ,if Guvnor web decision table is created manually then *Otherwise*
in rows can be use only for String literals . Can it be use for Boolean
variables?
Please let me know what steps needs to be taken.
Thanks,
Manasi Damle
--
View this message in context: http://drools.46999.n3.nabble.com/Use-of-Otherwise-in-converted-decision-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 7 months
Add calendars to knowledge session from Spring?
by dunnlow
I am using the Drools 5.4 integration server in a stateless session. I have
it running fine with the example. Now, I want to use custom Quartz
calendars in my rules. The only way I could come up with to do this in
Spring (a la integration server) was to create a bean that takes a ksession
constructer then creates the calendars and adds them to that ksession.
I see that the bean is created with a knowledge session and all seems ok,
but none of my calendar-based rules ever fire regardless of how the
calendars are configured. (I test the calendars in my bean (with a call to
isTimeIncluded()) and they seem to be in working order.
Also weird is that bean's constructor gets called twice and with two
different knowledge sessions. Once when I start the application, and then
again when I send to the rules service.
1) What is the right was to add custom calendars to a knowledge session (via
Spring)?
2) Any idea why my bean is getting called twice with different knowledge
sessions?
Thanks for any insight. -J
---in knowledge-service.xml
<drools:ksession id="ksession1" type="stateful" kbase="kbase1"
note="node1"/>
<bean id="myCalendar" class="org.test.MyQuartzCalendarLoader">
<constructor-arg ref="ksession1"/>
</bean>
--- MyQuartzCalendarLoader.java
public class MyQuartzCalendarLoader {
private static StatefulKnowledgeSession thisSession=null;
public MyQuartzCalendarLoader (StatefulKnowledgeSession thisKs) {
//gets called twice?
thisSession=thisKs;
print thisSession.tostring() -- looks ok
WeeklyCalendar calendar = new WeeklyCalendar();
org.drools.time.Calendar onlyWeekDays =
QuartzHelper.quartzCalendarAdapter(calendar);
calendar.setDayExcluded(Calendar.WEDNESDAY,false) -- I toggle
just to test
print onlyWeekDays.isTimeIncluded(now.getTime()); --- also
works as expected
Calendars cals =
thisSession.getCalendars().set("ONLYWEEKDAYS",onlyWeekDays);
}
}
--- test.drl
rule "weekdays" dialect "mvel" <-- This rule never fires unless i
remove calendars.
calendars "ONLYWEEKDAYS"
when
$m:Message()
then
$m.text = "FIRED"
end
--
View this message in context: http://drools.46999.n3.nabble.com/Add-calendars-to-knowledge-session-from...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 7 months
Best model for planning?
by mvermand
Hi,
I'd like some advice on how to make my model.
I need to plan maintenance-schedules for - let's say - airplanes.
Constraints are:
- planes are only at given moments available for maintenance (when not in
the air ;-)
- maintenance of a planes requires a number of techniciens (with specific
skills).
- techniciens have skills and also shifts and vacation.
Now, first I tought to make the maintenance of a plane the planningEntity.
But I did not know how to populate and match the techniciens.
So, second I tought to make a new Task-class the planningEntity.
A Task is a job that needs to be done by a technicien with specific skills.
Maintaining a plane requires then a number of tasks.
If I choose this model, I think I'll have to pass two Plannings variables to
the Task planningEntity:
1) a Maintenance-fact (Plane + Period + list of required tasks) and
2) a Technicien-fact (?)
Then I'll need to check if availabity of plane and availability of
technicien match and also skill-requirement of task and skills of
technicien.
Do you think this second model is the right one?
Will it perform well?
=> ? matching all combinations of plane availabilty and
techniciens-availability and -skills.
Thanks in advance
--
View this message in context: http://drools.46999.n3.nabble.com/Best-model-for-planning-tp4019464.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 7 months
Insert global into working memory via Spring?
by dunnlow
I am using the drools 5.4 Integration Server (with Guvnor).
I have two instances of the Integration Server and (ideally) one instance of
the rules in Guvnor. I would like to create some rules that depend on the
instance of the Integration Server on which they are running. The vision is
that I would set a global variable somewhere that provided the server name
then use that variable in my rules.
I thought about adding a global variable via guvnor package configuration,
but I can only declare it (not set it). Also, if I could do that, I would
need another knowledge base, which I am trying to avoid.
I am considering setting up a declared object (so that the rule just fires
once) and a rule that if the object doesnt exist, creates it and calls a
function that checks a System Property and sets the value (I know, I've read
not to set globals in rules). If this rule has a high salience, this seems
like it could work - but is REALLY ugly.
Is there a better way?
Basically, I think I want to inject that value into the knowledge session
via Spring.
Thanks for any thoughts,
-J
--
View this message in context: http://drools.46999.n3.nabble.com/Insert-global-into-working-memory-via-S...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 7 months