4c396a03784396605a6d9e2d698a7a999ab65d24 braney Wed Nov 30 20:04:14 2011 -0800 fix problems with status field in hubStatus not reflecting the actual state of the hubPublic table. We're no longer using the status field (#5965) diff --git src/hg/hgHubConnect/hgHubConnect.c src/hg/hgHubConnect/hgHubConnect.c index b67b64f..55fc759 100644 --- src/hg/hgHubConnect/hgHubConnect.c +++ src/hg/hgHubConnect/hgHubConnect.c @@ -72,58 +72,61 @@ { if (hub == NULL) return; struct trackHub *thub = hub->trackHub; if (thub != NULL) { /* List of associated genomes. */ struct trackHubGenome *genomes = thub->genomeList; for(; genomes; genomes = genomes->next) hashStore(hash, genomes->name); } } -static void hgHubConnectUnlisted(struct hubConnectStatus *hubList) +static void hgHubConnectUnlisted(struct hubConnectStatus *hubList, + struct hash *publicHash) /* Put up the list of unlisted hubs and other controls for the page. */ +/* adds hubUrls to publicHash */ /* NOTE: Destroys hubList */ { // put out the top of our page printf("
" " " " " " " " "); // count up the number of unlisted hubs we currently have int unlistedHubCount = 0; struct hubConnectStatus *unlistedHubList = NULL; struct hubConnectStatus *hub, *nextHub; struct hash *assHash = newHash(5); for(hub = hubList; hub; hub = nextHub) { nextHub = hub->next; - if (isHubUnlisted(hub) ) + // if url is not in publicHash, it's unlisted */ + if (!((publicHash != NULL) && hashLookup(publicHash, hub->hubUrl))) { addGenomesToHash(hub, assHash); unlistedHubCount++; slAddHead(&unlistedHubList, hub); } } hubList = NULL; // hubList no longer valid struct hashCookie cookie = hashFirst(assHash); struct dyString *dy = newDyString(100); struct hashEl *hel; int numAssemblies = 0; while ((hel = hashNext(&cookie)) != NULL) { @@ -206,62 +209,66 @@ ourCellStart(); printf( "" , hub->id); ourCellEnd(); } printf("
" " " "" "
\n"); printf("
"); } -static boolean outputPublicTable(struct sqlConnection *conn, char *publicTable) +static struct hash *outputPublicTable(struct sqlConnection *conn, char *publicTable) /* Put up the list of public hubs and other controls for the page. */ { +struct hash *publicHash = NULL; char query[512]; safef(query, sizeof(query), "select hubUrl,shortLabel,longLabel,dbList from %s", publicTable); struct sqlResult *sr = sqlGetResult(conn, query); char **row; boolean gotAnyRows = FALSE; while ((row = sqlNextRow(sr)) != NULL) { char *url = row[0], *shortLabel = row[1], *longLabel = row[2], *dbList = row[3]; if (gotAnyRows) webPrintLinkTableNewRow(); else { /* output header */ printf("
\n"); printf(" " " " " " " " " " " " " " "\n"); // start first row printf(""); gotAnyRows = TRUE; + + // allocate the hash to store hubUrl's + publicHash = newHash(5); } char *errorMessage = NULL; // get an id for this hub unsigned id = hubFindOrAddUrlInStatusTable(database, cart, url, &errorMessage); if ((id != 0) && isEmpty(errorMessage)) { ourCellStart(); char hubName[32]; safef(hubName, sizeof(hubName), "%s%u", hgHubConnectHubVarPrefix, id); cartMakeCheckBox(cart, hubName, FALSE); ourCellEnd(); } @@ -278,55 +285,60 @@ ourCellEnd(); } else errAbort("cannot get id for hub with url %s\n", url); ourPrintCell(shortLabel); if (isEmpty(errorMessage)) ourPrintCell(longLabel); else printf("", errorMessage); ourPrintCell(removeLastComma(dbList)); ourPrintCell(url); + hashStore(publicHash, url); } sqlFreeResult(&sr); if (gotAnyRows) { printf("
DisplayHub NameDescriptionAssembliesURL
ERROR: %s " "Debug
\n"); printf("
"); } -return gotAnyRows; +return publicHash; } -void hgHubConnectPublic() +struct hash *hgHubConnectPublic() /* Put up the list of public hubs and other controls for the page. */ { +struct hash *retHash = NULL; struct sqlConnection *conn = hConnectCentral(); char *publicTable = cfgOptionEnvDefault("HGDB_HUB_PUBLIC_TABLE", "hubPublicTableName", defaultHubPublicTableName); -if (!(sqlTableExists(conn, publicTable) && outputPublicTable(conn, publicTable) )) +if (!(sqlTableExists(conn, publicTable) && + (retHash = outputPublicTable(conn, publicTable)) != NULL )) { printf("
\n"); printf("No Public Track Hubs for this genome assembly
"); printf("
"); } hDisconnectCentral(&conn); + +return retHash; } static void tryHubOpen(unsigned id) /* try to open hub, leaks trackHub structure */ { /* try opening this again to reset error */ struct sqlConnection *conn = hConnectCentral(); struct errCatch *errCatch = errCatchNew(); struct hubConnectStatus *hub = NULL; if (errCatchStart(errCatch)) hub = hubConnectStatusForId(conn, id); errCatchEnd(errCatch); if (errCatch->gotError) hubUpdateStatus( errCatch->message->string, NULL); else @@ -489,32 +501,32 @@ puts(""); // ... and now the main form if (cartVarExists(cart, hgHubConnectCgiDestUrl)) destUrl = cartOptionalString(cart, hgHubConnectCgiDestUrl); printf("
\n", destUrl); cartSaveSession(cart); // we have two tabs for the public and unlisted hubs printf("
" " "); -hgHubConnectPublic(); -hgHubConnectUnlisted(hubList); +struct hash *publicHash = hgHubConnectPublic(); +hgHubConnectUnlisted(hubList, publicHash); printf("
"); printf("
"); cgiMakeButton("Submit", "Load Selected Hubs"); char *emailAddress = cfgOptionDefault("hub.emailAddress","genome@soe.ucsc.edu"); printf("" "Contact %s to add a public hub." "\n", emailAddress,emailAddress); printf("
"); cgiMakeHiddenVar(hgHubConnectRemakeTrackHub, "on"); printf("\n"); puts("
");