RED-8826: Fixed old codestyle
This commit is contained in:
parent
4a6777be71
commit
01ca31fbbf
@ -91,23 +91,23 @@ public class DictionaryManagementService {
|
||||
}
|
||||
|
||||
return MagicConverter.convert(dictionaryPersistenceService.addType(typeRequest.getType(),
|
||||
typeRequest.getDossierTemplateId(),
|
||||
color,
|
||||
recommendationHexColor,
|
||||
skippedHexColor,
|
||||
typeRequest.getRank(),
|
||||
typeRequest.isHint(),
|
||||
typeRequest.isCaseInsensitive(),
|
||||
typeRequest.isRecommendation(),
|
||||
typeRequest.getDescription(),
|
||||
typeRequest.isAddToDictionaryAction(),
|
||||
typeRequest.getLabel(),
|
||||
typeRequest.getDossierId(),
|
||||
typeRequest.isHasDictionary(),
|
||||
typeRequest.isSystemManaged(),
|
||||
typeRequest.isAutoHideSkipped(),
|
||||
typeRequest.isDossierDictionaryOnly(),
|
||||
typeRequest.isExperimental()), Type.class, new TypeMapper());
|
||||
typeRequest.getDossierTemplateId(),
|
||||
color,
|
||||
recommendationHexColor,
|
||||
skippedHexColor,
|
||||
typeRequest.getRank(),
|
||||
typeRequest.isHint(),
|
||||
typeRequest.isCaseInsensitive(),
|
||||
typeRequest.isRecommendation(),
|
||||
typeRequest.getDescription(),
|
||||
typeRequest.isAddToDictionaryAction(),
|
||||
typeRequest.getLabel(),
|
||||
typeRequest.getDossierId(),
|
||||
typeRequest.isHasDictionary(),
|
||||
typeRequest.isSystemManaged(),
|
||||
typeRequest.isAutoHideSkipped(),
|
||||
typeRequest.isDossierDictionaryOnly(),
|
||||
typeRequest.isExperimental()), Type.class, new TypeMapper());
|
||||
}
|
||||
|
||||
|
||||
@ -133,9 +133,11 @@ public class DictionaryManagementService {
|
||||
List<TypeEntity> typeResponse = dictionaryPersistenceService.getCumulatedTypes(dossierTemplateId, dossierId, false);
|
||||
for (TypeEntity res : typeResponse) {
|
||||
var dossierTemplateResponse = res.getDossierTemplateId() == null ? res.getDossierTemplate().getId() : res.getDossierTemplateId();
|
||||
if (res.getDossierId() != null && res.getDossierId()
|
||||
.equals(dossierId) && !type.equals(res.getType()) && dossierTemplateResponse.equals(dossierTemplateId) && labelToCheck.equals(res.getLabel()) || !type.equals(
|
||||
res.getType()) && dossierTemplateResponse.equals(dossierTemplateId) && labelToCheck.equals(res.getLabel())) {
|
||||
if (res.getDossierId() != null
|
||||
&& res.getDossierId().equals(dossierId)
|
||||
&& !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.");
|
||||
}
|
||||
}
|
||||
@ -146,10 +148,13 @@ public class DictionaryManagementService {
|
||||
|
||||
return dictionaryPersistenceService.getCumulatedTypes(typeRequest.getDossierTemplateId(), typeRequest.getDossierId(), false)
|
||||
.stream()
|
||||
.anyMatch(typeResult -> typeRequest.getDossierId() != null && typeResult.getDossierId() != null && typeRequest.getDossierId()
|
||||
.equals(typeResult.getDossierId()) && typeRequest.getType().equals(typeResult.getType()) && typeRequest.getDossierTemplateId()
|
||||
.equals(typeResult.getDossierTemplateId()) || typeRequest.getDossierId() == null && typeRequest.getType()
|
||||
.equals(typeResult.getType()) && typeRequest.getDossierTemplateId().equals(typeResult.getDossierTemplateId()));
|
||||
.anyMatch(typeResult -> typeRequest.getDossierId() != null
|
||||
&& typeResult.getDossierId() != null
|
||||
&& typeRequest.getDossierId().equals(typeResult.getDossierId())
|
||||
&& 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);
|
||||
|
||||
Set<String> cleanEntries = entries.stream().map(StringCleaningUtility::cleanString).collect(toSet());
|
||||
Set<String> cleanEntries = entries.stream()
|
||||
.map(StringCleaningUtility::cleanString)
|
||||
.collect(toSet());
|
||||
|
||||
if (CollectionUtils.isEmpty(entries)) {
|
||||
throw new BadRequestException("Entry list is empty.");
|
||||
@ -308,10 +315,13 @@ public class DictionaryManagementService {
|
||||
|
||||
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;
|
||||
|
||||
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);
|
||||
|
||||
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()) {
|
||||
|
||||
// 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);
|
||||
|
||||
// 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);
|
||||
} else {
|
||||
|
||||
// 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);
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
||||
@ -97,7 +97,7 @@ public class DossierTemplateCloneService {
|
||||
cloneLegalBasisMapping(dossierTemplate.getId(), clonedDossierTemplate.getId());
|
||||
|
||||
clonedDossierTemplate.setDossierTemplateStatus(DossierTemplateStatus.valueOf(dossierTemplatePersistenceService.computeDossierTemplateStatus(clonedDossierTemplate)
|
||||
.name()));
|
||||
.name()));
|
||||
|
||||
clonedDossierTemplate.setOcrByDefault(cloneDossierTemplateRequest.isOcrByDefault());
|
||||
clonedDossierTemplate.setRemoveWatermark(cloneDossierTemplateRequest.isRemoveWatermark());
|
||||
@ -149,7 +149,8 @@ public class DossierTemplateCloneService {
|
||||
private void cloneLegalBasisMapping(String dossierTemplateId, String clonedDossierTemplateId) {
|
||||
|
||||
legalBasisMappingPersistenceService.setLegalBasisMapping(clonedDossierTemplateId,
|
||||
MagicConverter.convert(legalBasisMappingPersistenceService.getLegalBasisMapping(dossierTemplateId), LegalBasis.class));
|
||||
MagicConverter.convert(legalBasisMappingPersistenceService.getLegalBasisMapping(dossierTemplateId),
|
||||
LegalBasis.class));
|
||||
}
|
||||
|
||||
|
||||
@ -158,23 +159,23 @@ public class DossierTemplateCloneService {
|
||||
var types = dictionaryPersistenceService.getAllTypesForDossierTemplate(dossierTemplateId, false);
|
||||
for (TypeEntity t : types) {
|
||||
var type = dictionaryPersistenceService.addType(t.getType(),
|
||||
clonedDossierTemplateId,
|
||||
t.getHexColor(),
|
||||
t.getRecommendationHexColor(),
|
||||
t.getSkippedHexColor(),
|
||||
t.getRank(),
|
||||
t.isHint(),
|
||||
t.isCaseInsensitive(),
|
||||
t.isRecommendation(),
|
||||
t.getDescription(),
|
||||
t.isAddToDictionaryAction(),
|
||||
t.getLabel(),
|
||||
null,
|
||||
t.isHasDictionary(),
|
||||
t.isSystemManaged(),
|
||||
t.isAutoHideSkipped(),
|
||||
t.isDossierDictionaryOnly(),
|
||||
t.isExperimental());
|
||||
clonedDossierTemplateId,
|
||||
t.getHexColor(),
|
||||
t.getRecommendationHexColor(),
|
||||
t.getSkippedHexColor(),
|
||||
t.getRank(),
|
||||
t.isHint(),
|
||||
t.isCaseInsensitive(),
|
||||
t.isRecommendation(),
|
||||
t.getDescription(),
|
||||
t.isAddToDictionaryAction(),
|
||||
t.getLabel(),
|
||||
null,
|
||||
t.isHasDictionary(),
|
||||
t.isSystemManaged(),
|
||||
t.isAutoHideSkipped(),
|
||||
t.isDossierDictionaryOnly(),
|
||||
t.isExperimental());
|
||||
entryPersistenceService.cloneEntries(t.getId(), type.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,7 +92,12 @@ public class DictionaryPersistenceService {
|
||||
if (!existingTypesForRank.isEmpty()) {
|
||||
for (var existingTypeValueForRank : existingTypesForRank) {
|
||||
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
|
||||
public void updateRankForType(String typeId, int newRank) {
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user