Re: [rules-users] drools migration

2013-07-02 Thread abhinay_agarwal
Have you checked that the jars have been downloaded in your local repository
?



--
View this message in context: 
http://drools.46999.n3.nabble.com/rules-users-drools-migration-tp4024691p4024707.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 migration

2013-07-02 Thread radhika.inugala
Yes, the dependencies are in my local repo.
I changed the way we read the DRL files, I need to use KnowledgeBase
classes.
Once I am done with that, I updated the antlr version as well in the maven
dependencies.
Now I am stuck at other point. In some of the rules, we have 
 ArrayList() from collect() in the when part and 
we retract them in the when part of the rule.
I am getting ConsequenceException now which is
Caused by: java.util.ConcurrentModificationException.






--
View this message in context: 
http://drools.46999.n3.nabble.com/rules-users-drools-migration-tp4024691p4024714.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 migration

2013-07-02 Thread maunakea
I ran into a similar issue a while ago and had to rewrite the rule on how it
deals with collection object as facts. Maybe, if you post your rule, I can
try to suggest.



--
View this message in context: 
http://drools.46999.n3.nabble.com/rules-users-drools-migration-tp4024691p4024716.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 migration

2013-07-02 Thread radhika.inugala
Thanks for your reply.

Here is a rule:

rule US authorities
  lock-on-active true
when
  $trx : TransactionWrapper(ignoreSourceLocation == false) 
  $fromState : TAyWrapper ( authorityType == TAType.STATE || authorityType
== TAType.COUNTRY, locationType == LocationType.ORIGIN ) 
  $toState   : TAWrapper ( authorityType == TAType.STATE || authorityType ==
TAType.COUNTRY, locationType == LocationType.DESTINATION, code !=
$fromState.code ) 
  $removableAuthorities : ArrayList() from collect(TAWrapper( locationType
== LocationType.ORIGIN ))
then
  for(Object ta: $removableAuthorities){
retract (ta);
  }
end

Basically it is not retracting a fact. I do not know what is the problem.
I have changed the version from 5.2 to 5.5.0 Final(Now I am not getting any
exception, but I could see that the fact is still there)





--
View this message in context: 
http://drools.46999.n3.nabble.com/rules-users-drools-migration-tp4024691p4024718.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 migration

2013-07-02 Thread maunakea
This seems to be an equivalent rule removing the need for collect...

when
  $trx : TransactionWrapper(ignoreSourceLocation == false) 
  $fromState : TAWrapper ( authorityType == TAType.STATE || authorityType ==
TAType.COUNTRY, locationType == LocationType.ORIGIN ) 
  $toState   : TAWrapper ( authorityType == TAType.STATE || authorityType ==
TAType.COUNTRY, locationType == LocationType.DESTINATION, code !=
$fromState.code ) 
  $removableAuthority : TAWrapper( locationType == LocationType.ORIGIN )
then
  retract ($removableAuthority);
end 

You know your domain better :) but maybe this is what was meant?...
when
  $trx : TransactionWrapper(ignoreSourceLocation == false) 
  $fromState : TAWrapper ( authorityType == TAType.STATE || authorityType ==
TAType.COUNTRY, locationType == LocationType.ORIGIN ) 
  $toState   : TAWrapper ( authorityType == TAType.STATE || authorityType ==
TAType.COUNTRY, locationType == LocationType.DESTINATION, code !=
$fromState.code ) 
then
  retract (fromState);
end 

Good luck!!!



--
View this message in context: 
http://drools.46999.n3.nabble.com/rules-users-drools-migration-tp4024691p4024719.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 migration

2013-07-02 Thread radhika.inugala
Thanks,
I see what you are saying.
I am trying that out. But I am wondering why the drools versions are not
backward compatible.

