use of org.apache.rya.mongodb.document.visibility.DocumentVisibilityAdapter.MalformedDocumentVisibilityException in project incubator-rya by apache.
the class SimpleMongoDBStorageStrategy method deserializeDBObject.
@Override
public RyaStatement deserializeDBObject(final DBObject queryResult) {
final Map<?, ?> result = queryResult.toMap();
final String subject = (String) result.get(SUBJECT);
final String object = (String) result.get(OBJECT);
final String objectType = (String) result.get(OBJECT_TYPE);
final String predicate = (String) result.get(PREDICATE);
final String context = (String) result.get(CONTEXT);
DocumentVisibility documentVisibility = null;
try {
documentVisibility = DocumentVisibilityAdapter.toDocumentVisibility(queryResult);
} catch (final MalformedDocumentVisibilityException e) {
throw new RuntimeException("Unable to convert document visibility", e);
}
final Long timestamp = (Long) result.get(TIMESTAMP);
final String statementMetadata = (String) result.get(STATEMENT_METADATA);
RyaType objectRya = null;
if (objectType.equalsIgnoreCase(ANYURI.stringValue())) {
objectRya = new RyaURI(object);
} else {
objectRya = new RyaType(factory.createURI(objectType), object);
}
final RyaStatement statement;
if (!context.isEmpty()) {
statement = new RyaStatement(new RyaURI(subject), new RyaURI(predicate), objectRya, new RyaURI(context));
} else {
statement = new RyaStatement(new RyaURI(subject), new RyaURI(predicate), objectRya);
}
statement.setColumnVisibility(documentVisibility.flatten());
if (timestamp != null) {
statement.setTimestamp(timestamp);
}
if (statementMetadata != null) {
try {
final StatementMetadata metadata = new StatementMetadata(statementMetadata);
statement.setStatementMetadata(metadata);
} catch (final Exception ex) {
LOG.debug("Error deserializing metadata for statement", ex);
}
}
return statement;
}
Aggregations