readall

Dieser Ausdruck ruft alle externen (also durch Client-Code erstellten) Regelobjektinstanzen einer Regelklasse ab. Interne (also aus Regeln erstellte) Regelobjektinstanzen werden mit diesem Ausdruck nicht abgerufen.

Weitere Details über die Erstellung von Regelobjekten finden Sie im Abschnitt Externe und interne Regelobjekte.

Seit Cúram Version 6 kann der Ausdruck readall verwendet werden, um Instanzen einer Regelklasse aus einem anderen Regelwerk abzurufen, indem für das optionale XML-Attribut ruleset ein Wert definiert wird.

Seit Cúram Version 6 unterstützt der Ausdruck readall ein optionales Element match. Dieses Element bewirkt, dass der Ausdruck readall nur diejenigen Regelobjekte abruft, deren Wert für ein bestimmtes Attribut mit dem in der Suchbedingung angegebenen Wert übereinstimmt.

Wichtig: Vor Cúram Version 6 konnten Regelobjekte, die mit einer Bedingung übereinstimmen, unter anderem dadurch abgerufen werden, dass der Ausdruck readall in einen Ausdruck "filter" (siehe filter) eingeschlossen wurde.

Bei CER-Sitzungen, die einen Datenbankdatenspeicher verwenden (siehe CER-Sitzungen), kann mit der in Cúram Version 6 eingeführten Syntax readall / match im Allgemeinen jedoch ein besseres Leistungsverhalten erzielt werden. Dies trifft in den folgenden Situationen zu:

  • Das Attribut, das den Ausdruck readall enthält, wird zuerst berechnet.
  • CER und der Abhängigkeitsmanager stellen fest, dass das Attribut, in dem der Ausdruck readall enthalten ist, nicht auf dem neuesten Stand ist und neu berechnet werden muss (siehe Abhängigkeitsmanager).

Bei Fällen, in denen Regelobjekte mit mehreren Bedingungen übereinstimmen müssen, sollten Sie mit der Syntax readall / match eine Übereinstimmung mit dem selektivsten Attribut erzielen und anschließend die Ergebnisse in einen Ausdruck "filter" (siehe filter) einschließen, um eine zusätzliche Filterung nach den übrigen Bedingungen vorzunehmen.

