Merge pull request 'Set deletedbyinference =true to dedup aliases, created when a dedup in a previous build has been merged in a new dedup' (#392) from fix_dedupaliases_deletedbyinference into master

Reviewed-on: #392
This commit is contained in:
Giambattista Bloisi 2024-02-08 15:29:29 +01:00
commit ba1a0e7b4f
1 changed files with 31 additions and 12 deletions

View File

@ -122,22 +122,41 @@ public class DedupRecordFactory {
} }
return Stream return Stream
.concat(Stream.of(agg.getDedupId()), agg.aliases.stream()) .concat(
.map(id -> { Stream
try { .of(agg.getDedupId())
OafEntity res = (OafEntity) BeanUtils.cloneBean(agg.entity); .map(id -> createDedupOafEntity(id, agg.entity, dataInfo, ts)),
res.setId(id); agg.aliases
res.setDataInfo(dataInfo); .stream()
res.setLastupdatetimestamp(ts); .map(id -> createMergedDedupAliasOafEntity(id, agg.entity, dataInfo, ts)))
return res;
} catch (Exception e) {
throw new RuntimeException(e);
}
})
.iterator(); .iterator();
}, beanEncoder); }, beanEncoder);
} }
private static OafEntity createDedupOafEntity(String id, OafEntity base, DataInfo dataInfo, long ts) {
try {
OafEntity res = (OafEntity) BeanUtils.cloneBean(base);
res.setId(id);
res.setDataInfo(dataInfo);
res.setLastupdatetimestamp(ts);
return res;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
private static OafEntity createMergedDedupAliasOafEntity(String id, OafEntity base, DataInfo dataInfo, long ts) {
try {
OafEntity res = createDedupOafEntity(id, base, dataInfo, ts);
DataInfo ds = (DataInfo) BeanUtils.cloneBean(dataInfo);
ds.setDeletedbyinference(true);
res.setDataInfo(ds);
return res;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
private static OafEntity reduceEntity(OafEntity entity, OafEntity duplicate) { private static OafEntity reduceEntity(OafEntity entity, OafEntity duplicate) {
if (duplicate == null) { if (duplicate == null) {