timelineoperation

하위 표현식을 반복적으로 호출하여 타임라인(시간 경과에 따라 변경되는 데이터 처리 참조)을 조합하십시오. 일반적으로 timelineoperationintervalvalue와 함께 사용되며, 이 두 표현식을 함께 사용하면 다른 표현식이 타임라인의 값을 기본 값으로 간주하여 이 값을 조작한 다음 결과 데이터를 타임라인에 다시 조합할 수 있습니다.

팁: 알고리즘에 입력되는 각 타임라인의 경우 일반적으로 타임라인을 리턴하는 표현식을 intervalvalue로 둘러싼 다음 전체 결과를 timelineoperation으로 둘러싸야 합니다.

다음은 평가 시 timelineoperation이 동작하는 방식에 대한 간략한 설명입니다.

위에 설명된 동작은 보면 내부 표현식이 타임라인과 관련된 처리의 일부임을 몰라도 된다는 의미입니다. 또한 입력 타임라인이 값을 변경한 날짜에 대해서만 표현식이 호출되므로 처리가 효율적입니다.

참고: timelineoperationintervalvalue로 둘러싸지 않은 표현식을 조작하는 경우 결과적으로 생긴 타임라인의 모든 시간이 상수 값이 됩니다.
<?xml version="1.0" encoding="UTF-8"?>
<RuleSet name="Example_timelineoperation"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:noNamespaceSchemaLocation=
"http://www.curamsoftware.com/CreoleRulesSchema.xsd">

  <Class name="Person">
    <!--
     개인이 생존해 있는 동안에는 true, 생년월일 전에는 false,
     사망년월일(있는 경우) 이후에도 false
      -->
    <Attribute name="isAliveTimeline">
      <type>
        <javaclass name="curam.creole.value.Timeline">
          <javaclass name="Boolean"/>
        </javaclass>
      </type>
      <derivation>
        <specified/>
      </derivation>
    </Attribute>

    <!--
     개인이 어떤 시점에 소유한 자산입니다. 각 자산의
     가치는 시간이 경과함에 따라 변할 수 있습니다.
      -->
    <Attribute name="ownedAssets">
      <type>
        <javaclass name="List">
          <ruleclass name="Asset"/>
        </javaclass>
      </type>
      <derivation>
        <specified/>
      </derivation>
    </Attribute>



    <!--
     개인(또는 개인이 사망한 경우 개인의 부동산)이 소유한
     자산의 총 가치입니다.
      -->
    <Attribute name="totalAssetValueTimeline">
      <type>
        <javaclass name="curam.creole.value.Timeline">
          <javaclass name="Number"/>
        </javaclass>
      </type>
      <derivation>
        <!--
         소유한 모든 자산의 총 가치입니다. 각 자산의 가치는
         시간이 경과함에 따라 변할 수 있습니다.
          -->

        <!--
         <timelineoperation>은 이 안에서 수행되는 일련의
         <sum> 계산에서 타임라인을 작성합니다.

         <sum>을 각각 실행하면 특정한 날의 총계가
         계산됩니다. <timelineoperation>은 이러한
         일별 총계를 숫자로 이루어진 타임라인으로 조합합니다.
          -->
        <timelineoperation>

          <sum>
            <!--
             소유한 각 자산에 대한 셀 수 있는 값 타임라인을 가져오십시오.
              -->
            <dynamiclist>
              <list>
                <reference attribute="ownedAssets"/>
              </list>
              <listitemexpression>

                <!--
                 <sum>이 타임라인 목록이 아닌
                 숫자 목록을 조작한다고 여기도록
                 countableValueTimeline이 리턴한 타임라인을
                 랩핑하십시오.
                  -->
                <intervalvalue>
                  <reference attribute="countableValueTimeline">
                    <current/>
                  </reference>
                </intervalvalue>
              </listitemexpression>
            </dynamiclist>

          </sum>

        </timelineoperation>

      </derivation>
    </Attribute>


    <!--
     혜택을 받을 자격이 중단되는 지점입니다. 이 가변 임계값을
     초과하는 자산이 있는 개인은 혜택을 받을 자격이 없습니다.

      -->
    <Attribute name="maximumAssetsThreshold">
      <type>
        <javaclass name="curam.creole.value.Timeline">
          <javaclass name="Number"/>
        </javaclass>
      </type>
      <derivation>
        <!--
         실제 구현 시, 이 값은 시간이 경과함에 따라
         변화합니다(예: 요금표와 달라짐).

         그러나 예를 들기 위해 이 구현에서는 중첩된
         <intervalvalue> 없이 <timelineoperation>을 사용하여
         값이 항상 상수인 타임라인을 작성합니다.

         <timelineoperation>을 사용하면 규칙 세트 개발
         초기의 더미 구현에서 유용한 경우가 많습니다.
        -->

        <timelineoperation>
          <!--
           하드 코딩된 forever-constant 값 - 규칙 개발 중
           나중에 가변 값으로 대체됩니다.
            -->
          <Number value="10000"/>
        </timelineoperation>
      </derivation>
    </Attribute>

    <!--
     (특정한 날에) 개인이 생존해 있으며 개인의
     총 자산 가치가 최대 자산 임계값을 초과하지
     않는 경우 개인은 혜택을 받을 자격이 있습니다.
      -->
    <Attribute name="qualifiesForBenefitTimeline">
      <type>
        <javaclass name="curam.creole.value.Timeline">
          <javaclass name="Boolean"/>
        </javaclass>
      </type>
      <derivation>
        <timelineoperation>
          <all>
            <fixedlist>
              <listof>
                <javaclass name="Boolean"/>
              </listof>
              <members>
                <!--
                 타임라인이 기본값인 경우 타임라인을
                 조작합니다.
                  -->
                <intervalvalue>
                  <reference attribute="isAliveTimeline"/>
                </intervalvalue>

                <compare comparison="&lt;=">
                  <intervalvalue>
                    <reference attribute="totalAssetValueTimeline"/>
                  </intervalvalue>
                  <intervalvalue>
                    <reference attribute="maximumAssetsThreshold"/>
                  </intervalvalue>
                </compare>
              </members>
            </fixedlist>

          </all>
        </timelineoperation>

      </derivation>
    </Attribute>



  </Class>

  <!--
   개인이 어떤 시점에 소유한 자산입니다.

   각 자산은 매입한 후 매도할 수 있습니다.

   자산의 가치는 시간이 경과함에 따라 변화합니다. 자산은
   개인이 소유하기 전이나 후에도 가치가 있습니다. 그러나
   _countable_ 값은 소유권 기간이 지나면
   0입니다.
    -->
  <Class name="Asset">
    <Attribute name="boughtDate">
      <type>
        <javaclass name="curam.util.type.Date"/>
      </type>
      <derivation>
        <specified/>
      </derivation>
    </Attribute>

    <!-- 자산이 매도되지 않은 경우 널입니다. -->
    <Attribute name="soldDate">
      <type>
        <javaclass name="curam.util.type.Date"/>
      </type>
      <derivation>
        <specified/>
      </derivation>
    </Attribute>

    <Attribute name="isOwnedTimeline">
      <type>
        <javaclass name="curam.creole.value.Timeline">
          <javaclass name="Boolean"/>
        </javaclass>
      </type>
      <derivation>
        <existencetimeline>
          <intervaltype>
            <javaclass name="Boolean"/>
          </intervaltype>
          <intervalfromdate>
            <reference attribute="boughtDate"/>
          </intervalfromdate>
          <intervaltodate>
            <reference attribute="soldDate"/>
          </intervaltodate>
          <preExistenceValue>
            <false/>
          </preExistenceValue>
          <existenceValue>
            <true/>
          </existenceValue>
          <postExistenceValue>
            <false/>
          </postExistenceValue>
        </existencetimeline>

      </derivation>
    </Attribute>

    <!--
     당시에 개인이 소유했는지 여부에 무관한
     자산의 가변 가치
      -->
    <Attribute name="valueTimeline">
      <type>
        <javaclass name="curam.creole.value.Timeline">
          <javaclass name="Number"/>
        </javaclass>
      </type>
      <derivation>
        <specified/>
      </derivation>
    </Attribute>


    <!--
     개인의 자산으로 가산되는 가치입니다. 즉,
     소유하는 기간 동안의 자산 가치입니다.
     소유하지 않는 경우 0입니다.
      -->
    <Attribute name="countableValueTimeline">
      <type>
        <javaclass name="curam.creole.value.Timeline">
          <javaclass name="Number"/>
        </javaclass>
      </type>
      <derivation>
        <!--
         각 <choose> 호출의 결과를 타임라인에
         다시 조합
          -->
        <timelineoperation>
          <choose>
            <type>
              <javaclass name="Number"/>
            </type>
            <when>
              <condition>
                <!--
                 상수 소유권의 각 간격을
                 조작
                -->

                <intervalvalue>
                  <reference attribute="isOwnedTimeline"/>
                </intervalvalue>
              </condition>
              <value>
                <!--
                 특정 날짜에 자산이 소유된 경우
                 해당 날짜에 셀 수 있는 값이 해당 가치가
                 됩니다.
                  -->
                <intervalvalue>
                  <reference attribute="valueTimeline"/>
                </intervalvalue>
              </value>
            </when>
            <otherwise>
              <value>
                <!--
                 특정 날짜에 자산이 소유된 경우
                 해당 날짜에 셀 수 있는 값은 0입니다.
                  -->
                <Number value="0"/>
              </value>
            </otherwise>
          </choose>

        </timelineoperation>
      </derivation>
    </Attribute>

  </Class>

