Bundt Programmer's Guide · Bundt Programmer's Interface version 1.0.1.0

Work with Temporal and Subjective Data

The following example shows how to work with temporal and subjective data in type and instance models.

Temporality and subjectivity are called "soft aspects" in Bundt. By being cross-cutting aspects, we can mark specific features in a type model as being temporal or subjective (or both). Conforming instance models will be able to store different value sets for these features, indexed by a predication qualifier. They will also be able to assign existence qualifiers to objects so that their existence is limited to specific moments and perspectives.

Please see the aspect class and related concepts in the Bundt User's Manual for additional details.

To execute this code, you will need a reference to the ModellingEngine library.

The code in this example is split in two. The first block deals with expressing temporal and subjective aspects in a type model.

using Incipit.Bundt.ModellingEngine;

//create a type model.
var tmo = ModelManager.CreateTypeModel("TypeTest", VersionInfo.OneZeroZeroZero);

//add some classes and attributes with T and S markers.
var clBuilding = tmo.AddNewClass("Building", false);
var attHeight = clBuilding.AddNewAttribute("Height", Cardinality.One, BaseDataType.Number);
attHeight.IsTemporal = true;
var attStatus = clBuilding.AddNewAttribute("Status", Cardinality.ZeroToOne, BaseDataType.Text);
attStatus.IsSubjective = true;

//add aspect classes for T and S.
var clPeriod = tmo.AddNewClass("Period", false);
clPeriod.IsTemporalAspect = true;
var clPerson = tmo.AddNewClass("Person", false);
clPerson.IsSubjectiveAspect = true;

In line 4, we create a type model.

In lines 7-11, we create a Building class having two attributes, Height, of a Number data type, and Status, of type Text. Height is marked as temporal by setting IsTemporal to true. Similarly, Status is marked as subjective by setting IsSubjective to true.

Finally, in lines 15-17 we introduce two new classes, Period and Person, to work as temporal and subjective aspects, respectively. They are marked as such by setting the properties IsTemporalAspect and IsSubjectiveAspect to true.

The second block of code deals with expressing temporal and subjective data in an instance model that conforms to the previous type model.

using Incipit.Bundt.ModellingEngine;

//create conforming instance model.
var imo = ModelManager.CreateInstanceModel(tmo, "InstanceTest", VersionInfo.OneZeroZeroZero);

//add some T and S qualifiers.
var obPresent = imo.AddNewObject(clPeriod, "present");
var obMiddleAges = imo.AddNewObject(clPeriod, "middle_ages");
var obLast1500Years = imo.AddNewObject(clPeriod, "last_1500_years");
var obAlice = imo.AddNewObject(clPerson, "alice");
var obBob = imo.AddNewObject(clPerson, "bob");

//add a building object with a temporal existence qualifier.
var obBuilding = imo.AddNewObject(clBuilding, "my_building");
obBuilding.TemporalExistentialQualifier = obLast1500Years;

//add some height data with T aspect.
var vastHeightPresent = obBuilding.AddNewValueSetWithPhase(attHeight, obPresent);
vastHeightPresent.SetContents(21);
var vastHeightMiddleAges = obBuilding.AddNewValueSetWithPhase(attHeight, obMiddleAges);
vastHeightMiddleAges.SetContents(16);

//add some status data with S aspect.
var vastStatusAlice = obBuilding.AddNewValueSetWithPerspective(attStatus, obAlice);
vastStatusAlice.SetContents("Well preserved");
var vastStatusBob = obBuilding.AddNewValueSetWithPerspective(attStatus, obBob);
vastStatusBob.SetContents("In need of repair");

//retrieve the height value in the Middle Ages and update it.
obBuilding.ValueSets[attHeight, obMiddleAges, null].SingleValue.UpdateTo(22);

In line 4, we create an instance model that conforms to the previous type model.

In lines 7-11, we create some objects of the temporal and subjective aspect classes, Period and Person. These objects can work as temporal and subjective qualifiers, respectively.

In lines 14-15, we create a Building object, and set its TemporalExistentialQualifier to one of the Period instances. This expresses the fact that this building only exists during the associated period.

In lines 18-21, we add two Height value sets to the Building object, one for the present period and one for the Middle Ages. Also, different values are asigned to the building's height for each period: 21 for the present, and 16 for the Middle Ages. This express the fact that the building has increased its height over time.

In lines 24-27, following a similar pattern, we add two Status value sets to the Building object, one for Alice and one for Bob. Different values are asigned to the building's status for each person: Alice's point of view is recorded as "Well preserved", whereas Bob's opinion is that the building is "In need of repair". This express the fact that the building's status is interpreted differently by different people.

Finally, in line 30 we retrieve the building's Height value set for the Middle Ages and update its content to 22.


Contents distributed under a Creative Commons Attribution 4.0 International License · About · Terms of Use · Contact Us · last updated on 08 October 2020