1 | /***********************************************************************/ |
2 | /* JMgoConn.h : header file for the MongoDB connection classes. */ |
3 | /***********************************************************************/ |
4 | |
5 | /***********************************************************************/ |
6 | /* Java interface. */ |
7 | /***********************************************************************/ |
8 | #include "javaconn.h" |
9 | |
10 | // Java connection to a MongoDB data source |
11 | class TDBJMG; |
12 | class JMGCOL; |
13 | |
14 | /***********************************************************************/ |
15 | /* Include MongoDB library header files. */ |
16 | /***********************************************************************/ |
17 | typedef class JNCOL *PJNCOL; |
18 | typedef class MGODEF *PMGODEF; |
19 | typedef class TDBJMG *PTDBJMG; |
20 | typedef class JMGCOL *PJMGCOL; |
21 | |
22 | typedef struct JKCOL { |
23 | JKCOL *Next; |
24 | PJNCOL Jncolp; |
25 | PCOL Colp; |
26 | char *Key; |
27 | int N; |
28 | } *PJKC; |
29 | |
30 | /***********************************************************************/ |
31 | /* Used when inserting values in a MongoDB collection. */ |
32 | /***********************************************************************/ |
33 | class JNCOL : public BLOCK { |
34 | public: |
35 | // Constructor |
36 | JNCOL(bool ar) { Klist = NULL; Array = ar; } |
37 | |
38 | // Methods |
39 | void AddCol(PGLOBAL g, PCOL colp, PSZ jp); |
40 | |
41 | //Members |
42 | PJKC Klist; |
43 | bool Array; |
44 | }; // end of JNCOL; |
45 | |
46 | /***********************************************************************/ |
47 | /* JMgoConn class. */ |
48 | /***********************************************************************/ |
49 | class JMgoConn : public JAVAConn { |
50 | friend class TDBJMG; |
51 | friend class JMGDISC; |
52 | //friend class TDBXJDC; |
53 | //friend PQRYRES GetColumnInfo(PGLOBAL, char*&, char *, int, PVBLK&); |
54 | private: |
55 | JMgoConn(); // Standard (unused) constructor |
56 | |
57 | public: |
58 | // Constructor |
59 | JMgoConn(PGLOBAL g, PCSZ collname, PCSZ wrapper); |
60 | |
61 | // Implementation |
62 | public: |
63 | virtual void AddJars(PSTRG jpop, char sep); |
64 | virtual bool Connect(PJPARM sop); |
65 | virtual bool MakeCursor(PGLOBAL g, PTDB tdbp, PCSZ options, PCSZ filter, bool pipe); |
66 | // PQRYRES AllocateResult(PGLOBAL g, TDBEXT *tdbp, int n); |
67 | |
68 | // Attributes |
69 | public: |
70 | // virtual int GetMaxValue(int infotype); |
71 | |
72 | public: |
73 | // Operations |
74 | virtual int Fetch(int pos = 0); |
75 | virtual PSZ GetColumnValue(PSZ name); |
76 | |
77 | int CollSize(PGLOBAL g); |
78 | bool FindCollection(PCSZ query, PCSZ proj); |
79 | bool AggregateCollection(PCSZ pipeline); |
80 | void MakeColumnGroups(PGLOBAL g, PTDB tdbp); |
81 | bool GetMethodId(PGLOBAL g, MODE mode); |
82 | jobject MakeObject(PGLOBAL g, PCOL colp, bool& error); |
83 | jobject MakeDoc(PGLOBAL g, PJNCOL jcp); |
84 | int DocWrite(PGLOBAL g); |
85 | int DocUpdate(PGLOBAL g, PTDB tdbp); |
86 | int DocDelete(PGLOBAL g, bool all); |
87 | bool Rewind(void); |
88 | PSZ GetDocument(void); |
89 | |
90 | protected: |
91 | // Members |
92 | PCSZ CollName; // The collation name |
93 | jmethodID gcollid; // The GetCollection method ID |
94 | jmethodID countid; // The GetCollSize method ID |
95 | jmethodID fcollid; // The FindColl method ID |
96 | jmethodID acollid; // The AggregateColl method ID |
97 | jmethodID readid; // The ReadNext method ID |
98 | jmethodID fetchid; // The Fetch method ID |
99 | jmethodID rewindid; // The Rewind method ID |
100 | jmethodID getdocid; // The GetDoc method ID |
101 | jmethodID objfldid; // The ObjectField method ID |
102 | jmethodID mkdocid; // The MakeDocument method ID |
103 | jmethodID docaddid; // The DocAdd method ID |
104 | jmethodID mkarid; // The MakeArray method ID |
105 | jmethodID araddid; // The ArrayAdd method ID |
106 | jmethodID insertid; // The CollInsert method ID |
107 | jmethodID updateid; // The CollUpdate method ID |
108 | jmethodID deleteid; // The CollDelete method ID |
109 | PJNCOL Fpc; // To JNCOL classes |
110 | int m_Fetch; |
111 | int m_Ncol; |
112 | int m_Version; // Java driver version (2 or 3) |
113 | }; // end of JMgoConn class definition |
114 | |