drools-scripting


License

License

GroupId

GroupId

fr.janalyse
ArtifactId

ArtifactId

drools-scripting_2.11
Last Version

Last Version

1.0.8
Release Date

Release Date

Type

Type

jar
Description

Description

drools-scripting
drools-scripting
Project URL

Project URL

https://github.com/dacr/drools-scripting
Project Organization

Project Organization

fr.janalyse
Source Code Management

Source Code Management

https://github.com/dacr/drools-scripting

Download drools-scripting_2.11

How to add to project

<!-- https://jarcasting.com/artifacts/fr.janalyse/drools-scripting_2.11/ -->
<dependency>
    <groupId>fr.janalyse</groupId>
    <artifactId>drools-scripting_2.11</artifactId>
    <version>1.0.8</version>
</dependency>
// https://jarcasting.com/artifacts/fr.janalyse/drools-scripting_2.11/
implementation 'fr.janalyse:drools-scripting_2.11:1.0.8'
// https://jarcasting.com/artifacts/fr.janalyse/drools-scripting_2.11/
implementation ("fr.janalyse:drools-scripting_2.11:1.0.8")
'fr.janalyse:drools-scripting_2.11:jar:1.0.8'
<dependency org="fr.janalyse" name="drools-scripting_2.11" rev="1.0.8">
  <artifact name="drools-scripting_2.11" type="jar" />
</dependency>
@Grapes(
@Grab(group='fr.janalyse', module='drools-scripting_2.11', version='1.0.8')
)
libraryDependencies += "fr.janalyse" % "drools-scripting_2.11" % "1.0.8"
[fr.janalyse/drools-scripting_2.11 "1.0.8"]

Dependencies

compile (7)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.11.12
org.drools : drools-core jar 7.31.0.Final
org.drools : drools-compiler jar 7.31.0.Final
org.slf4j : slf4j-api jar 1.7.30
ch.qos.logback : logback-classic jar 1.2.3
com.owlike : genson jar 1.6
org.scala-lang.modules : scala-collection-compat_2.11 jar 2.1.3

test (1)

Group / Artifact Type Version
org.scalatest : scalatest_2.11 jar 3.1.0

Project Modules

There are no modules declared in this project.

Drools scripting Build Status License Maven

Drools made easy to use for scripting or testing purposes.

This library allows you to easily design proof of concepts based of the drools expert system. It greatly simplifies how you can quickly write drools based code examples or small experiments.

Just insert JSON facts into your drools working memory, and use the available engine methods to interact with the expert system and extract data from it. Data extraction can be done through simple accessors or through the JSON format. Check the documented methods in the DroolsEngine class or take a look to the large amount of example I've made available. (Most of them can be run directly by using the great ammonite REPL solution from Li Haoyi)

A selection of my drools shared code examples based on drools-scripting project :

A hello world drools example runnable with ammonite :

import $ivy.`fr.janalyse::drools-scripting:1.0.11`, $ivy.`org.scalatest::scalatest:3.2.2`
import fr.janalyse.droolscripting._, org.scalatest.flatspec._, org.scalatest.matchers._

object HelloTest extends AnyFlatSpec with should.Matchers {
  "Drools" should "say hello" in {
    val drl =
      """package test
        |rule "hello" when
        |then
        |  insert("HELLO WORLD");
        |end
        |""".stripMargin
    val engine = DroolsEngine(drl)
    engine.fireAllRules()
    engine.strings shouldBe List("HELLO WORLD")
  }
}
HelloTest.execute()

or an other one runnable with ammonite :

import $ivy.`fr.janalyse::drools-scripting:1.0.11`, $ivy.`org.scalatest::scalatest:3.2.2`
import fr.janalyse.droolscripting._, org.scalatest._, flatspec._, matchers._, OptionValues._

object HelloTest extends AnyFlatSpec with should.Matchers {
  "Drools" should "say hello" in {
    val drl =
      """package test
        |
        |declare Someone
        |  name:String
        |end
        |
        |declare Message
        |  message:String
        |end
        |
        |rule "hello" when
        |  Someone($name:name)
        |then
        |  insert(new Message("HELLO "+$name));
        |end
        |""".stripMargin
    val engine = DroolsEngine(drl)
    engine.insertJson("""{"name":"John"}""","test.Someone")
    engine.fireAllRules()
    val msgOption = engine.getModelFirstInstanceAttribute("test.Message", "message")
    msgOption.value shouldBe "HELLO John"
  }
}
HelloTest.execute()

Versions

Version
1.0.8
1.0.7
1.0.6
1.0.5
1.0.4