umbrello: umbrello/codeimport/sqlimport.h Source File

umbrello 2.32.1 Umbrello UML Modeller is a Unified Modelling Language (UML) diagram program based on KDE Technology

sqlimport.h
Go to the documentation of this file.
1 /*
2 Copyright 2015 Ralf Habacker <ralf.habacker@freenet.de>
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as
6 published by the Free Software Foundation; either version 2 of
7 the License or (at your option) version 3 or any later version
8 accepted by the membership of KDE e.V. (or its successor approved
9 by the membership of KDE e.V.), which shall act as a proxy
10 defined in Section 14 of version 3 of the license.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #ifndef SQLIMPORT_H
22 #define SQLIMPORT_H
23
24 #include "nativeimportbase.h"
25
26 class UMLEntity;
27 class UMLObject;
28
36 class SQLImport : public QObject, public NativeImportBase {
37 Q_OBJECT
38 public:
39 explicit SQLImport(CodeImpThread* thread = 0);
40 virtual ~SQLImport();
41
42 bool parseStmt();
43
44 protected:
45 class ColumnConstraints {
46 public:
47 ColumnConstraints()
48 : primaryKey(false),
49 uniqueKey(false),
50 notNullConstraint(false),
51 autoIncrement(false)
52 {
53 }
54
55 bool primaryKey;
56 bool uniqueKey;
57 bool notNullConstraint;
58 bool autoIncrement;
59 QString collate;
60 QString defaultValue;
61 QString constraintName;
62 QString characterSet;
63 };
64
65 class TableConstraints {
66 public:
67 TableConstraints()
68 : primaryKey(false),
69 uniqueKeys(false),
70 notNullConstraint(false),
71 autoIncrement(false),
72 checkConstraint(false)
73 {
74 }
75
76 bool primaryKey;
77 bool uniqueKeys;
78 bool notNullConstraint;
79 bool autoIncrement;
80 bool checkConstraint;
81 QString checkExpression;
82 QStringList primaryKeyFields;
83 QString uniqueKeyName;
84 QStringList uniqueKeysFields;
85 QString collate;
86 QString defaultValue;
87 QString constraintName;
88 };
89
90 virtual QString advance();
91
92 void fillSource(const QString &word);
93 bool parseCreateTable(QString &token);
94 bool parseAlterTable(QString &token);
95 QString parseIdentifier(QString &token);
96 QString parseDefaultExpression(QString &token);
97 QStringList parseFieldType(QString &token);
98 QStringList parseIdentifierList(QString &token);
99 ColumnConstraints parseColumnConstraints(QString &token);
100 TableConstraints parseTableConstraints(QString &token);
101 bool parseCreateDefinition(QString &token, UMLEntity *entity);
102 UMLObject *addDatatype(const QStringList &type);
103 bool addPrimaryKey(UMLEntity *entity, const QString &name, const QStringList &fields);
104 bool addUniqueConstraint(UMLEntity *entity, const QString &name, const QStringList &fields);
105 bool addForeignConstraint(UMLEntity *entityA, const QString &name, const QStringList &fieldNames,
106 const QString &referencedTable, const QStringList &referencedFields);
107 };
108
109 #endif
110
UMLEntity
Non-graphical Information for an Entity.
Definition: entity.h:35
SQLImport::advance
virtual QString advance()
Definition: sqlimport.cpp:860
UMLObject::isUMLEnum
bool isUMLEnum()
Definition: umlobject.h:210
UMLPackage::addAssocToConcepts
void addAssocToConcepts(UMLAssociation *assoc)
Definition: package.cpp:82
DEBUG_REGISTER
#define DEBUG_REGISTER(src)
Definition: debug_utils.h:131
umlpackagelist.h
UMLObject::ot_EntityConstraint
@ ot_EntityConstraint
Definition: umlobject.h:104
checkconstraint.h
UMLDoc::datatypeFolder
UMLFolder * datatypeFolder() const
Definition: umldoc.cpp:2981
ClassImport::log
void log(const QString &file, const QString &text)
Definition: classimport.cpp:133
SQLImport::TableConstraints::uniqueKeysFields
QStringList uniqueKeysFields
Definition: sqlimport.h:84
UMLObject::name
QString name() const
Definition: umlobject.cpp:211
SQLImport::ColumnConstraints::uniqueKey
bool uniqueKey
Definition: sqlimport.h:56
UMLEntityAttribute::Primary
@ Primary
Definition: entityattribute.h:33
entity.h
UMLClassifier::getFilteredList
virtual UMLClassifierListItemList getFilteredList(UMLObject::ObjectType ot) const
Definition: classifier.cpp:998
UMLForeignKeyConstraint::setReferencedEntity
void setReferencedEntity(UMLEntity *ent)
Definition: foreignkeyconstraint.cpp:336
operation.h
UMLObject::ot_Entity
@ ot_Entity
Definition: umlobject.h:101
foreignkeyconstraint.h
SQLImport::ColumnConstraints::notNullConstraint
bool notNullConstraint
Definition: sqlimport.h:57
SQLImport::addPrimaryKey
bool addPrimaryKey(UMLEntity *entity, const QString &name, const QStringList &fields)
Definition: sqlimport.cpp:890
Uml::ID::None
const Type None
special value for uninitialized ID
Definition: basictypes.h:353
UMLForeignKeyConstraint
Sets up Foreign Key entity constraint information.
Definition: foreignkeyconstraint.h:33
SQLImport::TableConstraints::uniqueKeys
bool uniqueKeys
Definition: sqlimport.h:77
UMLDoc::rootFolder
UMLFolder * rootFolder(Uml::ModelType::Enum mt)
Definition: umldoc.cpp:3196
Uml::ProgrammingLanguage::MySQL
@ MySQL
Definition: basictypes.h:280
UMLEntity::addConstraint
bool addConstraint(UMLEntityConstraint *constr)
Definition: entity.cpp:576
association.h
Import_Utils::createUMLObject
UMLObject * createUMLObject(UMLObject::ObjectType type, const QString &inName, UMLPackage *parentPkg, const QString &comment, const QString &stereotype, bool searchInParentPackageOnly, bool remapParent)
Definition: import_utils.cpp:178
stripQuotes
QString & stripQuotes(QString &token)
Definition: sqlimport.cpp:106
SQLImport::ColumnConstraints::characterSet
QString characterSet
Definition: sqlimport.h:62
UMLEntity::getEntityAttributes
UMLEntityAttributeList getEntityAttributes() const
Definition: entity.cpp:692
SQLImport::TableConstraints::primaryKeyFields
QStringList primaryKeyFields
Definition: sqlimport.h:82
SQLImport::SQLImport
SQLImport(CodeImpThread *thread=0)
Definition: sqlimport.cpp:65
UMLObject
The base class for UML objects.
Definition: umlobject.h:74
SQLImport::TableConstraints::uniqueKeyName
QString uniqueKeyName
Definition: sqlimport.h:83
SQLImport::TableConstraints::notNullConstraint
bool notNullConstraint
Definition: sqlimport.h:78
import_utils.h
UMLDoc::loading
bool loading() const
Definition: umldoc.cpp:1570
UMLObject::asUMLEnum
UMLEnum * asUMLEnum()
Definition: umlobject.cpp:1315
SQLImport::TableConstraints::primaryKey
bool primaryKey
Definition: sqlimport.h:76
UMLObject::ot_EnumLiteral
@ ot_EnumLiteral
Definition: umlobject.h:94
UMLObject::asUMLEntity
UMLEntity * asUMLEntity()
Definition: umlobject.cpp:1312
NativeImportBase::currentScope
UMLPackage * currentScope()
Definition: nativeimportbase.cpp:165
NativeImportBase::skipStmt
void skipStmt(const QString &until=QLatin1String(";"))
Definition: nativeimportbase.cpp:82
Uml::Visibility::Public
@ Public
Definition: basictypes.h:60
Import_Utils::remapUMLEnum
UMLEnum * remapUMLEnum(UMLObject *ns, UMLPackage *currentScope)
Definition: import_utils.cpp:738
NativeImportBase::skipToClosing
bool skipToClosing(QChar opener)
Definition: nativeimportbase.cpp:97
entityattribute.h
SQLImport::parseCreateTable
bool parseCreateTable(QString &token)
Definition: sqlimport.cpp:672
Uml::ModelType::EntityRelationship
@ EntityRelationship
Definition: basictypes.h:46
attribute.h
Model_Utils::uniqObjectName
QString uniqObjectName(UMLObject::ObjectType type, UMLPackage *parentPkg, QString prefix)
Definition: model_utils.cpp:526
SQLImport::parseFieldType
QStringList parseFieldType(QString &token)
Definition: sqlimport.cpp:179
SQLImport::parseTableConstraints
TableConstraints parseTableConstraints(QString &token)
Definition: sqlimport.cpp:492
a
QString a
Definition: petalnode.cpp:18
NativeImportBase::m_source
QStringList m_source
the scanned lexemes
Definition: nativeimportbase.h:95
UMLDoc::setLoading
void setLoading(bool state=true)
Definition: umldoc.cpp:1579
folder.h
UMLObject::ot_Datatype
@ ot_Datatype
Definition: umlobject.h:87
UMLEntity::setAsPrimaryKey
bool setAsPrimaryKey(UMLUniqueConstraint *uconstr)
Definition: entity.cpp:512
SQLImport::TableConstraints::collate
QString collate
Definition: sqlimport.h:85
SQLImport::~SQLImport
virtual ~SQLImport()
Definition: sqlimport.cpp:73
NativeImportBase::advance
virtual QString advance()
Definition: nativeimportbase.cpp:198
UMLEntity::getFilteredList
UMLClassifierListItemList getFilteredList(UMLObject::ObjectType ot) const
Definition: entity.cpp:645
SQLImport::parseColumnConstraints
ColumnConstraints parseColumnConstraints(QString &token)
Definition: sqlimport.cpp:311
NativeImportBase::m_comment
QString m_comment
intermediate accumulator for comment text
Definition: nativeimportbase.h:100
CodeImpThread
Definition: codeimpthread.h:36
Uml::AssociationType::Generalization
@ Generalization
Definition: basictypes.h:107
SQLImport::parseCreateDefinition
bool parseCreateDefinition(QString &token, UMLEntity *entity)
Definition: sqlimport.cpp:552
UMLApp::app
static UMLApp * app()
Definition: uml.cpp:269
sqlimport.h
UMLCheckConstraint::setCheckCondition
void setCheckCondition(const QString &condition)
Definition: checkconstraint.h:55
SQLImport::addForeignConstraint
bool addForeignConstraint(UMLEntity *entityA, const QString &name, const QStringList &fieldNames, const QString &referencedTable, const QStringList &referencedFields)
Definition: sqlimport.cpp:973
SQLImport::parseIdentifier
QString parseIdentifier(QString &token)
Definition: sqlimport.cpp:123
SQLImport::TableConstraints
Definition: sqlimport.h:65
SQLImport::TableConstraints::checkExpression
QString checkExpression
Definition: sqlimport.h:81
UMLFolder
Non-graphical management of objects and diagrams of a Folder.
Definition: folder.h:35
NativeImportBase
Base class for native implementations of language import.
Definition: nativeimportbase.h:45
UMLUniqueConstraint::addEntityAttribute
bool addEntityAttribute(UMLEntityAttribute *attr)
Definition: uniqueconstraint.cpp:245
SQLImport::ColumnConstraints::primaryKey
bool primaryKey
Definition: sqlimport.h:55
nativeimportbase.h
SQLImport::addUniqueConstraint
bool addUniqueConstraint(UMLEntity *entity, const QString &name, const QStringList &fields)
Definition: sqlimport.cpp:934
SQLImport::parseDefaultExpression
QString parseDefaultExpression(QString &token)
Definition: sqlimport.cpp:251
UMLClassifierListItemList
Definition: umlclassifierlistitemlist.h:27
Import_Utils::addEnumLiteral
void addEnumLiteral(UMLEnum *enumType, const QString &literal, const QString &comment, const QString &value)
Definition: import_utils.cpp:593
UMLDoc::findUMLObject
UMLObject * findUMLObject(const QString &name, UMLObject::ObjectType type=UMLObject::ot_UMLObject, UMLObject *currentObj=0)
Definition: umldoc.cpp:1065
DEBUG
#define DEBUG(src)
Definition: debug_utils.h:129
SQLImport::TableConstraints::constraintName
QString constraintName
Definition: sqlimport.h:87
classifier.h
uError
#define uError()
Definition: debug_utils.h:123
uniqueconstraint.h
UMLObject::ot_Enum
@ ot_Enum
Definition: umlobject.h:88
uml.h
UMLCheckConstraint
Sets up Check Constraint information for UMLEntities.
Definition: checkconstraint.h:26
SQLImport::ColumnConstraints::defaultValue
QString defaultValue
Definition: sqlimport.h:60
SQLImport::parseIdentifierList
QStringList parseIdentifierList(QString &token)
Definition: sqlimport.cpp:153
debug_utils.h
UMLAssociation
Sets up association information.
Definition: association.h:33
UMLEntity::addEntityAttribute
UMLObject * addEntityAttribute(const QString &name, Uml::ID::Type id=Uml::ID::None)
Definition: entity.cpp:305
DBG_SRC
#define DBG_SRC
Definition: import_utils.cpp:43
SQLImport::ColumnConstraints::ColumnConstraints
ColumnConstraints()
Definition: sqlimport.h:47
SQLImport::TableConstraints::autoIncrement
bool autoIncrement
Definition: sqlimport.h:79
SQLImport::addDatatype
UMLObject * addDatatype(const QStringList &type)
Definition: sqlimport.cpp:867
b
bool b
Definition: cxx11-null-pointer-constant.h:6
UMLForeignKeyConstraint::addEntityAttributePair
bool addEntityAttributePair(UMLEntityAttribute *pAttr, UMLEntityAttribute *rAttr)
Definition: foreignkeyconstraint.cpp:185
SQLImport::TableConstraints::checkConstraint
bool checkConstraint
Definition: sqlimport.h:80
NativeImportBase::m_srcIndex
int m_srcIndex
used for indexing m_source
Definition: nativeimportbase.h:96
package.h
UMLEntityAttribute
Sets up entityattribute information.
Definition: entityattribute.h:26
SQLImport::ColumnConstraints::constraintName
QString constraintName
Definition: sqlimport.h:61
SQLImport::TableConstraints::TableConstraints
TableConstraints()
Definition: sqlimport.h:67
NativeImportBase::m_parsedFiles
static QStringList m_parsedFiles
Definition: nativeimportbase.h:115
SQLImport::ColumnConstraints::autoIncrement
bool autoIncrement
Definition: sqlimport.h:58
SQLImport
Definition: sqlimport.h:36
UMLEnum
Non-graphical Information for an Enum.
Definition: enum.h:29
SQLImport::ColumnConstraints
Definition: sqlimport.h:45
SQLImport::fillSource
void fillSource(const QString &word)
Definition: sqlimport.cpp:80
UMLApp::document
UMLDoc * document() const
Definition: uml.cpp:1055
umldoc.h
SQLImport::TableConstraints::defaultValue
QString defaultValue
Definition: sqlimport.h:86
SQLImport::ColumnConstraints::collate
QString collate
Definition: sqlimport.h:59
UMLUniqueConstraint
Sets up Unique entity constraint information.
Definition: uniqueconstraint.h:29
SQLImport::parseAlterTable
bool parseAlterTable(QString &token)
Definition: sqlimport.cpp:718
UMLPackage
Non-graphical information for a Package.
Definition: package.h:33
SQLImport::parseStmt
bool parseStmt()
Definition: sqlimport.cpp:804
enum.h