force is_similar to clone duplicate
This commit is contained in:
parent
7ba3c61768
commit
01fd913c1d
|
@ -17,6 +17,7 @@ import java.util.stream.Collectors;
|
|||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
|
@ -159,7 +160,7 @@ public class DatabaseUtils {
|
|||
|
||||
final List<OpenaireDuplicate> dups = openaireDuplicateRepository.findByLocalId(oldId)
|
||||
.stream()
|
||||
.map(d -> new OpenaireDuplicate(newId, d.getOaOriginalId(), SimilarityType.suggested.toString(), d.getOaCollectedFrom()))
|
||||
.map(d -> prepareNewDuplicate(newId, oldId, d))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
openaireDuplicateRepository.saveAll(dups);
|
||||
|
@ -209,6 +210,25 @@ public class DatabaseUtils {
|
|||
return newId;
|
||||
}
|
||||
|
||||
private OpenaireDuplicate prepareNewDuplicate(final String newId, final String oldId, final OpenaireDuplicate old) {
|
||||
final OpenaireDuplicate d = new OpenaireDuplicate();
|
||||
|
||||
d.setLocalId(newId);
|
||||
d.setOaOriginalId(old.getOaOriginalId());
|
||||
d.setOaCollectedFrom(old.getOaCollectedFrom());
|
||||
|
||||
if (oldId != null
|
||||
&& newId.startsWith(OpenOrgsConstants.OPENORGS_PREFIX)
|
||||
&& oldId.startsWith(OpenOrgsConstants.OPENORGS_PENDING_PREFIX)
|
||||
&& StringUtils.substringAfter(oldId, OpenOrgsConstants.OPENORGS_PENDING_PREFIX).equalsIgnoreCase(DigestUtils.md5Hex(d.getOaOriginalId()))) {
|
||||
d.setRelType(SimilarityType.is_similar.toString());
|
||||
} else {
|
||||
d.setRelType(SimilarityType.suggested.toString());
|
||||
}
|
||||
return d;
|
||||
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void saveDuplicates(final List<OpenaireDuplicate> simrels, final String user) {
|
||||
final OffsetDateTime now = OffsetDateTime.now();
|
||||
|
|
Loading…
Reference in New Issue