Revision 1e213c09
Von Christian Ehringfeld vor mehr als 10 Jahren hinzugefügt
| src/entitymanager.cpp | ||
|---|---|---|
|
#include "entitymanager.h"
|
||
|
#include "enums/databasetype.h"
|
||
|
#include "entityinstancefactory.h"
|
||
|
#include "databasemigration.h"
|
||
|
using namespace CuteEntityManager;
|
||
|
|
||
|
QStringList EntityManager::connectionNames = QStringList();
|
||
| ... | ... | |
|
this->init();
|
||
|
}
|
||
|
|
||
|
bool EntityManager::startup(QString version, QStringList toInitialize) {
|
||
|
DatabaseMigration dbm = DatabaseMigration();
|
||
|
QHash<QString, QVariant> map = QHash<QString, QVariant>();
|
||
|
map.insert("version", version);
|
||
|
this->findAllByAttributes(map, dbm.getTablename());
|
||
|
}
|
||
|
|
||
|
EntityManager::EntityManager(const QString &databaseType, QString databasename , QString hostname, QString username,
|
||
|
QString password, QString port) {
|
||
|
auto db = new Database(databaseType, this->createConnection(), hostname, databasename, username, password,
|
||
| ... | ... | |
|
|
||
|
QList<QSharedPointer<Entity> > EntityManager::findEntityByAttributes(const QSharedPointer<Entity> &entity,
|
||
|
bool ignoreID) {
|
||
|
auto maps = this->findByAttributes(entity, ignoreID);
|
||
|
auto maps = this->findAllByAttributes(entity, ignoreID);
|
||
|
return this->convert(maps, entity.data()->getClassname());
|
||
|
}
|
||
|
|
||
| ... | ... | |
|
}
|
||
|
|
||
|
|
||
|
QList<QHash<QString, QVariant> > EntityManager::findByAttributes(const QSharedPointer<Entity> &entity, bool ignoreID) {
|
||
|
QList<QHash<QString, QVariant> > EntityManager::findAllByAttributes(const QSharedPointer<Entity> &entity,
|
||
|
bool ignoreID) {
|
||
|
QSqlQuery q = this->schema.data()->getQueryBuilder().data()->findByAttributes(entity, ignoreID);
|
||
|
return this->convertQueryResult(q);
|
||
|
}
|
||
|
|
||
|
QList<QHash <QString, QVariant> > EntityManager::findByAttributes(const QHash<QString, QVariant> &m,
|
||
|
QList<QHash <QString, QVariant> > EntityManager::findAllByAttributes(const QHash<QString, QVariant> &m,
|
||
|
const QString &tblname,
|
||
|
bool ignoreID) {
|
||
|
QSqlQuery q = this->schema.data()->getQueryBuilder().data()->findByAttributes(m,
|
||
Auch abrufbar als: Unified diff
...