public String updateBMEvaluationAction() {
log.debug("In updateEvaluationAction...");
try {
ExperimentBean expBean = (ExperimentBean)JSFUtil.getManagedObject("ExperimentBean");
TestbedManager testbedMan = (TestbedManager) JSFUtil.getManagedObject("TestbedManager");
Experiment exp = expBean.getExperiment();
// 1. Store the updated report:
exp.getExperimentEvaluation().getExperimentReport().setHeader(expBean.getReportHeader());
exp.getExperimentEvaluation().getExperimentReport().setBodyText(expBean.getReportBody());
log.debug("updateEvaluation Report Header: "+exp.getExperimentEvaluation().getExperimentReport().getHeader());
// 2. update Experiment Overall BenchmarkGoals from Bean
List<BenchmarkGoal> expBMgoals = new ArrayList<BenchmarkGoal>();
Iterator<BenchmarkBean> iter = expBean.getExperimentBenchmarkBeans().iterator();
log.debug("Found # of ExperimentOverall BMGS: " + expBean.getExperimentBenchmarkBeans().size());
boolean bError = false;
while (iter.hasNext()) {
BenchmarkBean bmb = iter.next();
BenchmarkGoal bmg;
if (bmb.getSelected()) {
// get the bmgoal from the evaluation data
bmg = exp.getExperimentEvaluation().getEvaluatedExperimentBenchmarkGoal(bmb.getID());
expBMgoals.add(bmg);
/* FIXME ANJ Clean this up:
try {
//update the bmg with the provided bean's data
helper_addBMBSettingsToBMGoal(bmb,bmg);
expBMgoals.add(bmg);
log.debug("updating bmg's target:" + bmg.getTargetValue());
} catch (InvalidInputException e) {
//create an ErrorMessage
FacesMessage fmsg = new FacesMessage();
if(bmg!=null){
fmsg.setSummary("Validation of "+bmg.getName()+" failed");
fmsg.setDetail("Validation of "+bmg.getName()+" failed");
}
else{
fmsg.setDetail("source/target value of a given file-Benchmarkgoal is not valid!"+e.toString());
fmsg.setSummary("source/target value of a given file-Benchmarkgoal is not valid!");
}
fmsg.setSeverity(FacesMessage.SEVERITY_ERROR);
FacesContext ctx = FacesContext.getCurrentInstance();
ctx.addMessage("bmTable",fmsg);
log.error(e.toString());
//set error true: all error messages are collected and then "failure" is returned
bError = true;
}
*/
}
}
//3. fill the file benchmark goals - used for evaluation of every input file
boolean bError2 = false;
Map<String,BenchmarkBean> mBMBs = expBean.getFileBenchmarkBeans();
Map<URI,List<BenchmarkGoal>> mFileBMGs = new HashMap<URI,List<BenchmarkGoal>>();
Iterator<String> itLocalInputFileRefs = expBean.getExperimentInputData().values().iterator();
DataHandler dh = new DataHandlerImpl();
//iterate over every input file and add update their evaluation
BenchmarkGoal bmg =null;
try {
while(itLocalInputFileRefs.hasNext()){
String localInputFileRef = itLocalInputFileRefs.next();
URI inputURI = dh.get(localInputFileRef).getDownloadUri();
List<BenchmarkGoal> lbmgs = new ArrayList<BenchmarkGoal>();
for(BenchmarkBean b : mBMBs.values()){
bmg = exp.getExperimentEvaluation().getEvaluatedFileBenchmarkGoal(inputURI, b.getID());
//BenchmarkBean bmb = mBMBs.get(inputURI+b.getID());
lbmgs.add(bmg);
/* FIXME ANJ Clean this up:
try{
this.helper_addBMBSettingsToBMGoal(bmb, bmg);
lbmgs.add(bmg);
}
catch(InvalidInputException e){
//create an ErrorMessage
FacesMessage fmsg = new FacesMessage();
if(bmg!=null){
fmsg.setSummary("Validation of "+bmg.getName()+" failed");
fmsg.setDetail("Validation of "+bmg.getName()+" failed");
}
else{
fmsg.setDetail("source/target value of a given file-Benchmarkgoal is not valid!"+e.toString());
fmsg.setSummary("source/target value of a given file-Benchmarkgoal is not valid!");
}
fmsg.setSeverity(FacesMessage.SEVERITY_ERROR);
FacesContext ctx = FacesContext.getCurrentInstance();
ctx.addMessage("modelpanel_error",fmsg);
log.error(e.toString());
bError2 = true;
}
*/
}
mFileBMGs.put(inputURI,lbmgs);
}
} catch (Exception e2) {
//a system exception occurred:
log.error("Failure within filling FileBenchmarkGoals");
return "failure";
}
//if either overall bmgoal evaluation or file bmgoal evaluation caused a validation exception
if((bError)||(bError2)){
return "failure";
}
//4. now write these changes back to the experiment
Experiment e = expBean.getExperiment();
log.debug("Exp ID: "+ exp.getEntityID() + " exp: " + e);
exp.getExperimentEvaluation().setEvaluatedExperimentBenchmarkGoals(expBMgoals);
exp.getExperimentEvaluation().setEvaluatedFileBenchmarkGoals(mFileBMGs);
testbedMan.updateExperiment(exp);
FacesMessage fmsg = new FacesMessage();
fmsg.setDetail("Evaluation Data saved successfully!");
fmsg.setSummary("Evaluation Data saved successfully!");
fmsg.setSeverity(FacesMessage.SEVERITY_INFO);
FacesContext ctx = FacesContext.getCurrentInstance();
ctx.addMessage("bmTable",fmsg);
return "success";
} catch (Exception e) {
log.error("Exception when trying to create/update Evaluations: "+e.toString());
return "failure";
}
}