use of org.apache.rya.api.persist.query.RyaQuery in project incubator-rya by apache.
the class AccumuloRyaQueryEngine method query.
@Override
public CloseableIteration<RyaStatement, RyaDAOException> query(RyaStatement stmt, AccumuloRdfConfiguration conf) throws RyaDAOException {
if (conf == null) {
conf = configuration;
}
RyaQuery ryaQuery = RyaQuery.builder(stmt).load(conf).build();
CloseableIterable<RyaStatement> results = query(ryaQuery);
return new CloseableIterableIteration<RyaStatement, RyaDAOException>(results);
}
use of org.apache.rya.api.persist.query.RyaQuery in project incubator-rya by apache.
the class MongoDBRyaDAOIT method testVisibilityStatement.
/**
* Generates a test statement with the provided document visibility to
* determine if the specified user authorization can view the statement.
*
* @param dao - The DAO that will be used by the test.
* @param documentVisibility - The document visibility boolean expression
* string.
* @param userAuthorizations - The user authorization strings.
* @return {@code true} if provided authorization could access the document
* in the collection. {@code false} otherwise.
* @throws RyaDAOException
*/
private boolean testVisibilityStatement(final MongoDBRyaDAO dao, final String documentVisibility, final Authorizations userAuthorizations) throws RyaDAOException {
final MongoDatabase db = conf.getMongoClient().getDatabase(conf.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
final MongoCollection<Document> coll = db.getCollection(conf.getTriplesCollectionName());
final RyaStatement statement = buildVisibilityTestRyaStatement(documentVisibility);
dao.getConf().setAuths(AuthorizationsUtil.getAuthorizationsStringArray(Authorizations.EMPTY));
dao.add(statement);
dao.getConf().setAuths(AuthorizationsUtil.getAuthorizationsStringArray(userAuthorizations != null ? userAuthorizations : Authorizations.EMPTY));
assertEquals(1, coll.count());
final MongoDBQueryEngine queryEngine = (MongoDBQueryEngine) dao.getQueryEngine();
queryEngine.setConf(conf);
final CloseableIterable<RyaStatement> iter = queryEngine.query(new RyaQuery(statement));
// Check if user has authorization to view document based on its visibility
final boolean hasNext = iter.iterator().hasNext();
// Reset
dao.delete(statement, conf);
assertEquals(0, coll.count());
dao.getConf().setAuths(AuthorizationsUtil.getAuthorizationsStringArray(Authorizations.EMPTY));
return hasNext;
}
Aggregations