Package com.google.appengine.api.datastore

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


  }
 
  @Override
  public void copy(BaseEntity entity) {
    Key myKey = getKey();
    Entity buf = new Entity("tmp");
    entity.save(buf);
    load(buf);
    setKey(myKey);
  }
View Full Code Here


    return save(model, true);
  }
   
  private T save(T model, boolean audit) {
    getQueryCache().removeQueries(clazz);
    Entity entity = null;
    if (model.getId() != null) {
      try {
        getDao().getDaoStat().incGetCalls();
        entity = getDatastore().get(getKey(model.getId()));
        getEntityCache().removeEntity(clazz, model.getId());
      }
      catch (EntityNotFoundException e) {
        logger.error("Entity not found " + clazz.getName() + " "
            + model.getId());
      }
    }
    if (entity == null) {
      entity = new Entity(getKind());
      model.setCreateUserEmail(getCurrentUserEmail());
    }
    if (audit) {
      model.setModDate(new Date());
      model.setModUserEmail(getCurrentUserEmail());
    }
    model.save(entity);
    getDatastore().put(entity);
    model.setKey(entity.getKey());
    return model;
  }
View Full Code Here

    }
    StringBuffer result = new StringBuffer();
    for (UpdateTask task : tasks) {
      if (getConfig().getProperty("version").equals(task.getFromVersion())) {
        result.append("<p>").append(task.update()).append("</p>");
        Entity config = getConfig();
        config.setProperty("version", task.getToVersion());
        datastore.put(config);
      }
    }
    business.getSystemService().getCache().clear();
    return result.toString();
View Full Code Here

    Query query = new Query("ConfigEntity");
    return datastore.prepare(query).asIterator().next();
  }
 
  private void addConfigVersion() {
    Entity config = getConfig();
    config.setProperty("version", "0.0.2");
    config.setProperty("enableRecaptcha", false);
    datastore.put(config);
  }
View Full Code Here

            Expiration expires = Expiration.onDate(expire);

            memcache.put(id, bytes, expires);

            DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
            Entity entity = new Entity(AC_BASE, id);
            entity.setProperty(PROPERTY_EXPIRES, expire.getTime());
            entity.setProperty(PROPERTY_DATA, new Blob(bytes));
            ds.put(entity);

        } catch (DeadlineExceededException e) {
            getLogger().log(Level.WARNING, "DeadlineExceeded for {0}",
                    session.getId());
View Full Code Here

        String id = AC_BASE + session.getId();
        byte[] serializedAC = (byte[]) memcache.get(id);
        if (serializedAC == null) {
            DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
            Key key = KeyFactory.createKey(AC_BASE, id);
            Entity entity = null;
            try {
                entity = ds.get(key);
            } catch (EntityNotFoundException e) {
                // Ok, we were a bit optimistic; we'll create a new one later
            }
            if (entity != null) {
                Blob blob = (Blob) entity.getProperty(PROPERTY_DATA);
                serializedAC = blob.getBytes();
                // bring it to memcache
                memcache.put(
                        AC_BASE + session.getId(),
                        serializedAC,
View Full Code Here

  public SienaFuture<Void> insert(final Object obj) {
    final Class<?> clazz = obj.getClass();
    final ClassInfo info = ClassInfo.getClassInfo(clazz);
    final Field idField = info.getIdField();
   
    Entity entity = GaeMappingUtils.createEntityInstance(idField, info, obj);
    GaeMappingUtils.fillEntity(obj, entity);
    Future<Key> future = ds.put(entity);
   
    Future<Void> wrapped = new SienaFutureWrapper<Key, Void>(future) {
             @Override
View Full Code Here

    Transaction txn = ds.getCurrentTransaction();
    return new SienaFutureContainer<Void>(txn.rollbackAsync());
  }

  public SienaFuture<Void> update(Object obj) {
    Entity entity = new Entity(GaeMappingUtils.getKey(obj));
    GaeMappingUtils.fillEntity(obj, entity);
    Future<Key> future = ds.put(entity);
   
    Future<Void> wrapped = new SienaFutureWrapper<Key, Void>(future) {
            @Override
View Full Code Here

      }
      // associates linked models to their models
      // linkedModels is just a map to contain entities already mapped
      Map<Key, Object> linkedModels = new HashMap<Key, Object>();
      Object linkedObj;
      Entity entity;
     
      for(Field field: fieldMap.keySet()){
        Object objVal = field.get(model);
        Key key = GaeMappingUtils.getKey(objVal);
        linkedObj = linkedModels.get(key);
View Full Code Here

      }
      // associates linked models to their models
      // linkedModels is just a map to contain entities already mapped
      Map<Key, Object> linkedModels = new HashMap<Key, Object>();
      Object linkedObj;
      Entity entity;
     
      for (final T model : models) {
        for(Field field: fieldMap.keySet()){
          Object objVal = Util.readField(model, field);
                    // our object is not linked to another object...so it doesn't have any key
View Full Code Here

TOP

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

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.