ce20d3f78f14e756e3a76e57160249fba33d1819 tdreszer Thu Mar 24 13:29:13 2011 -0700 Split out the cv routines into their own lib file, but have yet to rename any of the APIs diff --git src/hg/inc/mdb.h src/hg/inc/mdb.h index b1bfd8a..0f06e9d 100644 --- src/hg/inc/mdb.h +++ src/hg/inc/mdb.h @@ -1,24 +1,24 @@ /* mdb.h was originally generated by the autoSql program, which also * generated mdb.c and mdb.sql. This header links the database and * the RAM representation of objects. */ #ifndef MDB_H #define MDB_H #include "jksql.h" -#define MDB_NUM_COLS 4 +#define MDB_NUM_COLS 3 struct mdb /* This contains metadata for a table, file or other predeclared object type. */ { struct mdb *next; /* Next in singly linked list. */ char *obj; /* Object name or ID. */ char *var; /* Metadata variable name. */ char *val; /* Metadata value. */ }; void mdbStaticLoad(char **row, struct mdb *ret); /* Load a row from mdb table into ret. The contents of ret will * be replaced at the next call to this function. */ struct mdb *mdbLoadByQuery(struct sqlConnection *conn, char *query); @@ -76,60 +76,58 @@ void mdbOutput(struct mdb *el, FILE *f, char sep, char lastSep); /* Print out mdb. Separate fields with sep. Follow last field with lastSep. */ #define mdbTabOut(el,f) mdbOutput(el,f,'\t','\n'); /* Print out mdb as a line in a tab-separated file. */ #define mdbCommaOut(el,f) mdbOutput(el,f,',',','); /* Print out mdb as a comma separated list including final comma. */ void mdbJsonOutput(struct mdb *el, FILE *f); /* Print out mdb in JSON format. */ /* -------------------------------- End autoSql Generated Code -------------------------------- */ +#include "cv.h" #include "trackDb.h" #define MDB_DEFAULT_NAME "metaDb" // The three mdb tuples #define MDB_OBJ "obj" #define MDB_VAR "var" #define MDB_VAL "val" // OBJECT TYPES #define MDB_OBJ_TYPE "objType" #define MDB_OBJ_TYPE_TABLE "table" #define MDB_OBJ_TYPE_FILE "file" #define MDB_OBJ_TYPE_COMPOSITE "composite" // WELL KNOWN MDB VARS #define MDB_VAR_COMPOSITE MDB_OBJ_TYPE_COMPOSITE #define MDB_VAR_ANTIBODY "antibody" #define MDB_VAR_CELL "cell" #define MDB_VAR_LAB "lab" #define MDB_VAR_DATATYPE "dataType" #define MDB_VAR_TABLENAME "tableName" #define MDB_VAR_FILENAME "fileName" #define MDB_VAR_FILEINDEX "fileIndex" #define MDB_VAR_DCC_ACCESSION "dccAccession" #define MDB_VAR_PROJECT "project" -// SPECIAL MDB VALS -#define MDB_VAL_SURE_TO_NOT_MATCH "{nothing}" - // ENCODE Specific (at least for now) #define MDB_VAL_ENCODE_PROJECT "wgEncode" #define MDB_VAR_ENCODE_SUBID "subId" #define MDB_VAR_ENCODE_EDVS "expVars" #define MDB_VAR_ENCODE_EXP_ID "expId" #define MDB_VAL_ENCODE_EDV_NONE "None" // The mdb holds metadata primarily for tables. // Many types of objects could be supported, though currently files are the only other type. // It is easy to imagine using the current mdb to support hierarchical trees of metadata. // For example a composite type object called "myComposte" could have metadata that is valid for // all tables that have the var=composite val=myComposte metadata defined. // // There are 2 ways to look at the metadata: By Obj: obj->[var=val] and By Var: var->[val->[obj]]. @@ -426,78 +424,16 @@ // Search the metaDb table for objs by var and val. Can restrict by op "is" or "like" and accept (non-zero) limited string size // Search is via mysql, so it's case-insensitive. Return is sorted on obj. struct slName *mdbValSearch(struct sqlConnection *conn, char *var, int limit, boolean tables, boolean files); // Search the metaDb table for vals by var. Can impose (non-zero) limit on returned string size of val // Search is via mysql, so it's case-insensitive. Return is sorted on val. struct slPair *mdbValLabelSearch(struct sqlConnection *conn, char *var, int limit, boolean tags, boolean tables, boolean files); // Search the metaDb table for vals by var and returns val (as pair->name) and controlled vocabulary (cv) label // (if it exists) (as pair->val). Can impose (non-zero) limit on returned string size of name. // if requested, return cv tag instead of mdb val. If requested, limit to table objs or file objs // Return is case insensitive sorted on label (cv label or else val). #define mdbPairVal(pair) (pair)->name #define mdbPairLabel(pair) (pair)->val -// ------------ CONTROLLED VOCABULARY APIs -------------- - -#define CV_FILE_NAME "cv.ra" - -// CV Common settings -#define CV_TERM "term" -#define CV_TYPE "type" -#define CV_LABEL "label" -#define CV_TAG "tag" - -// Type of Terms defines -#define CV_TOT "typeOfTerm" -#define CV_TOT_HIDDEN "hidden" -#define CV_TOT_CV_DEFINED "cvDefined" - -// Validation Rules -#define CV_VALIDATE "validate" -#define CV_VALIDATE_CV "cv" -#define CV_VALIDATE_CV_OR_NONE "cv or None" -#define CV_VALIDATE_CV_OR_CONTROL "cv or control" -#define CV_VALIDATE_DATE "date" -#define CV_VALIDATE_EXISTS "exists" -#define CV_VALIDATE_FLOAT "float" -#define CV_VALIDATE_INT "integer" -#define CV_VALIDATE_LIST "list:" -#define CV_VALIDATE_REGEX "regex:" -#define CV_VALIDATE_NONE "none" - -// CV TERMS (NOTE: UGLY Terms in cv.ra are hidden inside cv.c APIS) -#define CV_TERM_CELL MDB_VAR_CELL -#define CV_TERM_ANTIBODY MDB_VAR_ANTIBODY -#define CV_TERM_CONTROL "control" - -const struct hash *mdbCvTermHash(char *term); -// returns a hash of hashes of a term which should be defined in cv.ra -// NOTE: in static memory: DO NOT FREE - -const struct hash *mdbCvTermTypeHash(); -// returns a hash of hashes of mdb and controlled vocabulary (cv) term types -// Those terms should contain label,descrition,searchable,cvDefined,hidden -// NOTE: in static memory: DO NOT FREE - -struct slPair *mdbCvWhiteList(boolean searchTracks, boolean cvLinks); -// returns the official mdb/controlled vocabulary terms that have been whitelisted for certain uses. - -enum mdbCvSearchable -// metadata Variavble are only certain declared types - { - cvsNotSearchable =0, // Txt is default - cvsSearchByMultiSelect =1, // Search by drop down multi-select of supplied list (NOT YET IMPLEMENTED) - cvsSearchBySingleSelect =2, // Search by drop down single-select of supplied list - cvsSearchByFreeText =3, // Search by free text field (NOT YET IMPLEMENTED) - cvsSearchByDateRange =4, // Search by discovered date range (NOT YET IMPLEMENTED) - cvsSearchByIntegerRange =5 // Search by discovered integer range (NOT YET IMPLEMENTED) - }; - -enum mdbCvSearchable mdbCvSearchMethod(char *term); -// returns whether the term is searchable // TODO: replace with mdbCvWhiteList() returning struct - -const char *cvLabel(char *term); -// returns cv label if term found or else just term #endif /* MDB_H */ -