Class VersionHistoryService

  • All Implemented Interfaces:
    IVersionHistoryService

    public class VersionHistoryService
    extends java.lang.Object
    implements IVersionHistoryService
    Encapsulation of the transaction needed to read the version history table
    • Constructor Detail

      • VersionHistoryService

        public VersionHistoryService​(java.lang.String adminSchemaName,
                                     java.lang.String... schemaNames)
    • Method Detail

      • init

        public void init()
        Fetch the version history map for the given schema. This then becomes the reference for everything we try to apply going forward. This assumes, of course. If someone else comes along and tries to update the schema after we read this map, then it's possible (likely) that we'll try to apply a change that is no longer required, which is probably going to end in tears. But it's OK. A second attempt will see that the change has already been applied, so won't try again.
      • insertVersionHistoriesInTx

        public void insertVersionHistoriesInTx​(java.util.Collection<VersionHistoryService.TypeNameVersion> versionHistories)
        Insert all the entries in the versionHistoryMap. This must be called in the context of an existing transaction
        Parameters:
        versionHistories -
      • insertVersionHistoryInTx

        public void insertVersionHistoryInTx​(java.lang.String objectSchema,
                                             java.lang.String objectType,
                                             java.lang.String objectName,
                                             int version)
        Insert the version history for the objectType/objectName/version.
        Parameters:
        objectSchema -
        objectType -
        objectName -
        version -
      • clearVersionHistory

        public void clearVersionHistory​(java.lang.String objectSchema)
        Remove the version history information for all objects in the given schema
        Parameters:
        objectSchema -
      • insertVersionHistory

        public void insertVersionHistory​(java.util.Collection<VersionHistoryService.TypeNameVersion> versionHistories)
        Insert all the entries in the versionHistoryMap in a new transaction (useful for testing).
        Parameters:
        versionHistories -
      • getVersion

        public java.lang.Integer getVersion​(java.lang.String objectSchema,
                                            java.lang.String objectType,
                                            java.lang.String objectName)
        Description copied from interface: IVersionHistoryService
        Get the current version of an object
        Specified by:
        getVersion in interface IVersionHistoryService
        Returns:
        the current version of the given object or null if it doesn't exist
      • addVersion

        public void addVersion​(java.lang.String objectSchema,
                               java.lang.String objectType,
                               java.lang.String objectName,
                               int version)
        Description copied from interface: IVersionHistoryService
        Add this version (idempotent)
        Specified by:
        addVersion in interface IVersionHistoryService
      • applies

        public boolean applies​(java.lang.String objectSchema,
                               java.lang.String objectType,
                               java.lang.String objectName,
                               int changeVersion)
        Description copied from interface: IVersionHistoryService
        Check to see if we described object is newer than we have currently in the database
        Specified by:
        applies in interface IVersionHistoryService
        Returns: