Hey Lifters,

I overrode the toString method of a foreign key field, to make 
decisions, on what to return, nothing special. When I remove the if/else 
(Order.scala, line 65 ff.) and return directly the result, no error 
occurs! I append the source as attachment.

Further on, I've a similar error to one I already got (and solved with 
David's help). Initializing a foreign key field, with a value that 
doesn't exist at compile time. In line 45 ff. in file Order.scala is the 
solution, on how to do that. But this doesn't work for line 76 (same 
file). Why? What I do now, just to have the ability to test some things, 
is to comment out line 76 before I compile first (create all other 
tables) and then uncomment it and restart the application. Then it 
works, but if I don't do that, I get the error that table/view 
"TRADESTATUS" doesn't exist.

thanks alot in advance!

Here is the error that is forced through the if/else in line 65 ff. in 
file Order.scala.
-----------------------------------------------------------------------------------------------------------

Exception occured while processing /limitorder/list

Message: java.lang.AbstractMethodError: 
org.tobster.model.LimitOrder.tradeTypeName2()Ljava/lang/String;
    org.tobster.model.Order$tradeType$.toString(Order.scala:71)
    net.liftweb.mapper.MappedField$class.asHtml(MappedField.scala:645)
    net.liftweb.mapper.MappedLong.asHtml(MappedLong.scala:223)
    
net.liftweb.mapper.CRUDify$$anon$1$$anonfun$doRows$1$1$$anonfun$doRowItem$1$1.apply(CRUDify.scala:469)
    
net.liftweb.mapper.CRUDify$$anon$1$$anonfun$doRows$1$1$$anonfun$doRowItem$1$1.apply(CRUDify.scala:469)
    scala.List.flatMap(List.scala:1132)
    
net.liftweb.mapper.CRUDify$$anon$1$$anonfun$doRows$1$1.doRowItem$1(CRUDify.scala:468)
    
net.liftweb.mapper.CRUDify$$anon$1$$anonfun$doRows$1$1$$anonfun$apply$7.apply(CRUDify.scala:471)
    
net.liftweb.mapper.CRUDify$$anon$1$$anonfun$doRows$1$1$$anonfun$apply$7.apply(CRUDify.scala:471)
    
net.liftweb.util.BindHelpers$FuncBindParam.calcValue(BindHelpers.scala:218)
    
net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind$1$1$$anonfun$apply$24.apply(BindHelpers.scala:433)
    
net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind$1$1$$anonfun$apply$24.apply(BindHelpers.scala:426)
    net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65)
    
net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind$1$1.apply(BindHelpers.scala:425)
    
net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind$1$1.apply(BindHelpers.scala:424)
    scala.Seq$class.flatMap(Seq.scala:294)
    scala.xml.NodeSeq.flatMap(NodeSeq.scala:34)
    
net.liftweb.util.BindHelpers$$anonfun$bind$2.in_bind$1(BindHelpers.scala:424)
    
net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind$1$1.apply(BindHelpers.scala:444)
    
net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind$1$1.apply(BindHelpers.scala:424)
    scala.Seq$class.flatMap(Seq.scala:294)
    scala.xml.NodeSeq.flatMap(NodeSeq.scala:34)
    
net.liftweb.util.BindHelpers$$anonfun$bind$2.in_bind$1(BindHelpers.scala:424)
    
net.liftweb.util.BindHelpers$$anonfun$bind$2.apply(BindHelpers.scala:449)
    
net.liftweb.util.BindHelpers$$anonfun$bind$2.apply(BindHelpers.scala:409)
    net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65)
    net.liftweb.util.BindHelpers$class.bind(BindHelpers.scala:409)
    net.liftweb.util.Helpers$.bind(Helpers.scala:29)
    net.liftweb.util.BindHelpers$class.bind(BindHelpers.scala:380)
    net.liftweb.util.Helpers$.bind(Helpers.scala:29)
    
net.liftweb.mapper.CRUDify$$anon$1$$anonfun$doRows$1$1.apply(CRUDify.scala:471)
    
net.liftweb.mapper.CRUDify$$anon$1$$anonfun$doRows$1$1.apply(CRUDify.scala:467)
    scala.List.flatMap(List.scala:1132)
    net.liftweb.mapper.CRUDify$$anon$1.doRows$1(CRUDify.scala:466)
    
net.liftweb.mapper.CRUDify$$anon$1$$anonfun$doCrudAll$2.apply(CRUDify.scala:486)
    
