Skip to content
Snippets Groups Projects
Commit 3e410aba authored by cmaeder's avatar cmaeder
Browse files

code changes needed without Camel Scala DSL

This is only for documentation purposes.

"transform" is more cumbersome than "process"
due to the extra tyep parameter.

Implementing process or evaluate as part of "this" class
via "with Processor" or "with Expression" leads to a
stack overflow in RouteBuilder.toString
parent 8a919a46
Branches no_scala_DSL
No related tags found
No related merge requests found
......@@ -2,11 +2,11 @@ package info.kwarc.mmt.errorview
import java.util
import org.apache.camel.Exchange
import org.apache.camel.builder.RouteBuilder
import org.apache.camel.component.jackson.JacksonDataFormat
import org.apache.camel.model.DataFormatDefinition
import org.apache.camel.scala.dsl.builder.RouteBuilder
import org.apache.camel.util.jndi.JndiContext
import org.apache.camel.{Exchange, Expression}
import org.eclipse.jetty.server.handler.ResourceHandler
import scala.collection.JavaConverters._
......@@ -28,22 +28,25 @@ class SearchDB(inPrefix: String, addStaticRoute: Boolean) extends RouteBuilder {
})
hm
}
def asExpression = new Expression {
override def evaluate[T](ex: Exchange, _c: Class[T]): T = query2HashMap2(ex).asInstanceOf[T]
}
override def configure() = {
var prefix = inPrefix
if (addStaticRoute) {
(prefix +
"static?matchOnUriPrefix=true&handlers=#staticHandler") -->
("log:lll" + this.getClass + "?showHeaders=true")
from(prefix +
"static?matchOnUriPrefix=true&handlers=#staticHandler").to("log:lll" +
this.getClass + "?showHeaders=true")
prefix = inPrefix + "sally/error/"
}
((prefix + "search2") transform query2HashMap2) -->
("db:SELECT * FROM errors WHERE " +
from(prefix + "search2").transform(asExpression).to("db:SELECT * FROM errors WHERE " +
Table.columns.map(col => col + " LIKE :#" + col).mkString(" AND ") +
" LIMIT :#limit") marshal new DataFormatDefinition(new JacksonDataFormat())
((prefix + "count2") transform query2HashMap2) -->
("db:SELECT COUNT(*) as count FROM errors WHERE " +
Table.columns.map(col => col + " LIKE :#" + col).mkString(" AND ")) marshal
new DataFormatDefinition(new JacksonDataFormat())
" LIMIT :#limit").marshal(new DataFormatDefinition(new JacksonDataFormat()))
from(prefix + "count2").transform(asExpression).to("db:SELECT COUNT(*) as count FROM errors WHERE " +
Table.columns.map(col => col + " LIKE :#" + col).mkString(" AND ")).marshal(
new DataFormatDefinition(new JacksonDataFormat()))
}
}
object SearchDB {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment