Uploaded image for project: 'JBRULES'
  1. JBRULES
  2. JBRULES-2123

issue with the call of a drl function

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

    XMLWordPrintable

Details

    • Bug
    • Resolution: Obsolete
    • Minor
    • 6.0.0.Alpha1
    • 5.0.1.FINAL
    • drools-core
    • None

    Description

      in a drl file with a rule "reset" ad a function "formatDate",a bad behaviour is verified when is called the function in the "when" block..it call the function many times, but if the function called is stored in a external java file (not drl) everything works fine, and it call the function only 2 times (correct).
      Here the code of the drl file:

      rule "reset"
      when
      $conversation:Conversation(resource.code == "sms", tickets.size > 0)
      not Discount(date == (formatDate($conversation.getStopDate())))
      then
      Discount discount = new Discount();
      discount.setDate(formatDate($conversation.getStopDate()));
      discount.setQuantity(495);
      insert(discount);
      System.out.println("reset " + discount.getDate());
      end

      declare Discount
      date : String
      quantity : int
      end

      function String formatDate(java.util.Date date) {
      java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("dd/MM/yy");
      return formatter.format(date);
      }

      Attachments

        Activity

          People

            mfusco@redhat.com Mario Fusco
            mghanitab Marco Ghanitab (Inactive)
            Archiver:
            rhn-support-ceverson Clark Everson

            Dates

              Created:
              Updated:
              Resolved:
              Archived:

              PagerDuty