Class GraphAgqlToSql


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

      • GraphAgqlToSql

        public GraphAgqlToSql()
        Default constructor.
      • GraphAgqlToSql

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

      • getSchema

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

        public GraphAgqlToSql setSchema​(nzilbb.ag.Schema schema)
        Setter for schema.
        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.