Beispiel #1
0
char *hgFindSpecSettingOrDefault(struct hgFindSpec *hfs, char *name,
				 char *defaultVal)
/* Return setting string, or defaultVal if none exists */
{
    char *val = hgFindSpecSetting(hfs, name);
    return (val == NULL ? defaultVal : val);
}
Beispiel #2
0
static void checkXrefQueryFormat(struct hgFindSpec *hfs)
/* Make sure xrefQuery looks right and jives with searchMethod. */
{
if (isNotEmpty(hfs->xrefQuery) &&
    !hgFindSpecSetting(hfs, "dontCheckXrefQueryFormat"))
    {
    if (! regexMatchNoCase(hfs->xrefQuery, xrefQueryFormatRegex))
	errAbort("hfsPolish: search %s: xrefQuery needs to be of the format "
		 "\"select field1,field2 from %%s where field2 like '%%s'\" "
		 "(for prefix, '%%s%%%%'; for exact, '%%%%%%s%%%%'), "
		 "but instead is this:\n%s",
		 hfs->searchName, hfs->xrefQuery);
    if (sameString(hfs->searchMethod, "fuzzy") &&
	!endsWith(hfs->xrefQuery, fuzzyTermFormat))
	errAbort("hfsPolish: search %s: searchMethod is fuzzy so xrefQuery "
		 "needs to end with %s.",
		 hfs->searchName, fuzzyTermFormat);
    else if (sameString(hfs->searchMethod, "prefix") &&
	     !regexMatchNoCase(hfs->xrefQuery, prefixTermFormatRegex))
	errAbort("hfsPolish: search %s: searchMethod is prefix so xrefQuery "
		 "needs to end with %s.",
		 hfs->searchName, prefixTermFormat);
	
    else if (sameString(hfs->searchMethod, "exact") &&
	     !regexMatchNoCase(hfs->xrefQuery, exactTermFormatRegex))
	errAbort("hfsPolish: search %s: searchMethod is exact so xrefQuery "
		 " needs to end with %s.",
		 hfs->searchName, exactTermFormat);
    }
}
Beispiel #3
0
char *hgFindSpecRequiredSetting(struct hgFindSpec *hfs, char *name)
/* Return setting string or squawk and die. */
{
char *ret = hgFindSpecSetting(hfs, name);
if (ret == NULL)
   errAbort("Missing required %s setting in %s (%s) search spec",
	    name, hfs->searchTable, hfs->searchName);
return ret;
}
static struct hgFindSpec * pruneRelease(struct hgFindSpec *hfsList)
/* Prune out alternate track entries for another release */
{
    /* Build up list that only includes things in this release.  Release
     * can be inherited from parents. */
    struct hgFindSpec *hfs;
    struct hgFindSpec *relList = NULL;
    struct hash *haveHash = hashNew(3);

    while ((hfs = slPopHead(&hfsList)) != NULL)
    {
        char *rel = hgFindSpecSetting(hfs, "release");
        unsigned hfsRelBits = buildReleaseBits(rel);

        if (hfsRelBits & releaseBit)
        {
            /* we want to include this track, check to see if we already have it */
            struct hashEl *hel;
            if ((hel = hashLookup(haveHash, hfs->searchName)) != NULL)
            {
                // TODO restore this warning to errAbort
                // This has been temporarily changed to a warning to avoid everybody being held up.
                char *one = (char *)hel->val;
                char *other = release;
                if (!one)
                    one = "none";
                if (!other)
                    other = "none";
                warn("ERROR: found two or more copies of %s: one with release %s, the other %s\n",
                     hfs->searchName, one, other);
            }
            else
            {
                hashAdd(haveHash, hfs->searchName, rel);
                hashRemove(hfs->settingsHash, "release");
                slAddHead(&relList, hfs);
            }
        }
        else
            verbose(3,"pruneRelease: removing '%s', release: '%s' != '%s'\n",
                    hfs->searchName, rel, release);
    }

    freeHash(&haveHash);
    return relList;
}