Examples of AOGGameHiber


Examples of si.unimb.cot.mgbl.gamemgmt.aog.datamodel.AOGGameHiber

      if (USE_TRANSACTIONS_INSIDE) t=hibernateSession.beginTransaction();
      hibernateSession.delete(security);
      if (t!=null) t.commit();
    }
    //delete AOG record - if exists
    AOGGameHiber gm=AOGGameDao.findGameHiberForGame(id, hibernateSession);
    if (gm!=null) AOGGameDao.deleteGame(gm.getId(), hibernateSession);

    //delete magobal records - if exist
    ArrayList<MogabalEventHiber> events=MogabalGameDao.getGameEvents(id, hibernateSession);
    //first resolve all forward events
    for (MogabalEventHiber evt:events) {
View Full Code Here

Examples of si.unimb.cot.mgbl.gamemgmt.aog.datamodel.AOGGameHiber

  public static AOGGameHiber findGameHiber(long id, Session hibernateSession) {
    Query q=hibernateSession.createQuery("select o from AOGGameHiber o where o.id=:id");
    q.setParameter("id",id);
    for (Iterator iter = q.iterate(); iter.hasNext();) {
      AOGGameHiber ret=(AOGGameHiber)iter.next();
      //pre-read all levels
      Set<AOGGameLevelHiber> levels=ret.getLevels();
      for (AOGGameLevelHiber gameLevelHiber : levels) {
        gameLevelHiber.getId();
      }
      //pre-read all pictures
      Set<AOGGamePicturesHiber> pictures=ret.getPictures();
      for (AOGGamePicturesHiber gamePicturesHiber : pictures) {
        gamePicturesHiber.getPictureName();
      }
      return ret;
    }
View Full Code Here

Examples of si.unimb.cot.mgbl.gamemgmt.aog.datamodel.AOGGameHiber

 
  public static AOGGameHiber findGameHiberForGame(long gameId, Session hibernateSession) {
    Query q=hibernateSession.createQuery("select o from AOGGameHiber o where o.game.id=:id");
    q.setParameter("id",gameId);
    for (Iterator iter = q.iterate(); iter.hasNext();) {
      AOGGameHiber ret=(AOGGameHiber)iter.next();
      //pre-read all levels
      Set<AOGGameLevelHiber> levels=ret.getLevels();
      for (AOGGameLevelHiber gameLevelHiber : levels) {
        gameLevelHiber.getId();
      }
      //pre-read all pictures
      Set<AOGGamePicturesHiber> pictures=ret.getPictures();
      for (AOGGamePicturesHiber gamePicturesHiber : pictures) {
        gamePicturesHiber.getPictureName();
      }
      return ret;
    }
View Full Code Here

Examples of si.unimb.cot.mgbl.gamemgmt.aog.datamodel.AOGGameHiber

    if (t!=null) t.commit();
    return newGame.getId();
  }
 
  public static void deleteGame(long id,Session hibernateSession) {
    AOGGameHiber gt=findGameHiber(id,hibernateSession);
    if (gt==null) return;
    Transaction t=null;
    if (USE_TRANSACTIONS_INSIDE) t=hibernateSession.beginTransaction();
    //delete levels
    Set<AOGGameLevelHiber> cards=gt.getLevels();
    for (AOGGameLevelHiber gameCardHiber : cards) {
      AOGGameLevelDao.deleteGameLevel(gameCardHiber.getId(), hibernateSession);
    }
    //delete pictures
    Set<AOGGamePicturesHiber> pictures=gt.getPictures();
    for (AOGGamePicturesHiber p : pictures) {
      hibernateSession.delete(p);
    }

    hibernateSession.delete(gt);
View Full Code Here

Examples of si.unimb.cot.mgbl.gamemgmt.aog.datamodel.AOGGameHiber

  //use transactions strictly, false if transactions are handled outside the methods
  private static boolean USE_TRANSACTIONS_INSIDE=false;

  public static ArrayList<AOGGameLevelHiber> getOrderedLevelsForGame(long gameId, Session hibernateSession) {
    ArrayList<AOGGameLevelHiber> ret=new ArrayList<AOGGameLevelHiber>();
    AOGGameHiber ag=AOGGameDao.findGameHiber(gameId, hibernateSession);
    if (ag.getLevels()==null) return ret;
    Set<AOGGameLevelHiber> levels=ag.getLevels();
    for (AOGGameLevelHiber gameLevelHiber : levels) {
      ret.add(gameLevelHiber);
      //pre read cards
      Set<AOGGameCardHiber> cards=gameLevelHiber.getCards();
      for (AOGGameCardHiber gameCardHiber : cards) {
View Full Code Here

Examples of si.unimb.cot.mgbl.gamemgmt.aog.datamodel.AOGGameHiber

    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

Examples of si.unimb.cot.mgbl.gamemgmt.aog.datamodel.AOGGameHiber

   
    GameHiber g=GameDao.findGameHiber(id,session);
    form.setGh(g);
    form.setG(GameDao.findGame(id,session));

    AOGGameHiber ag=AOGGameDao.findGameHiberForGame(g.getId(), session);
    form.setAh(ag);
   
    AOGGameLevelHiber level=AOGGameLevelDao.findGameLevelHiber(lid, session);
    form.setLh(level);

    AOGGameCardHiber card=AOGGameCardDao.findGameCardHiber(cid, session);
    form.setCh(card);

    //insert new picture
    if (req.getParameter("newPictureSubmit")!=null){

      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);
     
    }

    //delete picture?
    if (req.getParameter("deletePicture")!=null){
   
      String deletePicture=req.getParameter("deletePicture");
      long pictureId=Long.parseLong(deletePicture);
     
      Set<AOGGamePicturesHiber> pctrs=ag.getPictures();
      for (Iterator iterator = pctrs.iterator(); iterator.hasNext();) {
        AOGGamePicturesHiber l = (AOGGamePicturesHiber) iterator.next();
       
        if (l.getId()==pictureId) {
          iterator.remove();
          session.delete(l);
 
          ag.setRepublishNeeded(true);
          AOGGameDao.updateGame(ag, session);
         
          break;
        }
       
      }
    }
   
   
    form.setPictures(new ArrayList<AOGGamePicturesHiber>(ag.getPictures()));

   
    //fill tables
    AOGGameCardHiber[] orderedSimulations=AOGGameCardDao.getOrderedCardsInSimulation(card);
    AOGGameCardHiber[] orderedIncidents0=AOGGameCardDao.getOrderedCardsInSimulation(orderedSimulations[0]);
    AOGGameCardHiber[] orderedIncidents1=AOGGameCardDao.getOrderedCardsInSimulation(orderedSimulations[1]);
    AOGGameCardHiber[] orderedIncidents2=AOGGameCardDao.getOrderedCardsInSimulation(orderedSimulations[2]);
    AOGGameCardHiber[] orderedIncidents3=AOGGameCardDao.getOrderedCardsInSimulation(orderedSimulations[3]);
   
    //save data
   
    if (req.getParameter("changeData")!=null) {
      fillDataFromRequest( req,orderedSimulations,orderedIncidents0,orderedIncidents1,orderedIncidents2,orderedIncidents3);
     
      //handle case data copying
      handleCaseCopying( req,orderedSimulations,orderedIncidents0,orderedIncidents1,orderedIncidents2,orderedIncidents3);
     
      AOGGameCardDao.updateGameCardRecursively(card,session);

      ag.setRepublishNeeded(true);
      AOGGameDao.updateGame(ag, session);
    }
    form.setCh(card);
   
    form.setOrderedSimulations(orderedSimulations);
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.