camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/3] git commit: Specifying criteria for count operation
Date Fri, 05 Sep 2014 06:52:51 GMT
Repository: camel
Updated Branches:
  refs/heads/master f4b7333c3 -> fd818acb5


Specifying criteria for count operation

Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/921c0722
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/921c0722
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/921c0722

Branch: refs/heads/master
Commit: 921c0722e3852d4c68710c496ba0e04ccb2b6169
Parents: e8fb927
Author: Denis Smirnov <denis.m.smirnov@gmail.com>
Authored: Tue Jul 29 21:34:01 2014 +0400
Committer: Denis Smirnov <denis.m.smirnov@gmail.com>
Committed: Tue Jul 29 21:34:01 2014 +0400

----------------------------------------------------------------------
 .../org/apache/camel/component/mongodb/MongoDbProducer.java  | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/921c0722/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbProducer.java
b/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbProducer.java
index 45267a8..72c27a9 100644
--- a/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbProducer.java
+++ b/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbProducer.java
@@ -338,7 +338,13 @@ public class MongoDbProducer extends DefaultProducer {
 
     protected void doCount(Exchange exchange) throws Exception {
         DBCollection dbCol = calculateCollection(exchange);
-        Long answer = Long.valueOf(dbCol.count());
+        DBObject query = exchange.getIn().getBody(DBObject.class);
+        Long answer;
+        if (query == null){
+            answer = Long.valueOf(dbCol.count());    
+        } else {
+            answer = Long.valueOf(dbCol.count(query));    
+        }
         Message resultMessage = prepareResponseMessage(exchange, MongoDbOperation.count);
         resultMessage.setBody(answer);
     }


Mime
View raw message