@Test public void AddBulk() throws SQLException, IOException { ID sub = new UID(TEST.NS, "e" + System.currentTimeMillis()); List<STMT> stmts = Arrays.asList( new STMT(sub, RDFS.label, sub), new STMT(sub, RDFS.label, new LIT(sub.getId())), new STMT(sub, RDFS.label, new LIT("X")), new STMT(sub, RDFS.label, new LIT(sub.getId(), Locale.ENGLISH)), new STMT(sub, RDFS.label, new LIT("1", XSD.intType)) ); toBeRemoved = stmts; connection.addBulk(stmts); for (STMT stmt : stmts) { assertExists(stmt); } }
public void addBulk(Collection<STMT> addedStatements) throws SQLException, IOException { verifyNotReadOnly(); Map<UID, TurtleStringWriter> writers = new HashMap<UID, TurtleStringWriter>(); for (STMT stmt : addedStatements) { assertAllowedGraph(stmt.getContext()); UID context = stmt.getContext() != null ? stmt.getContext() : defaultGraph; TurtleStringWriter writer = writers.get(context); if (writer == null) { writer = new TurtleStringWriter(true); writers.put(context, writer); writer.begin(); } writer.handle(stmt); } PreparedStatement stmt = connection.prepareStatement(SPARQL_CREATE_GRAPH); try { for (UID graph : writers.keySet()) { stmt.setString(1, graph.getId()); stmt.execute(); stmt.clearParameters(); } } finally { stmt.close(); } stmt = connection.prepareStatement("DB.DBA.TTLP(?,'',?,0)"); try { for (Map.Entry<UID, TurtleStringWriter> entry : writers.entrySet()) { entry.getValue().end(); stmt.setString(1, entry.getValue().toString()); stmt.setString(2, entry.getKey().getId()); stmt.execute(); stmt.clearParameters(); } } finally { stmt.close(); } }
VirtuosoRepositoryConnection implements RDFConnection { public void addBulk(Collection<STMT> addedStatements) throws SQLException, IOException { verifyNotReadOnly(); Map<UID, TurtleStringWriter> writers = new HashMap<UID, TurtleStringWriter>(); for (STMT stmt : addedStatements) { assertAllowedGraph(stmt.getContext()); UID context = stmt.getContext() != null ? stmt.getContext() : defaultGraph; TurtleStringWriter writer = writers.get(context); if (writer == null) { writer = new TurtleStringWriter(true); writers.put(context, writer); writer.begin(); } writer.handle(stmt); } PreparedStatement stmt = connection.prepareStatement(SPARQL_CREATE_GRAPH); try { for (UID graph : writers.keySet()) { stmt.setString(1, graph.getId()); stmt.execute(); stmt.clearParameters(); } } finally { stmt.close(); } stmt = connection.prepareStatement("DB.DBA.TTLP(?,'',?,0)"); try { for (Map.Entry<UID, TurtleStringWriter> entry : writers.entrySet()) { entry.getValue().end(); stmt.setString(1, entry.getValue().toString()); stmt.setString(2, entry.getKey().getId()); stmt.execute(); stmt.clearParameters(); } } finally { stmt.close(); } } }
VirtuosoRepositoryConnection implements RDFConnection { public void addBulk(Collection<STMT> addedStatements) throws SQLException, IOException { verifyNotReadOnly(); Map<UID, TurtleStringWriter> writers = new HashMap<UID, TurtleStringWriter>(); for (STMT stmt : addedStatements) { assertAllowedGraph(stmt.getContext()); UID context = stmt.getContext() != null ? stmt.getContext() : defaultGraph; TurtleStringWriter writer = writers.get(context); if (writer == null) { writer = new TurtleStringWriter(true); writers.put(context, writer); writer.begin(); } writer.handle(stmt); } PreparedStatement stmt = connection.prepareStatement(SPARQL_CREATE_GRAPH); try { for (UID graph : writers.keySet()) { stmt.setString(1, graph.getId()); stmt.execute(); stmt.clearParameters(); } } finally { stmt.close(); } stmt = connection.prepareStatement("DB.DBA.TTLP(?,'',?,0)"); try { for (Map.Entry<UID, TurtleStringWriter> entry : writers.entrySet()) { entry.getValue().end(); stmt.setString(1, entry.getValue().toString()); stmt.setString(2, entry.getKey().getId()); stmt.execute(); stmt.clearParameters(); } } finally { stmt.close(); } } protected  VirtuosoRepositoryConnection(
            IdSequence idSequence,
            Converter converter,
            int prefetchSize,
            UID defGraph,
            Collection<UID> allowedGraphs,
            Connection connection); }
