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

Merged
ali.oezyetimoglu1 merged 1 commits from RED-8951 into master 2024-07-24 09:02:11 +02:00
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) {
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
List<String> existing = entryPersistenceService.getEntries(typeId, dictionaryType, null)
.stream()

View File

@ -237,6 +237,12 @@ public class DictionaryManagementService {
@Transactional
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);
@ -258,7 +264,7 @@ public class DictionaryManagementService {
// 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);
if (!typeResult.isHasDictionary()) {
if (!typeResult.isHasDictionary() && !isImport) {
throw new BadRequestException("Entity type does not have a dictionary");
}