本文整理了Java中org.apache.jena.query.Query.isAskType
方法的一些代码示例,展示了Query.isAskType
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.isAskType
方法的具体详情如下:
包路径:org.apache.jena.query.Query
类名称:Query
方法名:isAskType
暂无
代码示例来源:origin: at.researchstudio.sat/won-core
public WonSparqlValidator(Query constraint, String name) {
if (!constraint.isAskType() && !constraint.isSelectType()) {
throw new IllegalArgumentException("Wrong constraint type!");
}
this.constraint = constraint;
this.name = name;
}
代码示例来源:origin: at.researchstudio.sat/won-core
public WonSparqlValidator(Query constraint) {
if (!constraint.isAskType() && !constraint.isSelectType()) {
throw new IllegalArgumentException("Wrong constraint type!");
}
this.constraint = constraint;
}
代码示例来源:origin: apache/jena
@Override
public void visitAskResultForm(Query query1)
{
check("Not both ASK queries", query2.isAskType()) ;
}
代码示例来源:origin: vivo-project/Vitro
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;
}
}
代码示例来源:origin: at.researchstudio.sat/won-core
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());
}
代码示例来源:origin: com.github.galigator.openllet/openllet-jena
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;
}
代码示例来源:origin: Galigator/openllet
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;
}
代码示例来源:origin: Galigator/openllet
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;
}
代码示例来源:origin: apache/jena
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>>" ;
}
代码示例来源:origin: TopQuadrant/shacl
/**
* Constructs a new SHACLSPARQLARQFunction based on a given sh:ConstraintComponent
* and a given validator (which must be a value of sh:nodeValidator, sh:propertyValidator etc.
* @param component the constraint component (defining the sh:parameters)
* @param askValidator the sh:SPARQLAskValidator resource
*/
public SHACLSPARQLARQFunction(SHConstraintComponent component, Resource askValidator) {
super(null);
try {
queryString = JenaUtil.getStringProperty(askValidator, SH.ask);
arqQuery = ARQFactory.get().createQuery(SPARQLSubstitutions.withPrefixes(queryString, askValidator));
}
catch(Exception ex) {
throw new IllegalArgumentException("Validator " + askValidator + " does not define a valid body", ex);
}
if(!arqQuery.isAskType()) {
throw new ExprEvalException("Body must be ASK query");
}
paramNames.add("value");
addParameters(component);
paramNames.add("shapesGraph");
}
代码示例来源:origin: Galigator/openllet
private void printQueryResults()
{
if (query.isSelectType())
printSelectQueryResuts();
else
if (query.isConstructType())
printConstructQueryResults();
else
if (query.isAskType())
printAskQueryResult();
}
代码示例来源:origin: apache/jena
@Override
public boolean execAsk() {
checkNotClosed();
if ( !query.isAskType() )
throw new QueryExecException("Attempt to have boolean from a " + labelForQuery(query) + " query");
startQueryIterator();
boolean r;
try {
// Not has next because setting timeout1 which applies to getting
// the first result, not testing for it.
queryIterator.next();
r = true;
} catch (NoSuchElementException ex) { r = false; }
this.close();
return r;
}
代码示例来源:origin: TopQuadrant/shacl
/**
* Constructs a new SHACLSPARQLARQFunction based on a given sh:Function.
* The shaclFunction must be associated with the Model containing
* the triples of its definition.
* @param shaclFunction the SHACL function
*/
public SHACLSPARQLARQFunction(SHSPARQLFunction shaclFunction) {
super(shaclFunction);
try {
queryString = shaclFunction.getSPARQL();
arqQuery = ARQFactory.get().createQuery(SPARQLSubstitutions.withPrefixes(queryString, shaclFunction));
}
catch(Exception ex) {
throw new IllegalArgumentException("Function " + shaclFunction.getURI() + " does not define a valid body", ex);
}
if(!arqQuery.isAskType() && !arqQuery.isSelectType()) {
throw new ExprEvalException("Body must be ASK or SELECT query");
}
addParameters(shaclFunction);
}
代码示例来源:origin: ch.epfl.bluebrain.nexus.org.topbraid/shacl
/**
* Constructs a new SHACLSPARQLARQFunction based on a given sh:Function.
* The shaclFunction must be associated with the Model containing
* the triples of its definition.
* @param shaclFunction the SHACL function
*/
public SHACLSPARQLARQFunction(SHSPARQLFunction shaclFunction) {
super(shaclFunction);
try {
queryString = shaclFunction.getSPARQL();
arqQuery = ARQFactory.get().createQuery(SPARQLSubstitutions.withPrefixes(queryString, shaclFunction));
}
catch(Exception ex) {
throw new IllegalArgumentException("Function " + shaclFunction.getURI() + " does not define a valid body", ex);
}
if(!arqQuery.isAskType() && !arqQuery.isSelectType()) {
throw new ExprEvalException("Body must be ASK or SELECT query");
}
addParameters(shaclFunction);
}
代码示例来源:origin: ch.epfl.bluebrain.nexus.org.topbraid/shacl
@Override
public NodeValue executeBody(Dataset dataset, Model defaultModel, QuerySolution bindings) {
try( QueryExecution qexec = createQueryExecution(dataset, defaultModel, bindings) ) {
if(arqQuery.isAskType()) {
boolean result = qexec.execAsk();
return NodeValue.makeBoolean(result);
}
else {
ResultSet rs = qexec.execSelect();
if(rs.hasNext()) {
QuerySolution s = rs.nextSolution();
List<String> resultVars = rs.getResultVars();
String varName = resultVars.get(0);
RDFNode resultNode = s.get(varName);
if(resultNode != null) {
return NodeValue.makeNode(resultNode.asNode());
}
}
throw new ExprEvalException("Empty result set for SHACL function");
}
}
}
代码示例来源:origin: TopQuadrant/shacl
@Override
public NodeValue executeBody(Dataset dataset, Model defaultModel, QuerySolution bindings) {
try( QueryExecution qexec = createQueryExecution(dataset, defaultModel, bindings) ) {
if(arqQuery.isAskType()) {
boolean result = qexec.execAsk();
return NodeValue.makeBoolean(result);
}
else {
ResultSet rs = qexec.execSelect();
if(rs.hasNext()) {
QuerySolution s = rs.nextSolution();
List<String> resultVars = rs.getResultVars();
String varName = resultVars.get(0);
RDFNode resultNode = s.get(varName);
if(resultNode != null) {
return NodeValue.makeNode(resultNode.asNode());
}
}
throw new ExprEvalException("Empty result set for SHACL function");
}
}
}
代码示例来源:origin: tarql/tarql
private void processResults(TarqlQueryExecution ex) throws IOException {
if (testQuery && ex.getFirstQuery().getConstructTemplate() != null) {
IndentedWriter out = new IndentedWriter(System.out);
new FmtTemplate(out, new SerializationContext(ex.getFirstQuery())).format(ex.getFirstQuery().getConstructTemplate());
out.flush();
}
if (ex.getFirstQuery().isSelectType()) {
System.out.println(ResultSetFormatter.asText(ex.execSelect()));
} else if (ex.getFirstQuery().isAskType()) {
System.out.println(ResultSetFormatter.asText(ex.execSelect()));
} else if (ex.getFirstQuery().isConstructType()) {
resultTripleIterator = resultTripleIterator.andThen(ex.execTriples());
} else {
cmdError("Only query forms CONSTRUCT, SELECT and ASK are supported");
}
}
代码示例来源:origin: apache/jena
private QueryExecution createQueryExecution(Query query, String queryStringToSend) {
QueryExecution qExec = new QueryEngineHTTP(svcQuery, queryStringToSend, httpClient, httpContext);
QueryEngineHTTP qEngine = (QueryEngineHTTP)qExec;
// Set the accept header - use the most specific method.
if ( query != null ) {
if ( query.isSelectType() && acceptSelectResult != null )
qEngine.setAcceptHeader(acceptSelectResult);
if ( query.isAskType() && acceptAskResult != null )
qEngine.setAcceptHeader(acceptAskResult);
if ( ( query.isConstructType() || query.isDescribeType() ) && acceptGraph != null )
qEngine.setAcceptHeader(acceptGraph);
if ( query.isConstructQuad() )
qEngine.setDatasetContentType(acceptDataset);
}
// Use the general one.
if ( qEngine.getAcceptHeader() == null && acceptSparqlResults != null )
qEngine.setAcceptHeader(acceptSparqlResults);
// Make sure it was set somehow.
if ( qEngine.getAcceptHeader() == null )
throw new JenaConnectionException("No Accept header");
return qExec ;
}
代码示例来源:origin: org.apache.jena/jena-rdfconnection
private QueryExecution createQueryExecution(Query query, String queryStringToSend) {
QueryExecution qExec = new QueryEngineHTTP(svcQuery, queryStringToSend, httpClient, httpContext);
QueryEngineHTTP qEngine = (QueryEngineHTTP)qExec;
// Set the accept header - use the most specific method.
if ( query != null ) {
if ( query.isSelectType() && acceptSelectResult != null )
qEngine.setAcceptHeader(acceptSelectResult);
if ( query.isAskType() && acceptAskResult != null )
qEngine.setAcceptHeader(acceptAskResult);
if ( ( query.isConstructType() || query.isDescribeType() ) && acceptGraph != null )
qEngine.setAcceptHeader(acceptGraph);
if ( query.isConstructQuad() )
qEngine.setDatasetContentType(acceptDataset);
}
// Use the general one.
if ( qEngine.getAcceptHeader() == null && acceptSparqlResults != null )
qEngine.setAcceptHeader(acceptSparqlResults);
// Make sure it was set somehow.
if ( qEngine.getAcceptHeader() == null )
throw new JenaConnectionException("No Accept header");
return qExec ;
}
代码示例来源:origin: apache/jena
public static void executeQuery(Prologue prologue, QueryExecution queryExecution, ResultsFormat outputFormat) {
Query query = queryExecution.getQuery() ;
if ( prologue == null )
prologue = query.getPrologue() ;
if ( prologue == null )
prologue = dftPrologue ;
if ( query.isSelectType() )
doSelectQuery(prologue, queryExecution, outputFormat) ;
else if ( query.isDescribeType() )
doDescribeQuery(prologue, queryExecution, outputFormat) ;
else if ( query.isConstructQuad() )
// Before isConstructType.
doConstructQuadsQuery(prologue, queryExecution, outputFormat) ;
else if ( query.isConstructType() )
doConstructQuery(prologue, queryExecution, outputFormat) ;
else if ( query.isAskType() )
doAskQuery(prologue, queryExecution, outputFormat) ;
else if ( query.isJsonType() )
doJsonQuery(prologue, queryExecution, outputFormat) ;
else
throw new QueryException("Unrecognized query form");
}
内容来源于网络,如有侵权,请联系作者删除!