RED-8951: made it possible to import entities with dictionary but hasDictionary=false

(cherry picked from commit 784b67ee5a4d0f69e667b26361e3399d8ea256e0)
This commit is contained in:
Ali Oezyetimoglu 2024-07-24 08:00:28 +02:00
parent 47383a280e
commit 054a06b17b
2 changed files with 8 additions and 2 deletions

View File

@ -171,7 +171,7 @@ public class EntityTypeImportService {
private void addEntries(Map<String, List<String>> entries, Map<String, List<String>> deleteEntries, String typeId, String typeName, DictionaryEntryType dictionaryType) { private void addEntries(Map<String, List<String>> entries, Map<String, List<String>> deleteEntries, String typeId, String typeName, DictionaryEntryType dictionaryType) {
if (entries != null && !entries.isEmpty() && entries.get(typeName) != null && !entries.get(typeName).isEmpty()) { if (entries != null && !entries.isEmpty() && entries.get(typeName) != null && !entries.get(typeName).isEmpty()) {
dictionaryManagementService.addEntries(typeId, entries.get(typeName), true, true, dictionaryType); dictionaryManagementService.addEntries(typeId, entries.get(typeName), true, true, dictionaryType, true);
} else { // no entries, delete current entries } else { // no entries, delete current entries
List<String> existing = entryPersistenceService.getEntries(typeId, dictionaryType, null) List<String> existing = entryPersistenceService.getEntries(typeId, dictionaryType, null)
.stream() .stream()

View File

@ -237,6 +237,12 @@ public class DictionaryManagementService {
@Transactional @Transactional
public void addEntries(String typeId, List<String> entries, boolean removeCurrent, boolean ignoreInvalidEntries, DictionaryEntryType dictionaryEntryType) { public void addEntries(String typeId, List<String> entries, boolean removeCurrent, boolean ignoreInvalidEntries, DictionaryEntryType dictionaryEntryType) {
addEntries(typeId, entries, removeCurrent, ignoreInvalidEntries, dictionaryEntryType, false);
}
@Transactional
public void addEntries(String typeId, List<String> entries, boolean removeCurrent, boolean ignoreInvalidEntries, DictionaryEntryType dictionaryEntryType, boolean isImport) {
checkForDossierTypeExistenceAndCreate(typeId); checkForDossierTypeExistenceAndCreate(typeId);
@ -258,7 +264,7 @@ public class DictionaryManagementService {
// To check whether the type exists, type should not be added into database implicitly by addEntry. // To check whether the type exists, type should not be added into database implicitly by addEntry.
Type typeResult = MagicConverter.convert(dictionaryPersistenceService.getType(typeId), Type.class); Type typeResult = MagicConverter.convert(dictionaryPersistenceService.getType(typeId), Type.class);
if (!typeResult.isHasDictionary()) { if (!typeResult.isHasDictionary() && !isImport) {
throw new BadRequestException("Entity type does not have a dictionary"); throw new BadRequestException("Entity type does not have a dictionary");
} }