net.liftweb.mapper.CRUDify$$anon$1$$anonfun$doCrudAll$2.apply(CRUDify.scala:486)
    
net.liftweb.util.BindHelpers$FuncBindParam.calcValue(BindHelpers.scala:218)
    
net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind$1$1$$anonfun$apply$24.apply(BindHelpers.scala:433)
    
net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind$1$1$$anonfun$apply$24.apply(BindHelpers.scala:426)
    net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65)
    
net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind$1$1.apply(BindHelpers.scala:425)
    
net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind$1$1.apply(BindHelpers.scala:424)
    scala.Seq$class.flatMap(Seq.scala:294)
    scala.xml.NodeSeq.flatMap(NodeSeq.scala:34)
    
net.liftweb.util.BindHelpers$$anonfun$bind$2.in_bind$1(BindHelpers.scala:424)
    
net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind$1$1.apply(BindHelpers.scala:444)
    
net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind$1$1.apply(BindHelpers.scala:424)
    scala.Seq$class.flatMap(Seq.scala:294)
    scala.xml.NodeSeq.flatMap(NodeSeq.scala:34)
    
net.liftweb.util.BindHelpers$$anonfun$bind$2.in_bind$1(BindHelpers.scala:424)
    
net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind$1$1.apply(BindHelpers.scala:444)
    
net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind$1$1.apply(BindHelpers.scala:424)
    scala.Seq$class.flatMap(Seq.scala:294)
    scala.xml.NodeSeq.flatMap(NodeSeq.scala:34)
    
net.liftweb.util.BindHelpers$$anonfun$bind$2.in_bind$1(BindHelpers.scala:424)
    
net.liftweb.util.BindHelpers$$anonfun$bind$2.apply(BindHelpers.scala:449)
    
net.liftweb.util.BindHelpers$$anonfun$bind$2.apply(BindHelpers.scala:409)
    net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65)
    net.liftweb.util.BindHelpers$class.bind(BindHelpers.scala:409)
    net.liftweb.util.Helpers$.bind(Helpers.scala:29)
    net.liftweb.util.BindHelpers$class.bind(BindHelpers.scala:380)
    net.liftweb.util.Helpers$.bind(Helpers.scala:29)
    net.liftweb.mapper.CRUDify$$anon$1.doCrudAll(CRUDify.scala:485)
    
net.liftweb.mapper.CRUDify$$anon$1$$anonfun$7$$anonfun$apply$5.apply(CRUDify.scala:447)
    
net.liftweb.mapper.CRUDify$$anon$1$$anonfun$7$$anonfun$apply$5.apply(CRUDify.scala:447)
    
net.liftweb.http.LiftSession$$anonfun$locSnippet$1$1$$anonfun$apply$40$$anonfun$apply$41.apply(LiftSession.scala:943)
    
net.liftweb.http.LiftSession$$anonfun$locSnippet$1$1$$anonfun$apply$40$$anonfun$apply$41.apply(LiftSession.scala:943)
    net.liftweb.util.Full.map(Box.scala:330)
    
net.liftweb.http.LiftSession$$anonfun$locSnippet$1$1$$anonfun$apply$40.apply(LiftSession.scala:943)
    
net.liftweb.http.LiftSession$$anonfun$locSnippet$1$1$$anonfun$apply$40.apply(LiftSession.scala:942)
    net.liftweb.util.Full.flatMap(Box.scala:332)
    
net.liftweb.http.LiftSession$$anonfun$locSnippet$1$1.apply(LiftSession.scala:942)
    
net.liftweb.http.LiftSession$$anonfun$locSnippet$1$1.apply(LiftSession.scala:941)
    net.liftweb.util.Full.flatMap(Box.scala:332)
    net.liftweb.http.LiftSession.locSnippet$1(LiftSession.scala:941)
    
net.liftweb.http.LiftSession$$anonfun$17$$anonfun$apply$43$$anonfun$apply$45.apply(LiftSession.scala:955)
    
net.liftweb.http.LiftSession$$anonfun$17$$anonfun$apply$43$$anonfun$apply$45.apply(LiftSession.scala:955)
    net.liftweb.util.EmptyBox.or(Box.scala:374)
    
net.liftweb.http.LiftSession$$anonfun$17$$anonfun$apply$43.apply(LiftSession.scala:954)
    
