Wolfgang Laun | 1 Jul 2011 07:21
Picon

Re: Date arithmetic in when part

2011/6/30 <rouvas <at> mm.di.uoa.gr>

What are the available symbolics for temporal values?
That is, d is for days, m is for minutes, h is for hours, s is for seconds.
Are there any other symbolics specifically for months and years?

You can use ms for millisecond. There are no universally acceptable duration values for monts and years .
-W
 

I haven't found any mentioning of them in the Fusion manual.
I'm using 5.0.1

Thank you,
-Stathis

Wolfgang Laun wrote:
> See the "Fusion" manual, section on Temporal Reasoning/Temporal Operators.
> Even when the facts aren't events, these operators can still be applied to
> fields of type Date, e.g.
>
>     $p1: Person( $dob1: dob )
>     $p2: Person( $dob2: dob after[3d] $dob1 )
>
> -W
>
>
> On 28 June 2011 18:02, <rouvas <at> mm.di.uoa.gr> wrote:
>
>> Hi list,
>>
>> I feel this should be an elementary question but unfortunately I haven't
>> been able to find a solution.
>>
>> I would like to perform date arithmetic in the when part of a rule.
>>
>> For example, I would like to express something like:
>>
>> rule "Date compare rule"
>>  dialect "mvel"
>> when
>>  a : A()
>>  b : B( a.creationDate <= b.creationDate after 3 months)
>> then
>>  ...
>> end
>>
>> Apart from using eval()'s is there any other way to express these types
>> of
>> comparisons?
>>
>> Thank you for your time,
>> -Stathis
>>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users <at> lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>



_______________________________________________
rules-users mailing list
rules-users <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
Mark Proctor | 1 Jul 2011 08:04

Re: Date arithmetic in when part

The times attempt to be ISO8601 compliant, for Hours and earlier. Although I noticed that tidbit of information is missing for the docs, we'll get it added. See TimeUtils

private static final Pattern SIMPLE  = Pattern.compile( "([+-])?((\\d+)[Dd])?\\s*((\\d+)[Hh])?\\s*((\\d+)[Mm])?\\s*((\\d+)[Ss])?\\s*((\\d+)([Mm][Ss])?)?" );

    public static long parseTimeString( String time ) {
        String trimmed = time.trim();
        long result = 0;
        if( trimmed.length() > 0 ) {
            Matcher mat = SIMPLE.matcher( trimmed );
            if ( mat.matches() ) {
                int days = (mat.group( SIM_DAY ) != null) ? Integer.parseInt( mat.group( SIM_DAY ) ) : 0;
                int hours = (mat.group( SIM_HOU ) != null) ? Integer.parseInt( mat.group( SIM_HOU ) ) : 0;
                int min = (mat.group( SIM_MIN ) != null) ? Integer.parseInt( mat.group( SIM_MIN ) ) : 0;
                int sec = (mat.group( SIM_SEC ) != null) ? Integer.parseInt( mat.group( SIM_SEC ) ) : 0;
                int ms = (mat.group( SIM_MS ) != null) ? Integer.parseInt( mat.group( SIM_MS ) ) : 0;
                long r = days * DAY_MS + hours * HOU_MS + min * MIN_MS + sec * SEC_MS + ms;
                if( mat.group(SIM_SGN) != null && mat.group( SIM_SGN ).equals( "-" ) ) {
                    r = -r;
                }
                result = r;
            } else if( "*".equals( trimmed ) || "+*".equals( trimmed ) ) {
                // positive infinity
                result = Long.MAX_VALUE;
            } else if( "-*".equals( trimmed ) ) {
                // negative infinity
                result = Long.MIN_VALUE;
            } else {
                throw new RuntimeDroolsException( "Error parsing time string: [ " + time + " ]" );
            }
        }
        return result;
    }


On 01/07/2011 06:21, Wolfgang Laun wrote:
2011/6/30 <rouvas <at> mm.di.uoa.gr>
What are the available symbolics for temporal values?
That is, d is for days, m is for minutes, h is for hours, s is for seconds.
Are there any other symbolics specifically for months and years?

You can use ms for millisecond. There are no universally acceptable duration values for monts and years .
-W
 

I haven't found any mentioning of them in the Fusion manual.
I'm using 5.0.1

Thank you,
-Stathis

