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(),
|
return MagicConverter.convert(dictionaryPersistenceService.addType(typeRequest.getType(),
|
||||||
typeRequest.getDossierTemplateId(),
|
typeRequest.getDossierTemplateId(),
|
||||||
color,
|
color,
|
||||||
recommendationHexColor,
|
recommendationHexColor,
|
||||||
skippedHexColor,
|
skippedHexColor,
|
||||||
typeRequest.getRank(),
|
typeRequest.getRank(),
|
||||||
typeRequest.isHint(),
|
typeRequest.isHint(),
|
||||||
typeRequest.isCaseInsensitive(),
|
typeRequest.isCaseInsensitive(),
|
||||||
typeRequest.isRecommendation(),
|
typeRequest.isRecommendation(),
|
||||||
typeRequest.getDescription(),
|
typeRequest.getDescription(),
|
||||||
typeRequest.isAddToDictionaryAction(),
|
typeRequest.isAddToDictionaryAction(),
|
||||||
typeRequest.getLabel(),
|
typeRequest.getLabel(),
|
||||||
typeRequest.getDossierId(),
|
typeRequest.getDossierId(),
|
||||||
typeRequest.isHasDictionary(),
|
typeRequest.isHasDictionary(),
|
||||||
typeRequest.isSystemManaged(),
|
typeRequest.isSystemManaged(),
|
||||||
typeRequest.isAutoHideSkipped(),
|
typeRequest.isAutoHideSkipped(),
|
||||||
typeRequest.isDossierDictionaryOnly(),
|
typeRequest.isDossierDictionaryOnly(),
|
||||||
typeRequest.isExperimental()), Type.class, new TypeMapper());
|
typeRequest.isExperimental()), Type.class, new TypeMapper());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -97,7 +97,7 @@ public class DossierTemplateCloneService {
|
|||||||
cloneLegalBasisMapping(dossierTemplate.getId(), clonedDossierTemplate.getId());
|
cloneLegalBasisMapping(dossierTemplate.getId(), clonedDossierTemplate.getId());
|
||||||
|
|
||||||
clonedDossierTemplate.setDossierTemplateStatus(DossierTemplateStatus.valueOf(dossierTemplatePersistenceService.computeDossierTemplateStatus(clonedDossierTemplate)
|
clonedDossierTemplate.setDossierTemplateStatus(DossierTemplateStatus.valueOf(dossierTemplatePersistenceService.computeDossierTemplateStatus(clonedDossierTemplate)
|
||||||
.name()));
|
.name()));
|
||||||
|
|
||||||
clonedDossierTemplate.setOcrByDefault(cloneDossierTemplateRequest.isOcrByDefault());
|
clonedDossierTemplate.setOcrByDefault(cloneDossierTemplateRequest.isOcrByDefault());
|
||||||
clonedDossierTemplate.setRemoveWatermark(cloneDossierTemplateRequest.isRemoveWatermark());
|
clonedDossierTemplate.setRemoveWatermark(cloneDossierTemplateRequest.isRemoveWatermark());
|
||||||
@ -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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -158,23 +159,23 @@ public class DossierTemplateCloneService {
|
|||||||
var types = dictionaryPersistenceService.getAllTypesForDossierTemplate(dossierTemplateId, false);
|
var types = dictionaryPersistenceService.getAllTypesForDossierTemplate(dossierTemplateId, false);
|
||||||
for (TypeEntity t : types) {
|
for (TypeEntity t : types) {
|
||||||
var type = dictionaryPersistenceService.addType(t.getType(),
|
var type = dictionaryPersistenceService.addType(t.getType(),
|
||||||
clonedDossierTemplateId,
|
clonedDossierTemplateId,
|
||||||
t.getHexColor(),
|
t.getHexColor(),
|
||||||
t.getRecommendationHexColor(),
|
t.getRecommendationHexColor(),
|
||||||
t.getSkippedHexColor(),
|
t.getSkippedHexColor(),
|
||||||
t.getRank(),
|
t.getRank(),
|
||||||
t.isHint(),
|
t.isHint(),
|
||||||
t.isCaseInsensitive(),
|
t.isCaseInsensitive(),
|
||||||
t.isRecommendation(),
|
t.isRecommendation(),
|
||||||
t.getDescription(),
|
t.getDescription(),
|
||||||
t.isAddToDictionaryAction(),
|
t.isAddToDictionaryAction(),
|
||||||
t.getLabel(),
|
t.getLabel(),
|
||||||
null,
|
null,
|
||||||
t.isHasDictionary(),
|
t.isHasDictionary(),
|
||||||
t.isSystemManaged(),
|
t.isSystemManaged(),
|
||||||
t.isAutoHideSkipped(),
|
t.isAutoHideSkipped(),
|
||||||
t.isDossierDictionaryOnly(),
|
t.isDossierDictionaryOnly(),
|
||||||
t.isExperimental());
|
t.isExperimental());
|
||||||
entryPersistenceService.cloneEntries(t.getId(), type.getId());
|
entryPersistenceService.cloneEntries(t.getId(), type.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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