Package si.unimb.cot.mgbl.gamemgmt.formbeans

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


    super.defaultMethod(am, af, req, res);

    this.session = HibernateSessions.getSessionFactory().openSession();
    try {
     
      ListGamesForm form=(ListGamesForm) af;
     
      form.setCriteriaName("");
 
      form.setMyUserId(webUser.getId());
     
      String criteria=req.getParameter("criteria");
     
      ArrayList<Game> ret=null;
 
      if ("all".equals(criteria)) {
        ret=GameDao.getAllGames(session);
        form.setCriteriaName("All games I can browse");
      }
      if ("enabled".equals(criteria)) {
        ret=GameDao.getAllGamesExceptRemoved(session);
        form.setCriteriaName("All enabled games I can browse");
      }
      if ("play".equals(criteria)) {
        ArrayList<Game> temp=GameDao.getAllGames(session);
        //apply filter
        ret=new ArrayList<Game>();
        for(Game gm:temp) {
          if (SecurityCenter.canIPlayGame(webUser.getId(), gm, session))
            ret.add(gm);
        }
        form.setCriteriaName("All games I can play");
      }
      if ("edit".equals(criteria)) {
        ArrayList<Game> temp=GameDao.getAllGames(session);
        //apply filter
        ret=new ArrayList<Game>();
        for(Game gm:temp) {
          if (SecurityCenter.canIEditGame(webUser.getId(), gm.getId(), session))
            ret.add(gm);
        }
        form.setCriteriaName("All games I can edit");
      }
     
      if (ret==null) ret=GameDao.getAllGames(session);
     
//      if (req.getParameter("newGames")!=null) {
//        setCriteriaName+="new ";
//        ArrayList<Game> ret2=new ArrayList<Game>();
//        Calendar yesterday=new GregorianCalendar();
//        yesterday.add(Calendar.HOUR, -48);
//        for (Game game : ret) {
//          Calendar c=game.getCreationTime();
//          if (c.after(yesterday))
//            ret2.add(game);
//        }
//        ret=ret2;
//      }
     
//      if (req.getParameter("startedGames")!=null) {
//        setCriteriaName+="started ";
//        ArrayList<Game> ret2=new ArrayList<Game>();
//        for (Game game : ret) {
//          if (game.getStatus()==Game.STATUS_STARTED)
//            ret2.add(game);
//        }
//        ret=ret2;
//      }
     
//      setCriteriaName+="games  ";
     
      if (req.getParameter("label")!=null) {
        long labelId=Long.parseLong(req.getParameter("label"));
        GameLabelHiber ghl=GameLabelDao.findGameLabel(labelId, session);
        form.setCriteriaName("All games with label '"+ghl.getName()+"'");
//        setCriteriaName+="with label "+ghl.getName();
        ArrayList<Game> ret2=new ArrayList<Game>();
        for (Game game : ret) {
          if (GameLabelDao.isThereLabelInGame(game, labelId))
            ret2.add(game);
        }
        ret=ret2;
      }

      if (req.getParameter("dublincore")!=null) {
        long labelId=Long.parseLong(req.getParameter("dublincore"));
//        setCriteriaName+="including Dublin Core metadata ";
        ArrayList<Game> ret2=new ArrayList<Game>();
        for (Game game : ret) {
          if (game.getId()==labelId) {
            ret2.add(game);
           
            //create appropriate metadata
           
              String DC_contributor=game.getDC_contributor();
              String DC_coverage=game.getDC_coverage();
              String DC_creator=game.getDC_creator();
              String DC_date=game.getDC_date();
              String DC_description=game.getDC_description();
              String DC_format=game.getDC_format();
              String DC_identifier=game.getDC_identifier();
              String DC_language=game.getDC_language();
              String DC_publisher=game.getDC_publisher();
              String DC_relation=game.getDC_relation();
              String DC_rights=game.getDC_rights();
              String DC_source=game.getDC_source();
              String DC_subject=game.getDC_subject();
              String DC_title=game.getDC_title();
              String DC_type=game.getDC_type();
             
              if (!game.getDC_contributor_manual().booleanValue()) {
               
                String gameCreatorString=game.getCreator()+"";
              try {
                evolaris.framework.um.datamodel.User usr=
                  si.unimb.cot.mgbl.gamemgmt.dao.UserDao.findUser(game.getCreator(),session);
                gameCreatorString=usr.getLastName()+" "+usr.getFirstName();
              } catch (Exception eee){
                //leave number if user can not be retrieved
              }
                DC_contributor=gameCreatorString;
                game.setDC_contributor(DC_contributor);
              }
              if (!game.getDC_coverage_manual().booleanValue()) {
                DC_coverage="unknown";
                game.setDC_coverage(DC_coverage);
              }
              if (!game.getDC_creator_manual().booleanValue()) {
                DC_creator=DC_contributor;
                game.setDC_creator(DC_creator);
              }
              if (!game.getDC_date_manual().booleanValue()) {
                DC_date=game.getCreationTimeDCString();
                game.setDC_date(DC_date);
              }
              if (!game.getDC_format_manual().booleanValue()) {
                DC_format="text/html, text/html; charset=UTF-8";
                game.setDC_format(DC_format);
              }
              if (!game.getDC_identifier_manual().booleanValue()) {
                DC_identifier=req.getRequestURI();
                game.setDC_identifier(DC_identifier);
              }
              if (!game.getDC_language_manual().booleanValue()) {
                DC_language="en";
                game.setDC_language(DC_language);
              }
              if (!game.getDC_publisher_manual().booleanValue()) {
                DC_publisher="mGBL";
                game.setDC_publisher(DC_publisher);
              }
              if (!game.getDC_relation_manual().booleanValue()) {
                DC_relation="mGBL";
                game.setDC_relation(DC_relation);
              }
              if (!game.getDC_rights_manual().booleanValue()) {
                DC_rights="unknown";
                game.setDC_rights(DC_rights);
              }
              if (!game.getDC_source_manual().booleanValue()) {
                DC_source=req.getRequestURL().toString();
                game.setDC_source(DC_source);
              }
              if (!game.getDC_description_manual().booleanValue()) {
                DC_description=game.getDescription();
                game.setDC_description(DC_description);
              }
              if (!game.getDC_subject_manual().booleanValue()) {
                DC_subject="mobile game";
                game.setDC_subject(DC_subject);
              }
              if (!game.getDC_title_manual().booleanValue()) {
                DC_title=game.getName();
                game.setDC_title(DC_title);
              }
              if (!game.getDC_type_manual().booleanValue()) {
                DC_type="Software.Executable";
                game.setDC_type(DC_type);
              }
             
            StringBuffer sb=new StringBuffer();
            sb.append("<link rel=\"schema.DC\" href=\"http://purl.org/dc/elements/1.1/\" /> \n");
            sb.append("<link rel=\"schema.DCTERMS\" href=\"http://purl.org/dc/terms/\" /> \n");

              sb.append("<META NAME=\"DC.Contributor\" CONTENT=\""+DC_contributor+"\" />\n");
              sb.append("<META NAME=\"DC.Coverage\" CONTENT=\""+DC_coverage+"\" />\n");
              sb.append("<META NAME=\"DC.Creator\" CONTENT=\""+DC_creator+"\" />\n");
              sb.append("<META NAME=\"DC.Date\" CONTENT=\""+DC_date+"\" />\n");
              sb.append("<META NAME=\"DC.Description\" CONTENT=\""+DC_description+"\" />\n");
              sb.append("<META NAME=\"DC.Format\" CONTENT=\""+DC_format+"\" />\n");
              sb.append("<META NAME=\"DC.Identifier\" CONTENT=\""+DC_identifier+"\" />\n");
              sb.append("<META NAME=\"DC.Language\" CONTENT=\""+DC_language+"\" />\n");
              sb.append("<META NAME=\"DC.Publisher\" CONTENT=\""+DC_publisher+"\" />\n");
              sb.append("<META NAME=\"DC.Relation.Requires\" CONTENT=\""+DC_relation+"\" />\n");
              sb.append("<META NAME=\"DC.Rights\" CONTENT=\""+DC_rights+"\" />\n");
              sb.append("<META NAME=\"DC.Source\" SCHEME=\"URI\" CONTENT=\""+DC_source+"\" />\n");             
              sb.append("<META NAME=\"DC.Subject\" CONTENT=\""+DC_subject+"\" />\n");
              sb.append("<META NAME=\"DC.Title\" CONTENT=\""+DC_title+"\" />\n");
              sb.append("<META NAME=\"DC.Type\" CONTENT=\"S"+DC_type+"\" />\n");

            DublinCoreBean.setMyMessage(req,sb.toString());
                   
            /*
            http://dublincore.org/documents/dces/
            */           
          }
        }
        ret=ret2;
      }
     
     
      //apply security
     
      ArrayList<Game> ret2=new ArrayList<Game>();
      for (Game game : ret) {
        if (SecurityCenter.canIBrowseGame(webUser.getId(), game,session)) {
          ret2.add(game);
          game.getBlog();
          game.getApplication();
        }
      }
     
      form.setGames(ret2);
 
      //form.setCriteriaName(setCriteriaName);
      return am.findForward("list");
     
    } finally {
View Full Code Here


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

      ListGamesForm form=(ListGamesForm) af;
 
      form.setMyUserId(webUser.getId());
     
      long id=Long.parseLong(req.getParameter("id"));
 
      ArrayList<Game> ret=new ArrayList<Game>();
 
      Game g=GameDao.findGame(id,session);
     
      if (SecurityCenter.canIPlayGame(form.getMyUserId(), g, session)) {
        ret.add(g);
      }
 
      form.setGames(ret);
 
      form.setCriteriaName("");
      return am.findForward("list");
     
    } finally {
      this.session.close();
    }
View Full Code Here

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

      ListGamesForm form=(ListGamesForm) af;

      form.setMyUserId(webUser.getId());
     
      String setCriteriaName="My ";
     
      ArrayList<Game> ret=GameDao.getAllGamesExceptRemoved(session);
     
      //filter those I can play
     
      ArrayList<Game> ret2=new ArrayList<Game>();
      for (Game game : ret) {
        if (SecurityCenter.canIPlayGame(form.getMyUserId(), game, session)) {
          ret2.add(game);
        }
      }
      ret=ret2;
     
      form.setGames(ret);
 
      form.setCriteriaName(setCriteriaName);
      return am.findForward("list");
     
    } finally {
      this.session.close();
    }
View Full Code Here

TOP

Related Classes of si.unimb.cot.mgbl.gamemgmt.formbeans.ListGamesForm

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.