home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / VSCPPv8.zip / VACPP / IBMCPP / samples / IOC / LANCELOT / LDBQRY.CPP < prev    next >
C/C++ Source or Header  |  1995-04-14  |  45KB  |  1,517 lines

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