umbrello 25.04.1
Umbrello UML Modeller is a Unified Modelling Language (UML) diagram program based on KDE Technology
Classes | Public Member Functions | Protected Member Functions | List of all members
SQLImport Class Reference

#include <sqlimport.h>

Inheritance diagram for SQLImport:
NativeImportBase ClassImport

Classes

class  ColumnConstraints
 
class  TableConstraints
 

Public Member Functions

 SQLImport (CodeImpThread *thread=nullptr)
 
virtual ~SQLImport ()
 
bool parseStmt ()
 
- Public Member Functions inherited from NativeImportBase
 NativeImportBase (const QString &singleLineCommentIntro, CodeImpThread *thread=nullptr)
 
virtual ~NativeImportBase ()
 
- Public Member Functions inherited from ClassImport
 ClassImport (CodeImpThread *thread=nullptr)
 
virtual ~ClassImport ()
 
bool importFiles (const QStringList &fileNames)
 
bool importFile (const QString &fileName)
 
void setRootPath (const QString &path)
 
bool enabled () const
 

Protected Member Functions

virtual QString advance ()
 
void fillSource (const QString &word)
 
bool parseCreateTable (QString &token)
 
bool parseAlterTable (QString &token)
 
QString parseIdentifier (QString &token)
 
QString parseDefaultExpression (QString &token)
 
QStringList parseFieldType (QString &token)
 
QStringList parseIdentifierList (QString &token)
 
ColumnConstraints parseColumnConstraints (QString &token)
 
TableConstraints parseTableConstraints (QString &token)
 
bool parseCreateDefinition (QString &token, UMLEntity *entity)
 
UMLObjectaddDatatype (const QStringList &type)
 
bool addPrimaryKey (UMLEntity *entity, const QString &name, const QStringList &fields)
 
bool addUniqueConstraint (UMLEntity *entity, const QString &name, const QStringList &fields)
 
bool addForeignConstraint (UMLEntity *entityA, const QString &name, const QStringList &fieldNames, const QString &referencedTable, const QStringList &referencedFields)
 
- Protected Member Functions inherited from NativeImportBase
void initialize ()
 
void setMultiLineComment (const QString &intro, const QString &end)
 
void setMultiLineAltComment (const QString &intro, const QString &end)
 
virtual bool parseFile (const QString &filename)
 
virtual void initVars ()
 
void scan (const QString &line)
 
virtual bool preprocess (QString &line)
 
virtual QStringList split (const QString &line)
 
void skipStmt (const QString &until=QStringLiteral(";"))
 
bool skipToClosing (QChar opener)
 
QString current ()
 
QString lookAhead ()
 
void pushScope (UMLPackage *p)
 
UMLPackagepopScope ()
 
UMLPackagecurrentScope ()
 
int scopeIndex ()
 
- Protected Member Functions inherited from ClassImport
virtual void initPerFile ()
 
void log (const QString &file, const QString &text)
 
void log (const QString &text)
 

Additional Inherited Members

- Static Public Member Functions inherited from ClassImport
static ClassImportcreateImporterByFileExt (const QString &fileName, CodeImpThread *thread=nullptr)
 
- Protected Attributes inherited from NativeImportBase
QString m_singleLineCommentIntro
 start token of a single line comment
 
QStringList m_source
 the scanned lexemes
 
int m_srcIndex
 used for indexing m_source
 
QList< UMLPackage * > m_scope
 stack of scopes for use by the specific importer
 
UMLClassifierm_klass
 class currently being processed
 
Uml::Visibility::Enum m_currentAccess
 current access (public/protected/private)
 
QString m_comment
 intermediate accumulator for comment text
 
bool m_inComment
 
bool m_isAbstract
 accumulator for abstractness
 
QString m_multiLineCommentIntro
 multi line comment delimiter intro
 
QString m_multiLineCommentEnd
 multi line comment delimiter end
 
QString m_multiLineAltCommentIntro
 
QString m_multiLineAltCommentEnd
 
- Protected Attributes inherited from ClassImport
CodeImpThreadm_thread
 thread in which the work of importing is done
 
bool m_enabled
 state of importer
 
QString m_rootPath
 root path of import
 
- Static Protected Attributes inherited from NativeImportBase
static QStringList m_parsedFiles
 

Detailed Description

Postgresql/mysql code import

Author
Ralf Habacker ralf..nosp@m.haba.nosp@m.cker@.nosp@m.free.nosp@m.net.d.nosp@m.e

Bugs and comments to umbre.nosp@m.llo-.nosp@m.devel.nosp@m.@kde.nosp@m..org or https://bugs.kde.org

Constructor & Destructor Documentation

◆ SQLImport()

SQLImport::SQLImport ( CodeImpThread thread = nullptr)
explicit

Constructor.

Parameters
threadthread in which the code import runs

◆ ~SQLImport()

