Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

dbobjdefinition.cpp

Go to the documentation of this file.
00001 //============================================================================= 
00002 //
00003 // XDFLengine library
00004 //
00005 //----------------------------------------------------------------------------- 
00006 //  DBOBJDEFINITION.CPP
00007 //----------------------------------------------------------------------------- 
00013 //_____________________________________________________________________________
00014 //
00015 //  Copyright (C) 2003 Guillaume Baurand. All Rights Reserved.
00016 //
00017 //  This file is part of the XDFLengine project.
00018 //
00019 //  The XDFLengine is free software; you can redistribute it and/or modify
00020 //  it under the terms of the GNU General Public License as published by
00021 //  the Free Software Foundation; either version 2 of the License, or
00022 //  (at your option) any later version.
00023 //
00024 //  This program is distributed in the hope that it will be useful,
00025 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00026 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00027 //  GNU General Public License for more details.
00028 //
00029 //  You should have received a copy of the GNU General Public License
00030 //  along with this program; if not, write to the Free Software
00031 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
00032 //  USA.
00033 //
00034 //  For more information, 
00035 //      contact  : guillaume@baurand.net 
00036 //      or visit : http://xdflengine.sourceforge.net
00037 //
00038 //=============================================================================
00039 
00040 #   include "dbobjdefinition.hpp"
00041 #   include "flow/consumers/streamsax2parser.hpp"
00042 #   include "streamers/db/dbstreamerfactory.hpp"
00043 
00044 BEGIN_XDFLENGINE_NS
00045 
00046 //============================================================================= 
00047 //  CLASS DBOBJDEFINITIONFIELD
00048 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00049 
00050     //  CONSTRUCTOR & DESTRUCTOR
00051 
00052     //_________________________________________________________________________
00053     //  DBOBJDEFINITIONFIELD
00054     //-------------------------------------------------------------------------
00055     DBOBJDefinitionField::DBOBJDefinitionField()
00056     {
00057         // Reset key flags
00058         m_boolAttribute=false;
00059         m_boolIsPkey=false;
00060         m_boolHidden=false;
00061 
00062         // Reset string members
00063         m_pszValue =        importCharBuffer( 0, DBOBJDEFFIELD_NOVALUE);
00064         m_pszDValue =       importCharBuffer( 0, DBOBJDEFFIELD_NOVALUE);
00065         m_pszUValue =       importCharBuffer( 0, DBOBJDEFFIELD_NOVALUE);
00066         m_pszIValue =       importCharBuffer( 0, DBOBJDEFFIELD_NOVALUE);
00067         m_pszMap =          importCharBuffer( 0, "");
00068         m_pszDBAlias =      importCharBuffer( 0, "");
00069         m_pszDBField =      importCharBuffer( 0, "");
00070         m_pszName =         importCharBuffer( 0, "");
00071         m_pszDBSpecProps =  importCharBuffer( 0, "");
00072         m_pszDateFormat =   importCharBuffer( 0, "");
00073 
00074         // Reset objects Members
00075         m_DBOBJParentNode=0;
00076 
00077         DEBUG_CREATE(DBOBJDefinitionField)
00078     }
00079 
00080     //_________________________________________________________________________
00081     //  ~DBOBJDEFINITIONFIELD
00082     //-------------------------------------------------------------------------
00083     DBOBJDefinitionField::~DBOBJDefinitionField()
00084     {
00085         DEBUG_DEL(DBOBJDefinitionField)
00086 
00087 
00088         // Reset key flags
00089         m_boolAttribute=false;
00090         m_boolIsPkey=false;
00091         m_boolHidden=false;
00092 
00093         // Reset string members
00094         m_pszValue = releaseCharBuffer( m_pszValue);
00095         m_pszDValue = releaseCharBuffer( m_pszDValue);
00096         m_pszUValue = releaseCharBuffer( m_pszUValue);
00097         m_pszIValue = releaseCharBuffer( m_pszIValue);
00098         m_pszMap = releaseCharBuffer( m_pszMap);
00099         m_pszDBAlias = releaseCharBuffer( m_pszDBAlias);
00100         m_pszDBField = releaseCharBuffer( m_pszDBField);
00101         m_pszName = releaseCharBuffer( m_pszName);
00102         m_pszDBSpecProps = releaseCharBuffer( m_pszDBSpecProps);
00103         m_pszDateFormat = releaseCharBuffer( m_pszDateFormat);
00104 
00105         // Reset objects Members
00106         m_DBOBJParentNode=0;
00107     }
00108 
00109     //  GETTERS
00110 
00111     //_________________________________________________________________________
00112     //  GETNAME
00113     //-------------------------------------------------------------------------
00114     const char* DBOBJDefinitionField::getName() const       
00115     {   
00116         DEBUG_FUNC(DBOBJDefinitionField::getName)    
00117         return exportCharBuffer( m_pszName);           
00118     }
00119 
00120     //_________________________________________________________________________
00121     //  GETDBFIELD
00122     //-------------------------------------------------------------------------
00123     const char* DBOBJDefinitionField::getDBField() const    
00124     {   
00125         DEBUG_FUNC(DBOBJDefinitionField::getDBField)
00126         return exportCharBuffer( m_pszDBField); 
00127     }
00128 
00129     //_________________________________________________________________________
00130     //  GETDBALIAS
00131     //-------------------------------------------------------------------------
00132     const char* DBOBJDefinitionField::getDBAlias() const    
00133     {   
00134         DEBUG_FUNC(DBOBJDefinitionField::getDBAlias)    
00135         return exportCharBuffer( m_pszDBAlias);     
00136     }
00137 
00138     //_________________________________________________________________________
00139     //  GETMAP
00140     //-------------------------------------------------------------------------
00141     const char* DBOBJDefinitionField::getMap() const        
00142     {
00143         DEBUG_FUNC(DBOBJDefinitionField::getMap)        
00144         return exportCharBuffer( m_pszMap);         
00145     }
00146 
00147     //_________________________________________________________________________
00148     //  GETIVALUE
00149     //-------------------------------------------------------------------------
00150     const char* DBOBJDefinitionField::getIValue() const   
00151     {
00152         DEBUG_FUNC(DBOBJDefinitionField::getIValue)  
00153         return exportCharBuffer( m_pszIValue);   
00154     }
00155 
00156     //_________________________________________________________________________
00157     //  GETUVALUE
00158     //-------------------------------------------------------------------------
00159     const char* DBOBJDefinitionField::getUValue() const   
00160     {   
00161         DEBUG_FUNC(DBOBJDefinitionField::getUValue)  
00162         return exportCharBuffer( m_pszUValue);   
00163     }
00164 
00165     //_________________________________________________________________________
00166     //  GETDVALUE
00167     //-------------------------------------------------------------------------
00168     const char* DBOBJDefinitionField::getDValue() const   
00169     {   
00170         DEBUG_FUNC(DBOBJDefinitionField::getDValue)  
00171         return exportCharBuffer( m_pszDValue);   
00172     }
00173 
00174     //_________________________________________________________________________
00175     //  GETVALUE
00176     //-------------------------------------------------------------------------
00177     const char* DBOBJDefinitionField::getValue() const     
00178     {   
00179         DEBUG_FUNC(DBOBJDefinitionField::getValue)    
00180         return exportCharBuffer( m_pszValue);     
00181     }
00182     
00183     //_________________________________________________________________________
00184     //  GETDATEFORMAT
00185     //-------------------------------------------------------------------------
00186     const char* DBOBJDefinitionField::getDateFormat() const    
00187     {   
00188         DEBUG_FUNC(DBOBJDefinitionField::getDateFormat)   
00189         return exportCharBuffer( m_pszDateFormat);    
00190     }   
00191 
00192     //_________________________________________________________________________
00193     //  GETDBSPECPROPS
00194     //-------------------------------------------------------------------------
00195     const char* DBOBJDefinitionField::getDBSpecProps() const
00196     {   
00197         DEBUG_FUNC(DBOBJDefinitionField::getDBSpecProps)      
00198         return exportCharBuffer( m_pszDBSpecProps);   
00199     }
00200 
00201     //_________________________________________________________________________
00202     //  ISATTRIBUTE
00203     //-------------------------------------------------------------------------
00204     bool DBOBJDefinitionField::isAttribute() const    
00205     {   
00206         DEBUG_FUNC(DBOBJDefinitionField::isAttribute)      
00207         return m_boolAttribute; 
00208     }
00209 
00210     //_________________________________________________________________________
00211     //  ISHIDDEN
00212     //-------------------------------------------------------------------------
00213     bool DBOBJDefinitionField::isHidden() const  
00214     {   
00215         DEBUG_FUNC(DBOBJDefinitionField::IsHidden)    
00216         return m_boolHidden; 
00217     }
00218 
00219     //_________________________________________________________________________
00220     //  ISPKEY
00221     //-------------------------------------------------------------------------
00222     bool DBOBJDefinitionField::isPkey() const      
00223     {   
00224         DEBUG_FUNC(DBOBJDefinitionField::isPkey)        
00225         return m_boolIsPkey; 
00226     }
00227 
00228     //_________________________________________________________________________
00229     //  GETPARENT
00230     //-------------------------------------------------------------------------
00231     DBOBJDefinitionNode* DBOBJDefinitionField::getParent() const
00232     {
00233         DEBUG_FUNC(DBOBJDefinitionField::getParent())
00234         return m_DBOBJParentNode;
00235     }
00236 
00237     //  SETTERS
00238 
00239     //_________________________________________________________________________
00240     //  SETNAME
00241     //-------------------------------------------------------------------------
00242     void DBOBJDefinitionField::setName( const char* p_pszName)
00243     {
00244         DEBUG_FUNC(DBOBJDefinitionField::setName)
00245         m_pszName = importCharBuffer( m_pszName, p_pszName);
00246     }
00247 
00248     //_________________________________________________________________________
00249     //  SETDBFIELD
00250     //-------------------------------------------------------------------------
00251     void DBOBJDefinitionField::setDBField( const char* p_pszDBField)
00252     {
00253         DEBUG_FUNC(DBOBJDefinitionField::setDBField)
00254         m_pszDBField = importCharBuffer( m_pszDBField, p_pszDBField);
00255     }
00256 
00257     //_________________________________________________________________________
00258     //  SETDBALIAS
00259     //-------------------------------------------------------------------------
00260     void DBOBJDefinitionField::setDBAlias( const char* p_pszDBAlias)
00261     {
00262         DEBUG_FUNC(DBOBJDefinitionField::setDBAlias)
00263         m_pszDBAlias = importCharBuffer( m_pszDBAlias, p_pszDBAlias);
00264     }
00265 
00266     //_________________________________________________________________________
00267     //  SETMAP
00268     //-------------------------------------------------------------------------
00269     void DBOBJDefinitionField::setMap( const char* p_pszMap)
00270     {
00271         DEBUG_FUNC(DBOBJDefinitionField::setMap)
00272         m_pszMap = importCharBuffer( m_pszMap, p_pszMap);
00273     }
00274 
00275     //_________________________________________________________________________
00276     //  SETIVALUE
00277     //-------------------------------------------------------------------------
00278     void DBOBJDefinitionField::setIValue( const char* p_pszIValue)
00279     {
00280         DEBUG_FUNC(DBOBJDefinitionField::setIValue)
00281         m_pszIValue = importCharBuffer( m_pszIValue, p_pszIValue);
00282     }
00283 
00284     //_________________________________________________________________________
00285     //  SETUVALUE
00286     //-------------------------------------------------------------------------
00287     void DBOBJDefinitionField::setUValue( const char* p_pszUValue)
00288     {
00289         DEBUG_FUNC(DBOBJDefinitionField::setUValue)
00290         m_pszUValue = importCharBuffer( m_pszUValue, p_pszUValue);
00291     }
00292 
00293     //_________________________________________________________________________
00294     //  SETDVALUE
00295     //-------------------------------------------------------------------------
00296     void DBOBJDefinitionField::setDValue( const char* p_pszDValue)
00297     {
00298         DEBUG_FUNC(DBOBJDefinitionField::setDValue)
00299         m_pszDValue = importCharBuffer( m_pszDValue, p_pszDValue);
00300     }
00301 
00302     //_________________________________________________________________________
00303     //  SETVALUE
00304     //-------------------------------------------------------------------------
00305     void DBOBJDefinitionField::setValue( const char* p_pszValue)
00306     {
00307         DEBUG_FUNC(DBOBJDefinitionField::setValue)
00308         m_pszValue = importCharBuffer( m_pszValue, p_pszValue);
00309     }
00310     
00311     //_________________________________________________________________________
00312     //  SETDATEFORMAT
00313     //-------------------------------------------------------------------------
00314     void DBOBJDefinitionField::setDateFormat( const char* p_pszDateFormat)
00315     {
00316         DEBUG_FUNC(DBOBJDefinitionField::setValue)
00317         m_pszDateFormat = importCharBuffer( m_pszDateFormat, p_pszDateFormat);
00318     }   
00319 
00320     //_________________________________________________________________________
00321     //  SETDBSPECPROPS
00322     //-------------------------------------------------------------------------
00323     void DBOBJDefinitionField::setDBSpecProps( const char* p_pszDBSpecProps)
00324     {
00325         DEBUG_FUNC(DBOBJDefinitionField::setValue)
00326         m_pszDBSpecProps = importCharBuffer( m_pszDBSpecProps, p_pszDBSpecProps);
00327     }
00328 
00329     //_________________________________________________________________________
00330     //  SETATTRIBUTE
00331     //-------------------------------------------------------------------------
00332     void DBOBJDefinitionField::setAttribute( bool p_boolAttribute)
00333     {
00334         DEBUG_FUNC(DBOBJDefinitionField::setAttribute)
00335         m_boolAttribute = p_boolAttribute;
00336     }
00337 
00338     //_________________________________________________________________________
00339     //  SETHIDDEN
00340     //-------------------------------------------------------------------------
00341     void DBOBJDefinitionField::setHidden( bool p_boolHidden)
00342     {
00343         DEBUG_FUNC(DBOBJDefinitionField::setHidden)
00344         m_boolHidden = p_boolHidden;
00345     }
00346 
00347     //_________________________________________________________________________
00348     //  SETPKEY
00349     //-------------------------------------------------------------------------
00350     void DBOBJDefinitionField::setPkey( bool p_boolPkey)
00351     {
00352         DEBUG_FUNC(DBOBJDefinitionField::setPkey)
00353         m_boolIsPkey = p_boolPkey;
00354     }
00355 
00356     //_________________________________________________________________________
00357     //  SETPARENT
00358     //-------------------------------------------------------------------------
00359     void DBOBJDefinitionField::setParent(DBOBJDefinitionNode* p_pParentDefinition) 
00360     {
00361         DEBUG_FUNC(DBOBJDefinitionField::setParent)
00362         m_DBOBJParentNode = p_pParentDefinition;
00363     }
00364 
00365     // FUNCTIONNALITIES
00366 
00367     //_________________________________________________________________________
00368     //  GETXML
00369     //-------------------------------------------------------------------------
00370     void DBOBJDefinitionField::getXML(XMLStreamConsumer* p_pXMLBufOut)
00371     {
00372         DEBUG_FUNC(DBOBJDefinitionField::getXML)
00373 
00374         // write field props
00375         (* p_pXMLBufOut) << "\t<" << DBOBJDEFFIELD_TAGNAME << " ";
00376         (* p_pXMLBufOut) << DBOBJDEFFIELD_NAME  << "=\"" << getName()       << "\" ";
00377         (* p_pXMLBufOut) << DBOBJDEFFIELD_FIELD << "=\"" << getDBField()    << "\" ";
00378         (* p_pXMLBufOut) << DBOBJDEFFIELD_MAP   << "=\"" << getMap()        << "\" ";
00379         if ( strcmp( getMap(), DBOBJDEFFIELD_MAP_DATE ) == 0 )  (* p_pXMLBufOut) << DBOBJDEFFIELD_DATE_FORMAT   << "=\"" << getDateFormat() << "\" ";
00380         if( strcmp( getValue(), DBOBJDEFFIELD_NOVALUE ) != 0 )  (* p_pXMLBufOut) << DBOBJDEFFIELD_VALUE         << "=\"" << getValue()      << "\" ";
00381         if( strcmp( getIValue(), DBOBJDEFFIELD_NOVALUE ) != 0 ) (* p_pXMLBufOut) << DBOBJDEFFIELD_IVALUE        << "=\"" << getIValue()     << "\" ";
00382         if( strcmp( getUValue(), DBOBJDEFFIELD_NOVALUE ) != 0 ) (* p_pXMLBufOut) << DBOBJDEFFIELD_UVALUE        << "=\"" << getIValue()     << "\" ";
00383         if( strcmp( getDValue(), DBOBJDEFFIELD_NOVALUE ) != 0 ) (* p_pXMLBufOut) << DBOBJDEFFIELD_DVALUE        << "=\"" << getUValue()     << "\" ";
00384         if( isHidden() )    (* p_pXMLBufOut) << DBOBJDEFFIELD_HIDDEN << "=\"" << REQ_TRUE << "\" ";
00385         else                (* p_pXMLBufOut) << DBOBJDEFFIELD_HIDDEN << "=\"" << REQ_FALSE << "\" ";
00386         if( strlen( getDBSpecProps() ) >0) (* p_pXMLBufOut) << DBOBJDEFFIELD_DBSPEC << "=\"" << getDBSpecProps() << "\" ";
00387 
00388         // close field
00389         (* p_pXMLBufOut) << "/>\n";
00390     }
00391 
00392 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00393 //=============================================================================
00394 
00395 
00396 
00397 //============================================================================= 
00398 //  CLASS DBOBJDEFINITIONNODE
00399 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00400 
00401     //  CONSTRUCTOR & DESTRUCTOR
00402 
00403     //_________________________________________________________________________
00404     //  DBOBJDEFINITIONNODE
00405     //-------------------------------------------------------------------------
00406     DBOBJDefinitionNode::DBOBJDefinitionNode()
00407 
00408     {
00409         m_boolLocked=false;
00410         m_pszCheckPost = importCharBuffer( 0, "");
00411         m_pszCheckPre = importCharBuffer( 0, "");
00412         m_pszRestrict = importCharBuffer( 0, "");
00413         m_pszDBTable = importCharBuffer( 0, "");
00414         m_pszName = importCharBuffer( 0, "");
00415         m_pszOnInsert = importCharBuffer( 0, "");
00416         m_pszOnUpdate = importCharBuffer( 0, "");
00417         m_pszOnDelete = importCharBuffer( 0, "");
00418 
00419         m_DBOBJParentNode=0;
00420 
00421         DEBUG_CREATE(DBOBJDefinitionNode)
00422     }
00423 
00424     //_________________________________________________________________________
00425     //  ~DBOBJDEFINITIONNODE
00426     //-------------------------------------------------------------------------
00427     DBOBJDefinitionNode::~DBOBJDefinitionNode()
00428 
00429     {
00430         DEBUG_DEL(DBOBJDefinitionNode)
00431 
00432         m_boolLocked=false;
00433         m_pszCheckPost = releaseCharBuffer( m_pszCheckPost);
00434         m_pszCheckPre = releaseCharBuffer( m_pszCheckPre);
00435         m_pszRestrict = releaseCharBuffer( m_pszRestrict);
00436         m_pszDBTable = releaseCharBuffer( m_pszDBTable);
00437         m_pszName = releaseCharBuffer( m_pszName);
00438         m_pszOnDelete = releaseCharBuffer( m_pszOnDelete);
00439         m_pszOnUpdate = releaseCharBuffer( m_pszOnUpdate);
00440         m_pszOnInsert = releaseCharBuffer( m_pszOnInsert);
00441 
00442         deleteTree();
00443 
00444         m_DBOBJParentNode=0;
00445     }
00446 
00447     //  GETTERS
00448 
00449     //_________________________________________________________________________
00450     //  GETNAME
00451     //-------------------------------------------------------------------------
00452     const char* DBOBJDefinitionNode::getName() const     
00453     {   
00454         DEBUG_FUNC(DBOBJDefinitionNode::getName)
00455         return exportCharBuffer( m_pszName);       
00456     }      
00457 
00458     //_________________________________________________________________________
00459     //  GETDBTABLE
00460     //-------------------------------------------------------------------------
00461     const char* DBOBJDefinitionNode::getDBTable() const  
00462     {   
00463         DEBUG_FUNC(DBOBJDefinitionNode::getDBTable) 
00464         return exportCharBuffer( m_pszDBTable);     
00465     }
00466 
00467     //_________________________________________________________________________
00468     //  GETRESTRICT
00469     //-------------------------------------------------------------------------
00470     const char* DBOBJDefinitionNode::getRestrict() const 
00471     {   
00472         DEBUG_FUNC(DBOBJDefinitionNode::getRestrict)    
00473         return exportCharBuffer( m_pszRestrict);   
00474     }
00475 
00476     //_________________________________________________________________________
00477     //  GETCHECKPRE
00478     //-------------------------------------------------------------------------
00479     const char* DBOBJDefinitionNode::getCheckPre() const 
00480     {   
00481         DEBUG_FUNC(DBOBJDefinitionNode::getCheckPre)    
00482         return exportCharBuffer( m_pszCheckPre);   
00483     }
00484 
00485     //_________________________________________________________________________
00486     //  GETCHECKPOST
00487     //-------------------------------------------------------------------------
00488     const char* DBOBJDefinitionNode::getCheckPost() const   
00489     {   
00490         DEBUG_FUNC(DBOBJDefinitionNode::getCheckPost)   
00491         return exportCharBuffer( m_pszCheckPost);  
00492     }
00493 
00494     //_________________________________________________________________________
00495     //  ISLOCKED
00496     //-------------------------------------------------------------------------
00497     bool DBOBJDefinitionNode::isLocked() const    
00498     {   
00499         DEBUG_FUNC(DBOBJDefinitionNode::isLocked)  
00500         return m_boolLocked; 
00501     }
00502 
00503 
00504     //_________________________________________________________________________
00505     //  ISDISTINCT
00506     //-------------------------------------------------------------------------
00507     bool DBOBJDefinitionNode::isDistinct() const      
00508     {   
00509         DEBUG_FUNC(DBOBJDefinitionNode::isDistinct)  
00510         return m_boolDistinct; 
00511     }
00512 
00513     //_________________________________________________________________________
00514     //  GETPARENT
00515     //-------------------------------------------------------------------------
00516     DBOBJDefinitionNode* DBOBJDefinitionNode::getParent() const
00517     {
00518         DEBUG_FUNC(DBOBJDefinitionNode::getParent())
00519         return m_DBOBJParentNode;
00520     }
00521 
00522     //  SETTERS
00523 
00524     //_________________________________________________________________________
00525     //  SETNAME
00526     //-------------------------------------------------------------------------
00527     void DBOBJDefinitionNode::setName( const char*  p_pszName)
00528     {
00529         DEBUG_FUNC(DBOBJDefinitionNode::setName)
00530         m_pszName = importCharBuffer( m_pszName, p_pszName);
00531     }
00532 
00533     //_________________________________________________________________________
00534     //  SETDBTABLE
00535     //-------------------------------------------------------------------------
00536     void DBOBJDefinitionNode::setDBtable( const char*  p_pszDBTable)
00537     {
00538         DEBUG_FUNC(DBOBJDefinitionNode::setDBtable)
00539         m_pszDBTable = importCharBuffer( m_pszDBTable, p_pszDBTable);
00540     }
00541 
00542     //_________________________________________________________________________
00543     //  SETRESTRICT
00544     //-------------------------------------------------------------------------
00545     void DBOBJDefinitionNode::setRestrict( const char*  p_pszRestrict)
00546     {
00547         DEBUG_FUNC(DBOBJDefinitionNode::setRestrict)
00548         m_pszRestrict = importCharBuffer( m_pszRestrict, p_pszRestrict);
00549     }
00550 
00551     //_________________________________________________________________________
00552     //  SETCHECKPRE
00553     //-------------------------------------------------------------------------
00554     void DBOBJDefinitionNode::setCheckPre( const char*  p_pszCheckPre)
00555     {
00556         DEBUG_FUNC(DBOBJDefinitionNode::setCheckPre)            
00557         m_pszCheckPre = importCharBuffer( m_pszCheckPre, p_pszCheckPre);
00558     }
00559 
00560     //_________________________________________________________________________
00561     //  SETCHECKPOST
00562     //-------------------------------------------------------------------------
00563     void DBOBJDefinitionNode::setCheckPost( const char*  p_pszCheckPost)
00564     {
00565         DEBUG_FUNC(DBOBJDefinitionNode::setCheckPost)
00566         m_pszCheckPost = importCharBuffer( m_pszCheckPost, p_pszCheckPost);
00567     }
00568 
00569     //_________________________________________________________________________
00570     //  SETLOCKED
00571     //-------------------------------------------------------------------------
00572     void DBOBJDefinitionNode::setLocked( bool p_boolLocked)
00573     {
00574         DEBUG_FUNC(DBOBJDefinitionNode::setLocked)
00575         m_boolLocked = p_boolLocked;
00576     }
00577 
00578     //_________________________________________________________________________
00579     //  SETDISTINCT
00580     //-------------------------------------------------------------------------
00581     void DBOBJDefinitionNode::setDistinct( bool p_boolDistinct)
00582     {
00583         DEBUG_FUNC(DBOBJDefinitionNode::setDistinct)
00584         m_boolDistinct = p_boolDistinct;
00585     }
00586 
00587     //_________________________________________________________________________
00588     //  SETPARENT
00589     //-------------------------------------------------------------------------
00590     void DBOBJDefinitionNode::setParent( DBOBJDefinitionNode* p_pParentDefinition)
00591     {
00592         DEBUG_FUNC(DBOBJDefinitionNode::setParent)
00593         m_DBOBJParentNode = p_pParentDefinition;
00594     }
00595 
00596 
00597     // EVENTS
00598 
00599     //_____________________________________________________________________
00600     //  GETONDELETE
00601     //---------------------------------------------------------------------
00602     const char* DBOBJDefinitionNode::getOnDelete() const 
00603     {
00604         DEBUG_FUNC(DBOBJDefinitionNode::getOnDelete)
00605         return exportCharBuffer( m_pszOnDelete);
00606     }
00607 
00608     //_____________________________________________________________________
00609     //  GETONINSERT
00610     //---------------------------------------------------------------------
00611     const char* DBOBJDefinitionNode::getOnInsert() const 
00612     {
00613         DEBUG_FUNC(DBOBJDefinitionNode::getOnInsert)
00614         return exportCharBuffer( m_pszOnInsert);
00615     }
00616 
00617     //_____________________________________________________________________
00618     //  GETONUPDATE
00619     //---------------------------------------------------------------------
00620     const char* DBOBJDefinitionNode::getOnUpdate() const 
00621     {
00622         DEBUG_FUNC(DBOBJDefinitionNode::getOnUpdate)
00623         return exportCharBuffer( m_pszOnUpdate);
00624     }
00625 
00626     //_____________________________________________________________________
00627     //  SETONDELETE
00628     //---------------------------------------------------------------------
00629     void DBOBJDefinitionNode::setOnDelete( const char* p_pszOnDelete)
00630     {
00631         DEBUG_FUNC(DBOBJDefinitionNode::setOnDelete)
00632         m_pszOnDelete = importCharBuffer( m_pszOnDelete, p_pszOnDelete);
00633     }
00634 
00635     //_____________________________________________________________________
00636     //  SETONINSERT
00637     //---------------------------------------------------------------------
00638     void DBOBJDefinitionNode::setOnInsert( const char* p_pszOnInsert)
00639     {
00640         DEBUG_FUNC(DBOBJDefinitionNode::setOnInsert)
00641         m_pszOnInsert = importCharBuffer( m_pszOnInsert, p_pszOnInsert);
00642 
00643     }
00644 
00645     //_____________________________________________________________________
00646     //  SETONUPDATE
00647     //---------------------------------------------------------------------
00648     void DBOBJDefinitionNode::setOnUpdate( const char* p_pszOnUpdate)
00649     {
00650         DEBUG_FUNC(DBOBJDefinitionNode::setOnUpdate)
00651         m_pszOnUpdate = importCharBuffer( m_pszOnUpdate, p_pszOnUpdate);
00652     }
00653 
00654 
00655     //  CHILD NODES FUNCTIONS
00656 
00657     //_________________________________________________________________________
00658     //  ADDCHILD
00659     //-------------------------------------------------------------------------
00660     void DBOBJDefinitionNode::addChild( DBOBJDefinitionNode* p_ChildDefinition)
00661     {
00662         DEBUG_FUNC(DBOBJDefinitionNode::addChild)
00663 
00664         p_ChildDefinition->setParent(this);
00665         m_vaChildren.add( p_ChildDefinition, p_ChildDefinition->getName());
00666     }
00667 
00668     //_________________________________________________________________________
00669     //  REMOVECHILD
00670     //-------------------------------------------------------------------------
00671     void DBOBJDefinitionNode::removeChild( unsigned int p_uiIndex, bool p_boolDestroy)
00672     {
00673         //---------------------------------------------------------------------
00674         DBOBJDefinitionNode* l_ChildDefinition;
00675         //---------------------------------------------------------------------
00676 
00677         DEBUG_FUNC(DBOBJDefinitionNode::removeChild)
00678 
00679         l_ChildDefinition = m_vaChildren.remove( p_uiIndex);
00680         if( l_ChildDefinition)
00681         {
00682             l_ChildDefinition->setParent(0);
00683             if(p_boolDestroy) delete l_ChildDefinition;
00684         }
00685     }
00686 
00687     //_________________________________________________________________________
00688     //  REMOVECHILD
00689     //-------------------------------------------------------------------------
00690     void DBOBJDefinitionNode::removeChild( const char* p_pszName, bool p_boolDestroy)
00691     {
00692         //---------------------------------------------------------------------
00693         DBOBJDefinitionNode* l_ChildDefinition;
00694         //---------------------------------------------------------------------
00695 
00696         DEBUG_FUNC(DBOBJDefinitionNode::removeChild)
00697 
00698         l_ChildDefinition = m_vaChildren.remove( p_pszName);
00699         if( l_ChildDefinition)
00700         {
00701             l_ChildDefinition->setParent(0);
00702             if(p_boolDestroy) delete l_ChildDefinition;
00703         }       
00704     }
00705 
00706     //_________________________________________________________________________
00707     //  GETCHILDNODESCOUNT
00708     //-------------------------------------------------------------------------
00709     unsigned int DBOBJDefinitionNode::getChildNodesCount() const
00710     {
00711         DEBUG_FUNC(DBOBJDefinitionNode::getChildNodesCount)
00712         return m_vaChildren.size();
00713     }
00714 
00715     //_________________________________________________________________________
00716     //  GETCHILDNODE
00717     //-------------------------------------------------------------------------
00718     DBOBJDefinitionNode* DBOBJDefinitionNode::getChildNode(unsigned int p_uiIndex) const 
00719     {
00720         DEBUG_FUNC(DBOBJDefinitionNode::getChildNode(index))
00721         return m_vaChildren.get(p_uiIndex);
00722     }
00723 
00724     //_________________________________________________________________________
00725     //  GETCHILDNODE
00726     //-------------------------------------------------------------------------
00727     DBOBJDefinitionNode* DBOBJDefinitionNode::getChildNode( const char* p_pszName) const
00728     {
00729         DEBUG_FUNC(DBOBJDefinitionNode::getChildNode(name))
00730         return m_vaChildren.get( p_pszName);
00731     }
00732 
00733     //  CHILD FIELDS FUNCTIONS
00734 
00735     //_________________________________________________________________________
00736     //  ADDFIELD
00737     //-------------------------------------------------------------------------
00738     void DBOBJDefinitionNode::addField( DBOBJDefinitionField* p_FieldDefinition)
00739     {
00740         DEBUG_FUNC(DBOBJDefinitionNode::addField)
00741 
00742         m_vaFields.add(p_FieldDefinition, p_FieldDefinition->getName());
00743         p_FieldDefinition->setParent( this);
00744     }
00745 
00746     //_________________________________________________________________________
00747     //  REMOVEFIELD
00748     //-------------------------------------------------------------------------
00749     void DBOBJDefinitionNode::removeField( unsigned int p_uiIndex, bool p_boolDestroy)
00750     {
00751         DBOBJDefinitionField* l_pDefField;
00752 
00753         DEBUG_FUNC(DBOBJDefinitionNode::removeField(name))
00754 
00755         l_pDefField =  m_vaFields.remove( p_uiIndex);   
00756         if( p_boolDestroy) delete l_pDefField;
00757     }
00758 
00759     //_________________________________________________________________________
00760     //  REMOVEFIELD
00761     //-------------------------------------------------------------------------
00762     void DBOBJDefinitionNode::removeField( const char* p_pszName, bool p_boolDestroy)
00763     {
00764         DBOBJDefinitionField* l_pDefField;
00765 
00766         DEBUG_FUNC(DBOBJDefinitionNode::removeField(name))
00767 
00768         l_pDefField =  removeNamedField( p_pszName);    
00769         if( p_boolDestroy) delete l_pDefField;
00770         
00771     }
00772 
00773     //_________________________________________________________________________
00774     //  REMOVENAMEDFIELD
00775     //-------------------------------------------------------------------------
00776     DBOBJDefinitionField* DBOBJDefinitionNode::removeNamedField( const char* p_pszName)
00777     {
00778 
00779         DEBUG_FUNC(DBOBJDefinitionNode::removeNamedField)
00780         
00781         m_vaPkeys.remove( p_pszName);
00782         m_vaKeyLinks.remove( p_pszName);
00783         return m_vaFields.remove( p_pszName);
00784     }
00785 
00786     //_________________________________________________________________________
00787     //  GETFIELDSCOUNT
00788     //-------------------------------------------------------------------------
00789     unsigned int DBOBJDefinitionNode::getFieldsCount() const 
00790     {
00791         DEBUG_FUNC(DBOBJDefinitionNode::getFieldsCount) 
00792         return m_vaFields.size();
00793     }
00794 
00795     //_________________________________________________________________________
00796     //  GETFIELD
00797     //-------------------------------------------------------------------------
00798     DBOBJDefinitionField* DBOBJDefinitionNode::getField(unsigned int p_uiIndex) const 
00799     {
00800         DEBUG_FUNC(DBOBJDefinitionNode::getField(index))    
00801         return m_vaFields.get(p_uiIndex);
00802     }
00803 
00804     //_________________________________________________________________________
00805     //  GETFIELD
00806     //-------------------------------------------------------------------------
00807     DBOBJDefinitionField* DBOBJDefinitionNode::getField(const char* p_pszName) const 
00808     {
00809 
00810         DEBUG_FUNC(DBOBJDefinitionNode::getField(name))
00811         return m_vaFields.get( p_pszName);
00812     }
00813 
00814     // PKEYS COLLECTION ACCESSORS
00815 
00816     //_________________________________________________________________________
00817     //  ADDPKEY
00818     //-------------------------------------------------------------------------
00819     void DBOBJDefinitionNode::addPkey( const char* p_pszName)
00820     {
00821         //---------------------------------------------------------------------
00822         DBOBJDefinitionField*   l_pDBOBJDefField;
00823         //---------------------------------------------------------------------
00824 
00825         DEBUG_FUNC(DBOBJDefinitionNode::addPkey)  
00826 
00827         l_pDBOBJDefField=getField( p_pszName);
00828 
00829         // ERRCHECK : field exists ?
00830         if(! l_pDBOBJDefField) THROW_XMLFLOW_EXCEPTION ( ERRCODE_LOC_DBOBJDEFINITION + ERRCODE_CAUSE_MISSINGREF , "Unable to find field to cast as primary key.", getName(), "DBOBJDefinitionNode::addPkey", "Provided field name does not exists in object node.", false);
00831 
00832         m_vaPkeys.add( l_pDBOBJDefField, p_pszName);
00833         l_pDBOBJDefField->setPkey(true);
00834 
00835     }
00836 
00837     //_________________________________________________________________________
00838     //  REMPKEY
00839     //-------------------------------------------------------------------------
00840     void DBOBJDefinitionNode::remPkey( unsigned int p_uiIndex)
00841     {
00842         DBOBJDefinitionField* l_FieldDefinition;
00843 
00844         DEBUG_FUNC(DBOBJDefinitionNode::remPkey)
00845         
00846         l_FieldDefinition = m_vaPkeys.remove( p_uiIndex);
00847         l_FieldDefinition->setPkey(false);
00848     }
00849 
00850     //_________________________________________________________________________
00851     //  GETPKEYSCOUNT
00852     //-------------------------------------------------------------------------
00853     unsigned int DBOBJDefinitionNode::getPkeysCount() const 
00854     {
00855         DEBUG_FUNC(DBOBJDefinitionNode::getPkeysCount)  
00856         return m_vaPkeys.size();
00857     }
00858 
00859     //_________________________________________________________________________
00860     //  GETPKEY
00861     //-------------------------------------------------------------------------
00862     DBOBJDefinitionField* DBOBJDefinitionNode::getPkey( unsigned int p_index) const 
00863     {
00864         DEBUG_FUNC(DBOBJDefinitionNode::getPkey)    
00865         return m_vaPkeys.get( p_index);
00866     }
00867 
00868     //_________________________________________________________________________
00869     //  GETPKEY
00870     //-------------------------------------------------------------------------
00871     DBOBJDefinitionField* DBOBJDefinitionNode::getPkey( const char* p_pszName) const 
00872     {
00873         DEBUG_FUNC(DBOBJDefinitionNode::getPkey)    
00874         return m_vaPkeys.get( p_pszName);
00875     }
00876 
00877 
00878     // KEYSLINKS COLLECTION ACCESSORS
00879 
00880     //_________________________________________________________________________
00881     //  ADDKEYLINK
00882     //-------------------------------------------------------------------------
00883     void DBOBJDefinitionNode::addKeyLink( const char* p_pszLocalName, const char * p_pszParentName)
00884     {
00885         //---------------------------------------------------------------------
00886         DBOBJDefinitionField*   l_pDBOBJLocalDefField;
00887         DBOBJDefinitionField*   l_pDBOBJParentDefField;
00888         DBOBJDefinitionFieldsPair* l_pKeyLink;
00889         //---------------------------------------------------------------------
00890         
00891         DEBUG_FUNC(DBOBJDefinitionNode::addKeyLink) 
00892 
00893         if(m_DBOBJParentNode)
00894         {
00895             l_pDBOBJLocalDefField = getField( p_pszLocalName);
00896             // ERRCHECK : field exists ?
00897             if(! l_pDBOBJLocalDefField) THROW_XMLFLOW_EXCEPTION ( ERRCODE_LOC_DBOBJDEFINITION + ERRCODE_CAUSE_MISSINGREF , "Unable to find field to cast as inner key." , getName(), "DBOBJDefinitionNode::addKeyLink", "Provided field name does not exists in object node.", false);
00898 
00899             l_pDBOBJParentDefField = getParent()->getField( p_pszParentName);
00900             // ERRCHECK : field exists ?
00901             if(! l_pDBOBJParentDefField) THROW_XMLFLOW_EXCEPTION ( ERRCODE_LOC_DBOBJDEFINITION + ERRCODE_CAUSE_MISSINGREF , "Unable to find field to cast as extern key." , getName(), "DBOBJDefinitionNode::addKeyLink", "Provided field name does not exists in parent object node.", false);
00902 
00903             l_pKeyLink=new DBOBJDefinitionFieldsPair;
00904             l_pKeyLink->first=l_pDBOBJLocalDefField;
00905             l_pKeyLink->second=l_pDBOBJParentDefField;
00906             m_vaKeyLinks.add(l_pKeyLink, p_pszLocalName);
00907         }
00908     }
00909 
00910     //_________________________________________________________________________
00911     //  REMKEYLINK
00912     //-------------------------------------------------------------------------
00913     void DBOBJDefinitionNode::remKeyLink( unsigned int p_uiIndex)
00914     {
00915         DEBUG_FUNC(DBOBJDefinitionNode::remKeyLink) 
00916 
00917         delete( m_vaKeyLinks.remove( p_uiIndex));
00918     }
00919 
00920     //_________________________________________________________________________
00921     //  GETKEYLINKSCOUNT
00922     //-------------------------------------------------------------------------
00923     unsigned int DBOBJDefinitionNode::getKeyLinksCount() const 
00924     {
00925         DEBUG_FUNC(DBOBJDefinitionNode::getKeyLinkCount) 
00926         return m_vaKeyLinks.size();
00927     }
00928 
00929     //_________________________________________________________________________
00930     //  GETKEYLINK
00931     //-------------------------------------------------------------------------
00932     DBOBJDefinitionFieldsPair* DBOBJDefinitionNode::getKeyLink( unsigned int p_uiIndex) const 
00933     {
00934         DEBUG_FUNC(DBOBJDefinitionNode::getKeyLink)   
00935         return m_vaKeyLinks.get(p_uiIndex);
00936     }
00937 
00938     //_________________________________________________________________________
00939     //  GETKEYLINK
00940     //-------------------------------------------------------------------------
00941     DBOBJDefinitionFieldsPair* DBOBJDefinitionNode::getKeyLink( const char* p_pszName) const 
00942     {
00943         DEBUG_FUNC(DBOBJDefinitionNode::getKeyLink)   
00944         return m_vaKeyLinks.get(p_pszName);
00945     }
00946 
00947     // FUNCTIONNALITIES
00948 
00949     //_________________________________________________________________________
00950     //  GETXML
00951     //-------------------------------------------------------------------------
00952     void DBOBJDefinitionNode::getXML(XMLStreamConsumer* p_pXMLBufOut)
00953     {
00954          //--------------------------------------------------------------------
00955         const char* l_pszSep;
00956         char* l_pszTmp;
00957         unsigned    int i;
00958          //--------------------------------------------------------------------
00959 
00960         DEBUG_FUNC(DBOBJDefinitionNode::getXML)
00961 
00962         // write node props
00963         (* p_pXMLBufOut) << "\n<" << DBOBJDEFNODE_TAGNAME << " ";
00964         (* p_pXMLBufOut) << DBOBJDEFNODE_NAME       << "=\"" << getName()       << "\" ";
00965         (* p_pXMLBufOut) << DBOBJDEFNODE_TABLE      << "=\"" << getDBTable()    << "\" ";
00966         (* p_pXMLBufOut) << DBOBJDEFNODE_RESTRICT   << "=\"" << getRestrict()   << "\" ";
00967         (* p_pXMLBufOut) << DBOBJDEFNODE_CHECKPRE   << "=\"" << getCheckPre()   << "\" ";
00968         (* p_pXMLBufOut) << DBOBJDEFNODE_CHECKPOST  << "=\"" << getCheckPost()  << "\" ";
00969 
00970         l_pszTmp=correctAttrValue( getOnInsert());
00971         (* p_pXMLBufOut) << DBOBJDEFNODE_ONINSERT   << "=\"" << l_pszTmp    << "\" ";
00972         l_pszTmp = releaseCharBuffer(l_pszTmp);
00973 
00974 
00975         l_pszTmp=correctAttrValue( getOnUpdate());
00976         (* p_pXMLBufOut) << DBOBJDEFNODE_ONUPDATE   << "=\"" << l_pszTmp    << "\" ";
00977         l_pszTmp = releaseCharBuffer(l_pszTmp);
00978 
00979         l_pszTmp=correctAttrValue( getOnDelete());
00980         (* p_pXMLBufOut) << DBOBJDEFNODE_ONDELETE   << "=\"" << l_pszTmp    << "\" ";
00981         l_pszTmp = releaseCharBuffer(l_pszTmp);
00982 
00983         if( isLocked() )    (* p_pXMLBufOut) << DBOBJDEFNODE_LOCK << "=\"" << REQ_TRUE << "\" ";
00984         else                (* p_pXMLBufOut) << DBOBJDEFNODE_LOCK << "=\"" << REQ_FALSE << "\" ";
00985 
00986         if( isDistinct() )  (* p_pXMLBufOut) << DBOBJDEFNODE_DISTINCT << "=\"" << REQ_TRUE << "\" ";
00987         else                (* p_pXMLBufOut) << DBOBJDEFNODE_DISTINCT << "=\"" << REQ_FALSE << "\" ";
00988 
00989         // write pkeys
00990         l_pszSep="";
00991         (* p_pXMLBufOut) << DBOBJDEFNODE_PKEY << "=\"";
00992         for(i=0 ; i<getPkeysCount() ; i++)
00993         {
00994             (* p_pXMLBufOut) << l_pszSep << getPkey(i)->getName();
00995             l_pszSep=",";
00996         }
00997         (* p_pXMLBufOut) <<  "\" ";
00998 
00999         // write inkeys
01000         l_pszSep="";
01001         (* p_pXMLBufOut) << DBOBJDEFNODE_INKEY << "=\"";
01002         for(i=0 ; i<getKeyLinksCount() ; i++)
01003         {
01004             (* p_pXMLBufOut) << l_pszSep << getKeyLink(i)->first->getName();
01005             l_pszSep=",";
01006         }
01007         (* p_pXMLBufOut) <<  "\" ";
01008 
01009         // write outkeys
01010         l_pszSep="";
01011         (* p_pXMLBufOut) << DBOBJDEFNODE_OUTKEY << "=\"";
01012         for(i=0 ; i<getKeyLinksCount() ; i++)
01013         {
01014             (* p_pXMLBufOut) << l_pszSep << getKeyLink(i)->second->getName();
01015             l_pszSep=",";
01016         }
01017         (* p_pXMLBufOut) <<  "\" >\n";
01018 
01019         // get Fields XML
01020         for(i=0 ; i<getFieldsCount() ; i++) getField(i)->getXML(p_pXMLBufOut);
01021 
01022         // get Children XML
01023         for(i=0 ; i<getChildNodesCount() ; i++) getChildNode(i)->getXML(p_pXMLBufOut);
01024 
01025         // close node
01026         (* p_pXMLBufOut) << "</" << DBOBJDEFNODE_TAGNAME << ">\n";
01027     }
01028 
01029     // PRIVATES
01030 
01031     //_________________________________________________________________________
01032     //  DELETETREE
01033     //-------------------------------------------------------------------------
01034     void DBOBJDefinitionNode::deleteTree()
01035     {   
01036         DEBUG_IN(DBOBJDefinitionNode::deleteTree)
01037 
01038         while(! m_vaKeyLinks.empty())   delete m_vaKeyLinks.pop();
01039         while(! m_vaPkeys.empty())      m_vaPkeys.pop();
01040         while(! m_vaFields.empty())     delete m_vaFields.pop();
01041         while(! m_vaChildren.empty())   delete m_vaChildren.pop();
01042           
01043         DEBUG_OUT(DBOBJDefinitionNode::deleteTree)
01044     }
01045 
01046 
01047 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
01048 //=============================================================================
01049 
01050 
01051 //============================================================================= 
01052 //  CLASS SAXDBOBJDEFINITIONBUILDER
01053 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
01054 
01055 
01056     //_________________________________________________________________________
01057     //  BUILDDBOBJDEFINITION
01058     //-------------------------------------------------------------------------
01059     DBOBJDefinitionNode* SAXDBOBJDefinitionBuilder::buildDBOBJDefinition(XMLFlowContext* p_pContext, XMLStreamProvider*  p_pInput)
01060     {
01061         //---------------------------------------------------------------------
01062         SAXDBOBJDefinitionBuilder*  l_pSAXDefinitionBuilder = 0;
01063         StreamSAX2Parser*           l_pStreamParser=0;
01064         DBOBJDefinitionNode*        l_pDefinitionNode = 0;
01065         XDFLSaxErrorReporter*       l_pErrReporter = 0;
01066         //---------------------------------------------------------------------
01067 
01068         DEBUG_IN(SAXDBOBJDefinitionBuilder::buildDBOBJDefinition);
01069         PREP_CATCH_XML_FLOW_ERROR;
01070 
01071         WATCH_XML_FLOW_ERROR
01072         {
01073             //  Create our SAX handler and error reporter objects.
01074             l_pSAXDefinitionBuilder = new SAXDBOBJDefinitionBuilder(p_pContext);
01075             l_pErrReporter= new XDFLSaxErrorReporter("SAXDBOBJDefinitionBuilder::buildDBOBJDefinition");
01076             
01077             // create parser
01078             l_pStreamParser = new StreamSAX2Parser(l_pSAXDefinitionBuilder, l_pErrReporter);
01079 
01080             // Parse !
01081             (*p_pInput) >> (*l_pStreamParser);
01082             l_pStreamParser->commitStream(true);
01083 
01084         }
01085         CATCH_XML_FLOW_ERROR_RELEASE_AND_RETURN
01086         catch(...)
01087         {
01088             // Unknown error handling
01089             MAKE_XMLFLOW_EXCEPTION( ERRCODE_LOC_DBOBJDEFINITION + ERRCODE_CAUSE_UNKNOWN , "Error while building definition." , "",  "SAXDBOBJDefinitionBuilder::buildDBOBJDefinition", "", false );         
01090         }
01091 
01092         l_pDefinitionNode = l_pSAXDefinitionBuilder->getDefinition();
01093         
01094     RELEASE_AND_RETURN:
01095 
01096         // Release
01097         ON_XML_FLOW_ERROR_DO delete l_pSAXDefinitionBuilder->getDefinition();
01098         
01099         delete l_pStreamParser;
01100         delete l_pErrReporter;
01101         delete l_pSAXDefinitionBuilder;
01102 
01103         DEBUG_OUT(SAXDBOBJDefinitionBuilder::buildDBOBJDefinition);
01104         ON_XML_FLOW_ERROR_THROW;
01105 
01106         return l_pDefinitionNode;       
01107     }
01108 
01109     //  CONSTRUCTORS AND DESTRUCTOR  
01110 
01111     //_________________________________________________________________________
01112     //  SAXDBOBJDEFINITIONBUILDER
01113     //-------------------------------------------------------------------------
01114     SAXDBOBJDefinitionBuilder::SAXDBOBJDefinitionBuilder(XMLFlowContext* p_pContext)
01115     {
01116         DEBUG_CREATE(SAXDBOBJDefinitionBuilder)
01117         m_rootNode = 0;
01118         m_pContext = p_pContext;
01119     }
01120 
01121     //_________________________________________________________________________
01122     //  ~SAXDBOBJDEFINITIONBUILDER
01123     //-------------------------------------------------------------------------
01124     SAXDBOBJDefinitionBuilder::~SAXDBOBJDefinitionBuilder()
01125     {
01126         DEBUG_DEL(SAXDBOBJDefinitionBuilder)
01127 
01128         while(!m_vaNodes.empty())   m_vaNodes.pop();
01129         while(!m_vaPkeysList.empty()) releaseCharBuffer( m_vaPkeysList.pop());
01130         while(!m_vaInkeysList.empty()) releaseCharBuffer( m_vaInkeysList.pop());
01131         while(!m_vaOutkeysList.empty()) releaseCharBuffer( m_vaOutkeysList.pop());
01132     }
01133 
01134     //  GETTERS  
01135 
01136     //_________________________________________________________________________
01137     //  GETDEFINITION
01138     //-------------------------------------------------------------------------
01139     DBOBJDefinitionNode* SAXDBOBJDefinitionBuilder::getDefinition() const
01140     {
01141         DEBUG_FUNC(SAXDBOBJDefinitionBuilder::getObjectRoot)
01142         return m_rootNode;
01143 
01144     }
01145 
01146     //  CONTENTHANDLER  
01147 
01148     //_________________________________________________________________________
01149     //  STARTELEMENT
01150     //-------------------------------------------------------------------------
01151     void SAXDBOBJDefinitionBuilder::startElement(   const XMLCh* const uri, 
01152                                                     const XMLCh* const localname, 
01153                                                     const XMLCh* const qname, 
01154                                                     const Attributes& attrs)
01155     {
01156         //---------------------------------------------------------------------
01157         DBOBJDefinitionNode*    l_pNodeDefinition;
01158         DBOBJDefinitionField*   l_pDBObjectFieldDef;
01159         char                    l_szTagName[XMLPROCESSOR_MAX_TAG_SIZE];
01160         char                    l_szAttrValue[XMLPROCESSOR_MAX_ATTRVAL_SIZE];
01161         const char*             l_pszName;
01162         //---------------------------------------------------------------------
01163 
01164         DEBUG_IN(SAXDBOBJDefinitionBuilder::startElement);
01165 
01166         XSTR(m_pContext->getTranscoder(), localname, (char*)&l_szTagName);
01167 
01168         //logout << (char*)&l_szTagName << "\n";
01169 
01170         if ( strcmp( (char*)&l_szTagName, DBOBJDEFNODE_TAGNAME) == 0)
01171         {
01172             l_pNodeDefinition= new DBOBJDefinitionNode();       
01173 
01174             l_pNodeDefinition->setName(         SAX_getAttrValue( attrs, DBOBJDEFNODE_NAME,     "", (char*) &l_szAttrValue));
01175             l_pNodeDefinition->setRestrict(     SAX_getAttrValue( attrs, DBOBJDEFNODE_RESTRICT, "", (char*) &l_szAttrValue));
01176             l_pNodeDefinition->setCheckPre(     SAX_getAttrValue( attrs, DBOBJDEFNODE_CHECKPRE, DBOBJDEFNODE_NOEVENT, (char*) &l_szAttrValue));
01177             l_pNodeDefinition->setCheckPost(    SAX_getAttrValue( attrs, DBOBJDEFNODE_CHECKPOST,DBOBJDEFNODE_NOEVENT, (char*) &l_szAttrValue));
01178             l_pNodeDefinition->setDBtable(      SAX_getAttrValue( attrs, DBOBJDEFNODE_TABLE,    "", (char*) &l_szAttrValue));
01179             l_pNodeDefinition->setOnInsert(     SAX_getAttrValue( attrs, DBOBJDEFNODE_ONINSERT, "", (char*) &l_szAttrValue));
01180             l_pNodeDefinition->setOnUpdate(     SAX_getAttrValue( attrs, DBOBJDEFNODE_ONUPDATE, "", (char*) &l_szAttrValue));
01181             l_pNodeDefinition->setOnDelete(     SAX_getAttrValue( attrs, DBOBJDEFNODE_ONDELETE, "", (char*) &l_szAttrValue));
01182 
01183 
01184             if( strcmp( SAX_getAttrValue( attrs, DBOBJDEFNODE_LOCK, REQ_FALSE, (char*)&l_szAttrValue), REQ_TRUE) == 0) l_pNodeDefinition->setLocked( true);
01185             else l_pNodeDefinition->setLocked( false);
01186 
01187             if( strcmp( SAX_getAttrValue( attrs, DBOBJDEFNODE_DISTINCT, REQ_FALSE, (char*)&l_szAttrValue), REQ_TRUE) == 0) l_pNodeDefinition->setDistinct( true);
01188             else l_pNodeDefinition->setDistinct( false);
01189             
01190             // Check for parents nodes in stack
01191             if(!m_vaNodes.empty()) 
01192             {           
01193                 // Attach to parent
01194                 m_vaNodes.top()->addChild( l_pNodeDefinition);
01195             }
01196             else  
01197             {
01198                 // no parent : Set as Root node
01199                 m_rootNode = l_pNodeDefinition;
01200             }           
01201             
01202             m_vaPkeysList.push( SAX_getAttrValue( attrs, DBOBJDEFNODE_PKEY));
01203             m_vaInkeysList.push( SAX_getAttrValue( attrs, DBOBJDEFNODE_INKEY));
01204             m_vaOutkeysList.push( SAX_getAttrValue( attrs, DBOBJDEFNODE_OUTKEY));
01205 
01206             // Put on stack
01207             m_vaNodes.push( l_pNodeDefinition);
01208         }
01209 
01210         if ( strcmp( (char*)&l_szTagName, DBOBJDEFFIELD_TAGNAME) == 0)
01211         {
01212             // Set properties
01213             l_pDBObjectFieldDef = new DBOBJDefinitionField();
01214             l_pDBObjectFieldDef->setName(       SAX_getAttrValue( attrs, DBOBJDEFFIELD_NAME,    "", (char*)&l_szAttrValue));
01215             l_pDBObjectFieldDef->setDBField(    SAX_getAttrValue( attrs, DBOBJDEFFIELD_FIELD,   "", (char*)&l_szAttrValue));
01216             l_pDBObjectFieldDef->setMap(        SAX_getAttrValue( attrs, DBOBJDEFFIELD_MAP,     "", (char*)&l_szAttrValue));
01217             l_pDBObjectFieldDef->setIValue(     SAX_getAttrValue( attrs, DBOBJDEFFIELD_IVALUE,DBOBJDEFFIELD_NOVALUE, (char*)&l_szAttrValue));
01218             l_pDBObjectFieldDef->setUValue(     SAX_getAttrValue( attrs, DBOBJDEFFIELD_UVALUE,DBOBJDEFFIELD_NOVALUE, (char*)&l_szAttrValue));
01219             l_pDBObjectFieldDef->setDValue(     SAX_getAttrValue( attrs, DBOBJDEFFIELD_DVALUE,DBOBJDEFFIELD_NOVALUE, (char*)&l_szAttrValue));
01220             l_pDBObjectFieldDef->setValue(      SAX_getAttrValue( attrs, DBOBJDEFFIELD_VALUE ,DBOBJDEFFIELD_NOVALUE, (char*)&l_szAttrValue));
01221             l_pDBObjectFieldDef->setDBSpecProps(SAX_getAttrValue( attrs, DBOBJDEFFIELD_DBSPEC , "", (char*)&l_szAttrValue));
01222 
01223             if( strcmp( l_pDBObjectFieldDef->getMap(), DBOBJDEFFIELD_MAP_DATE) == 0 )
01224             {
01225                 if (DBStreamerFactory::getSQLSyntax()==SQL_SYNTAX_ORA)
01226                 {
01227                     l_pDBObjectFieldDef->setDateFormat( SAX_getAttrValue( attrs, DBOBJDEFFIELD_DATE_FORMAT ,DBOBJDEFFIELD_DATE_FORMAT_DEF_ORA, (char*)&l_szAttrValue));             
01228                 }
01229                 else if (DBStreamerFactory::getSQLSyntax()==SQL_SYNTAX_MSSQL)
01230                 {
01231                     l_pDBObjectFieldDef->setDateFormat( SAX_getAttrValue( attrs, DBOBJDEFFIELD_DATE_FORMAT ,DBOBJDEFFIELD_DATE_FORMAT_DEF_MSSQL, (char*)&l_szAttrValue));               
01232                 }
01233             }
01234 
01235             if( strcmp( SAX_getAttrValue( attrs, DBOBJDEFFIELD_HIDDEN, REQ_FALSE, (char*)&l_szAttrValue ), REQ_TRUE) == 0 )
01236             {
01237                 l_pDBObjectFieldDef->setHidden( true);
01238             }
01239             else
01240             {
01241                 l_pDBObjectFieldDef->setHidden( false);
01242             }
01243 
01244             // Uppercase name and remove '@' to get alias & attribute prop
01245             l_pszName = l_pDBObjectFieldDef->getName();   
01246             if( l_pszName[0] == DBOBJDEFFIELD_ATTR )
01247             {
01248                 l_pDBObjectFieldDef->setAttribute(true);
01249                 l_pDBObjectFieldDef->setDBAlias( l_pszName+1); 
01250             }
01251             else
01252             {
01253                 l_pDBObjectFieldDef->setAttribute(false);
01254                 l_pDBObjectFieldDef->setDBAlias( l_pszName); 
01255             }
01256              
01257             // Attach to Parent
01258             m_vaNodes.top()->addField( l_pDBObjectFieldDef);
01259         }
01260 
01261 
01262         DEBUG_OUT(SAXDBOBJDefinitionBuilder::startElement)
01263     }
01264 
01265     //_________________________________________________________________________
01266     //  ENDELEMENT
01267     //-------------------------------------------------------------------------
01268     void SAXDBOBJDefinitionBuilder::endElement(   const XMLCh* const uri,
01269                                                const XMLCh* const localname,
01270                                                const XMLCh* const qname)
01271     {
01272 
01273         //---------------------------------------------------------------------
01274         char            l_szTagName[XMLPROCESSOR_MAX_TAG_SIZE];
01275         const char*     l_pszNodeName=0;
01276 
01277         char*           l_pszPkeys=0;       
01278         char*           l_pszInkeys=0;
01279         char*           l_pszOutkeys=0;
01280 
01281         char*           l_pszTmpKeys=0;
01282         char*           l_pszTmpKeys2=0;
01283         const char*         l_pszKey=0;
01284         const char*         l_pszKey2=0;
01285 
01286         bool            l_boolOK;
01287         DBOBJDefinitionNode* l_pNodeDefinition=0;
01288         //---------------------------------------------------------------------
01289         
01290         DEBUG_IN(SAXDBOBJDefinitionBuilder::endElement)
01291 
01292         PREP_CATCH_XML_FLOW_ERROR;
01293 
01294 
01295         WATCH_XML_FLOW_ERROR
01296         {
01297             XSTR(m_pContext->getTranscoder(), localname, (char*)&l_szTagName);
01298 
01299             //logout << "/" << (char*)&l_szTagName << "\n";
01300 
01301             if ( strcmp( (char*)&l_szTagName, DBOBJDEFNODE_TAGNAME) == 0)
01302             {
01303                 l_pNodeDefinition = m_vaNodes.pop();
01304                 l_pszNodeName = l_pNodeDefinition->getName();
01305 
01306                 DEBUG_ECHO << l_pszNodeName << "\n";
01307 
01308                 // set pkeys by parsing pkeys list
01309                 l_pszPkeys = m_vaPkeysList.pop();
01310 
01311                 // ERRCHECK : primary key?
01312                 if( strlen( l_pszPkeys) == 0) THROW_XMLFLOW_EXCEPTION ( ERRCODE_LOC_DBOBJDEFINITION + ERRCODE_CAUSE_MISSINGREF ,  "No primary key found for node." , l_pNodeDefinition->getName(), "SAXDBOBJDefinitionBuilder::endElemen", "A definition node must have at least one primary key.", false);
01313 
01314                 l_pszTmpKeys = l_pszPkeys;
01315                 l_boolOK=false;
01316                 l_pszKey="";
01317                 while( !l_boolOK)
01318                 {
01319                     l_pszKey  = l_pszTmpKeys;
01320                     l_pszTmpKeys = strchr(l_pszTmpKeys, ',');
01321                     if( !l_pszTmpKeys)
01322                     {
01323                         l_boolOK=true; // ! no more 
01324                     }
01325                     else
01326                     {
01327                         l_pszTmpKeys[0]='\0';
01328                         l_pszTmpKeys++;
01329                     }
01330                     DEBUG_ECHO << l_pszKey << "\n";
01331                     if ( strlen( l_pszKey)>0 ) l_pNodeDefinition->addPkey( l_pszKey);
01332                 }
01333 
01334                 // set keylinks by parsing inkeys & outkeys list in definition
01335                 l_pszOutkeys = m_vaOutkeysList.pop();
01336                 l_pszInkeys = m_vaInkeysList.pop();
01337 
01338                 l_pszTmpKeys = l_pszInkeys;
01339                 l_pszTmpKeys2 = l_pszOutkeys;
01340 
01341                 l_pszKey="";
01342                 l_pszKey2="";
01343 
01344                 l_boolOK=false;
01345                 while( !l_boolOK)
01346                 {
01347 
01348                     l_pszKey = l_pszTmpKeys;
01349                     l_pszTmpKeys = strchr(l_pszTmpKeys, ',');
01350                     if( !l_pszTmpKeys )
01351                     {
01352                         l_boolOK=true; // ! no more 
01353                     }
01354                     else
01355                     {
01356                         l_pszTmpKeys[0]='\0';
01357                         l_pszTmpKeys ++;
01358                     }
01359 
01360                     l_pszKey2 = l_pszTmpKeys2;
01361                     l_pszTmpKeys2 = strchr(l_pszTmpKeys2, ',');
01362                     if( !l_pszTmpKeys2)
01363                     {
01364                         l_boolOK=true; // ! no more 
01365                     }
01366                     else
01367                     {
01368                         l_pszTmpKeys2[0]='\0';
01369                         l_pszTmpKeys2 ++;
01370                     }
01371 
01372                     if ( ( strlen(l_pszKey) > 0 ) && ( strlen( l_pszKey2) > 0 ) )
01373                     {
01374                         l_pNodeDefinition->addKeyLink( l_pszKey, l_pszKey2);
01375                     }
01376                 }
01377             }
01378         }
01379         CATCH_XML_FLOW_ERROR_RELEASE_AND_RETURN
01380         
01381         RELEASE_AND_RETURN:
01382         releaseCharBuffer( l_pszPkeys);
01383         releaseCharBuffer( l_pszInkeys);
01384         releaseCharBuffer( l_pszOutkeys);
01385 
01386         DEBUG_OUT(SAXDBOBJDefinitionBuilder::endElement)
01387 
01388         ON_XML_FLOW_ERROR_THROW;
01389     }
01390 
01391 
01392 
01393 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
01394 //=============================================================================
01395 
01396 END_XDFLENGINE_NS
01397 

Generated on Sat Oct 4 13:19:55 2003 for XDFLengine by doxygen1.3-rc2