src/main/scala/fis/aaa/model/AaaSchema.scala
author Tomas Zeman <tzeman@volny.cz>
Fri, 20 Apr 2012 08:26:22 +0200
changeset 61 b65843860274
parent 56 9409e7ab3f9d
child 73 4bcb7deedd3f
permissions -rw-r--r--
Trackable entity: created/updated fields
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
56
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
     1
/*
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
     2
 * Copyright 2011-2012 Tomas Zeman <tzeman@volny.cz>
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
     3
 *
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
     4
 * Licensed under the Apache License, Version 2.0 (the "License");
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
     5
 * you may not use this file except in compliance with the License.
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
     6
 * You may obtain a copy of the License at
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
     7
 *
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
     8
 *     http://www.apache.org/licenses/LICENSE-2.0
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
     9
 *
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    10
 * Unless required by applicable law or agreed to in writing, software
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    11
 * distributed under the License is distributed on an "AS IS" BASIS,
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    13
 * See the License for the specific language governing permissions and
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    14
 * limitations under the License.
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    15
 */
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    16
package fis.aaa.model
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    17
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    18
import fis.base.model.BaseSchema
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    19
import net.liftweb.squerylrecord.RecordTypeMode._
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    20
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    21
/**
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    22
 * Database schema for users, ...
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    23
 */
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    24
trait AaaSchema extends BaseSchema {
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    25
  val userT = tableWithSeq[User]
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    26
  on(userT)(t => declare(
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    27
    t.login   defineAs(indexed("user_login_idx")),
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    28
    columns(t.deleted, t.active) are(indexed("user_deleted_active_idx"))
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    29
  ))
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    30
61
b65843860274 Trackable entity: created/updated fields
Tomas Zeman <tzeman@volny.cz>
parents: 56
diff changeset
    31
  UserVendors.byId.default.set(UserCrud.get _)
56
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    32
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    33
  /** All existing (undeleted) users. */
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    34
  val usersF = () => from(userT)(u =>
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    35
    where(u.deleted === false) select(u) orderBy(u.name asc))
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    36
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    37
  /** Active users. */
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    38
  val activeUsersF = () => from(userT)(u =>
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    39
    where(u.deleted === false and u.active === true) select(u)
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    40
    orderBy(u.name asc))
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    41
}
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    42
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    43
object AaaSchema extends AaaSchema
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    44
9409e7ab3f9d User record, mixins
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    45
// vim: set ts=2 sw=2 et: