Search in sources :

Example 1 with MalformedDocumentVisibilityException

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;
}
Also used : RyaURI(org.apache.rya.api.domain.RyaURI) MalformedDocumentVisibilityException(org.apache.rya.mongodb.document.visibility.DocumentVisibilityAdapter.MalformedDocumentVisibilityException) StatementMetadata(org.apache.rya.api.domain.StatementMetadata) RyaStatement(org.apache.rya.api.domain.RyaStatement) DocumentVisibility(org.apache.rya.mongodb.document.visibility.DocumentVisibility) RyaType(org.apache.rya.api.domain.RyaType) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) MalformedDocumentVisibilityException(org.apache.rya.mongodb.document.visibility.DocumentVisibilityAdapter.MalformedDocumentVisibilityException)

Aggregations

NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 RyaStatement (org.apache.rya.api.domain.RyaStatement)1 RyaType (org.apache.rya.api.domain.RyaType)1 RyaURI (org.apache.rya.api.domain.RyaURI)1 StatementMetadata (org.apache.rya.api.domain.StatementMetadata)1 DocumentVisibility (org.apache.rya.mongodb.document.visibility.DocumentVisibility)1 MalformedDocumentVisibilityException (org.apache.rya.mongodb.document.visibility.DocumentVisibilityAdapter.MalformedDocumentVisibilityException)1