⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 state.python.drl

📁 drools 一个开放源码的规则引擎
💻 DRL
字号:
<?xml version="1.0"?>

<rule-set name="State Example"
          xmlns="http://drools.org/rules"
          xmlns:python="http://drools.org/semantics/python"
          xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
          xs:schemaLocation="http://drools.org/rules rules.xsd
                             http://drools.org/semantics/python python.xsd">

    <import>from org.drools.examples.state import State</import>

    <rule name="Bootstrap">
        <parameter identifier="a">
            <class-field field="name" value="A">State</class-field>
        </parameter>

        <python:condition>a.getState() == "NOTRUN"</python:condition>

        <python:consequence>
            print "%s finished" % a.getName();
            a.setState("FINISHED");
        </python:consequence>
    </rule>

    <rule name="AtoB" salience="30">
        <parameter identifier="a">
            <class-field field="name" value="A">State</class-field>
        </parameter>
        <parameter identifier="b">
            <class-field field="name" value="B">State</class-field>
        </parameter>

        <python:condition>a.getState() == "FINISHED"</python:condition>
        <python:condition>b.getState() == "NOTRUN"</python:condition>

        <python:consequence>
            print "%s finished" % b.getName();
            b.setState("FINISHED");
        </python:consequence>
    </rule>

    <rule name="BtoC" salience="20">
        <parameter identifier="b">
            <class-field field="name" value="B">State</class-field>
        </parameter>
        <parameter identifier="c">
            <class-field field="name" value="C">State</class-field>
        </parameter>

        <python:condition>b.getState() == "FINISHED"</python:condition>
        <python:condition>c.getState() == "NOTRUN"</python:condition>

        <python:consequence>
            print "%s finished" % c.getName();
            c.setState("FINISHED");
        </python:consequence>
    </rule>

    <rule name="BtoD" salience="10">
        <parameter identifier="b">
            <class-field field="name" value="B">State</class-field>
        </parameter>
        <parameter identifier="d">
            <class-field field="name" value="D">State</class-field>
        </parameter>

        <python:condition>b.getState() == "FINISHED"</python:condition>
        <python:condition>d.getState() == "NOTRUN"</python:condition>

        <python:consequence>
            print "%s finished" % d.getName();
            d.setState("FINISHED");
        </python:consequence>
    </rule>

  </rule-set>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -