Skip to content

Commit

Permalink
indexing created and modified, do not overwrite created in consolidated
Browse files Browse the repository at this point in the history
version
  • Loading branch information
GordeaS authored and GordeaS committed Mar 22, 2024
1 parent a22d047 commit abdf81e
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,12 @@ protected <T extends Entity> Entity(T copy) {
if (copy.getIsRelatedTo() != null) this.isRelatedTo = new ArrayList<>(copy.getIsRelatedTo());
if (copy.getHasPart() != null) this.hasPart = new ArrayList<>(copy.getHasPart());
if (copy.getIsPartOfArray() != null) this.isPartOf = new ArrayList<>(copy.getIsPartOfArray());
if (copy.getIsAggregatedBy() != null)
if (copy.getIsAggregatedBy() != null) {
this.isAggregatedBy = new Aggregation(copy.getIsAggregatedBy());
if (copy.getIsShownBy() != null) this.isShownBy = new WebResource(copy.getIsShownBy());
}
if (copy.getIsShownBy() != null) {
this.isShownBy = new WebResource(copy.getIsShownBy());
}

this.payload = copy.getPayload();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package eu.europeana.entitymanagement.solr.model;

import eu.europeana.entitymanagement.definitions.model.Entity;
import eu.europeana.entitymanagement.definitions.model.WebResource;
import eu.europeana.entitymanagement.solr.SolrUtils;
import eu.europeana.entitymanagement.vocabulary.EntitySolrFields;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.collections.MapUtils;
import org.apache.solr.client.solrj.beans.Field;
import eu.europeana.entitymanagement.definitions.model.Entity;
import eu.europeana.entitymanagement.definitions.model.WebResource;
import eu.europeana.entitymanagement.solr.SolrUtils;
import eu.europeana.entitymanagement.vocabulary.EntitySolrFields;

public abstract class SolrEntity<T extends Entity> {

Expand Down Expand Up @@ -79,6 +80,14 @@ public abstract class SolrEntity<T extends Entity> {

@Field(EntitySolrFields.IN_SCHEME)
private List<String> inScheme;


@Field(EntitySolrFields.CREATED)
private Date created;

@Field(EntitySolrFields.MODIFIED)
private Date modified;


public SolrEntity(T entity) {
this.type = entity.getType();
Expand All @@ -100,6 +109,12 @@ public SolrEntity(T entity) {
this.isPartOf = new ArrayList<>(entity.getIsPartOfArray());
if (entity.getInScheme() != null) this.inScheme = new ArrayList<>(entity.getInScheme());

if(entity.getIsAggregatedBy() != null) {
this.created = entity.getIsAggregatedBy().getCreated();
this.modified = entity.getIsAggregatedBy().getModified();
}


this.entity = entity;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
import eu.europeana.entitymanagement.definitions.batch.model.BatchEntityRecord;
import eu.europeana.entitymanagement.definitions.batch.model.ScheduledUpdateType;
import eu.europeana.entitymanagement.definitions.exceptions.EntityModelCreationException;
import eu.europeana.entitymanagement.definitions.model.Aggregation;
import eu.europeana.entitymanagement.definitions.model.Entity;
import eu.europeana.entitymanagement.definitions.model.EntityProxy;
import eu.europeana.entitymanagement.definitions.model.EntityRecord;
import eu.europeana.entitymanagement.definitions.model.WebResource;
import eu.europeana.entitymanagement.exception.ingestion.EntityValidationException;
import eu.europeana.entitymanagement.normalization.EntityFieldsCleaner;
Expand Down Expand Up @@ -55,10 +57,11 @@ public EntityConsolidationProcessor(
this.depictionGeneratorService = depictionGeneratorService;
}

public BatchEntityRecord doProcessing(BatchEntityRecord entityRecord)
public BatchEntityRecord doProcessing(BatchEntityRecord batchEntityRecord)
throws EuropeanaApiException, EntityModelCreationException {

List<EntityProxy> externalProxies = entityRecord.getEntityRecord().getExternalProxies();
EntityRecord entityRecord = batchEntityRecord.getEntityRecord();
List<EntityProxy> externalProxies = entityRecord.getExternalProxies();

EntityProxy primaryExternalProxy = externalProxies.get(0);
Entity externalProxyEntity = primaryExternalProxy.getEntity();
Expand Down Expand Up @@ -88,7 +91,7 @@ public BatchEntityRecord doProcessing(BatchEntityRecord entityRecord)
}
}

Entity europeanaProxyEntity = entityRecord.getEntityRecord().getEuropeanaProxy().getEntity();
Entity europeanaProxyEntity = entityRecord.getEuropeanaProxy().getEntity();

Entity consolidatedEntity = null;
if (isStaticDataSource) {
Expand Down Expand Up @@ -117,10 +120,19 @@ public BatchEntityRecord doProcessing(BatchEntityRecord entityRecord)
}
}
validateCompleteValidationConstraints(consolidatedEntity);

//Aggregation is not a merged field, need to copy it from the old consolidated entity
copyIsAggregatedBy(entityRecord, consolidatedEntity);


entityRecordService.updateConsolidatedVersion(
entityRecord.getEntityRecord(), consolidatedEntity);
entityRecord, consolidatedEntity);

return batchEntityRecord;
}

return entityRecord;
void copyIsAggregatedBy(EntityRecord entityRecord, Entity consolidatedEntity) {
consolidatedEntity.setIsAggregatedBy(new Aggregation(entityRecord.getEntity().getIsAggregatedBy()));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class BaseEntityRecordService {
protected final Logger logger = LogManager.getLogger(getClass());

// Fields to be ignored during consolidation ("type" is final)
static final Set<String> ignoredMergeFields = Set.of(WebEntityFields.TYPE);
static final Set<String> ignoredMergeFields = Set.of(WebEntityFields.TYPE, WebEntityFields.IS_AGGREGATED_BY);


protected BaseEntityRecordService(EntityRecordRepository entityRecordRepository,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,6 @@ public Entity mergeEntities(Entity primary, Entity secondary)
}

public void updateConsolidatedVersion(EntityRecord entityRecord, Entity consolidatedEntity) {

entityRecord.setEntity(consolidatedEntity);
updateEntityAggregation(entityRecord, consolidatedEntity.getEntityId(), new Date());
}
Expand Down

0 comments on commit abdf81e

Please sign in to comment.