long id=Long.parseLong(req.getParameter("id"));
Game g=GameDao.findGame(id,session);
GameHiber gh=GameDao.findGameHiber(id,session);
form.setG(g);
AOGGameHiber ag=AOGGameDao.findGameHiberForGame(g.getId(), session);
//if null is returned: game has not been authored => create instance!
if (ag==null) {
ag=new AOGGameHiber();
ag.setGame(gh);
ag.setHalfJokerNumber(0);
ag.setHintJokerNumber(0);
ag.setPauseJokerNumber(0);
ag.setRepublishNeeded(true);
ag.setServiceId("");
ag.setAuthKey("");
AOGGameDao.persistAOGGameHiber(ag, session);
}
form.setAogGame(ag);
//ACTIONS SWITCH
//hide level
if (req.getParameter("hideLevelContnt")!=null) {
form.getHidenLevels().add(new Long(req.getParameter("hideLevelContnt")));
return am.findForward("ok");
}
//show level
if (req.getParameter("showLevelContnt")!=null) {
form.getHidenLevels().remove(new Long(req.getParameter("showLevelContnt")));
return am.findForward("ok");
}
//delete picture
if (req.getParameter("deletePicture")!=null) {
return defaultMethodDeletePicture(am, af, req, res, g, gh, ag);
}
//change the game
if (req.getParameter("change")!=null) {
ActionForward r=defaultMethodChangeGame(am, af, req, res, g, gh, ag);
if (r!=null) return r;
}
//insert new level
if ((req.getParameter("change")!=null)&&(req.getParameter("newLevelSubmit")!=null))
return defaultMethodInsertLevel(am, af, req, res, g, gh, ag);
//insert new picture
if ((req.getParameter("change")!=null)&&(req.getParameter("newPictureSubmit")!=null))
return defaultMethodInsertPicture(am, af, req, res, g, gh, ag);
//publish game - create JAR
//this functionality is now implemented at downloading game - XML holds user ID...
//if ((req.getParameter("change")!=null)&&(req.getParameter("republishGameSubmit")!=null))
// return defaultMethodCreateJar(am, af, req, res, g, gh, ag);
//delete level
if ((req.getParameter("changeLevel")!=null)&&(req.getParameter("deleteLevelSubmit")!=null))
return defaultMethodDeleteLevel(am, af, req, res, g, gh, ag);
//delete card
if ((req.getParameter("changeLevel")!=null)&&(req.getParameter("deleteCardSubmit")!=null))
return defaultMethodDeleteCard(am, af, req, res, g, gh, ag);
//move card up
if ((req.getParameter("changeLevel")!=null)&&(req.getParameter("movecardUp")!=null))
return defaultMethodMoveCardUpCard(am, af, req, res, g, gh, ag);
//move card down
if ((req.getParameter("changeLevel")!=null)&&(req.getParameter("movecardDown")!=null))
return defaultMethodMoveCardDownCard(am, af, req, res, g, gh, ag);
//move level up
if ((req.getParameter("changeLevel")!=null)&&(req.getParameter("movelevelUp")!=null))
return defaultMethodMoveLevelUp(am, af, req, res, g, gh, ag);
//move level down
if ((req.getParameter("changeLevel")!=null)&&(req.getParameter("movelevelDown")!=null))
return defaultMethodMoveLevelDown(am, af, req, res, g, gh, ag);
//new info card
if ((req.getParameter("changeLevel")!=null)&&(req.getParameter("newLevelInfoSubmit")!=null))
defaultMethodCreateInfoCard(am, af, req, res, g, gh, ag);
//new intro card
if ((req.getParameter("changeLevel")!=null)&&(req.getParameter("newLevelIntroSubmit")!=null))
defaultMethodCreateIntroCard(am, af, req, res, g, gh, ag);
//new question card
if ((req.getParameter("changeLevel")!=null)&&(req.getParameter("newLevelQuestionSubmit")!=null))
defaultMethodCreateQuestionCard(am, af, req, res, g, gh, ag);
//new order-question card
if ((req.getParameter("changeLevel")!=null)&&(req.getParameter("newLevelOQuestionSubmit")!=null))
defaultMethodCreateOQuestionCard(am, af, req, res, g, gh, ag);
//new self-assessment card
if ((req.getParameter("changeLevel")!=null)&&(req.getParameter("newLevelSASubmit")!=null))
defaultMethodCreateSACard(am, af, req, res, g, gh, ag);
//new image card
if ((req.getParameter("changeLevel")!=null)&&(req.getParameter("newLevelImageSubmit")!=null))
defaultMethodCreateImageCard(am, af, req, res, g, gh, ag);
//new imagetext card
if ((req.getParameter("changeLevel")!=null)&&(req.getParameter("newLevelImageTextSubmit")!=null))
defaultMethodCreateImageTextCard(am, af, req, res, g, gh, ag);
//new textfree card
if ((req.getParameter("changeLevel")!=null)&&(req.getParameter("newLevelTextFreeSubmit")!=null))
defaultMethodCreateTxtFreeCard(am, af, req, res, g, gh, ag);
//new reward card
if ((req.getParameter("changeLevel")!=null)&&(req.getParameter("newLevelRewardSubmit")!=null))
defaultMethodCreateRewardCard(am, af, req, res, g, gh, ag);
//new simulation card
if ((req.getParameter("changeLevel")!=null)&&(req.getParameter("newLevelSimulationSubmit")!=null))
defaultMethodCreateSimulationCard(am, af, req, res, g, gh, ag);
form.setHalfJokerNumber(ag.getHalfJokerNumber());
form.setPauseJokerNumber(ag.getPauseJokerNumber());
form.setHintJokerNumber(ag.getHintJokerNumber());
form.setMaxScores(g.getMaksimumScore());
form.setServiceId(ag.getServiceId());
form.setAuthKey(ag.getAuthKey());
form.setOrderedLevels(AOGGameLevelDao.getOrderedLevelsForGame(ag.getId(),session));
form.setPictures(new ArrayList<AOGGamePicturesHiber>(ag.getPictures()));
return am.findForward("ok");
}