RED-8826: Fixed old codestyle
This commit is contained in:
parent
4a6777be71
commit
01ca31fbbf
@ -133,9 +133,11 @@ public class DictionaryManagementService {
|
|||||||
List<TypeEntity> typeResponse = dictionaryPersistenceService.getCumulatedTypes(dossierTemplateId, dossierId, false);
|
List<TypeEntity> typeResponse = dictionaryPersistenceService.getCumulatedTypes(dossierTemplateId, dossierId, false);
|
||||||
for (TypeEntity res : typeResponse) {
|
for (TypeEntity res : typeResponse) {
|
||||||
var dossierTemplateResponse = res.getDossierTemplateId() == null ? res.getDossierTemplate().getId() : res.getDossierTemplateId();
|
var dossierTemplateResponse = res.getDossierTemplateId() == null ? res.getDossierTemplate().getId() : res.getDossierTemplateId();
|
||||||
if (res.getDossierId() != null && res.getDossierId()
|
if (res.getDossierId() != null
|
||||||
.equals(dossierId) && !type.equals(res.getType()) && dossierTemplateResponse.equals(dossierTemplateId) && labelToCheck.equals(res.getLabel()) || !type.equals(
|
&& res.getDossierId().equals(dossierId)
|
||||||
res.getType()) && dossierTemplateResponse.equals(dossierTemplateId) && labelToCheck.equals(res.getLabel())) {
|
&& !type.equals(res.getType())
|
||||||
|
&& dossierTemplateResponse.equals(dossierTemplateId)
|
||||||
|
&& labelToCheck.equals(res.getLabel()) || !type.equals(res.getType()) && dossierTemplateResponse.equals(dossierTemplateId) && labelToCheck.equals(res.getLabel())) {
|
||||||
throw new ConflictException("Label must be unique.");
|
throw new ConflictException("Label must be unique.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,10 +148,13 @@ public class DictionaryManagementService {
|
|||||||
|
|
||||||
return dictionaryPersistenceService.getCumulatedTypes(typeRequest.getDossierTemplateId(), typeRequest.getDossierId(), false)
|
return dictionaryPersistenceService.getCumulatedTypes(typeRequest.getDossierTemplateId(), typeRequest.getDossierId(), false)
|
||||||
.stream()
|
.stream()
|
||||||
.anyMatch(typeResult -> typeRequest.getDossierId() != null && typeResult.getDossierId() != null && typeRequest.getDossierId()
|
.anyMatch(typeResult -> typeRequest.getDossierId() != null
|
||||||
.equals(typeResult.getDossierId()) && typeRequest.getType().equals(typeResult.getType()) && typeRequest.getDossierTemplateId()
|
&& typeResult.getDossierId() != null
|
||||||
.equals(typeResult.getDossierTemplateId()) || typeRequest.getDossierId() == null && typeRequest.getType()
|
&& typeRequest.getDossierId().equals(typeResult.getDossierId())
|
||||||
.equals(typeResult.getType()) && typeRequest.getDossierTemplateId().equals(typeResult.getDossierTemplateId()));
|
&& typeRequest.getType().equals(typeResult.getType())
|
||||||
|
&& typeRequest.getDossierTemplateId().equals(typeResult.getDossierTemplateId())
|
||||||
|
|| typeRequest.getDossierId() == null && typeRequest.getType().equals(typeResult.getType()) && typeRequest.getDossierTemplateId()
|
||||||
|
.equals(typeResult.getDossierTemplateId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -235,7 +240,9 @@ public class DictionaryManagementService {
|
|||||||
|
|
||||||
checkForDossierTypeExistenceAndCreate(typeId);
|
checkForDossierTypeExistenceAndCreate(typeId);
|
||||||
|
|
||||||
Set<String> cleanEntries = entries.stream().map(StringCleaningUtility::cleanString).collect(toSet());
|
Set<String> cleanEntries = entries.stream()
|
||||||
|
.map(StringCleaningUtility::cleanString)
|
||||||
|
.collect(toSet());
|
||||||
|
|
||||||
if (CollectionUtils.isEmpty(entries)) {
|
if (CollectionUtils.isEmpty(entries)) {
|
||||||
throw new BadRequestException("Entry list is empty.");
|
throw new BadRequestException("Entry list is empty.");
|
||||||
@ -308,10 +315,13 @@ public class DictionaryManagementService {
|
|||||||
|
|
||||||
private Set<String> getInvalidEntries(Set<String> entries) {
|
private Set<String> getInvalidEntries(Set<String> entries) {
|
||||||
|
|
||||||
Predicate<String> isDictionaryEntryNotValid = entry -> DictionaryValidator.validateDictionaryEntry(entry).isPresent();
|
Predicate<String> isDictionaryEntryNotValid = entry -> DictionaryValidator.validateDictionaryEntry(entry)
|
||||||
|
.isPresent();
|
||||||
Predicate<String> isStopword = stopwordService::isStopword;
|
Predicate<String> isStopword = stopwordService::isStopword;
|
||||||
|
|
||||||
return entries.stream().filter(isDictionaryEntryNotValid.or(isStopword)).collect(toSet());
|
return entries.stream()
|
||||||
|
.filter(isDictionaryEntryNotValid.or(isStopword))
|
||||||
|
.collect(toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -324,25 +334,40 @@ public class DictionaryManagementService {
|
|||||||
|
|
||||||
var currentVersion = getCurrentVersion(typeResult);
|
var currentVersion = getCurrentVersion(typeResult);
|
||||||
|
|
||||||
List<String> allExistingEntiesFromType = entryPersistenceService.getEntries(typeId, dictionaryEntryType, null).stream().map(BaseDictionaryEntry::getValue).toList();
|
List<String> allExistingEntiesFromType = entryPersistenceService.getEntries(typeId, dictionaryEntryType, null)
|
||||||
|
.stream()
|
||||||
|
.map(BaseDictionaryEntry::getValue)
|
||||||
|
.toList();
|
||||||
|
|
||||||
if (typeResult.isCaseInsensitive()) {
|
if (typeResult.isCaseInsensitive()) {
|
||||||
|
|
||||||
// Set existing entries to deleted.
|
// Set existing entries to deleted.
|
||||||
var caseInsensitiveExistingEntries = allExistingEntiesFromType.stream().filter(e -> entries.stream().anyMatch(e::equalsIgnoreCase)).collect(toSet());
|
var caseInsensitiveExistingEntries = allExistingEntiesFromType.stream()
|
||||||
|
.filter(e -> entries.stream()
|
||||||
|
.anyMatch(e::equalsIgnoreCase))
|
||||||
|
.collect(toSet());
|
||||||
entryPersistenceService.deleteEntries(typeId, caseInsensitiveExistingEntries, currentVersion + 1, dictionaryEntryType);
|
entryPersistenceService.deleteEntries(typeId, caseInsensitiveExistingEntries, currentVersion + 1, dictionaryEntryType);
|
||||||
|
|
||||||
// Create new deleted entries for not existing.
|
// Create new deleted entries for not existing.
|
||||||
var caseInsensitiveNonExistingEntries = entries.stream().filter(e -> caseInsensitiveExistingEntries.stream().noneMatch(e::equalsIgnoreCase)).collect(toSet());
|
var caseInsensitiveNonExistingEntries = entries.stream()
|
||||||
|
.filter(e -> caseInsensitiveExistingEntries.stream()
|
||||||
|
.noneMatch(e::equalsIgnoreCase))
|
||||||
|
.collect(toSet());
|
||||||
entryPersistenceService.addDeleteEntries(typeId, caseInsensitiveNonExistingEntries, currentVersion + 1, dictionaryEntryType);
|
entryPersistenceService.addDeleteEntries(typeId, caseInsensitiveNonExistingEntries, currentVersion + 1, dictionaryEntryType);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Set existing entries to deleted.
|
// Set existing entries to deleted.
|
||||||
var caseSensitiveExistingEntries = allExistingEntiesFromType.stream().filter(e -> entries.stream().anyMatch(e::equals)).collect(toSet());
|
var caseSensitiveExistingEntries = allExistingEntiesFromType.stream()
|
||||||
|
.filter(e -> entries.stream()
|
||||||
|
.anyMatch(e::equals))
|
||||||
|
.collect(toSet());
|
||||||
entryPersistenceService.deleteEntries(typeId, new HashSet<>(caseSensitiveExistingEntries), currentVersion + 1, dictionaryEntryType);
|
entryPersistenceService.deleteEntries(typeId, new HashSet<>(caseSensitiveExistingEntries), currentVersion + 1, dictionaryEntryType);
|
||||||
|
|
||||||
// Create new deleted entries for not existing.
|
// Create new deleted entries for not existing.
|
||||||
var nonExistingEntries = entries.stream().filter(e -> caseSensitiveExistingEntries.stream().noneMatch(e::equals)).collect(toSet());
|
var nonExistingEntries = entries.stream()
|
||||||
|
.filter(e -> caseSensitiveExistingEntries.stream()
|
||||||
|
.noneMatch(e::equals))
|
||||||
|
.collect(toSet());
|
||||||
entryPersistenceService.addDeleteEntries(typeId, nonExistingEntries, currentVersion + 1, dictionaryEntryType);
|
entryPersistenceService.addDeleteEntries(typeId, nonExistingEntries, currentVersion + 1, dictionaryEntryType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -149,7 +149,8 @@ public class DossierTemplateCloneService {
|
|||||||
private void cloneLegalBasisMapping(String dossierTemplateId, String clonedDossierTemplateId) {
|
private void cloneLegalBasisMapping(String dossierTemplateId, String clonedDossierTemplateId) {
|
||||||
|
|
||||||
legalBasisMappingPersistenceService.setLegalBasisMapping(clonedDossierTemplateId,
|
legalBasisMappingPersistenceService.setLegalBasisMapping(clonedDossierTemplateId,
|
||||||
MagicConverter.convert(legalBasisMappingPersistenceService.getLegalBasisMapping(dossierTemplateId), LegalBasis.class));
|
MagicConverter.convert(legalBasisMappingPersistenceService.getLegalBasisMapping(dossierTemplateId),
|
||||||
|
LegalBasis.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -92,7 +92,12 @@ public class DictionaryPersistenceService {
|
|||||||
if (!existingTypesForRank.isEmpty()) {
|
if (!existingTypesForRank.isEmpty()) {
|
||||||
for (var existingTypeValueForRank : existingTypesForRank) {
|
for (var existingTypeValueForRank : existingTypesForRank) {
|
||||||
if (!existingTypeValueForRank.isDeleted() && !existingTypeValueForRank.getType().equalsIgnoreCase(type)) {
|
if (!existingTypeValueForRank.isDeleted() && !existingTypeValueForRank.getType().equalsIgnoreCase(type)) {
|
||||||
throw new ConflictException("Rank already exists: " + rank + " on type: " + existingTypeValueForRank.getType() + " type id: " + existingTypeValueForRank.getId());
|
throw new ConflictException("Rank already exists: "
|
||||||
|
+ rank
|
||||||
|
+ " on type: "
|
||||||
|
+ existingTypeValueForRank.getType()
|
||||||
|
+ " type id: "
|
||||||
|
+ existingTypeValueForRank.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -300,6 +305,7 @@ public class DictionaryPersistenceService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void updateRankForType(String typeId, int newRank) {
|
public void updateRankForType(String typeId, int newRank) {
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user