Skip to content

Commit 5299316

Browse files
Merge pull request #7431 from deutschebank/db-contrib/waltz-7429-bulk-upload-rating-for-non-capability-taxonomies
Db contrib/waltz 7429 bulk upload rating for non capability taxonomies
2 parents 759935a + 3e64cf7 commit 5299316

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

waltz-service/src/main/java/org/finos/waltz/service/measurable_rating/BulkMeasurableRatingService.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ public BulkMeasurableRatingValidationResult bulkPreview(EntityReference category
129129
List<AllocationScheme> allAllocationSchemes = allocationSchemeDao.findAll();
130130
Map<String, AllocationScheme> allAllocationSchemesByExtId = indexBy(allAllocationSchemes, t -> t.externalId().get());
131131

132+
boolean categorySupportsAllocations = allAllocationSchemes.stream()
133+
.anyMatch(s -> s.measurableCategoryId() == categoryRef.id());
134+
132135
Map<String, Application> allApplicationsByAssetCode = indexBy(allApplications, a -> a.assetCode()
133136
.map(ExternalIdValue::value)
134137
.map(StringUtilities::lower)
@@ -191,7 +194,7 @@ public BulkMeasurableRatingValidationResult bulkPreview(EntityReference category
191194
if (t.v4 != null && !t.v4.userSelectable()) {
192195
validationErrors.add(ValidationError.RATING_NOT_USER_SELECTABLE);
193196
}
194-
if (t.v5 == null) {
197+
if (categorySupportsAllocations && t.v5 == null) {
195198
validationErrors.add(ValidationError.ALLOCATION_SCHEME_NOT_FOUND);
196199
}
197200

@@ -446,7 +449,13 @@ public BulkMeasurableRatingApplyResult apply(EntityReference categoryRef,
446449
return tuple(insertCount, updateCount, removalCount);
447450
});
448451

449-
int allocationsInsertCount = updateAllocation(dsl, categoryRef, preview, userId);
452+
int allocationsInsertCount = 0;
453+
List<AllocationScheme> allAllocationSchemes = allocationSchemeDao.findAll();
454+
boolean categorySupportsAllocations = allAllocationSchemes.stream()
455+
.anyMatch(s -> s.measurableCategoryId() == categoryRef.id());
456+
if (categorySupportsAllocations) {
457+
allocationsInsertCount = updateAllocation(dsl, categoryRef, preview, userId);
458+
}
450459
return ImmutableBulkMeasurableRatingApplyResult
451460
.builder()
452461
.recordsAdded(transactionResult.v1)

0 commit comments

Comments
 (0)