Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Db contrib/7182 admin toggle read only on logical flows #7187

Prev Previous commit
Next Next commit
add removals to bulk taxonomy change service
jain-shreyans-db committed Nov 7, 2024
commit 4aab873f75fd082d7167d636cb716262bfc6627a
Original file line number Diff line number Diff line change
@@ -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<UpdateConditionStep<MeasurableRecord>> toRemove = bulkRequest
.plannedRemovals()
.stream()
.map(r -> {
UpdateSetStep<MeasurableRecord> 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<TaxonomyChangeRecord> 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();
});