@Override public boolean supportsTransactions() { return dataset.supportsTransactions(); } }
@Override public boolean supportsTransactions() { return dataset.supportsTransactions(); } }
@Override public boolean supportsTransactions() { return delegate.supportsTransactions(); }
@Override public boolean supportsTransactions() { return delegate.supportsTransactions(); }
@Override protected void checkTransactionIsolation(int level) throws SQLException { switch (level) { case TRANSACTION_NONE: return; case TRANSACTION_SERIALIZABLE: // Serializable is supported if the dataset supports transactions if (this.ds != null) if (this.ds.supportsTransactions()) return; // Otherwise we'll drop through and throw the error default: throw new SQLException(String.format("The Transaction level %d is not supported by this connection", level)); } }
@Override protected void checkTransactionIsolation(int level) throws SQLException { switch (level) { case TRANSACTION_NONE: return; case TRANSACTION_SERIALIZABLE: // Serializable is supported if the dataset supports transactions if (this.ds != null) if (this.ds.supportsTransactions()) return; // Otherwise we'll drop through and throw the error default: throw new SQLException(String.format("The Transaction level %d is not supported by this connection", level)); } }
@Override public boolean supportsTransactions() { // Transactions are only supported if the underlying dataset supports them return ((DatasetConnection)this.getConnection()).getJenaDataset().supportsTransactions(); } }
@Override public boolean supportsTransactions() { // Transactions are only supported if the underlying dataset supports them return ((DatasetConnection)this.getConnection()).getJenaDataset().supportsTransactions(); } }
@Override protected synchronized void commitInternal() throws SQLException { try { if (ds.supportsTransactions()) { if (ds.isInTransaction()) { // How many participants are there in this transaction? int participants = this.transactionParticipants.get(); if (participants > 1) { // Transaction should remain active this.transactionParticipants.set(participants - 1); } else { // Now safe to commit ds.commit(); ds.end(); this.transactionParticipants.remove(); this.transactionType.remove(); } } else { throw new SQLException("Attempted to commit a transaction when there was no active transaction"); } } } catch (SQLException e) { throw e; } catch (Exception e) { throw new SQLException("Unexpected error committing the transaction", e); } }
@Override protected synchronized void rollbackInternal() throws SQLException { try { if (ds.supportsTransactions()) { if (ds.isInTransaction()) { // Regardless of participants a rollback is always immediate ds.abort(); ds.end(); this.transactionType.remove(); this.transactionParticipants.remove(); } else { throw new SQLException("Attempted to rollback a transaction when there was no active transaction"); } } } catch (SQLException e) { throw e; } catch (Exception e) { throw new SQLException("Unexpected error rolling back the transaction", e); } } }
@Override protected synchronized void commitInternal() throws SQLException { try { if (ds.supportsTransactions()) { if (ds.isInTransaction()) { // How many participants are there in this transaction? int participants = this.transactionParticipants.get(); if (participants > 1) { // Transaction should remain active this.transactionParticipants.set(participants - 1); } else { // Now safe to commit ds.commit(); ds.end(); this.transactionParticipants.remove(); this.transactionType.remove(); } } else { throw new SQLException("Attempted to commit a transaction when there was no active transaction"); } } } catch (SQLException e) { throw e; } catch (Exception e) { throw new SQLException("Unexpected error committing the transaction", e); } }
@Override protected synchronized void rollbackInternal() throws SQLException { try { if (ds.supportsTransactions()) { if (ds.isInTransaction()) { // Regardless of participants a rollback is always immediate ds.abort(); ds.end(); this.transactionType.remove(); this.transactionParticipants.remove(); } else { throw new SQLException("Attempted to rollback a transaction when there was no active transaction"); } } } catch (SQLException e) { throw e; } catch (Exception e) { throw new SQLException("Unexpected error rolling back the transaction", e); } } }
@Test public void transaction_00() { Dataset ds = create(); assertTrue(ds.supportsTransactions()); }
private void executeUpdate(HttpServletRequest req, UpdateRequest parsed) { VitroRequest vreq = new VitroRequest(req); SearchIndexer indexer = ApplicationUtils.instance().getSearchIndexer(); Dataset ds = new RDFServiceDataset(vreq.getUnfilteredRDFService()); GraphStore graphStore = GraphStoreFactory.create(ds); try { if(indexer != null) { indexer.pause(); } if(ds.supportsTransactions()) { ds.begin(ReadWrite.WRITE); } UpdateAction.execute(parsed, graphStore); } finally { if(ds.supportsTransactions()) { ds.commit(); ds.end(); } if(indexer != null) { indexer.unpause(); } } }
protected void addGraphs(Dataset ds) { try { if ( hasEntries(dataURLs) ) { if ( ds.supportsTransactions() ) { Txn.executeWrite(ds, () -> { for ( String url : dataURLs ) RDFDataMgr.read(ds, url); }); } else { for ( String url : dataURLs ) RDFDataMgr.read(ds, url); } } if ( hasEntries(graphURLs) || hasEntries(namedGraphURLs) ) { // Resolve named graph URLs so the graphname is an absolute IRI. List<String> x = ListUtils.toList(namedGraphURLs.stream().map(IRIResolver::resolveFileURL)); DatasetUtils.addInGraphs(ds, graphURLs, x, null) ; } } catch (LabelExistsException ex) { throw new CmdException(ex.getMessage()) ; } catch (JenaException ex) { throw ex ; } catch (Exception ex) { throw new CmdException("Error creating dataset", ex) ; } }
@Test public void nullRdfService() throws Exception { model.removeAll(); Model desiredResults = ModelFactory.createDefaultModel(); desiredResults.read(new StringReader(result1), null, "N3"); Dataset ds = new RDFServiceDataset(rdfService); GraphStore graphStore = GraphStoreFactory.create(ds); try { if(ds.supportsTransactions()) { ds.begin(ReadWrite.WRITE); System.out.println("yep"); } UpdateAction.execute(UpdateFactory.create(updateStr1), graphStore); } finally { if(ds.supportsTransactions()) { ds.commit(); ds.end(); } } assertEquals("updateStr1 yields result1", desiredResults.toString(), model.toString()); }
private void createTest(String filename, Resource type) { Object thing = AssemblerUtils.build(filename, type) ; assertTrue(thing instanceof Dataset) ; Dataset ds = (Dataset)thing ; assertTrue(ds.asDatasetGraph() instanceof DatasetGraphSwitchable) ; assertTrue(ds.supportsTransactions()) ; ds.close() ; }
private void createTest(String filename, Resource type) { Object thing = AssemblerUtils.build(filename, type) ; assertTrue(thing instanceof Dataset) ; Dataset ds = (Dataset)thing ; assertTrue(ds.asDatasetGraph() instanceof DatasetGraphTransaction) ; assertTrue(ds.supportsTransactions()) ; ds.close(); }
private void createTest(String filename, Resource type) { Object thing = AssemblerUtils.build(filename, type) ; assertTrue(thing instanceof Dataset) ; Dataset ds = (Dataset)thing ; assertTrue(ds.asDatasetGraph() instanceof DatasetGraphTransaction) ; assertTrue(ds.supportsTransactions()) ; ds.close(); }
private void createTest(String filename, Resource type) { Object thing = AssemblerUtils.build(filename, type) ; assertTrue(thing instanceof Dataset) ; Dataset ds = (Dataset)thing ; assertTrue(ds.asDatasetGraph() instanceof DatasetGraphSwitchable) ; assertTrue(ds.supportsTransactions()) ; ds.close() ; }