wiki:Backtracking

Backtracking

The issue of Backtracking considers the need of save every version of a modified entity and makes possible the reverse of an action. Hereby will be described a perspective to solve this problematic.

EntityBuilder?

The EntityBuilder? has the task of building an entity. There are two types of Entities:

  • Original Entity: the current and valid version of an entity. It could be recognized by the attribute systemStatus, which has the value “original”.
  • Copy Entity: always when an entity is modified, the previous version will be saved with the systemStatus: “copy” and the new version is saved with the corresponding time stamp.

The connection from entity to attribute and from entity to relation is done respectively by the table entity_attribute and entity_relation using only the identification(id) of each object.

In the current version of ismi is needing the following join to build an entity:

select * from entity, attribute,  entity_attribute where entity.id = X && attribute.id= Y &&  entity_attribute.entityId = X && entity_attribute.attributeId= Y

Where X, Y are Numbers.

The Builder class requires a modification to difference between the current entity and its previous versions.

The following query will be used to build the current entity:

select * from entity, attribute,  entity_attribute where entity.id = X && attribute.id= Y &&  entity_attribute.entityId = X && entity_attribute.attributeId= Y && entity.systemStatus = “original” && attribute.systemStatus = original“

Where X and Y are numbers.

The attribute systemStatus is not useful to build the a version of an entity, because every entity's versions will have the same value. The attribute unique for each version is the modifier, therefore the query will look like this:

select * from entity, attribute,  entity_attribute where entity.id = X && attribute.id= Y &&  entity_attribute.entityId = X && entity_attribute.attributeId= Y && entity. modifier = Z && attribute. modifier = Z

Where X and Y are numbers and Z is a time stamp.

Analysis of Behavior

Let be an Entity, which has an Attribute like this:

Entity[id:1, systemStatus:original, modifier:x] Attribute[id:2, systemStatus:original, modifier:x]

-Modification of an Entity

A modification on an Entity will create a copy of the edited entity and its corresponding attributes (and relations). The new copy will have the value “original” in systemStatus and the current time in modifier. In the old version will be change only the attribute systemStatus from “original to copy”.

Entity[id:1, systemStatus:copy, modifier:x] Attribute[id:2, systemStatus:copy, modifier:x]

Entity[id:1, systemStatus:original, modifier:currentTime] Attribute[id:2, systemStatus:original, modifier:currentTime]

Both the table entity_attribute and the table_relation should not be changed.

-Elimination of an Attribute

An elimination of an attribute will mean the following changes:

Entity[id:1, systemStatus:copy, modifier:x] Attribute[id:2, systemStatus:copy, modifier:x]

Entity[id:1, systemStatus:original, modifier:currentTime]

For this case both the table entity_attribute and the table_relation should not be changed, because the reference between the attribute and the entity is used by the previous versions.

-Insertion of an Attribute

An insertion of an attribute will mean the following changes:

Entity[id:1, systemStatus:copy, modifier:x]

Entity[id:1, systemStatus:original, modifier:currentTime] Attribute[id:2, systemStatus:original, modifier:currentTime]

For this case is needing the insertion of a row in the table entity_attribute, which represents the relation between the entity and the new attribute. If the mentioned row exists already, do nothing.

Last modified 15 years ago Last modified on Oct 16, 2009, 3:25:02 PM