<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    On 14/02/2011 18:10, Edson Tirelli wrote:
    <blockquote
      cite="mid:AANLkTimgo-4NjfD3qTBF3Mu=quuGwJz7FqhAr3V7J9+=@mail.gmail.com"
      type="cite">
      <div><br>
      </div>
      &nbsp;&nbsp; The current version of Drools does not support dynamic changes
      in "type declarations" and I don't see this changing anytime soon.
      The reason is that not only the actual fact would require changes,
      but the actual knowledge base would require changes as several
      nodes might be referencing the old class.
      <div>
        <br>
      </div>
      <div>&nbsp;&nbsp; So, to update a fact type you need to recreate the
        knowledge base. This is the same, BTW, than changing one of your
        fact classes in your application jars... you need to recompile
        the knowledge base or you will end up with class cast
        exceptions, sooner or later.</div>
    </blockquote>
    Longer term there are two ways to achieve this<br>
    1) type declarations can only be modified if there is no data on
    them and the existing rules are still valid after the change, i.e.
    it will not effect the current state.<br>
    <br>
    2) If ther eare existing facts a migration script must be provided
    that handles the mapping as all beans would need to be copied to the
    new type declaration.<br>
    <br>
    Mark<br>
    <blockquote
      cite="mid:AANLkTimgo-4NjfD3qTBF3Mu=quuGwJz7FqhAr3V7J9+=@mail.gmail.com"
      type="cite">
      <div><br>
      </div>
      <div>&nbsp;&nbsp; &nbsp;Edson<br>
        <br>
        <div class="gmail_quote">2011/2/14 delete <span dir="ltr">&lt;<a
              moz-do-not-send="true" href="mailto:boyun.yuriy@gmail.com">boyun.yuriy@gmail.com</a>&gt;</span><br>
          <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
            0.8ex; border-left: 1px solid rgb(204, 204, 204);
            padding-left: 1ex;">
            <br>
            Hi.<br>
            I have such declaration of type<br>
            declare Contact<br>
            &nbsp;firstName : String<br>
            end<br>
            <br>
            then I want to add new property to this type. so the &nbsp;next
            version is<br>
            declare Contact<br>
            &nbsp;firstName : String<br>
            &nbsp;newField : String<br>
            end<br>
            <br>
            this type declaration is in separate drl file.<br>
            then I add this new type to current KnowledgeBase.<br>
            but when I execute knowledgeBase.getFactType("test.package",
            "Contact");<br>
            I get old version of Contact.<br>
            <br>
            During debugging I found the place where is should be
            upgraded in the<br>
            KnowledgeBase.<br>
            org.drools.common.AbstractRuleBase.mergePackage<br>
            there is<br>
            // merge the type declarations<br>
            &nbsp; &nbsp; &nbsp; &nbsp;if ( newPkg.getTypeDeclarations() != null ) {<br>
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// add type declarations<br>
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for ( TypeDeclaration type :<br>
            newPkg.getTypeDeclarations().values() ) {<br>
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// @TODO should we allow overrides? only if
            the class is not<br>
            in use.<br>
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ( !pkg.getTypeDeclarations().containsKey(<br>
            type.getTypeName() ) ) {<br>
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// add to package list of type
            declarations<br>
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pkg.addTypeDeclaration( type );<br>
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br>
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br>
            &nbsp; &nbsp; &nbsp; &nbsp;}<br>
            <br>
            so according this comments it's not possible to upgrade Type
            on the fly.<br>
            <br>
            Am I missing something?<br>
            Does someone had such problems or know the workaround.<br>
            <br>
            Thanks in advance,<br>
            Yuriy<br>
            <font color="#888888"><br>
              --<br>
              View this message in context: <a moz-do-not-send="true"
href="http://drools-java-rules-engine.46999.n3.nabble.com/Type-Declaration-upgrade-tp2491975p2491975.html"
                target="_blank">http://drools-java-rules-engine.46999.n3.nabble.com/Type-Declaration-upgrade-tp2491975p2491975.html</a><br>
              Sent from the Drools - User mailing list archive at
              Nabble.com.<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>
            </font></blockquote>
        </div>
        <br>
        <br clear="all">
        <br>
        -- <br>
        &nbsp; Edson Tirelli<br>
        &nbsp; JBoss Drools Core Development<br>
        &nbsp; JBoss by Red Hat @ <a moz-do-not-send="true"
          href="http://www.jboss.com">www.jboss.com</a><br>
      </div>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
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>