collectedFrom

This commit is contained in:
Michele Artini 2020-10-29 13:45:26 +01:00
parent f6feef1942
commit 14f88c7fb1
2 changed files with 18 additions and 5 deletions

View File

@ -29,12 +29,16 @@ public class OpenaireDuplicate implements Serializable {
@Column(name = "reltype")
private String relType;
@Column(name = "oa_collectedfrom")
private String oaCollectedFrom;
public OpenaireDuplicate() {}
public OpenaireDuplicate(final String localId, final String oaOriginalId, final String relType) {
public OpenaireDuplicate(final String localId, final String oaOriginalId, final String relType, final String oaCollectedFrom) {
this.localId = localId;
this.oaOriginalId = oaOriginalId;
this.relType = relType;
this.oaCollectedFrom = oaCollectedFrom;
}
public String getLocalId() {
@ -61,9 +65,18 @@ public class OpenaireDuplicate implements Serializable {
this.relType = relType;
}
public String getOaCollectedFrom() {
return oaCollectedFrom;
}
public void setOaCollectedFrom(final String oaCollectedFrom) {
this.oaCollectedFrom = oaCollectedFrom;
}
@Override
public String toString() {
return String.format("OpenaireDuplicate [localId=%s, oaOriginalId=%s, relType=%s]", localId, oaOriginalId, relType);
return String
.format("OpenaireDuplicate [localId=%s, oaOriginalId=%s, relType=%s, oaCollectedFrom=%s]", localId, oaOriginalId, relType, oaCollectedFrom);
}
}

View File

@ -143,10 +143,10 @@ public class DatabaseUtils {
final List<OpenaireDuplicate> dups = new ArrayList<>();
dups.add(new OpenaireDuplicate(newId, oldId, SimilarityType.is_similar.toString()));
dups.add(new OpenaireDuplicate(newId, oldId, SimilarityType.is_similar.toString(), ""));
dups.addAll(openaireDuplicateRepository.findByLocalId(oldId)
.stream()
.map(d -> new OpenaireDuplicate(newId, d.getOaOriginalId(), SimilarityType.suggested.toString()))
.map(d -> new OpenaireDuplicate(newId, d.getOaOriginalId(), SimilarityType.suggested.toString(), d.getOaCollectedFrom()))
.collect(Collectors.toList()));
openaireDuplicateRepository.saveAll(dups);
@ -383,7 +383,7 @@ public class DatabaseUtils {
final List<OpenaireDuplicate> newDuplicates = similarIds.stream()
.map(openaireDuplicateRepository::findByLocalId)
.flatMap(l -> l.stream())
.map(d -> new OpenaireDuplicate(masterId, d.getOaOriginalId(), d.getRelType()))
.map(d -> new OpenaireDuplicate(masterId, d.getOaOriginalId(), d.getRelType(), d.getOaCollectedFrom()))
.collect(Collectors.toList());
openaireDuplicateRepository.saveAll(newDuplicates);