Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Task extends Record[Long, Task] with IdentityGenerator[Long, Task] {
- def this(name: String, description: String, done: Boolean, dueTo: Option[Date], id: Long) = {
- this()
- this.name := name.trim()
- this.description := description.trim()
- this.dueTo := dueTo
- this.done := done
- if (id == 0) this.id.setNull else this.id := id
- }
- def PRIMARY_KEY = id
- def relation = Task
- val id = "id".BIGINT.NOT_NULL.AUTO_INCREMENT
- val name = "name".VARCHAR(255)
- val description = "description".TEXT
- val createdAt = "created_at".TIMESTAMP.DEFAULT("current_timestamp")
- val dueTo = "due_to".DATE
- val done = "done".BOOLEAN.NOT_NULL(false)
- }
- def apply(name: String, description: String, done: String, dueTo: Option[Date], id: Long) = {
- var task: Task = null;
- if (id > 0) {
- task = Task.get(id).get
- task.name := name
- task.description := description
- task.done := (done == "on")
- task.dueTo := dueTo getOrElse (null)
- task.id := id
- }
- else {
- task = new Task(name, description, done == "on", dueTo getOrElse null, id)
- }
- task
- }
Advertisement
Add Comment
Please, Sign In to add comment