Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modifty timestamp annotation #23

Closed
GoogleCodeExporter opened this issue Sep 2, 2015 · 9 comments
Closed

modifty timestamp annotation #23

GoogleCodeExporter opened this issue Sep 2, 2015 · 9 comments

Comments

@GoogleCodeExporter
Copy link

   If Slim3 add a new modify timestamp annotation, it would be more easy to
incremental backup data which is modified since last backup timestamp.
Although it could be done by programmers to maintain such a property when
writing every entity, it would reduce the burden of programmers.

Original issue reported on code.google.com by mylee...@gmail.com on 2 May 2010 at 11:11

@GoogleCodeExporter
Copy link
Author

Since slim3 doesn't use aop to detect dirty properties, it is reasonable that 
the
values of modify-timestamp-annotated properties will always be overridden by 
slim3.
The programmers have no responsibility for taking care of the
modify-timestamp-annotated properties.

Original comment by mylee...@gmail.com on 2 May 2010 at 11:19

@GoogleCodeExporter
Copy link
Author

We will prepare AttributeListener for "Automatic Assigned Property" as follows:

public interface AttributeListener<T> {

  /**
   * This method is called before a model is put to datastore.
   * 
   * @param value the original property value
   * @return the automatic assigned value
   */
  T prePut(T value);
}

public class CreatedDate implements AttributeListener<Date> {
  public Date prePut(Date value) {
    if (value != null) {
      return value;
    }
    return new Date();
  }
}

public class UpdatedDate implements AttributeListener<Date> {
  public Date prePut(Date value) {
    return new Date();
  }
}

@Model
public class Xxx {
  ...
  @Attribute(listener = CreatedDate.class)
  private Date createdDate;

  @Attribute(listener = UpdatedDate.class)
  private Date updatedDate;
}

Original comment by higaya...@gmail.com on 2 May 2010 at 11:43

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

Original comment by higaya...@gmail.com on 2 May 2010 at 11:44

  • Added labels: Version-1.0.4
  • Removed labels: Version

@GoogleCodeExporter
Copy link
Author

GJ!
One question: Can I use both listener in one property as below?

@Model
public class Xxx {
  ...
  @Attribute(listener = CreatedDate.class, listener = UpdatedDate.class)
  private Date modifyDate;
}

Original comment by mylee...@gmail.com on 3 May 2010 at 7:41

@GoogleCodeExporter
Copy link
Author

> One question: Can I use both listener in one property as below?

No you can't. Just one listener.

Original comment by higaya...@gmail.com on 3 May 2010 at 9:04

@GoogleCodeExporter
Copy link
Author

If I use UpdatedDate.class listener only as below, it seems (from the code) 
that 
modifyDate will be set to current time even upon entity creation (and that's 
what I 
want). Am I right?

@Attribute(listener = UpdatedDate.class)
  private Date modifyDate;

Original comment by mylee...@gmail.com on 3 May 2010 at 9:16

@GoogleCodeExporter
Copy link
Author

Yes. You are right.

Original comment by higaya...@gmail.com on 3 May 2010 at 9:21

@GoogleCodeExporter
Copy link
Author

Original comment by higaya...@gmail.com on 15 May 2010 at 8:07

  • Added labels: Version-1.0.5
  • Removed labels: Version-1.0.4

@GoogleCodeExporter
Copy link
Author

Original comment by higaya...@gmail.com on 8 Jul 2010 at 9:16

  • Changed state: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant