@Override public void addStatement(final RyaStatement statement) throws AddStatementException { try { dao.add(statement); } catch (final RyaDAOException e) { throw new AddStatementException("Unable to add statement: '" + statement.toString() + "'", e); } }
@Override public void removeStatement(final RyaStatement statement) throws RemoveStatementException { try { //mongo dao does not need a config to remove. dao.delete(statement, null); } catch (final RyaDAOException e) { throw new RemoveStatementException("Unable to remove statement: '" + statement.toString() + "'", e); } }
private DBObject prepareStatementForStorage(final RyaStatement ryaStatement) { try { final Statement statement = RyaToRdfConversions.convertStatement(ryaStatement); final boolean isValidPredicate = predicates.isEmpty() || predicates.contains(statement.getPredicate()); if (isValidPredicate && (statement.getObject() instanceof Literal)) { final DBObject obj = storageStrategy.serialize(ryaStatement); return obj; } } catch (final IllegalArgumentException e) { LOG.error("Unable to parse the statement: " + ryaStatement.toString(), e); } return null; }
private DBObject prepareStatementForStorage(final RyaStatement ryaStatement) { try { final Statement statement = RyaToRdfConversions.convertStatement(ryaStatement); final boolean isValidPredicate = predicates.isEmpty() || predicates.contains(statement.getPredicate()); if (isValidPredicate && (statement.getObject() instanceof Literal)) { final DBObject obj = storageStrategy.serialize(ryaStatement); return obj; } } catch (final IllegalArgumentException e) { LOG.error("Unable to parse the statement: " + ryaStatement.toString(), e); } return null; }
@Override public void add(final Iterator<RyaStatement> statementIter) throws RyaDAOException { final List<DBObject> dbInserts = new ArrayList<>(); while (statementIter.hasNext()){ final RyaStatement ryaStatement = statementIter.next(); final boolean canAdd = DocumentVisibilityUtil.doesUserHaveDocumentAccess(auths, ryaStatement.getColumnVisibility()); if (canAdd) { final DBObject insert = storageStrategy.serialize(ryaStatement); dbInserts.add(insert); try { for (final RyaSecondaryIndexer index : secondaryIndexers) { index.storeStatement(ryaStatement); } } catch (final IOException e) { log.error("Failed to add: " + ryaStatement.toString() + " to the indexer"); } } else { throw new RyaDAOException("User does not have the required authorizations to add statement"); } } try { mongoDbBatchWriter.addObjectsToQueue(dbInserts); if (flushEachUpdate.get()) { flush(); } } catch (final MongoDbBatchWriterException e) { throw new RyaDAOException("Error adding statements", e); } }
@Override public void add(final Iterator<RyaStatement> statementIter) throws RyaDAOException { final List<DBObject> dbInserts = new ArrayList<>(); while (statementIter.hasNext()){ final RyaStatement ryaStatement = statementIter.next(); final boolean canAdd = DocumentVisibilityUtil.doesUserHaveDocumentAccess(auths, ryaStatement.getColumnVisibility()); if (canAdd) { final DBObject insert = storageStrategy.serialize(ryaStatement); dbInserts.add(insert); try { for (final RyaSecondaryIndexer index : secondaryIndexers) { index.storeStatement(ryaStatement); } } catch (final IOException e) { log.error("Failed to add: " + ryaStatement.toString() + " to the indexer"); } } else { throw new RyaDAOException("User does not have the required authorizations to add statement"); } } try { mongoDbBatchWriter.addObjectsToQueue(dbInserts); if (flushEachUpdate.get()) { flush(); } } catch (final MongoDbBatchWriterException e) { throw new RyaDAOException("Error adding statements", e); } }
@Override public void delete(final Iterator<RyaStatement> statements, final StatefulMongoDBRdfConfiguration conf) throws RyaDAOException { while (statements.hasNext()){ final RyaStatement ryaStatement = statements.next(); final boolean canDelete = DocumentVisibilityUtil.doesUserHaveDocumentAccess(auths, ryaStatement.getColumnVisibility()); if (canDelete) { coll.remove(storageStrategy.getQuery(ryaStatement)); for (final RyaSecondaryIndexer index : secondaryIndexers) { try { index.deleteStatement(ryaStatement); } catch (final IOException e) { log.error("Unable to remove statement: " + ryaStatement.toString() + " from secondary indexer: " + index.getTableName(), e); } } } else { throw new RyaDAOException("User does not have the required authorizations to delete statement"); } } }
@Override public void delete(final Iterator<RyaStatement> statements, final StatefulMongoDBRdfConfiguration conf) throws RyaDAOException { while (statements.hasNext()){ final RyaStatement ryaStatement = statements.next(); final boolean canDelete = DocumentVisibilityUtil.doesUserHaveDocumentAccess(auths, ryaStatement.getColumnVisibility()); if (canDelete) { coll.remove(storageStrategy.getQuery(ryaStatement)); for (final RyaSecondaryIndexer index : secondaryIndexers) { try { index.deleteStatement(ryaStatement); } catch (final IOException e) { log.error("Unable to remove statement: " + ryaStatement.toString() + " from secondary indexer: " + index.getTableName(), e); } } } else { throw new RyaDAOException("User does not have the required authorizations to delete statement"); } } }
@Override public void add(final RyaStatement statement) throws RyaDAOException { // add it to the collection try { final boolean canAdd = DocumentVisibilityUtil.doesUserHaveDocumentAccess(auths, statement.getColumnVisibility()); if (canAdd) { final DBObject obj = storageStrategy.serialize(statement); try { mongoDbBatchWriter.addObjectToQueue(obj); if (flushEachUpdate.get()) { flush(); } } catch (final MongoDbBatchWriterException e) { throw new RyaDAOException("Error adding statement", e); } for(final RyaSecondaryIndexer index: secondaryIndexers) { index.storeStatement(statement); } } else { throw new RyaDAOException("User does not have the required authorizations to add statement"); } } catch (final IOException e) { log.error("Unable to add: " + statement.toString()); throw new RyaDAOException(e); } catch (final DuplicateKeyException e){ log.error("Attempting to load duplicate triple: " + statement.toString()); } }
@Override public void add(final RyaStatement statement) throws RyaDAOException { // add it to the collection try { final boolean canAdd = DocumentVisibilityUtil.doesUserHaveDocumentAccess(auths, statement.getColumnVisibility()); if (canAdd) { final DBObject obj = storageStrategy.serialize(statement); try { mongoDbBatchWriter.addObjectToQueue(obj); if (flushEachUpdate.get()) { flush(); } } catch (final MongoDbBatchWriterException e) { throw new RyaDAOException("Error adding statement", e); } for(final RyaSecondaryIndexer index: secondaryIndexers) { index.storeStatement(statement); } } else { throw new RyaDAOException("User does not have the required authorizations to add statement"); } } catch (final IOException e) { log.error("Unable to add: " + statement.toString()); throw new RyaDAOException(e); } catch (final DuplicateKeyException e){ log.error("Attempting to load duplicate triple: " + statement.toString()); } }
System.out.println(statement.toString()); childStore.removeStatement(statement);
System.out.println(statement.toString()); childStore.removeStatement(statement);
@Override public void delete(final RyaStatement statement, final StatefulMongoDBRdfConfiguration conf) throws RyaDAOException { final boolean canDelete = DocumentVisibilityUtil.doesUserHaveDocumentAccess(auths, statement.getColumnVisibility()); if (canDelete) { final DBObject obj = storageStrategy.getQuery(statement); coll.remove(obj); for (final RyaSecondaryIndexer index : secondaryIndexers) { try { index.deleteStatement(statement); } catch (final IOException e) { log.error("Unable to remove statement: " + statement.toString() + " from secondary indexer: " + index.getTableName(), e); } } } else { throw new RyaDAOException("User does not have the required authorizations to delete statement"); } }
@Override public void delete(final RyaStatement statement, final StatefulMongoDBRdfConfiguration conf) throws RyaDAOException { final boolean canDelete = DocumentVisibilityUtil.doesUserHaveDocumentAccess(auths, statement.getColumnVisibility()); if (canDelete) { final DBObject obj = storageStrategy.getQuery(statement); coll.remove(obj); for (final RyaSecondaryIndexer index : secondaryIndexers) { try { index.deleteStatement(statement); } catch (final IOException e) { log.error("Unable to remove statement: " + statement.toString() + " from secondary indexer: " + index.getTableName(), e); } } } else { throw new RyaDAOException("User does not have the required authorizations to delete statement"); } }