2d30d99f5f6d3d6532166a0c70c89d38e6053fb1 braney Fri Apr 5 16:57:02 2024 -0700 ongoing work on quickLift diff --git src/hg/lib/exportedDataHubs.c src/hg/lib/exportedDataHubs.c index 2e735b6..a5c92b9 100644 --- src/hg/lib/exportedDataHubs.c +++ src/hg/lib/exportedDataHubs.c @@ -1,23 +1,25 @@ /* exportedDataHubs.c was originally generated by the autoSql program, which also * generated exportedDataHubs.h and exportedDataHubs.sql. This module links the database and * the RAM representation of objects. */ #include "common.h" #include "linefile.h" #include "dystring.h" #include "jksql.h" +#include "hdb.h" +#include "hgConfig.h" #include "exportedDataHubs.h" char *exportedDataHubsCommaSepFieldNames = "id,db,label,description,path"; void exportedDataHubsStaticLoad(char **row, struct exportedDataHubs *ret) /* Load a row from exportedDataHubs table into ret. The contents of ret will * be replaced at the next call to this function. */ { ret->id = sqlUnsigned(row[0]); ret->db = row[1]; ret->label = row[2]; ret->description = row[3]; @@ -133,15 +135,49 @@ fprintf(f, "%s", el->label); if (sep == ',') fputc('"',f); fputc(sep,f); if (sep == ',') fputc('"',f); fprintf(f, "%s", el->description); if (sep == ',') fputc('"',f); fputc(sep,f); if (sep == ',') fputc('"',f); fprintf(f, "%s", el->path); if (sep == ',') fputc('"',f); fputc(lastSep,f); } /* -------------------------------- End autoSql Generated Code -------------------------------- */ +unsigned registerExportedDataHub(char *db, char *hubUrl) +/* Add a hub to the exportedDataHubs table. */ +{ +unsigned ret = 0; +struct sqlConnection *conn = hConnectCentral(); +char query[2048]; +sqlSafef(query, sizeof(query), "select id from exportedDataHubs where db='%s' and path='%s'", db, hubUrl); +char *id = sqlQuickString(conn, query); + +if (id) + ret = atoi(id); +else + { + sqlSafef(query, sizeof(query), "insert into exportedDataHubs values(0, '%s', 'Private','Private Label', '%s')", db, hubUrl); + sqlUpdate(conn, query); + + // now get the auto-increment id + sqlSafef(query, sizeof(query), "select id from exportedDataHubs where db='%s' and path='%s'", db, hubUrl); + id = sqlQuickString(conn, query); + if (id) + ret = atoi(id); + } + +hDisconnectCentral(&conn); + +return ret; +} + +boolean exportedDataHubsEnabled() +/* Return TRUE if feature is available */ +{ +char *cfgEnabled = cfgOption("browser.exportedDataHubs"); +return cfgEnabled && (sameString(cfgEnabled, "on") || sameString(cfgEnabled, "true")) ; +}