summaryrefslogtreecommitdiffstats
path: root/storage/connect/jmgoconn.h
blob: 9fed1907abc87a206e601fefc9f2c17d428de3db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/***********************************************************************/
/*  JMgoConn.h : header file for the MongoDB connection classes.       */
/***********************************************************************/

/***********************************************************************/
/*  Java interface.                                                    */
/***********************************************************************/
#include "javaconn.h"

// Java connection to a MongoDB data source
class TDBJMG;
class JMGCOL;

/***********************************************************************/
/*  Include MongoDB library header files.                       	  	 */
/***********************************************************************/
typedef class JNCOL  *PJNCOL;
typedef class MGODEF *PMGODEF;
typedef class TDBJMG *PTDBJMG;
typedef class JMGCOL *PJMGCOL;

typedef struct JKCOL {
	JKCOL *Next;
	PJNCOL Jncolp;
	PCOL   Colp;
	char  *Key;
	int    N;
	bool   Array;
} *PJKC;

/***********************************************************************/
/*  Used when inserting values in a MongoDB collection.                */
/***********************************************************************/
class JNCOL : public BLOCK {
public:
	// Constructor
//JNCOL(bool ar) { Klist = NULL; Array = ar; }
	JNCOL(void) { Klist = NULL; }

	// Methods
	void AddCol(PGLOBAL g, PCOL colp, PSZ jp);

	//Members
	PJKC   Klist;
}; // end of JNCOL;

/***********************************************************************/
/*  JMgoConn class.                                                    */
/***********************************************************************/
class JMgoConn : public JAVAConn {
	friend class TDBJMG;
	friend class JMGDISC;
	//friend class TDBXJDC;
	//friend PQRYRES GetColumnInfo(PGLOBAL, char*&, char *, int, PVBLK&);
private:
	JMgoConn();                      // Standard (unused) constructor

public:
	// Constructor
	JMgoConn(PGLOBAL g, PCSZ collname, PCSZ wrapper);

	// Implementation
public:
	virtual void AddJars(PSTRG jpop, char sep);
	virtual bool Connect(PJPARM sop);
	virtual bool MakeCursor(PGLOBAL g, PTDB tdbp, PCSZ options, PCSZ filter, bool pipe);
//	PQRYRES AllocateResult(PGLOBAL g, TDBEXT *tdbp, int n);

	// Attributes
public:
//	virtual int   GetMaxValue(int infotype);

public:
	// Operations
	virtual int  Fetch(int pos = 0);
	virtual PSZ  GetColumnValue(PSZ name);

	int     CollSize(PGLOBAL g);
	bool    FindCollection(PCSZ query, PCSZ proj);
	bool    AggregateCollection(PCSZ pipeline);
	void    MakeColumnGroups(PGLOBAL g, PTDB tdbp);
	bool    GetMethodId(PGLOBAL g, MODE mode);
	jobject MakeObject(PGLOBAL g, PCOL colp, bool& error);
	jobject MakeDoc(PGLOBAL g, PJNCOL jcp);
	int     DocWrite(PGLOBAL g, PCSZ line);
	int     DocUpdate(PGLOBAL g, PTDB tdbp);
	int     DocDelete(PGLOBAL g, bool all);
	bool    Rewind(void);
	PSZ     GetDocument(void);
	bool    Stringify(PCOL colp);

protected:
	// Members
	PCSZ      CollName;									// The collation name
	jmethodID gcollid;								// The GetCollection method ID
	jmethodID countid;								  // The GetCollSize method ID
	jmethodID fcollid;									// The FindColl method ID
	jmethodID acollid;									// The AggregateColl method ID
	jmethodID readid;										// The ReadNext method ID
	jmethodID fetchid;									// The Fetch method ID
	jmethodID rewindid;									// The Rewind method ID
	jmethodID getdocid;									// The GetDoc method ID
	jmethodID objfldid;									// The ObjectField method ID
	jmethodID mkdocid;									// The MakeDocument method ID
	jmethodID mkbsonid;								  // The MakeBson method ID
	jmethodID docaddid;									// The DocAdd method ID
	jmethodID mkarid;										// The MakeArray method ID
	jmethodID araddid;									// The ArrayAdd method ID
	jmethodID insertid;									// The CollInsert method ID
	jmethodID updateid;									// The CollUpdate method ID
	jmethodID deleteid;									// The CollDelete method ID
	PJNCOL    Fpc;				              // To JNCOL classes
	int       m_Fetch;
	int       m_Ncol;
	int       m_Version;								// Java driver version (2 or 3)
}; // end of JMgoConn class definition