Examples of AddNewGameTemplateForm


Examples of si.unimb.cot.mgbl.gamemgmt.formbeans.AddNewGameTemplateForm

  public ActionForward defaultMethod(ActionMapping am, ActionForm af, HttpServletRequest req, HttpServletResponse res) {
   
    //we use transactions here
    //super.defaultMethod(am, af, req, res);
   
    AddNewGameTemplateForm form=(AddNewGameTemplateForm)af;

    form.setMyUserId(webUser.getId());
   
    if (req.getParameter("cancelChangesSubmit")!=null) {
      form.reset();
      return am.findForward("cancel");
    }
   
    GameTemplateHiber gt=null;
    if (form.isModifyMe()) {
      //modify existing
      gt=GameTemplateDao.findGameTemplateHiber(form.getModifyId(),session);
      if (!SecurityCenter.canIEditGameTemplate(webUser.getId(), gt)) {
        MessageBean.setMyMessage(req, ("Error: Insufficient privileges."));
        form.reset();
        return am.findForward("ok");
      }
    } else {
      //add new
      gt=new GameTemplateHiber();
      if (!SecurityCenter.canICreateGameTemplate(webUser.getId(),session)) {
        MessageBean.setMyMessage(req, ("Error: Insufficient privileges."));
        form.reset();
        return am.findForward("ok");
      }
    }
    gt.setAuthoringHandlerCode(form.getAuthoringHandlerCode());
    gt.setName(form.getName());
    gt.setDescription(form.getDescription());
    //gt.setGameType(form.getGameType());
    gt.setCreator(webUser.getId());
    gt.setLearningGoal(form.getLearningGoal());
    gt.setTargetGroup(form.getTargetGroup());
    gt.setGameType(form.getSelectedArticle()+"");
    gt.setLearningGoal(form.getLearningGoal());
    gt.setTargetGroup(form.getTargetGroup());
    //gt.setLogo(null);
    //gt.setJarContent(null);
    //gt.setParamFileContent(null);
    //gt.setLogoType("image/jpeg");
   
    //TODO save jar file to filesystem! - that file will be used to produce games for mobile phones
   
    if (form.getLogo().getFileName()!=null)
      if (!form.getLogo().getFileName().equals("")) {
        try {
          gt.setLogo(Hibernate.createBlob(form.getLogo().getInputStream()));
          gt.setLogoType(form.getLogo().getContentType());
        } catch (Exception e) {
          // TODO Wo handle exception
        }
      }
//    if (form.getJarContent().getFileName()!=null)
//      if (!form.getJarContent().getFileName().equals("")) {
//        try {
//          gt.setJarContent(Hibernate.createBlob(form.getJarContent().getInputStream()));
//        } catch (Exception e) {
//        }
//      }
//    if (form.getParamFileContent().getFileName()!=null)
//      if (!form.getParamFileContent().getFileName().equals("")) {
//        try {
//          gt.setParamFileContent(Hibernate.createBlob(form.getParamFileContent().getInputStream()));
//        } catch (Exception e) {
//        }
//      }
   
    if (form.isModifyMe()) {
      GameTemplateDao.updateGameTemplate(gt,session);
      MessageBean.setMyMessage(req, "Game template updated.");
    } else {
      GameTemplateDao.persistGameTemplate(gt,session);
      MessageBean.setMyMessage(req, "Game template created.");
    }
   
    form.reset();
    return am.findForward("ok");
  }
View Full Code Here

Examples of si.unimb.cot.mgbl.gamemgmt.formbeans.AddNewGameTemplateForm

    super.defaultMethod(am, af, req, res);
   
    this.session = HibernateSessions.getSessionFactory().openSession();
    try {

      AddNewGameTemplateForm form=(AddNewGameTemplateForm)af;
      form.reset();
     
     
      //find blog with code "mgblgamestyles"
      Blog bl=null;
      Query q=session.createQuery("select o from Blog o where o.code=:code");
      q.setParameter("code","mgblgamestyles");
      for (Iterator iter = q.iterate(); iter.hasNext();) {
        bl=(Blog)iter.next();
      }
      if (bl!=null) {
        //read the game types from articles
        Query qa=session.createQuery("select o from Article o where o.blog.id=:id");
        qa.setParameter("id",bl.getId());
        for (Iterator iter = qa.iterate(); iter.hasNext();) {
          Article a=(Article)iter.next();
          form.getGameTypeArticles().add(a);
        }
      }
     
      form.setMyUserId(webUser.getId());
     
      if (req.getParameter("id")!=null) {
        long id=Long.parseLong(req.getParameter("id"));
        GameTemplate gt=GameTemplateDao.findGameTemplate(id,session);
        if (SecurityCenter.canIEditGameTemplate(webUser.getId(), gt)) {
          form.setName(gt.getName());
          form.setDescription(gt.getDescription());
          //form.setGameType(gt.getGameType());
          form.setLearningGoal(gt.getLearningGoal());
          form.setTargetGroup(gt.getTargetGroup());
          form.setAuthoringHandlerCode(gt.getAuthoringHandlerCode());
          form.setModifyMe(true);
          form.setModifyId(id);
          try {
            //game type id is written in gt.getGameType() -- because of refactorings..
            //there could be written text as well - if game type was not selected...
            form.setSelectedArticle(Long.parseLong(gt.getGameType()));
          } catch (Exception e) {
          }
        } else {
          MessageBean.setMyMessage(req, ("Error: Insufficient privileges."));
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.