log.error("Could not parse experiment id "+experimentId);
}
}
// Check if there is an experiment bean already, and persist changes.
ExperimentBean expBean = (ExperimentBean)JSFUtil.getManagedObject("ExperimentBean");
if( expBean != null ) {
log.info("Experiment Bean found: "+expBean.getEname());
}
// Load it:
ExperimentPersistencyRemote edao = ExperimentPersistencyImpl.getInstance();
if( edao != null && eid != null ) {
exp = edao.findExperiment(eid);
}
// Also look for an experiment bean in the session:
FacesContext ctx = FacesContext.getCurrentInstance();
ExperimentBean sessExpBean = (ExperimentBean) ctx.getExternalContext().getSessionMap().get(ExperimentInspector.EXP_BEAN_IN_SESSION_DEPRECATED);
// Experiment exp should work:
if( exp != null ) {
log.info("Experiment found: "+exp.getExperimentSetup().getBasicProperties().getExperimentName());
experimentBean = new ExperimentBean();
experimentBean.fill(exp);
ExperimentInspector.putExperimentIntoRequestExperimentBean(exp);
}
// If not, use the one in the session:
else if( sessExpBean != null ) {
log.info("Experiment found in session: "+sessExpBean.getEname());
if( sessExpBean.getExperiment() != null ) {
this.experimentId = ""+sessExpBean.getExperiment().getEntityID();
}
this.experimentBean = sessExpBean;
ctx.getExternalContext().getRequestMap().put(ExperimentInspector.EXP_BEAN_IN_REQUEST, sessExpBean);
}
// Otherwise, treat as a new experiment:
else {
log.info("No experiment found: make a new one.");
exp = new ExperimentImpl();
this.experimentId = null;
experimentBean = new ExperimentBean();
experimentBean.fill(exp);
ExperimentInspector.putExperimentIntoRequestExperimentBean(exp);
}
}