Package org.codinjutsu.tools.mongo.model

Examples of org.codinjutsu.tools.mongo.model.MongoQueryOptions


        }
        return new LexerEditorHighlighter(PlainTextSyntaxHighlighterFactory.getSyntaxHighlighter(language, null, null), settings);
    }

    public MongoQueryOptions getQueryOptions() {
        MongoQueryOptions mongoQueryOptions = new MongoQueryOptions();

        if (isAgregationEnabled()) {

            try {
                mongoQueryOptions.setQueries(getQueries());
            } catch (JSONParseException ex) {
                notifyOnErrorForOperator(ex);
                throw ex;
            } catch (NumberFormatException ex) {
                notifyOnErrorForOperator(ex);
                throw ex;
            }
        } else {
            try {
                mongoQueryOptions.setFilter(getQuery());
            } catch (JSONParseException ex) {
                notifyOnErrorForOperator(ex);
            }
        }

        if (StringUtils.isNotBlank(rowLimitField.getText())) {
            mongoQueryOptions.setResultLimit(Integer.parseInt(rowLimitField.getText()));
        }

        return mongoQueryOptions;
    }
View Full Code Here


    private ServerConfiguration serverConfiguration;


    @Test
    public void loadCollectionsWithEmptyFilter() throws Exception {
        MongoQueryOptions mongoQueryOptions = new MongoQueryOptions();
        mongoQueryOptions.setResultLimit(3);
        MongoCollectionResult mongoCollectionResult = mongoManager.loadCollectionValues(serverConfiguration, new MongoCollection("dummyCollection", "test"), mongoQueryOptions);
        Assert.assertNotNull(mongoCollectionResult);
        Assert.assertEquals(3, mongoCollectionResult.getMongoObjects().size());
    }
View Full Code Here

        Assert.assertEquals(3, mongoCollectionResult.getMongoObjects().size());
    }

    @Test
    public void updateMongoDocument() throws Exception {
        MongoQueryOptions mongoQueryOptions = new MongoQueryOptions();
        mongoQueryOptions.addQuery((BasicDBObject) JSON.parse("{'$match': {'label': 'tete'}}"));
        MongoCollection mongoCollection = new MongoCollection("dummyCollection", "test");
        MongoCollectionResult initialData = mongoManager.loadCollectionValues(serverConfiguration, mongoCollection, mongoQueryOptions);
        Assert.assertEquals(1, initialData.getMongoObjects().size());
        DBObject initialMongoDocument = initialData.getMongoObjects().get(0);
View Full Code Here

    }


    @Test
    public void deleteMongoDocument() throws Exception {
        MongoQueryOptions mongoQueryOptions = new MongoQueryOptions();
        mongoQueryOptions.addQuery((BasicDBObject) JSON.parse("{'$match': {'label': 'tete'}}"));
        MongoCollection mongoCollection = new MongoCollection("dummyCollection", "test");
        MongoCollectionResult initialData = mongoManager.loadCollectionValues(serverConfiguration, mongoCollection, mongoQueryOptions);
        Assert.assertEquals(1, initialData.getMongoObjects().size());
        DBObject initialMongoDocument = initialData.getMongoObjects().get(0);
View Full Code Here

    }


    @Test
    public void loadCollectionsWithMatchOperator() throws Exception {
        MongoQueryOptions mongoQueryOptions = new MongoQueryOptions();
        mongoQueryOptions.addQuery((BasicDBObject) JSON.parse("{'$match': {'price': 15}}"));
        mongoQueryOptions.addQuery((BasicDBObject) JSON.parse("{'$project': {'label': 1, 'price': 1}}"));
        mongoQueryOptions.addQuery((BasicDBObject) JSON.parse("{'$group': {'_id': '$label', 'total': {'$sum': '$price'}}}"));
        MongoCollectionResult mongoCollectionResult = mongoManager.loadCollectionValues(serverConfiguration, new MongoCollection("dummyCollection", "test"), mongoQueryOptions);
        Assert.assertNotNull(mongoCollectionResult);

        List<DBObject> mongoObjects = mongoCollectionResult.getMongoObjects();
View Full Code Here

TOP

Related Classes of org.codinjutsu.tools.mongo.model.MongoQueryOptions

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.