Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision e105465d

Von Sebastian Diel vor mehr als 7 Jahren hinzugefügt

  • ID e105465d396df8ec34387afa9f0dd9ac635563c1
  • Vorgänger 73e09317
  • Nachfolger fcbf1918

mergedObjects to QSP

Unterschiede anzeigen:

src/entitymanager.cpp
}
bool EntityManager::saveObject(QSharedPointer<Entity> &entity,
QList<Entity *> &mergedObjects, const bool persistRelations,
QList<QSharedPointer<Entity >> &mergedObjects, const bool persistRelations,
const bool ignoreHasChanged, const bool validate,
const bool relationsIgnoreHasChanged) {
bool merged = mergedObjects.contains(entity.data());
bool merged = mergedObjects.contains(entity);
if (entity && !merged && (ignoreHasChanged || this->hasChanged(entity))) {
if (entity->getProperty(entity->getPrimaryKey()).toLongLong() > -1) {
return this->mergeObject(entity, mergedObjects, persistRelations, validate,
......
}
bool EntityManager::mergeObject(QSharedPointer<Entity> &entity,
QList<Entity *> &mergedObjects, bool withRelations, const bool validate,
QList<QSharedPointer<Entity >> &mergedObjects, bool withRelations, const bool validate,
const bool relationsIgnoreHasChanged) {
bool ok = true;
if (entity && !mergedObjects.contains(entity.data())) {
mergedObjects.append(entity.data());
if (entity && !mergedObjects.contains(entity)) {
mergedObjects.append(entity);
ok = false;
if (entity->getId() > -1 && (!validate || this->validate(entity))) {
if (withRelations) {
......
}
bool EntityManager::createObject(QSharedPointer<Entity> &entity,
QList<Entity *> &mergedObjects, const bool persistRelations,
QList<QSharedPointer<Entity >> &mergedObjects, const bool persistRelations,
const bool checkDuplicate, const bool validate,
const bool relationsIgnoreHasChanged) {
bool rc = true;
if (entity && !mergedObjects.contains(entity.data())) {
mergedObjects.append(entity.data());
if (entity && !mergedObjects.contains(entity)) {
mergedObjects.append(entity);
rc = false;
if (this->checkTable(entity) && (!validate || this->validate(entity))
&& (!checkDuplicate || this->count(entity) <= 0)) {
......
const bool persistRelations, const bool checkDuplicate, const bool validate,
const bool relationsIgnoreHasChanged) {
bool ok = true;
auto merged = QList<Entity *>();
auto merged = QList<QSharedPointer<Entity >>();
foreach (QSharedPointer<Entity> ent, entities) {
this->createObject(ent, merged, persistRelations,
checkDuplicate, validate, relationsIgnoreHasChanged);
......
const bool persistRelations, const bool ignoreHasChanged, const bool validate,
const bool relationsIgnoreHasChanged) {
bool ok = true;
auto merged = QList<Entity *>();
auto merged = QList<QSharedPointer<Entity >>();
foreach (QSharedPointer<Entity> entity, entities) {
ok = this->saveObject(entity, merged, persistRelations,
ignoreHasChanged, validate, relationsIgnoreHasChanged);
......
}
void EntityManager::savePrePersistedRelations(const QSharedPointer<Entity>
&entity, QList<Entity *> &mergedObjects, bool ignoreHasChanged) {
&entity, QList<QSharedPointer<Entity >> &mergedObjects, bool ignoreHasChanged) {
auto relations = EntityHelper::getRelationProperties(entity.data());
auto iterator = relations.constBegin();
while (iterator != relations.constEnd()) {
......
}
void EntityManager::savePostPersistedRelations(const QSharedPointer<Entity>
&entity, QList<Entity *> &mergedObjects, bool ignoreHasChanged, bool newItem) {
&entity, QList<QSharedPointer<Entity >> &mergedObjects, bool ignoreHasChanged, bool newItem) {
auto relations = EntityHelper::getRelationProperties(entity.data());
for (auto i = relations.constBegin(); i != relations.constEnd(); ++i) {
const Relation r = i.key();
......
void EntityManager::persistMappedByRelation(const QList<QSharedPointer<Entity>>
&list, QSqlQuery &q, const QSharedPointer<Entity> &entity,
const QSharedPointer<Entity> &ptr, const Relation &r,
const QString &tblName, QList<Entity *> &mergedObjects) {
const QString &tblName, QList<QSharedPointer<Entity >> &mergedObjects) {
q.clear();
QList<QSharedPointer<Entity>> saved =
r.getCascadeType().contains(CascadeType::ALL) ||
......
QList<QSharedPointer<Entity>> EntityManager::saveRelationEntities(
const QList<QSharedPointer<Entity>> &list, const Relation &r,
QList<Entity *> &mergedObjects) {
QList<QSharedPointer<Entity >> &mergedObjects) {
QList<QSharedPointer<Entity>> saved = QList<QSharedPointer<Entity>>();
QSharedPointer<Entity> ptr;
for (int var = 0; var < list.size(); ++var) {
......
}
void EntityManager::persistManyToMany(const QSharedPointer<Entity> &entity,
const Relation &r, QVariant &property, QList<Entity *> &mergedObjects,
const Relation &r, QVariant &property, QList<QSharedPointer<Entity >> &mergedObjects,
const bool ignoreHasChanged, const bool newItem) {
auto list = property.value<QList<QVariant>>();
auto ptr = QSharedPointer<Entity>(EntityInstanceFactory::createInstance(
src/entitymanager.h
bool merge(QSharedPointer<T> &entity, bool withRelations = true,
const bool validate = true, const bool relationsIgnoreHasChanged = false) {
static_assert(std::is_base_of<Entity, T>::value, "T must inherit from Entity");
auto merged = QList<Entity *>();
auto merged = QList<QSharedPointer<Entity >>();
QSharedPointer<Entity> e = entity;
return this->mergeObject(e, merged, withRelations, validate,
relationsIgnoreHasChanged);
......
const bool ignoreHasChanged = false, const bool validate = true,
const bool relationsIgnoreHasChanged = false) {
static_assert(std::is_base_of<Entity, T>::value, "T must inherit from Entity");
auto merged = QList<Entity *>();
auto merged = QList<QSharedPointer<Entity >>();
QSharedPointer<Entity> e = entity;
return this->saveObject(e, merged, persistRelations,
ignoreHasChanged, validate, relationsIgnoreHasChanged);
......
const bool checkDuplicate = false, const bool validate = true,
const bool relationsIgnoreHasChanged = false) {
static_assert(std::is_base_of<Entity, T>::value, "T must inherit from Entity");
auto merged = QList<Entity *>();
auto merged = QList<QSharedPointer<Entity >>();
QSharedPointer<Entity> e = entity;
return this->createObject(e, merged, persistRelations,
checkDuplicate, validate, relationsIgnoreHasChanged);
......
}
protected:
bool saveObject(QSharedPointer<Entity> &entity, QList<Entity *> &mergedObjects,
bool saveObject(QSharedPointer<Entity> &entity, QList<QSharedPointer<Entity >> &mergedObjects,
const bool persistRelations = true,
const bool ignoreHasChanged = false, const bool validate = true,
const bool relationsIgnoreHasChanged = false);
bool mergeObject(QSharedPointer<Entity> &entity, QList<Entity *> &mergedObjects,
bool mergeObject(QSharedPointer<Entity> &entity, QList<QSharedPointer<Entity >> &mergedObjects,
bool withRelations,
const bool validate, const bool relationsIgnoreHasChanged = false);
bool createObject(QSharedPointer<Entity> &entity,
QList<Entity *> &mergedObjects, const bool persistRelations,
QList<QSharedPointer<Entity >> &mergedObjects, const bool persistRelations,
const bool checkDuplicate, const bool validate,
const bool relationsIgnoreHasChanged = false);
void init(bool inspect, const MsgType msgType);
......
void oneToOne(const QSharedPointer<Entity> &entity, Attribute *&attr,
const QVariant &id = "");
void persistManyToMany(const QSharedPointer<Entity> &entity, const Relation &r,
QVariant &property, QList<Entity *> &mergedObjects,
QVariant &property, QList<QSharedPointer<Entity >> &mergedObjects,
const bool ignoreHasChanged = false, const bool newItem = false);
QList<QHash<QString, QVariant>> findAllByAttributes(const
QSharedPointer<Entity> &entity,
......
* @throw can throw in debug mode a QString exception when the type of any Relation is wrong @see EntityManager::checkRelation
*/
void savePrePersistedRelations(const QSharedPointer<Entity> &entity,
QList<Entity *> &mergedObjects, bool ignoreHasChanged = false);
QList<QSharedPointer<Entity >> &mergedObjects, bool ignoreHasChanged = false);
/**
* @brief EntityManager::savePostPersistedRelations
* @param entity
......
* @throw can throw in debug mode a QString exception when the type of any Relation is wrong @see EntityManager::checkRelation
*/
void savePostPersistedRelations(const QSharedPointer<Entity> &entity,
QList<Entity *> &mergedObjects, bool ignoreHasChanged = false,
QList<QSharedPointer<Entity >> &mergedObjects, bool ignoreHasChanged = false,
bool newItem = false);
QList<QSharedPointer<Entity>> saveRelationEntities(const
QList<QSharedPointer<Entity>> &list, const Relation &r,
QList<Entity *> &mergedObjects);
QList<QSharedPointer<Entity >> &mergedObjects);
/**
* @brief EntityManager::persistManyToMany
* @param entity
......
void persistMappedByRelation(const QList<QSharedPointer<Entity>> &list,
QSqlQuery &q, const QSharedPointer<Entity> &entity,
const QSharedPointer<Entity> &ptr, const Relation &r,
const QString &tblName, QList<Entity *> &mergedObjects);
const QString &tblName, QList<QSharedPointer<Entity >> &mergedObjects);
bool shouldBeSaved(QSharedPointer<Entity> &entity , const Relation &r);
void removeRelations(const QSharedPointer<Entity> &entity);
void removeEntityList(QVariant &var);

Auch abrufbar als: Unified diff