[rules-users] Creating fact instance programatically

nestabur nestabur at gmail.com
Wed Mar 11 05:02:46 EDT 2009



Hi all again,

Finally I fixed the error, I was trying to get the factType with the model
name instead of the fact type name :( 
btw, this implementation threw me the error:

Exception while processing message:
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
java.lang.StringIndexOutOfBoundsException: String index out of range: -1at
java.lang.String.substring(String.java:1938)  at
java.lang.String.substring(String.java:1905)   at
org.drools.rule.Package.getFactType(Package.java:552)

when the correct response should be a null object, ins't it?

Thanks 4 the help,

NEStor


Edson Tirelli-3 wrote:
> 
>    Not sure what the problem is, in this case. Can you create a JIRA and
> attach a test case, plz?
> 
> 2009/3/10 nestabur <nestabur at gmail.com>
> 
>>
>> Thanks for the quick reply ;)
>>
>> I saw that sample before, but I'm getting the drl info throw the package
>> generated in guvnor, so I load the package like this:
>>                Properties props = new Properties();
>>                props.put("url", rulePackagePath);
>>                props.put("name",packageId);
>>                agent = RuleAgent.newRuleAgent(props);
>>                session = agent.getRuleBase().newStatefulSession();
>>
>> And I'm trying to get the factType like:
>> agent.getRuleBase().getPackage(packageId).getFactType(modelFullName);
>>
>> NEStor
>>
>>
>> Edson Tirelli-3 wrote:
>> >
>> >    Nestor
>> >
>> >    Look at this integration test, method testGeneratedBeans1():
>> >
>> >
>> http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java
>> >
>> >    Hopefully it will be clear.
>> >
>> >    []s
>> >    Edson
>> >
>> > 2009/3/10 nestabur <nestabur at gmail.com>
>> >
>> >>
>> >>
>> >> Sorry, I don't understand your suggestion ...
>> >>
>> >> As I know, the factTypes are included in the package and referenced in
>> >> the
>> >> DRL files, so for getting the factType I'd have to access via the
>> >> package,
>> >> isn't it? And your proposal is getting the factType throw the DRL file
>> >> name?¿
>> >>
>> >> NEStor
>> >>
>> >>
>> >> Edson Tirelli-3 wrote:
>> >> >
>> >> >     Nestor,
>> >> >
>> >> >     As it is now, DRL files must have a package name or you will be
>> in
>> >> > trouble. So, use a package name for your DRL file and use that
>> package
>> >> > name
>> >> > to retrieve the fact type. It will work.
>> >> >
>> >> >     Meanwhile, I will fix the bug. If you can open a JIRA, even
>> better
>> >> to
>> >> > keep track of progress.
>> >> >
>> >> >     []s
>> >> >     Edson
>> >> >
>> >> > 2009/3/10 nestabur <nestabur at gmail.com>
>> >> >
>> >> >>
>> >> >>
>> >> >> Any suggestions?¿
>> >> >>
>> >> >>
>> >> >> nestabur wrote:
>> >> >> >
>> >> >> > Yes,
>> >> >> >
>> >> >> > If I put a non existent package and type, the method getFactType
>> >> >> returns
>> >> >> > me
>> >> >> > null value, but if I put the correct package and type it throws
>> that
>> >> >> > error.
>> >> >> >
>> >> >> > Thanks,
>> >> >> >
>> >> >> > NEStor
>> >> >> >
>> >> >> > 2009/3/8 Michal Bali <michalbali at gmail.com>
>> >> >> >
>> >> >> >> your factTypeName should consist of package name + type name,
>> for
>> >> >> >> example:
>> >> >> >> com.mycompany.Account
>> >> >> >>
>> >> >> >>
>> >> >> >> On Sun, Mar 8, 2009 at 7:02 PM, nestabur <nestabur at gmail.com>
>> >> wrote:
>> >> >> >>
>> >> >> >>>
>> >> >> >>> Hi all,
>> >> >> >>>
>> >> >> >>> I'm trying to create a fact programatically like this:
>> >> >> >>>
>> >> >> >>> FactType myfact =package.getFactType(factTypeName);
>> >> >> >>> Object myPojo = myfact.newInstance();
>> >> >> >>>
>> >> >> >>> An error occurs when calling the method getFactType, here my
>> >> >> stackTrace:
>> >> >> >>> 36267-1236185246849-0:0:1:1 Exception while processing message:
>> >> >> >>> java.lang.StringIndexOutOfBoundsException: String index out of
>> >> range:
>> >> >> -1
>> >> >> >>> java.lang.StringIndexOutOfBoundsException: String index out of
>> >> range:
>> >> >> -1
>> >> >> >>>        at java.lang.String.substring(String.java:1938)
>> >> >> >>>        at java.lang.String.substring(String.java:1905)
>> >> >> >>>        at org.drools.rule.Package.getFactType(Package.java:552)
>> >> >> >>>
>> >> >> >>> My drools version is 5.0.0.M5
>> >> >> >>>
>> >> >> >>> Any suggestion?
>> >> >> >>>
>> >> >> >>> --
>> >> >> >>> View this message in context:
>> >> >> >>>
>> >> >>
>> >>
>> http://www.nabble.com/Creating-fact-instance-programatically-tp22334399p22334399.html
>> >> >> >>> Sent from the drools - user 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
>> >> >> >>
>> >> >> >>
>> >> >> >
>> >> >> > _______________________________________________
>> >> >> > rules-users mailing list
>> >> >> > rules-users at lists.jboss.org
>> >> >> > https://lists.jboss.org/mailman/listinfo/rules-users
>> >> >> >
>> >> >> >
>> >> >>
>> >> >> --
>> >> >> View this message in context:
>> >> >>
>> >>
>> http://www.nabble.com/Creating-fact-instance-programatically-tp22334399p22431776.html
>> >> >> Sent from the drools - user mailing list archive at Nabble.com.
>> >> >>
>> >> >>
>> >> >> _______________________________________________
>> >> >> rules-users mailing list
>> >> >> rules-users at lists.jboss.org
>> >> >> https://lists.jboss.org/mailman/listinfo/rules-users
>> >> >>
>> >> >
>> >> >
>> >> >
>> >> > --
>> >> >  Edson Tirelli
>> >> >  JBoss Drools Core Development
>> >> >  JBoss, a division of Red Hat @ www.jboss.com
>> >> >
>> >> > _______________________________________________
>> >> > rules-users mailing list
>> >> > rules-users at lists.jboss.org
>> >> > https://lists.jboss.org/mailman/listinfo/rules-users
>> >> >
>> >> >
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/Creating-fact-instance-programatically-tp22334399p22435233.html
>> >> Sent from the drools - user mailing list archive at Nabble.com.
>> >>
>> >>
>> >> _______________________________________________
>> >> rules-users mailing list
>> >> rules-users at lists.jboss.org
>> >> https://lists.jboss.org/mailman/listinfo/rules-users
>> >>
>> >
>> >
>> >
>> > --
>> >  Edson Tirelli
>> >  JBoss Drools Core Development
>> >  JBoss, a division of Red Hat @ www.jboss.com
>> >
>> > _______________________________________________
>> > rules-users mailing list
>> > rules-users at lists.jboss.org
>> > https://lists.jboss.org/mailman/listinfo/rules-users
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Creating-fact-instance-programatically-tp22334399p22437604.html
>> Sent from the drools - user mailing list archive at Nabble.com.
>>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
> 
> 
> 
> -- 
>  Edson Tirelli
>  JBoss Drools Core Development
>  JBoss, a division of Red Hat @ www.jboss.com
> 
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> 
> 

-- 
View this message in context: http://www.nabble.com/Creating-fact-instance-programatically-tp22334399p22451046.html
Sent from the drools - user mailing list archive at Nabble.com.





More information about the rules-users mailing list