All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.officefloor.tutorial.objectifyhttpserver.ObjectifyLogic Maven / Gradle / Ivy

There is a newer version: 3.17.0
Show newest version
package net.officefloor.tutorial.objectifyhttpserver;

import java.util.List;

import com.googlecode.objectify.Objectify;

import net.officefloor.web.HttpPathParameter;
import net.officefloor.web.ObjectResponse;

/**
 * {@link Objectify} logic.
 * 
 * @author Daniel Sagenschneider
 */
// START SNIPPET: tutorial
public class ObjectifyLogic {

	public void savePost(Post post, Objectify objectify) {
		objectify.save().entities(post).now();
	}

	public void retrieveAllPosts(Objectify objectify, ObjectResponse> response) {
		List posts = objectify.load().type(Post.class).list();
		response.send(posts);
	}

	public void retrievePost(@HttpPathParameter("id") String identifier, Objectify objectify,
			ObjectResponse response) {
		Post post = objectify.load().type(Post.class).id(Long.parseLong(identifier)).now();
		response.send(post);
	}

}
// END SNIPPET: tutorial




© 2015 - 2024 Weber Informatics LLC | Privacy Policy