Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2011-02-21 10:02:34 +0000
committerEike Stepper2011-02-21 10:02:34 +0000
commit1f5e6793b74b8265fad95fa5bf7d0dda09fe100d (patch)
tree303e98be15ecfbf2b1222d728cf22c39d70a8357 /plugins/org.eclipse.emf.cdo.server.mongodb/src
parent01e7412248e0999ce09c9f5ddd54bb427f984cd9 (diff)
downloadcdo-1f5e6793b74b8265fad95fa5bf7d0dda09fe100d.tar.gz
cdo-1f5e6793b74b8265fad95fa5bf7d0dda09fe100d.tar.xz
cdo-1f5e6793b74b8265fad95fa5bf7d0dda09fe100d.zip
[337152] [Mongo] Create a MongoDBStore
https://bugs.eclipse.org/bugs/show_bug.cgi?id=337152
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.server.mongodb/src')
-rw-r--r--plugins/org.eclipse.emf.cdo.server.mongodb/src/org/eclipse/emf/cdo/server/internal/mongodb/Expr.java143
-rw-r--r--plugins/org.eclipse.emf.cdo.server.mongodb/src/org/eclipse/emf/cdo/server/internal/mongodb/MongoDBStore.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server.mongodb/src/org/eclipse/emf/cdo/server/internal/mongodb/Ref.java81
3 files changed, 4 insertions, 224 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.mongodb/src/org/eclipse/emf/cdo/server/internal/mongodb/Expr.java b/plugins/org.eclipse.emf.cdo.server.mongodb/src/org/eclipse/emf/cdo/server/internal/mongodb/Expr.java
deleted file mode 100644
index 5b0cb91c98..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.mongodb/src/org/eclipse/emf/cdo/server/internal/mongodb/Expr.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/**
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.mongodb;
-
-import com.mongodb.BasicDBList;
-import com.mongodb.BasicDBObject;
-import com.mongodb.DBCollection;
-import com.mongodb.DBCursor;
-import com.mongodb.DBObject;
-
-/**
- * @author Eike Stepper
- */
-public abstract class Expr
-{
- public void evaluate(DBCollection collection, ResultHandler handler)
- {
- DBObject query = buildQuery(null);
- DBCursor cursor = findDocuments(collection, query);
-
- try
- {
- while (cursor.hasNext())
- {
- DBObject doc = cursor.next();
- handleDocument(doc, handler);
- }
- }
- finally
- {
- cursor.close();
- }
- }
-
- protected DBCursor findDocuments(DBCollection collection, DBObject query)
- {
- return collection.find(query);
- }
-
- protected void handleDocument(DBObject document, ResultHandler handler)
- {
- handleObject(document, handler);
- }
-
- protected abstract DBObject buildQuery(String context);
-
- protected abstract void handleObject(DBObject object, ResultHandler handler);
-
- /**
- * @author Eike Stepper
- */
- public static interface ResultHandler
- {
- public void handleResult(DBObject object);
- }
-
- /**
- * @author Eike Stepper
- */
- public static class Embed extends Expr
- {
- private String field;
-
- private Expr expr;
-
- public Embed(String field, Expr expr)
- {
- this.field = field;
- this.expr = expr;
- }
-
- public String getField()
- {
- return field;
- }
-
- public Expr getExpr()
- {
- return expr;
- }
-
- @Override
- protected DBObject buildQuery(String context)
- {
- String newContext = context == null ? field : context + "." + field;
- return expr.buildQuery(newContext);
- }
-
- @Override
- protected void handleObject(DBObject object, ResultHandler handler)
- {
- DBObject embedded = (DBObject)object.get(field);
- expr.handleObject(embedded, handler);
- }
- }
-
- /**
- * @author Eike Stepper
- */
- public static class Or extends Expr
- {
- private Expr[] operands;
-
- public Or(Expr... operands)
- {
- this.operands = operands;
- }
-
- public Expr[] getOperands()
- {
- return operands;
- }
-
- @Override
- protected DBObject buildQuery(String context)
- {
- BasicDBList list = new BasicDBList();
- for (Expr expr : operands)
- {
- list.add(expr.buildQuery(context));
- }
-
- return new BasicDBObject("$or", list);
- }
-
- @Override
- protected void handleObject(DBObject object, ResultHandler handler)
- {
- for (Expr expr : operands)
- {
- expr.handleObject(object, handler);
- }
- }
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.mongodb/src/org/eclipse/emf/cdo/server/internal/mongodb/MongoDBStore.java b/plugins/org.eclipse.emf.cdo.server.mongodb/src/org/eclipse/emf/cdo/server/internal/mongodb/MongoDBStore.java
index a734acbe29..6936c01910 100644
--- a/plugins/org.eclipse.emf.cdo.server.mongodb/src/org/eclipse/emf/cdo/server/internal/mongodb/MongoDBStore.java
+++ b/plugins/org.eclipse.emf.cdo.server.mongodb/src/org/eclipse/emf/cdo/server/internal/mongodb/MongoDBStore.java
@@ -258,6 +258,10 @@ public class MongoDBStore extends Store implements IMongoDBStore, //
{
InternalRepository repository = getRepository();
branching = repository.isSupportingBranches();
+ if (branching)
+ {
+ throw new IllegalStateException("Branching is not supported");
+ }
REPOS.put(repository.getName(), repository);
diff --git a/plugins/org.eclipse.emf.cdo.server.mongodb/src/org/eclipse/emf/cdo/server/internal/mongodb/Ref.java b/plugins/org.eclipse.emf.cdo.server.mongodb/src/org/eclipse/emf/cdo/server/internal/mongodb/Ref.java
deleted file mode 100644
index 62d0df8efc..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.mongodb/src/org/eclipse/emf/cdo/server/internal/mongodb/Ref.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package org.eclipse.emf.cdo.server.internal.mongodb;
-
-import com.mongodb.BasicDBObject;
-import com.mongodb.DBObject;
-
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public class Ref extends BasicDBObject
-{
- private static final long serialVersionUID = 1L;
-
- public Ref()
- {
- }
-
- public Ref(int size)
- {
- super(size);
- }
-
- public Ref(@SuppressWarnings("rawtypes") Map m)
- {
- super(m);
- }
-
- public Ref(String key, Object value)
- {
- super(key, value);
- }
-
- public Ref or(DBObject... expressions)
- {
- put("$or", expressions);
- return this;
- }
-
- public Ref eq(String field, Object value)
- {
- put(field, value);
- return this;
- }
-
- public Ref ne(String field, Object value)
- {
- return op(field, value, "$ne");
- }
-
- public Ref gt(String field, Object value)
- {
- return op(field, value, "$gt");
- }
-
- public Ref gte(String field, Object value)
- {
- return op(field, value, "$gte");
- }
-
- public Ref lt(String field, Object value)
- {
- return op(field, value, "$lt");
- }
-
- public Ref lte(String field, Object value)
- {
- return op(field, value, "$lte");
- }
-
- public Ref exists(String field, boolean yes)
- {
- return op(field, yes, "$exists");
- }
-
- private Ref op(String field, Object value, String op)
- {
- put(field, new BasicDBObject(op, value));
- return this;
- }
-} \ No newline at end of file

Back to the top