Wolfgang Laun wrote:
> See the "Fusion" manual, section on Temporal Reasoning/Temporal Operators.
> Even when the facts aren't events, these operators can still be applied to
> fields of type Date, e.g.
>
>     $p1: Person( $dob1: dob )
>     $p2: Person( $dob2: dob after[3d] $dob1 )
>
> -W
>
>
> On 28 June 2011 18:02, <rouvas <at> mm.di.uoa.gr> wrote:
>
>> Hi list,
>>
>> I feel this should be an elementary question but unfortunately I haven't
>> been able to find a solution.
>>
>> I would like to perform date arithmetic in the when part of a rule.
>>
>> For example, I would like to express something like:
>>
>> rule "Date compare rule"
>>  dialect "mvel"
>> when
>>  a : A()
>>  b : B( a.creationDate <= b.creationDate after 3 months)
>> then
>>  ...
>> end
>>
>> Apart from using eval()'s is there any other way to express these types
>> of
>> comparisons?
>>
>> Thank you for your time,
>> -Stathis
>>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users <at> lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>



_______________________________________________ rules-users mailing list rules-users <at> lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users

_______________________________________________
rules-users mailing list
rules-users <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
rouvas | 1 Jul 2011 08:25
Picon

Re: Date arithmetic in when part

Wolfgang Laun wrote:
> 2011/6/30 <rouvas <at> mm.di.uoa.gr>
>
>> What are the available symbolics for temporal values?
>> That is, d is for days, m is for minutes, h is for hours, s is for
>> seconds.
>> Are there any other symbolics specifically for months and years?
>>

Thanks for the clarification.

>
> You can use ms for millisecond. There are no universally acceptable
> duration
> values for monts and years .

Neither are the chosen values "universally" acceptable.
How about following "man date" conventions?

-Stathis

> -W
>
>
>>
>> I haven't found any mentioning of them in the Fusion manual.
>> I'm using 5.0.1
>>
>> Thank you,
>> -Stathis
>>
>> Wolfgang Laun wrote:
>> > See the "Fusion" manual, section on Temporal Reasoning/Temporal
>> Operators.
>> > Even when the facts aren't events, these operators can still be
>> applied
>> to
>> > fields of type Date, e.g.
>> >
>> >     $p1: Person( $dob1: dob )
>> >     $p2: Person( $dob2: dob after[3d] $dob1 )
>> >
>> > -W
>> >
>> >
>> > On 28 June 2011 18:02, <rouvas <at> mm.di.uoa.gr> wrote:
>> >
>> >> Hi list,
>> >>
>> >> I feel this should be an elementary question but unfortunately I
>> haven't
>> >> been able to find a solution.
>> >>
>> >> I would like to perform date arithmetic in the when part of a rule.
>> >>
>> >> For example, I would like to express something like:
>> >>
>> >> rule "Date compare rule"
>> >>  dialect "mvel"
>> >> when
>> >>  a : A()
>> >>  b : B( a.creationDate <= b.creationDate after 3 months)
>> >> then
>> >>  ...
>> >> end
>> >>
>> >> Apart from using eval()'s is there any other way to express these
>> types
>> >> of
>> >> comparisons?
>> >>
>> >> Thank you for your time,
>> >> -Stathis
>> >>
>> >>
>> >> _______________________________________________
>> >> rules-users mailing list
>> >> rules-users <at> lists.jboss.org
>> >> https://lists.jboss.org/mailman/listinfo/rules-users
>> >>
>> >
>>
>>
>>
>

_______________________________________________
rules-users mailing list
rules-users <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

prashant.badhe | 1 Jul 2011 13:15
Picon

Removing rule (DRL) from resource throwing NullPointerException...


Hi,

I am using Drools Kbase stateful sessions and using "changeset.xml" file to
dynamically load resources (DRL files) from a folder. 
The KnowledgeAgent configuration property 'drools.agent.newInstance' is set
to false.
And the 'drools.resource.scanner.interval' property is set to 1.

As I am using Spring, these properties are passed-in to the agent from
spring-beans.xml.

Now, when I start tomcat, everything works fine (some rules also get fired),
But when I remove a DRL rule from my resource folder following exception is
thrown:

Exception in thread "Thread-8" java.lang.NullPointerException
        at
org.drools.reteoo.RuleTerminalNode$RTNCleanupAdapter.cleanUp(RuleTerminalNode.java:507)
        at org.drools.reteoo.BetaNode.doRemove(BetaNode.java:253)
        at org.drools.common.BaseNode.remove(BaseNode.java:109)
        at
org.drools.reteoo.RuleTerminalNode.doRemove(RuleTerminalNode.java:411)
        at org.drools.common.BaseNode.remove(BaseNode.java:109)
        at
org.drools.reteoo.ReteooBuilder.removeRule(ReteooBuilder.java:237)
        at
org.drools.reteoo.ReteooRuleBase.removeRule(ReteooRuleBase.java:432)
        at
org.drools.common.AbstractRuleBase.removeRule(AbstractRuleBase.java:831)
        at
org.drools.common.AbstractRuleBase.removeRule(AbstractRuleBase.java:809)
        at
org.drools.impl.KnowledgeBaseImpl.removeRule(KnowledgeBaseImpl.java:206)
        at
