Package si.unimb.cot.mgbl.gamemgmt.aog.datamodel

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


    //aog game picture
    if (entity.equals("aogPicture")) {
      //Session hibernateSession=HibernateSessions.startTransactionSilently();
      Session hibernateSession = HibernateSessions.getSessionFactory().openSession();
      try {
        AOGGamePicturesHiber pict=null;
        Query q=hibernateSession.createQuery("select o from AOGGamePicturesHiber o where o.id=:id");
        q.setParameter("id",id);
        for (Iterator iter = q.iterate(); iter.hasNext();) {
          pict=(AOGGamePicturesHiber)iter.next();
        }
       
        if (pict.getData()==null) {
          try {
            res.setContentType("image/png");
            OutputStream os = res.getOutputStream();
            ImageIO.write(getNullImage(), "png", os);
            os.close();
          } catch (Exception e) {
          }
         
        } else {
          res.setContentType(pict.getDataType());
          try {
            InputStream in=pict.getData().getBinaryStream();
            OutputStream out = res.getOutputStream();
            byte[] buf = new byte[1024];
            int count = 0;
            while((count = in.read(buf)) >= 0) {
              out.write(buf, 0, count);
View Full Code Here


  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);
View Full Code Here

    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);
View Full Code Here

    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);
View Full Code Here

TOP

Related Classes of si.unimb.cot.mgbl.gamemgmt.aog.datamodel.AOGGamePicturesHiber

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.