But all these rules were written a long back.
And I was trying not to change the same. I need to build an application
which will have rules per client kind of thing.
So I would need to have a UI to create rules and also store them in
database.
I have seen some examples of using Guvnor and the db to store rules with the
newer versions of the drools.
When I upgraded the versions, my existing rules start breaking :(

 



--
View this message in context: 
http://drools.46999.n3.nabble.com/rules-users-drools-migration-tp4024691p4024720.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 migration

2013-07-02 Thread radhika.inugala
Also I am looking at the domain objects for this:
And I need to retract all the objects with locationType ==
LocationType.ORIGIN the fromState is one of them.
But there would be more of the same.
I think that is the reason the collect is in there.



--
View this message in context: 
http://drools.46999.n3.nabble.com/rules-users-drools-migration-tp4024691p4024721.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 migration

2013-07-02 Thread Thomas Grayson
I ran into the java.util.ConcurrentModificationException too when trying to 
iterate over an ArrayList created via from collect in Drools 5.5.0 Final.  My 
solution was to copy the list into an array using List.toArray and then iterate 
over that.  I found that the type information is often not properly maintained 
in the right-hand side of the rule, requiring casts where they should be 
unnecessary.  Here is a complete, self-contained example that shows how to 
iterate over the array to modify or retract the facts.


import java.util.ArrayList;

declare Fact
@propertyReactive
name : String @key
value : String
end

rule initialize
when
then
insert (new Fact(abc));
insert (new Fact(def));
insert (new Fact(ghi));
end

rule collect and retract
salience 1
when
$list : ArrayList(size  0) from collect (Fact(name in (abc, def)))
then
// This will not compile without the explicit cast.
Fact[] facts = (Fact[]) $list.toArray(new Fact[0]);

for (Fact f : facts) {
retract (f);
}
end

rule collect and modify
salience 2
when
$list : ArrayList(size  0) from collect (Fact(name in (abc, def)))
then
Fact[] facts = (Fact[]) $list.toArray(new Fact[0]);

for (Fact f : facts) {
// The modify will not compile without an explicit cast,
// despite the declaration of f in the enhanced for loop.
Fact g = (Fact) f;

modify (g) {
setValue(g.getName() +  A);
}
}

// Avoid the cast by using a traditional indexed loop.
for (int i = 0; i  facts.length; i++) {
  // Copy the array element into a new variable
  // because modify (facts[i]) will not compile.
Fact g = facts[i];

modify (g) {
setValue(g.getName() +  B);
}
}
end



Best wishes,

Tom



-Original Message-
From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of radhika.inugala
Sent: Tuesday, July 02, 2013 3:20 PM
To: rules-users@lists.jboss.org
Subject: Re: [rules-users] drools migration



Also I am looking at the domain objects for this:

And I need to retract all the objects with locationType == LocationType.ORIGIN 
the fromState is one of them.

But there would be more of the same.

I think that is the reason the collect is in there.







--

View this message in context: 
http://drools.46999.n3.nabble.com/rules-users-drools-migration-tp4024691p4024721.html

Sent from the Drools: User forum mailing list archive at Nabble.com.

___

rules-users mailing list

rules-users@lists.jboss.orgmailto: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] drools migration

2013-07-01 Thread Radhika Inugala
Hi All,
In my current project we are using drools and the maven dependencies show as
 dependency
groupIdorg.drools/groupId
artifactIdcom.springsource.org.drools.compiler/artifactId
version4.0.7/version
/dependency

 dependency
groupIdorg.drools/groupId
artifactIdcom.springsource.org.drools/artifactId
version4.0.7/version
/dependency

I would like to migrate this to 5.2.0 version. As I want to have Guvnor and
a UI integration for a new rules setup.
When I see for the springsource dependencies, I do not find the same.
When I changed these to

dependency
groupIdorg.drools/groupId
artifactIddrools-core/artifactId
version5.2.0.CR1/version
   /dependency
   dependency
groupIdorg.drools/groupId
artifactIddrools-compiler/artifactId
version5.2.0.CR1/version
/dependency
/dependencies

I am getting compilation failures.
Any inputs on how to migrate the drools is appreciated.

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