net.liftweb.http.LiftSession$$anonfun$17$$anonfun$apply$43.apply(LiftSession.scala:955)
    net.liftweb.http.S$.doSnippet(S.scala:1586)
    net.liftweb.http.LiftSession$$anonfun$17.apply(LiftSession.scala:953)
    net.liftweb.http.LiftSession$$anonfun$17.apply(LiftSession.scala:952)
    net.liftweb.util.Full.map(Box.scala:330)
    
net.liftweb.http.LiftSession.net$liftweb$http$LiftSession$$processSnippet(LiftSession.scala:952)
    
net.liftweb.http.LiftSession$$anonfun$_defaultLiftTagProcessing$1.apply(LiftSession.scala:1053)
    
net.liftweb.http.LiftSession$$anonfun$_defaultLiftTagProcessing$1.apply(LiftSession.scala:1041)
    net.liftweb.util.NamedPF.apply(NamedPartialFunction.scala:30)
    net.liftweb.util.NamedPF$.apply(NamedPartialFunction.scala:76)
    
net.liftweb.http.LiftSession$$anonfun$processSurroundAndInclude$1$$anonfun$apply$54$$anonfun$apply$55$$anonfun$apply$56.apply(LiftSession.scala:1074)
    
net.liftweb.http.LiftSession$$anonfun$processSurroundAndInclude$1$$anonfun$apply$54$$anonfun$apply$55$$anonfun$apply$56.apply(LiftSession.scala:1074)
    net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65)
    net.liftweb.http.S$.setVars(S.scala:1414)
    
net.liftweb.http.LiftSession$$anonfun$processSurroundAndInclude$1$$anonfun$apply$54$$anonfun$apply$55.apply(LiftSession.scala:1073)
    
net.liftweb.http.LiftSession$$anonfun$processSurroundAndInclude$1$$anonfun$apply$54$$anonfun$apply$55.apply(LiftSession.scala:1073)
    net.liftweb.http.S$.withAttrs(S.scala:1433)
    
net.liftweb.http.LiftSession$$anonfun$processSurroundAndInclude$1$$anonfun$apply$54.apply(LiftSession.scala:1072)
    
net.liftweb.http.LiftSession$$anonfun$processSurroundAndInclude$1$$anonfun$apply$54.apply(LiftSession.scala:1072)
    net.liftweb.http.S$.doSnippet(S.scala:1586)
    
net.liftweb.http.LiftSession$$anonfun$processSurroundAndInclude$1.apply(LiftSession.scala:1071)
    
net.liftweb.http.LiftSession$$anonfun$processSurroundAndInclude$1.apply(LiftSession.scala:1065)
    scala.Seq$class.flatMap(Seq.scala:294)
    scala.xml.NodeSeq.flatMap(NodeSeq.scala:34)
    
net.liftweb.http.LiftSession.processSurroundAndInclude(LiftSession.scala:1064)
    
net.liftweb.builtin.snippet.Surround$$anonfun$render$1$$anonfun$apply$2.apply(Surround.scala:34)
    
net.liftweb.builtin.snippet.Surround$$anonfun$render$1$$anonfun$apply$2.apply(Surround.scala:31)
    net.liftweb.util.Full.map(Box.scala:330)
    
net.liftweb.builtin.snippet.Surround$$anonfun$render$1.apply(Surround.scala:31)
    
net.liftweb.builtin.snippet.Surround$$anonfun$render$1.apply(Surround.scala:30)
    net.liftweb.util.Full.flatMap(Box.scala:332)
    net.liftweb.builtin.snippet.Surround$.render(Surround.scala:30)
    
net.liftweb.builtin.snippet.Surround$$anonfun$dispatch$1$$anonfun$apply$1.apply(Surround.scala:26)
    
net.liftweb.builtin.snippet.Surround$$anonfun$dispatch$1$$anonfun$apply$1.apply(Surround.scala:26)
    
net.liftweb.http.LiftSession$$anonfun$17$$anonfun$apply$43$$anonfun$apply$46$$anonfun$apply$48.apply(LiftSession.scala:971)
    
net.liftweb.http.LiftSession$$anonfun$17$$anonfun$apply$43$$anonfun$apply$46$$anonfun$apply$48.apply(LiftSession.scala:956)
    net.liftweb.util.EmptyBox.openOr(Box.scala:372)
    
net.liftweb.http.LiftSession$$anonfun$17$$anonfun$apply$43$$anonfun$apply$46.apply(LiftSession.scala:956)
    
