Revision f9dccfc5
Von Christian Ehringfeld vor fast 10 Jahren hinzugefügt
| src/attribute.cpp | ||
|---|---|---|
|
}
|
||
|
|
||
|
QString Attribute::toString() const {
|
||
|
return this->name + " " + this->columnName + " " + this->tableName + " " +
|
||
|
this->relatedTable + " " + this->relatedColumnName + " " + this->conjunctedTable;
|
||
|
return ("Attribute: " + this->name + " " + this->columnName + " " + this->tableName + " " +
|
||
|
this->relatedTable + " " + this->relatedColumnName + " " + this->conjunctedTable);
|
||
|
}
|
||
|
|
||
|
|
||
| src/attributeresolver.cpp | ||
|---|---|---|
|
#include "attributeresolver.h"
|
||
|
#include "entityhelper.h"
|
||
|
#include "querybuilder.h"
|
||
|
#include <QDebug>
|
||
|
using namespace CuteEntityManager;
|
||
|
|
||
|
AttributeResolver::AttributeResolver(QSharedPointer<QueryBuilder> queryBuilder) {
|
||
| ... | ... | |
|
const QString &attr, const Relation &r, const QSharedPointer<Entity> &target) {
|
||
|
auto ptr = e;
|
||
|
QString attributeName = r.getPropertyName();
|
||
|
QString foreignColumnName = target->getTablename();
|
||
|
auto baseObj = EntityHelper::getBaseClassObject(e, attributeName);
|
||
|
Entity* foreignBaseObj = target.data();
|
||
|
if (!r.getMappedBy().isEmpty()) {
|
||
|
ptr = target;
|
||
|
attributeName = r.getMappedBy();
|
||
|
foreignBaseObj = EntityHelper::getBaseClassObject(ptr, attributeName);
|
||
|
foreignColumnName = foreignBaseObj->getTablename();
|
||
|
}
|
||
|
auto obj = EntityHelper::getBaseClassObject(e, attributeName);
|
||
|
/**
|
||
|
* @todo check inheritance and mappedBy
|
||
|
*/
|
||
|
Attribute *attrObj = new Attribute(attr,
|
||
|
this->qb->generateColumnNameID(obj->getTablename()),
|
||
|
e->getTablename(), e->metaObject());
|
||
|
this->qb->generateColumnNameID(baseObj->getTablename()),
|
||
|
baseObj->getTablename(), e->metaObject());
|
||
|
this->resolveInheritance(e, attrObj);
|
||
|
attrObj->setRelation(target->getTablename(), target->metaObject(), r,
|
||
|
this->qb->generateManyToManyTableName(target->getTablename(), attributeName),
|
||
|
this->qb->generateColumnNameID(target->getTablename()));
|
||
|
delete obj;
|
||
|
attrObj->setRelation(foreignBaseObj->getTablename(), target->metaObject(), r,
|
||
|
this->qb->generateManyToManyTableName(foreignBaseObj->getTablename(), attributeName),
|
||
|
this->qb->generateColumnNameID(foreignColumnName));
|
||
|
delete baseObj;
|
||
|
if(foreignBaseObj != target.data()) {
|
||
|
delete foreignBaseObj;
|
||
|
}
|
||
|
|
||
|
qDebug() << "RESOLVE";
|
||
|
return attrObj;
|
||
|
}
|
||
|
|
||
Auch abrufbar als: Unified diff
m-n