Constructing Timelines in CER Rules

Typically, timeline data is created outside of rules by clients of CER, and used to populate the value of a CER attribute using the specify mechanism.

However, CER also contains some expressions for creating timelines directly in CER rules:

Timeline and Interval

A Timeline can be created natively in CER rules by first explicitly creating a list of intervals, and then using this list to create a timeline.

In practice, such fixed timelines tend to be useful only as a temporary measure while you flesh out your rule set.

Figure 1. Example of use of Timeline and Interval to create a timeline
<?xml version="1.0" encoding="UTF-8"?>
<RuleSet name="Example_Timeline"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:noNamespaceSchemaLocation=
"http://www.curamsoftware.com/CreoleRulesSchema.xsd">

  <Class name="CreateTimelines">

    <!-- This example uses <initialvalue> to set the value valid
         from the start of time. -->
    <Attribute name="aNumberTimeline">
      <type>
        <javaclass name="curam.creole.value.Timeline">
          <javaclass name="Number"/>
        </javaclass>
      </type>
      <derivation>
        <Timeline>
          <intervaltype>
            <javaclass name="Number"/>
          </intervaltype>
          <!-- Value from start of time -->
          <initialvalue>
            <Number value="0"/>
          </initialvalue>
          <!-- The remaining intervals -->
          <intervals>
            <fixedlist>
              <listof>
                <javaclass name="curam.creole.value.Interval">
                  <javaclass name="Number"/>
                </javaclass>
              </listof>
              <members>
                <Interval>
                  <intervaltype>
                    <javaclass name="Number"/>
                  </intervaltype>
                  <start>
                    <Date value="2001-01-01"/>
                  </start>
                  <value>
                    <Number value="10000"/>
                  </value>
                </Interval>
                <Interval>
                  <intervaltype>
                    <javaclass name="Number"/>
                  </intervaltype>
                  <start>
                    <Date value="2004-12-01"/>
                  </start>
                  <value>
                    <Number value="12000"/>
                  </value>
                </Interval>

              </members>
            </fixedlist>

          </intervals>
        </Timeline>

      </derivation>
    </Attribute>


    <!-- This example does not use <initialvalue>. -->
    <Attribute name="aStringTimeline">
      <type>
        <javaclass name="curam.creole.value.Timeline">
          <javaclass name="String"/>
        </javaclass>
      </type>
      <derivation>
        <Timeline>
          <intervaltype>
            <javaclass name="String"/>
          </intervaltype>

          <!-- The list of intervals must include one valid from the
             null date (start of time), otherwise an error will
             occur at runtime, if this expression is evaluated. -->
          <intervals>
            <fixedlist>
              <listof>
                <javaclass name="curam.creole.value.Interval">
                  <javaclass name="String"/>
                </javaclass>
              </listof>
              <members>
                <Interval>
                  <intervaltype>
                    <javaclass name="String"/>
                  </intervaltype>
                  <start>
                    <!-- "from the start of time" -->
                    <null/>
                  </start>
                  <value>
                    <String value="Start of time string"/>
                  </value>
                </Interval>
                <Interval>
                  <intervaltype>
                    <javaclass name="String"/>
                  </intervaltype>
                  <start>
                    <Date value="2001-01-01"/>
                  </start>
                  <value>
                    <String value="2001-only String"/>
                  </value>
                </Interval>
                <Interval>
                  <intervaltype>
                    <javaclass name="String"/>
                  </intervaltype>
                  <start>
                    <Date value="2002-01-01"/>
                  </start>
                  <value>
                    <String value="2002-onwards String"/>
                  </value>
                </Interval>
              </members>
            </fixedlist>
          </intervals>
        </Timeline>
      </derivation>
    </Attribute>
  </Class>
</RuleSet>

existencetimeline

Some business objects have natural start and end dates, which together specify a period for which the business object exists. Either or both of the start and end dates may be optional, in which case the existence period for the business object is open-ended.

Examples may include:

The start and end dates for a business object can be used to divide up time into these three periods (or fewer, if either of the start date or end date is blank):

It can often be convenient to ascribe a different value to each of these periods for a business object, and to create a timeline from these values. CER contains an existencetimeline expression to create a timeline of pre-existence/existence/post-existence values based on optional start and end dates.

If the start date does not exist, then there will be no pre-existence interval in the timeline. For example, if an asset does not have a purchase date recorded, then its effective value will apply from the start of time, with no "zero value" period.

If the end date does not exist, then there will be no post-existence interval in the timeline. For example, if an asset does not have a sold date, then the asset's value will hold until further notice (i.e. arbitrarily far into the future)

See Existence Timeline for details on how to use existence timeline in the CER Editor.