Package nzilbb.labbcat.server.db
Class GraphAgqlToSql
- java.lang.Object
-
- nzilbb.labbcat.server.db.GraphAgqlToSql
-
public class GraphAgqlToSql extends Object
Converts AGQL expressions into SQL queries for matching graphs (transcripts).- Author:
- Robert Fromont robert@fromont.net.nz
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GraphAgqlToSql.Query
Encapsulates the results ofsqlFor(String,String,String,String,String)
including the SQL.
-
Constructor Summary
Constructors Constructor Description GraphAgqlToSql()
Default constructor.GraphAgqlToSql(nzilbb.ag.Schema schema)
Attribute constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description nzilbb.ag.Schema
getSchema()
Getter forschema
.GraphAgqlToSql
setSchema(nzilbb.ag.Schema schema)
Setter forschema
.GraphAgqlToSql.Query
sqlFor(String expression, String sqlSelectClause, String userWhereClause, String orderClause, String sqlLimitClause)
Transforms the given AGQL query into an SQL query.
-
-
-
Method Detail
-
getSchema
public nzilbb.ag.Schema getSchema()
Getter forschema
.- Returns:
- Layer schema.
-
setSchema
public GraphAgqlToSql setSchema(nzilbb.ag.Schema schema)
Setter forschema
.- Parameters:
schema
- Layer schema.- Returns:
- this.
-
sqlFor
public GraphAgqlToSql.Query sqlFor(String expression, String sqlSelectClause, String userWhereClause, String orderClause, String sqlLimitClause) throws nzilbb.ag.ql.AGQLException
Transforms the given AGQL query into an SQL query.- Parameters:
expression
- The graph-matching expression, for example:id MATCHES 'Ada.+'
'Robert' IN labels('participant')
first('corpus').label = 'CC'
first('episode').label = 'Ada Aitcheson'
first('transcript_scribe').label = 'Robert'
first('participant_languages').label = 'en'
first('noise').label = 'bell'
'en' IN labels('transcript_languages')
'en' IN labels('participant_languages')
'bell' IN labels('noise')
all('transcript_languages').length gt; 1
all('participant_languages').length gt; 1
all('transcript').length gt; 100
'Robert' IN annotators('transcript_rating')
id NOT MATCHES 'Ada.+' AND first('corpus').label = 'CC' AND 'Robert' IN labels('participant')
sqlSelectClause
- The SQL expression that is to go between SELECT and FROM.userWhereClause
- The expression to add to the WHERE clause to ensure the user doesn't get access to data to which they're not entitled, or null.orderClause
- A comma-separated list of AGQL expressions to determine the order of results; e.g. "first('corpus').label, id", or null.sqlLimitClause
- The SQL LIMIT clause to append, or null for no LIMIT clause.- Throws:
nzilbb.ag.ql.AGQLException
- If the expression is invalid. -
-