b985d31ae01e1a4e3662d36f2b7e5f77cc131482
tdreszer
  Mon May 16 13:08:51 2011 -0700
User's should see 'None' and {empty} as the same thing.  Sortable tracks and sortable files lists will now show no value when term defined in cv as 'validate cv or None' and there is either no value or 'None'.
diff --git src/hg/lib/cv.c src/hg/lib/cv.c
index 0363138..0127b0f 100644
--- src/hg/lib/cv.c
+++ src/hg/lib/cv.c
@@ -58,39 +58,54 @@
     lab = "Yale-Weissman";
 
 char *ret = cloneString(lab);
 chopSuffixAt(ret, '(');
 return ret;
 }
 
 /*
 TBD
 char *cvLabDeNormalize(char *minimalTerm)
 // returns lab name with parenthesized trailing info, by lookup in cv.ra, and restores
 // other oddities caught by Normalize
 }
 */
 
+static char *cvFileRequested = NULL;
+
+void cvFileDeclare(char *filePath)
+// Declare an altername cv.ra file to use
+// (The cv.ra file is normally discovered based upon CGI/Tool and envirnment)
+{
+cvFileRequested = cloneString(filePath);
+}
 
 static char *cvFile()
 // return default location of cv.ra
 {
 static char filePath[PATH_LEN];
+if (cvFileRequested != NULL)
+    {
+    safecpy(filePath, sizeof(filePath), cvFileRequested);
+    }
+else
+    {
 char *root = hCgiRoot();
 if (root == NULL || *root == 0)
     root = "/usr/local/apache/cgi-bin/"; // Make this check out sandboxes?
 safef(filePath, sizeof(filePath), "%s/encode/%s", root,CV_FILE_NAME);
+    }
 if(!fileExists(filePath))
     errAbort("Error: can't locate %s; %s doesn't exist\n", CV_FILE_NAME, filePath);
 return filePath;
 }
 
 const struct hash *cvTermHash(char *term)
 // returns a hash of hashes of a term which should be defined in cv.ra
 // NOTE: in static memory: DO NOT FREE
 {
 static struct hash *cvHashOfHashOfHashes = NULL;
 if (sameString(term,CV_TERM_CELL))
     term = CV_UGLY_TERM_CELL_LINE;
 else if (sameString(term,CV_TERM_ANTIBODY))
     term = CV_UGLY_TERM_ANTIBODY;
 
@@ -253,15 +268,36 @@
 }
 
 boolean cvTermIsHidden(char *term)
 // returns TRUE if term is defined as hidden in cv.ra
 {
 struct hash *termTypeHash = (struct hash *)cvTermTypeHash();
 struct hash *termHash = hashFindVal(termTypeHash,term);
 if (termHash != NULL)
     {
     char *setting = hashFindVal(termHash,CV_TOT_HIDDEN);
     return cvHiddenIsTrue(setting);
     }
 return FALSE;
 }
 
+boolean cvTermIsEmpty(char *term,char *val)
+// returns TRUE if term has validation of "cv or None" and the val is None
+{
+if (val == NULL)
+    return TRUE; // Empty whether it is supposed to be or not
+
+struct hash *termTypeHash = (struct hash *)cvTermTypeHash();
+struct hash *termHash = hashFindVal(termTypeHash,term);
+if (termHash != NULL)
+    {
+    char *validationRule = hashFindVal(termHash,CV_VALIDATE);
+    if (validationRule != NULL)
+        {           // Currently only supporting special case for "None"
+        if (sameString(validationRule,CV_VALIDATE_CV_OR_NONE)
+        && sameString(val,MDB_VAL_ENCODE_EDV_NONE))
+            return TRUE;
+        }
+    }
+return FALSE;
+}
+