net.liftweb.http.LiftSession$$anonfun$17$$anonfun$apply$43$$anonfun$apply$46.apply(LiftSession.scala:956)
    net.liftweb.util.EmptyBox.openOr(Box.scala:372)
    
net.liftweb.http.LiftSession$$anonfun$17$$anonfun$apply$43.apply(LiftSession.scala:955)
    
net.liftweb.http.LiftSession$$anonfun$17$$anonfun$apply$43.apply(LiftSession.scala:955)
    net.liftweb.http.S$.doSnippet(S.scala:1586)
    net.liftweb.http.LiftSession$$anonfun$17.apply(LiftSession.scala:953)
    net.liftweb.http.LiftSession$$anonfun$17.apply(LiftSession.scala:952)
    net.liftweb.util.Full.map(Box.scala:330)
    
net.liftweb.http.LiftSession.net$liftweb$http$LiftSession$$processSnippet(LiftSession.scala:952)
    
net.liftweb.http.LiftSession$$anonfun$_defaultLiftTagProcessing$1.apply(LiftSession.scala:1053)
    
net.liftweb.http.LiftSession$$anonfun$_defaultLiftTagProcessing$1.apply(LiftSession.scala:1041)
    net.liftweb.util.NamedPF.apply(NamedPartialFunction.scala:30)
    net.liftweb.util.NamedPF$.apply(NamedPartialFunction.scala:76)
    
net.liftweb.http.LiftSession$$anonfun$processSurroundAndInclude$1$$anonfun$apply$54$$anonfun$apply$55$$anonfun$apply$56.apply(LiftSession.scala:1074)
    
net.liftweb.http.LiftSession$$anonfun$processSurroundAndInclude$1$$anonfun$apply$54$$anonfun$apply$55$$anonfun$apply$56.apply(LiftSession.scala:1074)
    net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65)
    net.liftweb.http.S$.setVars(S.scala:1414)
    
net.liftweb.http.LiftSession$$anonfun$processSurroundAndInclude$1$$anonfun$apply$54$$anonfun$apply$55.apply(LiftSession.scala:1073)
    
net.liftweb.http.LiftSession$$anonfun$processSurroundAndInclude$1$$anonfun$apply$54$$anonfun$apply$55.apply(LiftSession.scala:1073)
    net.liftweb.http.S$.withAttrs(S.scala:1433)
    
net.liftweb.http.LiftSession$$anonfun$processSurroundAndInclude$1$$anonfun$apply$54.apply(LiftSession.scala:1072)
    
net.liftweb.http.LiftSession$$anonfun$processSurroundAndInclude$1$$anonfun$apply$54.apply(LiftSession.scala:1072)
    net.liftweb.http.S$.doSnippet(S.scala:1586)
    
net.liftweb.http.LiftSession$$anonfun$processSurroundAndInclude$1.apply(LiftSession.scala:1071)
    
net.liftweb.http.LiftSession$$anonfun$processSurroundAndInclude$1.apply(LiftSession.scala:1065)
    scala.Seq$class.flatMap(Seq.scala:294)
    scala.xml.NodeSeq.flatMap(NodeSeq.scala:34)
    
net.liftweb.http.LiftSession.processSurroundAndInclude(LiftSession.scala:1064)
    
net.liftweb.http.LiftSession$$anonfun$10$$anonfun$apply$30$$anonfun$apply$32.apply(LiftSession.scala:673)
    
net.liftweb.http.LiftSession$$anonfun$10$$anonfun$apply$30$$anonfun$apply$32.apply(LiftSession.scala:673)
    net.liftweb.util.Full.map(Box.scala:330)
    
net.liftweb.http.LiftSession$$anonfun$10$$anonfun$apply$30.apply(LiftSession.scala:673)
    
net.liftweb.http.LiftSession$$anonfun$10$$anonfun$apply$30.apply(LiftSession.scala:673)
    net.liftweb.util.EmptyBox.or(Box.scala:374)
    net.liftweb.http.LiftSession$$anonfun$10.apply(LiftSession.scala:670)
    net.liftweb.http.LiftSession$$anonfun$10.apply(LiftSession.scala:663)
    net.liftweb.util.EmptyBox.or(Box.scala:374)
    net.liftweb.http.LiftSession.processRequest(LiftSession.scala:663)
    
