Villemos / hbird-business

The business tier of the Open Ground Segment; Hummingbird
www.hbird.de
Apache License 2.0
2 stars 2 forks source link

Add version to IEntity / IEntityInstance #33

Closed laurikimmel closed 11 years ago

laurikimmel commented 11 years ago

IEntityInstance needs version - the instance ID has to be unique. Current timestamp is semantically not correct for this purpose.

Requirements for the versioning:

  1. Version has to be comparable.
  2. Two IEntityInstances with same ID and version are equal. This enables replacement (edit, override, etc.) of the IEntityInstance in the system.
  3. If two IEntityInstances have same ID then instance with higher version is newer.

Using timestamp works for now, but setting the value to -1, 0, 1, 345 looks very odd. It's expected to look something more like 1372342891583. Also it's easy to assume that all values called "timestamp" can be treated like one.

There are several possible solutions. Two most obvious ones are:

  1. Rename timestamp in EntityInstance to version and add javadoc to describe the assumptions and expectations given in this issue. The instance ID will be in form ID:version. The default version can then be timestamp. Sequential version numbers, generated random values, hashes etc. can be used as well. It's up to user to select the approach.
  2. Add version field to the IEntityInstance. Default value of version can be current timestamp. The version can be set to any other type of value - sequential number, random value, calulated hash etc. The instance ID will be ID:version. This way the version and IEntityInstance (creation) time are separated.
laurikimmel commented 11 years ago

Done!