// Analysis Steps for Analysis and add algorithm type
List<AnalysisStep> analysisStepList = analysis.getAnalysisStepsReadOnly();
List<AnalysisStepCommand> analysisStepCommandList = new ArrayList<AnalysisStepCommand>();
for (AnalysisStep analysisStep : analysisStepList) {
AnalysisStepCommand analysisStepCommand = new AnalysisStepCommand();
BeanUtils.copyProperties(analysisStepCommand, analysisStep);
// analysisStepCommand.setId(analysisStep.getId());
// analysisStepCommand.setSoftwareInfo(analysisStep.getSoftwareInfo());
Algorithm algorithm = analysisStep.getAlgorithmInfo();
String algorithmType = new String();
if (algorithm instanceof LikelihoodAlgorithm) {
algorithmType = Constants.ALGORITHM_LIKELIHOOD;
} else if (algorithm instanceof ParsimonyAlgorithm) {
algorithmType = Constants.ALGORITHM_PARSIMONY;
} else if (algorithm instanceof OtherAlgorithm) {
algorithmType = Constants.ALGORITHM_OTHER;
}else if (algorithm instanceof BayesianAlgorithm) {
algorithmType = Constants.ALGORITHM_Bayesian;
} else if (algorithm instanceof EvolutionAlgorithm) {
algorithmType = Constants.ALGORITHM_Evolution;
} else if (algorithm instanceof JoiningAlgorithm) {
algorithmType = Constants.ALGORITHM_Joining;
} else if (algorithm instanceof UPGMAAlgorithm) {
algorithmType = Constants.ALGORITHM_UPGMA;
}
// add algorithm type for analysisStepCommand
analysisStepCommand.setAlgorithmType(algorithmType);
// analyzed data for each analysis step
List<AnalyzedData> analyzedDataSet = analysisStep.getDataSetReadOnly();
List<AnalyzedDataCommand> analyzedDataCommandList = new ArrayList<AnalyzedDataCommand>();
// Matrix or Tree?
for (AnalyzedData analyzedData : analyzedDataSet) {
AnalyzedDataCommand analyzedDataCommand = new AnalyzedDataCommand();
BeanUtils.copyProperties(analyzedDataCommand, analyzedData);
String inputOutput = (analyzedData.isInputData()) ? ("Input") : ("Output");
analyzedDataCommand.setInputOutputType(inputOutput);
if (analyzedData instanceof AnalyzedMatrix) {
AnalyzedMatrix analyzedMatrix = (AnalyzedMatrix) analyzedData;
analyzedDataCommand.setDataType(Constants.MATRIX_KEY);
analyzedDataCommand.setDisplayName(analyzedMatrix.getMatrix().getTitle());
analyzedDataCommand.setId(analyzedMatrix.getId());
analyzedDataCommand.setDataId(analyzedMatrix.getMatrix().getId());
} else if (analyzedData instanceof AnalyzedTree) {
AnalyzedTree analyzedTree = (AnalyzedTree) analyzedData;
analyzedDataCommand.setDataType(Constants.TREE_KEY);
analyzedDataCommand.setDisplayName(analyzedTree.getTree().getLabel());
analyzedDataCommand.setId(analyzedTree.getId());
analyzedDataCommand.setDataId(analyzedTree.getTree().getId());
}
analyzedDataCommandList.add(analyzedDataCommand);
} // end for
// add analyzedData for analysisStepCommand
Collections.sort(analyzedDataCommandList, new AnalyzedDataComparator());
analysisStepCommand.setAnalyzedDataCommandList(analyzedDataCommandList);
analysisStepCommandList.add(analysisStepCommand);
}
analysisCommand.setAnalysisStepCommandList(analysisStepCommandList);
analysisCommandList.add(analysisCommand);
}