net.liftweb.http.LiftServlet.net$liftweb$http$LiftServlet$$dispatchStatefulRequest(LiftServlet.scala:255)
    net.liftweb.http.LiftServlet$$anonfun$3.apply(LiftServlet.scala:172)
    net.liftweb.http.LiftServlet$$anonfun$3.apply(LiftServlet.scala:172)
    net.liftweb.http.S$.net$liftweb$http$S$$wrapQuery(S.scala:904)
    
net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_nest2InnerInit$1$$anonfun$apply$20.apply(S.scala:1044)
    net.liftweb.http.S$.net$liftweb$http$S$$doAround(S.scala:841)
    
net.liftweb.http.S$$anonfun$net$liftweb$http$S$$doAround$1.apply(S.scala:842)
    
net.liftweb.mapper.DB$$anon$1.net$liftweb$mapper$DB$$anon$$doWith(DB.scala:119)
    
net.liftweb.mapper.DB$$anon$1$$anonfun$net$liftweb$mapper$DB$$anon$$doWith$1.apply(DB.scala:120)
    
net.liftweb.mapper.DB$$anon$1$$anonfun$net$liftweb$mapper$DB$$anon$$doWith$1.apply(DB.scala:120)
    net.liftweb.mapper.DB$.use(DB.scala:324)
    
net.liftweb.mapper.DB$$anon$1.net$liftweb$mapper$DB$$anon$$doWith(DB.scala:120)
    net.liftweb.mapper.DB$$anon$1.apply(DB.scala:126)
    net.liftweb.http.S$.net$liftweb$http$S$$doAround(S.scala:842)
    
net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_nest2InnerInit$1.apply(S.scala:1042)
    net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65)
    net.liftweb.http.S$.net$liftweb$http$S$$_nest2InnerInit(S.scala:1041)
    
net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_innerInit$1$$anonfun$apply$23$$anonfun$apply$24$$anonfun$apply$25$$anonfun$apply$26$$anonfun$apply$27.apply(S.scala:1061)
    net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65)
    
net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_innerInit$1$$anonfun$apply$23$$anonfun$apply$24$$anonfun$apply$25$$anonfun$apply$26.apply(S.scala:1060)
    net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65)
    
net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_innerInit$1$$anonfun$apply$23$$anonfun$apply$24$$anonfun$apply$25.apply(S.scala:1059)
    net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65)
    
net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_innerInit$1$$anonfun$apply$23$$anonfun$apply$24.apply(S.scala:1058)
    net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65)
    
net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_innerInit$1$$anonfun$apply$23.apply(S.scala:1057)
    net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65)
    
net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_innerInit$1.apply(S.scala:1056)
    net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65)
    net.liftweb.http.S$.net$liftweb$http$S$$_innerInit(S.scala:1055)
    
net.liftweb.http.S$$anonfun$_init$1$$anonfun$apply$30$$anonfun$apply$31$$anonfun$apply$32$$anonfun$apply$33.apply(S.scala:1084)
    net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65)
    
net.liftweb.http.S$$anonfun$_init$1$$anonfun$apply$30$$anonfun$apply$31$$anonfun$apply$32.apply(S.scala:1083)
    net.liftweb.http.RequestVarHandler$.apply(Vars.scala:119)
    
net.liftweb.http.S$$anonfun$_init$1$$anonfun$apply$30$$anonfun$apply$31.apply(S.scala:1082)
    net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65)
    
net.liftweb.http.S$$anonfun$_init$1$$anonfun$apply$30.apply(S.scala:1081)
    net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65)
    net.liftweb.http.S$$anonfun$_init$1.apply(S.scala:1080)
    net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65)
    net.liftweb.http.S$._init(S.scala:1079)
    net.liftweb.http.S$.init(S.scala:775)
    net.liftweb.http.LiftServlet.doService(LiftServlet.scala:171)
    
net.liftweb.http.LiftServlet$$anonfun$doIt$1$1.apply(LiftServlet.scala:75)
    
net.liftweb.http.LiftServlet$$anonfun$doIt$1$1.apply(LiftServlet.scala:75)
    net.liftweb.util.TimeHelpers$class.calcTime(TimeHelpers.scala:241)
    net.liftweb.util.Helpers$.calcTime(Helpers.scala:29)
    net.liftweb.util.TimeHelpers$class.logTime(TimeHelpers.scala:250)
    net.liftweb.util.Helpers$.logTime(Helpers.scala:29)
    net.liftweb.http.LiftServlet.doIt$1(LiftServlet.scala:74)
    net.liftweb.http.LiftServlet.service(LiftServlet.scala:79)
    
