Skip to content

Commit 174392b

Browse files
authored
Compute unique names when we merge some models into a collection (#48)
Signed-off-by: David BRAQUART <[email protected]>
1 parent 8871833 commit 174392b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/main/java/org/gridsuite/studyconfig/server/service/SpreadsheetConfigService.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,15 @@ public UUID createSpreadsheetConfigCollection(SpreadsheetConfigCollectionInfos d
162162
@Transactional
163163
public UUID createSpreadsheetConfigCollectionFromConfigs(List<UUID> configUuids) {
164164
SpreadsheetConfigCollectionEntity entity = new SpreadsheetConfigCollectionEntity();
165+
Set<String> targetNames = new HashSet<>();
165166
entity.setSpreadsheetConfigs(configUuids.stream()
166-
.map(this::duplicateSpreadsheetConfigEntity)
167+
.map(configId -> {
168+
SpreadsheetConfigEntity clone = duplicateSpreadsheetConfigEntity(configId);
169+
String newName = getUniqueName(clone.getName(), targetNames, Set.of());
170+
clone.setName(newName);
171+
targetNames.add(newName);
172+
return clone;
173+
})
167174
.toList());
168175
return spreadsheetConfigCollectionRepository.save(entity).getId();
169176
}

0 commit comments

Comments
 (0)