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.envirocar.server.mongo.util.GeoBSON.java

License:Open Source License

@Override
public BSONObject encode(MultiPoint geometry) {
    Preconditions.checkNotNull(geometry);
    BSONObject db = new BasicDBObject();
    db.put(TYPE_KEY, MULTI_POINT_TYPE);// w w w  .ja va 2 s . c  o m
    BasicDBList list = new BasicDBList();
    for (int i = 0; i < geometry.getNumGeometries(); ++i) {
        list.add(encodeCoordinates((Point) geometry.getGeometryN(i)));
    }
    db.put(COORDINATES_KEY, list);
    return db;
}

From source file:org.envirocar.server.mongo.util.GeoBSON.java

License:Open Source License

@Override
public BSONObject encode(MultiLineString geometry) {
    Preconditions.checkNotNull(geometry);
    BSONObject db = new BasicDBObject();
    db.put(TYPE_KEY, MULTI_LINE_STRING_TYPE);
    BasicDBList list = new BasicDBList();
    for (int i = 0; i < geometry.getNumGeometries(); ++i) {
        list.add(encodeCoordinates((LineString) geometry.getGeometryN(i)));
    }/*from w  ww.j  av a 2  s . co m*/
    db.put(COORDINATES_KEY, list);
    return db;
}

From source file:org.envirocar.server.mongo.util.GeoBSON.java

License:Open Source License

@Override
public BSONObject encode(MultiPolygon geometry) {
    Preconditions.checkNotNull(geometry);
    BSONObject db = new BasicDBObject();
    db.put(TYPE_KEY, MULTI_POLYGON_TYPE);
    BasicDBList list = new BasicDBList();
    for (int i = 0; i < geometry.getNumGeometries(); ++i) {
        list.add(encodeCoordinates((Polygon) geometry.getGeometryN(i)));
    }/*from  w  w w .  ja  va 2 s  .c  o m*/
    db.put(COORDINATES_KEY, list);
    return db;
}

From source file:org.envirocar.server.mongo.util.GeoBSON.java

License:Open Source License

@Override
public BSONObject encode(GeometryCollection geometry) throws GeometryConverterException {
    Preconditions.checkNotNull(geometry);
    BSONObject bson = new BasicDBObject();
    bson.put(TYPE_KEY, GEOMETRY_COLLECTION_TYPE);
    BasicDBList geometries = new BasicDBList();
    for (int i = 0; i < geometry.getNumGeometries(); ++i) {
        geometries.add(encodeGeometry(geometry.getGeometryN(i)));
    }/* ww w .j ava  2  s  . c o  m*/
    bson.put(GEOMETRIES_KEY, geometries);
    return bson;
}

From source file:org.fastmongo.odm.dbobject.mapping.core.DomainToDbObjectConverter.java

License:Apache License

/**
 * Converts the given collection into {@link com.mongodb.BasicDBList}.
 *
 * @param col the collection to be converted.
 * @return the converted collection.//from  ww w . j a v a  2  s  . c o  m
 */
private BasicDBList toCollection(Collection<?> col) {
    final BasicDBList db = new BasicDBList();

    for (Object obj : col) {
        db.add(toDbValue(obj));
    }

    return db;
}

From source file:org.fastmongo.odm.repository.query.QueryField.java

License:Apache License

public Query and(Object... val) {
    BasicDBList and = new BasicDBList();
    for (Object object : val) {
        and.add(object instanceof Query ? ((Query) object).toDbObject() : object);
    }/* www . jav a 2  s .  c  om*/
    this.value = and;

    return query;
}

From source file:org.ff4j.mongo.mapper.PropertyDocumentBuilder.java

License:Apache License

/**
 * Chain add to build object./*  www  .  ja  v a 2 s  .  c o m*/
 * 
 * @param value
 *            target value
 * @return
 */
public PropertyDocumentBuilder addFixedValues(Set<String> values) {
    BasicDBList fixedValues = new BasicDBList();
    if (values != null) {
        fixedValues.addAll(values);
        builder.append(PROPERTY_FIXEDVALUES, fixedValues);
    }
    return this;
}

From source file:org.ff4j.store.mongodb.FeatureDBObjectBuilder.java

License:Apache License

/**
 * Chain add to build object.//from  w  w w .  j ava  2s  .co m
 * 
 * @param value
 *            target value
 * @return
 */
public FeatureDBObjectBuilder addRoles(Set<String> auths) {
    BasicDBList authorizations = new BasicDBList();
    authorizations.addAll(auths);
    builder.add(ROLES, authorizations);
    return this;
}

From source file:org.ff4j.store.mongodb.PropertyDBObjectBuilder.java

License:Apache License

/**
 * Chain add to build object.//from  w w w. j a  v a  2 s .  co  m
 * 
 * @param value
 *            target value
 * @return
 */
public PropertyDBObjectBuilder addFixedValues(Set<String> values) {
    BasicDBList fixedValues = new BasicDBList();
    if (values != null) {
        fixedValues.addAll(values);
        builder.add(PROPERTY_FIXEDVALUES, fixedValues);
    }
    return this;
}

From source file:org.frameworkset.security.session.impl.SessionHelper.java

License:Apache License

public static void buildExtendFieldQueryCondition(Map<String, AttributeInfo> monitorAttributeArray,
        BasicDBObject query) {/* ww w. j  a v  a 2  s.  c  o  m*/

    if (monitorAttributeArray != null && monitorAttributeArray.size() > 0) {

        for (Entry<String, AttributeInfo> Entry : monitorAttributeArray.entrySet()) {
            AttributeInfo attr = Entry.getValue();
            if (attr.getType().equals("String")) {

                if (!attr.isLike()) {
                    if (!StringUtil.isEmpty((String) attr.getValue())) {
                        Object value = serial(attr.getValue());
                        query.append(attr.getName(), value);
                    } else if (attr.isEnableEmptyValue()) {
                        BasicDBList values = new BasicDBList();
                        values.add(new BasicDBObject(attr.getName(), serial("")));
                        values.add(new BasicDBObject(attr.getName(), null));
                        query.append("$or", values);
                    }

                } else {
                    if (!StringUtil.isEmpty((String) attr.getValue())) {
                        Object value = attr.getValue();
                        Pattern hosts = Pattern.compile(
                                "^<ps><p n=\"_dflt_\" s:t=\"String\"><\\!\\[CDATA\\[" + value + ".*$",
                                Pattern.CASE_INSENSITIVE);
                        query.append(attr.getName(), new BasicDBObject("$regex", hosts));
                    } else if (attr.isEnableEmptyValue()) {

                        //values.add(null);

                        BasicDBList values = new BasicDBList();
                        values.add(new BasicDBObject(attr.getName(), serial("")));
                        values.add(new BasicDBObject(attr.getName(), null));
                        query.append("$or", values);

                    }
                }
            } else {
                Object value = serial(attr.getValue());
                query.append(attr.getName(), value);
            }

        }

    }

}