8a4758bc9826bad352cbce19052b01f28fb7171c hiram Fri Jul 5 11:25:55 2019 -0700 now allowing getData for any table in the database refs #23589 diff --git src/hg/hubApi/list.c src/hg/hubApi/list.c index 9708dde..78775a7 100644 --- src/hg/hubApi/list.c +++ src/hg/hubApi/list.c @@ -200,31 +200,31 @@ char **splitTableName, struct hTableInfo **tableInfo) /* determine what the 'chrom' name should be for this table (aka track) * this function could be used in getData() also TBD */ { static char *returnChrom = NULL; /* to be determined if this table name is used or is some other name */ char *sqlTableName = cloneString(table); /* 'track' name in trackDb usually refers to a SQL 'table' */ struct trackDb *tdb = obtainTdb(NULL, db); struct trackDb *thisTrack = findTrackDb(table,tdb); /* thisTrack can be NULL at this time, taken care of later */ -if (thisTrack && (tdbIsComposite(thisTrack) || tdbIsCompositeView(thisTrack))) +if (trackHasNoData(thisTrack)) apiErrAbort(err400, err400Msg, "container track '%s' does not contain data, use the children of this container for data access", table); if (thisTrack && ! isSupportedType(thisTrack->type)) apiErrAbort(err415, err415Msg, "track type '%s' for track=%s not supported at this time", thisTrack->type, table); /* however, the trackDb might have a specific table defined instead */ char *tableName = trackDbSetting(thisTrack, "table"); if (isNotEmpty(tableName)) { freeMem(sqlTableName); sqlTableName = cloneString(tableName); } /* this function knows how to deal with split chromosomes, the NULL * here for the chrom name means to use the first chrom name in chromInfo */ @@ -388,32 +388,32 @@ static void schemaJsonOutput(FILE *f, char *db, char *track) /* for given db and track, output the schema for the associated table */ { struct sqlConnection *conn = hAllocConnMaybe(db); if (NULL == conn) apiErrAbort(err400, err400Msg, "can not find 'genome=%s' for endpoint '/list/schema", db); struct trackDb *tdb = obtainTdb(NULL, db); struct trackDb *thisTrack = findTrackDb(track, tdb); if (NULL == thisTrack) /* OK to work with tables without trackDb definitions */ { if (! sqlTableExists(conn, track)) apiErrAbort(err400, err400Msg, "failed to find specified track=%s in genome=%s for endpoint '/list/schema'", track, db); } -/* in case of no trackDb, be wary of trying to use it */ -if (thisTrack && (tdbIsComposite(thisTrack) || tdbIsCompositeView(thisTrack))) + +if (trackHasNoData(thisTrack)) apiErrAbort(err400, err400Msg, "container track '%s' does not contain data, use the children of this container for data access", track); char *sqlTableName = cloneString(track); /* the trackDb might have a specific table defined instead */ char *tableName = trackDbSetting(thisTrack, "table"); if (isNotEmpty(tableName)) { freeMem(sqlTableName); sqlTableName = cloneString(tableName); } /* this function knows how to deal with split chromosomes, the NULL * here for the chrom name means to use the first chrom name in chromInfo */ struct hTableInfo *hti = hFindTableInfoWithConn(conn, NULL, sqlTableName); @@ -574,35 +574,34 @@ char query[2048]; sqlSafef(query, sizeof query, "select fileName from %s", tableName); struct sqlResult *sr = sqlGetResult(conn, query); char **row; while ((row = sqlNextRow(sr)) != NULL) { itemCount += bbiItemCount(hReplaceGbdb(row[0]), type, NULL); } sqlFreeResult(&sr); return itemCount; } static long long dataItemCount(char *db, struct trackDb *tdb) /* determine how many items are in this data set */ { -boolean isContainer = tdbIsComposite(tdb) || tdbIsCompositeView(tdb); -if (trackDbSetting(tdb, "container")) - isContainer = TRUE; long long itemCount = 0; -if (isContainer) /* containers have no data items */ +if (trackHasNoData(tdb)) /* container 'tracks' have no data items */ + return itemCount; +if (trackDbSetting(tdb, "tableBrowser")) /* private data */ return itemCount; if (sameWord("downloadsOnly", tdb->type)) return itemCount; char *bigDataUrl = hReplaceGbdb(trackDbSetting(tdb, "bigDataUrl")); if (isNotEmpty(bigDataUrl)) { char *indexFileOrUrl = hReplaceGbdb(trackDbSetting(tdb, "bigDataIndex")); itemCount = bbiItemCount(bigDataUrl, tdb->type, indexFileOrUrl); } else { /* prepare for getting table row count, find table name */ /* the trackDb might have a specific table defined */ char *tableName = trackDbSetting(tdb, "table");