Commit 341c11f5 authored by Matija Obreza's avatar Matija Obreza

DivTree: Fix bug with removing accession references

parent 79a1b274
......@@ -49,6 +49,7 @@ import org.genesys.blocks.model.SelfCleaning;
import org.genesys.blocks.model.UuidModel;
import org.genesys.blocks.security.model.AclAwareModel;
import org.genesys.blocks.util.ClassAclOid;
import org.genesys.custom.elasticsearch.IgnoreField;
import org.genesys.filerepository.model.RepositoryFile;
import org.genesys2.server.model.PublishState;
import org.genesys2.util.MCPDUtil;
......@@ -145,6 +146,7 @@ public class DiversityTree extends UuidModel implements AclAwareModel, SelfClean
/** The treeFile. */
@OneToOne(fetch = FetchType.LAZY, cascade = {}, optional = true, orphanRemoval = false)
@JoinColumn(name = "treeFileId", unique = true)
@IgnoreField
private RepositoryFile treeFile;
@Transient
......
......@@ -783,11 +783,8 @@ public class DiversityTreeServiceImpl implements DiversityTreeService {
}
private void deleteAccessionRefs(final DiversityTree tree) {
Lists.partition(tree.getAccessionRefs(), 10000).parallelStream().forEach(batch -> {
accessionRefRepository.deleteAll(batch);
LOG.debug("Removed {} accessionRefs of DiversityTree {} from database", batch.size(), tree.getUuid());
});
LOG.info("Removed {} accessionRefs from DiversityTree {}", tree.getAccessionRefs().size(), tree.getUuid());
LOG.info("Removing {} accessionRefs from DiversityTree {}", tree.getAccessionRefs().size(), tree.getUuid());
accessionRefRepository.deleteAll(tree.getAccessionRefs());
tree.getAccessionRefs().clear();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment