merge fix
This commit is contained in:
commit
7987d2b91c
@ -21,7 +21,7 @@ public class WatermarkEntity {
|
||||
@Id
|
||||
@Column
|
||||
private String dossierTemplateId;
|
||||
@Column
|
||||
@Column(columnDefinition = "text")
|
||||
private String text;
|
||||
@Column
|
||||
private String hexColor;
|
||||
|
||||
@ -2,14 +2,14 @@ package com.iqser.red.service.peristence.v1.server.controller;
|
||||
|
||||
import com.iqser.red.service.peristence.v1.server.TextNormalizationUtilities;
|
||||
import com.iqser.red.service.peristence.v1.server.validation.DictionaryValidator;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.configuration.ColorsEntity;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.configuration.DictionaryEntryEntity;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.configuration.TypeEntity;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.BadRequestException;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.ConflictException;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.ColorsService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.DictionaryPersistenceService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.EntryPersistenceService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.configuration.ColorsEntity;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.configuration.DictionaryEntryEntity;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.configuration.TypeEntity;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.configuration.Colors;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.type.DictionaryEntry;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.type.Type;
|
||||
@ -54,7 +54,7 @@ public class DictionaryController implements DictionaryResource {
|
||||
validateEntries(cleanEntries);
|
||||
|
||||
// To check whether the type exists, type should not be added into database implicitly by addEntry.
|
||||
TypeEntity typeResult = dictionaryPersistenceService.getType(typeId);
|
||||
Type typeResult = convert(dictionaryPersistenceService.getType(typeId), Type.class);
|
||||
|
||||
// List<String> entriesToSearch = new ArrayList<>();
|
||||
|
||||
@ -92,7 +92,8 @@ public class DictionaryController implements DictionaryResource {
|
||||
|
||||
validateEntries(entries);
|
||||
// To check whether the type exists
|
||||
TypeEntity typeResult = dictionaryPersistenceService.getType(typeId);
|
||||
Type typeResult = convert(dictionaryPersistenceService.getType(typeId), Type.class);
|
||||
|
||||
long currentVersion = typeResult.getVersion();
|
||||
|
||||
if (typeResult.isCaseInsensitive()) {
|
||||
@ -119,11 +120,11 @@ public class DictionaryController implements DictionaryResource {
|
||||
validateBoolean(typeValueRequest.isHint(), "isHint");
|
||||
validateBoolean(typeValueRequest.isCaseInsensitive(), "isCaseInsensitive");
|
||||
// To check whether the type exists
|
||||
TypeEntity typeResult = dictionaryPersistenceService.getType(typeId);
|
||||
Type typeResult = convert(dictionaryPersistenceService.getType(typeId), Type.class);
|
||||
|
||||
|
||||
if (typeValueRequest.getLabel() != null) {
|
||||
checkForDuplicateLabels(typeResult.getDossierTemplateId(), typeResult.getDossierId(), typeId, typeValueRequest.getLabel());
|
||||
checkForDuplicateLabels(typeResult.getDossierTemplateId(), typeResult.getDossierId(), typeValueRequest.getType(), typeValueRequest.getLabel());
|
||||
}
|
||||
|
||||
|
||||
@ -135,10 +136,10 @@ public class DictionaryController implements DictionaryResource {
|
||||
if (typeResult.isHint() != typeValueRequest.isHint() || typeResult.isCaseInsensitive() != typeValueRequest.isCaseInsensitive() || typeResult
|
||||
.getRank() != typeValueRequest.getRank()) {
|
||||
long currentVersion = typeResult.getVersion();
|
||||
List<DictionaryEntryEntity> entries = entryPersistenceService.getEntries(typeId);
|
||||
List<DictionaryEntry> entries = convert(entryPersistenceService.getEntries(typeId), DictionaryEntry.class);
|
||||
entryPersistenceService.setVersion(typeId, entries.stream()
|
||||
.filter(entry -> !entry.isDeleted())
|
||||
.map(DictionaryEntryEntity::getValue)
|
||||
.map(DictionaryEntry::getValue)
|
||||
.collect(toList()), currentVersion + 1);
|
||||
}
|
||||
|
||||
@ -158,11 +159,12 @@ public class DictionaryController implements DictionaryResource {
|
||||
typeRequest.setLabel(label);
|
||||
}
|
||||
|
||||
checkForDuplicateLabels(typeRequest.getDossierTemplateId(), typeRequest.getDossierId(), typeRequest.getId(), typeRequest.getLabel());
|
||||
checkForDuplicateLabels(typeRequest.getDossierTemplateId(), typeRequest.getDossierId(), typeRequest.getType(), typeRequest.getLabel());
|
||||
|
||||
if (dictionaryPersistenceService.getCumulatedTypes(typeRequest.getDossierTemplateId(), typeRequest.getDossierId())
|
||||
.stream()
|
||||
.anyMatch(typeResult -> typeResult.getType().equals(typeRequest.getType()))) {
|
||||
.anyMatch(typeResult -> typeRequest.getDossierId() != null && typeResult.getDossierId() != null && typeRequest.getDossierId().equals(typeResult.getDossierId()) && typeRequest.getType().equals(typeResult.getType()) && typeRequest.getDossierTemplateId().equals(typeResult.getDossierTemplateId())
|
||||
|| typeRequest.getType().equals(typeResult.getType()) && typeRequest.getDossierTemplateId().equals(typeResult.getDossierTemplateId()))) {
|
||||
throw new ConflictException("The type already exists, could not be added again.");
|
||||
}
|
||||
String color = typeRequest.getHexColor();
|
||||
@ -177,7 +179,7 @@ public class DictionaryController implements DictionaryResource {
|
||||
public void deleteType(@PathVariable(TYPE_PARAMETER_NAME) String typeId) {
|
||||
|
||||
// NotFoundException would be thrown if the type not found in database.
|
||||
TypeEntity typeResult = dictionaryPersistenceService.getType(typeId);
|
||||
Type typeResult = convert(dictionaryPersistenceService.getType(typeId), Type.class);
|
||||
long currentVersion = typeResult.getVersion();
|
||||
|
||||
dictionaryPersistenceService.deleteType(typeId);
|
||||
@ -280,11 +282,12 @@ public class DictionaryController implements DictionaryResource {
|
||||
}
|
||||
|
||||
|
||||
private void checkForDuplicateLabels(String dossierTemplateId, String dossierId, String typeId, String labelToCheck) {
|
||||
private void checkForDuplicateLabels(String dossierTemplateId, String dossierId, String type, String labelToCheck) {
|
||||
|
||||
List<TypeEntity> typeResponse = dictionaryPersistenceService.getCumulatedTypes(dossierTemplateId, dossierId);
|
||||
for (TypeEntity res : typeResponse) {
|
||||
if (!typeId.equals(res.getId()) && labelToCheck.equals(res.getLabel())) {
|
||||
if (res.getDossierId() != null && res.getDossierId().equals(dossierId) && !type.equals(res.getType()) && res.getDossierTemplateId().equals(dossierTemplateId) && labelToCheck.equals(res.getLabel())
|
||||
|| !type.equals(res.getType()) && res.getDossierTemplateId().equals(dossierTemplateId) && labelToCheck.equals(res.getLabel())) {
|
||||
throw new ConflictException("Label must be unique.");
|
||||
}
|
||||
}
|
||||
@ -298,7 +301,7 @@ public class DictionaryController implements DictionaryResource {
|
||||
str = str.replaceAll("_+?", " ");
|
||||
str = str.replaceAll(" +", " ");
|
||||
|
||||
StringBuffer strbf = new StringBuffer();
|
||||
StringBuilder strbf = new StringBuilder();
|
||||
Matcher match = Pattern.compile("([a-z])([a-z]*)", Pattern.CASE_INSENSITIVE).matcher(str);
|
||||
while (match.find()) {
|
||||
match.appendReplacement(strbf, match.group(1).toUpperCase() + match.group(2));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user