cf924d2aa402c655a84131bbcb689bfc3d5307aa
angie
  Fri Nov 20 16:21:13 2015 -0800
Data Integrator UI for adding related SQL tables and fields for SQL-based
tracks using all.joiner.  This is only the UI -- the implementation will be
in a subsequent commit.  Main changes:
- cartJson interface between hgIntegrator.c and hgIntegratorModel.js:
- new command getRelatedTables
- the getFields command used to expect a simple comma-sep list of tracks.
Now it expects a list of ';'-sep track blobs, each of which may include
multiple comma-sep tables (track plus related tables).
- UI state interface between hgIntegrator.jsx and hgIntegratorModel.js:
- fieldSelect now supports multiple tables per track
- js/react/hgIntegrator/hgIntegrator.jsx: new subsections of 'Choose fields...'
dialog (FieldSelect) for adding related tables and showing their available
fields w/checkboxes; corresponding new UI state and events.
- js/model/hgIntegrator/hgIntegratorModel.js:
- new handlers for UI events and cartJson data for related tables/fields
- hgIntegrator.c: new code to return information about what tables (if any)
are related to each selected track, and what fields are in selected related
tables.

Other changes:
- hgIntegratorModel.js:
- split monolithic handleCartVar into separate handlers
- add new 'hgi_uiChoices' cart var to remember things that may not pertain
to the current query, such as a user's related tables/fields selections
for a table that is not included in the current query.
- convert between hgi_querySpec and internal UI state representation
(querySpecUpdateUiChoices, toQuerySpecJS)
- cart.js: added uiChoices convenience functions, stringifying of cartSet val
- cartJson interface between hgIntegrator.c and hgIntegratorModel.js:
- new command getQueryState: bundle querySpec and uiChoices from the cart
since they need to be processed together
- UI state interface between hgIntegrator.jsx and hgIntegratorModel.js:
- split UI state's querySpec object into separate dataSources and
outFileOptions objects (no point in bundling those in the UI)

Thanks to Kate and Matt for helpful suggestions about the UI.

refs #15544

diff --git src/hg/lib/hui.c src/hg/lib/hui.c
index 8ccade1..6c0ca01 100644
--- src/hg/lib/hui.c
+++ src/hg/lib/hui.c
@@ -8378,59 +8378,36 @@
     }
 // TODO: standardize to a wig as
 //else if (tdbIsBigWig(tdb))
 //    asObj = asObjFrombigBed(conn,tdb);
 else if (tdbIsBam(tdb))
     asObj = bamAsObj();
 else if (tdbIsVcf(tdb))
     asObj = vcfAsObj();
 else if (startsWithWord("makeItems", tdb->type))
     asObj = makeItemsItemAsObj();
 else if (sameWord("bedDetail", tdb->type))
     asObj = bedDetailAsObj();
 else if (sameWord("pgSnp", tdb->type))
     asObj = pgSnpAsObj();
 else
-    {
-    if (sqlTableExists(conn, "tableDescriptions"))
-        {
-        char query[256];
-        char *asText = NULL;
-
-        // Try unsplit table first.
-        sqlSafef(query, sizeof(query),
-              "select autoSqlDef from tableDescriptions where tableName='%s'",tdb->table);
-        asText = sqlQuickString(conn, query);
-
-        // If no result try split table.
-        if (asText == NULL)
-            {
-            sqlSafef(query, sizeof(query),
-                  "select autoSqlDef from tableDescriptions where tableName='chrN_%s'",tdb->table);
-            asText = sqlQuickString(conn, query);
-            }
-
-        if (asText != NULL && asText[0] != 0)
-            asObj = asParseText(asText);
-        freez(&asText);
-        }
-    }
+    asObj = asFromTableDescriptions(conn, tdb->table);
 return asObj;
 }
 
 struct asObject *asForTdb(struct sqlConnection *conn, struct trackDb *tdb)
-// Get autoSQL description if any associated with table.
+// Get autoSQL description if any associated with table, ignoring errAborts if any.
 {
 struct errCatch *errCatch = errCatchNew();
 struct asObject *asObj = NULL;
 // Wrap some error catching around asForTdbOrDie.
 if (errCatchStart(errCatch))
     {
     asObj = asForTdbOrDie(conn, tdb);
     }
 errCatchEnd(errCatch);
 errCatchFree(&errCatch);
 return asObj;
 }
 
 #ifdef OLD /* This got moved to main library . */
 struct asColumn *asColumnFind(struct asObject *asObj, char *name)