Cross Reference Utility
by ronalbury
Is there a cross reference utility, that will allow me to easily find the
rules which reference a specific class and/or specific attribute? I'm
hoping for something like the standard Java 'references' report.
I'm guessing (based on what I've read) that the Drools compiler generates a
bunch of Java classes behind the scenes ... is there any way to get it to
leave those Java artifacts so that I could get a 'references' report from
them?
Thanks
Ron
--
View this message in context: http://drools.46999.n3.nabble.com/Cross-Reference-Utility-tp3583733p35837...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 3 months
Many to many matching using Drools rules
by Zhuo Li
Folks,
I am recently working on a BI project which is doing reconciliation between
repository and accounting. I'm using Drools 5.1.1 to maintain all these
matching rules. One scenario I have no clue to implement in Drools is that I
need to find x transactions from repository, to match y transactions from
accounting, while existing repository transactions and accounting
transactions are bigger than x and y. Does anybody have experience to do
similar thing in Drools?
Best Abe
14 years, 3 months
Store a Map in Country Enumeration
by srinivasasanda
Hi,
I have a declarative model with a fact named Person with
field*(country,state)*
I have seen in guvnor documentation that
'Board.type':['short','long','NN=MIn Mal']
Min Mal will be displayed in GUI where as NN will be used backend
In the sameway,I need to use country ids instead of countrynames in backend
where countryname should displayed at GUI.How I can do this?please suggest
me..
'Person.country':(new com.sample.DropDownList()).loadCountriesList()-----
Countries are succesfully loaded---US,UK,JAPAN....etc....in dropdown list
Now I should use different IDs for these different countries in backend.
In the above enumeration I should use different Ids for different countries
in backend(rule)..How can I do this
Please suggest me.Please How can I achieve
--
View this message in context: http://drools.46999.n3.nabble.com/Store-a-Map-in-Country-Enumeration-tp35...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 3 months
Sliding window behavior in stream mode and realtime clock
by MarcoMojana
Hi,
The situation is the following: we need to process a stream of delayed
events. This means that the event timestamp is provided for each one
of them and that it doesn't generally correspond to the system time when
we insert them in the entry-point. The events delay may vary, but they
are always inserted in chronological order. My questions refer to the
enclosed implementation and are:
1) Given my source code, would the timestamps correctly read and used?
2) I would like that the "time window" behaves as if it is initially
placed at t = -inf and, when a new event is inserted in the
entry-point, it would slide to the time of the last event timestamp.
In my code I have used the stream mode and a realtime clock: is it
correct?
3) When I run the given application, I expect it to print only:
Found TriggerEvent [timestamp=Tue Dec 06 13:00:00 CET 2011]
because it is the only event of type TriggerEvent for which there
exists a window of size 1h that contains no InhibitEvent. Instead,
sometimes it prints nothing and sometimes:
Found TriggerEvent [timestamp=Tue Dec 06 14:10:00 CET 2011]
Found TriggerEvent [timestamp=Tue Dec 06 13:00:00 CET 2011]
How is this possible? How can I achieve my goal?
(I'm currently using Drools 5.3.0 final.)
Cheers
Marco Mojana
------------------------------------------------------------------------
package com.sample;
import java.sql.Date;
import java.util.Calendar;
import java.util.GregorianCalendar;
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseConfiguration;
import org.drools.KnowledgeBaseFactory;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderError;
import org.drools.builder.KnowledgeBuilderErrors;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.ResourceType;
import org.drools.conf.EventProcessingOption;
import org.drools.io.ResourceFactory;
import org.drools.logger.KnowledgeRuntimeLogger;
import org.drools.logger.KnowledgeRuntimeLoggerFactory;
import org.drools.runtime.KnowledgeSessionConfiguration;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.conf.ClockTypeOption;
import org.drools.runtime.rule.WorkingMemoryEntryPoint;
public class DroolsTest {
public static final void main(String[] args) {
try {
// load up the knowledge base
KnowledgeBase kbase = readKnowledgeBase();
final KnowledgeSessionConfiguration sessionConfig =
KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
sessionConfig.setOption(ClockTypeOption.get("realtime"));
StatefulKnowledgeSession ksession =
kbase.newStatefulKnowledgeSession(sessionConfig, null);
WorkingMemoryEntryPoint eventStream =
ksession.getWorkingMemoryEntryPoint("EventStream");
KnowledgeRuntimeLogger logger =
KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test");
// Insert events
eventStream.insert(new InhibitEvent(new GregorianCalendar(2011,
Calendar.DECEMBER, 6, 12, 0, 0).getTime()));
eventStream.insert(new TriggerEvent(new GregorianCalendar(2011,
Calendar.DECEMBER, 6, 13, 0, 0).getTime()));
eventStream.insert(new InhibitEvent(new GregorianCalendar(2011,
Calendar.DECEMBER, 6, 14, 0, 0).getTime()));
eventStream.insert(new TriggerEvent(new GregorianCalendar(2011,
Calendar.DECEMBER, 6, 14, 10, 0).getTime()));
eventStream.insert(new InhibitEvent(new GregorianCalendar(2011,
Calendar.DECEMBER, 6, 14, 20, 0).getTime()));
ksession.fireAllRules();
ksession.dispose();
logger.close();
} catch (Throwable t) {
t.printStackTrace();
}
}
private static KnowledgeBase readKnowledgeBase() throws Exception {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("Rules.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.");
}
final KnowledgeBaseConfiguration kbConfig =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
kbConfig.setOption(EventProcessingOption.STREAM);
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(kbConfig);
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
return kbase;
}
}
------------------------------------------------------------------------
package com.sample;
import java.util.Date;
public class TriggerEvent {
private final Date timestamp;
public TriggerEvent(final Date timestamp) {
this.timestamp = timestamp;
}
public Date getTimestamp() {
return timestamp;
}
@Override
public String toString() {
return "TriggerEvent [timestamp=" + timestamp + "]";
}
}
------------------------------------------------------------------------
package com.sample;
import java.util.Date;
public class InhibitEvent {
private final Date timestamp;
public InhibitEvent(final Date timestamp) {
this.timestamp = timestamp;
}
public Date getTimestamp() {
return timestamp;
}
@Override
public String toString() {
return "InhibitEvent [timestamp=" + timestamp + "]";
}
}
------------------------------------------------------------------------
package com.sample
declare InhibitEvent
@role(event)
@timestamp(timestamp)
end
declare TriggerEvent
@role(event)
@timestamp(timestamp)
end
rule "EventNotInhibited"
dialect "mvel"
when
not( InhibitEvent() over window:time(1h) from entry-point EventStream )
$e0 : TriggerEvent() over window:time(1h) from entry-point EventStream
then
System.err.println("Found " + $e0);
end
------------------------------------------------------------------------
--
View this message in context: http://drools.46999.n3.nabble.com/Sliding-window-behavior-in-stream-mode-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 3 months
[MVEL] the data converter does not work
by kapokfly
Can someone tell why the data converter does not work at all and what is the
reason we make the data converter to value assignment statement only?
public void testDataConverter() throws Exception {
OptimizerFactory.setDefaultOptimizer(OptimizerFactory.SAFE_REFLECTIVE);
DataConversion.addConversionHandler(Date.class, new MyDateConverter());
Locale.setDefault(Locale.US);
Cheese cheese = new Cheese();
cheese.setUseBy(new
SimpleDateFormat("dd-MMM-yyyy").parse("10-Jul-1974"));
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("cheese", cheese);
Serializable compiledExpression = MVEL.compileExpression("cheese.useBy
== '10-Jul-1974'");
boolean result = MVEL.executeExpression(compiledExpression, variables,
Boolean.class);
assertTrue(result);
}
Here is what I can see from the code, at the end this method will be called,
would it be nice to allow the data converter here?
private static Boolean safeEquals(final Object val1, final Object val2)
{
if (val1 != null) {
return val1.equals(val2) ? Boolean.TRUE : Boolean.FALSE;
}
else return val2 == null || (val2.equals(val1) ? Boolean.TRUE :
Boolean.FALSE);
}
-----
Ivan, your Panda, forever
--
View this message in context: http://drools.46999.n3.nabble.com/MVEL-the-data-converter-does-not-work-t...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 3 months
Temporal operators for point-in-time events
by Mike Melton
Apologies for the stupid question, but I haven't seen anything in the
documentation regarding this and I want to verify my solution. Say I
have a point-in-time event (i.e., duration of 0) that I want to
correlate to another point-in-time event. I want a rule that will
activate if the timestamp of one is greater than or equal to the
other, basically "after or coincides". I wrote a test using the
following rule and it seemed to work:
rule "Greater Than or Equal"
when
$e1 : TestEvent( $id : id )
$e2 : TestEvent( id != id, this after[0ms] $e1 )
then
System.out.println($e2 + " is greater than or equal to " + $e1);
end
I realize this rule will fire twice if the event timestamps are equal,
but it's just for demonstration purposes; my question is specifically
about the "after[0ms]" part. Is this the way to go to accomplish what
I need? It seems so simple but I have this annoying feeling that I'm
missing something.
On a slightly related topic, is there an updated version of the
temporal operators image from the Drools Fusion homepage? It is a
great visual description of the operators and I want to print it out
and post it at my desk, but it doesn't include all of the operators.
Image: http://www.jboss.org/drools/drools-fusion/mainColumnParagraphs/02/imageBi...
>From page: http://www.jboss.org/drools/drools-fusion.html
Thanks
Mike
14 years, 3 months