[rules-users] RuleAgent - loading rules help ?

2011-08-08 Thread Ivan Peshev ( M-Tel )
Hello,

Is there a way to tell RuleAgent to load rules not only from remote URL ?
i.e. some rules from URL and some rules from LOCAL path on my computer.
(e.g.: c:\some\folder\rule.drl)

Or if it's not possible exactly that way is there another way to have some 
rules loaded from URLs and some rules loaded from local path ?



Best Regards
Ivan

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


Re: [rules-users] RuleAgent - loading rules help ?

2011-08-08 Thread Swindells, Thomas
Have you tried just using a file url?

From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Ivan Peshev ( M-Tel )
Sent: 08 August 2011 11:04
To: rules-users@lists.jboss.org
Subject: [rules-users] RuleAgent - loading rules help ?

Hello,

Is there a way to tell RuleAgent to load rules not only from remote URL ?
i.e. some rules from URL and some rules from LOCAL path on my computer.
(e.g.: c:\some\folder\rule.drl)

Or if it's not possible exactly that way is there another way to have some 
rules loaded from URLs and some rules loaded from local path ?



Best Regards
Ivan




**
This message is confidential and intended only for the addressee. If you have 
received this message in error, please immediately notify the 
postmas...@nds.com and delete it from your system as well as any copies. The 
content of e-mails as well as traffic data may be monitored by NDS for 
employment and security purposes. To protect the environment please do not 
print this e-mail unless necessary.

NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, 
United Kingdom. A company registered in England and Wales. Registered no. 
3080780. VAT no. GB 603 8808 40-00
**
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] RuleAgent - loading rules help ?

2011-08-08 Thread Esteban Aliverti
Which version of drools are you using?
If you are using a change-set to feed you kagent, then you can use other
protocols rather than http to get your rules from: file://, classpath://

Best Regards,



Esteban Aliverti
- Developer @ http://www.plugtree.com
- Blog @ http://ilesteban.wordpress.com


2011/8/8 Ivan Peshev ( M-Tel ) ivan.pes...@mobiltel.bg

 Hello,

 ** **

 Is there a way to tell RuleAgent to load rules not only from remote URL ?*
 ***

 i.e. some rules from URL and some rules from LOCAL path on my computer.***
 *

 (e.g.: c:\some\folder\rule.drl)

 ** **

 Or if it’s not possible exactly that way is there another way to have some
 rules loaded from URLs and some rules loaded from local path ?

 ** **

 ** **

 ** **

 Best Regards

 Ivan

 ** **

 ___
 rules-users mailing list
 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


Re: [rules-users] RuleAgent - loading rules help ?

2011-08-08 Thread Ivan Peshev ( M-Tel )
Here is some more details:

* Currently our system loads rules from Guvnor installed on a server 
(version 5.0.0)
The problem is that there is no way to debug remotely the rules which are 
already deployed on Guvnor.

So I was wondering what if I load the rule I need to debug from my local 
machine instead maybe then I'll be able to debug it...

* On my local machine I have drools 5.1.0

Here is part of the original code:

  public synchronized void loadRulebasesDefinition() {
ruleBaseList = RulesMapper.getRulesMapper().retrieveAllRuleBases();

for (EntryInteger, Rule entry : ruleBaseList.entrySet()) {
  Rule currentRuleDefinition = entry.getValue();

  Properties ruleBaseProperties = 
createRuleBaseProperties(currentRuleDefinition);
  RuleAgent agent = RuleAgent.newRuleAgent(ruleBaseProperties);
  currentRuleDefinition.setRuleBase(agent.getRuleBase());
}
  }

  private Properties createRuleBaseProperties(Rule ruleDefinition) {
Properties properties = new Properties();
properties.setProperty(url, ruleDefinition.getRuleBaseURL());
properties.setProperty(poll, 
Integer.toString(ruleDefinition.getRuleBasePoll()));
return properties;
  }

The info about the rules is retrieved by the Mapper class from a DB and the 
result is a map:
MapInteger, Rule ruleBaseList


So I modified the loadRulebasesDefinition() method and I changed the url info 
in the DB for some of the rules to start with local: and to point to a 
location on my machine:
--
  public synchronized void loadRulebasesDefinition() {
ruleBaseList = RulesMapper.getRulesMapper().retrieveAllRuleBases();

for (EntryInteger, Rule entry : ruleBaseList.entrySet()) {
  Rule currentRuleDefinition = entry.getValue();

  Properties ruleBaseProperties = 
createRuleBaseProperties(currentRuleDefinition);
  if 
(ruleBaseProperties.getProperty(url).startsWith(local:))
  {
try {
 String path = 
ruleBaseProperties.getProperty(url).replaceAll(local:, );
 File file = new File(path);
 Reader source = new InputStreamReader(new 
FileInputStream(file));
 PackageBuilder builder = new PackageBuilder();
 builder.addPackageFromDrl( source );
 org.drools.rule.Package pkg = builder.getPackage();
 RuleBase ruleBase = RuleBaseFactory.newRuleBase();
 ruleBase.addPackage( pkg );
 currentRuleDefinition.setRuleBase(ruleBase);
} catch (DroolsParserException e) {
 // TODO Auto-generated catch block
 e.printStackTrace();
} catch (IOException e) {
 // TODO Auto-generated catch block
 e.printStackTrace();
}
  }
  else
  {
RuleAgent agent = 
RuleAgent.newRuleAgent(ruleBaseProperties);
currentRuleDefinition.setRuleBase(agent.getRuleBase());
  }
}
  }

  When I start the project it looks like working,
But when I try to debug as Drools application it goes to some point - loads 
some rules from URLs etc
- and boom:
Exception in thread main org.drools.RuntimeDroolsException: [Error: not a 
statement, or badly formed structure]
[Near : {... Unknown }]


Any idea ?
Thanks  Best regards
Ivan



From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Esteban Aliverti
Sent: Monday, August 08, 2011 1:32 PM
To: Rules Users List
Subject: Re: [rules-users] RuleAgent - loading rules help ?

Which version of drools are you using?
If you are using a change-set to feed you kagent, then you can use other 
protocols rather than http to get your rules from: file://, classpath://

Best Regards,



Esteban Aliverti
- Developer @ http://www.plugtree.com
- Blog @ http://ilesteban.wordpress.com

2011/8/8 Ivan Peshev ( M-Tel ) 
ivan.pes...@mobiltel.bgmailto:ivan.pes...@mobiltel.bg
Hello,

Is there a way to tell RuleAgent to load rules not only from remote URL ?
i.e. some rules from URL and some rules from LOCAL path on my computer.
(e.g.: c:\some\folder\rule.drl)

Or if it's not possible exactly that way is there another way to have some 
rules loaded from URLs and some rules loaded from local path ?



Best Regards
Ivan