net.liftweb.http.provider.HTTPProvider$$anonfun$service$3.apply(HTTPProvider.scala:54)
    
net.liftweb.http.provider.HTTPProvider$$anonfun$service$3.apply(HTTPProvider.scala:54)
    net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65)
    net.liftweb.http.URLRewriter$.doWith(Req.scala:470)
    
net.liftweb.http.provider.HTTPProvider$class.service(HTTPProvider.scala:53)
    net.liftweb.http.LiftFilter.service(LiftServlet.scala:507)
    
net.liftweb.http.provider.servlet.ServletFilterProvider$class.protected$service(ServletFilterProvider.scala:41)
    net.liftweb.http.LiftFilter.protected$service(LiftServlet.scala:507)
    
net.liftweb.http.provider.servlet.ServletFilterProvider$$anonfun$doFilter$1.apply(ServletFilterProvider.scala:41)
    
net.liftweb.http.provider.servlet.ServletFilterProvider$$anonfun$doFilter$1.apply(ServletFilterProvider.scala:36)
    
net.liftweb.http.RequestVarHandler$$anonfun$apply$4$$anonfun$apply$5$$anonfun$apply$6$$anonfun$apply$7.apply(Vars.scala:125)
    net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65)
    
net.liftweb.http.RequestVarHandler$$anonfun$apply$4$$anonfun$apply$5$$anonfun$apply$6.apply(Vars.scala:124)
    net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65)
    
net.liftweb.http.RequestVarHandler$$anonfun$apply$4$$anonfun$apply$5.apply(Vars.scala:123)
    net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65)
    
net.liftweb.http.RequestVarHandler$$anonfun$apply$4.apply(Vars.scala:122)
    net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65)
    net.liftweb.http.RequestVarHandler$.apply(Vars.scala:121)
    
net.liftweb.http.provider.servlet.ServletFilterProvider$class.doFilter(ServletFilterProvider.scala:35)
    net.liftweb.http.LiftFilter.doFilter(LiftServlet.scala:507)
    
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1153)
    org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    
org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
    
org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
    org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    org.mortbay.jetty.Server.handle(Server.java:326)
    org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:536)
    
org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:913)
    org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)
    org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
    org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:405)
    
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
    
org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)




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

 /*
 * OrderType.scala
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package org.tobster.model

import net.liftweb._
import mapper._
import http._
import SHtml._
import util._

/* This class stores information about the two different trade types: BUY and 
SELL
   Means this table has only two rows. Maybe there will be more in the future. 
*/
class TradeType extends LongKeyedMapper[TradeType] with IdPK {

  def getSingleton = TradeTypeMetaObj

  /* Accessing this field will return the trade type name, BUY or SELL */
  object name1 extends MappedString(this, 4)
  /* Accessing this field will return the alternative name, BOUGHT or SOLD */
  object name2 extends MappedString(this, 6)

}

object TradeTypeMetaObj extends TradeType with LongKeyedMetaMapper[TradeType] {
    override def dbAddTable = Full(populate _)

    private def populate {
        TradeTypeMetaObj.create.name1("BUY").name2("BOUGHT").save
        TradeTypeMetaObj.create.name1("SELL").name2("SOLD").save
    }
}
/*
 * Order.scala
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package org.tobster.model

import net.liftweb._
import mapper._
import http._
import SHtml._
import util._

import net.liftweb.sitemap.Loc._
import comet.MarketServer

/* The main 'item' that people will be trading with.
 * Its important to mix the IdPK trait into the class! */
class LimitOrder extends LongKeyedMapper[LimitOrder] with IdPK with Order {

    def getSingleton = LimitOrderMetaObj

    /* This integer value is used to find similar orders
     * that could join this one. */
    object marketPoint extends MappedInt(this){
        override def displayName = "MARKETPOINT"
    }

    /* Stores the currentMarketValue when this order joined another. */
    object openPoint extends MappedInt(this){
        // hides this field in the CRUDify list/create forms
        override def dbDisplay_? = false
        override def displayName = "OPENPOINT"
    }

    /* Stores the currentMarketValue when this order was closed. */
    object closePoint extends MappedInt(this){
        // hides this field in the CRUDify list/create forms
        override def dbDisplay_? = false
        override def displayName = "CLOSEPOINT"
    }

