Package com.appspot.secretcuz.service

Source Code of com.appspot.secretcuz.service.BlogPostService

package com.appspot.secretcuz.service;

import java.util.List;

import com.appspot.secretcuz.entity.BlogPost;
import com.google.appengine.api.datastore.Cursor;
import com.googlecode.objectify.cmd.Query;

import static com.appspot.secretcuz.entity.OfyService.ofy;

public class BlogPostService {
 
  public static List<BlogPost> get() {
    return ofy().load().type(BlogPost.class).order("-date").list();
  }
 
  public static BlogPost get(Long id) {
    BlogPost bp = ofy().load().type(BlogPost.class).id(id).get();
    return bp;
  }
 
  public static Query<BlogPost> get(Cursor cursor, int limit) {
    if (cursor == null) {
      return ofy().load().type(BlogPost.class).limit(limit);
    }
    return ofy().load().type(BlogPost.class).limit(limit).startAt(cursor);
  }

  public static BlogPost save(BlogPost bp) {
    return get(ofy().save().entity(bp).now().getId());
  }
 
  public static void delete(BlogPost bp) {
    ofy().delete().entity(bp);
  }
}
TOP

Related Classes of com.appspot.secretcuz.service.BlogPostService

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.