Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fbettag/lift-stamped
Liftweb Traits for logging changes MetaMapper-Records
https://github.com/fbettag/lift-stamped
Last synced: about 1 month ago
JSON representation
Liftweb Traits for logging changes MetaMapper-Records
- Host: GitHub
- URL: https://github.com/fbettag/lift-stamped
- Owner: fbettag
- Created: 2009-12-09T02:29:05.000Z (about 15 years ago)
- Default Branch: master
- Last Pushed: 2009-12-09T18:35:34.000Z (about 15 years ago)
- Last Synced: 2024-05-01T19:23:08.372Z (8 months ago)
- Language: Scala
- Homepage: http://www.bett.ag/
- Size: 74.2 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.textile
Awesome Lists containing this project
README
h1. Lift Stamped
These traits let you extend your MetaMapper-models to log every change
made by users (and the belonging customers). Tested on liftweb 1.1-M7.
h2. What it does do
* logging *which user/customer* changed *which record* on *which class*
* skip logging (initial user creation, for background-job purpose)
* adds reverse associations so your record has a "logs" method
h2. What it doesn't do (yet)
* logging of *what* changed
* reverting records according to *what* was changed
* reverse associations for the Singleton to get every log associated with that modelh2. Traits for the class
* CustomerFields: adds a customer-object to the model
* ActivateFields: adds an active-boolean to the model (with seperate logging)
* ActionLogs: adds reverse associations to records (not the singleton)h2. Traits for the singleton
* Stamped: stamps any changes done to records in that model
* Activatable: logging for ActivateFieldsh2. Stamping a model
bc. class MyModel extends LongKeyedMapper[MyModel]
with IdPK
with CustomerFields[MyModel]
with ActionLogs[MyModel]
with ActivateFields[MyModel] {bc. object MyModel extends MyModel with LongKeyedMetaMapper[MyModel]
with Stamped[MyModel] with Activatable[MyModel]h2. Initial user creation with logging skipped
In Boot.scala add this:bc. if (Customer.findAll.length == 0) {
/* Customer creation */
Customer.skipLogging = true
val c = new Customer
c.name("First Customer").save
Customer.skipLogging = false
/* User creation */
User.skipLogging = true
val u = new User
u.customer(c).
firstName("First").
lastName("User").
email("[email protected]").
password("s0m3th1ngs3cur3").
validated(true).save
User.skipLogging = false
}h2. Read the sourcecode!
Really, it's open source for a reason. ;)