</RuleSet>
팁: 내부 표현식이 타임라인을 리턴하고 표현식을 intervalvalue로 둘러싸지 않은 경우 다음 예제에서와 같이 CER 유효성 검증 오류가 표시됩니다.
<!--
     개인의 자산으로 가산되는 가치입니다. 즉,
     소유하는 기간 동안의 자산 가치입니다.
     소유하지 않는 경우 0입니다.
      -->
    <Attribute name="countableValueTimeline">
      <type>
        <javaclass name="curam.creole.value.Timeline">
          <javaclass name="Number"/>
        </javaclass>
      </type>
      <derivation>
        <!--
         각 <choose> 호출의 결과를 타임라인에
         다시 조합
          -->
        <timelineoperation>
          <choose>
            <type>
              <javaclass name="Number"/>
            </type>
            <when>
              <condition>
                <!--
                 상수 소유권의 각 간격을
                 조작
                -->

                <!--
                  **** <intervalvalue>에 리턴된 타임라인을
                  랩핑하는 것을 잊음 ****
                  -->
                  <reference attribute="isOwnedTimeline"/>
              </condition>
              <value>
                <!--
                 특정 날짜에 자산이 소유된 경우
                 해당 날짜에 셀 수 있는 값이 해당 가치가
                 됩니다.
                  -->
                <intervalvalue>
                  <reference attribute="valueTimeline"/>
                </intervalvalue>
              </value>
            </when>
            <otherwise>
              <value>
                <!--
                 특정 날짜에 자산이 소유된 경우
                 해당 날짜에 셀 수 있는 값은 0입니다.
                  -->
                <Number value="0"/>
              </value>
            </otherwise>
          </choose>

        </timelineoperation>
      </derivation>
    </Attribute>
오류	... Example_timelineoperation.xml(276, 19)
  AbstractRuleItem:INVALID_CHILD_RETURN_TYPE: 하위 'condition'이
  'curam.creole.value.Timeline<? extends java.lang.Boolean>'을 리턴했지만
  이 항목에는 'java.lang.Boolean'이 필요합니다.