Class DbOperationManager


  • public class DbOperationManager
    extends java.lang.Object
    Manages a set of database operations.
    Author:
    Daniel Meyer
    • Field Detail

      • INSERT_TYPE_COMPARATOR

        public static java.util.Comparator<java.lang.Class<?>> INSERT_TYPE_COMPARATOR
      • MODIFICATION_TYPE_COMPARATOR

        public static java.util.Comparator<java.lang.Class<?>> MODIFICATION_TYPE_COMPARATOR
      • INSERT_OPERATION_COMPARATOR

        public static java.util.Comparator<DbEntityOperation> INSERT_OPERATION_COMPARATOR
      • MODIFICATION_OPERATION_COMPARATOR

        public static java.util.Comparator<DbEntityOperation> MODIFICATION_OPERATION_COMPARATOR
      • BULK_OPERATION_COMPARATOR

        public static java.util.Comparator<DbBulkOperation> BULK_OPERATION_COMPARATOR
      • inserts

        public java.util.SortedMap<java.lang.Class<?>,​java.util.SortedSet<DbEntityOperation>> inserts
        INSERTs
      • updates

        public java.util.SortedMap<java.lang.Class<?>,​java.util.SortedSet<DbEntityOperation>> updates
        UPDATEs of a single entity
      • deletes

        public java.util.SortedMap<java.lang.Class<?>,​java.util.SortedSet<DbEntityOperation>> deletes
        DELETEs of a single entity
      • bulkOperations

        public java.util.SortedMap<java.lang.Class<?>,​java.util.SortedSet<DbBulkOperation>> bulkOperations
        bulk modifications (DELETE, UPDATE) on an entity collection
      • bulkOperationsInsertionOrder

        public java.util.LinkedHashSet<DbBulkOperation> bulkOperationsInsertionOrder
        bulk modifications (DELETE, UPDATE) for which order of execution is important
    • Constructor Detail

      • DbOperationManager

        public DbOperationManager()
    • Method Detail

      • getDeletesByType

        protected java.util.SortedSet<DbEntityOperation> getDeletesByType​(java.lang.Class<? extends DbEntity> type,
                                                                          boolean create)
      • getUpdatesByType

        protected java.util.SortedSet<DbEntityOperation> getUpdatesByType​(java.lang.Class<? extends DbEntity> type,
                                                                          boolean create)
      • getInsertsForType

        protected java.util.SortedSet<DbEntityOperation> getInsertsForType​(java.lang.Class<? extends DbEntity> type,
                                                                           boolean create)
      • addOperation

        public boolean addOperation​(DbBulkOperation newOperation)
      • addOperationPreserveOrder

        public boolean addOperationPreserveOrder​(DbBulkOperation newOperation)
      • calculateFlush

        public java.util.List<DbOperation> calculateFlush()
      • addSortedInserts

        protected void addSortedInserts​(java.util.List<DbOperation> flush)
        Adds the insert operations to the flush (in correct order).
        Parameters:
        operationsForFlush -
      • addSortedModifications

        protected void addSortedModifications​(java.util.List<DbOperation> flush)
        Adds a correctly ordered list of UPDATE and DELETE operations to the flush.
        Parameters:
        flush -
      • addSortedModificationsForType

        protected void addSortedModificationsForType​(java.lang.Class<?> type,
                                                     java.util.SortedSet<DbEntityOperation> preSortedOperations,
                                                     java.util.List<DbOperation> flush)
      • sortByReferences

        protected java.util.List<DbEntityOperation> sortByReferences​(java.util.SortedSet<DbEntityOperation> preSorted)
        Assumptions: a) all operations in the set work on entities such that the entities implement HasDbReferences. b) all operations in the set work on the same type (ie. all operations are INSERTs or DELETEs).
      • determineDependencies

        protected void determineDependencies​(java.util.List<DbOperation> flush)