// Process one file at a time:
for (File file : pNexusFiles) {
long timeFile = System.currentTimeMillis();
NexusDataSet dataSet = null;
try {
// first start a transaction, use Hibernate to add and persist most of the data
dataSet = addNexusFile(pSubmission, file);
NexusDataSetJDBC dataJDBC = dataSet.getDataJDBC();
// Next use direct JDBC to batch insert data, for performance reason.
// getDomainHome().refreshAll(dataJDBC.getAllMatrices());
// TODO: create a new method:
Connection conn = getSubmissionHome().getConnection();
for (MatrixJDBC matrixJDBC : dataJDBC.getMatrixJDBCList()) {
matrixJDBC.batchInsertColumn(conn);
matrixJDBC.prepElementBatchInsert(conn);
matrixJDBC.processMatrixElements(conn);
// MesquiteMatrixConverter converter = matrixJDBC.getMesqMatrixConverter();
// converter.processMatrixElements(matrixJDBC, conn);
matrixJDBC.batchInsertCompoundElements(conn);
matrixCount ++;
}
treeCount += dataSet.getTotalTreeCount();
// ALERT: Do not use. will get connection closed exception!
// try {
// conn.close();
// } catch (SQLException ex) {
// throw new CleanupFailureDataAccessException("Failed to close connection.", ex);
// }
} finally {
// Dispose the mesquite project after all usage:
if (dataSet != null && dataSet.getMesqProject()!=null) dataSet.getMesqProject().dispose();
}
for (Matrix m : dataSet.getMatrices()) {
getMatrixHome().refresh(m);
m.setDimensions();
getMatrixHome().merge(m);
}