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

  1. /*******************************************************************************
  2. * FILE NAME: ldbqry.hpp                                                        *
  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. #ifndef _LDBQRY_
  19. #define _LDBQRY_
  20.  
  21.  
  22. #include <iostream.h>
  23.  
  24. #include <idate.hpp>
  25. #include "litems.hpp"
  26. #include "lacct.hpp"
  27. #include "lskill.hpp"
  28. #include "lbadge.hpp"
  29. #include "lstatus.hpp"
  30. #include "ldbase.hpp"
  31. #include "ldbqry.hpp"
  32. #include "lgenl.hpp"
  33.  
  34. #include <istring.hpp>
  35.  
  36. // forward reference
  37. class GeneralPage;
  38.  
  39.  
  40. class  ADate : public IDate
  41. {
  42. public:
  43.     ADate(const IString theDate);
  44.     ~ADate();
  45.  
  46. inline const IDate
  47.   *date() {return pDate;};
  48.  
  49. ADate&
  50.     setDate(const IString theDate);
  51.  
  52. private: // ---------------------- PRIVATE-------------------------------------
  53.  
  54. ADate&
  55.     extractDate(const IString theDate);
  56.  
  57. IDate
  58.   *pDate;
  59.  
  60. };
  61.  
  62.  
  63. // ========================================================================================
  64. // DB Query operations
  65. // Obtains a list of unique ids in lempl.ini
  66. // With an employee number an LEmployeeData object can be created
  67. // ========================================================================================
  68.  
  69. //----------------------------------------------------------------------------
  70. // class QueryEmpl
  71. //----------------------------------------------------------------------------
  72. class QueryEmpl : public IBase
  73. {
  74. public: // ---------------------- PUBLIC -------------------------------------
  75.  
  76.  
  77. //----------------------- Contructor/Destructor ------------------------------
  78. // Class QueryEmpl :: QueryEmpl()
  79. //----------------------------------------------------------------------------
  80.   QueryEmpl();
  81.   ~QueryEmpl();
  82.  
  83. inline Boolean
  84.   getNextId(){ itemsCur.setToNext();
  85.                return itemsCur.isValid();};
  86.  
  87. inline Boolean setFirstId(){ itemsCur.setToFirst();
  88.                              return itemsCur.isValid();};
  89. QueryEmpl&
  90.   deleteCurrentId();
  91.  
  92. Boolean
  93.   getId(  IString& i1);
  94.  
  95. Boolean
  96.   putId(   const IString& i1);
  97.  
  98. Boolean
  99.   emptyBagId();
  100.  
  101. private: //----------------------- PRIVATE ----------------------------------
  102.  
  103.   get();
  104.  
  105. Items
  106.     items;
  107.  
  108. Items::Cursor
  109.     itemsCur;
  110.  
  111. inline IString
  112.   deptQuery() {return aDeptQuery;};
  113.  
  114. IString
  115.     aDeptQuery;
  116.  
  117. };
  118.  
  119.  
  120.  
  121. //----------------------------------------------------------------------------
  122. // class QueryInfo
  123. //----------------------------------------------------------------------------
  124. class QueryInfo : public IBase
  125. {
  126. public: // ---------------------- PUBLIC -------------------------------------
  127.  
  128. friend class QueryGenl;
  129. friend class QueryMgrs;
  130. friend class QueryAcct;
  131. friend class QuerySkill;
  132. friend class QueryBadge;
  133. friend class QueryStatus;
  134. friend class QueryIntersection;
  135.  
  136. //----------------------- Contructor/Destructor ------------------------------
  137. // Class QueryInfo :: QueryInfo()
  138. //----------------------------------------------------------------------------
  139.   QueryInfo(const char *);
  140.   ~QueryInfo();
  141.  
  142. Boolean
  143.   isDBempty();
  144.  
  145. Boolean
  146.   getMatchId(IString& field);
  147.  
  148. inline Boolean
  149.   getNextMatchId(){ matchCur.setToNext();
  150.                     return matchCur.isValid();}
  151.  
  152. inline Boolean
  153.   setFirstMatchId(){ matchCur.setToFirst();
  154.                      return matchCur.isValid();}
  155.  
  156. inline INumber
  157.   numberOfMatches(){ return matchIds.numberOfElements();};
  158.  
  159. inline Boolean
  160.   isValid(){ return matchCur.isValid();}
  161.  
  162. QueryInfo&
  163.   emptyBagMatchIds();
  164.  
  165. QueryInfo&
  166.   addMatchId(const IString& anId);
  167.  
  168. Boolean
  169.   getSearchItem( IString& field,
  170.                  IString& data);
  171.  
  172. Boolean
  173.   getSearchItem( IString& field,
  174.                  IString& data,
  175.                  IString& range);
  176.  
  177. QueryInfo&
  178.   addSearchItem(const IString& field,
  179.                 const IString& data,
  180.                 const IString& range="");
  181.  
  182.  
  183. inline
  184.   Boolean getNextSearchItem(){ searchCur.setToNext();
  185.                                return searchCur.isValid();
  186.                               };
  187.  
  188. inline
  189.   Boolean setFirstSearchItem(){ searchCur.setToFirst();
  190.                                 return searchCur.isValid();
  191.                               };
  192. QueryInfo&
  193.   emptyBagSearchItems();
  194.  
  195. Boolean
  196.   inRange(const IString &d1,
  197.           const IString &d2,
  198.           const IString &range);
  199.  
  200. QueryInfo&
  201.   saveToQueryData(LQueryData *queryData,const IString& pageName);
  202.  
  203. inline
  204.   unsigned numberOfMatchElements(){return searchItems.numberOfElements();};
  205.  
  206. IString
  207.   chopOff( const IString& c2);
  208.  
  209. private: //----------------------- PRIVATE ----------------------------------
  210.  
  211. Boolean
  212.   compareIt( const ADate* d1,
  213.              const ADate* d2,
  214.              const IString& range) ;
  215.  
  216. Boolean
  217.   compareIt( const long   d1,
  218.              const long   d2,
  219.              const IString& range) ;
  220.  
  221. QueryEmpl
  222.   idList;
  223.  
  224. ItemsBag
  225.   matchIds;
  226.  
  227. Items
  228.   searchItems; // items to match up (the Queries)
  229.  
  230. ItemsBag::Cursor
  231.   matchCur;
  232.  
  233. Items::Cursor
  234.   searchCur;
  235.  
  236. IString
  237.   theDB;
  238.  
  239. } ;
  240.  
  241.  
  242. //----------------------------------------------------------------------------
  243. // class QueryGenl
  244. //----------------------------------------------------------------------------
  245. class QueryGenl : public QueryInfo
  246. {
  247. public: // ---------------------- PUBLIC -------------------------------------
  248.  
  249. enum EmplType {
  250.                 Regular,
  251.                 Manager,
  252.                 Supplemental,
  253.                 Unemployed};
  254.  
  255.  
  256. //----------------------- Contructor/Destructor ------------------------------
  257. // Class QueryGenl :: QueryGenl()
  258. //----------------------------------------------------------------------------
  259.     QueryGenl();
  260.     ~QueryGenl();
  261.  
  262. QueryGenl&
  263.     fillPage(GeneralPage & gp);
  264.  
  265. QueryGenl&
  266.     getMatchList(GeneralPage &genlPage);
  267.  
  268. Boolean
  269.     aMatch(const LEmployeeData* ed,
  270.            const IString& key,
  271.            const IString& value) ;
  272. inline IString
  273.   deptQuery() {return aDeptQuery;};
  274.  
  275. private: // ---------------------- PRIVATE-------------------------------------
  276.  
  277. IString
  278.     aDeptQuery;
  279.  
  280.  
  281. };
  282.  
  283. //----------------------------------------------------------------------------
  284. // class QueryMgrs - query manager
  285. //----------------------------------------------------------------------------
  286. class QueryMgrs  : public QueryInfo
  287. {
  288. public: // ---------------------- PUBLIC -------------------------------------
  289.  
  290. enum EmplType {
  291.                 Regular,
  292.                 Manager,
  293.                 Supplemental,
  294.                 Unemployed};
  295.  
  296.  
  297. //----------------------- Contructor/Destructor ------------------------------
  298. // Class QueryMgrs  :: QueryMgr()
  299. //----------------------------------------------------------------------------
  300.     QueryMgrs();
  301.     ~QueryMgrs();
  302.  
  303. // QueryGenl&
  304. //    fillPage(GeneralPage & gp);
  305.  
  306. QueryMgrs&
  307.     getMatchList();
  308.  
  309. Boolean
  310.     aMatch(const LEmployeeData* ed,
  311.            const IString& key,
  312.            const IString& value) ;
  313.  
  314.  
  315. };
  316.  
  317.  
  318. //----------------------------------------------------------------------------
  319. // class AcctPage
  320. //----------------------------------------------------------------------------
  321. class QueryAcct : public QueryInfo
  322. {
  323. public: // ---------------------- PUBLIC -------------------------------------
  324.  
  325. //----------------------- Contructor/Destructor ------------------------------
  326. // Class QueryAcct :: QueryAcct()
  327. //----------------------------------------------------------------------------
  328.   QueryAcct();
  329.   ~QueryAcct();
  330.  
  331. QueryAcct&
  332.   fillPage(AccountPage & ac);
  333.  
  334. QueryAcct&
  335.   getMatchList(AccountPage &acctPage);
  336.  
  337. Boolean
  338.   aMatch( LAcctData* ac,
  339.           const IString& key,
  340.           const IString& value) ;
  341.  
  342.  
  343. };
  344.  
  345.  
  346. //----------------------------------------------------------------------------
  347. // class QuerySkill
  348. //----------------------------------------------------------------------------
  349. class QuerySkill: public QueryInfo
  350. {
  351. public: // ---------------------- PUBLIC -------------------------------------
  352.  
  353. //----------------------------------------------------------------------------
  354. // class QuerySkill
  355. //----------------------------------------------------------------------------
  356.   QuerySkill();
  357.   ~QuerySkill();
  358.  
  359. QuerySkill&
  360.   fillPage(SkillPage & sk);
  361.  
  362. QuerySkill&
  363.   getMatchList(SkillPage &skillPage);
  364.  
  365. Boolean
  366.   aMatch( LSkillData* ac
  367.          ,const IString& key
  368.          ,const IString& value
  369.          ,const IString& range="") ;
  370.  
  371. };
  372.  
  373.  
  374. //----------------------------------------------------------------------------
  375. // class QueryBadge
  376. //----------------------------------------------------------------------------
  377. class QueryBadge: public QueryInfo
  378. {
  379. public: // ---------------------- PUBLIC -------------------------------------
  380.  
  381. //----------------------------------------------------------------------------
  382. // class QueryBadge
  383. //----------------------------------------------------------------------------
  384.   QueryBadge();
  385.   ~QueryBadge();
  386.  
  387. QueryBadge&
  388.   fillPage(BadgePage & bd);
  389.  
  390. QueryBadge&
  391.   getMatchList(BadgePage &badgePage);
  392.  
  393. Boolean
  394.   aMatch( LBadgeData* ac
  395.          ,const IString& key
  396.          ,const IString& value
  397.          ,const IString& range="") ;
  398.  
  399.  
  400. };
  401.  
  402.  
  403. //----------------------------------------------------------------------------
  404. // class QueryStatus
  405. //----------------------------------------------------------------------------
  406.  class QueryStatus : public QueryInfo
  407.  {
  408. //----------------------------------------------------------------------------
  409. // class QueryStatus
  410. //----------------------------------------------------------------------------
  411.  
  412. public: // ---------------------- PUBLIC -------------------------------------
  413.  
  414.   QueryStatus();
  415.   ~QueryStatus();
  416.  
  417. QueryStatus&
  418.   fillPage(StatusPage & bd);
  419.  
  420. QueryStatus&
  421.   getMatchList(StatusPage &statusPage);
  422.  
  423. Boolean
  424.   aMatch( LStatusData* ac
  425.          ,const IString& key
  426.          ,const IString& value
  427.          ,const IString& range="") ;
  428.  
  429.  
  430.  
  431. };
  432.  
  433.  
  434. //----------------------------------------------------------------------------
  435. // class QueryQry
  436. //----------------------------------------------------------------------------
  437. class QueryQry :public IBase
  438. {
  439. public: // ---------------------- PUBLIC -------------------------------------
  440.  
  441.  
  442. //----------------------------------------------------------------------------
  443. // class QueryQry
  444. //----------------------------------------------------------------------------
  445.     QueryQry();
  446.     ~QueryQry();
  447.  
  448. inline Boolean
  449.     setNextId(){ itemsCur.setToNext();
  450.                  return itemsCur.isValid();};
  451.  
  452. inline Boolean
  453.     setFirstId(){ itemsCur.setToFirst();
  454.                    return itemsCur.isValid();};
  455.  
  456. inline Boolean
  457.     isValid(){ return itemsCur.isValid();};
  458.  
  459. Boolean
  460.     setLastId();
  461.  
  462. IString
  463.     getQry() ;
  464.  
  465. Boolean
  466.     putQry(  const IString& i1) ;
  467.  
  468. Boolean
  469.     emptyBagQry();
  470.  
  471. private:
  472.  
  473.    getQryNames();
  474.  
  475. Items
  476.     items;
  477.  
  478. Items::Cursor
  479.     itemsCur;
  480.  
  481. };
  482.  
  483. //----------------------------------------------------------------------------
  484. // class QueryIntersection
  485. //----------------------------------------------------------------------------
  486. class QueryIntersection : public Items,
  487.                           public IBase
  488. {
  489. public: // ---------------------- PUBLIC -------------------------------------
  490.  
  491.     QueryIntersection( QueryGenl*   qg
  492.                       ,QuerySkill*  qs
  493.                       ,QueryAcct*   qa
  494.                       ,QueryStatus* qst
  495.                       ,QueryBadge*  qb);
  496.  
  497.     ~QueryIntersection();
  498.  
  499. inline Boolean
  500.     setNextId(){ itemsCur.setToNext();
  501.                  return itemsCur.isValid();};
  502.  
  503. inline Boolean
  504.     setFirstId(){ itemsCur.setToFirst();
  505.                   return itemsCur.isValid();};
  506.  
  507. inline Boolean
  508.     isValid(){ return itemsCur.isValid();};
  509.  
  510. inline Boolean
  511.     isIntersectionEmpty() { return !items.numberOfElements();};
  512.  
  513. IString
  514.     getId() ;
  515.  
  516. Boolean
  517.     putId(  const IString& i1) ;
  518.  
  519. Boolean
  520.     emptyBagIntersection();
  521.  
  522. private:
  523.  
  524.       getQryIds();
  525.  
  526. ItemsBag
  527.     items;
  528.  
  529. ItemsBag::Cursor
  530.     itemsCur;
  531.  
  532. };
  533.  
  534.  
  535. #endif
  536.