From 658ea94ae6346c5c49be771ca5ff0713ed221414 Mon Sep 17 00:00:00 2001 From: Nidhi Date: Wed, 13 Mar 2024 10:34:44 +0530 Subject: [PATCH] chore: Split changes for overridden package import (#31712) --- ...tionCollectionImportableServiceCEImpl.java | 39 ++++++++---------- .../ArtifactBasedImportableServiceCE.java | 12 ++++++ .../NewActionImportableServiceCEImpl.java | 41 ++++++++----------- 3 files changed, 45 insertions(+), 47 deletions(-) diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/importable/ActionCollectionImportableServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/importable/ActionCollectionImportableServiceCEImpl.java index 63bd3710d0..9f18888299 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/importable/ActionCollectionImportableServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/importable/ActionCollectionImportableServiceCEImpl.java @@ -75,7 +75,7 @@ public class ActionCollectionImportableServiceCEImpl implements ImportableServic ImportingMetaDTO importingMetaDTO, MappedImportableResourcesDTO mappedImportableResourcesDTO) { - ArtifactBasedImportableService artifactBasedExportableService = + ArtifactBasedImportableService artifactBasedImportableService = getArtifactBasedImportableService(importingMetaDTO); Mono> importedActionCollectionMono = Mono.just(importedActionCollectionList); @@ -83,14 +83,14 @@ public class ActionCollectionImportableServiceCEImpl implements ImportableServic if (importingMetaDTO.getAppendToArtifact()) { importedActionCollectionMono = importedActionCollectionMono.map(importedActionCollections -> { List importedContextNames = - artifactBasedExportableService.getImportedContextNames(mappedImportableResourcesDTO); + artifactBasedImportableService.getImportedContextNames(mappedImportableResourcesDTO); Map newToOldNameMap = mappedImportableResourcesDTO.getContextNewNameToOldName(); for (String newContextName : importedContextNames) { String oldContextName = newToOldNameMap.get(newContextName); if (!newContextName.equals(oldContextName)) { - artifactBasedExportableService.renameContextInImportableResources( + artifactBasedImportableService.renameContextInImportableResources( importedActionCollections, oldContextName, newContextName); } } @@ -125,7 +125,7 @@ public class ActionCollectionImportableServiceCEImpl implements ImportableServic ImportingMetaDTO importingMetaDTO, MappedImportableResourcesDTO mappedImportableResourcesDTO) { - ArtifactBasedImportableService artifactBasedExportableService = + ArtifactBasedImportableService artifactBasedImportableService = getArtifactBasedImportableService(importingMetaDTO); /* Mono.just(importableArtifact) is created to avoid the eagerly fetching of existing actionCollections @@ -138,7 +138,7 @@ public class ActionCollectionImportableServiceCEImpl implements ImportableServic // Map of gitSyncId to actionCollection of the existing records in DB Mono> actionCollectionsInCurrentArtifactMono = - artifactBasedExportableService + artifactBasedImportableService .getExistingResourcesInCurrentArtifactFlux(artifact) .filter(collection -> collection.getGitSyncId() != null) .collectMap(ActionCollection::getGitSyncId); @@ -147,7 +147,7 @@ public class ActionCollectionImportableServiceCEImpl implements ImportableServic if (artifact.getGitArtifactMetadata() != null) { final String defaultArtifactId = artifact.getGitArtifactMetadata().getDefaultArtifactId(); - actionCollectionsInBranchesMono = artifactBasedExportableService + actionCollectionsInBranchesMono = artifactBasedImportableService .getExistingResourcesInOtherBranchesFlux(defaultArtifactId, artifact.getId()) .filter(actionCollection -> actionCollection.getGitSyncId() != null) .collectMap(ActionCollection::getGitSyncId); @@ -190,10 +190,11 @@ public class ActionCollectionImportableServiceCEImpl implements ImportableServic if (actionsCollectionsInBranches.containsKey(actionCollection.getGitSyncId())) { branchedActionCollection = - getExistingCollectionInOtherBranchesForImportedCollection( - mappedImportableResourcesDTO, - actionsCollectionsInBranches, - actionCollection); + artifactBasedImportableService + .getExistingEntityInOtherBranchForImportedEntity( + mappedImportableResourcesDTO, + actionsCollectionsInBranches, + actionCollection); } Context defaultContext = populateIdReferencesAndReturnDefaultContext( @@ -209,10 +210,11 @@ public class ActionCollectionImportableServiceCEImpl implements ImportableServic // Since the resource is already present in DB, just update resource ActionCollection existingActionCollection = - getExistingCollectionInCurrentBranchForImportedCollection( - mappedImportableResourcesDTO, - actionsCollectionsInCurrentArtifact, - actionCollection); + artifactBasedImportableService + .getExistingEntityInCurrentBranchForImportedEntity( + mappedImportableResourcesDTO, + actionsCollectionsInCurrentArtifact, + actionCollection); updateExistingCollection( importingMetaDTO, @@ -226,7 +228,7 @@ public class ActionCollectionImportableServiceCEImpl implements ImportableServic .getSavedActionCollectionMap() .put(idFromJsonFile, existingActionCollection); } else { - artifactBasedExportableService.createNewResource( + artifactBasedImportableService.createNewResource( importingMetaDTO, actionCollection, defaultContext); populateDomainMappedReferences(mappedImportableResourcesDTO, actionCollection); @@ -374,13 +376,6 @@ public class ActionCollectionImportableServiceCEImpl implements ImportableServic return actionsCollectionsInCurrentArtifact.get(actionCollection.getGitSyncId()); } - protected ActionCollection getExistingCollectionInOtherBranchesForImportedCollection( - MappedImportableResourcesDTO mappedImportableResourcesDTO, - Map actionsCollectionsInOtherArtifact, - ActionCollection actionCollection) { - return actionsCollectionsInOtherArtifact.get(actionCollection.getGitSyncId()); - } - protected boolean existingArtifactContainsCollection( Map actionsCollectionsInCurrentArtifact, ActionCollection actionCollection) { return actionCollection.getGitSyncId() != null diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/importable/artifactbased/ArtifactBasedImportableServiceCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/importable/artifactbased/ArtifactBasedImportableServiceCE.java index e0aeee6b44..ff8f44ab5b 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/importable/artifactbased/ArtifactBasedImportableServiceCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/importable/artifactbased/ArtifactBasedImportableServiceCE.java @@ -30,4 +30,16 @@ public interface ArtifactBasedImportableServiceCE entityInCurrentArtifact, + T entity) { + return entityInCurrentArtifact.get(entity.getGitSyncId()); + } + + default T getExistingEntityInOtherBranchForImportedEntity( + MappedImportableResourcesDTO mappedImportableResourcesDTO, Map entityInOtherArtifact, T entity) { + return entityInOtherArtifact.get(entity.getGitSyncId()); + } } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/importable/NewActionImportableServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/importable/NewActionImportableServiceCEImpl.java index 471416ba37..90eddc072d 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/importable/NewActionImportableServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/importable/NewActionImportableServiceCEImpl.java @@ -202,7 +202,7 @@ public class NewActionImportableServiceCEImpl implements ImportableServiceCE artifactBasedExportableService = + ArtifactBasedImportableService artifactBasedImportableService = getArtifactBasedImportableService(importingMetaDTO); Mono> importedNewActionMono = Mono.justOrEmpty(importedNewActions); @@ -210,14 +210,14 @@ public class NewActionImportableServiceCEImpl implements ImportableServiceCE { List importedContextNames = - artifactBasedExportableService.getImportedContextNames(mappedImportableResourcesDTO); + artifactBasedImportableService.getImportedContextNames(mappedImportableResourcesDTO); Map newToOldNameMap = mappedImportableResourcesDTO.getContextNewNameToOldName(); for (String newContextName : importedContextNames) { String oldContextName = newToOldNameMap.get(newContextName); if (!newContextName.equals(oldContextName)) { - artifactBasedExportableService.renameContextInImportableResources( + artifactBasedImportableService.renameContextInImportableResources( importedNewActionList, oldContextName, newContextName); } } @@ -248,7 +248,7 @@ public class NewActionImportableServiceCEImpl implements ImportableServiceCE artifactBasedExportableService = + ArtifactBasedImportableService artifactBasedImportableService = getArtifactBasedImportableService(importingMetaDTO); /* Mono.just(importableArtifact) is created to avoid the eagerly fetching of existing actions @@ -258,7 +258,7 @@ public class NewActionImportableServiceCEImpl implements ImportableServiceCE> actionsInCurrentArtifactMono = artifactBasedExportableService + Mono> actionsInCurrentArtifactMono = artifactBasedImportableService .getExistingResourcesInCurrentArtifactFlux(artifact) .filter(collection -> collection.getGitSyncId() != null) .collectMap(NewAction::getGitSyncId); @@ -268,7 +268,7 @@ public class NewActionImportableServiceCEImpl implements ImportableServiceCE newAction.getGitSyncId() != null) .collectMap(NewAction::getGitSyncId); @@ -305,8 +305,9 @@ public class NewActionImportableServiceCEImpl implements ImportableServiceCE actionsInCurrentArtifact, - NewAction newAction) { - return actionsInCurrentArtifact.get(newAction.getGitSyncId()); - } - - protected NewAction getExistingActionInOtherBranchForImportedAction( - MappedImportableResourcesDTO mappedImportableResourcesDTO, - Map actionsInOtherArtifact, - NewAction newAction) { - return actionsInOtherArtifact.get(newAction.getGitSyncId()); - } - protected boolean existingArtifactContainsAction( Map actionsInCurrentArtifact, NewAction newAction) { return newAction.getGitSyncId() != null && actionsInCurrentArtifact.containsKey(newAction.getGitSyncId());