Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision fcbf1918

Von Christian Ehringfeld vor fast 8 Jahren hinzugefügt

  • ID fcbf1918b5340b7f5a3e9734ba67d76cf8e3b048
  • Vorgänger e105465d
  • Nachfolger c6a0f442

Revert "mergedObjects to QSP"

This reverts commit e105465d396df8ec34387afa9f0dd9ac635563c1.

Unterschiede anzeigen:

src/entitymanager.cpp
}
bool EntityManager::saveObject(QSharedPointer<Entity> &entity,
QList<QSharedPointer<Entity >> &mergedObjects, const bool persistRelations,
QList<Entity *> &mergedObjects, const bool persistRelations,
const bool ignoreHasChanged, const bool validate,
const bool relationsIgnoreHasChanged) {
bool merged = mergedObjects.contains(entity);
bool merged = mergedObjects.contains(entity.data());
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<QSharedPointer<Entity >> &mergedObjects, bool withRelations, const bool validate,
QList<Entity *> &mergedObjects, bool withRelations, const bool validate,
const bool relationsIgnoreHasChanged) {
bool ok = true;
if (entity && !mergedObjects.contains(entity)) {
mergedObjects.append(entity);
if (entity && !mergedObjects.contains(entity.data())) {
mergedObjects.append(entity.data());
ok = false;
if (entity->getId() > -1 && (!validate || this->validate(entity))) {
if (withRelations) {
......
}
bool EntityManager::createObject(QSharedPointer<Entity> &entity,
QList<QSharedPointer<Entity >> &mergedObjects, const bool persistRelations,
QList<Entity *> &mergedObjects, const bool persistRelations,
const bool checkDuplicate, const bool validate,
const bool relationsIgnoreHasChanged) {
bool rc = true;
if (entity && !mergedObjects.contains(entity)) {
mergedObjects.append(entity);
if (entity && !mergedObjects.contains(entity.data())) {
mergedObjects.append(entity.data());
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<QSharedPointer<Entity >>();
auto merged = QList<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<QSharedPointer<Entity >>();
auto merged = QList<Entity *>();
foreach (QSharedPointer<Entity> entity, entities) {
ok = this->saveObject(entity, merged, persistRelations,
ignoreHasChanged, validate, relationsIgnoreHasChanged);
......
}
void EntityManager::savePrePersistedRelations(const QSharedPointer<Entity>
&entity, QList<QSharedPointer<Entity >> &mergedObjects, bool ignoreHasChanged) {
&entity, QList<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<QSharedPointer<Entity >> &mergedObjects, bool ignoreHasChanged, bool newItem) {
&entity, QList<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<QSharedPointer<Entity >> &mergedObjects) {
const QString &tblName, QList<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<QSharedPointer<Entity >> &mergedObjects) {
QList<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<QSharedPointer<Entity >> &mergedObjects,
const Relation &r, QVariant &property, QList<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<QSharedPointer<Entity >>();
auto merged = QList<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<QSharedPointer<Entity >>();
auto merged = QList<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<QSharedPointer<Entity >>();
auto merged = QList<Entity *>();
QSharedPointer<Entity> e = entity;
return this->createObject(e, merged, persistRelations,
checkDuplicate, validate, relationsIgnoreHasChanged);
......
}
protected:
bool saveObject(QSharedPointer<Entity> &entity, QList<QSharedPointer<Entity >> &mergedObjects,
bool saveObject(QSharedPointer<Entity> &entity, QList<Entity *> &mergedObjects,
const bool persistRelations = true,
const bool ignoreHasChanged = false, const bool validate = true,
const bool relationsIgnoreHasChanged = false);
bool mergeObject(QSharedPointer<Entity> &entity, QList<QSharedPointer<Entity >> &mergedObjects,
bool mergeObject(QSharedPointer<Entity> &entity, QList<Entity *> &mergedObjects,
bool withRelations,
const bool validate, const bool relationsIgnoreHasChanged = false);
bool createObject(QSharedPointer<Entity> &entity,
QList<QSharedPointer<Entity >> &mergedObjects, const bool persistRelations,
QList<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<QSharedPointer<Entity >> &mergedObjects,
QVariant &property, QList<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<QSharedPointer<Entity >> &mergedObjects, bool ignoreHasChanged = false);
QList<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<QSharedPointer<Entity >> &mergedObjects, bool ignoreHasChanged = false,
QList<Entity *> &mergedObjects, bool ignoreHasChanged = false,
bool newItem = false);
QList<QSharedPointer<Entity>> saveRelationEntities(const
QList<QSharedPointer<Entity>> &list, const Relation &r,
QList<QSharedPointer<Entity >> &mergedObjects);
QList<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<QSharedPointer<Entity >> &mergedObjects);
const QString &tblName, QList<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