diff -r e2a2e2045c0e -r b65843860274 src/main/scala/fis/base/model/Entity.scala --- a/src/main/scala/fis/base/model/Entity.scala Fri Apr 20 08:26:22 2012 +0200 +++ b/src/main/scala/fis/base/model/Entity.scala Fri Apr 20 08:26:22 2012 +0200 @@ -15,16 +15,21 @@ */ package fis.base.model +import fis.aaa.model.{CreatedByField, UpdatedByField, User, UserVendors} +import net.liftweb.common._ +import net.liftweb.http.Factory import net.liftweb.record.{MetaRecord, Record} import net.liftweb.record.field._ import net.liftweb.squerylrecord.KeyedRecord -import net.tz.lift.model.{FieldLabel, OptionalFieldDisplay} +import net.liftweb.util._ +import net.tz.lift.model.{CreatedField, FieldLabel, OptionalFieldDisplay, UpdatedField} import org.squeryl.annotations.Column /** * Base data/model entity trait, common for all FIS entities. */ trait Entity[OwnerType <: Record[OwnerType]] extends KeyedRecord[Long] { + @Column(name="id") val idField = new LongField(this.asInstanceOf[OwnerType]) val name = new StringField(this.asInstanceOf[OwnerType], "") with FieldLabel @@ -33,6 +38,17 @@ /** Display representation of this entity. */ def linkName = name.get + + /* Can't mixin traits directly - must be implemented here. */ + val createdAt = new CreatedField(this.asInstanceOf[OwnerType]) + val updatedAt = new UpdatedField(this.asInstanceOf[OwnerType]) + val createdBy = new CreatedByField(this.asInstanceOf[OwnerType], + curUserVendor, getUserVendor) + val updatedBy = new UpdatedByField(this.asInstanceOf[OwnerType], + curUserVendor, getUserVendor) + + protected def curUserVendor: Vendor[Box[User]] = UserVendors.cur + protected def getUserVendor: Vendor[Long => Box[User]] = UserVendors.byId } import net.liftweb.common.Box