Search in sources :

Example 51 with BasicDBList

use of com.mongodb.BasicDBList in project GNS by MobilityFirst.

the class MongoRecords method parseJSONArrayLocationStringIntoDBList.

private BasicDBList parseJSONArrayLocationStringIntoDBList(String string) {
    BasicDBList box1 = new BasicDBList();
    BasicDBList box2 = new BasicDBList();
    BasicDBList box = new BasicDBList();
    try {
        JSONArray json = new JSONArray(string);
        box1.add(json.getJSONArray(0).getDouble(0));
        box1.add(json.getJSONArray(0).getDouble(1));
        box2.add(json.getJSONArray(1).getDouble(0));
        box2.add(json.getJSONArray(1).getDouble(1));
        box.add(box1);
        box.add(box2);
    } catch (JSONException e) {
        DatabaseConfig.getLogger().log(Level.SEVERE, "{0} Unable to parse JSON: {1}", new Object[] { dbName, e.getMessage() });
    }
    return box;
}
Also used : BasicDBList(com.mongodb.BasicDBList) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) JSONObject(org.json.JSONObject) DBObject(com.mongodb.DBObject) BasicDBObject(com.mongodb.BasicDBObject)

Example 52 with BasicDBList

use of com.mongodb.BasicDBList in project logging-log4j2 by apache.

the class MongoDbObject method set.

@Override
public void set(final String field, final NoSqlObject<BasicDBObject>[] values) {
    final BasicDBList list = new BasicDBList();
    for (final NoSqlObject<BasicDBObject> value : values) {
        list.add(value.unwrap());
    }
    this.mongoObject.append(field, list);
}
Also used : BasicDBList(com.mongodb.BasicDBList) BasicDBObject(com.mongodb.BasicDBObject)

Example 53 with BasicDBList

use of com.mongodb.BasicDBList in project logging-log4j2 by apache.

the class MongoDbObject method set.

@Override
public void set(final String field, final Object[] values) {
    final BasicDBList list = new BasicDBList();
    Collections.addAll(list, values);
    this.mongoObject.append(field, list);
}
Also used : BasicDBList(com.mongodb.BasicDBList)

Example 54 with BasicDBList

use of com.mongodb.BasicDBList in project spring-data-mongodb by spring-projects.

the class DefaultMongoTypeMapper method writeTypeRestrictions.

/*
	 * (non-Javadoc)
	 * @see org.springframework.data.mongodb.core.convert.MongoTypeMapper#writeTypeRestrictions(java.util.Set)
	 */
@Override
public void writeTypeRestrictions(Document result, @Nullable Set<Class<?>> restrictedTypes) {
    if (ObjectUtils.isEmpty(restrictedTypes)) {
        return;
    }
    BasicDBList restrictedMappedTypes = new BasicDBList();
    for (Class<?> restrictedType : restrictedTypes) {
        Alias typeAlias = getAliasFor(ClassTypeInformation.from(restrictedType));
        if (!ObjectUtils.nullSafeEquals(Alias.NONE, typeAlias) && typeAlias.isPresent()) {
            restrictedMappedTypes.add(typeAlias.getValue());
        }
    }
    accessor.writeTypeTo(result, new Document("$in", restrictedMappedTypes));
}
Also used : BasicDBList(com.mongodb.BasicDBList) Alias(org.springframework.data.mapping.Alias) Document(org.bson.Document)

Example 55 with BasicDBList

use of com.mongodb.BasicDBList in project oc-explorer by devgateway.

the class GenericOCDSController method createTextSearchFriendlyCriteriaList.

/**
 * We ensure {@link TextCriteria} is always returned first before {@link Criteria}
 *
 * @param criteria
 * @return
 * @see Criteria#createCriteriaList(Criteria[])
 */
private BasicDBList createTextSearchFriendlyCriteriaList(CriteriaDefinition[] criteria) {
    BasicDBList bsonList = new BasicDBList();
    Arrays.stream(criteria).sorted((c1, c2) -> c2.getClass().getSimpleName().compareTo(c1.getClass().getSimpleName())).map(CriteriaDefinition::getCriteriaObject).collect(Collectors.toCollection(() -> bsonList));
    return bsonList;
}
Also used : BasicDBList(com.mongodb.BasicDBList)

Aggregations

BasicDBList (com.mongodb.BasicDBList)69 BasicDBObject (com.mongodb.BasicDBObject)40 DBObject (com.mongodb.DBObject)33 Test (org.junit.Test)27 Document (org.springframework.data.mongodb.core.mapping.Document)16 ArrayList (java.util.ArrayList)13 List (java.util.List)9 DBCollection (com.mongodb.DBCollection)8 Document (org.bson.Document)7 DBCursor (com.mongodb.DBCursor)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 DBRef (com.mongodb.DBRef)5 Collection (java.util.Collection)4 NotFoundException (org.graylog2.database.NotFoundException)4 ImmutableList (com.google.common.collect.ImmutableList)3 MongoClient (com.mongodb.MongoClient)3 MongoException (com.mongodb.MongoException)3 MongoInputSplit (com.mongodb.hadoop.input.MongoInputSplit)3 LinkedHashMap (java.util.LinkedHashMap)3