16ac161a7e0835ba943b8c33c21858b0d1938219 braney Thu Oct 6 15:02:49 2011 -0700 change the relationship between the trackHub structure and the hubConnectStatus structure to be hierarchical. This fixes #4920. We now *always* fetch the URL contents instead of trusting what's in the hubStatus table *unless* there's an error message in the hubStatus table. diff --git src/hg/hgHubConnect/hgHubConnect.c src/hg/hgHubConnect/hgHubConnect.c index 0a7e78f..9180bce 100644 --- src/hg/hgHubConnect/hgHubConnect.c +++ src/hg/hgHubConnect/hgHubConnect.c @@ -64,96 +64,102 @@ " " " " "" " " " "); // count up the number of unlisted hubs we currently have int count = 0; struct hubConnectStatus *hub, *hubList = hubConnectStatusListFromCartAll(cart); for(hub = hubList; hub; hub = hub->next) { - if (isHubUnlisted(hub) && hubHasDatabase(hub, database) ) + if (isHubUnlisted(hub) && ((hub->trackHub == NULL) || trackHubHasDatabase(hub->trackHub, database) )) count++; } if (count == 0) { // nothing to see here printf( "No Track Hubs for this genome assembly" ""); printf(""); return; } // time to output the big table. First the header printf( " " "Display " "Hub Name " "Description " "URL " "Disconnect " "\n"); // start first row printf(""); count = 0; for(hub = hubList; hub; hub = hub->next) { /* if the hub is public, then don't list it here */ - if (!(isHubUnlisted(hub) && hubHasDatabase(hub, database) )) + if (!(isHubUnlisted(hub) && ((hub->trackHub == NULL) || trackHubHasDatabase(hub->trackHub, database) ))) continue; if (count) webPrintLinkTableNewRow(); // ends last row and starts a new one count++; // if there's an error message, we don't let people select it if (isEmpty(hub->errorMessage)) { ourCellStart(); char hubName[32]; safef(hubName, sizeof(hubName), "%s%u", hgHubConnectHubVarPrefix, hub->id); cartMakeCheckBox(cart, hubName, FALSE); ourCellEnd(); } else { // give people a chance to clear the error ourCellStart(); printf( "" , hub->hubUrl); ourCellEnd(); } - ourPrintCell(hub->shortLabel); - if (isEmpty(hub->errorMessage)) - ourPrintCell(hub->longLabel); + if (hub->trackHub != NULL) + ourPrintCell(hub->trackHub->shortLabel); else + ourPrintCell(""); + + if (!isEmpty(hub->errorMessage)) printf("ERROR: %s " "Debug", hub->errorMessage); + else if (hub->trackHub != NULL) + ourPrintCell(hub->trackHub->longLabel); + else + ourPrintCell(""); ourPrintCell(hub->hubUrl); ourCellStart(); printf( "" , hub->id); ourCellEnd(); } printf("\n"); printf(""); @@ -252,42 +258,43 @@ else { printf("
\n"); printf("No Public Track Hubs for this genome assembly
"); } printf("
"); hDisconnectCentral(&conn); } 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 trackHub *tHub; +struct hubConnectStatus *hub; if (errCatchStart(errCatch)) - tHub = trackHubFromId(id); + hub = hubConnectStatusForId(conn, id); errCatchEnd(errCatch); if (errCatch->gotError) - hubSetErrorMessage( errCatch->message->string, id); + hubUpdateStatus( errCatch->message->string, NULL); else - hubSetErrorMessage(NULL, id); + hubUpdateStatus(NULL, hub); errCatchFree(&errCatch); -tHub = NULL; +hDisconnectCentral(&conn); } static void doResetHub(struct cart *theCart) { char *url = cartOptionalString(cart, hgHubDataText); if (url != NULL) { unsigned id = hubResetError(url); tryHubOpen(id); } else errAbort("must specify url in %s\n", hgHubDataText); } @@ -363,34 +370,31 @@ "the box in the list below. " "After import the hub will show up as a group of tracks with its own blue " "bar and label underneath the main browser graphic, and in the " "configure page. For more information, see the " "" "User's Guide.

\n" "

NOTE: Because Track Hubs are created and maintained by external sources," " UCSC cannot be held responsible for their content.

" ); printf("\n"); // figure out and print out genome name makeGenomePrint(); // check to see if we have any new hubs -unsigned newId = hubCheckForNew(database, cart); - -if (newId) - tryHubOpen(newId); +hubCheckForNew(database, cart); // here's a little form for the add new hub button printf("
\n", "../cgi-bin/hgHubConnect"); cgiMakeHiddenVar("hubUrl", ""); cgiMakeHiddenVar(hgHubConnectRemakeTrackHub, "on"); puts("
"); // this the form for the disconnect hub button printf("
\n", "../cgi-bin/hgHubConnect"); cgiMakeHiddenVar("hubId", ""); cgiMakeHiddenVar(hgHubDoDisconnect, "on"); cgiMakeHiddenVar(hgHubConnectRemakeTrackHub, "on"); puts("
"); // this the form for the reset hub button