Dude,

You are amazing... I puzzled over this for 30 minutes yesterday and couldn't
get it right!

Thanks!

David

On Fri, Feb 27, 2009 at 6:47 AM, <[email protected]> wrote:

>
> Here is the solution to the complex domain modeling problem with Mapper
>
> importnet.liftweb.mapper._
>
> traitPositionextendsBaseLongKeyedMapper{
>   typeContentType<: LongKeyedMapper[ContentType] withPositionable
>   defforeign: LongKeyedMetaMapper[ContentType]
>   defisM*oving*():Boolean = scheduled.obj.map(_ => true).openOr(false) ||
> content.obj.map(_.isMoving()).openOr(false)
>   objectrole extendsMappedString(this.asInstanceOf[MapperType],18)
>   objectcontent extendsMappedLongForeignKey(this
> .asInstanceOf[MapperType],foreign)
>   objectscheduled extendsMappedLongForeignKey(this
> .asInstanceOf[MapperType],foreign)
> }
>
> traitPositionableextendsBaseLongKeyedMapper{
>   typeContainerType<: LongKeyedMapper[ContainerType] with*Position*
>   defforeign: LongKeyedMetaMapper[ContainerType]
>   defisMoving(): Boolean= dest.obj.map(_ => true).openOr(false) ||
> container.obj.map(_.*isMoving*()).openOr(false)
>   objectnameextendsMappedString(this.asInstanceOf[MapperType],32)
>   objectcontainerextends*MappedLongForeignKey*(this.asInstanceOf[
> MapperType],foreign)
>   objectdestextends*MappedLongForeignKey*(this.asInstanceOf[MapperType],
> foreign)
>
> }
>
> classPalletextendsLongKeyedMapper[Pallet] withPositionablewithIdPK{
>   typeContainerType= PalletPosition
>   defgetSingleton= PalletMeta
>   defforeign= PalletPositionMeta
> }
>
> objectPalletMetaextendsPalletwithLongKeyedMetaMapper[Pallet]
>
> classPalletPositionextendsLongKeyedMapper[PalletPosition] with*Position*
> withIdPK{
>   typeContentType= Pallet
>   defgetSingleton= PalletPositionMeta
>   defforeign= PalletMeta
> }
>
> objectPalletPositionMetaextendsPalletPositionwithLongKeyedMetaMapper[
> PalletPosition]
>
> Scala programming is too fun.
>
> Regards
> Giuseppe Fogliazza
>
>
> *beppe61 <[email protected]>*
>
> 26/02/2009 20.08
> Per favore, rispondere a
> [email protected]
>
> Per
> Lift <[email protected]>CC
> Oggetto
> [Lift] Using Traits in complex domain models
>
>
>
>
>
> In a new project to support Manufacturing Operations, using Lift, I
> want to code a common pattern for my application and hence I
> introduced two traits implementing the basic relationship between a
> Position and its content assumed as a Positionable. Concrete classes
> will be persisted using Mapper.
> Here my try:
>
> trait Position extends BaseLongKeyedMapper {
>  type ContentType <: Positionable
>  def foreign: LongKeyedMetaMapper[ContentType]
>  def isMoving():Boolean = scheduled.obj.map(_ => true).openOr(false)
> ||  content.obj.map(_.isMoving()).openOr(false)
>  object role extends MappedString(this.asInstanceOf[MapperType],18)
>  object content extends MappedLongForeignKey(this.asInstanceOf
> [MapperType],foreign) // type mismatch
>  object scheduled extends MappedLongForeignKey(this.asInstanceOf
> [MapperType],foreign) // type mismatch
> }
>
> trait Positionable extends BaseLongKeyedMapper {
>  type ContainerType <: Position
>  def foreign: LongKeyedMetaMapper[ContainerType]
>  def isMoving(): Boolean = dest.obj.map(_=>true).openOr(false)
>  object name extends MappedString(this.asInstanceOf[MapperType],32)
>  object position extends MappedLongForeignKey(this.asInstanceOf
> [MapperType],foreign) // type mismatch
>  object dest extends MappedLongForeignKey(this.asInstanceOf
> [MapperType],foreign) // type mismatch
> }
>
> I would like to declare a concrete class this way:
>
> class Pallet extends LongKeyedMapper[Pallet] with Positionable with
> IdPK {
>  type ContainerType = PalletPosition
>  def getSingleton = PalletMeta
>  def foreign = PalletPositionMeta
> }
>
> object PalletMeta extends Pallet with LongKeyedMetaMapper[Pallet]
>
> class PalletPosition extends LongKeyedMapper[PalletPosition] with
> Position with IdPK {
>  type ContentType = Pallet
>  def getSingleton = PalletPositionMeta
>  def foreign = PalletMeta
> }
>
> object PalletPositionMeta extends PalletPosition with
> LongKeyedMetaMapper[PalletPosition]
>
> Unfortunately there is a type mismatch in parameters passed to
> MappedLongForeignKey in the Position and Positionable traits.
>
> Do you have any suggestion?
>
>
>
> Chi riceve il presente messaggio e' tenuto a verificare se lo stesso non
> gli sia pervenuto per errore. In tal caso e' pregato di avvisare
> immediatamente il mittente e, tenuto conto delle responsabilita' connesse
> all'indebito utilizzo e/o divulgazione del messaggio e/o delle informazioni
> in esso contenute, voglia cancellare l'originale e distruggere le varie
> copie o stampe.
>
> The receiver of this message is required to check if he/she has received it
> erroneously. If so, the receiver is requested to immediately inform the
> sender and - in condideration of the responsibilities arising from undue use
> and/or disclosure of the message and/or the information contained therein
> destroy the original message and any copy or printout thereof.
>
> Die Information dieses e-mails ist vertraulich und ausschließlich für den
> Adressaten bestimmt.
> Der Empfänger dieses e-mails der nicht der Adressat ist (sowie einer seiner
> Mitarbeiter oder sein Empfangsberechtigter), darf den Inhalt nicht
> verwenden, weitergeben oder reproduzieren.
> Sollten Sie dieses e-mail irrtümlich erhalten haben, benachrichtigen Sie
> bitte den Absender und vernichten Sie dieses e-mail.
> >
>


-- 
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to