MigrateModel can destroy data unexpectedly
MigrateModel.MigrationOperation.replace
contains this code:
// Perform operation
for(Statement stm : graph.getStatements(instanceToMigrate, L0.IsWeaklyRelatedTo)) {
Resource predicate = stm.getPredicate();
if(stm.isAsserted(instanceToMigrate)) continue;
if(L0.InstanceOf.equals(predicate)) {
graph.deny(stm);
graph.claim(instanceToMigrate, L0.InstanceOf, type);
}
if(graph.isInstanceOf(predicate, STR.Property) || graph.isInstanceOf(predicate, STR.ConnectionRelation)) {
Resource replacement = getPossibleReplacement(graph, type, predicate);
graph.deny(stm); <-----
if(replacement == null) continue;
// Filter out incompatible literal types.
// TODO: Show warning in UI
Resource object = stm.getObject();
Resource replacementRange = graph.getPossibleObject(replacement, L0.HasRange);
where the graph.deny(stm)
row marked with <-----
does the deny too early. It can destroy data unwantedly if replacement == null
.
Related to #610.