RED-2836: Added hasDictionary and systemManaged to entities
This commit is contained in:
parent
231b2034bc
commit
4d4840bbc2
@ -32,6 +32,8 @@ public class Type {
|
||||
private List<DictionaryEntry> entries = new ArrayList<>();
|
||||
private List<DictionaryEntry> falsePositiveEntries = new ArrayList<>();
|
||||
private List<DictionaryEntry> falseRecommendationEntries = new ArrayList<>();
|
||||
private boolean hasDictionary;
|
||||
private boolean systemManaged;
|
||||
|
||||
// For auto-mappers
|
||||
@JsonIgnore
|
||||
|
||||
@ -58,6 +58,10 @@ public class TypeEntity {
|
||||
private long version;
|
||||
@Column
|
||||
private boolean addToDictionaryAction;
|
||||
@Column
|
||||
private boolean hasDictionary;
|
||||
@Column
|
||||
private boolean systemManaged;
|
||||
|
||||
@Fetch(FetchMode.SUBSELECT)
|
||||
@BatchSize(size=500)
|
||||
|
||||
@ -131,7 +131,7 @@ public class DossierTemplateCloneService {
|
||||
List<TypeEntity> clonedTypes = new ArrayList<>();
|
||||
var types = dictionaryPersistenceService.getAllTypesForDossierTemplate(dossierTemplateId);
|
||||
for (TypeEntity t : types) {
|
||||
TypeEntity te = dictionaryPersistenceService.addType(t.getType(), clonedDossierTemplateId, t.getHexColor(), t.getRecommendationHexColor(), t.getRank(), t.isHint(), t.isCaseInsensitive(), t.isRecommendation(), t.getDescription(), t.isAddToDictionaryAction(), t.getLabel(), null);
|
||||
TypeEntity te = dictionaryPersistenceService.addType(t.getType(), clonedDossierTemplateId, t.getHexColor(), t.getRecommendationHexColor(), t.getRank(), t.isHint(), t.isCaseInsensitive(), t.isRecommendation(), t.getDescription(), t.isAddToDictionaryAction(), t.getLabel(), null, t.isHasDictionary(), t.isSystemManaged());
|
||||
te.setDossierTemplateId(clonedDossierTemplateId);
|
||||
clonedTypes.add(te);
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ public class DictionaryPersistenceService {
|
||||
|
||||
|
||||
public TypeEntity addType(String type, String dossierTemplateId, String hexColor, String recommendationHexColor, int rank, boolean isHint, boolean caseInsensitive, boolean isRecommendation,
|
||||
String description, boolean addToDictionaryAction, String label, String dossierId) {
|
||||
String description, boolean addToDictionaryAction, String label, String dossierId, boolean hasDictionary, boolean systemManaged) {
|
||||
|
||||
checkRankAlreadyExists(type, dossierTemplateId, rank, dossierId);
|
||||
|
||||
@ -55,6 +55,8 @@ public class DictionaryPersistenceService {
|
||||
.addToDictionaryAction(addToDictionaryAction)
|
||||
.label(label)
|
||||
.version(1)
|
||||
.hasDictionary(hasDictionary)
|
||||
.systemManaged(systemManaged)
|
||||
.build();
|
||||
|
||||
return typeRepository.save(t);
|
||||
|
||||
@ -70,6 +70,9 @@ public class DictionaryController implements DictionaryResource {
|
||||
|
||||
// To check whether the type exists, type should not be added into database implicitly by addEntry.
|
||||
Type typeResult = convert(dictionaryPersistenceService.getType(typeId), Type.class);
|
||||
if (!typeResult.isHasDictionary()){
|
||||
throw new BadRequestException("Entity type does not have a dictionary");
|
||||
}
|
||||
|
||||
var currentVersion = getCurrentVersion(typeResult);
|
||||
|
||||
@ -204,7 +207,7 @@ public class DictionaryController implements DictionaryResource {
|
||||
validateColor(color);
|
||||
return convert(dictionaryPersistenceService.addType(typeRequest.getType(), typeRequest.getDossierTemplateId(), color, typeRequest.getRecommendationHexColor(), typeRequest
|
||||
.getRank(), typeRequest.isHint(), typeRequest.isCaseInsensitive(), typeRequest.isRecommendation(), typeRequest
|
||||
.getDescription(), typeRequest.isAddToDictionaryAction(), typeRequest.getLabel(), typeRequest.getDossierId()), Type.class);
|
||||
.getDescription(), typeRequest.isAddToDictionaryAction(), typeRequest.getLabel(), typeRequest.getDossierId(), typeRequest.isHasDictionary(), typeRequest.isSystemManaged()), Type.class);
|
||||
}
|
||||
|
||||
|
||||
@ -213,6 +216,9 @@ public class DictionaryController implements DictionaryResource {
|
||||
|
||||
// NotFoundException would be thrown if the type not found in database.
|
||||
Type typeResult = convert(dictionaryPersistenceService.getType(typeId), Type.class);
|
||||
if(typeResult.isSystemManaged()){
|
||||
throw new BadRequestException("Can not delete system managed entity type");
|
||||
}
|
||||
|
||||
var currentVersion = getCurrentVersion(typeResult);
|
||||
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
databaseChangeLog:
|
||||
- changeSet:
|
||||
id: add-has-dictionary
|
||||
author: dom
|
||||
changes:
|
||||
- addColumn:
|
||||
columns:
|
||||
- column:
|
||||
name: has_dictionary
|
||||
type: BOOLEAN
|
||||
- column:
|
||||
name: system_managed
|
||||
type: BOOLEAN
|
||||
tableName: entity
|
||||
@ -37,5 +37,5 @@ databaseChangeLog:
|
||||
file: db/changelog/14-add-redaction-source-id.changelog.yaml
|
||||
- include:
|
||||
file: db/changelog/15-dossier-remove-dossier-state.changelog.yaml
|
||||
|
||||
|
||||
- include:
|
||||
file: db/changelog/16-added-has-dictionary-to-entities.changelog.yaml
|
||||
@ -29,6 +29,8 @@ public class TypeProvider {
|
||||
type.setRecommendation(false);
|
||||
type.setCaseInsensitive(true);
|
||||
type.setDossierTemplateId(dossierTemplate.getId());
|
||||
type.setHasDictionary(true);
|
||||
type.setSystemManaged(false);
|
||||
type.setDossierId(dossier != null ? dossier.getId() : null);
|
||||
|
||||
var createdType = dictionaryClient.addType(type);
|
||||
|
||||
@ -73,6 +73,8 @@ public class DossierTemplateStatsTest extends AbstractPersistenceServerServiceTe
|
||||
.addToDictionaryAction(false)
|
||||
.dossierTemplateId(dossierTemplate2.getId())
|
||||
.dossierId(null)
|
||||
.hasDictionary(true)
|
||||
.systemManaged(false)
|
||||
.build());
|
||||
|
||||
assertThat(addedType).isNotNull();
|
||||
@ -93,6 +95,8 @@ public class DossierTemplateStatsTest extends AbstractPersistenceServerServiceTe
|
||||
.addToDictionaryAction(false)
|
||||
.dossierTemplateId(dossierTemplate2.getId())
|
||||
.dossierId(null)
|
||||
.hasDictionary(true)
|
||||
.systemManaged(false)
|
||||
.build());
|
||||
var entries2 = new ArrayList<String>();
|
||||
entries2.add("entry1");
|
||||
@ -113,6 +117,8 @@ public class DossierTemplateStatsTest extends AbstractPersistenceServerServiceTe
|
||||
.addToDictionaryAction(false)
|
||||
.dossierTemplateId(dossierTemplate3.getId())
|
||||
.dossierId(null)
|
||||
.hasDictionary(true)
|
||||
.systemManaged(false)
|
||||
.build());
|
||||
|
||||
assertThat(addedType3).isNotNull();
|
||||
@ -136,6 +142,8 @@ public class DossierTemplateStatsTest extends AbstractPersistenceServerServiceTe
|
||||
.description("Something")
|
||||
.addToDictionaryAction(false)
|
||||
.dossierTemplateId(dossierTemplate5.getId())
|
||||
.hasDictionary(true)
|
||||
.systemManaged(false)
|
||||
.build());
|
||||
assertThat(addedType5).isNotNull();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user