Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 4d58ef6a

Von Christian Ehringfeld vor fast 10 Jahren hinzugefügt

  • ID 4d58ef6a8ae2f665ec083b45d30568cac0b67e34
  • Vorgänger aa44e7d1
  • Nachfolger 2c152ba3

some stuff

Unterschiede anzeigen:

EntityManager.pro
src/entitymanager.h \
src/database.h \
src/enums/databasetype.h \
src/schema.h
src/schema.h \
src/schema/sqliteschema.h \
src/tableschema.h \
src/columnschema.h
SOURCES += \
src/base/entity.cpp \
src/entity.cpp \
src/entitymanager.cpp \
src/database.cpp \
src/schema.cpp
src/schema.cpp \
src/schema/sqliteschema.cpp \
src/tableschema.cpp \
src/columnschema.cpp
unix {
target.path = /usr/lib
INSTALLS += target
}
CONFIG += c++11
src/columnschema.cpp
#include "columnschema.h"
using namespace CuteEntityManager;
ColumnSchema::ColumnSchema() {
}
ColumnSchema::~ColumnSchema() {
}
QString ColumnSchema::getName() const {
return name;
}
void ColumnSchema::setName(const QString &value) {
name = value;
}
bool ColumnSchema::getAllowNull() const {
return allowNull;
}
void ColumnSchema::setAllowNull(bool value) {
allowNull = value;
}
QString ColumnSchema::getDbType() const {
return dbType;
}
void ColumnSchema::setDbType(const QString &value) {
dbType = value;
}
QString ColumnSchema::getDefaultValue() const {
return defaultValue;
}
void ColumnSchema::setDefaultValue(const QString &value) {
defaultValue = value;
}
QList<QString> ColumnSchema::getEnumValues() const {
return enumValues;
}
void ColumnSchema::setEnumValues(const QList<QString> &value) {
enumValues = value;
}
quint8 ColumnSchema::getSize() const {
return size;
}
void ColumnSchema::setSize(const quint8 &value) {
size = value;
}
quint8 ColumnSchema::getPrecision() const {
return precision;
}
void ColumnSchema::setPrecision(const quint8 &value) {
precision = value;
}
quint8 ColumnSchema::getScale() const {
return scale;
}
void ColumnSchema::setScale(const quint8 &value) {
scale = value;
}
bool ColumnSchema::getPrimaryKey() const {
return primaryKey;
}
void ColumnSchema::setPrimaryKey(bool value) {
primaryKey = value;
}
bool ColumnSchema::getAutoIncrement() const {
return autoIncrement;
}
void ColumnSchema::setAutoIncrement(bool value) {
autoIncrement = value;
}
bool ColumnSchema::getUnsignedColumn() const {
return unsignedColumn;
}
void ColumnSchema::setUnsignedColumn(bool value) {
unsignedColumn = value;
}
QString ColumnSchema::getComment() const {
return comment;
}
void ColumnSchema::setComment(const QString &value) {
comment = value;
}
src/columnschema.h
#ifndef COLUMNSCHEMA_H
#define COLUMNSCHEMA_H
#include <QString>
namespace CuteEntityManager {
class ColumnSchema
{
public:
ColumnSchema();
~ColumnSchema();
QString getName() const;
void setName(const QString &value);
bool getAllowNull() const;
void setAllowNull(bool value);
QString getDbType() const;
void setDbType(const QString &value);
QString getDefaultValue() const;
void setDefaultValue(const QString &value);
QList<QString> getEnumValues() const;
void setEnumValues(const QList<QString> &value);
quint8 getSize() const;
void setSize(const quint8 &value);
quint8 getPrecision() const;
void setPrecision(const quint8 &value);
quint8 getScale() const;
void setScale(const quint8 &value);
bool getPrimaryKey() const;
void setPrimaryKey(bool value);
bool getAutoIncrement() const;
void setAutoIncrement(bool value);
bool getUnsignedColumn() const;
void setUnsignedColumn(bool value);
QString getComment() const;
void setComment(const QString &value);
private:
QString name;
bool allowNull;
QString dbType;
QString defaultValue;
QList<QString> enumValues;
quint8 size;
quint8 precision;
quint8 scale;
bool primaryKey;
bool autoIncrement;
bool unsignedColumn;
QString comment;
};
}
#endif // COLUMNSCHEMA_H
src/database.cpp
DatabaseType Database::getDatabaseType() {
QString d = this->database.driverName();
if(d == "qmysql") {
return OpenTeacherTool::MYSQL;
return CuteEntityManager::MYSQL;
} else if(d == "qpgsql") {
return OpenTeacherTool::PGSQL;
return CuteEntityManager::PGSQL;
} else {
return OpenTeacherTool::SQLITE;
return CuteEntityManager::SQLITE;
}
}
......
}
QString Database::sqliteTableList() {
return "SELECT tbl_name FROM sqlite_master WHERE type='table';";
}
QString Database::mysqlTableList() {
return "SHOW TABLES;";
}
//QString Database::mysqlTableList() {
// return "SHOW TABLES;";
//}
QString Database::pgsqlTableList() {
return "SELECT table_name FROM information_schema.tables WHERE table_catalog = '"+this->database.databaseName()+"';";
}
//QString Database::pgsqlTableList() {
// return "SELECT table_name FROM information_schema.tables WHERE table_catalog = '"+this->database.databaseName()+"';";
//}
Database::~Database() {
if(this->database.isOpen()) {
src/entity.cpp
/*
Base class for all models
Copyright (C) 2013 Christian Ehringfeld <c.ehringfeld@t-online.de>
This file is part of OpenTeacherTool.
OpenTeacherTool is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenTeacherTool is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenTeacherTool. If not, see <http://www.gnu.org/licenses/>.
*/
* Copyright (C) 2015 Christian Ehringfeld <c.ehringfeld@t-online.de>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "entity.h"
namespace OpenTeacherTool {
namespace CuteEntityManager {
Entity::Entity() {
Entity::Entity() : QObject(){
this->id = -1;
this->relations = new QHash<QString,Entity*>();
this->attributeValues = new QHash<QString, QVariant>();
}
qint64 Entity::getId() {
......
}
void Entity::setId(qint64 id) {
this->id = id;
this->id = id;
}
Entity::~Entity() {
delete this->relations;
delete this->attributeValues;
}
Entity* Entity::getEntity() {
return this;
}
QString Entity::idColumnSQL() {
return "id BIGINT NOT NULL";
}
//QHash<QString, QString> OpenTeacherTool::Entity::getProperties(Datebasetype t) {
src/entity.h
#include <QMap>
#include <QDebug>
#include <QObject>
#include "enums/persistencetype.h"
#include "enums/databasetype.h"
namespace CuteEntityManager {
src/entitymanager.cpp
*/
#include "entitymanager.h"
using namespace CuteEntityManager;
/**
* Relationen fehlen noch
* Fehlermeldungen erstellen am besten eine Exception Klasse diesbzgl. erstellen
*/
namespace CuteEntityManager {
QStringList EntityManager::connectionNames = QStringList();
EntityManager::EntityManager(QSqlDatabase database) {
......
}
}
return rc;
}
}
src/schema.cpp
#include "schema.h"
using namespace CuteEntityManager;
Schema::Schema()
{
Schema::Schema() {
}
Schema::~Schema()
{
Schema::~Schema() {
}
src/schema.h
#ifndef SCHEMA_H
#define SCHEMA_H
#include <QString>
#include "tableschema.h"
namespace CuteEntityManager {
class Schema
{
class Schema {
public:
Schema();
~Schema();
};
protected:
virtual QList<QString> findTableNames(QString schema = "");
virtual QList<QString> findUniqueIndexes(QString tableName);
virtual TableSchema findConstraints(TableSchema ts);
virtual QString getCreateTableSql(TableSchema ts);
virtual bool findColumns(TableSchema ts);
};
}
#endif // SCHEMA_H
src/schema.h.autosave
#ifndef SCHEMA_H
#define SCHEMA_H
#include <QString>
#include "tableschema.h"
namespace CuteEntityManager {
class Schema {
public:
Schema();
~Schema();
protected:
virtual QList<QString> findTableNames(QString schema = "");
virtual QList<QString> findUniqueIndexes(QString tableName);
virtual TableSchema findConstraints(TableSchema ts);
virtual QString getCreateTableSql(TableSchema ts);
virtual bool findColumns(TableSchema ts);
};
}
#endif // SCHEMA_H
src/schema/sqliteschema.cpp
#include "sqliteschema.h"
SqliteSchema::SqliteSchema() : parent() {
}
SqliteSchema::~SqliteSchema()
{
}
QString Database::sqliteTableList() {
return "SELECT tbl_name FROM sqlite_master WHERE type='table';";
}
src/schema/sqliteschema.h
#ifndef SQLITESCHEMA_H
#define SQLITESCHEMA_H
#include "../schema.h"
namespace CuteEntityManager {
class SqliteSchema : public Schema {
public:
SqliteSchema();
~SqliteSchema();
};
}
#endif // SQLITESCHEMA_H
src/tableschema.cpp
#include "tableschema.h"
TableSchema::TableSchema()
{
}
TableSchema::~TableSchema()
{
}
src/tableschema.h
#ifndef TABLESCHEMA_H
#define TABLESCHEMA_H
namespace CuteEntityManager {
class TableSchema {
public:
TableSchema();
~TableSchema();
};
}
#endif // TABLESCHEMA_H
src/tableschema.h.autosave
#ifndef TABLESCHEMA_H
#define TABLESCHEMA_H
namespace CuteEntityManager {
class TableSchema {
public:
TableSchema();
~TableSchema();
};
}
#endif // TABLESCHEMA_H

Auch abrufbar als: Unified diff