for (AnalyzedData ad : as.getDataSetReadOnly()) {
if (tr == null) {
tr = rt.beginTransaction();
}
Matrix m = ad.getMatrixData();
PhyloTree t = ad.getTreeData();
if (m != null) {
System.err.println(" Repatriating matrix " + m.getId()
+ " to study " + s.getId() + " submission " + sub.getId());
if (m.getStudy() != s) {
String nexusFileName = m.getNexusFileName();
Map<String,String> nexusMap = m.getStudy().getNexusFiles();
String nexusFile = nexusMap.remove(nexusFileName);
s.getNexusFiles().put(nexusFileName, nexusFile);
m.setStudy(s);
}
if (! ms.contains(m)) {
Submission oldSub = sh.findByMatrix(m);
if (oldSub != null) {
oldSub.removeMatrix(m);
sh.flush();
}
sub.addMatrix(m);
}
} else if (t != null) {
System.err.println(" Repatriating tree " + t.getId()
+ " to study " + s.getId() + " submission " + sub.getId());
if (t.getStudy() != s) {
String nexusFileName = t.getNexusFileName();
Map<String,String> nexusMap = t.getStudy().getNexusFiles();
String nexusFile = nexusMap.remove(nexusFileName);
s.getNexusFiles().put(nexusFileName, nexusFile);
t.setStudy(s);
}
TreeBlock tb = t.getTreeBlock();
if (tb == null) {
System.err.println(" No tree block!");
} else if (! tbs.contains(tb)) {
Submission oldSub = sh.findByTreeBlock(tb);
if (oldSub != null) {