Class IdMapper


  • public class IdMapper
    extends Object
    Responsible for keeping all required id mappings between the old ids and the new ones. Note that it does keep id mappings only for entities that can be referenced. For example, it will keep mappings for Content objects but will not keep references for content properties.
    Since:
    7.20.0
    • Method Detail

      • generateNewId

        public Object generateNewId​(ExportableEntityInfo entityInfo,
                                    Object fakeObject,
                                    Object oldId)
        Generates and returns new id. This method could be changed in the future to support generating ids in batches.
      • getNewId

        public Object getNewId​(Class<?> clazz,
                               Object oldId)
        Returns the new id related to the old id or null if the new id was not generated before.
        Throws:
        BackupRestoreException - if the new id is not found
      • isPersistedOldId

        public boolean isPersistedOldId​(Class<?> clazz,
                                        Object oldId)
        Check if the records with id from XML (oldId) has been persisted.
      • createMapOfNewIds

        public Map<String,​Object> createMapOfNewIds​(ImportedObjectV2 importedObject,
                                                          Collection<HibernateField> references)
        For all references, it find the new id for each old id. Then it returns the map where the key is the property name and the value is the new id.
      • markObjectsAsPersisted

        public void markObjectsAsPersisted​(ExportableEntityInfo entityInfo,
                                           List<Object> newObjectIds)
        Marks all ids as persisted. This method is usually called when the transaction commit.
        Parameters:
        entityInfo - entity info
        newObjectIds - new objects ids
      • getAllNotSatisfiedDependencies

        public Collection<HibernateField> getAllNotSatisfiedDependencies​(ImportedObjectV2 importedObject)
        Returns:
        all fields which referenced records are not persisted yet.