Examples of SailConnection


Examples of org.openrdf.sail.SailConnection

              Database database = getDatabase();
              URI itemURI = database.getItemURI(_itemID);
             
              result.put("itemURI", result, itemURI.toString());
             
              SailConnection connection = database.getSail().getConnection();
              try {
                Value type = SailUtilities.getObject(connection, itemURI, RDF.TYPE);
                if (type instanceof URI) {
                  typeId = database.getTypeId((URI) type);
                }
              } finally {
                  connection.close();
              }
               
            Lens lens = _lensRegistry.getLens(typeId);
           
              SailRepositoryConnection connection2 = (SailRepositoryConnection) database.getRepository().getConnection();
View Full Code Here

Examples of org.openrdf.sail.SailConnection

            } else if ("ntriples".equals(lang)) {
                parser = new NTriplesParser(r.getValueFactory());
            }
           
            try {
              SailConnection c = null;
              try {
                  c = sail.getConnection();
                  BNodeConverterStatementHandler handler = new BNodeConverterStatementHandler(c);
 
                  parser.setRDFHandler(handler);
                  parser.setParseErrorListener(new LoggingParseErrorListener(sourceURL));
                  parser.setVerifyData(false);
                  parser.setStopAtFirstError(false);
 
                  parser.parse(stream, sourceURL);
                 
                  c.commit();
 
                  _logger.info("Read " + handler.m_count + " statements from '" + sourceURL + "'");
              } catch (RepositoryException e) {
                  if (c != null) c.rollback();
              } finally {
                  if (c != null) c.close();
              }
          } catch (Exception e) {
              throw new ModelReadFromFileException("Failed to read data from '" + sourceURL + "'", e);
          } finally {
              stream.close();
View Full Code Here

Examples of org.openrdf.sail.SailConnection

   
    private void computeCachedInformation() {
        if (_propertyRecords == null || _typeRecords == null) {
            getRepository();
           
            SailConnection sc = null;
            try {
                sc = _sail.getConnection();
            } catch (SailException e) {
                _logger.error("Failed to open sail connection in order to compute cached information", e);
            } catch (Exception e) {
            } finally {
            }
           
            if (sc != null) {
                try {
                    internalBuildPropertyRecords(sc);
                    internalBuildTypeRecords(sc);
                } finally {
                    try {
                        sc.close();
                    } catch (SailException e) {
                        _logger.warn("Failed to close sail connection", e);
                    }
                }
            }
View Full Code Here

Examples of org.openrdf.sail.SailConnection

           
          URI itemURI = _itemIdToUri.get(itemID);
          if (itemURI != null) {
              try {
               
                SailConnection sc = _sail.getConnection();
                try {
                    CloseableIteration<? extends Statement, SailException> i =
                      sc.getStatements(itemURI, RDFS.LABEL, null, true);
                       
                    try {
                      if (i.hasNext()) {
                        label = Utilities.valueToString(i.next().getObject());
                      }
                    } finally {
                      i.close();
                    }       
                } finally {
                  sc.close();
                }
              } catch (SailException e) {
              }
          }
         
View Full Code Here

Examples of org.openrdf.sail.SailConnection

                        final RDFParser rdfParser,
                        final String baseGraph,
                        final RDFHandler... rdfHandlers) {
        try {
            this.commit();
            final SailConnection c = this.rawGraph.getConnection();
            try {
                c.begin();
                RDFHandler h = null == baseGraph
                        ? new SailAdder(c)
                        : new SailAdder(c, new URIImpl(baseGraph));
                if (rdfHandlers != null) {
                    RDFHandler[] handlers = new RDFHandler[rdfHandlers.length + 1];
                    handlers[0] = h;
                    System.arraycopy(rdfHandlers, 0, handlers, 1, rdfHandlers.length);
                    h = new RDFHandlerWrapper(handlers);
                }
                rdfParser.setRDFHandler(h);
                rdfParser.parse(input, baseURI);
                c.commit();
            } finally {
                c.rollback();
                c.close();
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

Examples of org.openrdf.sail.SailConnection

     * @param format supported formats include rdf-xml, n-triples, turtle, n3, trix, or trig
     */
    public void saveRDF(final OutputStream output, final String format) {
        try {
            this.commit();
            final SailConnection c = this.rawGraph.getConnection();
            try {
                c.begin();
                RDFWriter w = Rio.createWriter(getFormat(format), output);
                w.startRDF();

                CloseableIteration<? extends Statement, SailException> iter = c.getStatements(null, null, null, false);
                try {
                    while (iter.hasNext()) {
                        w.handleStatement(iter.next());
                    }
                } finally {
                    iter.close();
                }

                w.endRDF();
            } finally {
                c.rollback();
                c.close();
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

Examples of org.openrdf.sail.SailConnection

        }
    }

    private synchronized SailConnection createConnection() throws SailException {
        cleanupConnections();
        final SailConnection sc = rawGraph.getConnection();
        sc.begin();
        connections.add(sc);
        return sc;
    }
View Full Code Here

Examples of org.openrdf.sail.SailConnection

        }
    }

    public void commit() {
        try {
            SailConnection sc = this.sailConnection.get();
            sc.commit();
            sc.begin();
        } catch (SailException e) {
            throw new RuntimeException(e.getMessage(), e);
        }
    }
View Full Code Here

Examples of org.openrdf.sail.SailConnection

        }
    }

    public void rollback() {
        try {
            SailConnection sc = this.sailConnection.get();
            sc.rollback();
            sc.begin();
        } catch (SailException e) {
            throw new RuntimeException(e.getMessage(), e);
        }
    }
View Full Code Here

Examples of org.openrdf.sail.SailConnection

            i.close();
        }
    }

    protected void clear() throws Exception {
        SailConnection sc = sail.getConnection();
        try {
            sc.begin();
            sc.clear();
            sc.commit();
        } finally {
            sc.rollback();
            sc.close();
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.