Package com.jeck.microblogging.utils

Source Code of com.jeck.microblogging.utils.StoreServiceDAO

package com.jeck.microblogging.utils;

import java.util.List;

import com.googlecode.objectify.ObjectifyOpts;
import com.googlecode.objectify.ObjectifyService;
import com.googlecode.objectify.Query;
import com.googlecode.objectify.util.DAOBase;
import com.jeck.microblogging.persistence.entities.User;

public class StoreServiceDAO extends DAOBase {
  static{
    ObjectifyService.register(User.class);
  }
 
  public StoreServiceDAO(){
    super();
  }
 
  public StoreServiceDAO(ObjectifyOpts opts){
    super(opts);
  }
 
  public User getOrCreateUser(String accessToken)
    {
        User found = ofy().find(User.class, accessToken);
        if (found == null)
            return new User(accessToken);
        else
            return found;
    }
 
  public <T> T find(Class<T> cls,String key){
    return ofy().find(cls,key);
  }
 
  public <T> void store(T user){
    ofy().put(user);
  }
 
  public <T> List<T> findList(Class<T> cls){
    Query<T> query = ofy().query(cls);
    return query.list();
  }
}
TOP

Related Classes of com.jeck.microblogging.utils.StoreServiceDAO

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.