home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / samples / ioc / lancelot / ldbqry.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  44.5 KB  |  1,523 lines

  1. /******************************************************************************
  2. * .FILE:         ldbqry.cpp                                                   *
  3. *                                                                             *
  4. * .DESCRIPTION:  Lancelot Sample Program:              Class Implementation   *
  5. *                                                                             *
  6. * .CLASSES:      ADate                                                        *
  7. *                QueryEmpl                                                    *
  8. *                QueryGenl                                                    *
  9. *                QueryMgrs                                                    *
  10. *                QueryAcct                                                    *
  11. *                QuerySkill                                                   *
  12. *                QueryBadge                                                   *
  13. *                QueryStatus                                                  *
  14. *                QueryQry                                                     *
  15. *                QueryIntersection                                            *
  16. *                                                                             *
  17. * .COPYRIGHT:                                                                 *
  18. *                                                                             *
  19. * .DISCLAIMER:                                                                *
  20. *                                                                             *
  21. * .NOTE: WE RECOMMEND USING A FIXED SPACE FONT TO LOOK AT THE SOURCE          *
  22. *                                                                             *
  23. ******************************************************************************/
  24.  
  25. #ifndef _IBASE_                         //Make sure ibase.hpp is included
  26.   #include <ibase.hpp>                  //  since that is where IC_<environ>
  27. #endif                                  //  is defined.
  28. #include <idate.hpp>
  29. #include <istring.hpp>
  30. #include "ldbqry.hpp"
  31.  
  32. // -------------------------------------------------------------------------
  33. // ADate Class
  34. // -------------------------------------------------------------------------
  35. ADate :: ADate(const IString theDate)
  36. {
  37.    extractDate(theDate);
  38. };
  39.  
  40. // -------------------------------------------------------------------------
  41. // ADate Class destructor
  42. // -------------------------------------------------------------------------
  43. ADate :: ~ADate()
  44. {
  45.  
  46. };
  47.  
  48. // -------------------------------------------------------------------------
  49. // ADate Class setDate
  50. // -------------------------------------------------------------------------
  51. ADate& ADate :: setDate(const IString theDate)
  52. {
  53.    extractDate(theDate);
  54.    return *this;
  55. };
  56.  
  57. // -------------------------------------------------------------------------
  58. // ADate Class extractDate
  59. // -------------------------------------------------------------------------
  60. ADate& ADate :: extractDate(const IString theDate)
  61. {
  62.    unsigned int ix, iy , yr , d1, d2 ;
  63.    /// a valid date is passed in
  64.  
  65.    // assume mm dd yr
  66.  
  67.    if (theDate.subString(1,2).isDigits() ) {
  68.       d1  = 4 ;
  69.       ix = theDate.subString(1,2).asInt();
  70.    }
  71.    else {
  72.       ix = theDate.subString(0,1).asInt();
  73.       d1 = 3;
  74.    }
  75.  
  76.    if (theDate.subString(d1,2).isDigits() ) {
  77.       iy = theDate.subString(d1,2).asInt();
  78.       d2 = 3 ;
  79.    }
  80.    else {
  81.       iy = theDate.subString(d1,1).asInt();
  82.       d2 = 2;
  83.  
  84.    }
  85.  
  86.    if (theDate.subString(d1+d2,2).isDigits() )
  87.       yr = theDate.subString(d1+d2,2).asInt();
  88.    else
  89.       yr = theDate.subString(d1+d2,1).asInt();
  90.  
  91.  
  92.    pDate = new IDate((Month)ix, iy, yr) ;
  93.    return *this;
  94.  
  95. };
  96.  
  97. // -------------------------------------------------------------------------
  98. // QueryEmpl Class
  99. // -------------------------------------------------------------------------
  100. QueryEmpl :: QueryEmpl ()
  101.            : itemsCur(items)
  102. {
  103.    get(); // fill bag
  104. };
  105.  
  106. // -------------------------------------------------------------------------
  107. // QueryEmpl Class destructor
  108. // -------------------------------------------------------------------------
  109. QueryEmpl :: ~QueryEmpl()
  110. {
  111.   emptyBagId();
  112. };
  113.  
  114.  
  115. // -------------------------------------------------------------------------
  116. // QueryEmpl Class get() - get the employee database
  117. // -------------------------------------------------------------------------
  118. QueryEmpl :: get ()
  119. {
  120.    IString
  121.       id;
  122.    try
  123.    {
  124.       IProfile emplIni = IProfile("lempl.ini");
  125.  
  126.       IProfile::Cursor IniCursor(emplIni);
  127.       for (IniCursor.setToFirst();
  128.            IniCursor.isValid();
  129.            IniCursor.setToNext() )
  130.       {
  131.          id = emplIni.applicationOrKeyAt(IniCursor);
  132.          putId(id) ;
  133.       }
  134.    }
  135.    catch(...)
  136.    {}
  137.  
  138.    return true;
  139. };
  140.  
  141.  
  142. // -------------------------------------------------------------------------
  143. // QueryEmpl Class getId() - get the employee number
  144. // -------------------------------------------------------------------------
  145. IBase :: Boolean QueryEmpl :: getId( IString& item1)
  146. {
  147.  
  148.    if (false == itemsCur.isValid())
  149.       return false;  // empty
  150.  
  151.    Entry name = itemsCur.element().item1();
  152.  
  153.    items.locateElementWithKey(name, itemsCur);
  154.  
  155.    item1 =  itemsCur.element().item1().text();
  156.  
  157.    return true;
  158.  
  159. }; //getId
  160.  
  161.  
  162.  
  163. // -------------------------------------------------------------------------
  164. // QueryEmpl Class putId() - add an id to the list
  165. // -------------------------------------------------------------------------
  166. IBase :: Boolean QueryEmpl :: putId( const IString& item1)
  167. {
  168.    items.add(Item(item1));
  169.  
  170.    return true;
  171.  
  172. };    // putId
  173.  
  174.  
  175. // -------------------------------------------------------------------------
  176. // QueryEmpl Class emptyBagId() - empty the bag of ids
  177. // -------------------------------------------------------------------------
  178. IBase :: Boolean  QueryEmpl :: emptyBagId()  {
  179.  items.removeAll();
  180.  itemsCur.invalidate();
  181.  return (true);
  182. };
  183.  
  184.  
  185. // -------------------------------------------------------------------------
  186. // QueryEmpl Class deleteCurrentId()
  187. // -------------------------------------------------------------------------
  188. QueryEmpl& QueryEmpl ::  deleteCurrentId()
  189. {
  190.     if (itemsCur.isValid()) {
  191.        items.removeAt(itemsCur);
  192.     }
  193.     return *this;
  194. };
  195.  
  196. // -------------------------------------------------------------------------
  197. // QueryInfo Class - QueryInfo
  198. // -------------------------------------------------------------------------
  199. QueryInfo :: QueryInfo(const char * iniFile)
  200.              : idList(),                          // get the current employees
  201.                matchCur(matchIds),
  202.                searchCur(searchItems),
  203.                theDB(iniFile)
  204. {
  205.    searchCur.invalidate();
  206.    matchCur.invalidate();
  207.  
  208. };
  209.  
  210.  
  211. // -------------------------------------------------------------------------
  212. // QueryInfo Class :: ~QueryInfo -
  213. // -------------------------------------------------------------------------
  214. QueryInfo :: ~QueryInfo ()
  215. {
  216.  emptyBagSearchItems();
  217.  emptyBagMatchIds();
  218.  searchCur.invalidate();
  219.  matchCur.invalidate();
  220.  
  221. };
  222.  
  223.  
  224. // -------------------------------------------------------------------------
  225. // QueryInfo Class :: isDbempty() - is the DB(ini) empty
  226. // -------------------------------------------------------------------------
  227. IBase :: Boolean QueryInfo :: isDBempty()
  228. {
  229.    Boolean  retCode;
  230.  
  231.    if (theDB.length() == 0)
  232.       return true;
  233.  
  234.    IProfile *p = new IProfile(theDB);
  235.  
  236.    if (p->numberOfApplications() == 0)
  237.         retCode = true;
  238.    else
  239.      retCode = false;
  240.  
  241.    delete p;
  242.    return retCode;
  243. };
  244.  
  245.  
  246.  
  247. // -------------------------------------------------------------------------
  248. // QueryInfo Class :: getSearchItem() - get a item to search on, has a range
  249. // -------------------------------------------------------------------------
  250. IBase :: Boolean QueryInfo :: getSearchItem( IString& field
  251.                                             , IString& data
  252.                                             , IString& range)
  253. {
  254.    Boolean retCode=false;
  255.    if (searchCur.isValid()) {
  256.       retCode = true;
  257.  
  258.       field = searchCur.element().item1().text();
  259.       data  = searchCur.element().item2().text();
  260.       range = searchCur.element().item3().text();
  261.  
  262.    }
  263.    else retCode = false;
  264.  
  265.    return retCode;
  266.  
  267. };
  268.  
  269. // -------------------------------------------------------------------------
  270. // QueryInfo Class :: getSearchItem() - get a item to search on
  271. // -------------------------------------------------------------------------
  272. IBase :: Boolean QueryInfo :: getSearchItem( IString& field,
  273.                                              IString& data)
  274. {
  275.    Boolean retCode=false;
  276.    if (searchCur.isValid()) {
  277.       retCode = true;
  278.  
  279.       field = searchCur.element().item1().text();
  280.       data  = searchCur.element().item2().text();
  281.  
  282.    }
  283.    else retCode = false;
  284.  
  285.    return retCode;
  286.  
  287. };
  288.  
  289.  
  290. // -------------------------------------------------------------------------
  291. // QueryInfo Class :: emptyBagSearchItems() empty the search items bag
  292. // -------------------------------------------------------------------------
  293. QueryInfo& QueryInfo ::emptyBagSearchItems()
  294. {
  295.    if (searchCur.isValid()) {
  296.       searchItems.removeAll();
  297.       searchCur.invalidate();
  298.    }
  299.    return *this;
  300.  
  301. };
  302.  
  303.  
  304. // -------------------------------------------------------------------------
  305. // QueryInfo Class :: addSearchItem() - add an item to search
  306. // -------------------------------------------------------------------------
  307.  
  308. QueryInfo& QueryInfo ::addSearchItem(const IString& field
  309.                               , const IString& data
  310.                               , const IString& range)
  311. {
  312.   searchItems.add(Item(field, data, range ));
  313.   return *this;
  314. };
  315.  
  316.  
  317. // -------------------------------------------------------------------------
  318. // QueryInfo Class :: getMatchId() - get an id that matched the query
  319. // -------------------------------------------------------------------------
  320. IBase :: Boolean  QueryInfo :: getMatchId(IString& theID )
  321. {
  322.  
  323.    Boolean retCode=false;
  324.    if (matchCur.isValid()) {
  325.       retCode = true;
  326.       theID = matchCur.element().asString();
  327.    }
  328.    else retCode = false;
  329.  
  330.    return retCode;
  331. };
  332.  
  333.  
  334. // -------------------------------------------------------------------------
  335. // QueryInfo Class :: emptyBagMatchIds() - initialize the bag of match ids
  336. // -------------------------------------------------------------------------
  337. QueryInfo& QueryInfo :: emptyBagMatchIds()
  338. {
  339.    if (matchCur.isValid()) {
  340.       matchIds.removeAll();
  341.       matchCur.invalidate();
  342.    }
  343.    return *this;
  344. };
  345.  
  346.  
  347. // -------------------------------------------------------------------------
  348. // QueryInfo Class :: addMatchId() - add a match id
  349. // -------------------------------------------------------------------------
  350. QueryInfo& QueryInfo ::addMatchId(const IString& anId)
  351. {
  352.   matchIds.add(anId );
  353.   return *this;
  354. };
  355.  
  356.  
  357.  
  358. // -------------------------------------------------------------------------
  359. // QueryInfo Class :: inRange() - match check having a range
  360. // -------------------------------------------------------------------------
  361. IBase :: Boolean QueryInfo :: inRange(const IString &c1
  362.                                      ,const IString &c2
  363.                                      ,const IString &range)
  364. {
  365.  
  366.    if (c2.length() == 0)
  367.       return false;
  368.  
  369.     IString matchItem, compareItem;
  370.  
  371.     matchItem   = chopOff(c1);
  372.     compareItem = chopOff(c2);
  373.  
  374.    if ( (c1.isDigits()) && (c2.isDigits()) ) {
  375.       // compare 2 numbers
  376.       long d1=c1.asInt();
  377.       long d2=c2.asInt();
  378.       return compareIt(d1, d2, range);
  379.    }
  380.    else {
  381.       ADate *date1 = new ADate(c1);
  382.       ADate *date2 = new ADate(c2);
  383.       return compareIt(date1, date2, range);
  384.    } /* endif */
  385.  
  386. };
  387.  
  388.  
  389. // -------------------------------------------------------------------------
  390. // QueryInfo Class :: saveToQueryData() - save the search list to composite
  391. //                                        list
  392. // -------------------------------------------------------------------------
  393. QueryInfo& QueryInfo :: saveToQueryData(LQueryData *queryData,const IString& pageName)
  394. {
  395.    // save to IProfile
  396.  
  397.    IString key, value, range, saveKey;
  398.    short i = 1;
  399.    for ( searchCur.setToFirst();
  400.          searchCur.isValid();
  401.          searchCur.setToNext()) {
  402.  
  403.          getSearchItem(key, value, range);
  404.  
  405.          // these are container objects
  406.          if ((pageName == "SKILL ") |
  407.              (pageName == "ACCOUNT ")) {
  408.  
  409.              saveKey = pageName + IString(i);
  410.              queryData->putItem(saveKey, key, value, range);
  411.              ++i;
  412.          } /* endif */
  413.          else
  414.            if ((pageName == "STATUS ") ||
  415.                (pageName == "BADGE "))   {
  416.  
  417.                saveKey = pageName + key;
  418.                // for these pages date and range are saved in the bag
  419.                if ((key == "saveDate") ||
  420.                    (key == "endDate")  ||
  421.                    (key == "issueDate")||
  422.                    (key == "expireDate") ) {
  423.                   queryData->putItem(saveKey, value );
  424.                   queryData->putItem(saveKey+"Range", range );
  425.                } else
  426.                   queryData->putItem(saveKey, value );
  427.  
  428.  
  429.            }
  430.            else {
  431.              saveKey = pageName + key;
  432.              if (range.length() > 0  ) {
  433.                 saveKey = pageName + key + "Range";
  434.                 queryData->putItem(saveKey, range);
  435.              }
  436.              queryData->putItem(saveKey, value );
  437.            }
  438.  
  439.    }
  440.    return *this;
  441. };
  442.  
  443.  
  444. // -------------------------------------------------------------------------
  445. // QueryInfo Class :: compareItData() - compare dates for a match
  446. // -------------------------------------------------------------------------
  447. IBase :: Boolean QueryInfo :: compareIt( const ADate* d1,
  448.                                          const ADate* d2,
  449.                                          const IString& range)
  450. {
  451.    Boolean retCode = false;
  452.    // now compare the date or integer
  453.    if (d1 == d2 )
  454.        if (range.indexOfAnyOf("="))
  455.           retCode=true;
  456.        else
  457.           retCode=false;
  458.    else
  459.      if (d2 > d1 )
  460.        if (range.indexOfAnyOf(">"))
  461.           retCode=true;
  462.        else
  463.           retCode=false;
  464.      else
  465.         if (d2 < d1 )
  466.           if (range.indexOfAnyOf("<"))
  467.              retCode=true;
  468.           else
  469.              retCode=false;
  470.  
  471.     return retCode;
  472. };
  473.  
  474. // -------------------------------------------------------------------------
  475. // QueryInfo Class :: compareItData() - compare integers for a match
  476. // -------------------------------------------------------------------------
  477. IBase :: Boolean QueryInfo :: compareIt( const long  d1
  478.                                         ,const long  d2
  479.                                         ,const IString& range)
  480. {
  481.    Boolean retCode = false;
  482.    // now compare the date or integer
  483.    if (d1 == d2 )
  484.        if (range.indexOfAnyOf("="))
  485.           retCode=true;
  486.        else
  487.           retCode=false;
  488.    else
  489.      if (d2 > d1 )
  490.        if (range.indexOfAnyOf(">"))
  491.           retCode=true;
  492.        else
  493.           retCode=false;
  494.      else
  495.         if (d2 < d1 )
  496.           if (range.indexOfAnyOf("<"))
  497.              retCode=true;
  498.           else
  499.              retCode=false;
  500.  
  501.     return retCode;
  502. };
  503.  
  504.  
  505. // -------------------------------------------------------------------------
  506. // QueryInfo Class :: chopOff() - ignore decimal points
  507. // -------------------------------------------------------------------------
  508. IString QueryInfo :: chopOff( const IString& c2) {
  509.    unsigned i = c2.indexOf(".");
  510.    if (i > 0)
  511.       return (c2.subString(1, i-1));
  512.    return c2;
  513.  
  514. };
  515.  
  516.  
  517.  
  518. // -------------------------------------------------------------------------
  519. // QueryGenl Class :: QueryGenl() - constuctor
  520. // -------------------------------------------------------------------------
  521. QueryGenl :: QueryGenl()
  522.            : QueryInfo("lempl.ini"),
  523.              aDeptQuery()
  524. { };
  525.  
  526.  
  527. // -------------------------------------------------------------------------
  528. // QueryGenl Class :: ~QueryGenl() - constuctor
  529. // -------------------------------------------------------------------------
  530. QueryGenl :: ~QueryGenl()
  531. { };
  532.  
  533. // -------------------------------------------------------------------------
  534. // QueryGenl Class :: fillPage() - obtain page info and save as search items
  535. // -------------------------------------------------------------------------
  536. QueryGenl& QueryGenl :: fillPage(GeneralPage &genlPage)
  537. {
  538. // assume that setEmployeeData()
  539.    emptyBagSearchItems();
  540.    genlPage.setEmployeeData();
  541.     emptyBagSearchItems();
  542.     if (genlPage.employeeData.employeeNumber().length() > 0)
  543.         addSearchItem( "employeeNum"
  544.                        ,genlPage.employeeData.employeeNumber());
  545.     if (genlPage.employeeData.lastName().length() > 0 )
  546.         addSearchItem( "lastName"
  547.                        ,genlPage.employeeData.lastName());
  548.  
  549.     if (genlPage.employeeData.firstName().length() > 0 )
  550.         addSearchItem( "firstName"
  551.                        ,genlPage.employeeData.firstName());
  552.  
  553.     if (genlPage.employeeData.middleInitial().length() > 0 )
  554.         addSearchItem( "middleInitial"
  555.                        ,genlPage.employeeData.middleInitial());
  556.  
  557.     if (genlPage.employeeData.internalPhone().length() > 0 )
  558.         addSearchItem( "internalPhone"
  559.                        ,genlPage.employeeData.internalPhone());
  560.  
  561.     if (genlPage.employeeData.externalPhone().length() > 0 )
  562.         addSearchItem( "externalPhone"
  563.                        ,genlPage.employeeData.externalPhone());
  564.  
  565.     if (genlPage.employeeData.room().length() > 0 )
  566.         addSearchItem( "room"
  567.                        ,genlPage.employeeData.room());
  568.  
  569.     if (genlPage.employeeData.building().length() > 0 )
  570.         addSearchItem( "building"
  571.                        ,genlPage.employeeData.building());
  572.  
  573.     if (genlPage.employeeData.department().length() > 0 ) {
  574.         addSearchItem( "deptName"
  575.                        ,genlPage.employeeData.department());
  576.         if ( genlPage.employeeData.department().isAlphanumeric() )
  577.            aDeptQuery = genlPage.employeeData.department();
  578.  
  579.     }
  580.  
  581.     if (genlPage.employeeData.division().length() > 0 )
  582.         addSearchItem( "divName"
  583.                        ,genlPage.employeeData.division());
  584.  
  585.     if (genlPage.employeeData.managerNumber().length() > 0 )
  586.         addSearchItem( "internalPhone"
  587.                        ,genlPage.employeeData.internalPhone());
  588.  
  589.     if (genlPage.employeeData.managerName().length() > 0 )
  590.         addSearchItem( "managerName"
  591.                        ,genlPage.employeeData.managerName());
  592.  
  593.     if (genlPage.employeeData.managerNumber().length() > 0 )
  594.         addSearchItem( "managerNum"
  595.                        ,genlPage.employeeData.managerNumber());
  596.  
  597.  
  598.     QueryGenl :: EmplType emplType = (QueryGenl::EmplType)
  599.                           genlPage.employeeData.employeeType();
  600.  
  601.     if ((QueryGenl :: Unemployed) != emplType )
  602.         addSearchItem( "employeeType"
  603.                        ,IString(emplType));
  604.  
  605.     return *this;
  606. };
  607.  
  608.  
  609. // -------------------------------------------------------------------------
  610. // QueryGenl Class :: getMatchList() - get a list of ids that match
  611. // -------------------------------------------------------------------------
  612. QueryGenl& QueryGenl :: getMatchList(GeneralPage &genlPage)
  613. {
  614.   // for each id get employeeData and see if a match
  615.   IString
  616.     matchId,
  617.     key,
  618.     value;
  619.  
  620.   Boolean
  621.     match = false;
  622.   LEmployeeData
  623.    *ed = NULL;
  624.  
  625.   //  no verification of valid input
  626.   genlPage.setEmployeeData();
  627.   //  get the stuff from general page
  628.   fillPage(genlPage);
  629.   emptyBagMatchIds();
  630.  
  631.  
  632.   idList.setFirstId();
  633.   while (idList.getId(matchId)) {
  634.     ed = new LEmployeeData(matchId);
  635.  
  636.     // see if a match by looping thru searchList
  637.  
  638.     // must match up on all items
  639.     // while ( done && getSearchItem(key, value)) {
  640.  
  641.     if (setFirstSearchItem())
  642.        match = true;
  643.  
  644.     while (match && getSearchItem(key, value)) {
  645.       match = aMatch(ed, key, value);
  646.       getNextSearchItem();
  647.     }
  648.  
  649.     // put this ID in the MatchList
  650.     if  (match)
  651.        addMatchId(matchId);
  652.  
  653.     idList.getNextId();
  654.     delete ed;
  655.   } /* endwhile */
  656.   return *this;
  657.  
  658. };
  659.  
  660.  
  661. // -------------------------------------------------------------------------
  662. // QueryGenl Class :: aMatch() - checks for a match
  663. // -------------------------------------------------------------------------
  664. IBase :: Boolean  QueryGenl :: aMatch(const LEmployeeData* ed,
  665.                                       const IString& key,
  666.                                       const IString& value)
  667. {
  668.   if (key == "employeeNum" )
  669.     if (ed->employeeNumber().length() > 0)
  670.        return ed->employeeNumber().isLike(value);
  671.  
  672.   if (key == "lastName" )
  673.     if (ed->lastName().length() > 0)
  674.        return ed->lastName().isLike(value);
  675.  
  676.   if (key == "firstName" )
  677.     if (ed->firstName().length() > 0)
  678.        return ed->firstName().isLike(value);
  679.  
  680.   if (key == "middleInitial" )
  681.     if (ed->middleInitial().length() > 0)
  682.        return ed->middleInitial().isLike(value);
  683.  
  684.   if (key == "internalPhone" )
  685.     if (ed->internalPhone().length() > 0)
  686.        return ed->internalPhone().isLike(value);
  687.  
  688.   if (key == "externalPhone" )
  689.     if (ed->externalPhone().length() > 0)
  690.        return ed->externalPhone().isLike(value);
  691.  
  692.   if (key == "room" )
  693.     if (ed->room().length() > 0)
  694.        return ed->room().isLike(value);
  695.  
  696.   if (key == "building" )
  697.     if (ed->building().length() > 0)
  698.        return ed->building().isLike(value);
  699.  
  700.   if (key == "deptName" )
  701.     if (ed->department().length() > 0)
  702.        return ed->department().isLike(value);
  703.  
  704.   if (key == "divName" )
  705.     if (ed->division().length() > 0)
  706.        return ed->division().isLike(value);
  707.  
  708.   if (key == "managerName" )
  709.     if (ed->managerName().length() > 0)
  710.        return ed->managerName().isLike(value);
  711.  
  712.   if (key == "managerNum" )
  713.     if (ed->managerNumber().length() > 0)
  714.        return ed->managerNumber().isLike(value);
  715.  
  716.   if (key == "employeeType" )
  717.      return value.isLike(IString(ed->employeeType()) );
  718.  
  719.   return false;
  720. };
  721.  
  722. // -------------------------------------------------------------------------
  723. // QueryMgr Class :: QueryMgr() - constuctor
  724. // -------------------------------------------------------------------------
  725. QueryMgrs :: QueryMgrs()
  726.            : QueryInfo("lempl.ini")
  727. {
  728.    emptyBagSearchItems();
  729.    addSearchItem( "employeeType" ,IString(QueryMgrs:: Manager));
  730. };
  731.  
  732.  
  733. // -------------------------------------------------------------------------
  734. // QueryMgrs Class :: ~QueryMgrs() - constuctor
  735. //                                 Obtain a list of managers
  736. // -------------------------------------------------------------------------
  737. QueryMgrs :: ~QueryMgrs()
  738. { };
  739.  
  740. // -------------------------------------------------------------------------
  741. // QueryMgrs Class :: fillPage() - obtain page info and save as search items
  742. // -------------------------------------------------------------------------
  743. /*
  744. QueryMgrs& QueryMgrs :: fillPage(GeneralPage &genlPage)
  745. {
  746.    emptyBagSearchItems();
  747.  
  748.    addSearchItem( "employeeType" ,IString(QueryMgr:: Manager));
  749.  
  750.     return *this;
  751. };
  752. */
  753.  
  754. // -------------------------------------------------------------------------
  755. // QueryMgrs Class :: getMatchList() - get a list of ids that match
  756. // -------------------------------------------------------------------------
  757. QueryMgrs& QueryMgrs :: getMatchList()
  758. {
  759.   // for each id get employeeData and see if a match
  760.   IString
  761.     matchId,
  762.     key,
  763.     value;
  764.  
  765.   Boolean
  766.     match = false;
  767.   LEmployeeData
  768.    *ed = NULL;
  769.  
  770.   emptyBagMatchIds();
  771.  
  772.   idList.setFirstId();
  773.   while (idList.getId(matchId)) {
  774.     ed = new LEmployeeData(matchId);
  775.  
  776.     // see if a match by looping thru searchList
  777.  
  778.     // must match up on all items
  779.     // while ( done && getSearchItem(key, value)) {
  780.  
  781.     if (setFirstSearchItem())
  782.        match = true;
  783.  
  784.     while (match && getSearchItem(key, value)) {
  785.       match = aMatch(ed, key, value);
  786.       getNextSearchItem();
  787.     }
  788.  
  789.     // put this ID in the MatchList
  790.     if  (match)
  791.        addMatchId(matchId);
  792.  
  793.     idList.getNextId();
  794.     delete ed;
  795.   } /* endwhile */
  796.   return *this;
  797.  
  798. };
  799.  
  800.  
  801. // -------------------------------------------------------------------------
  802. // QueryMgrs Class :: aMatch() - checks for a match
  803. // -------------------------------------------------------------------------
  804. IBase :: Boolean  QueryMgrs :: aMatch(const LEmployeeData* ed,
  805.                                       const IString& key,
  806.                                       const IString& value)
  807. {
  808.  
  809.   if (key == "employeeType" )
  810.      return value.isLike(IString(ed->employeeType()) );
  811.  
  812.   return false;
  813. };
  814.  
  815.  
  816. // -------------------------------------------------------------------------
  817. // QueryAcct :: QueryAcct()
  818. // -------------------------------------------------------------------------
  819. QueryAcct :: QueryAcct()
  820.            : QueryInfo("lacct.ini")
  821. {};
  822.  
  823. // -------------------------------------------------------------------------
  824. // QueryAcct :: ~QueryAcct()
  825. // -------------------------------------------------------------------------
  826. QueryAcct :: ~QueryAcct()
  827. {};
  828.  
  829.  
  830. // -------------------------------------------------------------------------
  831. // QueryAcct :: fillPage() page to data
  832. // -------------------------------------------------------------------------
  833. QueryAcct& QueryAcct :: fillPage(AccountPage &acctPage)
  834. {
  835.     emptyBagSearchItems();
  836.     acctPage.setAcctData();
  837.     // take data out of the container and put it in the bag
  838.  
  839.      // iterate thru the container and put it in the BAG
  840.      IContainerControl::ObjectCursor   iterator(*acctPage.pCnr);
  841.  
  842.      iterator.setToFirst();
  843.      // return false only if an error
  844.      if (false==iterator.isValid()) return *this;
  845.  
  846.      AcctCnrObj *cnrEntry;           // an IContainerObject
  847.      IString  name="", node="";
  848.      // only use data from the container
  849.  
  850.      while (iterator.isValid()) {
  851.         cnrEntry = (AcctCnrObj *)iterator.current();
  852.  
  853.         if (cnrEntry->getUserId().length() > 0)
  854.             name = cnrEntry->getUserId();
  855.  
  856.         if (cnrEntry->getNode().length() > 0);
  857.             node = cnrEntry->getNode();
  858.  
  859.          addSearchItem (name, node );
  860.  
  861.         // get the next one
  862.         cnrEntry = (AcctCnrObj *)iterator.next();
  863.  
  864.      } /* endwhile */
  865.      return *this;
  866. };
  867.  
  868. // -------------------------------------------------------------------------
  869. // QueryAcct :: getMatchList() get the search list
  870. // -------------------------------------------------------------------------
  871. QueryAcct& QueryAcct :: getMatchList(AccountPage &acctPage)
  872. {
  873.  
  874.   IString
  875.     matchId,
  876.     key,
  877.     value;
  878.  
  879.   Boolean
  880.     lp = false;
  881.   LAcctData
  882.    *ed = NULL;
  883.  
  884.   //  no verification of valid input
  885.   acctPage.setAcctData();
  886.   //  get the stuff from general page
  887.   fillPage(acctPage);
  888.   if (numberOfMatchElements() == 0) return *this;
  889.  
  890.   emptyBagMatchIds();
  891.  
  892.   // for each id get employeeData and see if a match
  893.  
  894.   idList.setFirstId();
  895.   while (idList.getId(matchId)) {
  896.     ed = new LAcctData(matchId);
  897.     // see if a match by looping thru searchList
  898.     if (setFirstSearchItem())
  899.        lp = true;
  900.     while ( lp && getSearchItem(key, value)) {
  901.       lp = !aMatch(ed, key, value);
  902.       getNextSearchItem();
  903.     }
  904.     if (!lp)
  905.        // put this ID in the MatchList
  906.        addMatchId(matchId);
  907.     idList.getNextId();
  908.     delete ed;
  909.   }
  910.   return *this;
  911. };
  912.  
  913. // -------------------------------------------------------------------------
  914. // QueryAcct :: aMatch() see if a match
  915. // -------------------------------------------------------------------------
  916. IBase :: Boolean  QueryAcct :: aMatch(LAcctData* ed,
  917.                                       const IString& matchID,
  918.                                       const IString& matchNode)
  919. {
  920.   IString
  921.     user,
  922.     node;
  923.  
  924.   Boolean
  925.     Done = false;
  926.  
  927.   ed->setFirst();
  928.   // loop thru and see if a match
  929.   while ( true == ed->isValid() ) {
  930.  
  931.        ed->getItem(  user ,node, false);
  932.        Done = ( (user.isLike(matchID)) &&
  933.                 (node.isLike(matchNode))) ;
  934.        if (Done)  return Done;
  935.  
  936.     ed->getNext();
  937.   } /* endwhile */
  938.  
  939.  
  940.   return Done;
  941. };
  942.  
  943.  
  944. // -------------------------------------------------------------------------
  945. // QuerySkill :: QuerySkill
  946. // -------------------------------------------------------------------------
  947. QuerySkill :: QuerySkill()
  948.            : QueryInfo("lskill.ini")
  949. {};
  950.  
  951. // -------------------------------------------------------------------------
  952. // QuerySkill :: QuerySkill destructor
  953. // -------------------------------------------------------------------------
  954. QuerySkill :: ~QuerySkill()
  955. {};
  956.  
  957. // -------------------------------------------------------------------------
  958. // QuerySkill :: fillPage()
  959. // -------------------------------------------------------------------------
  960. QuerySkill& QuerySkill :: fillPage(SkillPage &skillPage)
  961. {
  962.  
  963.      IString
  964.        skill="*",
  965.        years="0",
  966.        range="=";
  967.  
  968.      emptyBagSearchItems();
  969.      // take data out of the container and put it in the bag
  970.  
  971.      skillPage.setSkillData();
  972.      emptyBagSearchItems();
  973.  
  974.      // iterate thru the container and put it in the BAG
  975.      IContainerControl::ObjectCursor
  976.        iterator(*skillPage.pCnr);
  977.  
  978.      iterator.setToFirst();
  979.      // return false only if an error
  980.      if (false==iterator.isValid()) return *this;
  981.  
  982.      SkillCnrObj
  983.       *cnrEntry;           // an IContainerObject
  984.  
  985.      IString
  986.        it1,
  987.        it2;
  988.  
  989.      // only use data from the container
  990.  
  991.      while (iterator.isValid()) {
  992.         cnrEntry = (SkillCnrObj *)iterator.current();
  993.  
  994.           if (cnrEntry->getSkill().length() > 0)
  995.              skill = cnrEntry->getSkill();
  996.  
  997.           if (cnrEntry->getExp().length() > 0);
  998.              years =  cnrEntry->getExp() ;
  999.  
  1000.           if (skillPage.pSkillRange->getRange().length() > 0);
  1001.               range = skillPage.pSkillRange->getRange();
  1002.  
  1003.           addSearchItem ( skill, years, range) ;
  1004.  
  1005.         // get the next one
  1006.         cnrEntry = (SkillCnrObj *)iterator.next();
  1007.  
  1008.      } /* endwhile */
  1009.  
  1010.     return *this;
  1011. };
  1012.  
  1013.  
  1014. // -------------------------------------------------------------------------
  1015. // QuerySkill :: getMatchList()
  1016. // -------------------------------------------------------------------------
  1017. QuerySkill& QuerySkill :: getMatchList(SkillPage &skillPage)
  1018. {
  1019.  
  1020.   //  no verification of valid input
  1021.   skillPage.setSkillData();
  1022.   //  get the stuff from general page
  1023.   fillPage(skillPage);
  1024.   if (numberOfMatchElements() == 0) return *this;
  1025.  
  1026.   emptyBagMatchIds();
  1027.  
  1028.   // for each id get employeeData and see if a match
  1029.   IString
  1030.     matchId,
  1031.     key,
  1032.     range,
  1033.     value;
  1034.  
  1035.   Boolean
  1036.     lp = true ;
  1037.   LSkillData
  1038.    *ed = NULL;
  1039.  
  1040.   idList.setFirstId();
  1041.   while (idList.getId(matchId)) {
  1042.     ed = new LSkillData(matchId);
  1043.     // see if a match by looping thru searchList
  1044.     if (setFirstSearchItem())
  1045.        lp = true;
  1046.     while ( lp && getSearchItem(key, value, range)) {
  1047.       lp = !aMatch(ed, key, value, range);
  1048.       getNextSearchItem();
  1049.     }
  1050.     if (!lp)
  1051.        // put this ID in the MatchList
  1052.        addMatchId(matchId);
  1053.     idList.getNextId();
  1054.     delete ed;
  1055.   }
  1056.   return *this;
  1057. };
  1058.  
  1059. // -------------------------------------------------------------------------
  1060. // QuerySkill :: aMatch()
  1061. // -------------------------------------------------------------------------
  1062. IBase :: Boolean  QuerySkill :: aMatch(LSkillData* ed
  1063.                                      ,const IString& matchSkill
  1064.                                      ,const IString& matchYears
  1065.                                      ,const IString& matchRange)
  1066. {
  1067.   IString
  1068.     skill,
  1069.     years;
  1070.  
  1071.   Boolean
  1072.     Done = false;
  1073.  
  1074.   // loop thru and see if a match
  1075.   LSkillData::Rule
  1076.     rule;
  1077.  
  1078.   ed->setFirst();
  1079.   while (true == ed->isValid() ) {
  1080.        ed->getItem(  skill ,years, false );
  1081.  
  1082.        Done = ( (skill.isLike(matchSkill) ) &
  1083.                 (inRange(matchYears, years, matchRange) ));
  1084.        if (Done) return Done;
  1085.  
  1086.     ed->getNext();
  1087.   } /* endwhile */
  1088.  
  1089.  
  1090.   return Done ;
  1091. };
  1092.  
  1093. // -------------------------------------------------------------------------
  1094. // QueryBadge :: QueryBadge()
  1095. // -------------------------------------------------------------------------
  1096. QueryBadge :: QueryBadge()
  1097.             : QueryInfo("lbadge.ini")
  1098. {};
  1099.  
  1100. // -------------------------------------------------------------------------
  1101. // QueryBadge :: ~QueryBadge()
  1102. // -------------------------------------------------------------------------
  1103. QueryBadge :: ~QueryBadge()
  1104. {};
  1105.  
  1106.  
  1107. // -------------------------------------------------------------------------
  1108. // QueryBadge :: fillPage()
  1109. // -------------------------------------------------------------------------
  1110. QueryBadge& QueryBadge :: fillPage(BadgePage &badgePage)
  1111. {
  1112.  
  1113.     emptyBagSearchItems();
  1114.     if (badgePage.badgeNumber().IString::length() > 0 )
  1115.         addSearchItem( "badgeNumber"
  1116.                        ,badgePage.badgeNumber());
  1117.  
  1118.     if (badgePage.issueDate().IString::length() > 0 )
  1119.         addSearchItem( "issueDate"
  1120.                        ,badgePage.issueDate()
  1121.                        ,badgePage.pIssueRange->getRange());
  1122.  
  1123.     if (badgePage.expDate().IString::length() > 0 )
  1124.         addSearchItem( "expireDate"
  1125.                        ,badgePage.expDate()
  1126.                        ,badgePage.pExpRange->getRange());
  1127.  
  1128.     return *this;
  1129. };
  1130.  
  1131.  
  1132. // -------------------------------------------------------------------------
  1133. // QueryBadge :: getMatchList()
  1134. // -------------------------------------------------------------------------
  1135. QueryBadge& QueryBadge :: getMatchList(BadgePage &badgePage)
  1136. {
  1137.   //  no verification of valid input
  1138.  
  1139.   //  get the stuff from general page
  1140.   fillPage(badgePage);
  1141.  
  1142.   emptyBagMatchIds();
  1143.  
  1144.   // for each id get employeeData and see if a match
  1145.   IString
  1146.     matchId,
  1147.     key,
  1148.     range,
  1149.     value;
  1150.  
  1151.   Boolean
  1152.     match = false;
  1153.  
  1154.   LBadgeData
  1155.    *bd = NULL;
  1156.  
  1157.   idList.setFirstId();
  1158.   while (idList.getId(matchId)) {
  1159.     bd = new LBadgeData(matchId);
  1160.     // see if a match by looping thru searchList
  1161.     if (setFirstSearchItem())
  1162.        match = true;
  1163.     while ( match && getSearchItem(key, value, range)) {
  1164.       match = aMatch(bd, key, value, range);
  1165.       getNextSearchItem();
  1166.     }
  1167.     if (match)
  1168.        // put this ID in the MatchList
  1169.        addMatchId(matchId);
  1170.     idList.getNextId();
  1171.     delete bd;
  1172.   } /* endwhile */
  1173.   return *this;
  1174.  
  1175. };
  1176.  
  1177. // -------------------------------------------------------------------------
  1178. // QueryBadge :: aMatch()
  1179. // -------------------------------------------------------------------------
  1180. IBase :: Boolean  QueryBadge :: aMatch(LBadgeData* bd,
  1181.                                        const IString& key,
  1182.                                        const IString& value,
  1183.                                        const IString& range)
  1184. {
  1185.  
  1186.    if (key == "badgeNumber")
  1187.        return bd->badgeNumber().isLike(value);
  1188.  
  1189.    if (key == "issueDate")
  1190.       return inRange(value,bd->badgeIssue(), range);
  1191.  
  1192.    if (key == "expireDate")
  1193.       return inRange(value,bd->badgeExpire(), range);
  1194.  
  1195.   return false;
  1196. };
  1197.  
  1198.  
  1199.  
  1200. // -------------------------------------------------------------------------
  1201. // QueryStatus :: QueryStatus()
  1202. // -------------------------------------------------------------------------
  1203. QueryStatus :: QueryStatus()
  1204.             : QueryInfo("lstatus.ini")
  1205. {};
  1206.  
  1207.  
  1208. // -------------------------------------------------------------------------
  1209. // QueryStatus :: ~QueryStatus()
  1210. // -------------------------------------------------------------------------
  1211. QueryStatus :: ~QueryStatus()
  1212. {};
  1213.  
  1214.  
  1215.  
  1216. // -------------------------------------------------------------------------
  1217. // QueryStatus :: fillPage()
  1218. // -------------------------------------------------------------------------
  1219. QueryStatus& QueryStatus :: fillPage(StatusPage &statusPage)
  1220. {
  1221.  
  1222.     emptyBagSearchItems();
  1223.  
  1224.     if (statusPage.pQueryActive->isSelected())
  1225.         addSearchItem( "active"
  1226.                        ,"yes");
  1227.  
  1228.     if (statusPage.pQueryInactive->isSelected())
  1229.         addSearchItem( "inactive"
  1230.                        ,"yes");
  1231.  
  1232.     if (statusPage.startDate.text().length() > 0 )
  1233.         addSearchItem( "startDate"
  1234.                        ,statusPage.startDate.text()
  1235.                        ,statusPage.pStartRange->getRange());
  1236.  
  1237.     if (statusPage.endDate.text().length() > 0 )
  1238.         addSearchItem( "endDate"
  1239.                        ,statusPage.endDate.text()
  1240.                        ,statusPage.pEndRange->getRange());
  1241.  
  1242.     if (statusPage.hourlyRate.text().length() > 0 )
  1243.         addSearchItem( "hourlyRate"
  1244.                        ,statusPage.hourlyRate.text()
  1245.                        ,statusPage.pPayRange->getRange());
  1246.  
  1247.     return *this;
  1248.  
  1249. };
  1250.  
  1251.  
  1252. // -------------------------------------------------------------------------
  1253. // QueryStatus :: getMatchList()
  1254. // -------------------------------------------------------------------------
  1255. QueryStatus& QueryStatus :: getMatchList(StatusPage &statusPage)
  1256. {
  1257.   //  no verification of valid input
  1258.  
  1259.   fillPage(statusPage);
  1260.  
  1261.   emptyBagMatchIds();
  1262.  
  1263.   // for each id get employeeData and see if a match
  1264.   IString
  1265.     matchId,
  1266.     key,
  1267.     range,
  1268.     value;
  1269.  
  1270.   Boolean
  1271.     match = false;
  1272.  
  1273.   LStatusData
  1274.    *bd = NULL;
  1275.  
  1276.   idList.setFirstId();
  1277.   while (idList.getId(matchId)) {
  1278.     bd = new LStatusData(matchId);
  1279.     // see if a match by looping thru searchList
  1280.     if (setFirstSearchItem())
  1281.        match = true;
  1282.     while ( match && getSearchItem(key, value, range)) {
  1283.       match = aMatch(bd, key, value, range);
  1284.       getNextSearchItem();
  1285.     }
  1286.     if (match)
  1287.        // put this ID in the MatchList
  1288.        addMatchId(matchId);
  1289.  
  1290.     idList.getNextId();
  1291.     delete bd;
  1292.   } /* endwhile */
  1293.   return *this;
  1294.  
  1295. };
  1296.  
  1297. // -------------------------------------------------------------------------
  1298. // QueryStatus :: aMatch()
  1299. // -------------------------------------------------------------------------
  1300. IBase :: Boolean  QueryStatus :: aMatch(LStatusData* sd
  1301.                                        , const IString& key
  1302.                                        , const IString& value
  1303.                                        , const IString& range)
  1304. {
  1305.    if (key == "active")
  1306.        return ((sd->statusActive()=="yes") ? true :false);
  1307.  
  1308.    if (key == "inactive")
  1309.       return ((sd->statusActive()=="no") ? true :false);
  1310.  
  1311.    if (key == "startDate")
  1312.       return inRange(value,sd->statusStart(), range);
  1313.  
  1314.    if (key == "endDate")
  1315.       return inRange(value,sd->statusEnd(), range);
  1316.  
  1317.    if (key == "hourlyRate")
  1318.       return inRange(value,sd->statusRate(), range);
  1319.  
  1320.    return false;
  1321.  
  1322. };
  1323.  
  1324.  
  1325.  
  1326. // -------------------------------------------------------------------------
  1327. // QueryQry :: QueryQry() - get all the saved queries
  1328. // -------------------------------------------------------------------------
  1329. QueryQry :: QueryQry()
  1330.           : itemsCur(items)
  1331. {
  1332.     emptyBagQry();
  1333.     getQryNames();                      // fill bag
  1334. };
  1335.  
  1336. // -------------------------------------------------------------------------
  1337. // QueryQry :: ~QueryQry() destructor
  1338. // -------------------------------------------------------------------------
  1339. QueryQry :: ~QueryQry()
  1340. {
  1341.   emptyBagQry();
  1342. };
  1343.  
  1344.  
  1345. // -------------------------------------------------------------------------
  1346. // QueryQry :: getQryNames()
  1347. // -------------------------------------------------------------------------
  1348. QueryQry :: getQryNames()
  1349. {
  1350.    IString
  1351.       id;
  1352.  
  1353. // get all lsaveqry.ini query
  1354.    try
  1355.    {
  1356.       IProfile
  1357.          savIni = IProfile("lsaveqry.ini");
  1358.  
  1359.       IProfile::Cursor
  1360.          IniCursor(savIni);
  1361.       for (IniCursor.setToFirst();
  1362.            IniCursor.isValid();
  1363.            IniCursor.setToNext() )
  1364.       {
  1365.          id = savIni.applicationOrKeyAt(IniCursor);
  1366.          putQry(id) ;
  1367.       }
  1368.    }
  1369.    catch(...)
  1370.    {}
  1371.  
  1372.    return 0;
  1373. }
  1374.  
  1375.  
  1376. // -------------------------------------------------------------------------
  1377. // QueryQry :: emptyBagQry()
  1378. // -------------------------------------------------------------------------
  1379. IBase :: Boolean  QueryQry  :: emptyBagQry()  {
  1380.  items.removeAll();
  1381.  itemsCur.invalidate();
  1382.  return (true);
  1383. };
  1384.  
  1385.  
  1386. // -------------------------------------------------------------------------
  1387. // QueryQry :: putQry()
  1388. // -------------------------------------------------------------------------
  1389. IBase :: Boolean QueryQry :: putQry( const IString& item1)
  1390. {
  1391.    items.add(Item(item1));
  1392.  
  1393.    return true;
  1394.  
  1395. }     // putQry
  1396.  
  1397.  
  1398. // -------------------------------------------------------------------------
  1399. // QueryQry :: getQry()
  1400. // -------------------------------------------------------------------------
  1401. IString QueryQry :: getQry()
  1402. {
  1403.  
  1404.    if (false == itemsCur.isValid())
  1405.       return "";  // none left
  1406.  
  1407.    Entry name = itemsCur.element().item1();
  1408.  
  1409.    items.locateElementWithKey(name, itemsCur);
  1410.  
  1411.    Entry i1 = itemsCur.element().item1();
  1412.  
  1413.    return ( i1.text() );
  1414.  
  1415. }; //getId
  1416.  
  1417.  
  1418.  
  1419. // -------------------------------------------------------------------------
  1420. // QueryIntersection  :: QueryIntersection()
  1421. // -------------------------------------------------------------------------
  1422. QueryIntersection :: QueryIntersection( QueryGenl*   pGenl
  1423.                                        ,QuerySkill*  pSkill
  1424.                                        ,QueryAcct*   pAcct
  1425.                                        ,QueryStatus* pStatus
  1426.                                        ,QueryBadge*  pBadge)
  1427.           : itemsCur(items)
  1428. {
  1429.     IString id;
  1430.     emptyBagIntersection();
  1431.     if (pGenl->numberOfMatchElements() > 0 ) {
  1432.  
  1433.         items.unionWith(pGenl->matchIds);
  1434.  
  1435.         if (pSkill->numberOfMatchElements() > 0 )
  1436.            items.intersectionWith(pSkill->matchIds);
  1437.         if (pAcct->numberOfMatchElements() > 0 )
  1438.            items.intersectionWith(pAcct->matchIds);
  1439.         if (pStatus->numberOfMatchElements() > 0 )
  1440.            items.intersectionWith(pStatus->matchIds);
  1441.         if (pBadge->numberOfMatchElements() > 0 )
  1442.            items.intersectionWith(pBadge->matchIds);
  1443.  
  1444.     } else
  1445.       if (pSkill->numberOfMatchElements() > 0 ) {
  1446.           items.unionWith(pSkill->matchIds);
  1447.  
  1448.           if (pAcct->numberOfMatchElements() > 0 )
  1449.              items.intersectionWith(pAcct->matchIds);
  1450.           if (pStatus->numberOfMatchElements() > 0 )
  1451.              items.intersectionWith(pStatus->matchIds);
  1452.           if (pBadge->numberOfMatchElements() > 0 )
  1453.              items.intersectionWith(pBadge->matchIds);
  1454.       }
  1455.       else
  1456.        if (pAcct->numberOfMatchElements() > 0 ) {
  1457.            items.unionWith(pAcct->matchIds);
  1458.  
  1459.            if (pStatus->numberOfMatchElements() > 0 )
  1460.               items.intersectionWith(pStatus->matchIds);
  1461.            if (pBadge->numberOfMatchElements() > 0 )
  1462.               items.intersectionWith(pBadge->matchIds);
  1463.        }
  1464.        else
  1465.          if (pStatus->numberOfMatchElements() > 0 ) {
  1466.              items.unionWith(pStatus->matchIds);
  1467.  
  1468.              if (pBadge->numberOfMatchElements() > 0 )
  1469.                 items.intersectionWith(pBadge->matchIds);
  1470.          }
  1471.          if (pBadge->numberOfMatchElements() > 0 )
  1472.              items.unionWith(pBadge->matchIds);
  1473.  
  1474. };
  1475.  
  1476.  
  1477. // -------------------------------------------------------------------------
  1478. // QueryIntersection  :: ~QueryIntersection()
  1479. // -------------------------------------------------------------------------
  1480. QueryIntersection :: ~QueryIntersection()
  1481. {
  1482.   emptyBagIntersection();
  1483. };
  1484.  
  1485.  
  1486. // -------------------------------------------------------------------------
  1487. // QueryIntersection  :: emptyBagIntersection()
  1488. // -------------------------------------------------------------------------
  1489. IBase :: Boolean  QueryIntersection :: emptyBagIntersection()  {
  1490.  items.removeAll();
  1491.  itemsCur.invalidate();
  1492.  return (true);
  1493. };
  1494.  
  1495.  
  1496. // -------------------------------------------------------------------------
  1497. // QueryIntersection  :: putId()
  1498. // -------------------------------------------------------------------------
  1499. IBase :: Boolean QueryIntersection :: putId( const IString& item1)
  1500. {
  1501.    items.add(item1);
  1502.  
  1503.    return true;
  1504.  
  1505. };    // putQry
  1506.  
  1507.  
  1508. // -------------------------------------------------------------------------
  1509. // QueryIntersection  :: getId()
  1510. // -------------------------------------------------------------------------
  1511. IString QueryIntersection :: getId()
  1512. {
  1513.  
  1514.    if (false == itemsCur.isValid())
  1515.       return "";  // none left
  1516.  
  1517.    itemsCur.element().asString();
  1518.  
  1519.    return ( itemsCur.element().asString()  );
  1520.  
  1521. }; //getId
  1522.  
  1523.