Class ArchiveVersionStabilizer

java.lang.Object
org.odpi.openmetadata.samples.archiveutilities.ArchiveVersionStabilizer

public class ArchiveVersionStabilizer extends Object
Carries the version numbers of unchanged elements over from the previous edition of an archive.
An archive writer stamps every element with the same new version number (see EgeriaBaseArchiveWriter.getVersionNumber()), which tells a repository that the element is newer than the copy it already holds. That is right for an element whose content has changed, but stamping the unchanged ones as well meant that every rebuild changed every element: the archive could not be reproduced, a review of a content change was buried in thousands of version changes, and a repository reloading the archive rewrote every element in it.
This class compares each element and type in the new archive with the one of the same unique identifier in the previous edition. If they are identical apart from version numbers - their own and those of the classifications, entity proxies and attribute types they carry - the previous edition's copy is used, so it keeps its previous versions. New and changed elements keep the new version. An entity is compared together with its classifications, so it keeps its previous version only if none of them has changed.
  • Constructor Details

    • ArchiveVersionStabilizer

      public ArchiveVersionStabilizer()
  • Method Details

    • stabilizeVersions

      public int stabilizeVersions(OpenMetadataArchive newArchive, OpenMetadataArchive previousArchive)
      Give each element and type of the new archive that is unchanged from the previous edition its previous version numbers. An unchanged element is replaced by its copy from the previous edition, so its version - and the versions of the classifications and entity proxies it carries - are exactly as they were.
      Parameters:
      newArchive - archive about to be written - updated in place
      previousArchive - previous edition of the archive, or null if there is none
      Returns:
      number of elements and types whose previous version was kept
    • getHighestVersion

      public long getHighestVersion(OpenMetadataArchive archive)
      Return the highest version number of any element in an archive, or zero if it has none. Once versions are carried over from one edition to the next, the elements of an archive no longer all share one version.
      Parameters:
      archive - archive to examine
      Returns:
      highest version number, or zero