Package si.unimb.cot.mgbl.gameauth.formbeans

Examples of si.unimb.cot.mgbl.gameauth.formbeans.AOGAuthorForm


  }
 
  //change the game
  public ActionForward defaultMethodChangeGame(ActionMapping am, ActionForm af, HttpServletRequest req, HttpServletResponse res,Game g,GameHiber gh,AOGGameHiber ag) {
   
    AOGAuthorForm form=(AOGAuthorForm)af;

    if (!SecurityCenter.canIEditGame(webUser.getId(), g.getId(),session)) {
      MessageBean.setMyMessage(req, ("Error: Insufficient privileges."));
      form.reset();
      return am.findForward("list");
    }
   
    //jokers
    ag.setHalfJokerNumber(form.getHalfJokerNumber());
    ag.setPauseJokerNumber(form.getPauseJokerNumber());
    ag.setHintJokerNumber(form.getHintJokerNumber());

    ag.setServiceId(form.getServiceId());
    ag.setAuthKey(form.getAuthKey());
   
    ag.setRepublishNeeded(true);

    AOGGameDao.updateGame(ag, session);
   
    //max scores
    gh.setMaksimumScore(form.getMaxScores());
    GameDao.updateGame(gh, session);

    MessageBean.setMyMessage(req, "Game updated");
   
    return null;
View Full Code Here


  }
   
  //insert new level
  public ActionForward defaultMethodInsertLevel(ActionMapping am, ActionForm af, HttpServletRequest req, HttpServletResponse res,Game g,GameHiber gh,AOGGameHiber ag) {
   
    AOGAuthorForm form=(AOGAuthorForm)af;

    //insert at the end by default
    AOGGameLevelHiber newOne=new AOGGameLevelHiber();
    //get max level number
    int max=-1;
    ArrayList<AOGGameLevelHiber> levels=form.getOrderedLevels();
    for (AOGGameLevelHiber gameLevelHiber : levels) {
      if (gameLevelHiber.getLevelNumber()>max) max=gameLevelHiber.getLevelNumber();
    }
    //insert new one
    newOne.setLevelNumber(max+1);
    ag.getLevels().add(newOne);
    AOGGameLevelDao.persistAOGGameLevelHiber(newOne,session);

    ag.setRepublishNeeded(true);
   
    AOGGameDao.updateGame(ag, session);
   
    //add an introduction card to level
    AOGGameCardHiber ach=new AOGGameCardHiber();
    //fill data
   
    ach.setCardType(AOGGameCardDao.CARD_TYPE_INTRODUCTION);
    ach.setCardText(req.getParameter("levelintro"));
   
    ach.setCardNumber(0);
   
    AOGGameCardDao.persistAOGGameCardHiber(ach, session);
   
    newOne.getCards().add(ach);
   
    AOGGameLevelDao.updateGameLevel(newOne, session);
   
    form.setOrderedLevels(AOGGameLevelDao.getOrderedLevelsForGame(ag.getId(),session));

    MessageBean.setMyMessage(req, "Game updated");
    return am.findForward("ok");
  }
View Full Code Here

  }
 
  //insert new picture
  public ActionForward defaultMethodInsertPicture(ActionMapping am, ActionForm af, HttpServletRequest req, HttpServletResponse res,Game g,GameHiber gh,AOGGameHiber ag) {
   
    AOGAuthorForm form=(AOGAuthorForm)af;

    //insert at the end by default
    AOGGamePicturesHiber newOne=new AOGGamePicturesHiber();

    if (form.getPicture().getFileName()!=null)
      if (!form.getPicture().getFileName().equals("")) {
        try {
          newOne.setData(Hibernate.createBlob(form.getPicture().getInputStream()));
          newOne.setDataType(form.getPicture().getContentType());
          newOne.setPictureName(req.getParameter("pictureName"));
        } catch (Exception e) {
        }
      }
   
    session.persist(newOne);

    ag.getPictures().add(newOne);
    AOGGameDao.updateGame(ag, session);
   
    form.setPictures(new ArrayList<AOGGamePicturesHiber>(ag.getPictures()));
   
    MessageBean.setMyMessage(req, "New picture uploaded. It is ready to be used in the game.");
    return am.findForward("ok");
  }
View Full Code Here

        break;
      }
     
    }
   
    AOGAuthorForm form=(AOGAuthorForm)af;

    form.setPictures(new ArrayList<AOGGamePicturesHiber>(ag.getPictures()));
    MessageBean.setMyMessage(req, "Picture deleted");
    return am.findForward("ok");
  }
View Full Code Here

   
    ag.setRepublishNeeded(true);

    AOGGameDao.updateGame(ag, session);
   
    AOGAuthorForm form=(AOGAuthorForm)af;

    form.setOrderedLevels(AOGGameLevelDao.getOrderedLevelsForGame(ag.getId(),session));
    MessageBean.setMyMessage(req, "Level deleted");
    return am.findForward("ok");
  }
View Full Code Here

    }
   
    ag.setRepublishNeeded(true);
    AOGGameDao.updateGame(ag, session);
   
    AOGAuthorForm form=(AOGAuthorForm)af;
    form.setOrderedLevels(AOGGameLevelDao.getOrderedLevelsForGame(ag.getId(),session));
   
    MessageBean.setMyMessage(req, "Level moved up.");
    return am.findForward("ok");
   
  }
View Full Code Here

    }
   
    ag.setRepublishNeeded(true);
    AOGGameDao.updateGame(ag, session);

    AOGAuthorForm form=(AOGAuthorForm)af;
    form.setOrderedLevels(AOGGameLevelDao.getOrderedLevelsForGame(ag.getId(),session));
   
    MessageBean.setMyMessage(req, "Level moved down.");
    return am.findForward("ok");
  }
View Full Code Here

  public ActionForward defaultMethod(ActionMapping am, ActionForm af, HttpServletRequest req, HttpServletResponse res) {
   
    //we use transactions here!
    //super.defaultMethod(am, af, req, res);
   
    AOGAuthorForm form=(AOGAuthorForm)af;
    if (req.getParameter("startAuthoring")!=null) form.reset();

    form.setMyUserId(webUser.getId());

    if (req.getParameter("cancelChangesSubmit")!=null) {
      form.reset();
      return am.findForward("cancel");
    }
   
   
   
    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");
  }
View Full Code Here

TOP

Related Classes of si.unimb.cot.mgbl.gameauth.formbeans.AOGAuthorForm

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.