An often asked requirement in meta modeling applications is the recording of creation and modification dates. ConceptBase stores the creation time of an object in its object base, primary for the use of Rollback queries. With the literal Known(x,t) the time of the creation of x can be made visible in rules or queries. The following frames shows how to use it:
Class Employee with
attribute
salary : Integer;
createdOn : TransactionTime;
lastModified : String
rule
createdOnRule : $ forall t/TransactionTime
Known(this,t) ==> (this createdOn t) $
end
The limitation of this approach is, that it just records the creation date of an object and not the time when it was modified. i.e. the value of an attribute was changed.
To overcome this restriction, one can use an ECArule to update the attribute lastModified of the above example, whenever an attribute of the category salary is inserted.
ECArule LastModified_Employee_salary with
ecarule
er : $ t1,t2/TransactionTime y/Employee i/Integer
es/Employee!salary lab/Proposition
ON Tell(A(y,salary,i))
IF A(y,lastModified,t1)
DO Untell(A(y,lastModified,t1)),
Ask(new(In(es,Employee!salary))),
Ask(new(P(es,y,lab,i))),
Ask(new(Known(es,t2))),
Tell(A(y,lastModified,t2))
ELSE
Ask(new(In(es,Employee!salary))),
Ask(new(P(es,y,lab,i))),
Ask(new(Known(es,t2))),
Tell(A(y,lastModified,t2))
$
end
This ECArule is executed when a new salary is assigned to an employee. The condition checks, if there exists already a value for the lastModified attribute. If this is the case, the attribute is deleted. Except for deletion of this attribute, the 'DO' and the 'ELSE' part of the rule are identical.
First, we have to retrieve the transaction time of the new
object (es), when it was inserted into the knowledge base (t2).
We have to use new in the ask operations, because the
object was not visible before the transaction started.
After that, we can tell the new attribute. Note, that
the transaction time is represented as string of the
form "tt(year,month,day,hour,minute,sec,millisec)".