VirtuosoRepositoryConnection implements RDFConnection { public void addBulk(Collection<STMT> addedStatements) throws SQLException, IOException { verifyNotReadOnly(); Map<UID, TurtleStringWriter> writers = new HashMap<UID, TurtleStringWriter>(); for (STMT stmt : addedStatements) { assertAllowedGraph(stmt.getContext()); UID context = stmt.getContext() != null ? stmt.getContext() : defaultGraph; TurtleStringWriter writer = writers.get(context); if (writer == null) { writer = new TurtleStringWriter(true); writers.put(context, writer); writer.begin(); } writer.handle(stmt); } PreparedStatement stmt = connection.prepareStatement(SPARQL_CREATE_GRAPH); try { for (UID graph : writers.keySet()) { stmt.setString(1, graph.getId()); stmt.execute(); stmt.clearParameters(); } } finally { stmt.close(); } stmt = connection.prepareStatement("DB.DBA.TTLP(?,'',?,0)"); try { for (Map.Entry<UID, TurtleStringWriter> entry : writers.entrySet()) { entry.getValue().end(); stmt.setString(1, entry.getValue().toString()); stmt.setString(2, entry.getKey().getId()); stmt.execute(); stmt.clearParameters(); } } finally { stmt.close(); } } protected  VirtuosoRepositoryConnection(
            IdSequence idSequence,
            Converter converter,
            int prefetchSize,
            UID defGraph,
            Collection<UID> allowedGraphs,
            Connection connection); static void bindBlankNode(PreparedStatement ps, int col, BID n); static void bindResource(PreparedStatement ps, int col, ID n); static void bindURI(PreparedStatement ps, int col, UID n); static void bindValue(PreparedStatement ps, int col, NODE n); void addBulk(Collection<STMT> addedStatements); void removeBulk(Collection<STMT> deletedStatements); @Override RDFBeanTransaction beginTransaction(boolean readOnly, int txTimeout, int isolationLevel); @Override void clear(); @Override void close(); @Override BID createBNode(); @SuppressWarnings("unchecked") @Override Q createUpdate(UpdateLanguage<D, Q> updateLanguage, final D definition); @SuppressWarnings("unchecked") @Override Q createQuery(QueryLanguage<D, Q> queryLanguage, D definition); @Override boolean exists(ID subject, UID predicate, NODE object, UID context, boolean includeInferred); @Override CloseableIterator<STMT> findStatements(
            @Nullable ID subject,
            @Nullable UID predicate,
            @Nullable NODE object,
            @Nullable UID context, boolean includeInferred); Connection getConnection(); @Override long getNextLocalId(); boolean isReadOnly(); void load(Format format, InputStream is, @Nullable UID context, boolean replace); @Override void remove(ID subject, UID predicate, NODE object, UID context); @Override void update(Collection<STMT> removedStatements, Collection<STMT> addedStatements); T doInConnection(SQLConnectionCallback<T> callback); @Override QueryOptions getQueryOptions(); @Override InferenceOptions getInferenceOptions(); }
VirtuosoRepositoryConnection implements RDFConnection { public void addBulk(Collection<STMT> addedStatements) throws SQLException, IOException { verifyNotReadOnly(); Map<UID, TurtleStringWriter> writers = new HashMap<UID, TurtleStringWriter>(); for (STMT stmt : addedStatements) { assertAllowedGraph(stmt.getContext()); UID context = stmt.getContext() != null ? stmt.getContext() : defaultGraph; TurtleStringWriter writer = writers.get(context); if (writer == null) { writer = new TurtleStringWriter(true); writers.put(context, writer); writer.begin(); } writer.handle(stmt); } PreparedStatement stmt = connection.prepareStatement(SPARQL_CREATE_GRAPH); try { for (UID graph : writers.keySet()) { stmt.setString(1, graph.getId()); stmt.execute(); stmt.clearParameters(); } } finally { stmt.close(); } stmt = connection.prepareStatement("DB.DBA.TTLP(?,'',?,0)"); try { for (Map.Entry<UID, TurtleStringWriter> entry : writers.entrySet()) { entry.getValue().end(); stmt.setString(1, entry.getValue().toString()); stmt.setString(2, entry.getKey().getId()); stmt.execute(); stmt.clearParameters(); } } finally { stmt.close(); } } protected  VirtuosoRepositoryConnection(
            IdSequence idSequence,
            Converter converter,
            int prefetchSize,
            UID defGraph,
            Collection<UID> allowedGraphs,
            Connection connection); static void bindBlankNode(PreparedStatement ps, int col, BID n); static void bindResource(PreparedStatement ps, int col, ID n); static void bindURI(PreparedStatement ps, int col, UID n); static void bindValue(PreparedStatement ps, int col, NODE n); void addBulk(Collection<STMT> addedStatements); void removeBulk(Collection<STMT> deletedStatements); @Override RDFBeanTransaction beginTransaction(boolean readOnly, int txTimeout, int isolationLevel); @Override void clear(); @Override void close(); @Override BID createBNode(); @SuppressWarnings("unchecked") @Override Q createUpdate(UpdateLanguage<D, Q> updateLanguage, final D definition); @SuppressWarnings("unchecked") @Override Q createQuery(QueryLanguage<D, Q> queryLanguage, D definition); @Override boolean exists(ID subject, UID predicate, NODE object, UID context, boolean includeInferred); @Override CloseableIterator<STMT> findStatements(
            @Nullable ID subject,
            @Nullable UID predicate,
            @Nullable NODE object,
            @Nullable UID context, boolean includeInferred); Connection getConnection(); @Override long getNextLocalId(); boolean isReadOnly(); void load(Format format, InputStream is, @Nullable UID context, boolean replace); @Override void remove(ID subject, UID predicate, NODE object, UID context); @Override void update(Collection<STMT> removedStatements, Collection<STMT> addedStatements); T doInConnection(SQLConnectionCallback<T> callback); @Override QueryOptions getQueryOptions(); @Override InferenceOptions getInferenceOptions();  }