Example usage for com.mongodb BasicDBList BasicDBList

List of usage examples for com.mongodb BasicDBList BasicDBList

Introduction

In this page you can find the example usage for com.mongodb BasicDBList BasicDBList.

Prototype

BasicDBList

Source Link

Usage

From source file:org.jberet.repository.MongoRepository.java

License:Open Source License

@Override
public int countStepStartTimes(final String stepName, final long jobInstanceId) {
    final DBObject keys = new BasicDBObject(TableColumns.JOBEXECUTIONID, 1);
    keys.put(TableColumns._id, 0);//from   w  ww .j a va2  s  .c  o m
    final DBCursor cursor = db.getCollection(TableColumns.JOB_EXECUTION)
            .find(new BasicDBObject(TableColumns.JOBINSTANCEID, jobInstanceId), keys);
    final BasicDBList basicDBList = new BasicDBList();
    while (cursor.hasNext()) {
        final DBObject next = cursor.next();
        basicDBList.add(next.get(TableColumns.JOBEXECUTIONID));
    }
    final DBObject inClause = new BasicDBObject("$in", basicDBList);
    final DBObject query = new BasicDBObject(TableColumns.JOBEXECUTIONID, inClause);
    query.put(TableColumns.STEPNAME, stepName);
    return db.getCollection(TableColumns.STEP_EXECUTION).find(query).count();
}

From source file:org.jeo.mongo.GeoJSON.java

License:Open Source License

static DBObject toObject(Point p) {
    BasicDBList coords = new BasicDBList();
    coords.add(p.getX());/*w w  w. j a  va 2 s. co  m*/
    coords.add(p.getY());

    BasicDBObject obj = new BasicDBObject("type", "Point");
    obj.put("coordinates", coords);
    return obj;
}

From source file:org.jeo.mongo.GeoJSON.java

License:Open Source License

static DBObject toObject(Polygon p) {
    BasicDBList coords = new BasicDBList();
    coords.add(toList(p.getExteriorRing().getCoordinateSequence()));
    for (int i = 0; i < p.getNumInteriorRing(); i++) {
        coords.add(toList(p.getInteriorRingN(i).getCoordinateSequence()));
    }/*from ww  w  .  j  a  v a2  s  . co m*/
    BasicDBObject obj = new BasicDBObject("type", "Polygon");
    obj.put("coordinates", coords);
    return obj;
}

From source file:org.jeo.mongo.GeoJSON.java

License:Open Source License

static DBObject toObject(MultiPoint mp) {
    BasicDBObject obj = new BasicDBObject("type", "MultiPoint");

    BasicDBList coords = new BasicDBList();
    for (Coordinate c : mp.getCoordinates()) {
        BasicDBList coord = new BasicDBList();
        coord.add(c.x);/*from  ww w  .ja  v a2  s  .com*/
        coord.add(c.y);
        coords.add(coord);
    }
    return obj;
}

From source file:org.jeo.mongo.GeoJSON.java

License:Open Source License

static DBObject toObject(MultiLineString ml) {
    BasicDBObject obj = new BasicDBObject("type", "MultiLineString");
    BasicDBList coords = new BasicDBList();
    for (LineString l : Geom.iterate(ml)) {
        coords.add(toList(l.getCoordinateSequence()));
    }/*  w w w.  j  a  v a 2 s  .com*/
    obj.put("coordinates", coords);
    return obj;
}

From source file:org.jeo.mongo.GeoJSON.java

License:Open Source License

static DBObject toObject(MultiPolygon mp) {
    BasicDBObject obj = new BasicDBObject("type", "MultiPolygon");
    BasicDBList coords = new BasicDBList();
    for (Polygon p : Geom.iterate(mp)) {
        BasicDBList poly = new BasicDBList();
        poly.add(toList(p.getExteriorRing().getCoordinateSequence()));
        for (int i = 0; i < p.getNumInteriorRing(); i++) {
            poly.add(toList(p.getInteriorRingN(i).getCoordinateSequence()));
        }// w w  w  .ja  v  a  2  s .  com
        coords.add(poly);
    }
    obj.put("coordinates", coords);
    return obj;
}

From source file:org.jeo.mongo.GeoJSON.java

License:Open Source License

static DBObject toObject(GeometryCollection gc) {
    BasicDBObject obj = new BasicDBObject("type", "GeometryCollection");
    BasicDBList geoms = new BasicDBList();

    for (Geometry g : Geom.iterate(gc)) {
        geoms.add(toObject(g));/*from ww w. j  a v  a 2 s  .  co m*/
    }
    return obj;
}

From source file:org.jeo.mongo.GeoJSON.java

License:Open Source License

static BasicDBList toList(CoordinateSequence coordseq) {
    BasicDBList list = new BasicDBList();

    for (int i = 0; i < coordseq.size(); i++) {
        BasicDBList sub = new BasicDBList();
        sub.add(coordseq.getOrdinate(i, 0));
        sub.add(coordseq.getOrdinate(i, 1));
        if (coordseq.getDimension() > 2) {
            double z = coordseq.getOrdinate(i, 2);
            if (!Double.isNaN(z)) {
                sub.add(z);//from  w w w  . jav  a  2 s.  c om
            }
        }
        list.add(sub);
    }

    return list;
}

From source file:org.jongo.json.JsonQueryFactory.java

License:Apache License

private DBObject marshallArray(Object[] parameters) {
    BasicDBList list = new BasicDBList();
    for (int i = 0; i < parameters.length; i++) {
        list.put(i, marshallParameter(parameters[i], false));
    }/*from w  w w .j  av a2s.c om*/
    return list;
}

From source file:org.jongo.query.BsonQueryFactory.java

License:Apache License

private DBObject marshallArray(Object[] parameters) {
    BasicDBList list = new BasicDBList();
    for (int i = 0; i < parameters.length; i++) {
        list.add(marshallParameter(parameters[i]));
    }/*from   www .  ja v a 2  s.c o m*/
    return list;
}