\n",
hub->errorMessage);
else if (hub->trackHub != NULL)
ourPrintCell(hub->trackHub->longLabel);
else
ourPrintCell("");
if (hub->trackHub != NULL)
printGenomes(hub->trackHub, count);
else
@@ -261,56 +283,114 @@
{
char query[1024];
sqlSafef(query, sizeof(query), "select hubUrl from %s where hubUrl not in (select hubUrl from %s)\n", publicTable, statusTable);
struct sqlResult *sr = sqlGetResult(conn, query);
char **row;
while ((row = sqlNextRow(sr)) != NULL)
{
char *errorMessage = NULL;
char *url = row[0];
// add this url to the hubStatus table
hubFindOrAddUrlInStatusTable(database, cart, url, &errorMessage);
}
}
+struct hash *getUrlSearchHash(char *trixFile, char *hubSearchTerms)
+/* find hubs that match search term in trixFile */
+{
+struct hash *urlSearchHash = newHash(5);
+struct trix *trix = trixOpen(trixFile);
+int trixWordCount = chopString(hubSearchTerms, " ", NULL, 0);
+char *trixWords[trixWordCount];
+trixWordCount = chopString(hubSearchTerms, " ", trixWords, trixWordCount);
+
+struct trixSearchResult *tsList = trixSearch(trix, trixWordCount, trixWords, TRUE);
+for ( ; tsList != NULL; tsList = tsList->next)
+ hashStore(urlSearchHash, tsList->itemId);
+
+return urlSearchHash;
+}
+
static struct hash *outputPublicTable(struct sqlConnection *conn, char *publicTable, char *statusTable)
/* Put up the list of public hubs and other controls for the page. */
{
+char *trixFile = cfgOptionEnvDefault("HUBSEARCHTRIXFILE", "hubSearchTrixFile", "/gbdb/hubs/public.ix");
+char *hubSearchTerms = cartOptionalString(cart, hgHubSearchTerms);
+boolean haveTrixFile = fileExists(trixFile);
+struct hash *urlSearchHash = NULL;
+
+if (haveTrixFile && !isEmpty(hubSearchTerms))
+ urlSearchHash = getUrlSearchHash(trixFile, hubSearchTerms);
+
addPublicHubsToHubStatus(conn, publicTable, statusTable);
struct hash *publicHash = NULL;
char query[512];
+bool hasDescription = sqlColumnExists(conn, publicTable, "descriptionUrl");
+
+if (hasDescription)
+ sqlSafef(query, sizeof(query), "select p.hubUrl,p.shortLabel,p.longLabel,p.dbList,s.errorMessage,s.id,p.descriptionUrl from %s p,%s s where p.hubUrl = s.hubUrl",
+ publicTable, statusTable);
+else
sqlSafef(query, sizeof(query), "select p.hubUrl,p.shortLabel,p.longLabel,p.dbList,s.errorMessage,s.id from %s p,%s s where p.hubUrl = s.hubUrl",
publicTable, statusTable);
+
struct sqlResult *sr = sqlGetResult(conn, query);
char **row;
int count = 0;
+if (!isEmpty(hubSearchTerms))
+ {
+ printf(" List restricted by search terms : %s\n", hubSearchTerms);
+ puts("\n");
+ printf(" \n");
+ }
+
+if (haveTrixFile)
+ {
+ puts(" \n"
+ "\n");
+ }
+
boolean gotAnyRows = FALSE;
while ((row = sqlNextRow(sr)) != NULL)
{
++count;
char *url = row[0], *shortLabel = row[1], *longLabel = row[2],
- *dbList = row[3], *errorMessage = row[4];
+ *dbList = row[3], *errorMessage = row[4], *descriptionUrl = row[6];
int id = atoi(row[5]);
+
+ if ((urlSearchHash != NULL) && (hashLookup(urlSearchHash, url) == NULL))
+ continue;
+
if (gotAnyRows)
webPrintLinkTableNewRow();
else
{
/* output header */
printf("
\n");
+
printf("
"
"
"
"
Display
"
"
Hub Name
"
"
Description
"
"
Assemblies
"
"
URL
"
"
\n");
// start first row
printf("
");
gotAnyRows = TRUE;
// allocate the hash to store hubUrl's
publicHash = newHash(5);
@@ -327,30 +407,37 @@
else if (!isEmpty(errorMessage))
{
// give user a chance to clear the error
ourCellStart();
printf(
""
, url);
ourCellEnd();
}
else
errAbort("cannot get id for hub with url %s\n", url);
+ if (hasDescription && !isEmpty(descriptionUrl))
+ {
+ printf("\n", descriptionUrl);
+ ourPrintCellLink(shortLabel, descriptionUrl);
+ puts("");
+ }
+ else
ourPrintCell(shortLabel);
if (isEmpty(errorMessage))
ourPrintCell(longLabel);
else
printf("
",
errorMessage);
printGenomeList(slNameListFromComma(dbList), count); // Leaking a bit of memory
ourPrintCell(url);
hashStore(publicHash, url);
}
sqlFreeResult(&sr);
@@ -364,31 +451,31 @@
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",
hubPublicTableConfVariable, defaultHubPublicTableName);
char *statusTable = cfgOptionEnvDefault("HGDB_HUB_STATUS_TABLE",
hubStatusTableConfVariable, defaultHubStatusTableName);
if (!(sqlTableExists(conn, publicTable) &&
(retHash = outputPublicTable(conn, publicTable,statusTable)) != NULL ))
{
printf("
\n");
- printf("No Public Track Hubs for this genome assembly ");
+ printf("No Public Track Hubs ");
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))
@@ -531,44 +618,49 @@
// check to see if we have any new hubs
hubCheckForNew(cart);
// grab all the hubs that are listed in the cart
struct hubConnectStatus *hubList = hubConnectStatusListFromCartAll(cart);
checkTrackDbs(hubList);
// here's a little form for the add new hub button
printf("");
-// this the form for the disconnect hub button
+// this is the form for the disconnect hub button
printf("");
-// this the form for the reset hub button
+// this is the form for the reset hub button
printf("");
+// this is the form for the search hub button
+printf("");
// ... and now the main form
if (cartVarExists(cart, hgHubConnectCgiDestUrl))
destUrl = cartOptionalString(cart, hgHubConnectCgiDestUrl);
printf("