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

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