outline/queryByExample.js
function saveQuery (selection, qs) {
  // var qs = outline.qs // @@
  var q = new UI.rdf.Query()
  var n = selection.length
  var i, sel, st, tr
  for (i = 0; i < n; i++) {
    sel = selection[i]
    tr = sel.parentNode
    st = tr.AJAR_statement
    UI.log.debug('Statement ' + st)
    if (sel.getAttribute('class').indexOf('pred') >= 0) {
      UI.log.info('   We have a predicate')
      makeQueryRow(q, tr)
    }
    if (sel.getAttribute('class').indexOf('obj') >= 0) {
      UI.log.info('   We have an object')
      makeQueryRow(q, tr, true)
    }
  }
  qs.addQuery(q)

  function resetOutliner (pat) {
    var n = pat.statements.length
    var pattern, tr
    for (let i = 0; i < n; i++) {
      pattern = pat.statements[i]
      tr = pattern.tr
        // UI.log.debug('tr: ' + tr.AJAR_statement);
      if (typeof tr !== 'undefined') {
        tr.AJAR_pattern = null // TODO: is this == to whats in current version?
        tr.AJAR_variable = null
      }
    }
    for (let x in pat.optional) { resetOutliner(pat.optional[x]) }
  }
  resetOutliner(q.pat)
    // NextVariable=0;
  return q
}
function saveQuery (selection, qs) {
  // var qs = outline.qs // @@
  var q = new UI.rdf.Query()
  var n = selection.length
  var i, sel, st, tr
  for (i = 0; i < n; i++) {
    sel = selection[i]
    tr = sel.parentNode
    st = tr.AJAR_statement
    UI.log.debug('Statement ' + st)
    if (sel.getAttribute('class').indexOf('pred') >= 0) {
      UI.log.info('   We have a predicate')
      makeQueryRow(q, tr)
    }
    if (sel.getAttribute('class').indexOf('obj') >= 0) {
      UI.log.info('   We have an object')
      makeQueryRow(q, tr, true)
    }
  }
  qs.addQuery(q)

  function resetOutliner (pat) {
    var n = pat.statements.length
    var pattern, tr
    for (let i = 0; i < n; i++) {
      pattern = pat.statements[i]
      tr = pattern.tr
        // UI.log.debug('tr: ' + tr.AJAR_statement);
      if (typeof tr !== 'undefined') {
        tr.AJAR_pattern = null // TODO: is this == to whats in current version?
        tr.AJAR_variable = null
      }
    }
    for (let x in pat.optional) { resetOutliner(pat.optional[x]) }
  }
  resetOutliner(q.pat)
    // NextVariable=0;
  return q
}
makeQueryRow