13 * See the License for the specific language governing permissions and |
13 * See the License for the specific language governing permissions and |
14 * limitations under the License. |
14 * limitations under the License. |
15 */ |
15 */ |
16 package fis.base.model |
16 package fis.base.model |
17 |
17 |
|
18 import fis.aaa.model.{CreatedByField, UpdatedByField, User, UserVendors} |
|
19 import net.liftweb.common._ |
|
20 import net.liftweb.http.Factory |
18 import net.liftweb.record.{MetaRecord, Record} |
21 import net.liftweb.record.{MetaRecord, Record} |
19 import net.liftweb.record.field._ |
22 import net.liftweb.record.field._ |
20 import net.liftweb.squerylrecord.KeyedRecord |
23 import net.liftweb.squerylrecord.KeyedRecord |
21 import net.tz.lift.model.{FieldLabel, OptionalFieldDisplay} |
24 import net.liftweb.util._ |
|
25 import net.tz.lift.model.{CreatedField, FieldLabel, OptionalFieldDisplay, UpdatedField} |
22 import org.squeryl.annotations.Column |
26 import org.squeryl.annotations.Column |
23 |
27 |
24 /** |
28 /** |
25 * Base data/model entity trait, common for all FIS entities. |
29 * Base data/model entity trait, common for all FIS entities. |
26 */ |
30 */ |
27 trait Entity[OwnerType <: Record[OwnerType]] extends KeyedRecord[Long] { |
31 trait Entity[OwnerType <: Record[OwnerType]] extends KeyedRecord[Long] { |
|
32 |
28 @Column(name="id") |
33 @Column(name="id") |
29 val idField = new LongField(this.asInstanceOf[OwnerType]) |
34 val idField = new LongField(this.asInstanceOf[OwnerType]) |
30 val name = new StringField(this.asInstanceOf[OwnerType], "") with FieldLabel |
35 val name = new StringField(this.asInstanceOf[OwnerType], "") with FieldLabel |
31 val note = new OptionalTextareaField(this.asInstanceOf[OwnerType], 10240) |
36 val note = new OptionalTextareaField(this.asInstanceOf[OwnerType], 10240) |
32 with OptionalFieldDisplay with FieldLabel |
37 with OptionalFieldDisplay with FieldLabel |
33 |
38 |
34 /** Display representation of this entity. */ |
39 /** Display representation of this entity. */ |
35 def linkName = name.get |
40 def linkName = name.get |
|
41 |
|
42 /* Can't mixin traits directly - must be implemented here. */ |
|
43 val createdAt = new CreatedField(this.asInstanceOf[OwnerType]) |
|
44 val updatedAt = new UpdatedField(this.asInstanceOf[OwnerType]) |
|
45 val createdBy = new CreatedByField(this.asInstanceOf[OwnerType], |
|
46 curUserVendor, getUserVendor) |
|
47 val updatedBy = new UpdatedByField(this.asInstanceOf[OwnerType], |
|
48 curUserVendor, getUserVendor) |
|
49 |
|
50 protected def curUserVendor: Vendor[Box[User]] = UserVendors.cur |
|
51 protected def getUserVendor: Vendor[Long => Box[User]] = UserVendors.byId |
36 } |
52 } |
37 |
53 |
38 import net.liftweb.common.Box |
54 import net.liftweb.common.Box |
39 import net.liftweb.squerylrecord.RecordTypeMode._ |
55 import net.liftweb.squerylrecord.RecordTypeMode._ |
40 import org.squeryl.Table |
56 import org.squeryl.Table |