示例#1
0
  /*
   * (non-Javadoc)
   *
   * @see yanitime4u.yanitime.logic.UserLogic#delete(com.google.appengine.api.datastore.Key,
   * java.lang.Long)
   */
  @Override
  public void delete(Key key, Long version) {
    AssertionUtil.assertNotNull(key);
    AssertionUtil.assertNotNull(version);

    Transaction tx = Datastore.beginTransaction();
    try {
      Users latest = Datastore.get(meta, key, version);
      Datastore.delete(latest.getKey());
      tx.commit();
    } catch (ConcurrentModificationException e) {
      if (tx.isActive()) {
        tx.rollback();
      }
      throw e;
    }
  }
示例#2
0
  /*
   * (non-Javadoc)
   *
   * @see
   * yanitime4u.yanitime.logic.UserLogic#findByCondition(yanitime4u.yanitime.condition.UserCondition
   * )
   */
  @Override
  public List<Users> findByCondition(UserCondition condition) {
    AssertionUtil.assertNotNull(condition);
    ModelQuery<Users> query = Datastore.query(meta);
    FilterCriterion[] filters = createFilterByCondition(condition);

    if (filters.length > 0) {
      query = query.filter(filters);
    }
    return query.asList();
  }
示例#3
0
  /*
   * (non-Javadoc)
   *
   * @see yanitime4u.yanitime.logic.UserLogic#update(com.google.appengine.api.datastore.Key,
   * java.lang.Long, java.util.Map)
   */
  @Override
  public Users update(Key key, Long version, Map<String, Object> input) {
    AssertionUtil.assertNotNull(key);
    AssertionUtil.assertNotNull(version);
    AssertionUtil.assertNotNull(input);

    Transaction tx = Datastore.beginTransaction();
    try {
      Users latest = Datastore.get(meta, key, version);
      BeanUtil.copy(input, latest);
      Datastore.put(tx, latest);
      tx.commit();
      return latest;
    } catch (ConcurrentModificationException e) {
      if (tx.isActive()) {
        tx.rollback();
      }
      throw e;
    }
  }
示例#4
0
 /*
  * (non-Javadoc)
  *
  * @see yanitime4u.yanitime.logic.UserLogic#create(yanitime4u.yanitime.model.Users)
  */
 @Override
 public Users create(Users users) {
   AssertionUtil.assertNotNull(users);
   Transaction tx = Datastore.beginTransaction();
   try {
     Users register = new Users();
     BeanUtil.copy(users, register);
     Datastore.put(register);
     tx.commit();
     return register;
   } catch (ConcurrentModificationException e) {
     if (tx.isActive()) {
       tx.rollback();
     }
     throw e;
   }
 }
示例#5
0
 /*
  * (non-Javadoc)
  *
  * @see yanitime4u.yanitime.logic.UserLogic#findByKey(java.lang.Long)
  */
 @Override
 public Users findByKey(Long id) {
   AssertionUtil.assertNotNull(id);
   Key key = Datastore.createKey(Users.class, id);
   return Datastore.get(meta, key);
 }