log.debug(t.getName() + ": added " + sample.getName());
}
for (SequencerPoolPartition partition : partitionDAO.listBySubmissionId(rs.getLong("submissionId"))) {
//for each partition, lists all the runs on the flowcell/container
SequencerPoolPartition newPartition = new PartitionImpl();
newPartition.setId(partition.getId());
newPartition.setSequencerPartitionContainer(partition.getSequencerPartitionContainer());
newPartition.setPartitionNumber(partition.getPartitionNumber());
Pool<Dilution> newPool = new PoolImpl<Dilution>();
Pool<? extends Poolable> oldPool = partition.getPool();
newPool.setId(oldPool.getId());
newPool.setExperiments(oldPool.getExperiments());
List<Run> runs = new ArrayList<Run>(runDAO.listBySequencerPartitionContainerId(partition.getSequencerPartitionContainer().getId()));
//if there is 1 run for the flowcell/container, sets the run for that container to the first on on the list
if (runs.size() == 1) {
partition.getSequencerPartitionContainer().setRun(runs.get(0));
}
List<Long> dilutionIdList = template.queryForList(SUBMISSION_DILUTION_SELECT, Long.class, new Object[]{rs.getLong("submissionId"), partition.getId()});
log.debug("dilutionIdList for partition " + partition.getId() + "from DB table:" + dilutionIdList.toString());
for (Long id : dilutionIdList) {
Dilution dil = libraryDilutionDAO.getLibraryDilutionByIdAndPlatform(id, partition.getPool().getPlatformType());
try {
newPool.addPoolableElement(dil);
}
catch (Exception e) {
e.printStackTrace();
}
}
//adds the new pool to the partition
newPartition.setPool(newPool);
//replace any existing experiment-linked pools with the new pool
for (Experiment experiment : experimentDAO.listBySubmissionId(rs.getLong("submissionId"))) {
if (experiment.getPool().getId() == newPool.getId()) {
experiment.setPool(newPool);
t.addSubmissionElement(experiment);
log.debug(t.getName() + ": added " + experiment.getName());
break;
}
}
//adds the partition to the submission
log.debug("submission " + t.getId() + " new partition " + newPartition.getId() + " contains dilutions " + newPartition.getPool().getDilutions().toString());
t.addSubmissionElement(newPartition);
}
}
catch (IOException ie) {
log.warn("Cannot map submission: " + ie.getMessage());