Java Code Examples for org.openrdf.query.QueryLanguage#SPARQL
The following examples show how to use
org.openrdf.query.QueryLanguage#SPARQL .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BigdataSailRepositoryConnection.java From database with GNU General Public License v2.0 | 6 votes |
/** * Parse a SPARQL UPDATE request. * * @param ql * The {@link QueryLanguage}. * @param updateStr * The update request. * @param baseURI * The base URI. * * @return An object wrapping the bigdata AST model for that request. * * @throws MalformedQueryException * @throws UnsupportedOperationException * if the {@link QueryLanguage} is not SPARQL. */ public BigdataSailUpdate prepareNativeSPARQLUpdate(final QueryLanguage ql, final String updateStr, final String baseURI) throws MalformedQueryException { if (getTripleStore().isReadOnly()) throw new UnsupportedOperationException("Read only"); if (ql != QueryLanguage.SPARQL) throw new UnsupportedOperationException(ql.toString()); if (log.isDebugEnabled()) { log.debug(updateStr); } // Flush buffers since we are about to resolve Values to IVs. getSailConnection() .flushStatementBuffers(true/* assertions */, true/* retractions */); // Parse the UPDATE request. final ASTContainer astContainer = new Bigdata2ASTSPARQLParser() .parseUpdate2(updateStr, baseURI); return new BigdataSailUpdate(astContainer, this); }
Example 2
Source File: BigdataSailRepositoryConnection.java From database with GNU General Public License v2.0 | 5 votes |
/** * Parse a SPARQL query * * @param ql * The {@link QueryLanguage}. * @param queryStr * The query. * @param baseURI * The base URI. * * @return An object wrapping the bigdata AST model for that query. * * @throws MalformedQueryException * @throws UnsupportedOperationException * if the query language is not SPARQL. */ public BigdataSailQuery prepareNativeSPARQLQuery(final QueryLanguage ql, final String queryStr, final String baseURI) throws MalformedQueryException { if (ql != QueryLanguage.SPARQL) throw new UnsupportedOperationException(ql.toString()); if (log.isDebugEnabled()) { log.debug(queryStr); } // Flush buffers since we are about to resolve Values to IVs. getSailConnection() .flushStatementBuffers(true/* assertions */, true/* retractions */); final ASTContainer astContainer = new Bigdata2ASTSPARQLParser() .parseQuery2(queryStr, baseURI); final QueryType queryType = astContainer.getOriginalAST() .getQueryType(); switch (queryType) { case SELECT: return new BigdataSailTupleQuery(astContainer, this); case DESCRIBE: case CONSTRUCT: return new BigdataSailGraphQuery(astContainer, this); case ASK: { return new BigdataSailBooleanQuery(astContainer, this); } default: throw new RuntimeException("Unknown query type: " + queryType); } }
Example 3
Source File: ConversionUtil.java From semweb4j with BSD 2-Clause "Simplified" License | 5 votes |
public static QueryLanguage toOpenRDFQueryLanguage(String queryLanguage) { String queryLanguageLowerCase = queryLanguage.toLowerCase(); if(queryLanguageLowerCase.equals("sparql")) { return QueryLanguage.SPARQL; } else if(queryLanguageLowerCase.equals("serql")) { return QueryLanguage.SERQL; } else if(queryLanguageLowerCase.equals("serqo")) { return QueryLanguage.SERQO; } else { throw new QueryLanguageNotSupportedException("Query language '" + queryLanguageLowerCase + "' not supported. Valid values are \"sparql\", \"serql\" and \"serqo\"."); } }
Example 4
Source File: BigdataSailRemoteRepositoryConnection.java From database with GNU General Public License v2.0 | 4 votes |
@Override public BooleanQuery prepareBooleanQuery(final QueryLanguage ql, final String query, final String baseURI) throws RepositoryException, MalformedQueryException { if (ql != QueryLanguage.SPARQL) { throw new UnsupportedOperationException("unsupported query language: " + ql); } try { return new BigdataRemoteBooleanQuery(repo.getRemoteRepository(), query, baseURI); } catch (Exception ex) { throw new RepositoryException(ex); } }
Example 5
Source File: BigdataSailRemoteRepositoryConnection.java From database with GNU General Public License v2.0 | 4 votes |
@Override public GraphQuery prepareGraphQuery(final QueryLanguage ql, final String query, final String baseURI) throws RepositoryException, MalformedQueryException { if (ql != QueryLanguage.SPARQL) { throw new UnsupportedOperationException("unsupported query language: " + ql); } try { return new BigdataRemoteGraphQuery(repo.getRemoteRepository(), query, baseURI); } catch (Exception ex) { throw new RepositoryException(ex); } }
Example 6
Source File: BigdataSailRemoteRepositoryConnection.java From database with GNU General Public License v2.0 | 4 votes |
@Override public TupleQuery prepareTupleQuery(final QueryLanguage ql, final String query, final String baseURI) throws RepositoryException, MalformedQueryException { if (ql != QueryLanguage.SPARQL) { throw new UnsupportedOperationException("unsupported query language: " + ql); } try { final RemoteRepository remote = repo.getRemoteRepository(); return new BigdataRemoteTupleQuery(remote, query, baseURI); } catch (Exception ex) { throw new RepositoryException(ex); } }
Example 7
Source File: RepositoryQueryResultTable.java From semweb4j with BSD 2-Clause "Simplified" License | 4 votes |
public RepositoryQueryResultTable(String queryString, RepositoryConnection connection) throws ModelRuntimeException { this(queryString, QueryLanguage.SPARQL, connection); }
Example 8
Source File: BigdataSailRepositoryConnection.java From database with GNU General Public License v2.0 | 3 votes |
@Override public SailQuery prepareQuery(final QueryLanguage ql, final String qs, final String baseURI) throws MalformedQueryException { if (ql == QueryLanguage.SPARQL) { return (SailQuery) prepareNativeSPARQLQuery(ql, qs, baseURI); } throw new MalformedQueryException("Unsupported language: " + ql); }
Example 9
Source File: BigdataSailRepositoryConnection.java From database with GNU General Public License v2.0 | 3 votes |
/** * {@inheritDoc} * * @see <a href="https://sourceforge.net/apps/trac/bigdata/ticket/448"> * SPARQL 1.1 Update </a> */ @Override public Update prepareUpdate(final QueryLanguage ql, final String update, final String baseURI) throws RepositoryException, MalformedQueryException { if (ql == QueryLanguage.SPARQL) { return (Update) prepareNativeSPARQLUpdate(ql, update, baseURI); } throw new MalformedQueryException("Unsupported language: " + ql); }