Search in sources :

Example 1 with DocumentVisibilityConversionException

use of org.apache.rya.mongodb.document.util.DocumentVisibilityConversionException in project incubator-rya by apache.

the class DocumentVisibilityAdapter method toDBObject.

/**
 * Serializes a {@link DocumentVisibility} to a MongoDB {@link DBObject}.
 * @param documentVisibility the {@link DocumentVisibility} to be
 * serialized.
 * @return The MongoDB {@link DBObject}.
 */
public static BasicDBObject toDBObject(final DocumentVisibility documentVisibility) {
    DocumentVisibility dv;
    if (documentVisibility == null) {
        dv = MongoDbRdfConstants.EMPTY_DV;
    } else {
        dv = documentVisibility;
    }
    Object[] dvArray = null;
    try {
        dvArray = DocumentVisibilityUtil.toMultidimensionalArray(dv);
    } catch (final DocumentVisibilityConversionException e) {
        log.error("Unable to convert document visibility");
    }
    final BasicDBObjectBuilder builder = BasicDBObjectBuilder.start();
    builder.add(DOCUMENT_VISIBILITY_KEY, dvArray);
    return (BasicDBObject) builder.get();
}
Also used : BasicDBObject(com.mongodb.BasicDBObject) BasicDBObjectBuilder(com.mongodb.BasicDBObjectBuilder) DocumentVisibilityConversionException(org.apache.rya.mongodb.document.util.DocumentVisibilityConversionException) DBObject(com.mongodb.DBObject) BasicDBObject(com.mongodb.BasicDBObject)

Aggregations

BasicDBObject (com.mongodb.BasicDBObject)1 BasicDBObjectBuilder (com.mongodb.BasicDBObjectBuilder)1 DBObject (com.mongodb.DBObject)1 DocumentVisibilityConversionException (org.apache.rya.mongodb.document.util.DocumentVisibilityConversionException)1