public WonSparqlValidator(Query constraint) { if (!constraint.isAskType() && !constraint.isSelectType()) { throw new IllegalArgumentException("Wrong constraint type!"); } this.constraint = constraint; }
public WonSparqlValidator(Query constraint, String name) { if (!constraint.isAskType() && !constraint.isSelectType()) { throw new IllegalArgumentException("Wrong constraint type!"); } this.constraint = constraint; this.name = name; }
@Override public ResultSet execSelect() { if (!query.isSelectType()) { throw new RuntimeException("SELECT query expected. Got: [" + query.toString() + "]"); } return executeCoreSelect(query); }
protected Query endSubSelect(int line, int column) { Query subQuery = query ; if ( ! subQuery.isSelectType() ) throwParseException("Subquery not a SELECT query", line, column) ; popQuery(); return subQuery ; }
public static Query createQuery(String queryParam) throws AjaxControllerException { Query query = QueryFactory.create(queryParam, Syntax.syntaxARQ); if (!query.isSelectType()) { throw new AjaxControllerException(SC_NOT_FOUND, "Only 'select' queries are allowed."); } return query; }
private String interpretRequestedFormats(HttpServletRequest req, String queryString) throws NotAcceptableException { Query query = SparqlQueryUtils.create(queryString); String parameterName = (query.isSelectType() || query.isAskType()) ? "resultFormat" : "rdfResultFormat"; String parameterValue = req.getParameter(parameterName); if (StringUtils.isBlank(parameterValue)) { throw new NotAcceptableException("Parameter '" + parameterName + "' was '" + parameterValue + "'."); } else { return parameterValue; } }
public Set<Triple> extractTriplePattern(final Query query, final boolean ignoreOptionals) { triplePattern = new HashSet<>(); optionalTriplePattern = new HashSet<>(); query.getQueryPattern().visit(this); // postprocessing: triplepattern in OPTIONAL clause if (!ignoreOptionals && query.isSelectType()) { for (Triple t : optionalTriplePattern) { if (!ListUtils.intersection(new ArrayList<>(VarUtils.getVars(t)), query.getProjectVars()).isEmpty()) { triplePattern.add(t); } } } return triplePattern; }
Query query = QueryFactory.create(queryString); query.isSelectType() && query.isQueryResultStar(); // of the form SELECT *? query.getDatasetDescription(); // FROM / FROM NAMED bits query.getQueryPattern(); // The meat of the query, the WHERE bit ...etc etc.. Op op = Algebra.compile(query); // Get the algebra for the query
/** Return a closable resultset for a {@link QueryExecution}. * The {@link QueryExecution} must be for a {@code SELECT} query. * @param queryExecution {@code QueryExecution} must be for a {@code SELECT} query. * @return ResultSetCloseable */ public static ResultSetCloseable closeableResultSet(QueryExecution queryExecution) { if ( queryExecution.getQuery() != null && ! queryExecution.getQuery().isSelectType() ) throw new IllegalArgumentException("Not an execution for a SELECT query"); return new ResultSetCloseable(queryExecution.execSelect(), queryExecution) ; }
public ValidationResult validate(Dataset input) { if (logger.isDebugEnabled()) { logger.debug("validating constraint of WonSparqlValidator '{}'", name); } if (constraint.isAskType()) { return validateAsk(input); } else if (constraint.isSelectType()) { return validateSelect(input); } return new ValidationResult(false, "Invalid constraint: " + constraint.toString()); }
private static QueryType getQueryType(final Query query) { if (query.isSelectType()) return QueryType.SELECT; if (query.isConstructType()) return QueryType.CONSTRUCT; if (query.isDescribeType()) return QueryType.DESCRIBE; if (query.isAskType()) return QueryType.ASK; return null; }
private static QueryType getQueryType(final Query query) { if (query.isSelectType()) return QueryType.SELECT; if (query.isConstructType()) return QueryType.CONSTRUCT; if (query.isDescribeType()) return QueryType.DESCRIBE; if (query.isAskType()) return QueryType.ASK; return null; }
private static QueryType getQueryType(final Query query) { if (query.isSelectType()) return QueryType.SELECT; if (query.isConstructType()) return QueryType.CONSTRUCT; if (query.isDescribeType()) return QueryType.DESCRIBE; if (query.isAskType()) return QueryType.ASK; return null; }
/** * Execute a SELECT query and process the ResultSet with the handler code. * @param query * @param resultSetAction */ @Override public default void queryResultSet(Query query, Consumer<ResultSet> resultSetAction) { if ( ! query.isSelectType() ) throw new JenaConnectionException("Query is not a SELECT query"); Txn.executeRead(this, ()->{ try ( QueryExecution qExec = query(query) ) { ResultSet rs = qExec.execSelect(); resultSetAction.accept(rs); } } ); }
static private String labelForQuery(Query q) { if ( q.isSelectType() ) return "SELECT" ; if ( q.isConstructType() ) return "CONSTRUCT" ; if ( q.isDescribeType() ) return "DESCRIBE" ; if ( q.isAskType() ) return "ASK" ; if ( q.isJsonType() ) return "JSON" ; return "<<unknown>>" ; }
@Override public ResultSet execSelect() { checkNotClosed(); if ( !query.isSelectType() ) throw new QueryExecException("Attempt to have ResultSet from a " + labelForQuery(query) + " query"); ResultSet rs = execResultSet(); return new ResultSetCheckCondition(rs, this); }
private void printQueryResults() { if (query.isSelectType()) printSelectQueryResuts(); else if (query.isConstructType()) printConstructQueryResults(); else if (query.isAskType()) printAskQueryResult(); }
/** * Execute a SELECT query and process the rows of the results with the handler code. * @param query * @param rowAction */ @Override public default void querySelect(Query query, Consumer<QuerySolution> rowAction) { if ( ! query.isSelectType() ) throw new JenaConnectionException("Query is not a SELECT query"); Txn.executeRead(this, ()->{ try ( QueryExecution qExec = query(query) ) { qExec.execSelect().forEachRemaining(rowAction); } } ); }
/** * Execute a SELECT query and process the rows of the results with the handler code. * @param query * @param rowAction */ @Override public default void querySelect(Query query, Consumer<QuerySolution> rowAction) { if ( ! query.isSelectType() ) throw new JenaConnectionException("Query is not a SELECT query"); Txn.executeRead(this, ()->{ try ( QueryExecution qExec = query(query) ) { qExec.execSelect().forEachRemaining(rowAction); } } ); }
@Override public void visitSelectResultForm(Query query1) { check("Not both SELECT queries", query2.isSelectType()) ; check("DISTINCT modifier", query1.isDistinct() == query2.isDistinct()) ; check("SELECT *", query1.isQueryResultStar() == query2.isQueryResultStar()) ; check("Result variables", query1.getProject(), query2.getProject() ) ; }