<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
You should be able to create a KnowledgeBase and add DRL's based on
a string.<br>
And there's a way to cast the KnowledgeBase to the RuleBase, so you
can give it to planner.<br>
<br>
For Planner 6.0, setRuleBase will be replaced by setKnowledgeBase or
setKieBase.<br>
<br>
<div class="moz-cite-prefix">Op 23-01-13 16:53, André Fróes schreef:<br>
</div>
<blockquote
cite="mid:CAC8f_wUUF46udfGz2u+ny6DTxtVkUdZtE3VWVLoCctW4SVqRgg@mail.gmail.com"
type="cite">
<div dir="ltr">I"ve seen that i can do this:
<div><br>
</div>
<div>
<pre class="" style="font-size:0.9em;font-family:courrier,monospace;background-color:rgb(245,245,245);color:rgb(51,51,51);overflow:auto;padding:5px 15px 5px 25px;border:1px solid rgb(204,204,204);line-height:10px;text-align:justify"><a moz-do-not-send="true" id="d0e3847"><span class="" style="color:rgb(0,0,0)">solverFactory</span><span class="" style="color:rgb(0,0,0)">.</span><span class="" style="color:rgb(0,0,0)">getSolverConfig</span><span class="" style="color:rgb(0,0,0)">().</span><span class="" style="color:rgb(0,0,0)">getScoreDirectorFactoryConfig</span><span class="" style="color:rgb(0,0,0)">.</span><span class="" style="color:rgb(0,0,0)">setRuleBase</span><span class="" style="color:rgb(0,0,0)">(</span><span class="" style="color:rgb(0,0,0)">ruleBase</span><span class="" style="color:rgb(0,0,0)">);</span></a></pre>
</div>
<div style="">but this ruleBase still pointing a drl file, i
would like to pass a String to this rulebase, one from my
database.</div>
<div style=""><br>
</div>
<div style="">----------- another implementation i tried</div>
<div style="">
<div> final Reader source = new InputStreamReader(
HelloWorldExample.class.getResourceAsStream(
"HelloWorld.drl" ) ); </div>
<div> final PackageBuilder builder = new
PackageBuilder(); </div>
<div>
builder.addPackageFromDrl( source ); </div>
<div> </div>
<div> if ( builder.hasErrors() ) { </div>
<div> System.out.println(
builder.getErrors().toString() ); </div>
<div> throw new RuntimeException( "Unable to
compile \"HelloWorld.drl\"."); </div>
<div> } </div>
<div> </div>
<div> final Package pkg = builder.getPackage(); </div>
<div> final RuleBase ruleBase =
RuleBaseFactory.newRuleBase(); </div>
<div> ruleBase.addPackage( pkg ); </div>
</div>
<div style=""><br>
</div>
</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">2013/1/22 Geoffrey De Smet <span
dir="ltr"><<a moz-do-not-send="true"
href="mailto:ge0ffrey.spam@gmail.com" target="_blank">ge0ffrey.spam@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"> in the manual, look
for setRuleBase(), it's how you can set the DRL at runtime<br>
<br>
<div>Op 22-01-13 20:17, André Fróes schreef:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div class="im">Can it be done for the drl file
pointed at xml file? Instead of pass the path to drl
file, the drl content?
<div><br>
</div>
<div>here's what i've done to use the xml by java
over the cloudcomputing example:</div>
<div><br>
</div>
<div>--------------------</div>
<div><br>
</div>
</div>
<div>
<div>
<div>String t = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?><solver><solutionClass>org.drools.planner.examples.cloudbalancing.domain.CloudBalance</solutionClass><planningEntityClass>org.drools.planner.examples.cloudbalancing.domain.CloudProcess</planningEntityClass><scoreDirectorFactory><scoreDefinitionType>HARD_AND_SOFT</scoreDefinitionType><scoreDrl>/org/drools/planner/examples/cloudbalancing/solver/cloudBalancingScoreRules.drl</scoreDrl></scoreDirectorFactory><termination><maximumSecondsSpend>120</maximumSecondsSpend></termination><constructionHeuristic><constructionHeuristicType>FIRST_FIT_DECREASING</constructionHeuristicType><constructionHeuristicPickEarlyType>FIRST_LAST_STEP_SCORE_EQUAL_OR_IMPROVING</constructionHeuristicPickEarlyType></constructionHeuristic><localSearch><acceptor><planningEntityTabuSize>7</planningEntityTabuSize></acceptor&
gt;<forager!
><mi
nimalAcceptedSelection>1000</minimalAcceptedSelection></forager></localSearch></solver>";</div>
<div>
<div class="h5">
<div><br>
</div>
<div> <span style="white-space:pre-wrap">
</span>byte b[] = t.getBytes();</div>
<div> <span style="white-space:pre-wrap">
</span>ByteArrayInputStream bt = new
ByteArrayInputStream(b);</div>
<div> SolverFactory solverFactory =
new XmlSolverFactory().configure(bt);</div>
<div> Solver solver =
solverFactory.buildSolver();</div>
</div>
</div>
</div>
</div>
<div>
<div class="h5">
<div>---------------------</div>
<div><br>
</div>
<div>cloudBalancingScoreRules.drl is the file I
want to get from database as text and apply it
to the xml. Is it possible to do inside this
configuration or will I have to implement a xml
file pointing it everytime?</div>
<div><br>
</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote"> 2013/1/22 Geoffrey De
Smet <span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:ge0ffrey.spam@gmail.com"
target="_blank">ge0ffrey.spam@gmail.com</a>></span><br>
<blockquote class="gmail_quote"
style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"> Use a
ByteArrayInputStream based on that String<br>
and give it to:<br>
org.drools.planner.config.XmlSolverFactory#configure(InputStream)<br>
<br>
<div>Op 22-01-13 15:51, André Fróes
schreef:<br>
</div>
<blockquote type="cite">
<div dir="ltr">Can I provide the plain
xml code to a SolverFactory?
<div><br>
</div>
<div>SolverFactory solverFactory = new
XmlSolverFactory(<<xmlHere>>);<br>
</div>
<div><br>
</div>
<div>I know that I can provide the
path to a config file.</div>
</div>
<br>
<fieldset></fieldset>
<br>
<pre>_______________________________________________
rules-users mailing list
<a moz-do-not-send="true" href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>
<a moz-do-not-send="true" href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a>
</pre>
</blockquote>
<br>
</div>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a moz-do-not-send="true"
href="mailto:rules-users@lists.jboss.org"
target="_blank">rules-users@lists.jboss.org</a><br>
<a moz-do-not-send="true"
href="https://lists.jboss.org/mailman/listinfo/rules-users"
target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
<div>
<div class="h5"> <br>
<fieldset></fieldset>
<br>
<pre>_______________________________________________
rules-users mailing list
<a moz-do-not-send="true" href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>
<a moz-do-not-send="true" href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a>
</pre>
</div>
</div>
</blockquote>
<br>
</div>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a moz-do-not-send="true"
href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a moz-do-not-send="true"
href="https://lists.jboss.org/mailman/listinfo/rules-users"
target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br>
</blockquote>
</div>
<br>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
rules-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a>
</pre>
</blockquote>
<br>
</body>
</html>