DictionaryModel Incremental build
This commit is contained in:
parent
47a45e9650
commit
a896c51335
@ -87,8 +87,24 @@ public class DictionaryService {
|
|||||||
|
|
||||||
List<DictionaryModel> dictionary = typeResponse
|
List<DictionaryModel> dictionary = typeResponse
|
||||||
.stream()
|
.stream()
|
||||||
.map(t -> new DictionaryModel(t.getType(), t.getRank(), convertColor(t.getHexColor()), t.isCaseInsensitive(), t
|
.map(t -> {
|
||||||
.isHint(), t.isRecommendation(), convertEntries(t.getId(), currentVersion), new HashSet<>(), dossierId != null))
|
|
||||||
|
Optional<DictionaryModel> oldModel;
|
||||||
|
if (dossierId == null) {
|
||||||
|
oldModel = dictionariesByDossierTemplate.get(dossierTemplateId).getDictionary().stream().filter(f -> f.getType().equals(t.getType())).findAny();
|
||||||
|
} else {
|
||||||
|
oldModel = dictionariesByDossier.get(dossierId).getDictionary().stream().filter(f -> f.getType().equals(t.getType())).findAny();
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<DictionaryEntry> entries = new HashSet<>();
|
||||||
|
// add old entries from existing DictionaryModel
|
||||||
|
oldModel.ifPresent(dictionaryModel -> entries.addAll(dictionaryModel.getEntries()));
|
||||||
|
// Add Increments
|
||||||
|
entries.addAll(convertEntries(t.getId(), currentVersion));
|
||||||
|
|
||||||
|
return new DictionaryModel(t.getType(), t.getRank(), convertColor(t.getHexColor()), t.isCaseInsensitive(), t
|
||||||
|
.isHint(), t.isRecommendation(), entries, new HashSet<>(), dossierId != null);
|
||||||
|
})
|
||||||
.sorted(Comparator.comparingInt(DictionaryModel::getRank).reversed())
|
.sorted(Comparator.comparingInt(DictionaryModel::getRank).reversed())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user