Skip to content
Snippets Groups Projects
Commit 83d19f57 authored by cmaeder's avatar cmaeder
Browse files

added limit and record count

parent 4ada818b
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<link rel="stylesheet" href="static/search.css"/> <link rel="stylesheet" href="static/search.css"/>
</head> </head>
<body> <body>
<h2>Search</h2> <h3>Search</h3>
<div ng-controller="SearchController"> <div ng-controller="SearchController">
<li><input type="checkbox" ng-model="columns.id"/>row id</li> <li><input type="checkbox" ng-model="columns.id"/>row id</li>
...@@ -16,8 +16,9 @@ ...@@ -16,8 +16,9 @@
<li><input type="checkbox" ng-model="columns.errType"/>error type</li> <li><input type="checkbox" ng-model="columns.errType"/>error type</li>
<li><input type="checkbox" ng-model="columns.shortMsg"/>short message</li> <li><input type="checkbox" ng-model="columns.shortMsg"/>short message</li>
<li><input type="checkbox" ng-model="columns.longMsg"/>long message</li> <li><input type="checkbox" ng-model="columns.longMsg"/>long message</li>
<p/> <p>number of records: {{number}}</p>
<form ng-submit="search()"> <form ng-submit="search()">
<p>maximal entries: <input type="integer" ng-model="maxNumber" size="5"/></p>
<input type="text" ng-model="searchText" size="20" <input type="text" ng-model="searchText" size="20"
placeholder="add new search string"/> placeholder="add new search string"/>
<input class="btn-primary" type="submit" value="search"/> <input class="btn-primary" type="submit" value="search"/>
......
...@@ -8,11 +8,21 @@ angular.module('searchApp', []).controller('SearchController', ...@@ -8,11 +8,21 @@ angular.module('searchApp', []).controller('SearchController',
, shortMsg : true , shortMsg : true
, longMsg : false }; , longMsg : false };
$scope.results = []; $scope.results = [];
$scope.number = 0;
$scope.maxNumber = 100;
$scope.searchText = '';
$scope.search = function() { $scope.search = function() {
if ($scope.searchText) { if ($scope.searchText) {
$http.get('search?text=' + $scope.searchText).success(function(data) { $http.get('search?limit=' + $scope.maxNumber +
'&text=' + $scope.searchText).success(function(data) {
$scope.results = data; $scope.results = data;
}); });
}; };
$scope.count();
};
$scope.count = function() {
$http.get('count?text=' + $scope.searchText).success(function(data) {
$scope.number = data[0].count;
});
}; };
} ]); } ]);
import java.util
import org.apache.camel.Exchange
import org.apache.camel.component.jackson.JacksonDataFormat import org.apache.camel.component.jackson.JacksonDataFormat
import org.apache.camel.model.DataFormatDefinition import org.apache.camel.model.DataFormatDefinition
import org.apache.camel.scala.dsl.builder.RouteBuilder import org.apache.camel.scala.dsl.builder.RouteBuilder
...@@ -6,9 +9,18 @@ import org.eclipse.jetty.server.handler.ResourceHandler ...@@ -6,9 +9,18 @@ import org.eclipse.jetty.server.handler.ResourceHandler
object CamelTest { object CamelTest {
def query2HashMap(ex: Exchange) : util.HashMap[String, String] = {
val hm = new util.HashMap[String, String]()
hm.put("shortMsg", "%" + ex.getIn.getHeader("text") + "%")
hm.put("limit", ex.getIn.getHeader("limit").toString)
hm
}
class MyRouteBuilder extends RouteBuilder { class MyRouteBuilder extends RouteBuilder {
("jetty:http://localhost:8383/search" transform (ex => "%" + ex.getIn.getHeader("text") + "%")) --> ("jetty:http://localhost:8383/count" transform (ex => "%" + ex.getIn.getHeader("text") + "%")) -->
"db:SELECT * FROM errors WHERE shortMsg LIKE #" marshal (new DataFormatDefinition(new JacksonDataFormat())) "db:SELECT COUNT(*) as count FROM errors WHERE shortMsg LIKE #" marshal new DataFormatDefinition(new JacksonDataFormat())
("jetty:http://localhost:8383/search" transform query2HashMap) -->
"db:SELECT * FROM errors WHERE shortMsg LIKE :#shortMsg LIMIT :#limit" marshal new DataFormatDefinition(new JacksonDataFormat())
"jetty:http://localhost:8383/static?matchOnUriPrefix=true&handlers=#staticHandler" --> "log:a" "jetty:http://localhost:8383/static?matchOnUriPrefix=true&handlers=#staticHandler" --> "log:a"
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment