elastic fixes

This commit is contained in:
Efstratios Giannopoulos 2024-06-20 14:17:58 +03:00
parent d2d96b128a
commit 0135f80e89
7 changed files with 54 additions and 5 deletions

View File

@ -41,10 +41,6 @@ public class DescriptionElasticEntity {
private Date finalizedAt;
public final static String _finalizedAt = "finalizedAt";
@Field(value = DescriptionElasticEntity._createdAt, type = FieldType.Date)
private Date createdAt;
public final static String _createdAt = "createdAt";
@Field(value = DescriptionElasticEntity._tags, type = FieldType.Nested)
private List<NestedTagElasticEntity> tags;
public final static String _tags = "tags";
@ -61,6 +57,14 @@ public class DescriptionElasticEntity {
private List<NestedReferenceElasticEntity> references;
public final static String _references = "references";
@Field(value = DescriptionElasticEntity._updatedAt, type = FieldType.Date)
private Date updatedAt;
public final static String _updatedAt = "updatedAt";
@Field(value = DescriptionElasticEntity._createdAt, type = FieldType.Date)
private Date createdAt;
public final static String _createdAt = "createdAt";
public UUID getId() {
return this.id;
}
@ -148,4 +152,12 @@ public class DescriptionElasticEntity {
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public Date getUpdatedAt() {
return this.updatedAt;
}
public void setUpdatedAt(Date updatedAt) {
this.updatedAt = updatedAt;
}
}

View File

@ -82,6 +82,14 @@ public class DmpElasticEntity {
private List<NestedDoiElasticEntity> dois;
public final static String _dois = "dois";
@Field(value = DmpElasticEntity._updatedAt, type = FieldType.Date)
private Date updatedAt;
public final static String _updatedAt = "updatedAt";
@Field(value = DmpElasticEntity._createdAt, type = FieldType.Date)
private Date createdAt;
public final static String _createdAt = "createdAt";
public UUID getId() {
return this.id;
}
@ -217,4 +225,20 @@ public class DmpElasticEntity {
public void setDmpDescriptionTemplates(List<NestedDmpDescriptionTemplateElasticEntity> dmpDescriptionTemplates) {
this.dmpDescriptionTemplates = dmpDescriptionTemplates;
}
public Date getCreatedAt() {
return this.createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public Date getUpdatedAt() {
return this.updatedAt;
}
public void setUpdatedAt(Date updatedAt) {
this.updatedAt = updatedAt;
}
}

View File

@ -65,6 +65,7 @@ public class DescriptionElasticBuilder extends BaseElasticBuilder<DescriptionEla
m.setDescription(d.getDescription());
m.setStatus(d.getStatus());
m.setCreatedAt(Date.from(d.getCreatedAt()));
m.setUpdatedAt(Date.from(d.getUpdatedAt()));
if (d.getFinalizedAt() != null) {
m.setFinalizedAt(Date.from(d.getFinalizedAt()));
}

View File

@ -66,6 +66,9 @@ public class DmpElasticBuilder extends BaseElasticBuilder<DmpElasticEntity, DmpE
if (d.getTenantId() != null) {
m.setTenantId(d.getTenantId());
}
m.setUpdatedAt(Date.from(d.getUpdatedAt()));
m.setCreatedAt(Date.from(d.getCreatedAt()));
if (referenceElasticEntityMap != null) m.setReferences(referenceElasticEntityMap.getOrDefault(d.getId(), null));
if (descriptionElasticEntityMap != null) m.setDescriptions(descriptionElasticEntityMap.getOrDefault(d.getId(), null));
if (dmpDescriptionTemplateElasticEntityMap != null) m.setDmpDescriptionTemplates(dmpDescriptionTemplateElasticEntityMap.getOrDefault(d.getId(), null));

View File

@ -280,7 +280,8 @@ public class DescriptionElasticQuery extends ElasticQuery<DescriptionElasticEnti
if (columns.contains(DescriptionElasticEntity._description)) mocDoc.setDescription(FieldBasedMapper.shallowSafeConversion(rawData.get(DescriptionElasticEntity._description), String.class));
if (columns.contains(DescriptionElasticEntity._status)) mocDoc.setStatus(FieldBasedMapper.shallowSafeConversion(rawData.get(DescriptionElasticEntity._status), DescriptionStatus.class));
if (columns.contains(DescriptionElasticEntity._finalizedAt)) mocDoc.setFinalizedAt(FieldBasedMapper.shallowSafeConversion(rawData.get(DescriptionElasticEntity._finalizedAt), Date.class));
if (columns.contains(DescriptionElasticEntity._createdAt)) mocDoc.setFinalizedAt(FieldBasedMapper.shallowSafeConversion(rawData.get(DescriptionElasticEntity._createdAt), Date.class));
if (columns.contains(DescriptionElasticEntity._createdAt)) mocDoc.setCreatedAt(FieldBasedMapper.shallowSafeConversion(rawData.get(DescriptionElasticEntity._createdAt), Date.class));
if (columns.contains(DescriptionElasticEntity._updatedAt)) mocDoc.setUpdatedAt(FieldBasedMapper.shallowSafeConversion(rawData.get(DescriptionElasticEntity._updatedAt), Date.class));
mocDoc.setTags(this.convertNested(rawData, columns, this.queryFactory.query(NestedTagElasticQuery.class), DescriptionElasticEntity._tags, null));
mocDoc.setReferences(this.convertNested(rawData, columns, this.queryFactory.query(NestedReferenceElasticQuery.class), DescriptionElasticEntity._references, null));
mocDoc.setDescriptionTemplate(this.convertInnerObject(rawData, columns, this.queryFactory.query(InnerObjectDescriptionTemplateElasticQuery.class), DescriptionElasticEntity._descriptionTemplate, null));
@ -296,6 +297,7 @@ public class DescriptionElasticQuery extends ElasticQuery<DescriptionElasticEnti
else if (item.match(DescriptionElasticEntity._status)) return this.elasticFieldOf(DescriptionElasticEntity._status);
else if (item.match(DescriptionElasticEntity._finalizedAt)) return this.elasticFieldOf(DescriptionElasticEntity._finalizedAt);
else if (item.match(DescriptionElasticEntity._createdAt)) return this.elasticFieldOf(DescriptionElasticEntity._createdAt);
else if (item.match(DescriptionElasticEntity._updatedAt)) return this.elasticFieldOf(DescriptionElasticEntity._updatedAt);
else if (item.prefix(DescriptionElasticEntity._references)) return this.queryFactory.query(NestedReferenceElasticQuery.class).nestedPath(DescriptionElasticEntity._references).fieldNameOf(this.extractPrefixed(item, DescriptionElasticEntity._references));
else if (item.prefix(DescriptionElasticEntity._tags)) return this.queryFactory.query(NestedTagElasticQuery.class).nestedPath(DescriptionElasticEntity._tags).fieldNameOf(this.extractPrefixed(item, DescriptionElasticEntity._tags));
else if (item.prefix(DescriptionElasticEntity._descriptionTemplate)) return this.queryFactory.query(InnerObjectDescriptionTemplateElasticQuery.class).innerPath(DescriptionElasticEntity._descriptionTemplate).fieldNameOf(this.extractPrefixed(item, DescriptionElasticEntity._description));

View File

@ -341,6 +341,8 @@ public class DmpElasticQuery extends ElasticQuery<DmpElasticEntity, UUID> {
if (columns.contains(DmpElasticEntity._groupId)) mocDoc.setGroupId(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._groupId), UUID.class));
if (columns.contains(DmpElasticEntity._accessType)) mocDoc.setAccessType(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._accessType), DmpAccessType.class));
if (columns.contains(DmpElasticEntity._finalizedAt)) mocDoc.setFinalizedAt(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._finalizedAt), Date.class));
if (columns.contains(DmpElasticEntity._createdAt)) mocDoc.setCreatedAt(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._createdAt), Date.class));
if (columns.contains(DmpElasticEntity._updatedAt)) mocDoc.setUpdatedAt(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._updatedAt), Date.class));
mocDoc.setCollaborators(this.convertNested(rawData, columns, this.queryFactory.query(NestedCollaboratorElasticQuery.class), DmpElasticEntity._collaborators, null));
mocDoc.setReferences(this.convertNested(rawData, columns, this.queryFactory.query(NestedReferenceElasticQuery.class), DmpElasticEntity._references, null));
mocDoc.setDescriptions(this.convertNested(rawData, columns, this.queryFactory.query(NestedDescriptionElasticQuery.class), DmpElasticEntity._descriptions, null));
@ -358,6 +360,8 @@ public class DmpElasticQuery extends ElasticQuery<DmpElasticEntity, UUID> {
else if (item.match(DmpElasticEntity._versionStatus)) return this.elasticFieldOf(DmpElasticEntity._versionStatus);
else if (item.match(DmpElasticEntity._groupId)) return this.elasticFieldOf(DmpElasticEntity._groupId);
else if (item.match(DmpElasticEntity._finalizedAt)) return this.elasticFieldOf(DmpElasticEntity._finalizedAt);
else if (item.match(DmpElasticEntity._updatedAt)) return this.elasticFieldOf(DmpElasticEntity._updatedAt);
else if (item.match(DmpElasticEntity._createdAt)) return this.elasticFieldOf(DmpElasticEntity._createdAt);
else if (item.match(DmpElasticEntity._accessType)) return this.elasticFieldOf(DmpElasticEntity._accessType);
else if (item.prefix(DmpElasticEntity._collaborators)) return this.queryFactory.query(NestedCollaboratorElasticQuery.class).nestedPath(DmpElasticEntity._collaborators).fieldNameOf(this.extractPrefixed(item, DmpElasticEntity._collaborators));
else if (item.prefix(DmpElasticEntity._references)) return this.queryFactory.query(NestedReferenceElasticQuery.class).nestedPath(DmpElasticEntity._references).fieldNameOf(this.extractPrefixed(item, DmpElasticEntity._references));

View File

@ -139,6 +139,7 @@ public class ElasticServiceImpl implements ElasticService {
propertyMap.put(DescriptionElasticEntity._status, this.createElastic(FieldType.Short, false));
propertyMap.put(DescriptionElasticEntity._finalizedAt, this.createElastic(FieldType.Date, false));
propertyMap.put(DescriptionElasticEntity._createdAt, this.createElastic(FieldType.Date, false));
propertyMap.put(DescriptionElasticEntity._updatedAt, this.createElastic(FieldType.Date, false));
propertyMap.put(DescriptionElasticEntity._tags, new Property.Builder().nested(x -> x.properties(this.createNestedTagsTemplatePropertyMap())).build());
propertyMap.put(DescriptionElasticEntity._references, new Property.Builder().nested(x -> x.properties(this.createNestedReferencesTemplatePropertyMap())).build());
@ -160,6 +161,8 @@ public class ElasticServiceImpl implements ElasticService {
propertyMap.put(DmpElasticEntity._accessType, this.createElastic(FieldType.Short, false));
propertyMap.put(DmpElasticEntity._groupId, this.createElastic(FieldType.Keyword, false));
propertyMap.put(DmpElasticEntity._finalizedAt, this.createElastic(FieldType.Date, false));
propertyMap.put(DmpElasticEntity._updatedAt, this.createElastic(FieldType.Date, false));
propertyMap.put(DmpElasticEntity._createdAt, this.createElastic(FieldType.Date, false));
propertyMap.put(DmpElasticEntity._versionStatus, this.createElastic(FieldType.Short, false));
propertyMap.put(DmpElasticEntity._descriptions, new Property.Builder().nested(x -> x.properties(this.createNestedDescriptionTemplatePropertyMap())).build());