    /* Depending on the trade type, goal specifies the cheapest BUY,
     * or the best SELL. */
    object goal extends MappedInt(this){
        override def displayName = "GOAL"
    }

    /* Stop is a protection mechanism that specifies
     * when the order is excecuted before the user is running out of money. */
    object stop extends MappedInt(this){
        override def displayName = "STOP"
    }

    /* implement.... */
    def join = "Nothing"

    /* setter methods*/
    def open = this.status(2).save
    def close = this.status(3).save
    def substractLotsFromOrder(that: LimitOrder) = this.lots(this.lots.is - 
that.lots.is).save

    /* Creates a open LimitOrder with the given parameters, inverse TradeType,
     * same owner and same marketPoint as the caller. */
    def createOpenLimitOrderWithInverseType(l: Int) = {
        LimitOrderMetaObj.create.tradeType(this.inverseTradeType).lots(l).
            marketPoint(this.marketPoint.is).owner(User.findAll(By(User.id, 
this.ownerId))(0)).status(2).save
    }

    /* Returns the opposite TradeType from the caller. */
    def inverseTradeType: TradeType = {
        if (this.tradeType.is == 1) 
TradeTypeMetaObj.findAll(By(TradeTypeMetaObj.id, 2))(0)
        else TradeTypeMetaObj.findAll(By(TradeTypeMetaObj.id, 1))(0)
    }

