From d05e1123bc9ba2bb54d8bc938d7ff027249d1d6b Mon Sep 17 00:00:00 2001 From: Alex Plate Date: Fri, 29 May 2020 21:24:02 +0300 Subject: [PATCH] [Workspace Model] Soft links fix in replaceBySource GitOrigin-RevId: 5313b11c8cf4f75a39e3d9f474230feb85203336 --- platform/workspaceModel-core/src/pstorage/PEntityStorage.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/platform/workspaceModel-core/src/pstorage/PEntityStorage.kt b/platform/workspaceModel-core/src/pstorage/PEntityStorage.kt index eaf40b023754..911da20355b8 100644 --- a/platform/workspaceModel-core/src/pstorage/PEntityStorage.kt +++ b/platform/workspaceModel-core/src/pstorage/PEntityStorage.kt @@ -278,6 +278,9 @@ internal class PEntityStorageBuilder( val pid = clonedEntity.createPid() val parents = this.refs.getParentRefsOfChild(pid) val children = this.refs.getChildrenRefsOfParentBy(pid) + + // At this point you might ask me: What about updating softLinks index? + // Well, this is not necessary because we won't recognize entity if it'll change it's PersistentId indexes.updateIndices(oldPid, pid, replaceWith) updateChangeLog { it.add(ChangeEntry.ReplaceEntity(clonedEntity, children, parents)) } } @@ -291,6 +294,7 @@ internal class PEntityStorageBuilder( val newPid = newEntity.createPid() replaceMap[newPid] = oldPid indexes.updateIndices(oldPid, newPid, replaceWith) + if (newEntity is PSoftLinkable) indexes.updateSoftLinksIndex(newEntity) createAddEvent(newEntity) } } @@ -304,6 +308,7 @@ internal class PEntityStorageBuilder( this.entitiesByType.remove(localEntity.id, entityClass) val entityId = localEntity.createPid() indexes.removeFromIndices(entityId) + if (localEntity is PSoftLinkable) indexes.removeFromSoftLinksIndex(localEntity) updateChangeLog { it.add(ChangeEntry.RemoveEntity(entityId)) } }