BindException errors) throws Exception {
String dataType = request.getParameter("dataType");
String inputOutput = request.getParameter("inputOutput");
Boolean input = inputOutput.equals("Input");
String analysisStepId = request.getParameter("analysisStepId");
AnalysisStep analysisStep = getAnalysisStepService().findByID(Long.parseLong(analysisStepId));
String action = request.getParameter("action");
// add a list of ids
if ( action.equals("add") ) {
String idString = request.getParameter("ids");
String[] ids = idString.split(" +");
if ( dataType.equals("Matrices") ) {
for ( int i = 0; i < ids.length; i++ ) {
if ( ! TreebaseUtil.isEmpty(ids[i]) ) {
Matrix matrix = getMatrixService().findByID(Long.parseLong(ids[i]));
AnalyzedMatrix analyzedMatrix = new AnalyzedMatrix();
analyzedMatrix.setInput(input);
analyzedMatrix.setMatrix(matrix);
analysisStep.addAnalyzedData(analyzedMatrix);
getAnalysisStepService().update(analysisStep);
}
}
}
else if ( dataType.equals("Trees") ) {
for ( int i = 0; i < ids.length; i++ ) {
if ( ! TreebaseUtil.isEmpty(ids[i]) ) {
PhyloTree phyloTree = getPhyloTreeService().findByID(Long.parseLong(ids[i]));
AnalyzedTree analyzedTree = new AnalyzedTree();
analyzedTree.setInput(input);
analyzedTree.setTree(phyloTree);
analysisStep.addAnalyzedData(analyzedTree);
getAnalysisStepService().update(analysisStep);
}
}
}
else if ( dataType.equals("TreeBlocks") ) {
for ( int i = 0; i < ids.length; i++ ) {
if ( ! TreebaseUtil.isEmpty(ids[i]) ) {
TreeBlock treeBlock = getPhyloTreeService().findTreeBlockByID(Long.parseLong(ids[i]));
for ( PhyloTree phyloTree : treeBlock.getTreeList() ) {
AnalyzedTree analyzedTree = new AnalyzedTree();
analyzedTree.setInput(input);
analyzedTree.setTree(phyloTree);
analysisStep.addAnalyzedData(analyzedTree);
getAnalysisStepService().update(analysisStep);
}
}
}
}
}
// remove an id
else if ( action.equals("remove") ) {
String deleteMe = request.getParameter("deleteMe");
AnalyzedData datumToDelete = null;
if ( dataType.equals("Matrices") ) {
for ( AnalyzedData data : analysisStep.getDataSetReadOnly() ) {
if ( data.isInputData() == input && data.getMatrixData() != null ) {
if ( data.getId() == Long.parseLong(deleteMe) ) {
datumToDelete = data;
break;
}
}
}
}
else if ( dataType.equals("Trees") ) {
for ( AnalyzedData data : analysisStep.getDataSetReadOnly() ) {
if ( data.isInputData() == input && data.getTreeData() != null ) {
if ( data.getId() == Long.parseLong(deleteMe) ) {
datumToDelete = data;
break;
}
}
}
}
analysisStep.removeAnalyzedData(datumToDelete);
getAnalysisStepService().update(analysisStep);
}
return new ModelAndView(new RedirectView("analyses.html"));
}