Package com.google.appengine.api.datastore

Examples of com.google.appengine.api.datastore.DatastoreService


    return patientEntity;
  }

  private void UploadComments(Key dataEntity, ArrayList<Comment> comments) {
    DatastoreService datastore = DatastoreServiceFactory
        .getDatastoreService();
    for (Comment c: comments) {
      Entity commentEntity = new Entity("Comment", dataEntity);
      commentEntity.setProperty("Text", c.getContent());
      // Author entry consists of user's google account
      commentEntity.setProperty("Author", c.getAuthor().getGoogleUser());
      commentEntity.setProperty("Timestamp", c.getTimestamp());
      commentEntity.setProperty("Title", c.getTitle());
      ArrayList<String> keywords = extractKeywords(c.getContent());
      datastore.put(commentEntity);
      for (String keyword : keywords) {
        Entity kwEntity = new Entity("Keyword", commentEntity.getKey());
        kwEntity.setProperty("Word", keyword.replaceAll("[^A-Za-z]", "").toUpperCase());
        // If this is a chief complaint (first comment), set it as such
        if (c.getTitle().equals("Complaint")) {
          kwEntity.setProperty("Type", "CC");
        }
        else if (c.getTitle().equals("Reason")){
          kwEntity.setProperty("Type", "RE");
        }
        else {
          kwEntity.setProperty("Type", "KW");
        }
        datastore.put(kwEntity);
      }
    }
  }
View Full Code Here


    private static final String USER_ENABLED = "enabled";
    private static final String USER_AUTHORITIES = "authorities";

    public GaeUser findUser(String userId) {
        Key key = KeyFactory.createKey(USER_TYPE, userId);
        DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();

        try {
            Entity user = datastore.get(key);

            long binaryAuthorities = (Long)user.getProperty(USER_AUTHORITIES);
            Set<AppRole> roles = EnumSet.noneOf(AppRole.class);

            for (AppRole r : AppRole.values()) {
View Full Code Here

            binaryAuthorities |= 1 << r.getBit();
        }

        user.setUnindexedProperty(USER_AUTHORITIES, binaryAuthorities);

        DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
        datastore.put(user);
    }
View Full Code Here

        DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
        datastore.put(user);
    }

    public void removeUser(String userId) {
        DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
        Key key = KeyFactory.createKey(USER_TYPE, userId);

        datastore.delete(key);
    }
View Full Code Here

    try {
      l = Integer.parseInt(req.getParameter("limit"));
    } catch (Exception e) {
    }

    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();

    Query q = new Query(cl);
    ArrayList<Key> keys = new ArrayList<Key>();

    List<Entity> it = datastore.prepare(q).asList(withLimit(l));
    for (Entity entity : it) {
      keys.add(entity.getKey());
    }
    datastore.delete(keys);

    resp.setContentType("text/plain");
    try {
      resp.getWriter().println("Deleting items of type " + cl);
      resp.getWriter().println("Found " + keys.size() + " items");
View Full Code Here

  private static final String KIND = AppEngineCredentialStore.class.getName();

  @Override
  public void store(String userId, Credential credential) {
    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
    Entity entity = new Entity(KIND, userId);
    entity.setProperty("accessToken", credential.getAccessToken());
    entity.setProperty("refreshToken", credential.getRefreshToken());
    entity.setProperty("expirationTimeMillis", credential.getExpirationTimeMilliseconds());
    datastore.put(entity);
  }
View Full Code Here

    datastore.put(entity);
  }

  @Override
  public void delete(String userId, Credential credential) {
    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
    Key key = KeyFactory.createKey(KIND, userId);
    datastore.delete(key);
  }
View Full Code Here

    datastore.delete(key);
  }

  @Override
  public boolean load(String userId, Credential credential) {
    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
    Key key = KeyFactory.createKey(KIND, userId);
    try {
      Entity entity = datastore.get(key);
      credential.setAccessToken((String) entity.getProperty("accessToken"));
      credential.setRefreshToken((String) entity.getProperty("refreshToken"));
      credential.setExpirationTimeMilliseconds((Long) entity.getProperty("expirationTimeMillis"));
      return true;
    } catch (EntityNotFoundException exception) {
View Full Code Here

public class MyFirstTest extends LocalDataTestBase2GAE{

    // run this test twice to prove we're not leaking any state across tests
    private void doTest() {
        DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
        assertEquals(0, ds.prepare(new Query("yam")).countEntities(withLimit(10)));
        ds.put(new Entity("yam"));
        ds.put(new Entity("yam"));
        assertEquals(2, ds.prepare(new Query("yam")).countEntities(withLimit(10)));
    }
View Full Code Here

        String loginUrl = userService.createLoginURL("/");
        String logoutUrl = userService.createLogoutURL("/");

        Entity userPrefs = null;
        if (user != null) {
            DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
            MemcacheService memcache = MemcacheServiceFactory.getMemcacheService();

            String cacheKey = "UserPrefs:" + user.getUserId();
            userPrefs = (Entity) memcache.get(cacheKey);
            if (userPrefs == null) {
                log.warning("CACHE MISS");

                Key userKey = KeyFactory.createKey("UserPrefs", user.getUserId());
                try {
                    userPrefs = ds.get(userKey);
                    memcache.put(cacheKey, userPrefs);
                } catch (EntityNotFoundException e) {
                    // No user preferences stored.
                }
            } else {
View Full Code Here

TOP

Related Classes of com.google.appengine.api.datastore.DatastoreService

Copyright © 2018 www.massapicom. 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.