d3e338b79532a1ba0415e2a65ef1e069ba84caf1 tdreszer Tue Jan 11 13:20:47 2011 -0800 Added suppport for file searching diff --git src/hg/inc/mdb.h src/hg/inc/mdb.h index 529fc10..e299c5f 100644 --- src/hg/inc/mdb.h +++ src/hg/inc/mdb.h @@ -262,69 +262,95 @@ // Finds the val associated with the var or retruns NULL boolean mdbObjContains(struct mdbObj *mdbObj, char *var, char *val); // Returns TRUE if object contains var, val or both boolean mdbByVarContains(struct mdbByVar *mdbByVar, char *val, char *obj); // Returns TRUE if var contains val, obj or both void mdbObjReorderVars(struct mdbObj *mdbObjs, char *vars,boolean back); // Reorders vars list based upon list of vars "cell antibody treatment". Send to front or back. void mdbObjsSortOnVars(struct mdbObj **mdbObjs, char *vars); // Sorts on var,val pairs vars lists: fwd case-sensitive. Assumes all objs' vars are in identical order. // Optionally give list of vars "cell antibody treatment" to sort on (bringing to front of vars lists). +void mdbObjsSortOnVarPairs(struct mdbObj **mdbObjs,struct slPair *varValPairs); +// Sorts on var,val pairs vars lists: fwd case-sensitive. Assumes all objs' vars are in identical order. +// This method will use mdbObjsSortOnVars() + void mdbObjRemoveVars(struct mdbObj *mdbObjs, char *vars); // Prunes list of vars for an object, freeing the memory. Doesn't touch DB. char *mdbRemoveCommonVar(struct mdbObj *mdbList, char *var); // Removes var from set of mdbObjs but only if all that hav it have a commmon val // Returns the val if removed, else NULL void mdbObjSwapVars(struct mdbObj *mdbObjs, char *vars,boolean deleteThis); // Replaces objs' vars with var=vap pairs provided, preparing for DB update. +struct mdbObj *mdbObjsFilter(struct mdbObj **pMdbObjs, char *var, char *val,boolean exclude); +// Filters mdb objects to only those that include/exclude vars. Optionally checks val too. Frees removed objects + +struct mdbObj *mdbObjsFilterTablesOrFiles(struct mdbObj **pMdbObjs,boolean table, boolean files); +// Filters mdb objects to only those that have associated tables or files. Returns removed non-table/file objects +// Note: Since table/file objects overlap, there are 3 possibilites: tables, files, table && files + +struct mdbObj *mdbObjIntersection(struct mdbObj **a, struct mdbObj *b); +// return duplicate objs from an intersection of two mdbObj lists. +// List b is untouched but pA will contain the resulting intersection + void mdbObjTransformToUpdate(struct mdbObj *mdbObjs, char *var, char *varType,char *val,boolean deleteThis); // Turns one or more mdbObjs into the stucture needed to add/update or delete. struct mdbObj *mdbObjClone(const struct mdbObj *mdbObj); // Clones a single mdbObj, including hash and maintining order +struct slName *mdbObjToSlName(struct mdbObj *mdbObjs); +// Creates slNames list of mdbObjs->obj. mdbObjs remains untouched + int mdbVarCmp(const void *va, const void *vb); /* Compare to sort on label. */ // --------------- Free at last ---------------- void mdbObjsFree(struct mdbObj **mdbObjsPtr); // Frees one or more metadata objects and any contained mdbVars. Will free any hashes as well. void mdbByVarsFree(struct mdbByVar **mdbByVarsPtr); // Frees one or more metadata vars and any contained vals and objs. Will free any hashes as well. // ----------------- CGI specific routines for use with tdb ----------------- const struct mdbObj *metadataForTable(char *db,struct trackDb *tdb,char *table); // Returns the metadata for a table. NEVER FREE THIS STRUCT! // This is the main routine for CGIs to access metadata const char *metadataFindValue(struct trackDb *tdb, char *var); // Finds the val associated with the var or retruns NULL #define MDB_VAL_STD_TRUNCATION 64 -struct slName *mdbObjSearch(struct sqlConnection *conn, char *var, char *val, char *op, int limit, boolean tables, boolean files); +struct mdbObj *mdbObjSearch(struct sqlConnection *conn, char *var, char *val, char *op, int limit); +// Search the metaDb table for objs by var and val. Can restrict by op "is", "like", "in" and accept (non-zero) limited string size +// Search is via mysql, so it's case-insensitive. Return is sorted on obj. + +struct mdbObj *mdbObjRepeatedSearch(struct sqlConnection *conn,struct slPair *varValPairs,boolean tables,boolean files); +// Search the metaDb table for objs by var,val pairs. Uses mdbCvSearchMethod() if available. +// This method will use mdbObjsQueryByVars() + +struct slName *mdbObjNameSearch(struct sqlConnection *conn, char *var, char *val, char *op, int limit, boolean tables, boolean files); // 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 tables, boolean files); // Search the metaDb table for vals by var and returns controlled vocabulary (cv) label // (if it exists) and val as a pair. Can impose (non-zero) limit on returned string size of name. // Return is case insensitive sorted on name (label or else val). 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