Package util

Source Code of util.UserHelper

package util;

import java.util.ArrayList;
import java.util.List;

import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.FetchOptions;
import com.google.appengine.api.datastore.PreparedQuery;
import com.google.appengine.api.datastore.Query;
import com.google.appengine.api.datastore.Query.SortDirection;

import entity.User;

public class UserHelper {
    public static List<User> getLadder(int offset, int number)
    {
        Query query = new Query("User");
       
        query.addSort("rating", SortDirection.DESCENDING);
        DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
        PreparedQuery pq = ds.prepare(query);
        List<Entity> results = pq.asList(FetchOptions.Builder.withLimit(number).offset(offset));
        List<User> ret = new ArrayList<User>();
        for(Entity e: results)
        {
            ret.add(new User(e));
        }
        //System.out.println("Have " + ret.size());
        return ret;
    }
}
TOP

Related Classes of util.UserHelper

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.