org.drools.agent.impl.KnowledgeAgentImpl.removeKnowledgeDefinitionFromBase(KnowledgeAgentImpl.java:842)
        at
org.drools.agent.impl.KnowledgeAgentImpl.incrementalBuildResources(KnowledgeAgentImpl.java:763)
        at
org.drools.agent.impl.KnowledgeAgentImpl.buildKnowledgeBase(KnowledgeAgentImpl.java:586)
        at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:185)
        at
org.drools.agent.impl.KnowledgeAgentImpl$ChangeSetNotificationDetector.run(KnowledgeAgentImpl.java:1106)
        at java.lang.Thread.run(Thread.java:662)

Is there anything more that needs to be set for 'changeset' to work for
add/update/remove of resources?

FYI - I am using Drools 5.1.1

Thanks,
Prashant

--
View this message in context: http://drools.46999.n3.nabble.com/Removing-rule-DRL-from-resource-throwing-NullPointerException-tp3128955p3128955.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

jpullmann | 1 Jul 2011 13:58
Picon
Favicon

System actions available within RHS

  Hello, 
    does Drools 5.2. provides API calls for: 
     a) advancing the pseudo clock time
     b) inserting a new (aggregate) event into an entry point 
   from within the RHS of a rule ? 

  Thank you!
    Jaro

--
View this message in context: http://drools.46999.n3.nabble.com/System-actions-available-within-RHS-tp3129049p3129049.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Wolfgang Laun | 1 Jul 2011 14:31
Picon

Re: System actions available within RHS

All of Java can be used on the RHS of a rule.

Inserting a fact (or event) is done simply by: insert( X )

-W

On 1 July 2011 13:58, jpullmann <jaroslav.pullmann <at> fit.fraunhofer.de> wrote:
 Hello,
   does Drools 5.2. provides API calls for:
    a) advancing the pseudo clock time
    b) inserting a new (aggregate) event into an entry point
  from within the RHS of a rule ?

 Thank you!
   Jaro



--
View this message in context: http://drools.46999.n3.nabble.com/System-actions-available-within-RHS-tp3129049p3129049.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

_______________________________________________
rules-users mailing list
rules-users <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
tarley.lana | 1 Jul 2011 15:28
Picon

Is there any way to compress (gzip) the rules package to optimize network traffic between server and agent?

We have a drools application composed of almost 1000 rules. The rules
deployment package has almost 8MB and we need to distribute it over a 100
Kbps network for offline use on some client machines.
If we could zip this package, it would require only 237Kbytes (instead 8MB).
It seems, however, the class org.drools.agent.impl.KnowledgeAgentImpl
doesn't support  gzip compression.
Is it right? Is there any workaround for this problem?

Thanks in advance.

--
View this message in context: http://drools.46999.n3.nabble.com/Is-there-any-way-to-compress-gzip-the-rules-package-to-optimize-network-traffic-between-server-and-a-tp3129297p3129297.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Michael Anstis | 1 Jul 2011 15:37
Picon
Gravatar

Re: Is there any way to compress (gzip) the rules package to optimize network traffic between server and agent?

Whilst I don't believe there is anything "out of the box" could you just not write a JEE5 javax.servlet.Filter to perform the compression for you?

On 1 July 2011 14:28, tarley.lana <tarley.lana <at> gmail.com> wrote:
We have a drools application composed of almost 1000 rules. The rules
deployment package has almost 8MB and we need to distribute it over a 100
Kbps network for offline use on some client machines.
If we could zip this package, it would require only 237Kbytes (instead 8MB).
It seems, however, the class org.drools.agent.impl.KnowledgeAgentImpl
doesn't support  gzip compression.
Is it right? Is there any workaround for this problem?

Thanks in advance.

--
View this message in context: http://drools.46999.n3.nabble.com/Is-there-any-way-to-compress-gzip-the-rules-package-to-optimize-network-traffic-between-server-and-a-tp3129297p3129297.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

_______________________________________________
rules-users mailing list
rules-users <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
sv | 1 Jul 2011 16:12

Re: Drools with Spring - Need Help

Can you be bit elobrate? What version of drools you are using.

--
View this message in context: http://drools.46999.n3.nabble.com/Drools-with-Spring-Need-Help-tp3115948p3129427.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

tarley.lana | 1 Jul 2011 16:42
Picon

Re: Is there any way to compress (gzip) the rules package to optimize network traffic between server and agent?

Ok, but I have to modify the class org.drools.agent.impl.KnowledgeAgentImpl
for it to do unzip the package on the client. There is no standard mechanism
for this?

--
View this message in context: http://drools.46999.n3.nabble.com/Is-there-any-way-to-compress-gzip-the-rules-package-to-optimize-network-traffic-between-server-and-a-tp3129297p3129523.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Gmane