95a7a559f4f4d92725d85d3a2ce726fff7c7190d tdreszer Fri Feb 25 10:08:53 2011 -0800 Beginning to support mutiSelects for cv.ra searchables diff --git src/hg/lib/mdb.c src/hg/lib/mdb.c index 0f3f2f3..d1cc3af 100644 --- src/hg/lib/mdb.c +++ src/hg/lib/mdb.c @@ -2914,52 +2914,33 @@ struct mdbObj *mdbObjs = mdbObjsLoadFromMemory(&mdb,TRUE); return mdbObjs; } 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 slPair *onePair; struct dyString *dyTerms = dyStringNew(256); // Build list of terms as "var1=val1 var2=val2a,val2b,val2c var3=%val3%" for(onePair = varValPairs; onePair != NULL; onePair = onePair->next) { enum mdbCvSearchable searchBy = mdbCvSearchMethod(onePair->name); - // If select is by free text then like - if (searchBy == cvsSearchByMultiSelect) - { - // TO BE IMPLEMENTED - warn("mdb search by multi-select is not yet implemented."); - // The mdbVal[1] will hve to be filled cartOptionalSlNameList(cart,???) - struct slName *choices = (struct slName *)onePair->val; - if (slCount(choices) == 1) - dyStringPrintf(dyTerms,"%s=%s ",onePair->name,choices->name); - else if(choices != NULL) - { - // Then slNames will need to be assembled into a string in the form of a,b,c - dyStringPrintf(dyTerms,"%s=%s",onePair->name,choices->name); - struct slName *choice = choices->next; - for(;choice!=NULL;choice=choice->next) - dyStringPrintf(dyTerms,",%s",choice->name); - dyStringAppendC(dyTerms,' '); - } - } - else if (searchBy == cvsSearchBySingleSelect) + if (searchBy == cvsSearchBySingleSelect || searchBy == cvsSearchByMultiSelect) // multiSelect val will be filled with a comma delimited list dyStringPrintf(dyTerms,"%s=%s ",onePair->name,(char *)onePair->val); - else if (searchBy == cvsSearchByFreeText) + else if (searchBy == cvsSearchByFreeText) // If select is by free text then like dyStringPrintf(dyTerms,"%s=%%%s%% ",onePair->name,(char *)onePair->val); else if (searchBy == cvsSearchByDateRange || searchBy == cvsSearchByIntegerRange) { // TO BE IMPLEMENTED // Requires new mdbObjSearch API and more than one (char *)onePair->val warn("mdb search by date is not yet implemented."); } } // Be sure to include table of file in selections if (tables) dyStringAppend(dyTerms,"tableName=? "); if (files) dyStringAppend(dyTerms,"fileName=? "); // Build the mdbByVals struct and then select all mdbObjs in one query @@ -3196,30 +3177,32 @@ } enum mdbCvSearchable mdbCvSearchMethod(char *term) // returns whether the term is searchable // TODO: replace with mdbCvWhiteList() returning struct { // Get the list of term types from thew cv struct hash *termTypeHash = mdbCvTermTypeHash(); struct hash *termHash = hashFindVal(termTypeHash,term); if (termHash != NULL) { char *searchable = hashFindVal(termHash,"searchable"); if (searchable != NULL) { if (sameWord(searchable,"select")) return cvsSearchBySingleSelect; + if (sameWord(searchable,"multiSelect")) + return cvsSearchByMultiSelect; if (sameWord(searchable,"freeText")) return cvsSearchByFreeText; } } return cvsNotSearchable; } const char *cvLabel(char *term) // returns cv label if term found or else just term { // Get the list of term types from thew cv struct hash *termTypeHash = mdbCvTermTypeHash(); struct hash *termHash = hashFindVal(termTypeHash,term); if (termHash != NULL) {