public static Entity getSingleUser(String email) { Iterable<Entity> results = Util.listEntities(USER, EMAIL, email); List<Entity> entity = new ArrayList<Entity>(); for (Entity e : results) if (e != null) entity.add(e); if (!entity.isEmpty()) { return (Entity) entity.remove(0); } return null; }
public static Entity createUser(String email, String necessidade, String token) { Entity user = getSingleUser(email); if (user == null) { user = new Entity(USER); user.setProperty(EMAIL, email); user.setProperty("necessidade", necessidade); user.setProperty("token", token); Util.persistEntity(user); } return user; }
public static Iterable<Entity> getUser(String email) { Iterable<Entity> entities = Util.listEntities(USER, EMAIL, email); return entities; }
/** * get All the items in the list * * @param kind : item kind * @return all the items */ public static Iterable<Entity> getAllUsers() { Iterable<Entity> entities = Util.listEntities(USER, null, null); return entities; }