RED-2200 - Dossier Template export and import
- fix problems for entries and file attribute primary flag.
This commit is contained in:
parent
ff225b4260
commit
43e36ddff4
@ -65,6 +65,11 @@ public class FileAttributeConfigPersistenceService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void updatePrimaryAttribute(String fileAttribute) {
|
||||||
|
fileAttributeConfigRepository.updatePrimaryAttributeValueToTrue(fileAttribute);
|
||||||
|
}
|
||||||
|
|
||||||
public FileAttributesGeneralConfigurationEntity setFileAttributesGeneralConfig(String dossierTemplateId, FileAttributesGeneralConfigurationEntity fileAttributesConfig) {
|
public FileAttributesGeneralConfigurationEntity setFileAttributesGeneralConfig(String dossierTemplateId, FileAttributesGeneralConfigurationEntity fileAttributesConfig) {
|
||||||
fileAttributesConfig.setDossierTemplateId(dossierTemplateId);
|
fileAttributesConfig.setDossierTemplateId(dossierTemplateId);
|
||||||
fileAttributesConfig.setDossierTemplate(dossierTemplateRepository.getOne(dossierTemplateId));
|
fileAttributesConfig.setDossierTemplate(dossierTemplateRepository.getOne(dossierTemplateId));
|
||||||
|
|||||||
@ -16,6 +16,10 @@ public interface FileAttributeConfigRepository extends JpaRepository<FileAttribu
|
|||||||
@Query("update FileAttributeConfigEntity e set e.primaryAttribute = false where e.dossierTemplate.id = :dossierTemplateId")
|
@Query("update FileAttributeConfigEntity e set e.primaryAttribute = false where e.dossierTemplate.id = :dossierTemplateId")
|
||||||
void updateAllPrimaryAttributeValuesToFalse(String dossierTemplateId);
|
void updateAllPrimaryAttributeValuesToFalse(String dossierTemplateId);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query("update FileAttributeConfigEntity e set e.primaryAttribute = true where e.id = :fileAttributeId")
|
||||||
|
void updatePrimaryAttributeValueToTrue(String fileAttributeId);
|
||||||
|
|
||||||
@Query("select fa from FileAttributeConfigEntity fa where fa.dossierTemplate.id = :dossierTemplateId and (fa.id = :fileAttributeId or fa.label = :label)")
|
@Query("select fa from FileAttributeConfigEntity fa where fa.dossierTemplate.id = :dossierTemplateId and (fa.id = :fileAttributeId or fa.label = :label)")
|
||||||
Optional<FileAttributeConfigEntity> findByIdOrDossierTemplateIdAndLabel(String dossierTemplateId, String fileAttributeId, String label);
|
Optional<FileAttributeConfigEntity> findByIdOrDossierTemplateIdAndLabel(String dossierTemplateId, String fileAttributeId, String label);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -244,9 +244,9 @@ public class DossierTemplateImportService {
|
|||||||
return dossierTemplateId;
|
return dossierTemplateId;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addEntries(Map<String, List<String>> entries, String typeId, String initialTypeId, DictionaryEntryType dictionaryType) {
|
private void addEntries(Map<String, List<String>> entries, String typeId, String typeName, DictionaryEntryType dictionaryType) {
|
||||||
if (entries != null && !entries.isEmpty() && entries.get(initialTypeId) != null && !entries.get(initialTypeId).isEmpty()) {
|
if (entries != null && !entries.isEmpty() && entries.get(typeName) != null && !entries.get(typeName).isEmpty()) {
|
||||||
dictionaryService.addEntries(typeId, entries.get(initialTypeId), true, true, dictionaryType);
|
dictionaryService.addEntries(typeId, entries.get(typeName), true, true, dictionaryType);
|
||||||
} 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()
|
||||||
@ -342,9 +342,9 @@ public class DossierTemplateImportService {
|
|||||||
}
|
}
|
||||||
typeIdsAdded.add(typeId);
|
typeIdsAdded.add(typeId);
|
||||||
|
|
||||||
this.addEntries(request.getEntries(), typeId, type.getTypeId(), DictionaryEntryType.ENTRY);
|
this.addEntries(request.getEntries(), typeId, type.getType(), DictionaryEntryType.ENTRY);
|
||||||
this.addEntries(request.getFalsePositives(), typeId, type.getTypeId(), DictionaryEntryType.FALSE_POSITIVE);
|
this.addEntries(request.getFalsePositives(), typeId, type.getType(), DictionaryEntryType.FALSE_POSITIVE);
|
||||||
this.addEntries(request.getFalseRecommendations(), typeId, type.getTypeId(), DictionaryEntryType.FALSE_RECOMMENDATION);
|
this.addEntries(request.getFalseRecommendations(), typeId, type.getType(), DictionaryEntryType.FALSE_RECOMMENDATION);
|
||||||
}
|
}
|
||||||
// remove additional types and not included in the archive
|
// remove additional types and not included in the archive
|
||||||
this.deleteTypes(currentTypes, typeIdsAdded);
|
this.deleteTypes(currentTypes, typeIdsAdded);
|
||||||
@ -416,6 +416,9 @@ public class DossierTemplateImportService {
|
|||||||
fa.setId(fileAttributeConfigPersistenceService.getFileAttributeByIdOrName(dossierTemplateId, fa.getId(), fa.getLabel()));
|
fa.setId(fileAttributeConfigPersistenceService.getFileAttributeByIdOrName(dossierTemplateId, fa.getId(), fa.getLabel()));
|
||||||
FileAttributeConfigEntity fileAttributeAdded = fileAttributeConfigPersistenceService.addOrUpdateFileAttribute(dossierTemplateId, convert(fa, FileAttributeConfigEntity.class));
|
FileAttributeConfigEntity fileAttributeAdded = fileAttributeConfigPersistenceService.addOrUpdateFileAttribute(dossierTemplateId, convert(fa, FileAttributeConfigEntity.class));
|
||||||
fileAttributeIdsAdded.add(fileAttributeAdded.getId());
|
fileAttributeIdsAdded.add(fileAttributeAdded.getId());
|
||||||
|
if (fa.isPrimaryAttribute()) {
|
||||||
|
fileAttributeConfigPersistenceService.updatePrimaryAttribute(fileAttributeAdded.getId());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
// remove existing file attributes and not included in archive
|
// remove existing file attributes and not included in archive
|
||||||
Set<String> attributesToRemove = currentFileAttributeIds.stream().filter(fa -> !fileAttributeIdsAdded.contains(fa)).collect(Collectors.toSet());
|
Set<String> attributesToRemove = currentFileAttributeIds.stream().filter(fa -> !fileAttributeIdsAdded.contains(fa)).collect(Collectors.toSet());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user