singleitem

목록에서 단일 항목을 검색합니다.

목록에 하나의 항목만 포함되어야 하는 경우(즉, 목록에서 하나의 항목만 수집해야 하는 기준을 사용하여 목록을 필터링하는 경우) singleitem 표현식을 유용하게 사용할 수 있습니다.

singleitem 표현식은 다음을 지정합니다.

목록의 특정 위치에서 항목을 검색하려면 유용한 목록 조작get을 참조하십시오.

<?xml version="1.0" encoding="UTF-8"?>
<RuleSet name="Example_singleitem"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:noNamespaceSchemaLocation=
"http://www.curamsoftware.com/CreoleRulesSchema.xsd">
  <Class name="Person">

    <Attribute name="dateOfBirth">
      <type>
        <javaclass name="curam.util.type.Date"/>
      </type>
      <derivation>
        <specified/>
      </derivation>
    </Attribute>

    <Attribute name="children">
      <type>
        <javaclass name="List">
          <ruleclass name="Person"/>
        </javaclass>
      </type>
      <derivation>
        <specified/>
      </derivation>
    </Attribute>

    <!-- 이 개인의 첫째 자녀 -->
    <Attribute name="firstBornChild">
      <type>
        <ruleclass name="Person"/>
      </type>
      <derivation>
        <!-- 첫째 자녀를 가져옴(있는 경우)
             - 자녀가 없으면 널을 리턴함 -->
        <singleitem onEmpty="returnNull" onMultiple="returnFirst">
          <!-- 생년월일 순서로 자녀를 정렬 -->
          <sort>
            <list alias="child">
              <reference attribute="children"/>
            </list>
            <sortorder>
              <sortitem direction="ascending">
                <reference attribute="dateOfBirth">
                  <current alias="child"/>
                </reference>
              </sortitem>
            </sortorder>
          </sort>

        </singleitem>
      </derivation>

    </Attribute>

    <!-- 외부 스토리지에서 단일 가정 정보 레코드를
         검색합니다. 항상 정확히 하나의 레코드가 있어야
         합니다. 그 이상이 있으면 오류입니다. -->
    <Attribute name="householdInformation">
      <type>
        <ruleclass name="HouseholdInformation"/>
      </type>
      <derivation>
        <singleitem onEmpty="error" onMultiple="error">
          <readall ruleclass="HouseholdInformation"/>
        </singleitem>
      </derivation>
    </Attribute>

  </Class>

  <Class name="HouseholdInformation">

    <Attribute name="householdContainsDisabledPerson">
      <type>
        <javaclass name="Boolean"/>
      </type>
      <derivation>
        <specified/>
      </derivation>
    </Attribute>

  </Class>

</RuleSet>