Commit 1dc79171 authored by Enriko Käsper's avatar Enriko Käsper
Browse files

Merge branch 'develop' into 'master'

Release: merge 'develop' into 'master' created by Enriko Käsper

See merge request teis/classifiers-service!58
parents 1050eaf5 a973276f
theGroup=ee.sm.ti.teis
theVersion=1.10.0
theVersion=1.11.0
commonsVersion=1.10.0
commonApiGatewayVersion=1.8.0
officeApiGatewayVersion=1.8.0
commonApiGatewayVersion=1.11.0
officeApiGatewayVersion=1.11.0
schedulerVersion=1.5.0
pluginVersion=1.1.1
mapstructVersion=1.3.0.Final
......
......@@ -107,11 +107,21 @@ public class ClassifierItemBusinessService {
upperClassifier = classifierItemDataService.getUpperClassifierBySeqNo(definition.getId(), classifierItem.getSeqNo());
}
if (upperClassifier.isEmpty()) {
classifierItem = setSeqNoIfNull(classifierItem);
return List.of(classifierItemMapper.toOfficeDto(classifierItem));
}
return getShiftedClassifierDto(classifierItem, upperClassifier.get(), requestMetaDTO);
}
private ClassifierItemEntity setSeqNoIfNull(ClassifierItemEntity classifierItem) {
if (classifierItem.getSeqNo() == null) {
Long seqNumber = classifierItemDataService.getSeqNoByDefinition(classifierItem.getClassifierDefinition().getId());
classifierItem.setSeqNo(seqNumber + 1);
classifierItem = classifierItemDataService.save(classifierItem);
}
return classifierItem;
}
private List<ClassifierItemOfficeDto> shiftClassifierDown(ClassifierItemEntity classifierItem, ClassifierDefinitionEntity definition, RequestMetaDTO requestMetaDTO) {
Optional<ClassifierItemEntity> lowerClassifier;
if (definition.isHierarchical()) {
......@@ -122,16 +132,20 @@ public class ClassifierItemBusinessService {
lowerClassifier = classifierItemDataService.getLowerClassifierBySeqNo(definition.getId(), classifierItem.getSeqNo());
}
if (lowerClassifier.isEmpty()) {
classifierItem = setSeqNoIfNull(classifierItem);
return List.of(classifierItemMapper.toOfficeDto(classifierItem));
}
return getShiftedClassifierDto(classifierItem, lowerClassifier.get(), requestMetaDTO);
}
private List<ClassifierItemOfficeDto> getShiftedClassifierDto(ClassifierItemEntity shiftedClassifier, ClassifierItemEntity shiftingClassifier, RequestMetaDTO requestMetaDTO) {
Long upperSeqNo = shiftingClassifier.getSeqNo();
Long lowerSeqNo = shiftedClassifier.getSeqNo();
shiftedClassifier.setSeqNo(upperSeqNo);
if (shiftedClassifier.getSeqNo() == null) {
setSeqNoIfNull(shiftedClassifier);
} else {
shiftedClassifier.setSeqNo(upperSeqNo);
}
shiftingClassifier.setSeqNo(lowerSeqNo);
classifierItemDataService.save(shiftingClassifier);
classifierItemDataService.save(shiftedClassifier);
......
......@@ -110,6 +110,9 @@ public class ClassifierItemDataService {
if (StringUtils.isNotEmpty(search.getItemCode())) {
where.and(qClassifierItemEntity.code.equalsIgnoreCase(trim(search.getItemCode())));
}
if (search.getItemName() != null) {
where.and(qClassifierItemEntity.name.containsIgnoreCase(search.getItemName()));
}
if (StringUtils.isNotEmpty(search.getAttributeCode())) {
where.and(qClassifierItemEntity.attributes.any().classifierAttributeDefinition.code.equalsIgnoreCase(trim(search.getAttributeCode())));
where.and(qClassifierItemEntity.attributes.any().value.equalsIgnoreCase(trim(search.getAttributeValue())));
......
--liquibase formatted sql
--changeset hando:2020-09-14.add-vocabulary
INSERT INTO classifier_definition (id, default_value, editable, name, hierarchical, ordered, description )
VALUES ('VOCABULARY', null, true, 'Terminite selgitused', false, false, 'Tekstides kasutatavate terminite sõnastik');
\ No newline at end of file
......@@ -9,6 +9,7 @@ DELETE FROM classifier_item_link WHERE source_classifier_item_id LIKE 'TEST_%';
DELETE FROM classifier_item_link WHERE target_classifier_item_id LIKE 'TEST_%';
DELETE FROM classifier_item WHERE (classifier_definition_id != 'EMTAK' AND seq_no >= 10000000)
OR classifier_definition_id LIKE 'TEST_%' OR code LIKE 'PLACEHOLDER_FOR_TESTING%';
DELETE FROM classifier_item WHERE name LIKE 'TEST%';
DELETE FROM classifier_definition WHERE id LIKE 'TEST_%';
DELETE FROM classifier_attribute_definition WHERE id LIKE 'TEST_%';
......@@ -48,6 +49,7 @@ VALUES
('TEST_EDITABLENONHIERARCHICAL__TEST003','TEST_EDITABLENONHIERARCHICAL', 'TEST003',TRUE, 'Testimiseks loodud klaasifikaator','CURRENT',100000003,null,now(),null, null),
('TEST_EDITABLENONHIERARCHICAL__TEST002','TEST_EDITABLENONHIERARCHICAL', 'TEST002',TRUE, 'Testimiseks loodud klaasifikaator','DELETED',100000002,null,now(),null, null),
('TEST_EDITABLEHIERARCHICAL_2__TEST004','TEST_EDITABLEHIERARCHICAL_2', 'TEST004',TRUE, 'Testimiseks loodud klaasifikaator','CURRENT',100000001,null,now(),null, 1),
('TEST_EDITABLEHIERARCHICAL_2__TEST006','TEST_EDITABLEHIERARCHICAL_2', 'TEST006',TRUE, 'Testimiseks loodud klaasifikaator, seqNo null','CURRENT',null,null,now(),null, 1),
('TEST_NONEDITABLEHIERARCHICAL__TEST005','TEST_NONEDITABLEHIERARCHICAL', 'TEST005',TRUE, 'Testimiseks loodud klaasifikaator','CURRENT',100000004,null,now(),null, 1),
('INSPECTION_DOCUMENT__001','INSPECTION_DOCUMENT', '001',TRUE, 'Töökeskkonna riskianalüüs ja kirjalik tegevuskava terviseriskide vähendamiseks','CURRENT',100000001,null,now(),null, 1),
('INSPECTION_DOCUMENT__002','INSPECTION_DOCUMENT', '002',TRUE, 'Töökeskkonna sisekontrolli korraldus ja tulemuse','CURRENT',100000002, null, now(), null, null),
......@@ -148,3 +150,6 @@ VALUES
INSERT INTO classifier_item_link(id,source_classifier_item_id,target_classifier_item_id) VALUES
('dd68d8cd-1a36-476a-bfbf-dbfe8b828586','TEST_NONEDITABLEHIERARCHICAL__TEST005','VIOLATION_LEGISLATION__SK_LASKETIIRUD_RA1');
INSERT INTO classifier_item (id, classifier_definition_id, code, editable, name, object_status, seq_no, upper_classifier_item_id, valid_from, valid_until, level)
VALUES ('VOCABULARY__RISK', 'VOCABULARY', 'RISK', false, 'TEST See on ohu selgitus', 'CURRENT', 12, null, now(), null, null),
('VOCABULARY__OH', 'VOCABULARY', 'OH', false, 'TEST See on töötervishoiu selgitus', 'CURRENT', 12, null, now(), null, null);
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment