DroolsEngine

class DroolsEngine(kbaseName: String, drl: String, config: DroolsEngineConfig) extends RuntimeDrools

Drools engine abstraction

Drools engine abstraction

Value Params
config

drools engine configuration

drl

knowledge base content (rules, declarations, ...)

kbaseName

knowledge base name (what ever you want)

Companion
object
class Object
trait Matchable
class Any

Value members

Concrete methods

def advanceTime(duration: Int, timeUnit: TimeUnit): Unit

Manipulate the time, if a pseudo clock has been configured. This method is very important for unit test purposes.

Manipulate the time, if a pseudo clock has been configured. This method is very important for unit test purposes.

Value Params
duration

how much time shall will go in future

timeUnit

the time unit, default is seconds

def advanceTimeDays(days: Int): Unit
def advanceTimeHours(hours: Int): Unit
def advanceTimeMillis(millis: Int): Unit
def advanceTimeMinutes(minutes: Int): Unit
def advanceTimeSeconds(seconds: Int): Unit
def delete(handle: FactHandle): Unit

delete a fact

delete a fact

def dispose(): Unit
def fireAllRules(): Int

Makes the drools engine fire all activable rules, it will stop once no more rules are activable

Makes the drools engine fire all activable rules, it will stop once no more rules are activable

Returns

number of rule fired

def fireUntilHalt(): Unit

Enter a forever fireAll loop

Enter a forever fireAll loop

def getCurrentTime: Long
def getFactHandle(arrived: Any): FactHandle
def getFactType(declaredType: String): Option[FactType]
def getFields(declaredType: String): List[String]
def getModelFirstInstance(declaredType: String): Option[Any]

Convenient method to quickly get the first available instance of the given type

Convenient method to quickly get the first available instance of the given type

Returns

object option

def getModelFirstInstanceAsJson(declaredType: String): Option[String]

Convenient method to quickly get the first available json instance of the given type

Convenient method to quickly get the first available json instance of the given type

Returns

json string option

def getModelFirstInstanceAttribute(declaredType: String, attributeName: String): Option[Object]

Convenient method to extract a field value from the first found instance of the given type Of course, really convenient if only have just one instance of the given type

Convenient method to extract a field value from the first found instance of the given type Of course, really convenient if only have just one instance of the given type

Returns

value

def getModelInstanceAttribute(instance: Any, attributeName: String): Option[Object]

Retrieve a field value from a drools facts previously extracted from the working memory

Retrieve a field value from a drools facts previously extracted from the working memory

def getModelInstances(declaredType: String): Iterable[Any]

Get all facts which have the given type or inheritate from it

Get all facts which have the given type or inheritate from it

Value Params
declaredType

the full type information of the facts we want to extract

Returns

objects iterable

def getModelInstancesAsJson(declaredType: String): Iterable[String]

Get all facts which have the given type or inheritate from it

Get all facts which have the given type or inheritate from it

Value Params
declaredType

the full type information of the facts we want to extract

Returns

json strings iterable

def getObjects: Iterable[Any]

Retreive all available fact from drools working memory

Retreive all available fact from drools working memory

Returns

objects iterable

def getObjectsAsJson: Iterable[String]

Retreive as json all available fact from drools working memory

Retreive as json all available fact from drools working memory

Returns

json strings iterable

def insert(that: AnyRef): FactHandle

insert a raw object into drools, it can be anything

insert a raw object into drools, it can be anything

def insertJson(json: String, typeInfo: String): FactHandle

Insert a fact described in json, the given typeInfo will be use to find the right declaration

Insert a fact described in json, the given typeInfo will be use to find the right declaration

Value Params
json

the fact to insert

typeInfo

the type of the object we will create

Returns

internal drools fact handle

def strings: List[String]

A convenient method to quickly extract all string instance from drools working memory. Using such strings is quite helpful for testing purposes.

A convenient method to quickly extract all string instance from drools working memory. Using such strings is quite helpful for testing purposes.

Returns

working memory String instances

def timeShiftInSeconds(seconds: Int): Unit
def update(handle: FactHandle, that: AnyRef): Unit

update a fact

update a fact

Inherited methods

def createAndDeployJar(ks: KieServices, kModuleContent: String, releaseId: ReleaseId, drls: Seq[Resource]): KieModule
Inherited from
RuntimeDrools
def createJar(ks: KieServices, kModuleContent: String, releaseId: ReleaseId, drlResources: Seq[Resource]): Array[Byte]
Inherited from
RuntimeDrools
def deployJarIntoRepository(ks: KieServices, jar: Array[Byte]): KieModule
Inherited from
RuntimeDrools
def stringToDrlResource(drlContent: String, sourcePath: String): Resource
Inherited from
RuntimeDrools

Concrete fields

val services: KieServices
val session: KieSession