    /* Returns a list of limit orders (IDs) that fit the calling limit order...
     * search criteria see inside findAll(...) I decided to return a list of
     * IDs instead of LimitOrder objects, because its easier to do all the 
filter
     * process before and just get a list with the wanted IDs back. */
    def findCandidates: List[Long] = {
        def filterAndSort(orders: List[LimitOrder]): List[Long] = {
             /* 
             *  a) If you BUY, you take everything that has an equivalent
             *     marketPoint or lower, because than its cheaper for you.
             *  b) If you SELL, you take everything that has an equivalent
             *     marketPoint or higher, because than you make more profit. */
            if (this.tradeType.is == 1) //BUY
                orders.filter(that => that.marketPoint.is <= 
this.marketPoint.is).
                    sort((o1, o2) => o1.marketPoint.is < o2.marketPoint.is).
                    map(that => that.id)
            else //SELL
                orders.filter(that => that.marketPoint.is >= 
this.marketPoint.is).
                    sort((o1, o2) => o1.marketPoint.is > o2.marketPoint.is).
                    map(that => that.id)
        }
        /* SQL query that returns LimitOrders that are filtered in more detail 
with filterAndSort */
        val res1 = LimitOrderMetaObj.findAll(
                    // only NEW orders
                    By(LimitOrderMetaObj.status, 1),
                    // from the same market place
                    By(LimitOrderMetaObj.marketPlace, this.marketPlace),
                    // not from the same owner
                    NotBy(LimitOrderMetaObj.owner, this.owner),
                    // opposite trade type
                    NotBy(LimitOrderMetaObj.tradeType, this.tradeType),
                    // exclude the calling order from the results
                    NotBy(LimitOrderMetaObj.id, this.id))
        val res2 = filterAndSort(res1)
        println("------------------#DEBUG 
MESSAGES#---------------------------------------")
        println("------------------#res1 (sql query)    :" + res1.length + " 
------------------------------")
        println("------------------#res2 (filterAndSort):" + res1.length + " 
------------------------------")
        res2
    }
}

/* Its important to mix the CRUDify trait into the object, NOT into the class! 
*/
object LimitOrderMetaObj extends LimitOrder with LongKeyedMetaMapper[LimitOrder]
                                            with CRUDify[Long, LimitOrder] {

    // sorts the fields in the CRUDify list/create forms
    override def fieldOrder = List(tradeType, lots, marketPoint, marketPlace,
                                   stop, goal, openPoint, closePoint)

    // hide the create/list LimitOrder menu entries until a user is not logged 
in
    override def showAllMenuLocParams = If(User.loggedIn_? _,
                        "Please log in first!") :: super.showAllMenuLocParams
    override def createMenuLocParams = If(User.loggedIn_? _,
                        "Please log in first!") :: super.createMenuLocParams

    // only show those orders, that the current logged in user owns
    override def findForListParams = By(LimitOrderMetaObj.owner,
                                  User.currentUser) :: super.findForListParams

    /* After a order is created/deleted, a message is send to the MarketServer
     * Actor to inform it to update the HTML page that lists all orders. */
    override def afterCreate = informMarket _ :: super.afterCreate
    override def afterDelete = informMarket _ :: super.afterDelete

    private def informMarket(order: LimitOrder) = {
        MarketServer ! order
    }
}
/*
 * Order.scala
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package org.tobster.model

import net.liftweb._
import mapper._
import http._
import SHtml._
import util._
import model._

/* Describes a general order.
 * The reason why I decided not to make an abstract class but a trait to hold 
this information,
 * was that Lift models need to extend LongKeyedMapper, hence they can't extend 
another class, but a trait. */
trait Order extends BaseLongKeyedMapper{

    /* Returns the current cost of this order
     * marketPlace.obj references the 'real' object, because 
Order.this.marketPlace is a foreign key. */
    def currentCost = Order.this.lots * 
(Order.this.marketPlace.obj.map(_.lotValue.is) openOr 0)

    def ownerId: Long = owner.is
    def statusId: Long = status.is
    def marketPlaceId: Long = marketPlace.is
    def statusName: String = Order.this.status.obj.map(_.name.is) openOr ""
    def tradeTypeName1: String = Order.this.tradeType.obj.map(_.name1.is) 
openOr ""
    def tradeTypeName2: String = Order.this.tradeType.obj.map(_.name2.is) 
openOr ""
    def marketPlaceName: String = Order.this.marketPlace.obj.map(_.name.is) 
openOr ""

    /* The number of lots this order has */
    object lots extends MappedInt(this.asInstanceOf[MapperType]){
        override def displayName = "LOTS"
    }

    /* The person who owns the order */
    object owner extends MappedLongForeignKey(this.asInstanceOf[MapperType], 
User){
        // hides this field in the CRUDify list/create forms
        override def dbDisplay_? = false
        
        //set the default value to the current logged in user (at creation time)
        override def defaultValue = User.currentUser.map(_.id.is) openOr 0L
    }

    /* The market place where the order belongs to.
     * Display this field as a drop-down menu, that contains all available 
market places.  */
    object marketPlace extends 
MappedLongForeignKey(this.asInstanceOf[MapperType], MarketPlaceMetaObj){
        override def _toForm = 
Full(SHtml.selectObj[MarketPlace](MarketPlaceMetaObj.findAll.map(
                                    x => (x, x.name.is)), obj, (x: MarketPlace) 
=> apply(x)))
        override def displayName = "MARKETPLACE"
        override def toString = marketPlaceName
    }

    /* The basic trade types are: BUY and SELL.
     * Display this field as a drop-down menu, that contains all available 
trade type. */
    object tradeType extends 
MappedLongForeignKey(this.asInstanceOf[MapperType], TradeTypeMetaObj){
        override def _toForm = 
Full(SHtml.selectObj[TradeType](TradeTypeMetaObj.findAll.map(
                                    x => (x, x.name1.is)), obj, (x: TradeType) 
=> apply(x)))
        override def displayName = "TYPE"
        /* works just fine! */
        //override def toString = tradeTypeName1
        override def toString = {
            /* if status=NEW, display BUY/SELL, if the order is already open or
             * closed, display BOUGHT/SOLD */
            println("status=" + statusId)
            if (statusId == 1L) tradeTypeName1
            else tradeTypeName2
        }
    }

    /* Set the default status for newly created LimitOrders to New */
    object status extends MappedLongForeignKey(this.asInstanceOf[MapperType], 
TradeStatusMetaObj) {
        override def defaultValue = TradeStatusMetaObj.find(1).map(_.id.is) 
openOr 0L
        override def displayName = "STATUS"
        override def toString = statusName
    }

}
/*
 * TradeStatus.scala
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package org.tobster.model

import net.liftweb._
import mapper._
import http._
import SHtml._
import util._

class TradeStatus extends LongKeyedMapper[TradeStatus] with IdPK {
    def getSingleton = TradeStatusMetaObj

    /* Accessing this field will return the trade type name, BUY or SELL */
    object name extends MappedString(this, 6)
}

object TradeStatusMetaObj extends TradeStatus with 
LongKeyedMetaMapper[TradeStatus] {
    override def dbAddTable = Full(populate _)

    private def populate {
        TradeStatusMetaObj.create.name("NEW").save
        TradeStatusMetaObj.create.name("OPEN").save
        TradeStatusMetaObj.create.name("CLOSED").save
    }
}

Reply via email to