From 3692b4fa3ef9ab9c8bc6e93fa1d9494e8380b376 Mon Sep 17 00:00:00 2001 From: Trisha Anand Date: Mon, 13 Apr 2020 08:49:30 +0000 Subject: [PATCH] Stupid coding error of using OR instead of AND. Also Mono.zipping the update Action and update Layout instead of this.then because in some optimization done by Spring, one mono doesnt end up emitting. --- .../appsmith/server/services/ActionService.java | 1 + .../server/services/ActionServiceImpl.java | 5 +++++ .../server/services/LayoutActionServiceImpl.java | 15 +++++++++------ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ActionService.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ActionService.java index e690034b54..a447009db6 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ActionService.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ActionService.java @@ -23,4 +23,5 @@ public interface ActionService extends CrudService { Object variableSubstitution(Object configuration, Map replaceParamsMap); + Flux findByPageId(String pageId); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ActionServiceImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ActionServiceImpl.java index cf3c0c1d12..c666b36943 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ActionServiceImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ActionServiceImpl.java @@ -464,6 +464,11 @@ public class ActionServiceImpl extends BaseService findByPageId(String pageId) { + return repository.findByPageId(pageId); + } + /** * @param template : This is the string which contains {{key}} which would be replaced with value * @param name : This is the class name of the object from which template string was created diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/LayoutActionServiceImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/LayoutActionServiceImpl.java index 9960748427..6b33e18acb 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/LayoutActionServiceImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/LayoutActionServiceImpl.java @@ -317,7 +317,6 @@ public class LayoutActionServiceImpl implements LayoutActionService { if (pageId != null) { params.add(FieldName.PAGE_ID, pageId); } - Flux actionsInPageFlux = actionService.get(params); Mono updatePageMono = pageService .findById(pageId) @@ -349,7 +348,8 @@ public class LayoutActionServiceImpl implements LayoutActionService { return Mono.just(page); }); - Mono> updateActionsMono = actionsInPageFlux + Mono> updateActionsMono = actionService + .findByPageId(pageId) /* * Assuming that the datasource should not be dependent on the widget and hence not going through the same * to look for replacement pattern. @@ -359,7 +359,7 @@ public class LayoutActionServiceImpl implements LayoutActionService { ActionConfiguration actionConfiguration = action.getActionConfiguration(); Set jsonPathKeys = action.getJsonPathKeys(); - if (jsonPathKeys != null || !jsonPathKeys.isEmpty()) { + if (jsonPathKeys != null && !jsonPathKeys.isEmpty()) { // Since json path keys actually contain the entire inline js function instead of just the widget/action // name, we can not simply use the set.contains(obj) function. We need to iterate over all the keys // in the set and see if the old name is a substring of the json path key. @@ -387,11 +387,14 @@ public class LayoutActionServiceImpl implements LayoutActionService { return Mono.just(action); } }) + .map(savedAction -> savedAction.getName()) .collect(toSet()); - return updateActionsMono - .then(updatePageMono) - .flatMap(page -> { + return Mono.zip(updateActionsMono, updatePageMono) + .flatMap(tuple -> { + Set updatedActionNames = tuple.getT1(); + Page page = tuple.getT2(); + log.debug("Actions updated due to refactor name in page {} are : {}", pageId, updatedActionNames); List layouts = page.getLayouts(); for (Layout layout : layouts) { if (layout.getId().equals(layoutId)) {