Class AnnotationAgqlToSql


  • public class AnnotationAgqlToSql
    extends Object
    Converts AGQL expressions into SQL queries for matching graphs (transcripts).
    Author:
    Robert Fromont robert@fromont.net.nz
    • Constructor Detail

      • AnnotationAgqlToSql

        public AnnotationAgqlToSql()
        Default constructor.
      • AnnotationAgqlToSql

        public AnnotationAgqlToSql​(nzilbb.ag.Schema schema)
        Attribute constructor.
    • Method Detail

      • getSchema

        public nzilbb.ag.Schema getSchema()
        Getter for schema.
        Returns:
        Layer schema.
      • setSchema

        public AnnotationAgqlToSql setSchema​(nzilbb.ag.Schema schema)
        Setter for schema.
        Parameters:
        schema - Layer schema.
        Returns:
        this.
      • sqlFor

        public AnnotationAgqlToSql.Query sqlFor​(String expression,
                                                String sqlSelectClause,
                                                String userWhereClause,
                                                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 == 'ew_0_456'
        • layer.id == 'orthography' && /th[aeiou].+/.test(label)
        • layer.id == 'orthography' && first('participant').label == 'Robert' && first('utterances').start.offset == 12.345
        • graph.id == 'AdaAicheson-01.trs' && layer.id == 'orthography' && start.offset > 10.5
        • layer.id == 'utterances' && all('transcript').includes('ew_0_456')
        • previous.id == 'ew_0_456'
        Also currently supported are the legacy SQL-style expressions:
        • id = 'ew_0_456'
        • layer.id = 'orthography' AND label NOT MATCHES 'th[aeiou].*'
        • layer.id = 'orthography' AND first('participant').label = 'Robert' AND first('utterances').start.offset = 12.345
        • graph.id = 'AdaAicheson-01.trs' AND layer.id = 'orthography' AND start.offset > 10.5
        • layer.id = 'utterances' AND 'ew_0_456' IN all('transcript')
        • previous.id = 'ew_0_456'
        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.
        sqlLimitClause - The SQL LIMIT clause to append, or null for no LIMIT clause.
        Throws:
        nzilbb.ag.ql.AGQLException - If the expression is invalid.