<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&eacute; Fr&oacute;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>&nbsp; &nbsp; &nbsp; &nbsp; final Reader source = new InputStreamReader(
            HelloWorldExample.class.getResourceAsStream(
            "HelloWorld.drl" ) ); &nbsp;&nbsp;</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; final PackageBuilder builder = new
            PackageBuilder(); &nbsp;&nbsp;</div>
          <div>
            &nbsp; &nbsp; &nbsp; &nbsp; builder.addPackageFromDrl( source ); &nbsp;&nbsp;</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; if ( builder.hasErrors() ) { &nbsp;&nbsp;</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(
            builder.getErrors().toString() ); &nbsp;&nbsp;</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; throw new RuntimeException( "Unable to
            compile \"HelloWorld.drl\"."); &nbsp;&nbsp;</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; } &nbsp;&nbsp;</div>
          <div>&nbsp; &nbsp;</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; final Package pkg = builder.getPackage(); &nbsp;&nbsp;</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; final RuleBase ruleBase =
            RuleBaseFactory.newRuleBase(); &nbsp;&nbsp;</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; ruleBase.addPackage( pkg );&nbsp;</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">&lt;<a moz-do-not-send="true"
              href="mailto:ge0ffrey.spam@gmail.com" target="_blank">ge0ffrey.spam@gmail.com</a>&gt;</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&eacute; Fr&oacute;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 = "&lt;?xml version=\"1.0\"
                        encoding=\"UTF-8\"?&gt;&lt;solver&gt;&lt;solutionClass&gt;org.drools.planner.examples.cloudbalancing.domain.CloudBalance&lt;/solutionClass&gt;&lt;planningEntityClass&gt;org.drools.planner.examples.cloudbalancing.domain.CloudProcess&lt;/planningEntityClass&gt;&lt;scoreDirectorFactory&gt;&lt;scoreDefinitionType&gt;HARD_AND_SOFT&lt;/scoreDefinitionType&gt;&lt;scoreDrl&gt;/org/drools/planner/examples/cloudbalancing/solver/cloudBalancingScoreRules.drl&lt;/scoreDrl&gt;&lt;/scoreDirectorFactory&gt;&lt;termination&gt;&lt;maximumSecondsSpend&gt;120&lt;/maximumSecondsSpend&gt;&lt;/termination&gt;&lt;constructionHeuristic&gt;&lt;constructionHeuristicType&gt;FIRST_FIT_DECREASING&lt;/constructionHeuristicType&gt;&lt;constructionHeuristicPickEarlyType&gt;FIRST_LAST_STEP_SCORE_EQUAL_OR_IMPROVING&lt;/constructionHeuristicPickEarlyType&gt;&lt;/constructionHeuristic&gt;&lt;localSearch&gt;&lt;acceptor&gt;&lt;planningEntityTabuSize&gt;7&lt;/planningEntityTabuSize&gt;&lt;/acceptor&
gt;&lt;forager!

                        &gt;&lt;mi
nimalAcceptedSelection&gt;1000&lt;/minimalAcceptedSelection&gt;&lt;/forager&gt;&lt;/localSearch&gt;&lt;/solver&gt;";</div>
                      <div>
                        <div class="h5">
                          <div><br>
                          </div>
                          <div>&nbsp; &nbsp; <span style="white-space:pre-wrap">
                            </span>byte b[] = t.getBytes();</div>
                          <div>&nbsp; &nbsp; <span style="white-space:pre-wrap">
                            </span>ByteArrayInputStream bt = new
                            ByteArrayInputStream(b);</div>
                          <div> &nbsp; &nbsp; &nbsp; &nbsp; SolverFactory solverFactory =
                            new XmlSolverFactory().configure(bt);</div>
                          <div>&nbsp; &nbsp; &nbsp; &nbsp; 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">&lt;<a
                              moz-do-not-send="true"
                              href="mailto:ge0ffrey.spam@gmail.com"
                              target="_blank">ge0ffrey.spam@gmail.com</a>&gt;</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&eacute; Fr&oacute;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(&lt;&lt;xmlHere&gt;&gt;);<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>