src/main/scala/fis/crm/model/CrmSchema.scala
changeset 91 494b3b9db463
parent 84 43674362ff5e
equal deleted inserted replaced
90:39d3fc08414c 91:494b3b9db463
    14  * limitations under the License.
    14  * limitations under the License.
    15  */
    15  */
    16 package fis.crm.model
    16 package fis.crm.model
    17 
    17 
    18 import fis.base.model.{BaseSchema, Entity}
    18 import fis.base.model.{BaseSchema, Entity}
       
    19 import fis.cl.model.CodeListSchema
    19 import fis.geo.model.GeoSchema
    20 import fis.geo.model.GeoSchema
    20 import net.liftweb.squerylrecord.RecordTypeMode._
    21 import net.liftweb.squerylrecord.RecordTypeMode._
    21 
    22 
    22 trait CrmSchema extends BaseSchema with GeoSchema {
    23 trait CrmSchema extends BaseSchema with CodeListSchema with GeoSchema {
    23 
    24 
    24   val contactT = tableWithSeq[Contact]
    25   val contactT = tableWithSeq[Contact]
    25 
    26 
    26   def allContacts: Iterable[Contact] = from(contactT) (c =>
    27   def allContacts: Iterable[Contact] = from(contactT) (c =>
    27     select(c) orderBy(c.lastName asc, c.firstName asc)
    28     select(c) orderBy(c.lastName asc, c.firstName asc)
    39   val contactTypeToEntityContacts = oneToManyRelation(codeListItems,
    40   val contactTypeToEntityContacts = oneToManyRelation(codeListItems,
    40     entityContacts).via((cli, ec) => cli.id === ec.typeId)
    41     entityContacts).via((cli, ec) => cli.id === ec.typeId)
    41   */
    42   */
    42 
    43 
    43   val companyT = tableWithSeq[Company]
    44   val companyT = tableWithSeq[Company]
       
    45 
       
    46   val companyStatus = oneToManyRelation(cli, companyT).
       
    47     via((i, c) => i.id === c.status)
    44 
    48 
    45   val companyAddress = oneToManyRelation(addressT, companyT).
    49   val companyAddress = oneToManyRelation(addressT, companyT).
    46     via((a, c) => c.address === a.id)
    50     via((a, c) => c.address === a.id)
    47 
    51 
    48   val companyPostAddress = oneToManyRelation(addressT, companyT).
    52   val companyPostAddress = oneToManyRelation(addressT, companyT).