1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // CegoDistDbHandler.cc
4 // --------------------
5 // Cego global db handler class implementation
6 //
7 // Design and Implementation by Bjoern Lemke
8 //
9 // (C)opyright 2000-2019 Bjoern Lemke
10 //
11 // IMPLEMENTATION MODULE
12 //
13 // Class: CegoDistDbHandler
14 //
15 // Description: Database client interface to the access the database backend via network
16 //
17 // Status: CLEAN
18 //
19 ///////////////////////////////////////////////////////////////////////////////
20 
21 // LFC INCLUDES
22 #include <lfcbase/Datetime.h>
23 #include <lfcbase/NetHandler.h>
24 #include <lfcxml/Element.h>
25 
26 // CEGO INCLUDES
27 #include "CegoDistDbHandler.h"
28 #include "CegoTypeConverter.h"
29 #include "CegoXMLdef.h"
30 
CegoDistDbHandler(NetHandler * pN,CegoDbHandler::ProtocolType pt,CegoModule * pModule)31 CegoDistDbHandler::CegoDistDbHandler(NetHandler *pN, CegoDbHandler::ProtocolType pt, CegoModule *pModule) : CegoDbHandler(pN, pt, pModule)
32 {
33     _modId = pModule->getModId("CegoDistDbHandler");
34 }
35 
~CegoDistDbHandler()36 CegoDistDbHandler::~CegoDistDbHandler()
37 {
38 }
39 
getDeleteArg(Chain & tableSet,Chain & tableName,CegoPredDesc * & pPred,CegoDistManager * pGTM)40 void CegoDistDbHandler::getDeleteArg(Chain& tableSet, Chain& tableName, CegoPredDesc*& pPred,
41 				     CegoDistManager *pGTM)
42 {
43     if ( _protType == CegoDbHandler::XML )
44     {
45 	Element *pRoot = _xml.getDocument()->getRootElement();
46 	if ( pRoot )
47 	{
48 
49 	    tableSet = pRoot->getAttributeValue(XML_TABLESET_ATTR);
50 	    tableName = _xml.getDocument()->getRootElement()->getAttributeValue(XML_TABLENAME_ATTR);
51 
52 	    ListT<Element*> pel = _xml.getDocument()->getRootElement()->getChildren(XML_PRED_ELEMENT);
53 
54 	    Element **pPE = pel.First();
55 	    if ( pPE )
56 	    {
57 		pPred = new CegoPredDesc(*pPE, pGTM);
58 	    }
59 	}
60     }
61     else
62     {
63 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
64     }
65 }
66 
getUpdateArg(Chain & tableSet,Chain & tableName,ListT<CegoField> & fl,ListT<CegoExpr * > & exprList,CegoPredDesc * & pPred,CegoDistManager * pGTM)67 void CegoDistDbHandler::getUpdateArg(Chain& tableSet,
68 				     Chain& tableName,
69 				     ListT<CegoField>& fl,
70 				     ListT<CegoExpr*>& exprList,
71 				     CegoPredDesc*& pPred,
72 				     CegoDistManager *pGTM)
73 {
74     if ( _protType == CegoDbHandler::XML )
75     {
76 	Element *pRoot = _xml.getDocument()->getRootElement();
77 	if ( pRoot )
78 	{
79 
80 	    tableSet = pRoot->getAttributeValue(XML_TABLESET_ATTR);
81 	    tableName = _xml.getDocument()->getRootElement()->getAttributeValue(XML_TABLENAME_ATTR);
82 
83 	    /*
84 	      Chain lastPageValue = _xml.getDocument()->getRootElement()->getAttributeValue(XML_LASTPAGE_ATTR);
85 
86 	      if ( lastPageValue == Chain(XML_TRUE_VALUE) )
87 	      lastPage = true;
88 	      else
89 	      lastPage = false;
90 	    */
91 
92 	    ListT<Element*> pel = _xml.getDocument()->getRootElement()->getChildren(XML_PRED_ELEMENT);
93 
94 	    Element **pPE = pel.First();
95 	    if ( pPE )
96 	    {
97 		pPred = new CegoPredDesc(*pPE, pGTM);
98 	    }
99 	}
100     }
101     else
102     {
103 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
104     }
105 }
106 
getCreateTableArg(Chain & tableSet,Chain & tableName,ListT<CegoField> & fl,ListT<CegoField> & idxList)107 void CegoDistDbHandler::getCreateTableArg(Chain& tableSet, Chain& tableName, ListT<CegoField>& fl, ListT<CegoField>& idxList)
108 {
109     if ( _protType == CegoDbHandler::XML )
110     {
111 
112 	Element *pRoot = _xml.getDocument()->getRootElement();
113 	if ( pRoot )
114 	{
115 	    tableSet = pRoot->getAttributeValue(XML_TABLESET_ATTR);
116 	    tableName = pRoot->getAttributeValue(XML_TABLENAME_ATTR);
117 
118 	    ListT<Element*> colList = pRoot->getChildren(XML_COL_ELEMENT);
119 
120 	    Element **pCol = colList.First();
121 	    while ( pCol )
122 	    {
123 		Chain colName = (*pCol)->getAttributeValue(XML_COLNAME_ATTR);
124 		Chain colType = (*pCol)->getAttributeValue(XML_COLTYPE_ATTR);
125 		Chain colSize = (*pCol)->getAttributeValue(XML_COLSIZE_ATTR);
126 
127 		CegoTypeConverter tc;
128 		CegoField f(CegoField(tableName, tableName, colName, tc.getTypeId(colType), colSize.asInteger()));
129 		fl.Insert(f);
130 
131 		pCol = colList.Next();
132 	    }
133 	}
134     }
135     else
136     {
137 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
138     }
139 }
140 
getCreateViewArg(Chain & tableSet,Chain & viewName,ListT<CegoField> & fl,Chain & viewText)141 void CegoDistDbHandler::getCreateViewArg(Chain& tableSet, Chain& viewName, ListT<CegoField>& fl, Chain& viewText)
142 {
143     if ( _protType == CegoDbHandler::XML )
144     {
145 
146 	Element *pRoot = _xml.getDocument()->getRootElement();
147 	if ( pRoot )
148 	{
149 	    tableSet = pRoot->getAttributeValue(XML_TABLESET_ATTR);
150 	    viewName = pRoot->getAttributeValue(XML_VIEWNAME_ATTR);
151 	    viewText = pRoot->getAttributeValue(XML_VIEWTEXT_ATTR);
152 
153 	    ListT<Element*> colList = pRoot->getChildren(XML_COL_ELEMENT);
154 
155 	    Element **pCol = colList.First();
156 	    while ( pCol )
157 	    {
158 		Chain colName = (*pCol)->getAttributeValue(XML_COLNAME_ATTR);
159 		Chain colType = (*pCol)->getAttributeValue(XML_COLTYPE_ATTR);
160 		Chain colSize = (*pCol)->getAttributeValue(XML_COLSIZE_ATTR);
161 
162 		CegoTypeConverter tc;
163 		CegoField f(CegoField(viewName, viewName, colName, tc.getTypeId(colType), colSize.asInteger()));
164 		fl.Insert(f);
165 		pCol = colList.Next();
166 	    }
167 	}
168     }
169     else
170     {
171 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
172     }
173 }
174 
getCreateProcedureArg(Chain & tableSet,Chain & procName,Chain & procText)175 void CegoDistDbHandler::getCreateProcedureArg(Chain& tableSet, Chain& procName, Chain& procText)
176 {
177     if ( _protType == CegoDbHandler::XML )
178     {
179 
180 	Element *pRoot = _xml.getDocument()->getRootElement();
181 	if ( pRoot )
182 	{
183 	    tableSet = pRoot->getAttributeValue(XML_TABLESET_ATTR);
184 	    procName = pRoot->getAttributeValue(XML_PROCNAME_ATTR);
185 	    procText = pRoot->getAttributeValue(XML_PROCTEXT_ATTR);
186 	}
187     }
188     else
189     {
190 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
191     }
192 }
193 
getCreateCheckArg(Chain & tableSet,Chain & checkName,Chain & tableName,CegoPredDesc * & pPred,CegoDistManager * pGTM)194 void CegoDistDbHandler::getCreateCheckArg(Chain& tableSet, Chain& checkName, Chain& tableName, CegoPredDesc*& pPred,
195 				     CegoDistManager *pGTM)
196 {
197     if ( _protType == CegoDbHandler::XML )
198     {
199 	Element *pRoot = _xml.getDocument()->getRootElement();
200 	if ( pRoot )
201 	{
202 
203 	    tableSet = pRoot->getAttributeValue(XML_TABLESET_ATTR);
204 	    checkName = _xml.getDocument()->getRootElement()->getAttributeValue(XML_NAME_ATTR);
205 	    tableName = _xml.getDocument()->getRootElement()->getAttributeValue(XML_TABLENAME_ATTR);
206 
207 	    ListT<Element*> pel = _xml.getDocument()->getRootElement()->getChildren(XML_PRED_ELEMENT);
208 
209 	    Element **pPE = pel.First();
210 	    if ( pPE )
211 	    {
212 		pPred = new CegoPredDesc(*pPE, pGTM);
213 	    }
214 	}
215     }
216     else
217     {
218 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
219     }
220 }
221 
getAlterTableArg(Chain & tableSet,Chain & tableName,ListT<CegoAlterDesc> & alterList)222 void CegoDistDbHandler::getAlterTableArg(Chain& tableSet, Chain& tableName, ListT<CegoAlterDesc>& alterList)
223 {
224     if ( _protType == CegoDbHandler::XML )
225     {
226 
227 	Element *pRoot = _xml.getDocument()->getRootElement();
228 	if ( pRoot )
229 	{
230 	    tableSet = pRoot->getAttributeValue(XML_TABLESET_ATTR);
231 	    tableName = pRoot->getAttributeValue(XML_TABLENAME_ATTR);
232 
233 	    ListT<Element*> alterElementList = pRoot->getChildren(XML_ALTER_ELEMENT);
234 
235 	    Element **pAlterElement = alterElementList.First();
236 	    while ( pAlterElement )
237 	    {
238 		CegoAlterDesc ad(*pAlterElement);
239 		alterList.Insert(ad);
240 		pAlterElement = alterElementList.Next();
241 	    }
242 	}
243     }
244     else
245     {
246 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
247     }
248 }
249 
getDropTableArg(Chain & tableSet,Chain & tableName,CegoObject::ObjectType & type)250 void CegoDistDbHandler::getDropTableArg(Chain& tableSet, Chain& tableName, CegoObject::ObjectType& type)
251 {
252     if ( _protType == CegoDbHandler::XML )
253     {
254 	Element *pRoot = _xml.getDocument()->getRootElement();
255 	if ( pRoot )
256 	{
257 	    tableSet = pRoot->getAttributeValue(XML_TABLESET_ATTR);
258 	    tableName = pRoot->getAttributeValue(XML_OBJNAME_ATTR);
259 	    CegoTypeConverter tc;
260 	    type = tc.getObjectTypeId( pRoot->getAttributeValue(XML_OBJTYPE_ATTR) );
261 	}
262     }
263     else
264     {
265 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
266     }
267 }
268 
getCreateIndexArg(Chain & tableSet,Chain & indexName,Chain & tableName,ListT<CegoField> & idxList,CegoObject::ObjectType & type)269 void CegoDistDbHandler::getCreateIndexArg(Chain& tableSet, Chain& indexName, Chain& tableName, ListT<CegoField>& idxList, CegoObject::ObjectType& type)
270 {
271     if ( _protType == CegoDbHandler::XML )
272     {
273 	Element *pRoot = _xml.getDocument()->getRootElement();
274 	if ( pRoot )
275 	{
276 	    tableSet = pRoot->getAttributeValue(XML_TABLESET_ATTR);
277 	    indexName = pRoot->getAttributeValue(XML_INDEXNAME_ATTR);
278 	    tableName = pRoot->getAttributeValue(XML_TABLENAME_ATTR);
279 
280 	    ListT<Element*> colList = pRoot->getChildren(XML_COL_ELEMENT);
281 
282 	    Element **pCol = colList.First();
283 	    while ( pCol )
284 	    {
285 		Chain colName = (*pCol)->getAttributeValue(XML_COLNAME_ATTR);
286 
287 		CegoField f(CegoField(tableName, colName));
288 		idxList.Insert(f);
289 
290 		pCol = colList.Next();
291 	    }
292 
293 	    if ( pRoot->getAttributeValue(XML_INDEXTYPE_ATTR) == Chain(XML_INDEX_VALUE) )
294 		type = CegoObject::AVLTREE;
295 	    else if ( pRoot->getAttributeValue(XML_INDEXTYPE_ATTR) == Chain(XML_PINDEX_VALUE) )
296 		type = CegoObject::PAVLTREE;
297 	    else if ( pRoot->getAttributeValue(XML_INDEXTYPE_ATTR) == Chain(XML_UINDEX_VALUE) )
298 		type = CegoObject::UAVLTREE;
299 	}
300     }
301     else
302     {
303 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
304     }
305 }
306 
getObjectInfoArg(int & tabSetId,Chain & tableName,CegoObject::ObjectType & type)307 void CegoDistDbHandler::getObjectInfoArg(int& tabSetId, Chain& tableName, CegoObject::ObjectType& type)
308 {
309     if ( _protType == CegoDbHandler::XML )
310     {
311 	Element *pRoot = _xml.getDocument()->getRootElement();
312 	if ( pRoot )
313 	{
314 	    tabSetId = pRoot->getAttributeValue(XML_TSID_ATTR).asInteger();
315 	    tableName = pRoot->getAttributeValue(XML_OBJNAME_ATTR);
316 
317 	    CegoTypeConverter tc;
318 	    type = tc.getObjectTypeId( pRoot->getAttributeValue(XML_OBJTYPE_ATTR) );
319 	}
320     }
321     else
322     {
323 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
324     }
325 }
326 
getGetTableArg(int & tabSetId,Chain & tableName,CegoObject::ObjectType & type)327 void CegoDistDbHandler::getGetTableArg(int& tabSetId, Chain& tableName, CegoObject::ObjectType& type)
328 {
329     if ( _protType == CegoDbHandler::XML )
330     {
331 	Element *pRoot = _xml.getDocument()->getRootElement();
332 	if ( pRoot )
333 	{
334 	    tabSetId = pRoot->getAttributeValue(XML_TSID_ATTR).asInteger();
335 	    tableName = pRoot->getAttributeValue(XML_TABLENAME_ATTR);
336 
337 	    CegoTypeConverter tc;
338 	    type = tc.getObjectTypeId(pRoot->getAttributeValue(XML_TABLETYPE_ATTR));
339 
340 	}
341     }
342     else
343     {
344 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
345     }
346 }
347 
getRenameArg(Chain & tableSet,Chain & objName,CegoObject::ObjectType & type,Chain & newObjName)348 void CegoDistDbHandler::getRenameArg(Chain& tableSet, Chain& objName, CegoObject::ObjectType& type, Chain& newObjName)
349 {
350     if ( _protType == CegoDbHandler::XML )
351     {
352 	Element *pRoot = _xml.getDocument()->getRootElement();
353 	if ( pRoot )
354 	{
355 	    tableSet = pRoot->getAttributeValue(XML_TABLESET_ATTR);
356 	    objName = pRoot->getAttributeValue(XML_OBJNAME_ATTR);
357 
358 	    CegoTypeConverter tc;
359 	    type = tc.getObjectTypeId(pRoot->getAttributeValue(XML_TABLETYPE_ATTR));
360 
361 	    newObjName = pRoot->getAttributeValue(XML_NEWOBJNAME_ATTR);
362 
363 	}
364     }
365     else
366     {
367 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
368     }
369 }
370 
getReorgArg(Chain & tableSet,Chain & objName,CegoObject::ObjectType & type)371 void CegoDistDbHandler::getReorgArg(Chain& tableSet, Chain& objName, CegoObject::ObjectType& type)
372 {
373     if ( _protType == CegoDbHandler::XML )
374     {
375 	Element *pRoot = _xml.getDocument()->getRootElement();
376 	if ( pRoot )
377 	{
378 	    tableSet = pRoot->getAttributeValue(XML_TABLESET_ATTR);
379 	    objName = pRoot->getAttributeValue(XML_OBJNAME_ATTR);
380 
381 	    CegoTypeConverter tc;
382 	    type = tc.getObjectTypeId(pRoot->getAttributeValue(XML_TABLETYPE_ATTR));
383 	}
384     }
385     else
386     {
387 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
388     }
389 }
390 
getGetObjectListArg(int & tabSetId,CegoObject::ObjectType & type)391 void CegoDistDbHandler::getGetObjectListArg(int& tabSetId, CegoObject::ObjectType& type)
392 {
393     if ( _protType == CegoDbHandler::XML )
394     {
395 	Element *pRoot = _xml.getDocument()->getRootElement();
396 	if ( pRoot )
397 	{
398 	    tabSetId = pRoot->getAttributeValue(XML_TSID_ATTR).asInteger();
399 
400 	    CegoTypeConverter tc;
401 	    type = tc.getObjectTypeId(pRoot->getAttributeValue(XML_TABLETYPE_ATTR));
402 	}
403     }
404     else
405     {
406 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
407     }
408 }
409 
getGetObjectByTableListArg(Chain & tableSet,Chain & tableName)410 void CegoDistDbHandler::getGetObjectByTableListArg(Chain& tableSet, Chain& tableName)
411 {
412     if ( _protType == CegoDbHandler::XML )
413     {
414 	Element *pRoot = _xml.getDocument()->getRootElement();
415 	if ( pRoot )
416 	{
417 	    tableSet = pRoot->getAttributeValue(XML_TABLESET_ATTR);
418 	    tableName = pRoot->getAttributeValue(XML_TABLENAME_ATTR);
419 	}
420     }
421     else
422     {
423 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
424     }
425 }
426 
getSyncArg(Chain & tableSet,Chain & escCmd,int & timeout)427 void CegoDistDbHandler::getSyncArg(Chain& tableSet, Chain& escCmd, int& timeout)
428 {
429     if ( _protType == CegoDbHandler::XML )
430     {
431 	Element *pRoot = _xml.getDocument()->getRootElement();
432 	if ( pRoot )
433 	{
434 	    tableSet = pRoot->getAttributeValue(XML_TABLESET_ATTR);
435 	    escCmd = pRoot->getAttributeValue(XML_ESCCMD_ATTR);
436 	    timeout = pRoot->getAttributeValue(XML_TIMEOUT_ATTR).asInteger();
437 	}
438     }
439     else
440     {
441 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
442     }
443 }
444 
getPageCountArg(Chain & tableSet,Chain & objName,CegoObject::ObjectType & type)445 void CegoDistDbHandler::getPageCountArg(Chain& tableSet, Chain& objName, CegoObject::ObjectType& type)
446 {
447     if ( _protType == CegoDbHandler::XML )
448     {
449 	Element *pRoot = _xml.getDocument()->getRootElement();
450 	if ( pRoot )
451 	{
452 	    tableSet = pRoot->getAttributeValue(XML_TABLESET_ATTR);
453 	    objName = pRoot->getAttributeValue(XML_OBJNAME_ATTR);
454 
455 	    CegoTypeConverter tc;
456 	    type = tc.getObjectTypeId(pRoot->getAttributeValue(XML_OBJTYPE_ATTR));
457 	}
458     }
459     else
460     {
461 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
462     }
463 }
464 
reqInsertOp(const Chain & tableSet,const Chain & tableName,const ListT<CegoField> & fl)465 CegoDistDbHandler::ResultType CegoDistDbHandler::reqInsertOp(const Chain& tableSet, const Chain& tableName, const ListT<CegoField>& fl)
466 {
467     if ( _protType == CegoDbHandler::XML )
468     {
469 	_xml.getDocument()->clear();
470 
471 	Element* pRoot = new Element(XML_FRAME_ELEMENT);
472 	pRoot->setAttribute(XML_TABLENAME_ATTR, tableName);
473 	pRoot->setAttribute(XML_TABLESET_ATTR, tableSet);
474 
475 	CegoField *pF = fl.First();
476 	while ( pF )
477 	{
478 	    Element *pColElement = new Element(XML_COL_ELEMENT);
479 	    pColElement->setAttribute(XML_COLNAME_ATTR, pF->getAttrName());
480 	    pColElement->setAttribute(XML_COLVAL_ATTR, pF->getValue().valAsChain());
481 
482 	    CegoTypeConverter tc;
483 	    pColElement->setAttribute(XML_COLTYPE_ATTR, tc.getTypeString(pF->getType()));
484 
485 	    pRoot->addContent(pColElement);
486 	    pF = fl.Next();
487 	}
488 
489 	_xml.getDocument()->setRootElement(pRoot);
490 	_xml.getDocument()->setDocType(XML_INSERT_REQUEST);
491 
492 	Chain request;
493 	_xml.getXMLChain(request);
494 
495 	_pN->setMsg(request, request.length());
496 
497 	_pN->writeMsg();
498 
499 	_pN->readMsg();
500 
501 	_xml.getDocument()->clear();
502 	_xml.setChain( _pN->getMsg() );
503 	_xml.parse();
504 
505 	Chain docType = _xml.getDocument()->getDocType();
506 
507 	if ( docType == Chain(XML_OK_DOC) )
508 	{
509 	    return DB_OK;
510 	}
511 	else if ( docType == Chain(XML_ERROR_DOC) )
512 	{
513 	    return DB_ERROR;
514 	}
515 	else
516 	{
517 	    throw Exception(EXLOC, Chain("Invalid document type"));
518 	}
519     }
520     else
521     {
522 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
523     }
524 }
525 
reqUpdateOp(const Chain & tableSet,const Chain & tableName,const ListT<CegoField> & updSchema,const ListT<CegoExpr * > & exprList,CegoPredDesc * pPred)526 CegoDistDbHandler::ResultType CegoDistDbHandler::reqUpdateOp(const Chain& tableSet,
527 							     const Chain& tableName,
528 							     const ListT<CegoField>& updSchema,
529 							     const ListT<CegoExpr*>& exprList,
530 							     CegoPredDesc* pPred)
531 {
532     if ( _protType == CegoDbHandler::XML )
533     {
534 	Element* pRoot = new Element(XML_FRAME_ELEMENT);
535 
536 	pRoot->setAttribute(XML_TABLESET_ATTR, tableSet);
537 	pRoot->setAttribute(XML_TABLENAME_ATTR, tableName);
538 
539 	CegoField *pF = updSchema.First();
540 	while ( pF )
541 	{
542 	    pRoot->addContent(pF->toElement());
543 	    pF = updSchema.Next();
544 	}
545 	CegoExpr **pExpr = exprList.First();
546 	while ( pExpr )
547 	{
548 	    pRoot->addContent((*pExpr)->toElement());
549 	    pExpr = exprList.Next();
550 	}
551 
552 	pRoot->addContent(pPred->toElement());
553 
554 	return sendXMLReq(XML_UPDATE_REQUEST, pRoot);
555     }
556     else
557     {
558 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
559     }
560 }
561 
reqDeleteOp(const Chain & tableSet,const Chain & tableName,CegoPredDesc * pPred)562 CegoDistDbHandler::ResultType CegoDistDbHandler::reqDeleteOp(const Chain& tableSet, const Chain& tableName, CegoPredDesc* pPred)
563 {
564     if ( _protType == CegoDbHandler::XML )
565     {
566 	Element* pRoot = new Element(XML_FRAME_ELEMENT);
567 
568 	pRoot->setAttribute(XML_TABLESET_ATTR, tableSet);
569 	pRoot->setAttribute(XML_TABLENAME_ATTR, tableName);
570 
571 	pRoot->addContent(pPred->toElement());
572 
573 	return sendXMLReq(XML_DELETE_REQUEST, pRoot);
574     }
575     else
576     {
577 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
578     }
579 }
580 
reqCreateTableOp(const Chain & tableSet,const Chain & tableName,CegoObject::ObjectType type,const ListT<CegoField> & fl,const ListT<CegoField> & idxList)581 CegoDistDbHandler::ResultType CegoDistDbHandler::reqCreateTableOp(const Chain& tableSet, const Chain& tableName, CegoObject::ObjectType type,
582 								  const ListT<CegoField>& fl, const ListT<CegoField>& idxList)
583 {
584     if ( _protType == CegoDbHandler::XML )
585     {
586 	Element* pRoot = new Element(XML_FRAME_ELEMENT);
587 
588 	pRoot->setAttribute(XML_TABLESET_ATTR, tableSet);
589 	pRoot->setAttribute(XML_TABLENAME_ATTR, tableName);
590 
591 	CegoField *pF = fl.First();
592 	while ( pF )
593 	{
594 	    Element *pColElement = new Element(XML_COL_ELEMENT);
595 	    pColElement->setAttribute(XML_COLNAME_ATTR, pF->getAttrName());
596 
597 	    CegoTypeConverter tc;
598 	    pColElement->setAttribute(XML_COLTYPE_ATTR, tc.getTypeString(pF->getType()));
599 	    pColElement->setAttribute(XML_COLSIZE_ATTR, Chain(pF->getLength()));
600 
601 	    pRoot->addContent(pColElement);
602 	    pF = fl.Next();
603 	}
604 	return sendXMLReq(XML_CREATETABLE_REQUEST, pRoot);
605     }
606     else
607     {
608 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
609     }
610 }
611 
reqAlterTableOp(const Chain & tableSet,const Chain & tableName,const ListT<CegoAlterDesc> & alterList)612 CegoDistDbHandler::ResultType CegoDistDbHandler::reqAlterTableOp(const Chain& tableSet, const Chain& tableName, const ListT<CegoAlterDesc>& alterList)
613 {
614     if ( _protType == CegoDbHandler::XML )
615     {
616 	Element* pRoot = new Element(XML_FRAME_ELEMENT);
617 
618 	pRoot->setAttribute(XML_TABLESET_ATTR, tableSet);
619 	pRoot->setAttribute(XML_TABLENAME_ATTR, tableName);
620 
621 	CegoAlterDesc *pAD = alterList.First();
622 	while ( pAD )
623 	{
624 	    pRoot->addContent(pAD->toElement());
625 	    pAD = alterList.Next();
626 	}
627 
628 	return sendXMLReq(XML_ALTERTABLE_REQUEST, pRoot);
629     }
630     else
631     {
632 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
633     }
634 }
635 
reqCreateIndexOp(const Chain & tableSet,const Chain & indexName,const Chain & tableName,CegoObject::ObjectType type,const ListT<CegoField> & idxList)636 CegoDistDbHandler::ResultType CegoDistDbHandler::reqCreateIndexOp(const Chain& tableSet,
637 								  const Chain& indexName,
638 								  const Chain& tableName,
639 								  CegoObject::ObjectType type,
640 								  const ListT<CegoField>& idxList)
641 {
642     if ( _protType == CegoDbHandler::XML )
643     {
644 	Element* pRoot = new Element(XML_FRAME_ELEMENT);
645 
646 	pRoot->setAttribute(XML_TABLESET_ATTR, tableSet);
647 	pRoot->setAttribute(XML_INDEXNAME_ATTR, indexName);
648 	pRoot->setAttribute(XML_TABLENAME_ATTR, tableName);
649 	if ( type == CegoObject::AVLTREE )
650 	    pRoot->setAttribute(XML_INDEXTYPE_ATTR, XML_INDEX_VALUE);
651 	else if ( type == CegoObject::PAVLTREE )
652 	    pRoot->setAttribute(XML_INDEXTYPE_ATTR, XML_PINDEX_VALUE);
653 	else if ( type == CegoObject::UAVLTREE )
654 	    pRoot->setAttribute(XML_INDEXTYPE_ATTR, XML_UINDEX_VALUE);
655 
656 	CegoField *pF = idxList.First();
657 	while ( pF )
658 	{
659 	    Element *pColElement = new Element(XML_COL_ELEMENT);
660 	    pColElement->setAttribute(XML_COLNAME_ATTR, pF->getAttrName());
661 
662 	    pRoot->addContent(pColElement);
663 	    pF = idxList.Next();
664 	}
665 
666 	return sendXMLReq(XML_CREATEINDEX_REQUEST, pRoot);
667     }
668     else
669     {
670 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
671     }
672 }
673 
reqCreateFKeyOp(int tabSetId,const Chain & fkey,const Chain & tableName,const ListT<CegoField> & keyList,const Chain & refTable,const ListT<CegoField> & refList)674 CegoDistDbHandler::ResultType CegoDistDbHandler::reqCreateFKeyOp(int tabSetId, const Chain& fkey,
675 								 const Chain& tableName,
676 								 const ListT<CegoField>& keyList,
677 								 const Chain& refTable,
678 								 const ListT<CegoField>& refList)
679 {
680     if ( _protType == CegoDbHandler::XML )
681     {
682 	Element* pRoot = new Element(XML_FRAME_ELEMENT);
683 
684 	pRoot->setAttribute(XML_TSID_ATTR, Chain(tabSetId));
685 	pRoot->setAttribute(XML_FKEY_ATTR, fkey);
686 	pRoot->setAttribute(XML_TABLENAME_ATTR, tableName);
687 	pRoot->setAttribute(XML_REFTABLENAME_ATTR, refTable);
688 
689 	CegoField *pK = keyList.First();
690 	while ( pK )
691 	{
692 	    Element *pColElement = new Element(XML_KEY_ELEMENT);
693 	    pColElement->setAttribute(XML_COLNAME_ATTR, pK->getAttrName());
694 
695 	    pRoot->addContent(pColElement);
696 	    pK = keyList.Next();
697 	}
698 
699 	CegoField *pR = refList.First();
700 	while ( pR )
701 	{
702 	    Element *pColElement = new Element(XML_REF_ELEMENT);
703 	    pColElement->setAttribute(XML_COLNAME_ATTR, pR->getAttrName());
704 
705 	    pRoot->addContent(pColElement);
706 	    pR = refList.Next();
707 	}
708 
709 	return sendXMLReq(XML_CREATE_FKEY_REQUEST, pRoot);
710     }
711     else
712     {
713 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
714     }
715 }
716 
reqTableDataOp(int tabSetId,const Chain & tableName,CegoObject::ObjectType type)717 CegoDistDbHandler::ResultType CegoDistDbHandler::reqTableDataOp(int tabSetId, const Chain& tableName, CegoObject::ObjectType type)
718 {
719     if ( _protType == CegoDbHandler::XML )
720     {
721 	Element* pRoot = new Element(XML_FRAME_ELEMENT);
722 	pRoot->setAttribute(XML_TSID_ATTR, Chain(tabSetId));
723 	pRoot->setAttribute(XML_TABLENAME_ATTR, tableName);
724 
725 	CegoTypeConverter tc;
726 	pRoot->setAttribute(XML_TABLETYPE_ATTR,  tc.getObjectTypeString(type));
727 
728 	return sendXMLReq(XML_GETTABLE_REQUEST, pRoot);
729     }
730     else
731     {
732 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
733     }
734 }
735 
reqGetObjectListOp(int tabSetId,CegoObject::ObjectType type)736 CegoDistDbHandler::ResultType CegoDistDbHandler::reqGetObjectListOp(int tabSetId, CegoObject::ObjectType type)
737 {
738     if ( _protType == CegoDbHandler::XML )
739     {
740 	Element* pRoot = new Element(XML_FRAME_ELEMENT);
741 	pRoot->setAttribute(XML_TSID_ATTR, Chain(tabSetId));
742 
743 	CegoTypeConverter tc;
744 	pRoot->setAttribute(XML_TABLETYPE_ATTR, tc.getObjectTypeString(type));
745 
746 	return sendXMLReq(XML_GETOBJLIST_REQUEST, pRoot);
747     }
748     else
749     {
750 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
751     }
752 }
753 
reqGetObjectByTableListOp(const Chain & tableSet,const Chain & tableName)754 CegoDistDbHandler::ResultType CegoDistDbHandler::reqGetObjectByTableListOp(const Chain& tableSet, const Chain& tableName)
755 {
756     if ( _protType == CegoDbHandler::XML )
757     {
758 	Element* pRoot = new Element(XML_FRAME_ELEMENT);
759 	pRoot->setAttribute(XML_TABLESET_ATTR, tableSet);
760 	pRoot->setAttribute(XML_TABLENAME_ATTR, tableName);
761 
762 	return sendXMLReq(XML_GETOBJLISTBYTABLE_REQUEST, pRoot);
763     }
764     else
765     {
766 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
767     }
768 }
769 
reqRenameOp(const Chain & tableSet,const Chain & objName,CegoObject::ObjectType type,const Chain & newObjName)770 CegoDistDbHandler::ResultType CegoDistDbHandler::reqRenameOp(const Chain& tableSet, const Chain& objName, CegoObject::ObjectType type, const Chain& newObjName)
771 {
772     if ( _protType == CegoDbHandler::XML )
773     {
774 	Element* pRoot = new Element(XML_FRAME_ELEMENT);
775 	pRoot->setAttribute(XML_TABLESET_ATTR, tableSet);
776 	pRoot->setAttribute(XML_OBJNAME_ATTR, objName);
777 
778 	CegoTypeConverter tc;
779 	pRoot->setAttribute(XML_TYPE_ATTR, tc.getObjectTypeString(type));
780 	pRoot->setAttribute(XML_NEWOBJNAME_ATTR, newObjName);
781 
782 	return sendXMLReq(XML_OBJRENAME_REQUEST, pRoot);
783     }
784     else
785     {
786 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
787     }
788 }
789 
reqSyncOp(const Chain & tableSet,const Chain & escCmd,int timeout)790 CegoDistDbHandler::ResultType CegoDistDbHandler::reqSyncOp(const Chain& tableSet, const Chain& escCmd, int timeout)
791 {
792     if ( _protType == CegoDbHandler::XML )
793     {
794 	Element* pRoot = new Element(XML_FRAME_ELEMENT);
795 	pRoot->setAttribute(XML_TABLESET_ATTR, tableSet);
796 	pRoot->setAttribute(XML_ESCCMD_ATTR, escCmd);
797 	pRoot->setAttribute(XML_TIMEOUT_ATTR, Chain(timeout));
798 
799 	return sendXMLReq(XML_SYNC_REQUEST, pRoot);
800     }
801     else
802     {
803 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
804     }
805 }
806 
reqGetPageCount(const Chain & tableSet,const Chain & objName,CegoObject::ObjectType type)807 CegoDistDbHandler::ResultType CegoDistDbHandler::reqGetPageCount(const Chain& tableSet, const Chain& objName, CegoObject::ObjectType type)
808 {
809     if ( _protType == CegoDbHandler::XML )
810     {
811 	Element* pRoot = new Element(XML_FRAME_ELEMENT);
812 	pRoot->setAttribute(XML_TABLESET_ATTR, tableSet);
813 	pRoot->setAttribute(XML_OBJNAME_ATTR, objName);
814 
815 	CegoTypeConverter tc;
816 	pRoot->setAttribute(XML_OBJTYPE_ATTR, tc.getObjectTypeString(type));
817 
818 	return sendXMLReq(XML_GETPAGECOUNT_REQUEST, pRoot);
819     }
820     else
821     {
822 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
823     }
824 }
825 
reqReorgObjectOp(const Chain & tableSet,const Chain & objName,CegoObject::ObjectType type)826 CegoDistDbHandler::ResultType CegoDistDbHandler::reqReorgObjectOp(const Chain& tableSet, const Chain& objName, CegoObject::ObjectType type)
827 {
828     if ( _protType == CegoDbHandler::XML )
829     {
830 
831 	Element* pRoot = new Element(XML_FRAME_ELEMENT);
832 	pRoot->setAttribute(XML_TABLESET_ATTR, tableSet);
833 	pRoot->setAttribute(XML_OBJNAME_ATTR, objName);
834 
835 	CegoTypeConverter tc;
836 	pRoot->setAttribute(XML_TYPE_ATTR, tc.getObjectTypeString(type));
837 
838 	return sendXMLReq(XML_REORG_REQUEST, pRoot);
839     }
840     else
841     {
842 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
843     }
844 }
845 
reqCreateCheckOp(const Chain & tableSet,const Chain & checkName,const Chain & tableName,CegoPredDesc * pPred)846 CegoDistDbHandler::ResultType CegoDistDbHandler::reqCreateCheckOp(const Chain& tableSet, const Chain& checkName, const Chain& tableName, CegoPredDesc* pPred)
847 {
848     if ( _protType == CegoDbHandler::XML )
849     {
850 
851 	Element* pRoot = new Element(XML_FRAME_ELEMENT);
852 
853 	pRoot->setAttribute(XML_NAME_ATTR, checkName);
854 	pRoot->setAttribute(XML_TABLESET_ATTR, tableSet);
855 	pRoot->setAttribute(XML_TABLENAME_ATTR, tableName);
856 	pRoot->addContent(pPred->toElement());
857 
858 	return sendXMLReq(XML_CREATECHECK_REQUEST, pRoot);
859     }
860     else
861     {
862 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
863     }
864 }
865 
reqObjectInfoOp(int tabSetId,const Chain & objName,CegoObject::ObjectType type)866 CegoDistDbHandler::ResultType CegoDistDbHandler::reqObjectInfoOp(int tabSetId, const Chain& objName, CegoObject::ObjectType type)
867 {
868     if ( _protType == CegoDbHandler::XML )
869     {
870 	Element* pRoot = new Element(XML_FRAME_ELEMENT);
871 
872 	pRoot->setAttribute(XML_TSID_ATTR, Chain(tabSetId));
873 	pRoot->setAttribute(XML_OBJNAME_ATTR, objName);
874 
875 	CegoTypeConverter tc;
876 	pRoot->setAttribute(XML_OBJTYPE_ATTR, tc.getObjectTypeString(type));
877 
878 	return sendXMLReq(XML_OBJECTINFO_REQUEST, pRoot);
879     }
880     else
881     {
882 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
883     }
884 }
885 
reqDropObjectOp(const Chain & tableSet,const Chain & objName,CegoObject::ObjectType type)886 CegoDistDbHandler::ResultType CegoDistDbHandler::reqDropObjectOp(const Chain& tableSet, const Chain& objName, CegoObject::ObjectType type)
887 {
888     if ( _protType == CegoDbHandler::XML )
889     {
890 	Element* pRoot = new Element(XML_FRAME_ELEMENT);
891 
892 	pRoot->setAttribute(XML_TABLESET_ATTR, tableSet);
893 	pRoot->setAttribute(XML_OBJNAME_ATTR, objName);
894 
895 	CegoTypeConverter tc;
896 	pRoot->setAttribute(XML_OBJTYPE_ATTR, tc.getObjectTypeString(type));
897 
898 	return sendXMLReq(XML_DROP_OBJECT_REQUEST, pRoot);
899     }
900     else
901     {
902 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
903     }
904 }
905 
reqCreateViewOp(const Chain & tableSet,const Chain & viewName,const ListT<CegoField> & fl,const Chain & viewText)906 CegoDistDbHandler::ResultType CegoDistDbHandler::reqCreateViewOp(const Chain& tableSet, const Chain& viewName, const ListT<CegoField>& fl, const Chain& viewText)
907 {
908     if ( _protType == CegoDbHandler::XML )
909     {
910 	Element* pRoot = new Element(XML_FRAME_ELEMENT);
911 	pRoot->setAttribute(XML_TABLESET_ATTR, tableSet);
912 	pRoot->setAttribute(XML_VIEWNAME_ATTR, viewName);
913 	pRoot->setAttribute(XML_VIEWTEXT_ATTR, viewText);
914 
915 	CegoField *pF = fl.First();
916 	while ( pF )
917 	{
918 	    Element *pColElement = new Element(XML_COL_ELEMENT);
919 	    pColElement->setAttribute(XML_COLNAME_ATTR, pF->getAttrName());
920 
921 	    CegoTypeConverter tc;
922 	    pColElement->setAttribute(XML_COLTYPE_ATTR, tc.getTypeString(pF->getType()));
923 	    pColElement->setAttribute(XML_COLSIZE_ATTR, Chain(pF->getLength()));
924 
925 	    pRoot->addContent(pColElement);
926 	    pF = fl.Next();
927 	}
928 
929 	return sendXMLReq(XML_CREATEVIEW_REQUEST, pRoot);
930     }
931     else
932     {
933 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
934     }
935 }
936 
reqCreateProcOp(const Chain & tableSet,const Chain & procName,const Chain & procText)937 CegoDistDbHandler::ResultType CegoDistDbHandler::reqCreateProcOp(const Chain& tableSet, const Chain& procName, const Chain& procText)
938 {
939     if ( _protType == CegoDbHandler::XML )
940     {
941 	Element* pRoot = new Element(XML_FRAME_ELEMENT);
942 	pRoot->setAttribute(XML_TABLESET_ATTR, tableSet);
943 	pRoot->setAttribute(XML_PROCNAME_ATTR, procName);
944 	pRoot->setAttribute(XML_PROCTEXT_ATTR, procText);
945 	return sendXMLReq(XML_CREATEPROCEDURE_REQUEST, pRoot);
946     }
947     else
948     {
949 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
950     }
951 }
952 
reqCreateTriggerOp(const Chain & tableSet,const Chain & triggerName,const Chain & tableName,const Chain & triggerText)953 CegoDistDbHandler::ResultType CegoDistDbHandler::reqCreateTriggerOp(const Chain& tableSet, const Chain& triggerName, const Chain& tableName, const Chain& triggerText)
954 {
955     if ( _protType == CegoDbHandler::XML )
956     {
957 	Element* pRoot = new Element(XML_FRAME_ELEMENT);
958 	pRoot->setAttribute(XML_TABLESET_ATTR, tableSet);
959 	pRoot->setAttribute(XML_TRIGGERNAME_ATTR, triggerName);
960 	pRoot->setAttribute(XML_TABLENAME_ATTR, tableName);
961 	pRoot->setAttribute(XML_TRIGGERTEXT_ATTR, triggerText);
962 	return sendXMLReq(XML_CREATETRIGGER_REQUEST, pRoot);
963     }
964     else
965     {
966 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
967     }
968 }
969 
reqStartTransactionOp(const Chain & tableSet)970 CegoDistDbHandler::ResultType CegoDistDbHandler::reqStartTransactionOp(const Chain& tableSet)
971 {
972     if ( _protType == CegoDbHandler::XML )
973     {
974 	Element* pRoot = new Element(XML_FRAME_ELEMENT);
975 	pRoot->setAttribute(XML_TABLESET_ATTR, tableSet);
976 	return sendXMLReq(XML_STARTTRANSACTION_REQUEST, pRoot);
977     }
978     else
979     {
980 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
981     }
982 }
983 
reqCommitTransactionOp(const Chain & tableSet)984 CegoDistDbHandler::ResultType CegoDistDbHandler::reqCommitTransactionOp(const Chain& tableSet)
985 {
986     if ( _protType == CegoDbHandler::XML )
987     {
988 	Element* pRoot = new Element(XML_FRAME_ELEMENT);
989 	pRoot->setAttribute(XML_TABLESET_ATTR, tableSet);
990 	return sendXMLReq(XML_COMMITTRANSACTION_REQUEST, pRoot);
991     }
992     else
993     {
994 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
995     }
996 }
997 
reqRollbackTransactionOp(const Chain & tableSet)998 CegoDistDbHandler::ResultType CegoDistDbHandler::reqRollbackTransactionOp(const Chain& tableSet)
999 {
1000     if ( _protType == CegoDbHandler::XML )
1001     {
1002 	Element* pRoot = new Element(XML_FRAME_ELEMENT);
1003 	pRoot->setAttribute(XML_TABLESET_ATTR, tableSet);
1004 	return sendXMLReq(XML_ROLLBACKTRANSACTION_REQUEST, pRoot);
1005     }
1006     else
1007     {
1008 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
1009     }
1010 }
1011 
reqGetTidOp(const Chain & tableSet)1012 CegoDistDbHandler::ResultType CegoDistDbHandler::reqGetTidOp(const Chain& tableSet)
1013 {
1014     if ( _protType == CegoDbHandler::XML )
1015     {
1016 	Element* pRoot = new Element(XML_FRAME_ELEMENT);
1017 	pRoot->setAttribute(XML_TABLESET_ATTR, tableSet);
1018 	return sendXMLReq(XML_GETTID_REQUEST, pRoot);
1019     }
1020     else
1021     {
1022 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
1023     }
1024 }
1025 
getArgValue(const Chain & arg,Chain & value)1026 void CegoDistDbHandler::getArgValue(const Chain& arg, Chain& value)
1027 {
1028     if ( _protType == CegoDbHandler::XML )
1029     {
1030 	Element *pRoot = _xml.getDocument()->getRootElement();
1031 	if ( pRoot )
1032 	{
1033 	    value = pRoot->getAttributeValue(arg);
1034 	}
1035     }
1036     else
1037     {
1038 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
1039     }
1040 }
1041 
getInsertArg(Chain & tableSet,Chain & tableName,ListT<CegoField> & fl)1042 void CegoDistDbHandler::getInsertArg(Chain& tableSet, Chain& tableName, ListT<CegoField>& fl)
1043 {
1044     if ( _protType == CegoDbHandler::XML )
1045     {
1046 	Element *pRoot = _xml.getDocument()->getRootElement();
1047 	if ( pRoot )
1048 	{
1049 
1050 	    tableSet = pRoot->getAttributeValue(XML_TABLESET_ATTR);
1051 	    tableName = pRoot->getAttributeValue(XML_TABLENAME_ATTR);
1052 
1053 	    ListT<Element*> colList = pRoot->getChildren(XML_COL_ELEMENT);
1054 
1055 	    Element **pCol = colList.First();
1056 	    while ( pCol )
1057 	    {
1058 		Chain colName = (*pCol)->getAttributeValue(XML_COLNAME_ATTR);
1059 		Chain colType = (*pCol)->getAttributeValue(XML_COLTYPE_ATTR);
1060 		Chain colVal = (*pCol)->getAttributeValue(XML_COLVAL_ATTR);
1061 
1062 		CegoField f(CegoField(tableName, colName));
1063 
1064 		CegoTypeConverter tc;
1065 		CegoDataType type;
1066 		type = tc.getTypeId(colType);
1067 
1068 		CegoFieldValue fv(type, colVal);
1069 
1070 		f.setValue(fv);
1071 		fl.Insert(f);
1072 
1073 		pCol = colList.Next();
1074 	    }
1075 	}
1076     }
1077     else
1078     {
1079 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
1080     }
1081 }
1082 
sendObjList(const ListT<Chain> & objList)1083 void CegoDistDbHandler::sendObjList(const ListT<Chain>& objList)
1084 {
1085 #ifdef DEBUG
1086     _pModule->log(_modId, Logger::DEBUG, Chain("Sending object info"));
1087 #endif
1088 
1089     if ( _protType == CegoDbHandler::XML )
1090     {
1091 	_xml.getDocument()->clear();
1092 
1093 	Element* pRoot = new Element(XML_FRAME_ELEMENT);
1094 
1095 	Chain *pObj = objList.First();
1096 	while ( pObj )
1097 	{
1098 	    Element *pObjElement = new Element(XML_OBJ_ELEMENT);
1099 	    pObjElement->setAttribute(XML_NAME_ATTR, *pObj);
1100 
1101 	    pRoot->addContent(pObjElement);
1102 	    pObj = objList.Next();
1103 	}
1104 
1105 	_xml.getDocument()->setRootElement(pRoot);
1106 	_xml.getDocument()->setDocType(XML_INFO_DOC);
1107 
1108 	Chain response;
1109 	_xml.getXMLChain(response);
1110 
1111 #ifdef DEBUG
1112 	_pModule->log(_modId, Logger::DEBUG, Chain("--- XML ---"));
1113 	_pModule->log(_modId, Logger::DEBUG, response);
1114 	_pModule->log(_modId, Logger::DEBUG, Chain("--- --- ---"));
1115 #endif
1116 
1117 	_pN->setMsg((char*)response, response.length());
1118 	_pN->writeMsg();
1119 
1120 	_xml.getDocument()->clear();
1121     }
1122     else
1123     {
1124 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
1125     }
1126 }
1127 
sendObjByTableList(const ListT<CegoTableObject> & idxList,const ListT<CegoKeyObject> & keyList,const ListT<CegoCheckObject> & checkList)1128 void CegoDistDbHandler::sendObjByTableList(const ListT<CegoTableObject>& idxList,
1129 					   const ListT<CegoKeyObject>& keyList,
1130 					   const ListT<CegoCheckObject>& checkList)
1131 {
1132     if ( _protType == CegoDbHandler::XML )
1133     {
1134 	_xml.getDocument()->clear();
1135 
1136 	Element* pRoot = new Element(XML_FRAME_ELEMENT);
1137 
1138 	CegoTableObject *pIdx = idxList.First();
1139 	while ( pIdx )
1140 	{
1141 	    pRoot->addContent(pIdx->getElement());
1142 	    pIdx = idxList.Next();
1143 	}
1144 
1145 	CegoKeyObject *pKey = keyList.First();
1146 	while ( pKey )
1147 	{
1148 	    pRoot->addContent(pKey->getElement());
1149 	    pKey = keyList.Next();
1150 	}
1151 
1152 	CegoCheckObject *pCheck = checkList.First();
1153 	while ( pCheck )
1154 	{
1155 	    pRoot->addContent(pCheck->getElement());
1156 	    pCheck = checkList.Next();
1157 	}
1158 
1159 	_xml.getDocument()->setRootElement(pRoot);
1160 	_xml.getDocument()->setDocType(XML_INFO_DOC);
1161 
1162 	Chain response;
1163 	_xml.getXMLChain(response);
1164 
1165 
1166 #ifdef DEBUG
1167 	_pModule->log(_modId, Logger::DEBUG, Chain("--- XML ---"));
1168 	_pModule->log(_modId, Logger::DEBUG, response);
1169 	_pModule->log(_modId, Logger::DEBUG, Chain("--- --- ---"));
1170 #endif
1171 
1172 	_pN->setMsg((char*)response, response.length());
1173 	_pN->writeMsg();
1174 
1175 	_xml.getDocument()->clear();
1176     }
1177     else
1178     {
1179 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
1180     }
1181 }
1182 
sendTID(int tid)1183 void CegoDistDbHandler::sendTID(int tid)
1184 {
1185     if ( _protType == CegoDbHandler::XML )
1186     {
1187 
1188 	_xml.getDocument()->clear();
1189 
1190 	Element* pRoot = new Element(XML_FRAME_ELEMENT);
1191 
1192 	pRoot->setAttribute(XML_TID_ATTR, Chain(tid));
1193 
1194 	_xml.getDocument()->setRootElement(pRoot);
1195 	_xml.getDocument()->setDocType(XML_INFO_DOC);
1196 
1197 	Chain response;
1198 	_xml.getXMLChain(response);
1199 
1200 #ifdef DEBUG
1201 	_pModule->log(_modId, Logger::DEBUG, Chain("--- XML ---"));
1202 	_pModule->log(_modId, Logger::DEBUG, response);
1203 	_pModule->log(_modId, Logger::DEBUG, Chain("--- --- ---"));
1204 #endif
1205 
1206 	_pN->setMsg((char*)response, response.length());
1207 	_pN->writeMsg();
1208 
1209 	_xml.getDocument()->clear();
1210     }
1211     else
1212     {
1213 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
1214     }
1215 }
1216 
sendPageCount(int pageCount)1217 void CegoDistDbHandler::sendPageCount(int pageCount)
1218 {
1219     if ( _protType == CegoDbHandler::XML )
1220     {
1221 	_xml.getDocument()->clear();
1222 
1223 	Element* pRoot = new Element(XML_FRAME_ELEMENT);
1224 
1225 	pRoot->setAttribute(XML_PAGECOUNT_ATTR, Chain(pageCount));
1226 
1227 	_xml.getDocument()->setRootElement(pRoot);
1228 	_xml.getDocument()->setDocType(XML_INFO_DOC);
1229 
1230 	Chain response;
1231 	_xml.getXMLChain(response);
1232 
1233 #ifdef DEBUG
1234 	_pModule->log(_modId, Logger::DEBUG, Chain("--- XML ---"));
1235 	_pModule->log(_modId, Logger::DEBUG, response);
1236 	_pModule->log(_modId, Logger::DEBUG, Chain("--- --- ---"));
1237 #endif
1238 
1239 	_pN->setMsg((char*)response, response.length());
1240 	_pN->writeMsg();
1241 
1242 	_xml.getDocument()->clear();
1243     }
1244     else
1245     {
1246 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
1247     }
1248 }
1249 
getObjectList(ListT<Chain> & objList)1250 void CegoDistDbHandler::getObjectList(ListT<Chain>& objList)
1251 {
1252     if ( _protType == CegoDbHandler::XML )
1253     {
1254 
1255 	Element *pRoot = _xml.getDocument()->getRootElement();
1256 	if ( pRoot )
1257 	{
1258 	    ListT<Element*> objElementList = pRoot->getChildren(XML_OBJ_ELEMENT);
1259 
1260 	    Element **pObjEntry = objElementList.First();
1261 	    while ( pObjEntry )
1262 	    {
1263 		objList.Insert((*pObjEntry)->getAttributeValue(XML_NAME_ATTR));
1264 		pObjEntry = objElementList.Next();
1265 	    }
1266 	}
1267     }
1268     else
1269     {
1270 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
1271     }
1272 }
1273 
getObjectByTableList(ListT<CegoTableObject> & idxList,ListT<CegoKeyObject> & keyList,ListT<CegoCheckObject> & checkList)1274 void CegoDistDbHandler::getObjectByTableList(ListT<CegoTableObject>& idxList,
1275 					     ListT<CegoKeyObject>& keyList,
1276 					     ListT<CegoCheckObject>& checkList)
1277 {
1278     if ( _protType == CegoDbHandler::XML )
1279     {
1280 	Element *pRoot = _xml.getDocument()->getRootElement();
1281 	if ( pRoot )
1282 	{
1283 	    ListT<Element*> objElementList = pRoot->getChildren(XML_OBJ_ELEMENT);
1284 
1285 	    Element **pObjEntry = objElementList.First();
1286 	    while ( pObjEntry )
1287 	    {
1288 
1289 		CegoTypeConverter tc;
1290 		CegoObject::ObjectType type = tc.getObjectTypeId((*pObjEntry)->getAttributeValue(XML_OBJTYPE_ATTR));
1291 
1292 		switch ( type )
1293 		{
1294 		case CegoObject::AVLTREE:
1295 		case CegoObject::PAVLTREE:
1296 		case CegoObject::UAVLTREE:
1297 		{
1298 		    CegoTableObject io;
1299 		    io.putElement(*pObjEntry);
1300 		    idxList.Insert(io);
1301 		    break;
1302 		}
1303 		case CegoObject::FKEY:
1304 		{
1305 		    CegoKeyObject ko;
1306 		    ko.putElement(*pObjEntry);
1307 		    keyList.Insert(ko);
1308 		    break;
1309 		}
1310 		case CegoObject::CHECK:
1311 		{
1312 		    CegoCheckObject co;
1313 		    co.putElement(*pObjEntry);
1314 		    checkList.Insert(co);
1315 		    break;
1316 		}
1317 		case CegoObject::SYSTEM:
1318 		case CegoObject::TABLE:
1319 		case CegoObject::VIEW:
1320 		case CegoObject::RBSEG:
1321 		case CegoObject::PROCEDURE:
1322 		case CegoObject::JOIN:
1323 		case CegoObject::PBTREE:
1324 		case CegoObject::UBTREE:
1325 		case CegoObject::BTREE:
1326 		case CegoObject::TRIGGER:
1327 		case CegoObject::ALIAS:
1328 		case CegoObject::UNDEFINED:
1329 		{
1330 		    break;
1331 		}
1332 		}
1333 
1334 		pObjEntry = objElementList.Next();
1335 	    }
1336 	}
1337     }
1338     else
1339     {
1340 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
1341     }
1342 }
1343 
getPageCount(int & pageCount)1344 void CegoDistDbHandler::getPageCount(int& pageCount)
1345 {
1346     if ( _protType == CegoDbHandler::XML )
1347     {
1348 	Element *pRoot = _xml.getDocument()->getRootElement();
1349 	if ( pRoot )
1350 	{
1351 	    pageCount = pRoot->getAttributeValue(XML_PAGECOUNT_ATTR).asInteger();
1352 	}
1353     }
1354     else
1355     {
1356 	throw Exception(EXLOC, Chain("Serial protocol still not supported"));
1357     }
1358 }
1359