48fb236e9a07a49585fd1ed15f4aaff24dbcf8a2 max Thu Oct 26 13:15:57 2017 -0700 fixing dataVersion for hgTrackUi by libifying printDataVersion and expanding it to cover all possible track data version places that have accumulated over time. refs #20419 diff --git src/hg/lib/hui.c src/hg/lib/hui.c index f39ad0a..75611db 100644 --- src/hg/lib/hui.c +++ src/hg/lib/hui.c @@ -38,30 +38,32 @@ #include "errCatch.h" #include "samAlignment.h" #include "makeItemsItem.h" #include "bedDetail.h" #include "pgSnp.h" #include "memgfx.h" #include "trackHub.h" #include "gtexUi.h" #include "genbank.h" #include "htmlPage.h" #include "longRange.h" #include "tagRepo.h" #include "fieldedTable.h" #include "barChartUi.h" #include "customComposite.h" +#include "trackVersion.h" +#include "hubConnect.h" #define SMALLBUF 256 #define MAX_SUBGROUP 9 #define ADD_BUTTON_LABEL "add" #define CLEAR_BUTTON_LABEL "clear" #define JBUFSIZE 2048 #define DEF_BUTTON "<IMG id=\"btn_%s\" src=\"../images/%s\" alt=\"%s\">\n" #define DEF_BUTTON_JS "setCheckBoxesThatContain('%s',true,false,'%s','','%s');" \ "setCheckBoxesThatContain('%s',false,false,'%s','_defOff','%s');" #define DEFAULT_BUTTON(nameOrId,anc,beg,contains) \ printf(DEF_BUTTON,(anc),"defaults_sm.png","default"); \ safef(id, sizeof id, "btn_%s", (anc)); \ jsOnEventByIdF("click", id, DEF_BUTTON_JS,(nameOrId),(beg),(contains),(nameOrId),(beg),(contains)); @@ -8880,43 +8882,86 @@ if (nextColon) /* terminate suffixClone suffix */ *nextColon = '\0'; /* when next colon is present */ *suffix = '\0'; /* terminate itemClone prefix */ outs[7] = itemClone; outs[8] = suffixClone; /* small memory leak here for these cloned strings */ /* not important for a one-time operation in a CGI that will exit */ } else { outs[7] = idInUrl; /* otherwise, these are not expected */ outs[8] = idInUrl; /* to be used */ } // URL may now contain item boundaries ins[9] = "${"; ins[10] = "$}"; -if (cartOptionalString(cart, "o") && cartOptionalString(cart, "t")) +if (cart!=NULL && cartOptionalString(cart, "o") && cartOptionalString(cart, "t")) { char *itemBeg = cartString(cart, "o"); // unexpected commas? char *itemEnd = cartString(cart, "t"); outs[9] = itemBeg; outs[10] = itemEnd; } else // should never be but I am unwilling to bet the farm { outs[9] = startString; outs[10] = endString; } ins[11] = "$n"; outs[11] = scName; ins[12] = "$taxId"; outs[12] = taxId; uUrl = subMulti(url, ArraySize(ins), ins, outs); outs[0] = eItem; eUrl = subMulti(url, ArraySize(ins), ins, outs); freeDyString(&uUrl); freeMem(eItem); freeMem(scName); return eUrl->string; } +void printDataVersion(char *database, struct trackDb *tdb) +/* If this annotation has a dataVersion setting, print it. + * check hgFixed.trackVersion, meta data and trackDb 'dataVersion'. */ +{ +char *version = NULL; + +// try the hgFixed.trackVersion table +struct trackVersion *trackVersion = getTrackVersion(database, tdb->track); +// try trackVersion table with parent, for composites/superTracks +if(trackVersion == NULL && (tdb->parent!=NULL)) + trackVersion = getTrackVersion(database, tdb->parent->track); + +// try the metadata +if(trackVersion == NULL) + { + metadataForTable(database, tdb,NULL); + version = (char *)metadataFindValue(tdb, "dataVersion"); + } +else + version = trackVersion->version; + +// try trackDb itself, this automatically will go up the hierarchy +if (version == NULL) +{ + version = trackDbSetting(tdb, "dataVersion"); +} + +if (version == NULL) + return; + +// On the RR, dataVersion can also be the path to a local file, for otto tracks +if (!trackHubDatabase(database) && !isHubTrack(tdb->table) && startsWith("/", version)) + { + char *path = replaceInUrl((char *)version, "", NULL, database, "", 0, 0, tdb->track, FALSE); + struct lineFile* lf = lineFileOpen(path, TRUE); + if (lf) + version = lineFileReadAll(lf); + } + +if (version != NULL) + printf("<B>Data version:</B> %s <BR>\n", version); +} +