SQLImport::~SQLImport ( )
virtual

Destructor.

Member Function Documentation

◆ addDatatype()

UMLObject * SQLImport::addDatatype ( const QStringList &  type)
protected

◆ addForeignConstraint()

bool SQLImport::addForeignConstraint ( UMLEntity entityA,
const QString &  _name,
const QStringList &  fieldNames,
const QString &  referencedTable,
const QStringList &  referencedFields 
)
protected

Add UML object foreign constraint.

Parameters
entityAentity object the foreign constraint belongs
_namename of foreign constraint
fieldNameslist of field names
referencedTablereferenced table name
referencedFieldslist of referenced field names
Returns
true on success
false on error

◆ addPrimaryKey()

bool SQLImport::addPrimaryKey ( UMLEntity entity,
const QString &  name,
const QStringList &  fields 
)
protected

◆ addUniqueConstraint()

bool SQLImport::addUniqueConstraint ( UMLEntity entity,
const QString &  _name,
const QStringList &  fields 
)
protected

Add UML object for unique constraint.

Parameters
entityentity object
_nameunique constraint name
fieldsfield list
Returns
true on success
false on error

◆ advance()

QString SQLImport::advance ( )
protectedvirtual

Implement virtual method

Returns
string with next token

Reimplemented from NativeImportBase.

◆ fillSource()

void SQLImport::fillSource ( const QString &  word)
protectedvirtual

Implement abstract operation from NativeImportBase.

Implements NativeImportBase.

◆ parseAlterTable()

bool SQLImport::parseAlterTable ( QString &  token)
protected

Parse alter table statement.

Parameters
tokenstring with current token
Returns
true on success
false on error

◆ parseColumnConstraints()

SQLImport::ColumnConstraints SQLImport::parseColumnConstraints ( QString &  token)
protected

Parse column constraint.

pgsql: [ CONSTRAINT constraint_name ] { NOT NULL | NULL | CHECK ( expression ) | COLLATE collation | DEFAULT default_expr | UNIQUE index_parameters | PRIMARY KEY index_parameters | REFERENCES reftable [ ( refcolumn ) ] [ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ] [ ON DELETE action ] [ ON UPDATE action ] } [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ]

mysql: [ PRIMARY KEY index_parameters | KEY key_name ( fields ) CHARACTER SET charset_name | COLLATE collation ]

Parameters
tokenstring with current token
Returns
column constraints

◆ parseCreateDefinition()

bool SQLImport::parseCreateDefinition ( QString &  token,
UMLEntity entity 
)
protected

Parse table create definition.

Parameters
tokenstring with current token
entityentity to save the definition into
Returns
true on success
false on error

◆ parseCreateTable()

bool SQLImport::parseCreateTable ( QString &  token)
protected

Parse create table statement.

Parameters
tokenstring with current token
Returns
true on success
false on error

◆ parseDefaultExpression()

QString SQLImport::parseDefaultExpression ( QString &  token)
protected

Parse default expression.

The expression could be in the form (expression)::<type> function(expression)

Parameters
tokenstring with current token
Returns
string with default expression

◆ parseFieldType()

QStringList SQLImport::parseFieldType ( QString &  token)
protected

Parse field type.

Parameters
tokenstring with current token
Returns
string list containing field type (index 0), size/count (index 1) and optional values (index > 2)

◆ parseIdentifier()

QString SQLImport::parseIdentifier ( QString &  token)
protected

Parse identifier.

Parameters
tokenstring with current token
Returns
parsed identifier

◆ parseIdentifierList()

QStringList SQLImport::parseIdentifierList ( QString &  token)
protected

Parse identifier list.

Parameters
tokenstring with current token
Returns
string list with identifiers

◆ parseStmt()

bool SQLImport::parseStmt ( )
virtual

Implement abstract operation from NativeImportBase.

Implements NativeImportBase.

◆ parseTableConstraints()

SQLImport::TableConstraints SQLImport::parseTableConstraints ( QString &  token)
protected

Parse table constraint.

pgsql:

[ CONSTRAINT constraint_name ] { CHECK ( expression ) | UNIQUE ( column_name [, ... ] ) index_parameters | PRIMARY KEY ( column_name [, ... ] ) index_parameters | EXCLUDE [ USING index_method ] ( exclude_element WITH operator [, ... ] ) index_parameters [ WHERE ( predicate ) ] | FOREIGN KEY ( column_name [, ... ] ) REFERENCES reftable [ ( refcolumn [, ... ] ) ] [ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ] [ ON DELETE action ] [ ON UPDATE action ] } [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ]

mysql: PRIMARY KEY (`uid`, `pid`) | KEY `t3ver_oid` (`t3ver_oid`,`t3ver_wsid`) UNIQUE KEY `entry_identifier` (`entry_namespace`,`entry_key`)

Parameters
tokenstring with current token
Returns
table constraints

The documentation for this class was generated from the following files: