title: How to call a Java function in the 'when' part of the drools rule?
body: <p>I have been searching for a while now, but I can't find the exact answer to my question anywhere, or if I find something similar, it doesn't works.</p>
  
  <p>I want to call a simple java method in the when part of the rule.</p>
  
  <p>My code looks like this:</p>
  
  <pre><code>rule "Ret Rule"
  when 
      Map(this["LOYAL"] == "true")
      Map(this["LOYALTYPROMORETENTION"] == "true")
      PromotionValidityPeriod(promotionName == "VIVACLUB Loyalty Promo 2013 25 percent")
      $customer: Customer( segment == "Residential" , $assets : assets )
      $o: Order( ( (DPOrderType == 17 &amp;&amp; retentionReason == "RET") || (DPOrderType == 2 &amp;&amp; reason == "557") ) , $ct: contractTerms == 24, $olis: orderLineItems )
      $tariff: OrderLI( part in ("DT2319", "DT2320"), actionCode not in ("Delete", "INVALID"), $parentId : parentId) from $olis
      OrderLI( part == "DT2316", nodeId == $parentId, actionCode not in ("Delete", "INVALID"), $assetId : assetId ) from $olis
      /*Asset( assetId == $assetId,
          ( (contractTerms != null &amp;&amp; contractEndDate != null &amp;&amp; eval(CalculationsHelper.getFullMonthDifference(new Date(), contractEndDate) &lt; 3 ))
              || (contractTerms == null) ) ) from $assets*/
      $li : OrderLI( $newTariff : part in ("DT2319", "DT2320"), parentId == $parentnodeid, actionCode == "Add")  from $olis 
      $del : OrderLI( $oldTariff : part, parentId == $parentnodeid, actionCode == "Delete", productType == "Calling Plan")  from $olis
      eval(OrderDwrController.setTransitionCondition(fromTariff == $oldTariff, toTariff == $newTariff) == true
  then
      Offer of = new Offer("DT2331", $parentId, 7);
      System.out.println($tariffOld);
      of.getOrderLineItemAttributes().add(new OrderLIAttribute("DURATION", "" + $ct));
      of.getOrderLineItemAttributes().add(new OrderLIAttribute("Discount of MRC", "25%"));
      of.getOrderLineItemAttributes().add(new OrderLIAttribute("VIVACOM TV Package", $tariff.getProductNameENU()));
      of.setProductNameENU("VIVACLUB Loyalty Promo 2013 25 percent");
      $o.addOffer(of);
      of.setLoyaltyPromo(true);
      $o.addTextForOffer(of, new Integer[]{173});
  end
  </code></pre>
  
  <p>The particular line where I have a problem is the very last one in the <code>when</code> part:</p>
  
  <pre><code>eval(OrderDwrController.setTransitionCondition(
      fromTariff == $oldTariff, toTariff == $newTariff) == true
  </code></pre>
  
  <p>I just want to call a simple function </p>
  
  <pre><code>(OrderDwrController.setTransitionCondition(
      fromTariff == $oldTariff, toTariff == $newTariff))
  </code></pre>
  
  <p>like the one above mine </p>
  
  <pre><code>(eval(CalculationsHelper.getFullMonthDifference(
      new Date(), contractEndDate) &lt; 3 ))
  </code></pre>
  
  <p>The function is static, returns a boolean value. I have imported the class in the beginning of the file.</p>
  
  <p>What am I doing wrong?</p>