Package com.appspot.bambugame.server.rest

Source Code of com.appspot.bambugame.server.rest.HangmanQuestionsResyncServlet

/*
*
* Copyright 2011, Ibrahim Arief
*
* This file is part of Bambu Game Backend.
*
* Bambu Game Backend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Bambu Game Backend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Bambu Game Backend.  If not, see <http://www.gnu.org/licenses/>.
*
*/

package com.appspot.bambugame.server.rest;

import java.util.Arrays;
import java.util.List;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.appspot.bambugame.server.data.HangmanPlurkQuestion;
import com.appspot.bambugame.server.data.HangmanQuestion;
import com.google.appengine.api.datastore.QueryResultIterable;
import com.google.appengine.repackaged.com.google.common.collect.Lists;
import com.googlecode.objectify.Objectify;
import com.googlecode.objectify.ObjectifyService;

public class HangmanQuestionsResyncServlet extends HttpServlet
{
    /**
     *
     */
    private static final long serialVersionUID = -8957362320144318364L;

    public void doGet(HttpServletRequest req, HttpServletResponse resp)
    {
        try
        {
            List<HangmanQuestion> tQuestions = getAllQuestions();
           
            Objectify tObjectify = ObjectifyService.begin();
            for (HangmanQuestion tQuestion : tQuestions)
            {
                tQuestion.APPEARANCE_COUNT += 3;
               
                resp.getWriter().write("\n<br>Setting question " + tQuestion.SENTENCE + " to have appearance count as " + tQuestion.APPEARANCE_COUNT);
               
                tObjectify.put( tQuestion );
            }           
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
            System.out.println("Exception " + ex.getClass() + ", " + ex.getMessage() + " : " + Arrays.deepToString( ex.getStackTrace() ));
        }
    }
   
    public List<HangmanPlurkQuestion> getAllPlurkQuestions()
    {
        Objectify tObjectify = ObjectifyService.begin();
        QueryResultIterable<HangmanPlurkQuestion> tRetIter = tObjectify.query( HangmanPlurkQuestion.class ).filter( "HINT =", "country & capital" ).fetch();
       
        return Lists.newArrayList( tRetIter );
    }
   
    public List<HangmanQuestion> getAllQuestions()
    {
        Objectify tObjectify = ObjectifyService.begin();
        QueryResultIterable<HangmanQuestion> tRetIter = tObjectify.query( HangmanQuestion.class ).filter( "HINT =", "country & capital" ).fetch();
       
        return Lists.newArrayList( tRetIter );
    }
}
TOP

Related Classes of com.appspot.bambugame.server.rest.HangmanQuestionsResyncServlet

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.