643 lines
17 KiB
C++
643 lines
17 KiB
C++
#pragma execution_character_set("utf-8")
|
||
#include <QFileDialog>
|
||
|
||
#include "DataModelData.h"
|
||
#include "global.h"
|
||
#include "M_EntityModelDAO.h"
|
||
#include "M_FolderDAO.h"
|
||
#include "DataPack.h"
|
||
#include "DataManager.h"
|
||
#include "ProjectData.h"
|
||
#include "DataClass.h"
|
||
#include "DataAttribute.h"
|
||
#include <QDateTime>
|
||
|
||
|
||
//数据模型
|
||
|
||
DataModelData::DataModelData()
|
||
{
|
||
_baseType = g_TYPE_DATAMODEL;
|
||
}
|
||
|
||
DataModelData::~DataModelData()
|
||
{
|
||
|
||
}
|
||
|
||
void static backupDAOData(DBPlatformSpace::M_EntityModelDAO& src, DBPlatformSpace::M_EntityModelDAO& dst)
|
||
{
|
||
|
||
}
|
||
|
||
void static restoreData(DBPlatformSpace::M_EntityModelDAO& src, DataModelData& dst)
|
||
{
|
||
//主要恢复界面属性值和updateTime值
|
||
}
|
||
|
||
void DataModelData::saveToDao()
|
||
{
|
||
using namespace DBPlatformSpace;
|
||
M_EntityModelDAO* pDao = dynamic_cast<M_EntityModelDAO*>(_pDBDAO);
|
||
|
||
if (pDao == nullptr)
|
||
{
|
||
pDao = new M_EntityModelDAO();
|
||
_pDBDAO = pDao;
|
||
}
|
||
|
||
|
||
pDao->_name = CommonHelper::qstringToStdString(getName()); //数据模型标识
|
||
pDao->_type = _type;
|
||
pDao->_createTime = CommonHelper::qstringToStdString(_createTime);
|
||
pDao->_updateTime = CommonHelper::qstringToStdString(_updateTime);
|
||
pDao->_description = CommonHelper::qstringToStdString(_description);
|
||
pDao->_isVersionLocked = _isVerLocked; //?
|
||
pDao->_displayName = CommonHelper::qstringToStdString(_displayName);
|
||
}
|
||
|
||
bool DataModelData::saveSelf()
|
||
{
|
||
using namespace DBPlatformSpace;
|
||
ResultMsg rm;
|
||
/*将这条项目数据写入数据库*/
|
||
M_EntityModelDAO* pDao = dynamic_cast<M_EntityModelDAO*>(_pDBDAO);
|
||
/*备份DAO数据*/
|
||
M_EntityModelDAO oldDaoData;
|
||
|
||
if (pDao == nullptr)
|
||
{
|
||
pDao = new M_EntityModelDAO();
|
||
_pDBDAO = pDao;
|
||
}
|
||
else
|
||
{
|
||
backupDAOData(*pDao, oldDaoData);
|
||
}
|
||
|
||
saveToDao();
|
||
|
||
rm = pDao->save();
|
||
if (rm.rCode == 0)
|
||
{
|
||
LOG(INFO) << CommonHelper::utf8ToStdString("M_EntityModelDAO.save success");
|
||
return true;
|
||
}
|
||
else
|
||
{
|
||
LOG(INFO) << CommonHelper::utf8ToStdString("M_EntityModelDAO.save failed");
|
||
LOG(INFO) << rm.rMsg;
|
||
restoreData(oldDaoData, *this);
|
||
return false;
|
||
}
|
||
}
|
||
|
||
bool DataModelData::addChild(DPData* pNewData)
|
||
{
|
||
//新增数据类模块
|
||
using namespace DBPlatformSpace;
|
||
ResultMsg rm;
|
||
M_EntityModelDAO* pModelDAO = dynamic_cast<M_EntityModelDAO*>(_pDBDAO);
|
||
pNewData->saveToDao();
|
||
DataPack* pPack = qobject_cast<DataPack*>(pNewData);
|
||
M_FolderDAO* pFolderDAO = dynamic_cast<M_FolderDAO*>(pNewData->_pDBDAO);
|
||
rm = pModelDAO->addM_FolderDAO(pFolderDAO);
|
||
if (rm.rCode == 0)
|
||
{
|
||
LOG(INFO) << CommonHelper::utf8ToStdString("M_EntityModelDAO.addM_FolderDAO success");
|
||
//新建成功
|
||
pPack->_id = pFolderDAO->_ID;
|
||
pPack->_wCreateVersion = pFolderDAO->_addVersion; //建立版本
|
||
//保存数据模型成功,添加到childMap
|
||
_childrenMap.insert(pNewData->_id, pNewData);
|
||
return true;
|
||
}
|
||
else
|
||
{
|
||
LOG(INFO) << CommonHelper::utf8ToStdString("M_EntityModelDAO.addM_FolderDAO failed");
|
||
LOG(ERROR) << rm.rMsg;
|
||
return false;
|
||
}
|
||
}
|
||
|
||
bool DataModelData::deleteChild(unsigned int id)
|
||
{
|
||
_childrenMap.remove(id);
|
||
return true;
|
||
}
|
||
|
||
/*从数据库加载数据到当前对象*/
|
||
void DataModelData::loadData(DBPlatformSpace::DAO* pDao)
|
||
{
|
||
_pDBDAO = pDao;
|
||
//将DAO数据存入DataModelData对象
|
||
DBPlatformSpace::M_EntityModelDAO* pDAOData = dynamic_cast<DBPlatformSpace::M_EntityModelDAO*>(_pDBDAO);
|
||
setID(pDAOData->_ID);
|
||
setName(CommonHelper::stringToQstring(pDAOData->_name)); //数据模型标识
|
||
_type = pDAOData->_type;
|
||
_createTime = CommonHelper::stringToQstring(pDAOData->_createTime);
|
||
_updateTime = CommonHelper::stringToQstring(pDAOData->_updateTime);
|
||
_description = CommonHelper::stringToQstring(pDAOData->_description);
|
||
_displayName = CommonHelper::stringToQstring(pDAOData->_displayName);
|
||
_version = pDAOData->_version;
|
||
_isDeleted = pDAOData->_isDeleted;
|
||
_isReleased = pDAOData->_isReleased;
|
||
_isVerLocked = pDAOData->_isVersionLocked;
|
||
}
|
||
|
||
/*降版处理*/
|
||
//当前版本删除,剩下最高版本变为非锁定状态
|
||
void DataModelData::downgradeVersion()
|
||
{
|
||
ProjectData* pProject = qobject_cast<ProjectData*>(_parent);
|
||
QList<DPData*> modelList;
|
||
pProject->findDatamodelByName(_name, modelList);
|
||
if (modelList.size() == 0)
|
||
{
|
||
return;
|
||
}
|
||
DataModelData* pDest = qobject_cast<DataModelData*>(modelList.at(0));
|
||
for (int i = 1; i < modelList.size(); i++)
|
||
{
|
||
DataModelData* pCur = qobject_cast<DataModelData*>(modelList.at(i));
|
||
if (pCur->_version > pDest->_version)
|
||
{
|
||
pDest = pCur;
|
||
}
|
||
}
|
||
pDest->_isVerLocked = 0;
|
||
pDest->saveSelf();
|
||
}
|
||
|
||
|
||
/*从数据库中删除当前数据*/
|
||
bool DataModelData::deleteSelf()
|
||
{
|
||
if (_pDBDAO)
|
||
{
|
||
DBPlatformSpace::ResultMsg rm = _pDBDAO->delself();
|
||
if (rm.rCode == 0)
|
||
{
|
||
LOG(INFO) << CommonHelper::utf8ToStdString("M_EntityModelDAO.delself success");
|
||
if (_parent)
|
||
{
|
||
//数据库删除成功,从内存项目中删除该数据模型
|
||
_parent->deleteChild(_id);
|
||
removeChildinDPMap();
|
||
//处理降版问题
|
||
downgradeVersion();
|
||
return true;
|
||
}
|
||
else
|
||
{
|
||
//_parent = Null
|
||
LOG(ERROR) << CommonHelper::utf8ToStdString("DataModelData.parent 为null ");
|
||
return false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
LOG(INFO) << CommonHelper::utf8ToStdString("M_EntityModelDAO.delself failed");
|
||
LOG(ERROR) << rm.rMsg;
|
||
//从数据库删除失败
|
||
return false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//_pDBDAO为空
|
||
return false;
|
||
}
|
||
|
||
}
|
||
|
||
/*升版*/
|
||
bool DataModelData::upgradeVersion(DataModelData*& pNew)
|
||
{
|
||
using namespace DBPlatformSpace;
|
||
ResultMsg rm;
|
||
if (_pDBDAO)
|
||
{
|
||
M_EntityModelDAO* pNewModelDAO = dynamic_cast<M_EntityModelDAO*>(pNew->_pDBDAO);
|
||
if (!pNewModelDAO)
|
||
{
|
||
pNewModelDAO = new M_EntityModelDAO();
|
||
}
|
||
M_EntityModelDAO* pModelDAO = dynamic_cast<M_EntityModelDAO*>(_pDBDAO);
|
||
// int newVersionModelId = 0;
|
||
rm = pModelDAO->upgradeNewVersion(pNewModelDAO);
|
||
if (rm.rCode == 0)
|
||
{
|
||
LOG(INFO) << CommonHelper::utf8ToStdString("M_EntityModelDAO.upgradeNewVersion success");
|
||
//给新数据模型赋值
|
||
pNew->loadData(pNewModelDAO);
|
||
//升版后原模型需要锁定
|
||
this->_isVerLocked = pModelDAO->_isVersionLocked;
|
||
return true;
|
||
}
|
||
else
|
||
{
|
||
LOG(INFO) << CommonHelper::utf8ToStdString("M_EntityModelDAO.upgradeNewVersion failed");
|
||
LOG(ERROR) << rm.rMsg;
|
||
return false;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
/*实例生成*/
|
||
bool DataModelData::createInstance(QString& msg)
|
||
{
|
||
using namespace DBPlatformSpace;
|
||
ResultMsg rm;
|
||
|
||
//选择生成实例文件全路径
|
||
QString file = QFileDialog::getSaveFileName(nullptr, tr("保存实例文件"), "", "", nullptr, QFileDialog::DontConfirmOverwrite);
|
||
|
||
if (file.isEmpty())
|
||
{
|
||
msg = "未选择实例文件路径";
|
||
return false;
|
||
}
|
||
QFileInfo selectFile(file);
|
||
if (selectFile.isFile() )
|
||
{
|
||
//文件存在
|
||
msg = "文件已存在,请重新命名!";
|
||
return false;
|
||
}
|
||
|
||
//分别获取路径与文件名
|
||
int pos = file.lastIndexOf("/");
|
||
QString path = file.left(pos);
|
||
QString name = file.right(file.size() - pos - 1);
|
||
//检查文件是否重名
|
||
QFileInfoList filelist;
|
||
QDir dir(path);
|
||
for each (QFileInfo info in dir.entryInfoList(QDir::Files))
|
||
{
|
||
filelist.append(info);
|
||
}
|
||
|
||
if (_pDBDAO)
|
||
{
|
||
M_EntityModelDAO* pModel = dynamic_cast<M_EntityModelDAO*>(_pDBDAO);
|
||
rm = pModel->createInstance(CommonHelper::qstringToStdString(path), CommonHelper::qstringToStdString(name));
|
||
if (rm.rCode == 0)
|
||
{
|
||
LOG(INFO) << CommonHelper::utf8ToStdString("M_EntityModelDAO.createInstance success");
|
||
return true;
|
||
}
|
||
else
|
||
{
|
||
LOG(INFO) << CommonHelper::utf8ToStdString("M_EntityModelDAO.createInstance failed");
|
||
LOG(ERROR) << rm.rMsg;
|
||
msg = "生成实例文件失败";
|
||
return false;
|
||
}
|
||
}
|
||
msg = "程序出错,请查看日志";
|
||
LOG(ERROR) << "createInstance: _pDBDAO is null";
|
||
return false;
|
||
}
|
||
/*复制数据模型*/
|
||
|
||
bool DataModelData::copyData(DataModelData*& pNew, json& parameter)
|
||
{
|
||
auto data = parameter["data"];
|
||
using namespace DBPlatformSpace;
|
||
ResultMsg rm;
|
||
M_EntityModelDAO* pModelDAO = dynamic_cast<M_EntityModelDAO*>(_pDBDAO);
|
||
if (pModelDAO)
|
||
{
|
||
M_EntityModelDAO* pNewModelDAO = dynamic_cast<M_EntityModelDAO*>(pNew->_pDBDAO);
|
||
if (!pNewModelDAO)
|
||
{
|
||
pNewModelDAO = new M_EntityModelDAO();
|
||
}
|
||
//给新数据模型确定名称标识
|
||
QString newDisplayName = _displayName + "_[" + QString::number(_version) + "]" + "复制";
|
||
//进行显示名称重名验证,若有重名,加序号
|
||
int nameId = 0;
|
||
QString newName = newDisplayName;
|
||
while (isDuplicatName(newName, "displayName"))
|
||
{
|
||
nameId += 1;
|
||
newName = newDisplayName + QString::number(nameId);
|
||
}
|
||
pNewModelDAO->_displayName = CommonHelper::qstringToStdString(newName);
|
||
//名称标识重名判断
|
||
QString nameFlag;
|
||
if (!data["label"].is_null())
|
||
{
|
||
nameFlag = CommonHelper::utf8ToQString(data["label"]);
|
||
}
|
||
if (nameFlag.isEmpty())
|
||
{
|
||
//如果为空,自动处理加上
|
||
nameFlag = _name;
|
||
int nameId = 0;
|
||
newName = nameFlag;
|
||
while (isDuplicatName(newName, "name"))
|
||
{
|
||
nameId += 1;
|
||
newName = nameFlag + QString::number(nameId);
|
||
}
|
||
pNewModelDAO->_name = CommonHelper::qstringToStdString(newName);
|
||
}
|
||
|
||
rm = pModelDAO->copyTo(pNewModelDAO);
|
||
if (rm.rCode == 0)
|
||
{
|
||
LOG(INFO) << CommonHelper::utf8ToStdString("M_EntityModelDAO.copyTo success");
|
||
//给新数据模型赋值
|
||
pNew->loadData(pNewModelDAO);
|
||
_parent->_childrenMap.insert(pNew->_id, pNew);
|
||
return true;
|
||
}
|
||
else
|
||
{
|
||
LOG(INFO) << CommonHelper::utf8ToStdString("M_EntityModelDAO.copyTo failed");
|
||
LOG(ERROR) << rm.rMsg;
|
||
return false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//为空?
|
||
return false;
|
||
}
|
||
}
|
||
|
||
void DataModelData::toJson(json& jsonObj, bool /*recursive*/)
|
||
{
|
||
jsonObj["id"] = _id;
|
||
jsonObj["name"] = CommonHelper::qstringToUtf8(_displayName);
|
||
jsonObj["type"] = _type;
|
||
jsonObj["identification"] = CommonHelper::qstringToUtf8(_name);
|
||
jsonObj["description"] = CommonHelper::qstringToUtf8(_description);
|
||
jsonObj["version"] = _version;
|
||
jsonObj["locked"] = _isVerLocked;
|
||
jsonObj["deleted"] = _isDeleted;
|
||
jsonObj["published"] = _isReleased;
|
||
jsonObj["createTime"] = CommonHelper::qstringToUtf8(getCreateTime());
|
||
jsonObj["updateTime"] = CommonHelper::qstringToUtf8(getUpdateTime());
|
||
jsonObj["classType"] = g_TYPE_DATAMODEL;
|
||
}
|
||
|
||
void DataModelData::removeChildinDPMap()
|
||
{
|
||
DataManager& mgr = GetDataRoot();
|
||
QMap<unsigned int, DPData*>::iterator it = _childrenMap.begin();
|
||
while (it != _childrenMap.end())
|
||
{
|
||
mgr.deleteInDataMap(DataManager::DataType::dataPack, (*it)->_id);
|
||
qobject_cast<DataPack*>(*it)->removeChildinDPMap();
|
||
it++;
|
||
}
|
||
}
|
||
|
||
//获取所有数据,数据模型数据树
|
||
void DataModelData::getAllChildren(DPData* pManager, bool reload)
|
||
{
|
||
using namespace DBPlatformSpace;
|
||
ResultMsg rm;
|
||
|
||
DataManager* pMng = qobject_cast<DataManager*>(pManager);
|
||
//重新加载
|
||
if (reload)
|
||
{
|
||
removeChildinDPMap();
|
||
qDeleteAll(_childrenMap);
|
||
_childrenMap.clear();
|
||
_initChildren = false;
|
||
}
|
||
|
||
if (_initChildren)
|
||
{
|
||
return;
|
||
}
|
||
|
||
M_EntityModelDAO* pMoldeDAO = dynamic_cast<M_EntityModelDAO*>(_pDBDAO);
|
||
//获取所有根数据模块
|
||
list<M_FolderDAO*> listDataPack;
|
||
rm = pMoldeDAO->getRootM_FolderDAOList(listDataPack);
|
||
if (rm.rCode != 0)
|
||
{
|
||
LOG(INFO) << CommonHelper::utf8ToStdString("M_EntityModelDAO.getRootM_FolderDAOList failed");
|
||
LOG(ERROR) << rm.rMsg;
|
||
return;
|
||
}
|
||
LOG(INFO) << CommonHelper::utf8ToStdString("M_EntityModelDAO.getRootM_FolderDAOList success");
|
||
_initChildren = true;
|
||
for (list<M_FolderDAO*>::iterator it = listDataPack.begin(); it != listDataPack.end(); ++it)
|
||
{
|
||
DataPack* pNew = new DataPack();
|
||
pNew->loadData(*it);
|
||
pNew->_parent = this;
|
||
pNew->_bIsChildPack = false;
|
||
_childrenMap.insert(pNew->_id, pNew);
|
||
//加入数据map
|
||
pMng->insertDataMap(DataManager::DataType::dataPack, pNew->_id, pNew);
|
||
//取下层子模块
|
||
pNew->getAllChildren(pMng);
|
||
}
|
||
}
|
||
|
||
void DataModelData::getNewProperty(json& parameter, QVariantMap& values)
|
||
{
|
||
//所有能通过参数进来的属性
|
||
//name des type
|
||
auto data = parameter["data"];
|
||
auto type = data["type"];
|
||
if (!data["name"].is_null())
|
||
{
|
||
values.insert("displayName", CommonHelper::utf8ToQString(data["name"]));
|
||
}
|
||
if (!data["type"].is_null())
|
||
{
|
||
values.insert("type", (int)data["type"]);
|
||
}
|
||
if (!data["description"].is_null())
|
||
{
|
||
values.insert("description", CommonHelper::utf8ToQString(data["description"]));
|
||
}
|
||
if (!data["identification"].is_null())
|
||
{ //名称标识
|
||
values.insert("name", CommonHelper::utf8ToQString(data["identification"]));
|
||
}
|
||
}
|
||
|
||
void DataModelData::setNewData(json& parameter)
|
||
{
|
||
//当前时间
|
||
QString curTime = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm");
|
||
QVariantMap valueMap;
|
||
getNewProperty(parameter, valueMap);
|
||
valueMap.insert("createTime", curTime);
|
||
valueMap.insert("updateTime", curTime);
|
||
//保存属性
|
||
setProperties(valueMap);
|
||
}
|
||
|
||
void DataModelData::setEditData(json& parameter)
|
||
{
|
||
//当前时间
|
||
QString curTime = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm");
|
||
QVariantMap valueMap;
|
||
getNewProperty(parameter, valueMap);
|
||
valueMap.insert("updateTime", curTime);
|
||
setProperties(valueMap);
|
||
}
|
||
|
||
// bool DataModelData::isDuplicateDisplayName(QString name)
|
||
// {
|
||
// //看是否有重名的数据模型,如果有相同的显示名称,则返回true.无重名则返回false
|
||
// //获取根结点
|
||
// DataManager* pManager = qobject_cast<DataManager*>(_parent->_parent);
|
||
// QMap<unsigned int, DPData*>::iterator it;
|
||
// QMap<unsigned int, DPData*> modelMap;
|
||
// pManager->getDataMap(DataManager::DataType::dataModel,modelMap);
|
||
// it = modelMap.begin();
|
||
// while (it != modelMap.end())
|
||
// {
|
||
// DataModelData* pModelData = qobject_cast<DataModelData*>(*it);
|
||
// if (pModelData->_displayName == name)
|
||
// {
|
||
// return true;
|
||
// }
|
||
// it++;
|
||
// }
|
||
// return false;
|
||
// }
|
||
|
||
//在同一项目中 名称/显示名称 是否重复
|
||
bool DataModelData::isDuplicatName(QString name, QString propertyName)
|
||
{
|
||
// ProjectData* pManager = qobject_cast<ProjectData*>(_parent);
|
||
QMap<unsigned int, DPData*>::iterator it;
|
||
|
||
it = _parent->_childrenMap.begin();
|
||
while (it != _parent->_childrenMap.end())
|
||
{
|
||
QString n = (*it)->property(CommonHelper::qstringToString(propertyName)).toString();
|
||
if (n == name)
|
||
{
|
||
return true;
|
||
}
|
||
it++;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
|
||
void DataModelData::takeRelationTableName()
|
||
{
|
||
DataManager& mgr = GetDataRoot();
|
||
//mn关系,通过关系类
|
||
QMap<unsigned int, DPData*> classMap;
|
||
mgr.getDataMap(DataManager::DataType::dataClass, classMap);
|
||
QList<unsigned int> keylist = classMap.keys();
|
||
for (int i = 0; i < keylist.size(); i++)
|
||
{
|
||
DataClass* pData = qobject_cast<DataClass*>(classMap.value(keylist.at(i)));
|
||
if (pData->_type == g_RELATED_CLASS)
|
||
{
|
||
if (pData->getDataModelOwner()->_id == _id)
|
||
{
|
||
QString mnRelName = pData->_name.right(pData->_name.size() - 3);
|
||
//"_"的位置
|
||
int pos = mnRelName.indexOf("_");
|
||
//主类名
|
||
QString mainClassName = mnRelName.left(pos);
|
||
DPData* pMain = nullptr;
|
||
while (!pMain)
|
||
{
|
||
pMain = mgr.findobjectByNameInDatamodel(g_RELATED_CLASS, "name", mainClassName, _id);
|
||
if (pMain)
|
||
{
|
||
break;
|
||
}
|
||
pos = mnRelName.indexOf("_", pos + 1); //查找下一个
|
||
if (pos == -1)
|
||
{
|
||
return;
|
||
}
|
||
mainClassName = mnRelName.left(pos);
|
||
}
|
||
QString subName = mnRelName.right(mnRelName.size() - pos - 1);
|
||
DataClass* pSubClass = qobject_cast<DataClass*>(mgr.findobjectByNameInDatamodel(g_RELATED_CLASS, "name", subName, _id));
|
||
if (pSubClass)
|
||
{
|
||
qobject_cast<DataClass*>(pMain)->_fkTableName.append(pSubClass->_strDisplayName);
|
||
qobject_cast<DataClass*>(pMain)->_relTableName.append(pData->_strDisplayName);
|
||
qobject_cast<DataClass*>(pMain)->_fkTypeName.append("m:n");
|
||
pSubClass->_fkTableName.append(qobject_cast<DataClass*>(pMain)->_strDisplayName);
|
||
pSubClass->_relTableName.append(pData->_strDisplayName);
|
||
pSubClass->_fkTypeName.append("m:n");
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
//其它关系
|
||
QMap<unsigned int, DPData*> attributeMap;
|
||
mgr.getDataMap(DataManager::DataType::dataAttribute, attributeMap);
|
||
keylist = attributeMap.keys();
|
||
for (int i = 0; i < keylist.size(); i++)
|
||
{
|
||
QString rel;
|
||
DataAttribute* pData = qobject_cast<DataAttribute*>(attributeMap.value(keylist.at(i)));
|
||
if (pData->_FKType != 0)
|
||
{
|
||
if (pData->_FKType == RELATION_11)
|
||
{
|
||
rel = "1:1";
|
||
}
|
||
else if (pData->_FKType == RELATION_1N)
|
||
{
|
||
rel = "1:n/n:1";
|
||
}
|
||
//查找关系类
|
||
DataClass* pRelClass = qobject_cast<DataClass*>(mgr.findObjectById(DataManager::DataType::dataClass, pData->_wFkTableID));
|
||
if (pRelClass)
|
||
{
|
||
qobject_cast<DataClass*>(pData->_parent)->_fkTypeName.append(rel);
|
||
qobject_cast<DataClass*>(pData->_parent)->_fkTableName.append(pRelClass->_strDisplayName);
|
||
qobject_cast<DataClass*>(pData->_parent)->_relTableName.append(" ");
|
||
pRelClass->_fkTypeName.append(rel);
|
||
pRelClass->_fkTableName.append(qobject_cast<DataClass*>(pData->_parent)->_strDisplayName);
|
||
pRelClass->_relTableName.append(" ");
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
void DataModelData::setFileData(FileGenerate* generator, QStringList qs)
|
||
{
|
||
//封面
|
||
generator->CoverRightItem.append(new CCS_Report::CCSModelDataSet("", "v" + QString::number(_version)));
|
||
/*QList<QObject*> ModelItem;*/
|
||
generator->ModelItem.append(new CCS_Report::CCSModelDataSet(_parent->_name, _displayName));
|
||
|
||
takeRelationTableName();
|
||
|
||
QMap<unsigned int, DPData*>::iterator it = _childrenMap.begin();
|
||
int id = 0;
|
||
QStringList flaglist;
|
||
flaglist << QString::number(id);
|
||
while (it != _childrenMap.end())
|
||
{
|
||
flaglist.replace(0, QString::number(id));
|
||
(*it)->setFileData(generator, flaglist);
|
||
|
||
id++;
|
||
it++;
|
||
}
|
||
|
||
|
||
}
|
||
|