Revision d84c91e7
Von Christian Ehringfeld vor mehr als 10 Jahren hinzugefügt
| EntityManager.pro | ||
|---|---|---|
|
src/querybuilder.h \
|
||
|
src/schema/sqlitequerybuilder.h \
|
||
|
src/relation.h \
|
||
|
src/entityinstancefactory.h
|
||
|
src/entityinstancefactory.h \
|
||
|
src/condition.h \
|
||
|
src/cache.h
|
||
|
|
||
|
SOURCES += \
|
||
|
src/entity.cpp \
|
||
| ... | ... | |
|
src/querybuilder.cpp \
|
||
|
src/schema/sqlitequerybuilder.cpp \
|
||
|
src/relation.cpp \
|
||
|
src/entityinstancefactory.cpp
|
||
|
src/entityinstancefactory.cpp \
|
||
|
src/condition.cpp \
|
||
|
src/cache.cpp
|
||
|
|
||
|
unix {
|
||
|
target.path = /usr/lib
|
||
| src/cache.cpp | ||
|---|---|---|
|
#include "cache.h"
|
||
|
using namespace CuteEntityManager;
|
||
|
Cache::Cache() {
|
||
|
|
||
|
}
|
||
|
|
||
| src/cache.h | ||
|---|---|---|
|
#ifndef CACHE_H
|
||
|
#define CACHE_H
|
||
|
|
||
|
namespace CuteEntityManager {
|
||
|
class Cache {
|
||
|
public:
|
||
|
Cache();
|
||
|
};
|
||
|
}
|
||
|
|
||
|
#endif // CACHE_H
|
||
| src/condition.cpp | ||
|---|---|---|
|
#include "condition.h"
|
||
|
using namespace CuteEntityManager;
|
||
|
Condition::Condition() {
|
||
|
|
||
|
}
|
||
|
|
||
| src/condition.h | ||
|---|---|---|
|
#ifndef CONDITION_H
|
||
|
#define CONDITION_H
|
||
|
|
||
|
namespace CuteEntityManager {
|
||
|
class Condition {
|
||
|
public:
|
||
|
Condition();
|
||
|
};
|
||
|
}
|
||
|
|
||
|
#endif // CONDITION_H
|
||
| src/entitymanager.cpp | ||
|---|---|---|
|
DatabaseMigration *dbm = new DatabaseMigration();
|
||
|
QSharedPointer<Entity> ptrDbm = QSharedPointer<Entity>(dbm);
|
||
|
QHash<QString, QVariant> map = QHash<QString, QVariant>();
|
||
|
bool ok = true;
|
||
|
map.insert("version", version);
|
||
|
if (this->findAllByAttributes(map, dbm->getTablename()).isEmpty()) {
|
||
|
for (int var = 0; var < toInitialize.size(); ++var) {
|
||
|
QString c = toInitialize.at(var);
|
||
|
this->createTable(QSharedPointer<Entity>(EntityInstanceFactory::createInstance(c)));
|
||
|
if (ok) {
|
||
|
QString c = toInitialize.at(var);
|
||
|
ok = this->createTable(QSharedPointer<Entity>(EntityInstanceFactory::createInstance(c)));
|
||
|
} else {
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
if (ok) {
|
||
|
dbm->setVersion(version);
|
||
|
dbm->setApplyTime(QDateTime::currentDateTime());
|
||
|
this->create(ptrDbm);
|
||
|
}
|
||
|
dbm->setVersion(version);
|
||
|
dbm->setApplyTime(QDateTime::currentDateTime());
|
||
|
this->create(ptrDbm);
|
||
|
}
|
||
|
delete dbm;
|
||
|
return ok;
|
||
|
}
|
||
|
|
||
|
EntityManager::EntityManager(const QString &databaseType, QString databasename , QString hostname, QString username,
|
||
| ... | ... | |
|
return this->convert(maps, entity.data()->getClassname());
|
||
|
}
|
||
|
|
||
|
bool EntityManager::create(QList<QSharedPointer<Entity> > entities) {
|
||
|
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @TODO insert Relations
|
||
|
* @brief EntityManager::create
|
||
| src/entitymanager.h | ||
|---|---|---|
|
e->setId(id);
|
||
|
return this->findEntity(ptr);
|
||
|
}
|
||
|
template<class T> QSharedPointer<Entity> findEntityByAttributes(QHash<QString, QString> attributes) {
|
||
|
auto list = this->findAllEntitiesByAttributes<T>(attributes,1,0);
|
||
|
if(list.isEmpty()) {
|
||
|
return QSharedPointer<Entity>();
|
||
|
}
|
||
|
return list.at(0);
|
||
|
}
|
||
|
|
||
|
template<class T> QList<QSharedPointer<Entity>> findAllEntitiesByAttributes(QHash<QString, QString> attributes = QHash<QString, QString>(),quint32 limit = 0, quint32 offset = 0) {
|
||
|
|
||
|
}
|
||
|
|
||
|
bool create(QList<QSharedPointer<Entity>> entities);
|
||
|
bool create(QSharedPointer<Entity> &entity);
|
||
|
bool save(QSharedPointer<Entity> &entity);
|
||
|
qint64 findId(QSharedPointer<Entity> &entity);
|
||
|
bool merge(QSharedPointer<Entity> &entity, bool withRelations = true);
|
||
|
template<class T> bool remove(QList<qint64> ids) {
|
||
|
|
||
|
}
|
||
|
bool remove(QSharedPointer<Entity> &entity);
|
||
|
bool removeAll(QString tblname);
|
||
|
bool createTable(const QSharedPointer<Entity> &entity);
|
||
|
qint8 count(const QSharedPointer<Entity> &entity, bool ignoreID = true);
|
||
|
qint8 count(const QString &tableName);
|
||
|
//template<class T> count(QHash<QString, QString> condition = QHash<QString, QString>());
|
||
|
QSharedPointer<Database> getDb() const;
|
||
|
void setDb(const QSharedPointer<Database> &value);
|
||
|
QSharedPointer<Schema> getSchema() const;
|
||
Auch abrufbar als: Unified diff
some stuff