From 447a15c8a6d189b978e84885fe1905a55453670b Mon Sep 17 00:00:00 2001 From: jainshrk Date: Tue, 5 Nov 2024 13:17:27 +0530 Subject: [PATCH 01/10] tests for the changes --- .../inmem/service/LogicalFlowServiceTest.java | 25 +++++++++++++++++++ .../logical_flow/LogicalFlowService.java | 13 +++++----- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/waltz-integration-test/src/test/java/org/finos/waltz/integration_test/inmem/service/LogicalFlowServiceTest.java b/waltz-integration-test/src/test/java/org/finos/waltz/integration_test/inmem/service/LogicalFlowServiceTest.java index acadcd9ee8..6facfd86c1 100644 --- a/waltz-integration-test/src/test/java/org/finos/waltz/integration_test/inmem/service/LogicalFlowServiceTest.java +++ b/waltz-integration-test/src/test/java/org/finos/waltz/integration_test/inmem/service/LogicalFlowServiceTest.java @@ -430,4 +430,29 @@ public void findUpstreamFlowsForEntityReferences() { assertEquals(3, allUpstreams.size(), "Returns all upstreams but not downstreams"); } + @Test + public void updateReadOnlyTest() { + helper.clearAllFlows(); + + EntityReference a = appHelper.createNewApp("xyz-app", ouIds.a); + EntityReference b = appHelper.createNewApp("xyz-app-2", ouIds.a); + + LogicalFlow logicalFlow = helper.createLogicalFlow(a, b); + + LogicalFlow updatedFlow = lfSvc.updateReadOnly(logicalFlow.id().get(), true, "updateTestUser"); + assertTrue(updatedFlow.isReadOnly()); + + updatedFlow = lfSvc.updateReadOnly(logicalFlow.id().get(), false, "updateTestUser"); + assertFalse(updatedFlow.isReadOnly()); + + updatedFlow = lfSvc.updateReadOnly(122, true, "updateTestUser"); + assertNull(updatedFlow); + + try{ + updatedFlow = lfSvc.updateReadOnly(logicalFlow.id().get(), false, "updateTestUser"); + } catch (Exception e) { + assertNotNull(e); + } + } + } \ No newline at end of file diff --git a/waltz-service/src/main/java/org/finos/waltz/service/logical_flow/LogicalFlowService.java b/waltz-service/src/main/java/org/finos/waltz/service/logical_flow/LogicalFlowService.java index 0750c76a1f..e292b9efc7 100644 --- a/waltz-service/src/main/java/org/finos/waltz/service/logical_flow/LogicalFlowService.java +++ b/waltz-service/src/main/java/org/finos/waltz/service/logical_flow/LogicalFlowService.java @@ -31,13 +31,7 @@ import org.finos.waltz.data.physical_flow.PhysicalFlowIdSelectorFactory; import org.finos.waltz.data.physical_specification.PhysicalSpecificationDao; import org.finos.waltz.data.physical_specification.PhysicalSpecificationIdSelectorFactory; -import org.finos.waltz.model.EntityReference; -import org.finos.waltz.model.HierarchyQueryScope; -import org.finos.waltz.model.IdProvider; -import org.finos.waltz.model.IdSelectionOptions; -import org.finos.waltz.model.Operation; -import org.finos.waltz.model.Severity; -import org.finos.waltz.model.UserTimestamp; +import org.finos.waltz.model.*; import org.finos.waltz.model.assessment_definition.AssessmentDefinition; import org.finos.waltz.model.assessment_rating.AssessmentRating; import org.finos.waltz.model.changelog.ChangeLog; @@ -316,6 +310,11 @@ private void rejectIfSelfLoop(AddLogicalFlowCommand addCmd) { } } + public LogicalFlow updateReadOnly(long flowId, boolean isReadOnly, String user) { + + return null; + } + /** * Removes the given logical flow and creates an audit log entry. From 48dc575716fcb65f40b4af0f174d12818352b6b8 Mon Sep 17 00:00:00 2001 From: jainshrk Date: Tue, 5 Nov 2024 13:20:55 +0530 Subject: [PATCH 02/10] refactor imports --- .../waltz/service/logical_flow/LogicalFlowService.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/waltz-service/src/main/java/org/finos/waltz/service/logical_flow/LogicalFlowService.java b/waltz-service/src/main/java/org/finos/waltz/service/logical_flow/LogicalFlowService.java index e292b9efc7..8688f9236b 100644 --- a/waltz-service/src/main/java/org/finos/waltz/service/logical_flow/LogicalFlowService.java +++ b/waltz-service/src/main/java/org/finos/waltz/service/logical_flow/LogicalFlowService.java @@ -31,7 +31,13 @@ import org.finos.waltz.data.physical_flow.PhysicalFlowIdSelectorFactory; import org.finos.waltz.data.physical_specification.PhysicalSpecificationDao; import org.finos.waltz.data.physical_specification.PhysicalSpecificationIdSelectorFactory; -import org.finos.waltz.model.*; +import org.finos.waltz.model.EntityReference; +import org.finos.waltz.model.HierarchyQueryScope; +import org.finos.waltz.model.IdProvider; +import org.finos.waltz.model.IdSelectionOptions; +import org.finos.waltz.model.Operation; +import org.finos.waltz.model.Severity; +import org.finos.waltz.model.UserTimestamp; import org.finos.waltz.model.assessment_definition.AssessmentDefinition; import org.finos.waltz.model.assessment_rating.AssessmentRating; import org.finos.waltz.model.changelog.ChangeLog; From 7a70bb8a5160aa2398c9ef47c8f23ca5ba34fd1f Mon Sep 17 00:00:00 2001 From: jainshrk Date: Wed, 6 Nov 2024 10:49:05 +0530 Subject: [PATCH 03/10] create service component --- .../data/logical_flow/LogicalFlowDao.java | 10 ++++ .../logical_flow/UpdateReadOnlyCommand.java | 12 +++++ .../logical_flow/LogicalFlowService.java | 54 ++++++++++++++----- .../endpoints/api/LogicalFlowEndpoint.java | 23 ++++++-- 4 files changed, 81 insertions(+), 18 deletions(-) create mode 100644 waltz-model/src/main/java/org/finos/waltz/model/logical_flow/UpdateReadOnlyCommand.java diff --git a/waltz-data/src/main/java/org/finos/waltz/data/logical_flow/LogicalFlowDao.java b/waltz-data/src/main/java/org/finos/waltz/data/logical_flow/LogicalFlowDao.java index 530b296d58..20904d94a7 100644 --- a/waltz-data/src/main/java/org/finos/waltz/data/logical_flow/LogicalFlowDao.java +++ b/waltz-data/src/main/java/org/finos/waltz/data/logical_flow/LogicalFlowDao.java @@ -346,6 +346,16 @@ public LogicalFlow getByFlowId(long dataFlowId) { .fetchOne(TO_DOMAIN_MAPPER); } + public long updateReadOnly(long flowId, boolean isReadOnly, String user) { + return dsl + .update(LOGICAL_FLOW) + .set(LOGICAL_FLOW.IS_READONLY, isReadOnly) + .set(LOGICAL_FLOW.LAST_UPDATED_AT, Timestamp.valueOf(nowUtc())) + .set(LOGICAL_FLOW.LAST_UPDATED_BY, user) + .where(LOGICAL_FLOW.ID.eq(flowId)) + .execute(); + } + public List findAllActive() { return baseQuery() diff --git a/waltz-model/src/main/java/org/finos/waltz/model/logical_flow/UpdateReadOnlyCommand.java b/waltz-model/src/main/java/org/finos/waltz/model/logical_flow/UpdateReadOnlyCommand.java new file mode 100644 index 0000000000..429fdca3ca --- /dev/null +++ b/waltz-model/src/main/java/org/finos/waltz/model/logical_flow/UpdateReadOnlyCommand.java @@ -0,0 +1,12 @@ +package org.finos.waltz.model.logical_flow; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.immutables.value.Value; + +@Value.Immutable +@JsonSerialize(as = ImmutableUpdateReadOnlyCommand.class) +@JsonDeserialize(as = ImmutableUpdateReadOnlyCommand.class) +public interface UpdateReadOnlyCommand { + boolean readOnly(); +} diff --git a/waltz-service/src/main/java/org/finos/waltz/service/logical_flow/LogicalFlowService.java b/waltz-service/src/main/java/org/finos/waltz/service/logical_flow/LogicalFlowService.java index 8688f9236b..0d2155a605 100644 --- a/waltz-service/src/main/java/org/finos/waltz/service/logical_flow/LogicalFlowService.java +++ b/waltz-service/src/main/java/org/finos/waltz/service/logical_flow/LogicalFlowService.java @@ -222,6 +222,7 @@ public LogicalFlow getByExternalId(String externalId) { *
  • DATA_TYPE
  • *
  • APPLICATION
  • * + * * @param options given to logical flow selector factory to determine in-scope flows * @return a list of logical flows matching the given options */ @@ -233,10 +234,10 @@ public List findBySelector(IdSelectionOptions options) { /** * Creates a logical flow and creates a default, 'UNKNOWN' data type decoration * if possible. - * + *

    * If the flow already exists, but is inactive, the flow will be re-activated. * - * @param addCmd Command object containing flow details + * @param addCmd Command object containing flow details * @param username who is creating the flow * @return the newly created logical flow * @throws IllegalArgumentException if a flow already exists @@ -317,7 +318,33 @@ private void rejectIfSelfLoop(AddLogicalFlowCommand addCmd) { } public LogicalFlow updateReadOnly(long flowId, boolean isReadOnly, String user) { + LogicalFlow logicalFlow = getById(flowId); + LocalDateTime now = nowUtc(); + + // if the flow exists + if (logicalFlow != null) { + // if the flag is being set to what it already was -> should not happen but just in case + if (isReadOnly == logicalFlow.isReadOnly()) { + throw new IllegalArgumentException(format("isReadOnly already set to %s", isReadOnly)); + } else { + // update the read only flag to what you want + logicalFlowDao.updateReadOnly(flowId, isReadOnly, user); + LogicalFlow updatedFlow = getById(logicalFlow.id().get()); + + ChangeLog changeLog = ImmutableChangeLog + .builder() + .parentReference(EntityReference.mkRef(LOGICAL_DATA_FLOW, logicalFlow.id().get())) + .operation(Operation.UPDATE) + .createdAt(now) + .userId(user) + .message(format("Updated the readOnlyFlag and set it to: %s", isReadOnly)) + .build(); + changeLogService.write(changeLog); + return updatedFlow; + } + } + // return null if the flow was not found return null; } @@ -325,18 +352,18 @@ public LogicalFlow updateReadOnly(long flowId, boolean isReadOnly, String user) /** * Removes the given logical flow and creates an audit log entry. * The removal is a soft removal. After the removal usage stats are recalculated - * + *

    * todo: #WALTZ-1894 for cleanupOrphans task * - * @param flowId identifier of flow to be removed - * @param username who initiated the removal + * @param flowId identifier of flow to be removed + * @param username who initiated the removal * @return number of flows removed */ public int removeFlow(Long flowId, String username) { LogicalFlow logicalFlow = logicalFlowDao.getByFlowId(flowId); - if(logicalFlow == null){ + if (logicalFlow == null) { LOG.warn("Logical flow cannot be found, no flows will be updated"); throw new IllegalArgumentException(format("Cannot find flow with id: %d, no logical flow removed", flowId)); } else { @@ -357,6 +384,7 @@ public int removeFlow(Long flowId, String username) { /** * Calculate Stats by selector + * * @param options determines which flows are in-scope for this calculation * @return statistics about the in-scope flows */ @@ -372,7 +400,7 @@ public LogicalFlowStatistics calculateStats(IdSelectionOptions options) { case DATA_TYPE: return calculateStatsForAppIdSelector(options); default: - throw new UnsupportedOperationException("Cannot calculate stats for selector kind: "+ options.entityReference().kind()); + throw new UnsupportedOperationException("Cannot calculate stats for selector kind: " + options.entityReference().kind()); } } @@ -530,12 +558,12 @@ public LogicalFlowView getFlowView(IdSelectionOptions idSelectionOptions) { Set physicalSpecAssessmentRatings = filter(psRatings, d -> toIds(physicalSpecAssessmentDefs).contains(d.assessmentDefinitionId())); Set ratingSchemeItems = ratingSchemeService.findRatingSchemeItemsByIds( - map( - union( - logicalFlowAssessmentRatings, - physicalFlowAssessmentRatings, - physicalSpecAssessmentRatings), - AssessmentRating::ratingId)); + map( + union( + logicalFlowAssessmentRatings, + physicalFlowAssessmentRatings, + physicalSpecAssessmentRatings), + AssessmentRating::ratingId)); List specDecorators = physicalSpecDecoratorDao.findByEntityIdSelector(physSpecSelector, Optional.empty()); diff --git a/waltz-web/src/main/java/org/finos/waltz/web/endpoints/api/LogicalFlowEndpoint.java b/waltz-web/src/main/java/org/finos/waltz/web/endpoints/api/LogicalFlowEndpoint.java index c095b79bd8..73ad1bba17 100644 --- a/waltz-web/src/main/java/org/finos/waltz/web/endpoints/api/LogicalFlowEndpoint.java +++ b/waltz-web/src/main/java/org/finos/waltz/web/endpoints/api/LogicalFlowEndpoint.java @@ -18,11 +18,12 @@ package org.finos.waltz.web.endpoints.api; +import org.eclipse.jetty.util.IO; import org.finos.waltz.common.exception.InsufficientPrivelegeException; import org.finos.waltz.model.EntityKind; import org.finos.waltz.model.IdSelectionOptions; import org.finos.waltz.model.Operation; -import org.finos.waltz.model.logical_flow.LogicalFlowView; +import org.finos.waltz.model.logical_flow.*; import org.finos.waltz.service.permission.permission_checker.FlowPermissionChecker; import org.finos.waltz.service.logical_flow.LogicalFlowService; import org.finos.waltz.service.user.UserRoleService; @@ -31,10 +32,6 @@ import org.finos.waltz.web.endpoints.Endpoint; import org.finos.waltz.common.StringUtilities; import org.finos.waltz.model.EntityReference; -import org.finos.waltz.model.logical_flow.AddLogicalFlowCommand; -import org.finos.waltz.model.logical_flow.LogicalFlow; -import org.finos.waltz.model.logical_flow.LogicalFlowGraphSummary; -import org.finos.waltz.model.logical_flow.LogicalFlowStatistics; import org.finos.waltz.model.user.SystemRole; import org.jooq.lambda.tuple.Tuple; import org.jooq.lambda.tuple.Tuple2; @@ -108,6 +105,7 @@ public void register() { String addFlowsPath = mkPath(BASE_URL, "list"); String getFlowGraphSummaryPath = mkPath(BASE_URL, "entity", ":kind", ":id", "data-type", ":dtId", "graph-summary"); String getFlowViewPath = mkPath(BASE_URL, "view"); + String updateReadOnlyPath = mkPath(BASE_URL, "update", "read-only", ":id"); ListRoute getByEntityRef = (request, response) -> logicalFlowService.findByEntityReference(getEntityReference(request)); @@ -177,6 +175,7 @@ public void register() { postForList(addFlowsPath, this::addFlowsRoute); putForDatum(restoreFlowPath, this::restoreFlowRoute); postForDatum(getFlowViewPath, getFlowViewRoute); + postForDatum(updateReadOnlyPath, this::updateReadOnly); } @@ -286,4 +285,18 @@ private void ensureUserHasEditRights(EntityReference source, EntityReference tar private void ensureUserHasAdminRights(Request request) { requireRole(userRoleService, request, SystemRole.ADMIN); } + + private LogicalFlow updateReadOnly(Request request, Response response) throws IOException { + long flowId = getId(request); + String user = getUsername(request); + UpdateReadOnlyCommand cmd = readBody(request, UpdateReadOnlyCommand.class); + + ensureUserHasAdminRights(request); + LogicalFlow resp = logicalFlowService.updateReadOnly(flowId, cmd.readOnly(), user); + if(resp == null) { + throw new IllegalArgumentException("No such Logical Flow exists"); + } + + return resp; + } } From 494b334f2a135f4001277182756392b2d9ca86d3 Mon Sep 17 00:00:00 2001 From: jainshrk Date: Wed, 6 Nov 2024 13:46:24 +0530 Subject: [PATCH 04/10] toggle on the ui for readonly --- .../pages/view/logical-flow-view.html | 12 ++++++ .../pages/view/logical-flow-view.js | 37 +++++++++++++++++-- .../services/logical-flow-store.js | 12 +++++- 3 files changed, 57 insertions(+), 4 deletions(-) diff --git a/waltz-ng/client/logical-flow/pages/view/logical-flow-view.html b/waltz-ng/client/logical-flow/pages/view/logical-flow-view.html index 3bcbf98547..b06ea00ec6 100644 --- a/waltz-ng/client/logical-flow/pages/view/logical-flow-view.html +++ b/waltz-ng/client/logical-flow/pages/view/logical-flow-view.html @@ -128,6 +128,18 @@ +

    +
    + Toggle Read Only +
    +
    + +
    +
    diff --git a/waltz-ng/client/logical-flow/pages/view/logical-flow-view.js b/waltz-ng/client/logical-flow/pages/view/logical-flow-view.js index aca1eb9f43..05e8ad7387 100644 --- a/waltz-ng/client/logical-flow/pages/view/logical-flow-view.js +++ b/waltz-ng/client/logical-flow/pages/view/logical-flow-view.js @@ -35,16 +35,20 @@ const initialState = { canEdit: false, canRestore: false, canRemove: false, + isAdmin: false, + updateCommand: { + readOnly: false, + }, AlignedDataTypesList }; - function controller($q, $state, $stateParams, $window, serviceBroker, - historyStore) + historyStore, + userService) { const vm = initialiseData(this, initialState); @@ -55,6 +59,12 @@ function controller($q, kind: "LOGICAL_DATA_FLOW" }; + userService + .whoami(true) + .then(usr => { + vm.isAdmin = _.includes(usr.roles, "ADMIN"); + }); + // -- LOAD --- const flowPromise = serviceBroker @@ -91,6 +101,22 @@ function controller($q, }; + const onToggleReadOnly = () => { + const changedField = !vm.logicalFlow.isReadOnly; + vm.updateCommand.readOnly = changedField; + return serviceBroker + .execute(CORE_API.LogicalFlowStore.updateReadOnly, [vm.updateCommand, vm.logicalFlow.id]) + .then(() => { + toasts.success("Successfully made the flow " + (changedField ? `read only` : `editable`) + '.'); + setTimeout(() => { + $window.location.reload(); + }, 600); + }) + .catch(e => { + toasts.error(e.data.message); + }); + } + const removeLogicalFlow = () => { return serviceBroker .execute(CORE_API.LogicalFlowStore.removeFlow, [vm.logicalFlow.id]) @@ -134,6 +160,10 @@ function controller($q, } }; + vm.onToggleReadOnly = () => { + onToggleReadOnly(); + } + vm.restoreFlow = () => { if (confirm("Are you sure you want to restore this flow ?")) { console.log("restoring", vm.logicalFlow); @@ -156,7 +186,8 @@ controller.$inject = [ "$stateParams", "$window", "ServiceBroker", - "HistoryStore" + "HistoryStore", + "UserService" ]; diff --git a/waltz-ng/client/logical-flow/services/logical-flow-store.js b/waltz-ng/client/logical-flow/services/logical-flow-store.js index ed5b3145ad..0d1794ae13 100644 --- a/waltz-ng/client/logical-flow/services/logical-flow-store.js +++ b/waltz-ng/client/logical-flow/services/logical-flow-store.js @@ -126,6 +126,10 @@ export function store($http, BaseApiUrl) { .get(`${BASE}/cleanup-self-references`) .then(r => r.data); + const updateReadOnly = (updateReadOnlyCmd, id) => $http + .post(`${BASE}/update/read-only/${id}`, updateReadOnlyCmd) + .then(r => r.data); + return { findBySelector, findByIds, @@ -144,7 +148,8 @@ export function store($http, BaseApiUrl) { findPermissionsForParentRef, findPermissionsForFlow, cleanupOrphans, - cleanupSelfReferences + cleanupSelfReferences, + updateReadOnly }; } @@ -252,6 +257,11 @@ export const LogicalFlowStore_API = { serviceFnName: "cleanupSelfReferences", description: "mark flows as removed where the flow source and target are the same" }, + updateReadOnly: { + serviceName, + serviceFnName: "updateReadOnly", + description: "update whether a logical flow is read only or editable" + }, }; From f2012b8d984b72d56c2c97723297b066148d1af4 Mon Sep 17 00:00:00 2001 From: jainshrk Date: Wed, 6 Nov 2024 16:22:44 +0530 Subject: [PATCH 05/10] reformat the changelog + update the command --- .../finos/waltz/model/logical_flow/UpdateReadOnlyCommand.java | 3 ++- .../finos/waltz/service/logical_flow/LogicalFlowService.java | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/waltz-model/src/main/java/org/finos/waltz/model/logical_flow/UpdateReadOnlyCommand.java b/waltz-model/src/main/java/org/finos/waltz/model/logical_flow/UpdateReadOnlyCommand.java index 429fdca3ca..0c3b23e0fd 100644 --- a/waltz-model/src/main/java/org/finos/waltz/model/logical_flow/UpdateReadOnlyCommand.java +++ b/waltz-model/src/main/java/org/finos/waltz/model/logical_flow/UpdateReadOnlyCommand.java @@ -2,11 +2,12 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.finos.waltz.model.command.Command; import org.immutables.value.Value; @Value.Immutable @JsonSerialize(as = ImmutableUpdateReadOnlyCommand.class) @JsonDeserialize(as = ImmutableUpdateReadOnlyCommand.class) -public interface UpdateReadOnlyCommand { +public interface UpdateReadOnlyCommand extends Command { boolean readOnly(); } diff --git a/waltz-service/src/main/java/org/finos/waltz/service/logical_flow/LogicalFlowService.java b/waltz-service/src/main/java/org/finos/waltz/service/logical_flow/LogicalFlowService.java index 0d2155a605..540d5d7688 100644 --- a/waltz-service/src/main/java/org/finos/waltz/service/logical_flow/LogicalFlowService.java +++ b/waltz-service/src/main/java/org/finos/waltz/service/logical_flow/LogicalFlowService.java @@ -337,7 +337,9 @@ public LogicalFlow updateReadOnly(long flowId, boolean isReadOnly, String user) .operation(Operation.UPDATE) .createdAt(now) .userId(user) - .message(format("Updated the readOnlyFlag and set it to: %s", isReadOnly)) + .message(isReadOnly + ? format("Set to read only by waltz_support<%s>", user) + : format("Set to editable by waltz_support<%s>", user)) .build(); changeLogService.write(changeLog); return updatedFlow; From 4aab873f75fd082d7167d636cb716262bfc6627a Mon Sep 17 00:00:00 2001 From: jainshrk Date: Thu, 7 Nov 2024 15:51:26 +0530 Subject: [PATCH 06/10] add removals to bulk taxonomy change service --- .../BulkTaxonomyChangeService.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/waltz-service/src/main/java/org/finos/waltz/service/taxonomy_management/BulkTaxonomyChangeService.java b/waltz-service/src/main/java/org/finos/waltz/service/taxonomy_management/BulkTaxonomyChangeService.java index 36820ca62d..a5b2189dfd 100644 --- a/waltz-service/src/main/java/org/finos/waltz/service/taxonomy_management/BulkTaxonomyChangeService.java +++ b/waltz-service/src/main/java/org/finos/waltz/service/taxonomy_management/BulkTaxonomyChangeService.java @@ -48,6 +48,7 @@ import org.finos.waltz.service.taxonomy_management.BulkTaxonomyItemParser.InputFormat; import org.finos.waltz.service.user.UserRoleService; import org.jooq.DSLContext; +import org.jooq.DeleteConditionStep; import org.jooq.UpdateConditionStep; import org.jooq.UpdateSetStep; import org.jooq.impl.DSL; @@ -280,6 +281,17 @@ public BulkTaxonomyApplyResult applyBulk(EntityReference taxonomyRef, }) .collect(Collectors.toSet()); + Set> toRemove = bulkRequest + .plannedRemovals() + .stream() + .map(r -> { + UpdateSetStep updRemove = DSL.update(org.finos.waltz.schema.tables.Measurable.MEASURABLE); + return updRemove + .set(org.finos.waltz.schema.tables.Measurable.MEASURABLE.ENTITY_LIFECYCLE_STATUS, EntityLifecycleStatus.REMOVED.name()) + .where(org.finos.waltz.schema.tables.Measurable.MEASURABLE.ID.eq(r.id().get())); + }) + .collect(Collectors.toSet()); + boolean requiresRebuild = requiresHierarchyRebuild(bulkRequest.validatedItems()); @@ -289,6 +301,7 @@ public BulkTaxonomyApplyResult applyBulk(EntityReference taxonomyRef, int insertCount = summarizeResults(tx.batchInsert(toAdd).execute()); int restoreCount = summarizeResults(tx.batch(toRestore).execute()); int updateCount = summarizeResults(tx.batch(toUpdate).execute()); + int removalCount = summarizeResults(tx.batch(toRemove).execute()); Set changeRecords = mkTaxonomyChangeRecords(tx, taxonomyRef, bulkRequest, userId); @@ -306,7 +319,7 @@ public BulkTaxonomyApplyResult applyBulk(EntityReference taxonomyRef, .recordsAdded(insertCount) .recordsUpdated(updateCount) .recordsRestored(restoreCount) - .recordsRemoved(0)//TODO: add removeCount + .recordsRemoved(removalCount) .hierarchyRebuilt(requiresRebuild) .build(); }); From c11f8f569105c704e39ff2921ac5176d54533241 Mon Sep 17 00:00:00 2001 From: jainshrk Date: Mon, 11 Nov 2024 14:24:50 +0530 Subject: [PATCH 07/10] remove redundant info from changelog --- .../finos/waltz/service/logical_flow/LogicalFlowService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/waltz-service/src/main/java/org/finos/waltz/service/logical_flow/LogicalFlowService.java b/waltz-service/src/main/java/org/finos/waltz/service/logical_flow/LogicalFlowService.java index 540d5d7688..e46cf6fb4d 100644 --- a/waltz-service/src/main/java/org/finos/waltz/service/logical_flow/LogicalFlowService.java +++ b/waltz-service/src/main/java/org/finos/waltz/service/logical_flow/LogicalFlowService.java @@ -338,8 +338,8 @@ public LogicalFlow updateReadOnly(long flowId, boolean isReadOnly, String user) .createdAt(now) .userId(user) .message(isReadOnly - ? format("Set to read only by waltz_support<%s>", user) - : format("Set to editable by waltz_support<%s>", user)) + ? format("Set to read only by waltz_support.") + : format("Set to editable by waltz_support.")) .build(); changeLogService.write(changeLog); return updatedFlow; From d01203005a1de493895f5c4efc7f0ab15a199e97 Mon Sep 17 00:00:00 2001 From: jainshrk Date: Tue, 12 Nov 2024 15:29:15 +0530 Subject: [PATCH 08/10] changes on pr comments --- .../pages/view/logical-flow-view.html | 21 ++++++++++--------- .../pages/view/logical-flow-view.js | 7 ------- .../logical_flow/LogicalFlowService.java | 15 +++++++------ .../endpoints/api/LogicalFlowEndpoint.java | 7 ++++++- 4 files changed, 24 insertions(+), 26 deletions(-) diff --git a/waltz-ng/client/logical-flow/pages/view/logical-flow-view.html b/waltz-ng/client/logical-flow/pages/view/logical-flow-view.html index b06ea00ec6..e09d3049dd 100644 --- a/waltz-ng/client/logical-flow/pages/view/logical-flow-view.html +++ b/waltz-ng/client/logical-flow/pages/view/logical-flow-view.html @@ -128,16 +128,17 @@
    -
    -
    - Toggle Read Only -
    -
    - +
    +
    +
    + Toggle Read Only +
    +
    + +
    diff --git a/waltz-ng/client/logical-flow/pages/view/logical-flow-view.js b/waltz-ng/client/logical-flow/pages/view/logical-flow-view.js index 05e8ad7387..8df8dcd95b 100644 --- a/waltz-ng/client/logical-flow/pages/view/logical-flow-view.js +++ b/waltz-ng/client/logical-flow/pages/view/logical-flow-view.js @@ -35,7 +35,6 @@ const initialState = { canEdit: false, canRestore: false, canRemove: false, - isAdmin: false, updateCommand: { readOnly: false, }, @@ -59,12 +58,6 @@ function controller($q, kind: "LOGICAL_DATA_FLOW" }; - userService - .whoami(true) - .then(usr => { - vm.isAdmin = _.includes(usr.roles, "ADMIN"); - }); - // -- LOAD --- const flowPromise = serviceBroker diff --git a/waltz-service/src/main/java/org/finos/waltz/service/logical_flow/LogicalFlowService.java b/waltz-service/src/main/java/org/finos/waltz/service/logical_flow/LogicalFlowService.java index e46cf6fb4d..db8e1e6521 100644 --- a/waltz-service/src/main/java/org/finos/waltz/service/logical_flow/LogicalFlowService.java +++ b/waltz-service/src/main/java/org/finos/waltz/service/logical_flow/LogicalFlowService.java @@ -321,11 +321,10 @@ public LogicalFlow updateReadOnly(long flowId, boolean isReadOnly, String user) LogicalFlow logicalFlow = getById(flowId); LocalDateTime now = nowUtc(); - // if the flow exists if (logicalFlow != null) { // if the flag is being set to what it already was -> should not happen but just in case if (isReadOnly == logicalFlow.isReadOnly()) { - throw new IllegalArgumentException(format("isReadOnly already set to %s", isReadOnly)); + return logicalFlow; } else { // update the read only flag to what you want logicalFlowDao.updateReadOnly(flowId, isReadOnly, user); @@ -560,12 +559,12 @@ public LogicalFlowView getFlowView(IdSelectionOptions idSelectionOptions) { Set physicalSpecAssessmentRatings = filter(psRatings, d -> toIds(physicalSpecAssessmentDefs).contains(d.assessmentDefinitionId())); Set ratingSchemeItems = ratingSchemeService.findRatingSchemeItemsByIds( - map( - union( - logicalFlowAssessmentRatings, - physicalFlowAssessmentRatings, - physicalSpecAssessmentRatings), - AssessmentRating::ratingId)); + map( + union( + logicalFlowAssessmentRatings, + physicalFlowAssessmentRatings, + physicalSpecAssessmentRatings), + AssessmentRating::ratingId)); List specDecorators = physicalSpecDecoratorDao.findByEntityIdSelector(physSpecSelector, Optional.empty()); diff --git a/waltz-web/src/main/java/org/finos/waltz/web/endpoints/api/LogicalFlowEndpoint.java b/waltz-web/src/main/java/org/finos/waltz/web/endpoints/api/LogicalFlowEndpoint.java index 73ad1bba17..23e9aafc7e 100644 --- a/waltz-web/src/main/java/org/finos/waltz/web/endpoints/api/LogicalFlowEndpoint.java +++ b/waltz-web/src/main/java/org/finos/waltz/web/endpoints/api/LogicalFlowEndpoint.java @@ -23,7 +23,7 @@ import org.finos.waltz.model.EntityKind; import org.finos.waltz.model.IdSelectionOptions; import org.finos.waltz.model.Operation; -import org.finos.waltz.model.logical_flow.*; +import org.finos.waltz.model.logical_flow.LogicalFlowView; import org.finos.waltz.service.permission.permission_checker.FlowPermissionChecker; import org.finos.waltz.service.logical_flow.LogicalFlowService; import org.finos.waltz.service.user.UserRoleService; @@ -32,6 +32,11 @@ import org.finos.waltz.web.endpoints.Endpoint; import org.finos.waltz.common.StringUtilities; import org.finos.waltz.model.EntityReference; +import org.finos.waltz.model.logical_flow.AddLogicalFlowCommand; +import org.finos.waltz.model.logical_flow.LogicalFlow; +import org.finos.waltz.model.logical_flow.LogicalFlowGraphSummary; +import org.finos.waltz.model.logical_flow.LogicalFlowStatistics; +import org.finos.waltz.model.logical_flow.UpdateReadOnlyCommand; import org.finos.waltz.model.user.SystemRole; import org.jooq.lambda.tuple.Tuple; import org.jooq.lambda.tuple.Tuple2; From d3d25148692d14d195c51f396b828aa375be1513 Mon Sep 17 00:00:00 2001 From: jainshrk Date: Tue, 12 Nov 2024 15:32:09 +0530 Subject: [PATCH 09/10] remove user service dependency --- .../client/logical-flow/pages/view/logical-flow-view.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/waltz-ng/client/logical-flow/pages/view/logical-flow-view.js b/waltz-ng/client/logical-flow/pages/view/logical-flow-view.js index 8df8dcd95b..fa75192efd 100644 --- a/waltz-ng/client/logical-flow/pages/view/logical-flow-view.js +++ b/waltz-ng/client/logical-flow/pages/view/logical-flow-view.js @@ -46,8 +46,7 @@ function controller($q, $stateParams, $window, serviceBroker, - historyStore, - userService) + historyStore) { const vm = initialiseData(this, initialState); @@ -179,8 +178,7 @@ controller.$inject = [ "$stateParams", "$window", "ServiceBroker", - "HistoryStore", - "UserService" + "HistoryStore" ]; From 2d94f01c79d7c096a765333b9025fbd80881a69e Mon Sep 17 00:00:00 2001 From: jainshrk Date: Tue, 12 Nov 2024 17:33:11 +0530 Subject: [PATCH 10/10] update tests to accomodate new logic --- .../inmem/service/LogicalFlowServiceTest.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/waltz-integration-test/src/test/java/org/finos/waltz/integration_test/inmem/service/LogicalFlowServiceTest.java b/waltz-integration-test/src/test/java/org/finos/waltz/integration_test/inmem/service/LogicalFlowServiceTest.java index 6facfd86c1..33013269b5 100644 --- a/waltz-integration-test/src/test/java/org/finos/waltz/integration_test/inmem/service/LogicalFlowServiceTest.java +++ b/waltz-integration-test/src/test/java/org/finos/waltz/integration_test/inmem/service/LogicalFlowServiceTest.java @@ -448,11 +448,9 @@ public void updateReadOnlyTest() { updatedFlow = lfSvc.updateReadOnly(122, true, "updateTestUser"); assertNull(updatedFlow); - try{ - updatedFlow = lfSvc.updateReadOnly(logicalFlow.id().get(), false, "updateTestUser"); - } catch (Exception e) { - assertNotNull(e); - } + + updatedFlow = lfSvc.updateReadOnly(logicalFlow.id().get(), false, "updateTestUser"); + assertFalse(updatedFlow.isReadOnly()); } } \ No newline at end of file