Tipp: Erwarten Sie lediglich eine Singleton-Instanz der Regelklasse (möglicherweise nach einer Filterung oder Übereinstimmung), kann es sinnvoll sein, den Ausdruckk in einen Ausdruck "singleitem" (siehe singleitem) einzuschließen.
<?xml version="1.0" encoding="UTF-8"?>
<RuleSet name="Example_readall"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:noNamespaceSchemaLocation=
"http://www.curamsoftware.com/CreoleRulesSchema.xsd">
  <Class name="Person">

    <Attribute name="socialSecurityNumber">
      <type>
        <javaclass name="String"/>
      </type>
      <derivation>
        <specified/>
      </derivation>
    </Attribute>

    <!--
    Retrieve the one-and-only claim which will have been used to
    seed the session
    -->

    <Attribute name="claim">
      <type>
        <ruleclass name="Claim"/>
      </type>
      <derivation>
        <singleitem onEmpty="error" onMultiple="error">
          <readall ruleclass="Claim"/>
        </singleitem>
      </derivation>
    </Attribute>


    <!--
    Retrieve the benefit rule objects for this person (created from
    client code, probably by querying external storage).

    This implementation uses a <readall> with a nested <match> to
    retrieve only the matching rule objects, and (depending on data
    storage) will be more performant than the
    "benefitsFilterReadall" implementation below.
    -->

    <Attribute name="benefitsReadallMatch">
      <type>
        <javaclass name="List">
          <ruleclass name="Benefit"/>
        </javaclass>
      </type>
      <derivation>
        <readall ruleclass="Benefit">
          <match retrievedattribute="socialSecurityNumber">
            <reference attribute="socialSecurityNumber"/>
          </match>
        </readall>
      </derivation>
    </Attribute>


    <!--
    Retrieves the same rule objects as for "benefitsReadallMatch"
    above, but (depending on data storage) may not be as performant.
    -->
    <Attribute name="benefitsFilterReadall">
      <type>
        <javaclass name="List">
          <ruleclass name="Benefit"/>
        </javaclass>
      </type>
      <derivation>
        <filter>
          <list>
            <!-- retrieve all Benefit rule objects from external
                 storage -->
            <readall ruleclass="Benefit"/>
          </list>
          <listitemexpression>
            <equals>
              <!-- match up the social security numbers on
                the person rule object and the benefit
                rule object -->
              <reference attribute="socialSecurityNumber">
                <current/>
              </reference>
              <reference attribute="socialSecurityNumber"/>
            </equals>
          </listitemexpression>
        </filter>
      </derivation>
    </Attribute>

    <!--
    Retrieves the person's benefits of type "IncomeAssistance",
    using a <match> to retrieve all the person's benefits, and then
    a <filter> to extract only the "Income Assistance" benefits from
    the benefits for that person.

    This implementation may be suitable when the
    socialSecurityNumber is the most selective attribute for a
    Benefit in the data storage (i.e. there are many Benefit rule
    objects, but each socialSecurityNumber value is present on
    relatively few Benefit rule objects).
    -->
    <Attribute name="incomeAssistanceBenefitsMatchSSNFilterType">
      <type>
        <javaclass name="List">
          <ruleclass name="Benefit"/>
        </javaclass>
      </type>
      <derivation>
        <filter>
          <list>
            <!-- retrieve all Benefit rule objects for the Person
 -->
            <readall ruleclass="Benefit">
              <match retrievedattribute="socialSecurityNumber">
                <reference attribute="socialSecurityNumber"/>
              </match>
            </readall>
          </list>
          <listitemexpression>
            <equals>
              <!-- filter the Benefit rule objects for the Person
                   down to those of type "Income Assistance" only
                -->
              <reference attribute="type">
                <current/>
              </reference>
              <Code table="BenefitType">
                <!-- The value for Income Assistance -->
                <String value="BT1"/>
              </Code>
            </equals>
          </listitemexpression>
        </filter>
      </derivation>
    </Attribute>


    <!--
    Retrieves the person's benefits of type "IncomeAssistance",
    using a <match> to retrieve all the "Income Assistance"
    benefits, and then a <filter> to extract only the "Income
    Assistance" benefits for this Person.

    This implementation may be suitable when the type is the most
    selective attribute for a Benefit in the data storage (i.e.
    there are few Benefit rule objects of each type).
    -->
    <Attribute name="incomeAssistanceBenefitsMatchTypeFilterSSN">
      <type>
        <javaclass name="List">
          <ruleclass name="Benefit"/>
        </javaclass>
      </type>
      <derivation>
        <filter>
          <list>
            <!-- retrieve all Benefit rule objects of type "Income
                 Assistance" -->
            <readall ruleclass="Benefit">
              <match retrievedattribute="type">
                <Code table="BenefitType">
                  <!-- The value for Income Assistance -->
                  <String value="BT1"/>
                </Code>
              </match>
            </readall>
          </list>
          <listitemexpression>
            <equals>
              <!-- filter the Benefit rule objects of type "Income
                   Assistance"  down to those for this Person only
                -->
              <reference attribute="socialSecurityNumber">
                <current/>
              </reference>
              <reference attribute="socialSecurityNumber"/>
            </equals>
          </listitemexpression>
        </filter>
      </derivation>
    </Attribute>

    <!--
    Retrieves the rule objects for Benefits whose amount is greater
    than 100.

    Because "greater than" is not an exact match predicate, a
    <filter> must be used (<match> can only be used for an exact
    match criterion).
    -->
    <Attribute name="highPaymentBenefits">
      <type>
        <javaclass name="List">
          <ruleclass name="Benefit"/>
        </javaclass>
      </type>
      <derivation>
        <filter>
          <list>
            <!-- retrieve all Benefit rule objects for the Person
              -->
            <readall ruleclass="Benefit">
              <match retrievedattribute="socialSecurityNumber">
                <reference attribute="socialSecurityNumber"/>
              </match>
            </readall>
          </list>
          <listitemexpression>
            <!-- filter the Benefit rule objects for the Person down
                 to those of amount greater than 100 only -->
            <compare comparison=">">
              <reference attribute="amount">
                <current/>
              </reference>
              <Number value="100"/>
            </compare>
          </listitemexpression>
        </filter>
      </derivation>
    </Attribute>



  </Class>

  <Class name="Benefit">

    <Attribute name="socialSecurityNumber">
      <type>
        <javaclass name="String"/>
      </type>
      <derivation>
        <specified/>
      </derivation>
    </Attribute>

    <Attribute name="type">
      <type>
        <codetableentry table="BenefitType"/>
      </type>
      <derivation>
        <specified/>
      </derivation>
    </Attribute>

    <Attribute name="amount">
      <type>
        <javaclass name="Number"/>
      </type>
      <derivation>
        <specified/>
      </derivation>
    </Attribute>

  </Class>

  <!--
  This rule set expects that the code creating the session also
  creates a "bootstrap" single instance of this Claim rule
  class.
  -->
  <Class name="Claim">
    <Initialization>
      <Attribute name="claimIdentifier">
        <type>
          <javaclass name="String"/>
        </type>
      </Attribute>
      <Attribute name="claimDate">
        <type>
          <javaclass name="curam.util.type.Date"/>
        </type>
      </Attribute>
    </Initialization>
  </Class>

</RuleSet>