block.addPhyloTree(tree);
block.addPhyloTree(tree2);
// Create an analysis step and associate w/ tree.
Study s = getTestStudy();
Analysis a1 = new Analysis();
a1.setName("1 " + newName);
AnalysisStep step1 = new AnalysisStep();
step1.setName("step1 " + newName);
s.addAnalysis(a1);
a1.addAnalysisStep(step1);
AnalyzedTree treeData = new AnalyzedTree();
treeData.setTree(tree);
treeData.setInput(Boolean.FALSE);
step1.addAnalyzedData(treeData);
getFixture().store(tree);
getFixture().store(tree2);
getFixture().store(block);
// force commit immediately, important:
setComplete();
endTransaction();
logger.info("tree1 created: " + tree.getLabel() + "id = " + tree.getId());
logger.info("tree2 created: " + tree2.getLabel() + "id = " + tree2.getId());
logger.info("treeBlock created: " + block.getTitle() + "id = " + block.getId());
logger.info("analysis step created: " + step1.getName() + "id = " + step1.getId()
+ " associated data count=" + step1.getDataSetReadOnly().size());
// logger.info("treeBlock created: " + block.getTitle() + "id = " + block.getId());
// 2. verify
String treeSql = "select count(*) from phylotree where treeBlock_id=" + block.getId();
String blockSql = "select count(*) from treeblock where treeBlock_id=" + block.getId();
String analyzedDataSql = "select count(*) from analyzedData where analysisstep_id="
+ step1.getId();
String a1Sql = "select count(*) from analysis where analysis_id=" + a1.getId();
int count = jdbcTemplate.queryForInt(treeSql);
assertTrue(count == 2);
count = jdbcTemplate.queryForInt(blockSql);
assertTrue(count == 1);
count = jdbcTemplate.queryForInt(a1Sql);
assertTrue(count == 1);
count = jdbcTemplate.queryForInt(analyzedDataSql);
assertTrue(count == 1);
onSetUp();
// 3. delete
getFixture().refresh(block);
getFixture().refresh(a1);
getFixture().refreshAll(a1.getAnalysisStepsReadOnly());
getFixture().deleteTreeBlock(block);
setComplete();
endTransaction();
// 3.2: have to separate the deleting of analysis, due to
// analysisstep -->analyzedData.
onSetUp();
// getFixture().refresh(a1);
a1 = (Analysis) loadObject(Analysis.class, a1.getId());
getAnalysisService().deleteAnalysis(a1);
setComplete();
endTransaction();