detect touch state from description-editor's form-field
This commit is contained in:
commit
ec512727cf
|
@ -23,7 +23,7 @@ import org.opencdmp.commons.scope.user.UserScope;
|
||||||
import org.opencdmp.elastic.data.DescriptionElasticEntity;
|
import org.opencdmp.elastic.data.DescriptionElasticEntity;
|
||||||
import org.opencdmp.elastic.data.DmpElasticEntity;
|
import org.opencdmp.elastic.data.DmpElasticEntity;
|
||||||
import org.opencdmp.elastic.data.nested.NestedDmpElasticEntity;
|
import org.opencdmp.elastic.data.nested.NestedDmpElasticEntity;
|
||||||
import org.opencdmp.service.elastic.AppElasticProperties;
|
import org.opencdmp.service.elastic.AppElasticConfiguration;
|
||||||
import org.opencdmp.service.elastic.ElasticService;
|
import org.opencdmp.service.elastic.ElasticService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.config.BeanDefinition;
|
import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
|
@ -135,16 +135,16 @@ public class DescriptionElasticQuery extends ElasticQuery<DescriptionElasticEnti
|
||||||
}
|
}
|
||||||
|
|
||||||
private final QueryFactory queryFactory;
|
private final QueryFactory queryFactory;
|
||||||
private final AppElasticProperties appElasticProperties;
|
private final AppElasticConfiguration appElasticConfiguration;
|
||||||
private final ElasticService elasticService;
|
private final ElasticService elasticService;
|
||||||
private final UserScope userScope;
|
private final UserScope userScope;
|
||||||
private final TenantScope tenantScope;
|
private final TenantScope tenantScope;
|
||||||
private final AuthorizationService authService;
|
private final AuthorizationService authService;
|
||||||
@Autowired
|
@Autowired
|
||||||
public DescriptionElasticQuery(ElasticsearchTemplate elasticsearchTemplate, ElasticProperties elasticProperties, QueryFactory queryFactory, AppElasticProperties appElasticProperties, ElasticService elasticService, UserScope userScope, TenantScope tenantScope, AuthorizationService authService) {
|
public DescriptionElasticQuery(ElasticsearchTemplate elasticsearchTemplate, ElasticProperties elasticProperties, QueryFactory queryFactory, AppElasticConfiguration appElasticConfiguration, ElasticService elasticService, UserScope userScope, TenantScope tenantScope, AuthorizationService authService) {
|
||||||
super(elasticsearchTemplate, elasticProperties);
|
super(elasticsearchTemplate, elasticProperties);
|
||||||
this.queryFactory = queryFactory;
|
this.queryFactory = queryFactory;
|
||||||
this.appElasticProperties = appElasticProperties;
|
this.appElasticConfiguration = appElasticConfiguration;
|
||||||
this.elasticService = elasticService;
|
this.elasticService = elasticService;
|
||||||
this.userScope = userScope;
|
this.userScope = userScope;
|
||||||
this.tenantScope = tenantScope;
|
this.tenantScope = tenantScope;
|
||||||
|
@ -306,7 +306,7 @@ public class DescriptionElasticQuery extends ElasticQuery<DescriptionElasticEnti
|
||||||
@Override
|
@Override
|
||||||
protected String[] getIndex() {
|
protected String[] getIndex() {
|
||||||
List<String> indexNames = new ArrayList<>();
|
List<String> indexNames = new ArrayList<>();
|
||||||
indexNames.add(this.appElasticProperties.getDescriptionIndexName());
|
indexNames.add(this.appElasticConfiguration.getAppElasticProperties().getDescriptionIndexName());
|
||||||
try {
|
try {
|
||||||
this.elasticService.ensureDescriptionIndex();
|
this.elasticService.ensureDescriptionIndex();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.opencdmp.commons.scope.tenant.TenantScope;
|
||||||
import org.opencdmp.commons.scope.user.UserScope;
|
import org.opencdmp.commons.scope.user.UserScope;
|
||||||
import org.opencdmp.elastic.data.DmpElasticEntity;
|
import org.opencdmp.elastic.data.DmpElasticEntity;
|
||||||
import org.opencdmp.elastic.data.nested.NestedDescriptionElasticEntity;
|
import org.opencdmp.elastic.data.nested.NestedDescriptionElasticEntity;
|
||||||
import org.opencdmp.service.elastic.AppElasticProperties;
|
import org.opencdmp.service.elastic.AppElasticConfiguration;
|
||||||
import org.opencdmp.service.elastic.ElasticService;
|
import org.opencdmp.service.elastic.ElasticService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.config.BeanDefinition;
|
import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
|
@ -184,16 +184,16 @@ public class DmpElasticQuery extends ElasticQuery<DmpElasticEntity, UUID> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private final QueryFactory queryFactory;
|
private final QueryFactory queryFactory;
|
||||||
private final AppElasticProperties appElasticProperties;
|
private final AppElasticConfiguration appElasticConfiguration;
|
||||||
private final ElasticService elasticService;
|
private final ElasticService elasticService;
|
||||||
private final UserScope userScope;
|
private final UserScope userScope;
|
||||||
private final TenantScope tenantScope;
|
private final TenantScope tenantScope;
|
||||||
private final AuthorizationService authService;
|
private final AuthorizationService authService;
|
||||||
@Autowired
|
@Autowired
|
||||||
public DmpElasticQuery(ElasticsearchTemplate elasticsearchTemplate, ElasticProperties elasticProperties, QueryFactory queryFactory, AppElasticProperties appElasticProperties, ElasticService elasticService, UserScope userScope, TenantScope tenantScope, AuthorizationService authService) {
|
public DmpElasticQuery(ElasticsearchTemplate elasticsearchTemplate, ElasticProperties elasticProperties, QueryFactory queryFactory, AppElasticConfiguration appElasticConfiguration, ElasticService elasticService, UserScope userScope, TenantScope tenantScope, AuthorizationService authService) {
|
||||||
super(elasticsearchTemplate, elasticProperties);
|
super(elasticsearchTemplate, elasticProperties);
|
||||||
this.queryFactory = queryFactory;
|
this.queryFactory = queryFactory;
|
||||||
this.appElasticProperties = appElasticProperties;
|
this.appElasticConfiguration = appElasticConfiguration;
|
||||||
this.elasticService = elasticService;
|
this.elasticService = elasticService;
|
||||||
this.userScope = userScope;
|
this.userScope = userScope;
|
||||||
this.tenantScope = tenantScope;
|
this.tenantScope = tenantScope;
|
||||||
|
@ -369,7 +369,7 @@ public class DmpElasticQuery extends ElasticQuery<DmpElasticEntity, UUID> {
|
||||||
@Override
|
@Override
|
||||||
protected String[] getIndex() {
|
protected String[] getIndex() {
|
||||||
List<String> indexNames = new ArrayList<>();
|
List<String> indexNames = new ArrayList<>();
|
||||||
indexNames.add(this.appElasticProperties.getDmpIndexName());
|
indexNames.add(this.appElasticConfiguration.getAppElasticProperties().getDmpIndexName());
|
||||||
try {
|
try {
|
||||||
this.elasticService.ensureDescriptionIndex();
|
this.elasticService.ensureDescriptionIndex();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import gr.cite.tools.exception.MyValidationException;
|
import gr.cite.tools.exception.MyValidationException;
|
||||||
import gr.cite.tools.fieldset.FieldSet;
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
import jakarta.xml.bind.JAXBException;
|
import jakarta.xml.bind.JAXBException;
|
||||||
|
import org.opencdmp.commonmodels.models.dmpblueprint.DmpBlueprintModel;
|
||||||
import org.opencdmp.commons.enums.DmpBlueprintSystemFieldType;
|
import org.opencdmp.commons.enums.DmpBlueprintSystemFieldType;
|
||||||
import org.opencdmp.commons.types.dmpblueprint.importexport.BlueprintImportExport;
|
import org.opencdmp.commons.types.dmpblueprint.importexport.BlueprintImportExport;
|
||||||
import org.opencdmp.data.DmpBlueprintEntity;
|
import org.opencdmp.data.DmpBlueprintEntity;
|
||||||
|
@ -42,4 +43,5 @@ public interface DmpBlueprintService {
|
||||||
DmpBlueprint importXml(BlueprintImportExport dmpDefinition, UUID groupId, String label, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException;
|
DmpBlueprint importXml(BlueprintImportExport dmpDefinition, UUID groupId, String label, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException;
|
||||||
|
|
||||||
DmpBlueprint importXml(byte[] bytes, UUID groupId, String label, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException;
|
DmpBlueprint importXml(byte[] bytes, UUID groupId, String label, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException;
|
||||||
|
DmpBlueprint importCommonModel(DmpBlueprintModel dmpDefinition, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import jakarta.xml.bind.JAXBException;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.opencdmp.authorization.AuthorizationFlags;
|
import org.opencdmp.authorization.AuthorizationFlags;
|
||||||
import org.opencdmp.authorization.Permission;
|
import org.opencdmp.authorization.Permission;
|
||||||
|
import org.opencdmp.commonmodels.models.dmpblueprint.*;
|
||||||
import org.opencdmp.commons.XmlHandlingService;
|
import org.opencdmp.commons.XmlHandlingService;
|
||||||
import org.opencdmp.commons.enums.*;
|
import org.opencdmp.commons.enums.*;
|
||||||
import org.opencdmp.commons.scope.tenant.TenantScope;
|
import org.opencdmp.commons.scope.tenant.TenantScope;
|
||||||
|
@ -804,5 +805,188 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
//region Import RDA Json
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DmpBlueprint importCommonModel(DmpBlueprintModel dmpDefinition, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException {
|
||||||
|
logger.debug(new MapLogEntry("import data").And("dmpDefinition", dmpDefinition).And("fields", fields));
|
||||||
|
|
||||||
|
this.authorizationService.authorizeForce(Permission.ImportDmpBlueprint);
|
||||||
|
|
||||||
|
long activeBlueprintForTheGroup = dmpDefinition.getGroupId() != null ? this.queryFactory.query(DmpBlueprintQuery.class).disableTracking()
|
||||||
|
.isActive(IsActive.Active)
|
||||||
|
.groupIds(dmpDefinition.getGroupId())
|
||||||
|
.count() : 0;
|
||||||
|
|
||||||
|
if (activeBlueprintForTheGroup == 0) {
|
||||||
|
DmpBlueprintPersist persist = new DmpBlueprintPersist();
|
||||||
|
|
||||||
|
persist.setLabel(dmpDefinition.getLabel());
|
||||||
|
persist.setStatus(DmpBlueprintStatus.Draft);
|
||||||
|
persist.setDefinition(this.commonModelDefinitionToPersist(dmpDefinition.getDefinition()));
|
||||||
|
|
||||||
|
this.validatorFactory.validator(DmpBlueprintPersist.DmpBlueprintPersistValidator.class).validateForce(persist);
|
||||||
|
return this.persist(persist, dmpDefinition.getGroupId(), fields);
|
||||||
|
} else {
|
||||||
|
DmpBlueprintEntity latestVersionDmpBlueprint = this.queryFactory.query(DmpBlueprintQuery.class)
|
||||||
|
.disableTracking()
|
||||||
|
.versionStatuses(DmpBlueprintVersionStatus.Current)
|
||||||
|
.isActive(IsActive.Active)
|
||||||
|
.statuses(DmpBlueprintStatus.Finalized)
|
||||||
|
.groupIds(dmpDefinition.getGroupId())
|
||||||
|
.first();
|
||||||
|
if (latestVersionDmpBlueprint == null) throw new MyValidationException(this.errors.getDmpIsNotFinalized().getCode(), this.errors.getDmpIsNotFinalized().getMessage());
|
||||||
|
NewVersionDmpBlueprintPersist persist = new NewVersionDmpBlueprintPersist();
|
||||||
|
persist.setId(latestVersionDmpBlueprint.getId());
|
||||||
|
persist.setLabel(dmpDefinition.getLabel());
|
||||||
|
persist.setStatus(DmpBlueprintStatus.Draft);
|
||||||
|
persist.setDefinition(this.commonModelDefinitionToPersist(dmpDefinition.getDefinition()));
|
||||||
|
persist.setHash(this.conventionService.hashValue(latestVersionDmpBlueprint.getUpdatedAt()));
|
||||||
|
|
||||||
|
this.validatorFactory.validator(NewVersionDmpBlueprintPersist.NewVersionDmpBlueprintPersistValidator.class).validateForce(persist);
|
||||||
|
return this.createNewVersion(persist, fields);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private DefinitionPersist commonModelDefinitionToPersist(DefinitionModel commonModel) {
|
||||||
|
if (commonModel == null)
|
||||||
|
return null;
|
||||||
|
DefinitionPersist persist = new DefinitionPersist();
|
||||||
|
List<SectionPersist> dmpBlueprintSections = new ArrayList<>();
|
||||||
|
if (!this.conventionService.isListNullOrEmpty(commonModel.getSections())) {
|
||||||
|
for (SectionModel section : commonModel.getSections()) {
|
||||||
|
dmpBlueprintSections.add(this.commonModelSectionToPersist(section));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
persist.setSections(dmpBlueprintSections);
|
||||||
|
return persist;
|
||||||
|
}
|
||||||
|
|
||||||
|
private SectionPersist commonModelSectionToPersist(SectionModel commonModel) {
|
||||||
|
SectionPersist persist = new SectionPersist();
|
||||||
|
persist.setId(commonModel.getId());
|
||||||
|
persist.setLabel(commonModel.getLabel());
|
||||||
|
persist.setDescription(commonModel.getDescription());
|
||||||
|
persist.setOrdinal(commonModel.getOrdinal());
|
||||||
|
persist.setHasTemplates(commonModel.getHasTemplates());
|
||||||
|
List<FieldPersist> dmpBlueprintFieldModels = new LinkedList<>();
|
||||||
|
if (!this.conventionService.isListNullOrEmpty(commonModel.getFields())) {
|
||||||
|
for (SystemFieldModel systemField : commonModel.getFields().stream().filter(x-> org.opencdmp.commonmodels.enums.DmpBlueprintFieldCategory.System.equals(x.getCategory())).map(x-> (SystemFieldModel)x).toList()) {
|
||||||
|
dmpBlueprintFieldModels.add(this.commonModelSystemFieldToPersist(systemField));
|
||||||
|
}
|
||||||
|
for (ReferenceTypeFieldModel referenceField : commonModel.getFields().stream().filter(x-> org.opencdmp.commonmodels.enums.DmpBlueprintFieldCategory.ReferenceType.equals(x.getCategory())).map(x-> (ReferenceTypeFieldModel)x).toList()) {
|
||||||
|
dmpBlueprintFieldModels.add(this.commonModelReferenceFieldToPersist(referenceField));
|
||||||
|
}
|
||||||
|
for (ExtraFieldModel extraField : commonModel.getFields().stream().filter(x-> org.opencdmp.commonmodels.enums.DmpBlueprintFieldCategory.Extra.equals(x.getCategory())).map(x-> (ExtraFieldModel)x).toList()) {
|
||||||
|
dmpBlueprintFieldModels.add(this.commonExtraFieldToPersist(extraField));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
persist.setFields(dmpBlueprintFieldModels);
|
||||||
|
// List<DescriptionTemplatePersist> dmpBlueprintDescriptionTemplates = new LinkedList<>();
|
||||||
|
// if (!this.conventionService.isListNullOrEmpty(importXml.getDescriptionTemplates())) {
|
||||||
|
// for (BlueprintDescriptionTemplateImportExport descriptionTemplate : importXml.getDescriptionTemplates()) {
|
||||||
|
// dmpBlueprintDescriptionTemplates.add(this.xmlDescriptionTemplateToPersist(descriptionTemplate));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// persist.setDescriptionTemplates(dmpBlueprintDescriptionTemplates);
|
||||||
|
//
|
||||||
|
// List<UUID> prefillingSources = new LinkedList<>();
|
||||||
|
// if (!this.conventionService.isListNullOrEmpty(importXml.getPrefillingSources())) {
|
||||||
|
// for (BlueprintPrefillingSourceImportExport prefillingSource : importXml.getPrefillingSources()) {
|
||||||
|
// prefillingSources.add(this.xmlPrefillingSourceToPersist(prefillingSource));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// persist.setPrefillingSourcesIds(prefillingSources);
|
||||||
|
return persist;
|
||||||
|
}
|
||||||
|
|
||||||
|
// private DescriptionTemplatePersist xmlDescriptionTemplateToPersist(BlueprintDescriptionTemplateImportExport importXml) {
|
||||||
|
// org.opencdmp.data.DescriptionTemplateEntity data = importXml.getDescriptionTemplateGroupId() != null ? this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking().groupIds(importXml.getDescriptionTemplateGroupId()).disableTracking().firstAs(new BaseFieldSet().ensure(DescriptionTemplate._groupId)) : null;
|
||||||
|
// if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{importXml.getDescriptionTemplateGroupId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
//
|
||||||
|
// DescriptionTemplatePersist persist = new DescriptionTemplatePersist();
|
||||||
|
// persist.setDescriptionTemplateGroupId(importXml.getDescriptionTemplateGroupId());
|
||||||
|
// persist.setLabel(importXml.getLabel());
|
||||||
|
// persist.setMinMultiplicity(importXml.getMinMultiplicity());
|
||||||
|
// persist.setMaxMultiplicity(importXml.getMaxMultiplicity());
|
||||||
|
// return persist;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private UUID xmlPrefillingSourceToPersist(BlueprintPrefillingSourceImportExport importXml) {
|
||||||
|
// org.opencdmp.data.PrefillingSourceEntity data = importXml.getId() != null ? this.queryFactory.query(PrefillingSourceQuery.class).disableTracking().ids(importXml.getId()).disableTracking().firstAs(new BaseFieldSet().ensure(PrefillingSource._id)) : null;
|
||||||
|
// if (data == null) {
|
||||||
|
// if (!this.conventionService.isNullOrEmpty(importXml.getCode())) data = this.queryFactory.query(PrefillingSourceQuery.class).disableTracking().codes(importXml.getCode()).disableTracking().firstAs(new BaseFieldSet().ensure(PrefillingSource._id));
|
||||||
|
// if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{importXml.getId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return data.getId();
|
||||||
|
// }
|
||||||
|
|
||||||
|
private FieldPersist commonExtraFieldToPersist(ExtraFieldModel commonModel) {
|
||||||
|
ExtraFieldPersist persist = new ExtraFieldPersist();
|
||||||
|
persist.setId(commonModel.getId());
|
||||||
|
persist.setCategory(DmpBlueprintFieldCategory.Extra);
|
||||||
|
switch (commonModel.getDataType()){
|
||||||
|
case Text -> persist.setDataType(DmpBlueprintExtraFieldDataType.Text);
|
||||||
|
case Date -> persist.setDataType(DmpBlueprintExtraFieldDataType.Date);
|
||||||
|
case Number -> persist.setDataType(DmpBlueprintExtraFieldDataType.Number);
|
||||||
|
case RichTex -> persist.setDataType(DmpBlueprintExtraFieldDataType.RichTex);
|
||||||
|
default -> throw new InternalError("unknown type: " + commonModel.getDataType());
|
||||||
|
}
|
||||||
|
persist.setLabel(commonModel.getLabel());
|
||||||
|
persist.setPlaceholder(commonModel.getPlaceholder());
|
||||||
|
persist.setDescription(commonModel.getDescription());
|
||||||
|
persist.setOrdinal(commonModel.getOrdinal());
|
||||||
|
persist.setRequired(commonModel.getRequired());
|
||||||
|
persist.setSemantics(commonModel.getSemantics());
|
||||||
|
return persist;
|
||||||
|
}
|
||||||
|
|
||||||
|
private FieldPersist commonModelSystemFieldToPersist(SystemFieldModel commonModel) {
|
||||||
|
SystemFieldPersist persist = new SystemFieldPersist();
|
||||||
|
persist.setId(commonModel.getId());
|
||||||
|
persist.setCategory(DmpBlueprintFieldCategory.System);
|
||||||
|
switch (commonModel.getSystemFieldType()){
|
||||||
|
case User -> persist.setSystemFieldType(DmpBlueprintSystemFieldType.User);
|
||||||
|
case AccessRights -> persist.setSystemFieldType(DmpBlueprintSystemFieldType.AccessRights);
|
||||||
|
case Contact -> persist.setSystemFieldType(DmpBlueprintSystemFieldType.Contact);
|
||||||
|
case Description -> persist.setSystemFieldType(DmpBlueprintSystemFieldType.Description);
|
||||||
|
case Language -> persist.setSystemFieldType(DmpBlueprintSystemFieldType.Language);
|
||||||
|
case Title -> persist.setSystemFieldType(DmpBlueprintSystemFieldType.Title);
|
||||||
|
default -> throw new InternalError("unknown type: " + commonModel.getSystemFieldType());
|
||||||
|
}
|
||||||
|
persist.setLabel(commonModel.getLabel());
|
||||||
|
persist.setPlaceholder(commonModel.getPlaceholder());
|
||||||
|
persist.setDescription(commonModel.getDescription());
|
||||||
|
persist.setOrdinal(commonModel.getOrdinal());
|
||||||
|
persist.setRequired(commonModel.getRequired());
|
||||||
|
persist.setSemantics(commonModel.getSemantics());
|
||||||
|
return persist;
|
||||||
|
}
|
||||||
|
|
||||||
|
private FieldPersist commonModelReferenceFieldToPersist(ReferenceTypeFieldModel commonModel) {
|
||||||
|
|
||||||
|
ReferenceTypeEntity data = commonModel.getReferenceType() != null && commonModel.getReferenceType().getId() != null ? this.queryFactory.query(ReferenceTypeQuery.class).disableTracking().ids(commonModel.getReferenceType().getId()).disableTracking().firstAs(new BaseFieldSet().ensure(ReferenceType._id)) : null;
|
||||||
|
if (data == null){
|
||||||
|
if (commonModel.getReferenceType() != null && !this.conventionService.isNullOrEmpty(commonModel.getReferenceType().getCode())) data = this.queryFactory.query(ReferenceTypeQuery.class).disableTracking().codes(commonModel.getReferenceType().getCode()).disableTracking().firstAs(new BaseFieldSet().ensure(ReferenceType._id));
|
||||||
|
if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{commonModel.getReferenceType().getCode(), ReferenceType.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
}
|
||||||
|
|
||||||
|
ReferenceTypeFieldPersist persist = new ReferenceTypeFieldPersist();
|
||||||
|
persist.setId(commonModel.getId());
|
||||||
|
persist.setCategory(DmpBlueprintFieldCategory.ReferenceType);
|
||||||
|
persist.setReferenceTypeId(data.getId());
|
||||||
|
persist.setLabel(commonModel.getLabel());
|
||||||
|
persist.setPlaceholder(commonModel.getPlaceholder());
|
||||||
|
persist.setDescription(commonModel.getDescription());
|
||||||
|
persist.setOrdinal(commonModel.getOrdinal());
|
||||||
|
persist.setRequired(commonModel.getRequired());
|
||||||
|
persist.setMultipleSelect(commonModel.getMultipleSelect());
|
||||||
|
persist.setSemantics(commonModel.getSemantics());
|
||||||
|
return persist;
|
||||||
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,16 +5,22 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableConfigurationProperties(AppElasticProperties.class)
|
@EnableConfigurationProperties({AppElasticProperties.class, ElasticQueryHelperServiceProperties.class })
|
||||||
public class AppElasticConfiguration {
|
public class AppElasticConfiguration {
|
||||||
private final AppElasticProperties properties;
|
private final AppElasticProperties appElasticProperties;
|
||||||
|
private final ElasticQueryHelperServiceProperties elasticQueryHelperServiceProperties;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public AppElasticConfiguration(AppElasticProperties properties) {
|
public AppElasticConfiguration(AppElasticProperties appElasticProperties, ElasticQueryHelperServiceProperties elasticQueryHelperServiceProperties) {
|
||||||
this.properties = properties;
|
this.appElasticProperties = appElasticProperties;
|
||||||
|
this.elasticQueryHelperServiceProperties = elasticQueryHelperServiceProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AppElasticProperties getProperties() {
|
public AppElasticProperties getAppElasticProperties() {
|
||||||
return properties;
|
return this.appElasticProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ElasticQueryHelperServiceProperties getElasticQueryHelperServiceProperties() {
|
||||||
|
return this.elasticQueryHelperServiceProperties;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ public class AppElasticProperties {
|
||||||
private boolean enableIcuAnalysisPlugin;
|
private boolean enableIcuAnalysisPlugin;
|
||||||
|
|
||||||
public String getDmpIndexName() {
|
public String getDmpIndexName() {
|
||||||
return dmpIndexName;
|
return this.dmpIndexName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDmpIndexName(String dmpIndexName) {
|
public void setDmpIndexName(String dmpIndexName) {
|
||||||
|
@ -19,7 +19,7 @@ public class AppElasticProperties {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEnableIcuAnalysisPlugin() {
|
public boolean isEnableIcuAnalysisPlugin() {
|
||||||
return enableIcuAnalysisPlugin;
|
return this.enableIcuAnalysisPlugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnableIcuAnalysisPlugin(boolean enableIcuAnalysisPlugin) {
|
public void setEnableIcuAnalysisPlugin(boolean enableIcuAnalysisPlugin) {
|
||||||
|
@ -27,7 +27,7 @@ public class AppElasticProperties {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
return enabled;
|
return this.enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnabled(boolean enabled) {
|
public void setEnabled(boolean enabled) {
|
||||||
|
@ -35,7 +35,7 @@ public class AppElasticProperties {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescriptionIndexName() {
|
public String getDescriptionIndexName() {
|
||||||
return descriptionIndexName;
|
return this.descriptionIndexName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescriptionIndexName(String descriptionIndexName) {
|
public void setDescriptionIndexName(String descriptionIndexName) {
|
||||||
|
@ -43,7 +43,7 @@ public class AppElasticProperties {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getResetBatchSize() {
|
public int getResetBatchSize() {
|
||||||
return resetBatchSize;
|
return this.resetBatchSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResetBatchSize(int resetBatchSize) {
|
public void setResetBatchSize(int resetBatchSize) {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
import gr.cite.tools.data.query.QueryFactory;
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
import gr.cite.tools.fieldset.BaseFieldSet;
|
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||||
import gr.cite.tools.fieldset.FieldSet;
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
import org.opencdmp.authorization.AuthorizationFlags;
|
import org.opencdmp.authorization.AuthorizationFlags;
|
||||||
import org.opencdmp.data.DescriptionEntity;
|
import org.opencdmp.data.DescriptionEntity;
|
||||||
import org.opencdmp.data.DmpEntity;
|
import org.opencdmp.data.DmpEntity;
|
||||||
|
@ -22,6 +23,7 @@ import org.opencdmp.query.DescriptionQuery;
|
||||||
import org.opencdmp.query.DmpQuery;
|
import org.opencdmp.query.DmpQuery;
|
||||||
import org.opencdmp.query.lookup.DescriptionLookup;
|
import org.opencdmp.query.lookup.DescriptionLookup;
|
||||||
import org.opencdmp.query.lookup.DmpLookup;
|
import org.opencdmp.query.lookup.DmpLookup;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
@ -30,14 +32,17 @@ import java.util.function.Function;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class ElasticQueryHelperServiceImpl implements ElasticQueryHelperService {
|
public class ElasticQueryHelperServiceImpl implements ElasticQueryHelperService {
|
||||||
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ElasticQueryHelperServiceImpl.class));
|
||||||
|
|
||||||
private final QueryFactory queryFactory;
|
private final QueryFactory queryFactory;
|
||||||
private final BuilderFactory builderFactory;
|
private final BuilderFactory builderFactory;
|
||||||
private final ElasticService elasticService;
|
private final ElasticService elasticService;
|
||||||
public ElasticQueryHelperServiceImpl(QueryFactory queryFactory, BuilderFactory builderFactory, ElasticService elasticService) {
|
private final AppElasticConfiguration appElasticConfiguration;
|
||||||
|
public ElasticQueryHelperServiceImpl(QueryFactory queryFactory, BuilderFactory builderFactory, ElasticService elasticService, AppElasticConfiguration appElasticConfiguration) {
|
||||||
this.queryFactory = queryFactory;
|
this.queryFactory = queryFactory;
|
||||||
this.builderFactory = builderFactory;
|
this.builderFactory = builderFactory;
|
||||||
this.elasticService = elasticService;
|
this.elasticService = elasticService;
|
||||||
|
this.appElasticConfiguration = appElasticConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -55,12 +60,25 @@ public class ElasticQueryHelperServiceImpl implements ElasticQueryHelperService
|
||||||
private <M> QueryResult<M> collect(DmpLookup lookup, Function<List<DmpEntity>, List<M>> buildFunc, EnumSet<AuthorizationFlags> flags) {
|
private <M> QueryResult<M> collect(DmpLookup lookup, Function<List<DmpEntity>, List<M>> buildFunc, EnumSet<AuthorizationFlags> flags) {
|
||||||
DmpQuery query = null;
|
DmpQuery query = null;
|
||||||
QueryResult<M> result = new QueryResult<>();
|
QueryResult<M> result = new QueryResult<>();
|
||||||
|
boolean elasticFilterUsed = false;
|
||||||
if (lookup.useElastic() && this.elasticService.enabled()){
|
if (lookup.useElastic() && this.elasticService.enabled()){
|
||||||
List<DmpElasticEntity> elasticResponse = lookup.enrichElastic(this.queryFactory).authorize(flags).collectAs(new BaseFieldSet().ensure(DmpElasticEntity._id));
|
try {
|
||||||
query = this.queryFactory.query(DmpQuery.class).authorize(flags).ids(elasticResponse.stream().map(DmpElasticEntity::getId).toList());
|
List<DmpElasticEntity> elasticResponse = lookup.enrichElastic(this.queryFactory).authorize(flags).collectAs(new BaseFieldSet().ensure(DmpElasticEntity._id));
|
||||||
query.setOrder(lookup.enrich(this.queryFactory).getOrder());
|
query = this.queryFactory.query(DmpQuery.class).authorize(flags).ids(elasticResponse.stream().map(DmpElasticEntity::getId).toList());
|
||||||
if (lookup.getMetadata() != null && lookup.getMetadata().countAll) result.setCount(lookup.enrichElastic(this.queryFactory).authorize(flags).count());
|
query.setOrder(lookup.enrich(this.queryFactory).getOrder());
|
||||||
} else {
|
if (lookup.getMetadata() != null && lookup.getMetadata().countAll) result.setCount(lookup.enrichElastic(this.queryFactory).authorize(flags).count());
|
||||||
|
elasticFilterUsed = true;
|
||||||
|
} catch (Exception e){
|
||||||
|
elasticFilterUsed = false;
|
||||||
|
if (this.appElasticConfiguration.getElasticQueryHelperServiceProperties().getEnableDbFallback()) {
|
||||||
|
logger.error(e.getMessage(), e);
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!elasticFilterUsed) {
|
||||||
query = lookup.enrich(this.queryFactory).disableTracking().authorize(flags);
|
query = lookup.enrich(this.queryFactory).disableTracking().authorize(flags);
|
||||||
if (lookup.getMetadata() != null && lookup.getMetadata().countAll) result.setCount(query.count());
|
if (lookup.getMetadata() != null && lookup.getMetadata().countAll) result.setCount(query.count());
|
||||||
}
|
}
|
||||||
|
@ -74,10 +92,17 @@ public class ElasticQueryHelperServiceImpl implements ElasticQueryHelperService
|
||||||
public long count(DmpLookup lookup, EnumSet<AuthorizationFlags> authorizationFlags) {
|
public long count(DmpLookup lookup, EnumSet<AuthorizationFlags> authorizationFlags) {
|
||||||
EnumSet<AuthorizationFlags> flags = authorizationFlags == null ? EnumSet.of(AuthorizationFlags.None) : authorizationFlags;
|
EnumSet<AuthorizationFlags> flags = authorizationFlags == null ? EnumSet.of(AuthorizationFlags.None) : authorizationFlags;
|
||||||
if (lookup.useElastic() && this.elasticService.enabled()){
|
if (lookup.useElastic() && this.elasticService.enabled()){
|
||||||
return lookup.enrichElastic(this.queryFactory).authorize(flags).count();
|
try {
|
||||||
} else {
|
return lookup.enrichElastic(this.queryFactory).authorize(flags).count();
|
||||||
return lookup.enrich(this.queryFactory).authorize(flags).count();
|
} catch (Exception e){
|
||||||
|
if (this.appElasticConfiguration.getElasticQueryHelperServiceProperties().getEnableDbFallback()) {
|
||||||
|
logger.error(e.getMessage(), e);
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return lookup.enrich(this.queryFactory).authorize(flags).count();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -96,12 +121,26 @@ public class ElasticQueryHelperServiceImpl implements ElasticQueryHelperService
|
||||||
private <M> QueryResult<M> collect(DescriptionLookup lookup, Function<List<DescriptionEntity>, List<M>> buildFunc, EnumSet<AuthorizationFlags> flags) {
|
private <M> QueryResult<M> collect(DescriptionLookup lookup, Function<List<DescriptionEntity>, List<M>> buildFunc, EnumSet<AuthorizationFlags> flags) {
|
||||||
DescriptionQuery query = null;
|
DescriptionQuery query = null;
|
||||||
QueryResult<M> result = new QueryResult<>();
|
QueryResult<M> result = new QueryResult<>();
|
||||||
|
boolean elasticFilterUsed = false;
|
||||||
if (lookup.useElastic() && this.elasticService.enabled()){
|
if (lookup.useElastic() && this.elasticService.enabled()){
|
||||||
List<DescriptionElasticEntity> elasticResponse = lookup.enrichElastic(this.queryFactory).authorize(flags).collectAs(new BaseFieldSet().ensure(DescriptionElasticEntity._id));
|
|
||||||
query = this.queryFactory.query(DescriptionQuery.class).authorize(flags).ids(elasticResponse.stream().map(DescriptionElasticEntity::getId).toList());
|
try {
|
||||||
query.setOrder(lookup.enrich(this.queryFactory).getOrder());
|
List<DescriptionElasticEntity> elasticResponse = lookup.enrichElastic(this.queryFactory).authorize(flags).collectAs(new BaseFieldSet().ensure(DescriptionElasticEntity._id));
|
||||||
if (lookup.getMetadata() != null && lookup.getMetadata().countAll) result.setCount(lookup.enrichElastic(this.queryFactory).authorize(flags).count());
|
query = this.queryFactory.query(DescriptionQuery.class).authorize(flags).ids(elasticResponse.stream().map(DescriptionElasticEntity::getId).toList());
|
||||||
} else {
|
query.setOrder(lookup.enrich(this.queryFactory).getOrder());
|
||||||
|
if (lookup.getMetadata() != null && lookup.getMetadata().countAll) result.setCount(lookup.enrichElastic(this.queryFactory).authorize(flags).count());
|
||||||
|
elasticFilterUsed = true;
|
||||||
|
} catch (Exception e){
|
||||||
|
elasticFilterUsed = false;
|
||||||
|
if (this.appElasticConfiguration.getElasticQueryHelperServiceProperties().getEnableDbFallback()) {
|
||||||
|
logger.error(e.getMessage(), e);
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (!elasticFilterUsed) {
|
||||||
query = lookup.enrich(this.queryFactory).disableTracking().authorize(flags);
|
query = lookup.enrich(this.queryFactory).disableTracking().authorize(flags);
|
||||||
if (lookup.getMetadata() != null && lookup.getMetadata().countAll) result.setCount(query.count());
|
if (lookup.getMetadata() != null && lookup.getMetadata().countAll) result.setCount(query.count());
|
||||||
}
|
}
|
||||||
|
@ -115,9 +154,16 @@ public class ElasticQueryHelperServiceImpl implements ElasticQueryHelperService
|
||||||
public long count(DescriptionLookup lookup, EnumSet<AuthorizationFlags> authorizationFlags) {
|
public long count(DescriptionLookup lookup, EnumSet<AuthorizationFlags> authorizationFlags) {
|
||||||
EnumSet<AuthorizationFlags> flags = authorizationFlags == null ? EnumSet.of(AuthorizationFlags.None) : authorizationFlags;
|
EnumSet<AuthorizationFlags> flags = authorizationFlags == null ? EnumSet.of(AuthorizationFlags.None) : authorizationFlags;
|
||||||
if (lookup.useElastic() && this.elasticService.enabled()){
|
if (lookup.useElastic() && this.elasticService.enabled()){
|
||||||
return lookup.enrichElastic(this.queryFactory).authorize(flags).count();
|
try {
|
||||||
} else {
|
return lookup.enrichElastic(this.queryFactory).authorize(flags).count();
|
||||||
return lookup.enrich(this.queryFactory).authorize(flags).count();
|
} catch (Exception e){
|
||||||
|
if (this.appElasticConfiguration.getElasticQueryHelperServiceProperties().getEnableDbFallback()) {
|
||||||
|
logger.error(e.getMessage(), e);
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return lookup.enrich(this.queryFactory).authorize(flags).count();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package org.opencdmp.service.elastic;
|
||||||
|
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
|
@ConfigurationProperties(prefix = "elastic-query-helper")
|
||||||
|
public class ElasticQueryHelperServiceProperties {
|
||||||
|
private boolean enableDbFallback;
|
||||||
|
|
||||||
|
public boolean getEnableDbFallback() {
|
||||||
|
return this.enableDbFallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnableDbFallback(boolean enableDbFallback) {
|
||||||
|
this.enableDbFallback = enableDbFallback;
|
||||||
|
}
|
||||||
|
}
|
|
@ -46,7 +46,7 @@ import java.util.Map;
|
||||||
@Service
|
@Service
|
||||||
public class ElasticServiceImpl implements ElasticService {
|
public class ElasticServiceImpl implements ElasticService {
|
||||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpBlueprintServiceImpl.class));
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpBlueprintServiceImpl.class));
|
||||||
public final AppElasticProperties appElasticProperties;
|
public final AppElasticConfiguration appElasticConfiguration;
|
||||||
private final ElasticsearchClient restHighLevelClient;
|
private final ElasticsearchClient restHighLevelClient;
|
||||||
private final ElasticsearchTemplate elasticsearchTemplate;
|
private final ElasticsearchTemplate elasticsearchTemplate;
|
||||||
private final QueryFactory queryFactory;
|
private final QueryFactory queryFactory;
|
||||||
|
@ -55,8 +55,8 @@ public class ElasticServiceImpl implements ElasticService {
|
||||||
private final MessageSource messageSource;
|
private final MessageSource messageSource;
|
||||||
private final AuthorizationService authorizationService;
|
private final AuthorizationService authorizationService;
|
||||||
|
|
||||||
public ElasticServiceImpl(AppElasticProperties appElasticProperties, ElasticsearchClient restHighLevelClient, ElasticsearchTemplate elasticsearchTemplate, QueryFactory queryFactory, BuilderFactory builderFactory, TenantEntityManager entityManager, MessageSource messageSource, AuthorizationService authorizationService) {
|
public ElasticServiceImpl(AppElasticConfiguration appElasticConfiguration, ElasticsearchClient restHighLevelClient, ElasticsearchTemplate elasticsearchTemplate, QueryFactory queryFactory, BuilderFactory builderFactory, TenantEntityManager entityManager, MessageSource messageSource, AuthorizationService authorizationService) {
|
||||||
this.appElasticProperties = appElasticProperties;
|
this.appElasticConfiguration = appElasticConfiguration;
|
||||||
this.restHighLevelClient = restHighLevelClient;
|
this.restHighLevelClient = restHighLevelClient;
|
||||||
this.elasticsearchTemplate = elasticsearchTemplate;
|
this.elasticsearchTemplate = elasticsearchTemplate;
|
||||||
this.queryFactory = queryFactory;
|
this.queryFactory = queryFactory;
|
||||||
|
@ -68,20 +68,20 @@ public class ElasticServiceImpl implements ElasticService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean enabled() {
|
public boolean enabled() {
|
||||||
return this.appElasticProperties.isEnabled();
|
return this.appElasticConfiguration.getAppElasticProperties().isEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean existsDmpIndex() throws IOException {
|
public boolean existsDmpIndex() throws IOException {
|
||||||
if (!this.enabled()) return false;
|
if (!this.enabled()) return false;
|
||||||
return this.restHighLevelClient.indices().exists(new ExistsRequest.Builder().index(this.appElasticProperties.getDmpIndexName()).includeDefaults(true).build()).value();
|
return this.restHighLevelClient.indices().exists(new ExistsRequest.Builder().index(this.appElasticConfiguration.getAppElasticProperties().getDmpIndexName()).includeDefaults(true).build()).value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean existsDescriptionIndex() throws IOException {
|
public boolean existsDescriptionIndex() throws IOException {
|
||||||
if (!this.enabled()) return false;
|
if (!this.enabled()) return false;
|
||||||
return this.restHighLevelClient.indices().exists(new ExistsRequest.Builder().index(this.appElasticProperties.getDescriptionIndexName()).includeDefaults(true).build()).value();
|
return this.restHighLevelClient.indices().exists(new ExistsRequest.Builder().index(this.appElasticConfiguration.getAppElasticProperties().getDescriptionIndexName()).includeDefaults(true).build()).value();
|
||||||
}
|
}
|
||||||
|
|
||||||
//region ensure index
|
//region ensure index
|
||||||
|
@ -92,7 +92,7 @@ public class ElasticServiceImpl implements ElasticService {
|
||||||
boolean exists = this.existsDmpIndex();
|
boolean exists = this.existsDmpIndex();
|
||||||
if (exists) return ;
|
if (exists) return ;
|
||||||
|
|
||||||
this.ensureIndex(this.appElasticProperties.getDmpIndexName(), this.createDmpTemplatePropertyMap());
|
this.ensureIndex(this.appElasticConfiguration.getAppElasticProperties().getDmpIndexName(), this.createDmpTemplatePropertyMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -100,7 +100,7 @@ public class ElasticServiceImpl implements ElasticService {
|
||||||
if (!this.enabled()) return ;
|
if (!this.enabled()) return ;
|
||||||
boolean exists = this.existsDescriptionIndex();
|
boolean exists = this.existsDescriptionIndex();
|
||||||
if (exists) return ;
|
if (exists) return ;
|
||||||
this.ensureIndex(this.appElasticProperties.getDescriptionIndexName(), this.createDescriptionTemplatePropertyMap());
|
this.ensureIndex(this.appElasticConfiguration.getAppElasticProperties().getDescriptionIndexName(), this.createDescriptionTemplatePropertyMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -120,7 +120,7 @@ public class ElasticServiceImpl implements ElasticService {
|
||||||
indexSettingsAnalysis.filter("english_stemmer", ((tf) -> tf.definition(tfdb -> tfdb.stemmer(stemmerBuilder -> stemmerBuilder.language("english")))))
|
indexSettingsAnalysis.filter("english_stemmer", ((tf) -> tf.definition(tfdb -> tfdb.stemmer(stemmerBuilder -> stemmerBuilder.language("english")))))
|
||||||
.filter("english_stop", tf -> tf.definition(tfdb -> tfdb.stop(stopTokenBuilder -> stopTokenBuilder)));
|
.filter("english_stop", tf -> tf.definition(tfdb -> tfdb.stop(stopTokenBuilder -> stopTokenBuilder)));
|
||||||
|
|
||||||
if (this.appElasticProperties.isEnableIcuAnalysisPlugin()){
|
if (this.appElasticConfiguration.getAppElasticProperties().isEnableIcuAnalysisPlugin()){
|
||||||
indexSettingsAnalysis.analyzer("icu_analyzer_text", ab -> ab.custom(x-> x.filter("icu_folding", "english_stop", "english_stemmer").tokenizer("icu_tokenizer")));
|
indexSettingsAnalysis.analyzer("icu_analyzer_text", ab -> ab.custom(x-> x.filter("icu_folding", "english_stop", "english_stemmer").tokenizer("icu_tokenizer")));
|
||||||
} else {
|
} else {
|
||||||
indexSettingsAnalysis.analyzer("icu_analyzer_text", ab -> ab.custom(x-> x.filter("icu_folding", "english_stop", "english_stemmer").tokenizer("standard")));
|
indexSettingsAnalysis.analyzer("icu_analyzer_text", ab -> ab.custom(x-> x.filter("icu_folding", "english_stop", "english_stemmer").tokenizer("standard")));
|
||||||
|
@ -291,23 +291,23 @@ public class ElasticServiceImpl implements ElasticService {
|
||||||
this.ensureIndexes();
|
this.ensureIndexes();
|
||||||
|
|
||||||
DmpElasticEntity dmpElasticEntity = this.builderFactory.builder(DmpElasticBuilder.class).build(dmp);
|
DmpElasticEntity dmpElasticEntity = this.builderFactory.builder(DmpElasticBuilder.class).build(dmp);
|
||||||
this.elasticsearchTemplate.save(dmpElasticEntity, IndexCoordinates.of(this.appElasticProperties.getDmpIndexName()));
|
this.elasticsearchTemplate.save(dmpElasticEntity, IndexCoordinates.of(this.appElasticConfiguration.getAppElasticProperties().getDmpIndexName()));
|
||||||
List<DescriptionElasticEntity> descriptions = this.builderFactory.builder(DescriptionElasticBuilder.class).build(this.queryFactory.query(DescriptionQuery.class).disableTracking().isActive(IsActive.Active).dmpSubQuery(this.queryFactory.query(DmpQuery.class).ids(dmp.getId())).collect());
|
List<DescriptionElasticEntity> descriptions = this.builderFactory.builder(DescriptionElasticBuilder.class).build(this.queryFactory.query(DescriptionQuery.class).disableTracking().isActive(IsActive.Active).dmpSubQuery(this.queryFactory.query(DmpQuery.class).ids(dmp.getId())).collect());
|
||||||
this.elasticsearchTemplate.save(descriptions, IndexCoordinates.of(this.appElasticProperties.getDescriptionIndexName()));
|
this.elasticsearchTemplate.save(descriptions, IndexCoordinates.of(this.appElasticConfiguration.getAppElasticProperties().getDescriptionIndexName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteDmp(DmpEntity dmp) throws IOException {
|
public void deleteDmp(DmpEntity dmp) throws IOException {
|
||||||
if (!this.enabled()) return;
|
if (!this.enabled()) return;
|
||||||
this.ensureIndexes();
|
this.ensureIndexes();
|
||||||
DmpElasticEntity dmpElasticEntity = this.elasticsearchTemplate.get(dmp.getId().toString(),DmpElasticEntity.class, IndexCoordinates.of(this.appElasticProperties.getDmpIndexName()));
|
DmpElasticEntity dmpElasticEntity = this.elasticsearchTemplate.get(dmp.getId().toString(),DmpElasticEntity.class, IndexCoordinates.of(this.appElasticConfiguration.getAppElasticProperties().getDmpIndexName()));
|
||||||
if (dmpElasticEntity == null) return;
|
if (dmpElasticEntity == null) return;
|
||||||
this.elasticsearchTemplate.delete(dmpElasticEntity, IndexCoordinates.of(this.appElasticProperties.getDmpIndexName()));
|
this.elasticsearchTemplate.delete(dmpElasticEntity, IndexCoordinates.of(this.appElasticConfiguration.getAppElasticProperties().getDmpIndexName()));
|
||||||
List<DescriptionEntity> descriptions = this.queryFactory.query(DescriptionQuery.class).dmpSubQuery(this.queryFactory.query(DmpQuery.class).disableTracking().ids(dmp.getId())).collectAs(new BaseFieldSet().ensure(Description._id));
|
List<DescriptionEntity> descriptions = this.queryFactory.query(DescriptionQuery.class).dmpSubQuery(this.queryFactory.query(DmpQuery.class).disableTracking().ids(dmp.getId())).collectAs(new BaseFieldSet().ensure(Description._id));
|
||||||
for (DescriptionEntity description: descriptions) {
|
for (DescriptionEntity description: descriptions) {
|
||||||
DescriptionElasticEntity descriptionElasticEntity = this.elasticsearchTemplate.get(description.getId().toString(), DescriptionElasticEntity.class, IndexCoordinates.of(this.appElasticProperties.getDescriptionIndexName()));
|
DescriptionElasticEntity descriptionElasticEntity = this.elasticsearchTemplate.get(description.getId().toString(), DescriptionElasticEntity.class, IndexCoordinates.of(this.appElasticConfiguration.getAppElasticProperties().getDescriptionIndexName()));
|
||||||
if (descriptionElasticEntity == null) continue;
|
if (descriptionElasticEntity == null) continue;
|
||||||
this.elasticsearchTemplate.delete(descriptionElasticEntity, IndexCoordinates.of(this.appElasticProperties.getDescriptionIndexName()));
|
this.elasticsearchTemplate.delete(descriptionElasticEntity, IndexCoordinates.of(this.appElasticConfiguration.getAppElasticProperties().getDescriptionIndexName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,12 +317,12 @@ public class ElasticServiceImpl implements ElasticService {
|
||||||
this.ensureIndexes();
|
this.ensureIndexes();
|
||||||
|
|
||||||
DescriptionElasticEntity descriptionElasticEntity = this.builderFactory.builder(DescriptionElasticBuilder.class).build(description);
|
DescriptionElasticEntity descriptionElasticEntity = this.builderFactory.builder(DescriptionElasticBuilder.class).build(description);
|
||||||
this.elasticsearchTemplate.save(descriptionElasticEntity, IndexCoordinates.of(this.appElasticProperties.getDescriptionIndexName()));
|
this.elasticsearchTemplate.save(descriptionElasticEntity, IndexCoordinates.of(this.appElasticConfiguration.getAppElasticProperties().getDescriptionIndexName()));
|
||||||
DmpEntity dmpEntity = this.entityManager.find(DmpEntity.class, description.getDmpId(), true);
|
DmpEntity dmpEntity = this.entityManager.find(DmpEntity.class, description.getDmpId(), true);
|
||||||
if (dmpEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{description.getDmpId(), Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (dmpEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{description.getDmpId(), Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
if (dmpEntity.getIsActive().equals(IsActive.Active)) {
|
if (dmpEntity.getIsActive().equals(IsActive.Active)) {
|
||||||
DmpElasticEntity dmpElasticEntity = this.builderFactory.builder(DmpElasticBuilder.class).build(dmpEntity);
|
DmpElasticEntity dmpElasticEntity = this.builderFactory.builder(DmpElasticBuilder.class).build(dmpEntity);
|
||||||
this.elasticsearchTemplate.save(dmpElasticEntity, IndexCoordinates.of(this.appElasticProperties.getDmpIndexName()));
|
this.elasticsearchTemplate.save(dmpElasticEntity, IndexCoordinates.of(this.appElasticConfiguration.getAppElasticProperties().getDmpIndexName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,15 +331,15 @@ public class ElasticServiceImpl implements ElasticService {
|
||||||
if (!this.enabled()) return;
|
if (!this.enabled()) return;
|
||||||
this.ensureIndexes();
|
this.ensureIndexes();
|
||||||
|
|
||||||
DescriptionElasticEntity descriptionElasticEntity = this.elasticsearchTemplate.get(description.getId().toString(), DescriptionElasticEntity.class, IndexCoordinates.of(this.appElasticProperties.getDescriptionIndexName()));
|
DescriptionElasticEntity descriptionElasticEntity = this.elasticsearchTemplate.get(description.getId().toString(), DescriptionElasticEntity.class, IndexCoordinates.of(this.appElasticConfiguration.getAppElasticProperties().getDescriptionIndexName()));
|
||||||
if (descriptionElasticEntity == null) return;
|
if (descriptionElasticEntity == null) return;
|
||||||
this.elasticsearchTemplate.delete(descriptionElasticEntity, IndexCoordinates.of(this.appElasticProperties.getDescriptionIndexName()));
|
this.elasticsearchTemplate.delete(descriptionElasticEntity, IndexCoordinates.of(this.appElasticConfiguration.getAppElasticProperties().getDescriptionIndexName()));
|
||||||
|
|
||||||
DmpEntity dmpEntity = this.entityManager.find(DmpEntity.class, description.getDmpId(), true);
|
DmpEntity dmpEntity = this.entityManager.find(DmpEntity.class, description.getDmpId(), true);
|
||||||
if (dmpEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{description.getDmpId(), Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (dmpEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{description.getDmpId(), Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
if (dmpEntity.getIsActive().equals(IsActive.Active)) {
|
if (dmpEntity.getIsActive().equals(IsActive.Active)) {
|
||||||
DmpElasticEntity dmpElasticEntity = this.builderFactory.builder(DmpElasticBuilder.class).build(dmpEntity);
|
DmpElasticEntity dmpElasticEntity = this.builderFactory.builder(DmpElasticBuilder.class).build(dmpEntity);
|
||||||
this.elasticsearchTemplate.save(dmpElasticEntity, IndexCoordinates.of(this.appElasticProperties.getDmpIndexName()));
|
this.elasticsearchTemplate.save(dmpElasticEntity, IndexCoordinates.of(this.appElasticConfiguration.getAppElasticProperties().getDmpIndexName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,7 +356,7 @@ public class ElasticServiceImpl implements ElasticService {
|
||||||
boolean exists = this.existsDmpIndex();
|
boolean exists = this.existsDmpIndex();
|
||||||
if (!exists) return ;
|
if (!exists) return ;
|
||||||
|
|
||||||
this.restHighLevelClient.indices().delete(new DeleteIndexRequest.Builder().index(this.appElasticProperties.getDmpIndexName()).build());
|
this.restHighLevelClient.indices().delete(new DeleteIndexRequest.Builder().index(this.appElasticConfiguration.getAppElasticProperties().getDmpIndexName()).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -367,7 +367,7 @@ public class ElasticServiceImpl implements ElasticService {
|
||||||
if (!this.enabled()) return;
|
if (!this.enabled()) return;
|
||||||
boolean exists = this.existsDescriptionIndex();
|
boolean exists = this.existsDescriptionIndex();
|
||||||
if (!exists) return ;
|
if (!exists) return ;
|
||||||
this.restHighLevelClient.indices().delete(new DeleteIndexRequest.Builder().index(this.appElasticProperties.getDescriptionIndexName()).build());
|
this.restHighLevelClient.indices().delete(new DeleteIndexRequest.Builder().index(this.appElasticConfiguration.getAppElasticProperties().getDescriptionIndexName()).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -382,7 +382,7 @@ public class ElasticServiceImpl implements ElasticService {
|
||||||
try {
|
try {
|
||||||
this.entityManager.disableTenantFilters();
|
this.entityManager.disableTenantFilters();
|
||||||
int page = 0;
|
int page = 0;
|
||||||
int pageSize = this.appElasticProperties.getResetBatchSize();
|
int pageSize = this.appElasticConfiguration.getAppElasticProperties().getResetBatchSize();
|
||||||
List<DmpEntity> items;
|
List<DmpEntity> items;
|
||||||
do {
|
do {
|
||||||
DmpQuery query = this.queryFactory.query(DmpQuery.class).disableTracking();
|
DmpQuery query = this.queryFactory.query(DmpQuery.class).disableTracking();
|
||||||
|
@ -392,7 +392,7 @@ public class ElasticServiceImpl implements ElasticService {
|
||||||
items = query.collect();
|
items = query.collect();
|
||||||
if (items != null && !items.isEmpty()) {
|
if (items != null && !items.isEmpty()) {
|
||||||
List<DmpElasticEntity> elasticEntities = this.builderFactory.builder(DmpElasticBuilder.class).build(items);
|
List<DmpElasticEntity> elasticEntities = this.builderFactory.builder(DmpElasticBuilder.class).build(items);
|
||||||
this.elasticsearchTemplate.save(elasticEntities, IndexCoordinates.of(this.appElasticProperties.getDmpIndexName()));
|
this.elasticsearchTemplate.save(elasticEntities, IndexCoordinates.of(this.appElasticConfiguration.getAppElasticProperties().getDmpIndexName()));
|
||||||
page++;
|
page++;
|
||||||
}
|
}
|
||||||
} while (items != null && !items.isEmpty());
|
} while (items != null && !items.isEmpty());
|
||||||
|
@ -414,7 +414,7 @@ public class ElasticServiceImpl implements ElasticService {
|
||||||
this.entityManager.disableTenantFilters();
|
this.entityManager.disableTenantFilters();
|
||||||
|
|
||||||
int page = 0;
|
int page = 0;
|
||||||
int pageSize = this.appElasticProperties.getResetBatchSize();
|
int pageSize = this.appElasticConfiguration.getAppElasticProperties().getResetBatchSize();
|
||||||
List<DescriptionEntity> items;
|
List<DescriptionEntity> items;
|
||||||
do {
|
do {
|
||||||
DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).disableTracking();
|
DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).disableTracking();
|
||||||
|
@ -424,7 +424,7 @@ public class ElasticServiceImpl implements ElasticService {
|
||||||
items = query.collect();
|
items = query.collect();
|
||||||
if (items != null && !items.isEmpty()) {
|
if (items != null && !items.isEmpty()) {
|
||||||
List<DescriptionElasticEntity> elasticEntities = this.builderFactory.builder(DescriptionElasticBuilder.class).build(items);
|
List<DescriptionElasticEntity> elasticEntities = this.builderFactory.builder(DescriptionElasticBuilder.class).build(items);
|
||||||
this.elasticsearchTemplate.save(elasticEntities, IndexCoordinates.of(this.appElasticProperties.getDescriptionIndexName()));
|
this.elasticsearchTemplate.save(elasticEntities, IndexCoordinates.of(this.appElasticConfiguration.getAppElasticProperties().getDescriptionIndexName()));
|
||||||
page++;
|
page++;
|
||||||
}
|
}
|
||||||
} while (items != null && !items.isEmpty());
|
} while (items != null && !items.isEmpty());
|
||||||
|
|
|
@ -4,3 +4,5 @@ elastic:
|
||||||
- classpath:certificates/elasticsearch_dev04.crt
|
- classpath:certificates/elasticsearch_dev04.crt
|
||||||
app-elastic:
|
app-elastic:
|
||||||
enableIcuAnalysisPlugin: true
|
enableIcuAnalysisPlugin: true
|
||||||
|
elastic-query-helper:
|
||||||
|
enableDbFallback: false
|
|
@ -19,3 +19,5 @@ app-elastic:
|
||||||
descriptionIndexName: ${ELASTIC_DESCRIPTION_INDEX}
|
descriptionIndexName: ${ELASTIC_DESCRIPTION_INDEX}
|
||||||
enableIcuAnalysisPlugin: false
|
enableIcuAnalysisPlugin: false
|
||||||
resetBatchSize: 1000
|
resetBatchSize: 1000
|
||||||
|
elastic-query-helper:
|
||||||
|
enableDbFallback: true
|
|
@ -50,13 +50,19 @@ export class UserListingFiltersComponent extends BaseComponent implements OnInit
|
||||||
}
|
}
|
||||||
|
|
||||||
protected applyFilters(): void {
|
protected applyFilters(): void {
|
||||||
const { isActive, like, userRoleSubQuery } = this.internalFilters ?? {}
|
const { isActive, like, userRoleSubQuery } = this.internalFilters ?? {};
|
||||||
this.filterChange.emit({
|
let filter = {
|
||||||
...this.filter,
|
...this.filter,
|
||||||
like,
|
like,
|
||||||
isActive: isActive ? [IsActive.Active] : [IsActive.Inactive],
|
isActive: isActive ? [IsActive.Active] : [IsActive.Inactive],
|
||||||
userRoleSubQuery
|
}
|
||||||
})
|
if (userRoleSubQuery && userRoleSubQuery.roles != null && userRoleSubQuery.roles.length > 0) {
|
||||||
|
filter = {
|
||||||
|
...filter,
|
||||||
|
userRoleSubQuery
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.filterChange.emit(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -265,6 +265,12 @@ public class DatasetMigrationService {
|
||||||
|
|
||||||
this.entityManager.flush();
|
this.entityManager.flush();
|
||||||
|
|
||||||
|
this.sortFieldSets(propertyDefinitionEntity, createdDescriptionReferenceEntities);
|
||||||
|
|
||||||
|
return propertyDefinitionEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sortFieldSets(PropertyDefinitionEntity propertyDefinitionEntity, List<DescriptionReferenceEntity> createdDescriptionReferenceEntities){
|
||||||
Map<UUID, DescriptionReferenceEntity> descriptionReferenceEntitiesMap = createdDescriptionReferenceEntities.stream().collect(Collectors.toMap(DescriptionReferenceEntity::getId, x-> x));
|
Map<UUID, DescriptionReferenceEntity> descriptionReferenceEntitiesMap = createdDescriptionReferenceEntities.stream().collect(Collectors.toMap(DescriptionReferenceEntity::getId, x-> x));
|
||||||
Map<UUID, DescriptionReferenceDataEntity> descriptionReferenceDataEntityById = new HashMap<>();
|
Map<UUID, DescriptionReferenceDataEntity> descriptionReferenceDataEntityById = new HashMap<>();
|
||||||
for (DescriptionReferenceEntity descriptionReferenceEntity : createdDescriptionReferenceEntities){
|
for (DescriptionReferenceEntity descriptionReferenceEntity : createdDescriptionReferenceEntities){
|
||||||
|
@ -272,28 +278,24 @@ public class DatasetMigrationService {
|
||||||
if (propertyDefinition != null) descriptionReferenceDataEntityById.put(descriptionReferenceEntity.getId(), propertyDefinition);
|
if (propertyDefinition != null) descriptionReferenceDataEntityById.put(descriptionReferenceEntity.getId(), propertyDefinition);
|
||||||
}
|
}
|
||||||
for (PropertyDefinitionFieldSetEntity fieldSetEntity : propertyDefinitionEntity.getFieldSets().values()){
|
for (PropertyDefinitionFieldSetEntity fieldSetEntity : propertyDefinitionEntity.getFieldSets().values()){
|
||||||
int newOrdinal = 0;
|
LinkedList<PropertyDefinitionFieldSetItemEntity> sortedPropertyDefinitionFieldSetItemEntities = new LinkedList<>();
|
||||||
PropertyDefinitionFieldSetItemEntity firstFieldSet = fieldSetEntity.getItems().stream().findFirst().filter(x-> x.getOrdinal() == SimpleFieldSetOrdinal).orElse(null);
|
fieldSetEntity.getItems().stream().findFirst().filter(x -> x.getOrdinal() == SimpleFieldSetOrdinal).ifPresent(sortedPropertyDefinitionFieldSetItemEntities::addLast);
|
||||||
if (firstFieldSet != null){
|
|
||||||
this.ensureDescriptionReferenceOrdinal(firstFieldSet, descriptionReferenceEntitiesMap, descriptionReferenceDataEntityById, newOrdinal);
|
|
||||||
firstFieldSet.setOrdinal(newOrdinal);
|
|
||||||
newOrdinal++;
|
|
||||||
|
|
||||||
}
|
for (PropertyDefinitionFieldSetItemEntity propertyDefinitionFieldSetItemEntity : fieldSetEntity.getItems().stream().filter(x-> x.getOrdinal() >= 0 && x.getOrdinal() != SimpleFieldSetOrdinal).sorted(Comparator.comparingInt(PropertyDefinitionFieldSetItemEntity::getOrdinal)).toList()){
|
||||||
for (PropertyDefinitionFieldSetItemEntity propertyDefinitionFieldSetItemEntity : fieldSetEntity.getItems().stream().filter(x-> x.getOrdinal() >= 0 && x.getOrdinal() != SimpleFieldSetOrdinal).sorted(Comparator.comparingInt(PropertyDefinitionFieldSetItemEntity::getOrdinal)).toList()){
|
sortedPropertyDefinitionFieldSetItemEntities.addLast(propertyDefinitionFieldSetItemEntity);
|
||||||
this.ensureDescriptionReferenceOrdinal(propertyDefinitionFieldSetItemEntity, descriptionReferenceEntitiesMap, descriptionReferenceDataEntityById, newOrdinal);
|
|
||||||
propertyDefinitionFieldSetItemEntity.setOrdinal(newOrdinal);
|
|
||||||
newOrdinal++;
|
|
||||||
}
|
}
|
||||||
for (PropertyDefinitionFieldSetItemEntity propertyDefinitionFieldSetItemEntity : fieldSetEntity.getItems().stream().filter(x-> x.getOrdinal() < 0 && x.getOrdinal() != SimpleFieldSetOrdinal).sorted(Comparator.comparingInt(PropertyDefinitionFieldSetItemEntity::getOrdinal)).toList()){
|
for (PropertyDefinitionFieldSetItemEntity propertyDefinitionFieldSetItemEntity : fieldSetEntity.getItems().stream().filter(x-> x.getOrdinal() < 0 && x.getOrdinal() != SimpleFieldSetOrdinal).sorted(Comparator.comparingInt(PropertyDefinitionFieldSetItemEntity::getOrdinal)).toList()){
|
||||||
this.ensureDescriptionReferenceOrdinal(propertyDefinitionFieldSetItemEntity, descriptionReferenceEntitiesMap, descriptionReferenceDataEntityById, newOrdinal);
|
sortedPropertyDefinitionFieldSetItemEntities.addLast(propertyDefinitionFieldSetItemEntity);
|
||||||
propertyDefinitionFieldSetItemEntity.setOrdinal(newOrdinal);
|
}
|
||||||
newOrdinal++;
|
|
||||||
|
for (int ordinal = 0; ordinal < sortedPropertyDefinitionFieldSetItemEntities.size(); ordinal++){
|
||||||
|
PropertyDefinitionFieldSetItemEntity fieldSet = sortedPropertyDefinitionFieldSetItemEntities.get(ordinal);
|
||||||
|
this.ensureDescriptionReferenceOrdinal(fieldSet, descriptionReferenceEntitiesMap, descriptionReferenceDataEntityById, ordinal);
|
||||||
|
fieldSet.setOrdinal(ordinal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.entityManager.flush();
|
this.entityManager.flush();
|
||||||
return propertyDefinitionEntity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ensureDescriptionReferenceOrdinal(PropertyDefinitionFieldSetItemEntity propertyDefinitionFieldSetItemEntity, Map<UUID, DescriptionReferenceEntity> descriptionReferenceEntitiesMap, Map<UUID, DescriptionReferenceDataEntity> descriptionReferenceDataEntityById, int newOrdinal){
|
private void ensureDescriptionReferenceOrdinal(PropertyDefinitionFieldSetItemEntity propertyDefinitionFieldSetItemEntity, Map<UUID, DescriptionReferenceEntity> descriptionReferenceEntitiesMap, Map<UUID, DescriptionReferenceDataEntity> descriptionReferenceDataEntityById, int newOrdinal){
|
||||||
|
|
Loading…
Reference in New Issue