Migrates flm handlers and objects to plain member access
This commit is contained in:
1 parent
e156fbb5e4
commit
3c058facd7
9 files changed
+217
-217
No files matched your search
+29
-29
@@ -70,7 +70,7 @@ bool HandlerFileContent::init()
|
||||
void HandlerFileContent::onFileContentModifyRequest(const rti::core::SampleIdentity &cookie,
|
||||
const FileManagement::FileContentModifyRequest &request)
|
||||
{
|
||||
auto ret = request.id() > 0 ? fileContentModifyRequest(request) : fileContentCreateRequest(request);
|
||||
auto ret = request.id > 0 ? fileContentModifyRequest(request) : fileContentCreateRequest(request);
|
||||
if (ret.error())
|
||||
WARNING_LOG(m_logger) << ret();
|
||||
fts()->fileContentModifyReply(cookie, ret);
|
||||
@@ -91,9 +91,9 @@ Core::FunctionReplyObject HandlerFileContent::fileContentCreateRequest(const Fil
|
||||
//----------------------------------------------------------------------------------------------------------------------------
|
||||
Core::FunctionReplyObject HandlerFileContent::fileContentModifyRequest(const FileManagement::FileContentModifyRequest &request)
|
||||
{
|
||||
ObjectFileContent *ifs = m_objectFileContentMap.value(request.id());
|
||||
ObjectFileContent *ifs = m_objectFileContentMap.value(request.id);
|
||||
if (ifs == nullptr)
|
||||
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "FileContent with id %1 not found")).arg(request.id());
|
||||
return Core::FunctionReplyObject(request.id, tr_lts("dds", "FileContent with id %1 not found")).arg(request.id);
|
||||
return ifs->updateObject(request);
|
||||
}
|
||||
|
||||
@@ -101,10 +101,10 @@ Core::FunctionReplyObject HandlerFileContent::fileContentModifyRequest(const Fil
|
||||
void HandlerFileContent::onFileContentChangeStatusRequest(const rti::core::SampleIdentity &cookie,
|
||||
const FileManagement::FileContentChangeStatusRequest &request)
|
||||
{
|
||||
ObjectFileContent *ifs = m_objectFileContentMap.value(request.id());
|
||||
ObjectFileContent *ifs = m_objectFileContentMap.value(request.id);
|
||||
if (ifs == nullptr)
|
||||
{
|
||||
Core::FunctionReplyObject ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "FileContent with id %1 not found")).arg(request.id());
|
||||
Core::FunctionReplyObject ret = Core::FunctionReplyObject(request.id, tr_lts("dds", "FileContent with id %1 not found")).arg(request.id);
|
||||
fts()->fileContentChangeStatusReply(cookie, ret);
|
||||
return;
|
||||
}
|
||||
@@ -127,13 +127,13 @@ void HandlerFileContent::onFileContentRemoveRequest(const rti::core::SampleIdent
|
||||
|
||||
Core::FunctionReplyObject HandlerFileContent::fileContentRemoveRequest(const Core::RemoveElementRequest &request)
|
||||
{
|
||||
ObjectFileContent *ifs = m_objectFileContentMap.value(request.id());
|
||||
ObjectFileContent *ifs = m_objectFileContentMap.value(request.id);
|
||||
|
||||
if (ifs == nullptr)
|
||||
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "FileContent with id %1 not found")).arg(request.id());
|
||||
return Core::FunctionReplyObject(request.id, tr_lts("dds", "FileContent with id %1 not found")).arg(request.id);
|
||||
|
||||
if (m_mainHandler->dds()->topicLockMaster()->isLocked(ifs->getData(), m_mainHandler->exerciseId()))
|
||||
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "FileContent '%1' is used by another user!")).arg(ifs->getName());
|
||||
return Core::FunctionReplyObject(request.id, tr_lts("dds", "FileContent '%1' is used by another user!")).arg(ifs->getName());
|
||||
|
||||
auto ret = ifs->removeObject();
|
||||
|
||||
@@ -141,7 +141,7 @@ Core::FunctionReplyObject HandlerFileContent::fileContentRemoveRequest(const Cor
|
||||
{
|
||||
// delete ObjectFileContent
|
||||
delete ifs;
|
||||
m_objectFileContentMap.remove(request.id());
|
||||
m_objectFileContentMap.remove(request.id);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -152,28 +152,28 @@ void HandlerFileContent::onFileContentExportRequest(const rti::core::SampleIdent
|
||||
const FileManagement::FileContentExportRequest &request)
|
||||
{
|
||||
Core::FunctionReplyObject ret;
|
||||
ObjectFileContent *ifs = m_objectFileContentMap.value(request.id());
|
||||
ObjectFileContent *ifs = m_objectFileContentMap.value(request.id);
|
||||
if (ifs == nullptr)
|
||||
{
|
||||
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "FileContent with id %1 not found")).arg(request.id());
|
||||
ret = Core::FunctionReplyObject(request.id, tr_lts("dds", "FileContent with id %1 not found")).arg(request.id);
|
||||
fts()->fileContentExportReply(cookie, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
// get content on demand from DB
|
||||
Database::FlmFileContent flmContent;
|
||||
if (!db()->selectFlmFileContent(request.id(), flmContent))
|
||||
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "FileContent with id %1 not found in database")).arg(request.id());
|
||||
if (!db()->selectFlmFileContent(request.id, flmContent))
|
||||
ret = Core::FunctionReplyObject(request.id, tr_lts("dds", "FileContent with id %1 not found in database")).arg(request.id);
|
||||
|
||||
QByteArray content = flmContent.content;
|
||||
DEBUG_LOG(m_logger) << "Content size: " << content.size();
|
||||
|
||||
// creating an unique file name: temp path + folderId + file name + file extension (NN_FileName.FileExt)
|
||||
QString fileName = QDir::tempPath() + QLatin1Char('/') + QString::number(ifs->getFolderId()) + QLatin1Char('-');
|
||||
fileName += QString::fromStdString(ifs->getData().name()).simplified().replace(QLatin1Char(' '), QLatin1Char('_'));
|
||||
fileName += QString::fromStdString(ifs->getData().name).simplified().replace(QLatin1Char(' '), QLatin1Char('_'));
|
||||
|
||||
// add extension
|
||||
FileType fileType = ifs->getData().fileType().underlying();
|
||||
FileType fileType = ifs->getData().fileType;
|
||||
QString fileExt = m_mainHandler->getHandlerFileTypeInfo()->getFileExtension(fileType);
|
||||
if (!fileExt.isEmpty())
|
||||
fileName += QLatin1Char('.') + fileExt;
|
||||
@@ -184,7 +184,7 @@ void HandlerFileContent::onFileContentExportRequest(const rti::core::SampleIdent
|
||||
QFile file(fileName);
|
||||
if (!file.open(QIODevice::WriteOnly))
|
||||
{
|
||||
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "Failed to write to %1")).arg(fileName);
|
||||
ret = Core::FunctionReplyObject(request.id, tr_lts("dds", "Failed to write to %1")).arg(fileName);
|
||||
fts()->fileContentExportReply(cookie, ret);
|
||||
delete ifs;
|
||||
return;
|
||||
@@ -213,16 +213,16 @@ void HandlerFileContent::onGetFileContentDataRequest(const rti::core::SampleIden
|
||||
Core::FunctionReplyObject fro;
|
||||
GetFileContentDataReply reply;
|
||||
|
||||
ObjectFileContent *ifs = m_objectFileContentMap.value(request.fileContentId());
|
||||
ObjectFileContent *ifs = m_objectFileContentMap.value(request.fileContentId);
|
||||
|
||||
if (ifs)
|
||||
{
|
||||
reply.id(ifs->getId());
|
||||
reply.id = ifs->getId();
|
||||
|
||||
// get content on demand from DB
|
||||
Database::FlmFileContent flmContent;
|
||||
if (!db()->selectFlmFileContent(request.fileContentId(), flmContent))
|
||||
fro = Core::FunctionReplyObject(request.fileContentId(), tr_lts("dds", "File content with id %1 not found in database")).arg(request.fileContentId());
|
||||
if (!db()->selectFlmFileContent(request.fileContentId, flmContent))
|
||||
fro = Core::FunctionReplyObject(request.fileContentId, tr_lts("dds", "File content with id %1 not found in database")).arg(request.fileContentId);
|
||||
/* no need to set content of object
|
||||
else
|
||||
ifs->setContent(LtsUtils::convert<std::vector<uint8_t>>(flmContent.content));
|
||||
@@ -233,21 +233,21 @@ void HandlerFileContent::onGetFileContentDataRequest(const rti::core::SampleIden
|
||||
reply.content(ifs->getContent());
|
||||
*/
|
||||
if (flmContent.content.size() <= 0)
|
||||
fro = Core::FunctionReplyObject(request.fileContentId(), tr_lts("dds", "No content available"));
|
||||
fro = Core::FunctionReplyObject(request.fileContentId, tr_lts("dds", "No content available"));
|
||||
else
|
||||
reply.content(LtsUtils::convert<std::vector<uint8_t>>(flmContent.content));
|
||||
reply.content = LtsUtils::convert<std::vector<uint8_t>>(flmContent.content);
|
||||
}
|
||||
else
|
||||
fro = Core::FunctionReplyObject(request.fileContentId(), tr_lts("dds", "No valid id = %1 for retrieving file content")).arg(request.fileContentId());
|
||||
fro = Core::FunctionReplyObject(request.fileContentId, tr_lts("dds", "No valid id = %1 for retrieving file content")).arg(request.fileContentId);
|
||||
|
||||
if (fro.error())
|
||||
{
|
||||
reply.id(fro.id());
|
||||
reply.errorString(fro.str());
|
||||
reply.errorParams(fro.args());
|
||||
reply.id = fro.id();
|
||||
reply.errorString = fro.str();
|
||||
reply.errorParams = fro.args();
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "Got content size: " << reply.content().size();
|
||||
DEBUG_LOG(m_logger) << "Got content size: " << reply.content.size();
|
||||
|
||||
fts()->getFileContentDataReply(cookie, reply);
|
||||
}
|
||||
@@ -307,10 +307,10 @@ bool HandlerFileContent::initByDbId(int dbId)
|
||||
void HandlerFileContent::onFileContentSetUsedRequest(const rti::core::SampleIdentity &cookie,
|
||||
const FileManagement::FileContentSetUsedRequest &request)
|
||||
{
|
||||
ObjectFileContent *ifs = m_objectFileContentMap.value(request.id());
|
||||
ObjectFileContent *ifs = m_objectFileContentMap.value(request.id);
|
||||
if (ifs == nullptr)
|
||||
{
|
||||
Core::FunctionReplyObject ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "FileContent with id %1 not found")).arg(request.id());
|
||||
Core::FunctionReplyObject ret = Core::FunctionReplyObject(request.id, tr_lts("dds", "FileContent with id %1 not found")).arg(request.id);
|
||||
fts()->fileContentSetUsedReply(cookie, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ QString HandlerFileTypeInfo::getFileExtension(const FileManagement::FileType &fi
|
||||
{
|
||||
for (FileManagement::ObjectFileTypeInfo *ft : m_objectFileTypeInfoMap)
|
||||
{
|
||||
if (ft->getId() == fileType.underlying())
|
||||
if (ft->getId() == static_cast<int>(fileType))
|
||||
return ft->getExtension();
|
||||
}
|
||||
return QString();
|
||||
|
||||
@@ -67,7 +67,7 @@ bool HandlerFolder::init()
|
||||
void HandlerFolder::onFolderModifyRequest(const rti::core::SampleIdentity &cookie,
|
||||
const FileManagement::FolderModifyRequest &request)
|
||||
{
|
||||
auto ret = request.id() > 0 ? folderModifyRequest(request) : folderCreateRequest(request);
|
||||
auto ret = request.id > 0 ? folderModifyRequest(request) : folderCreateRequest(request);
|
||||
if (ret.error())
|
||||
WARNING_LOG(m_logger) << ret();
|
||||
fts()->folderModifyReply(cookie, ret);
|
||||
@@ -76,14 +76,14 @@ void HandlerFolder::onFolderModifyRequest(const rti::core::SampleIdentity &cooki
|
||||
//---------------------------------------------------
|
||||
Core::FunctionReplyObject HandlerFolder::folderCreateRequest(const FileManagement::FolderModifyRequest &request)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Creating folder with name = " << request.name() << " under parent folder " << request.parentId();
|
||||
DEBUG_LOG(m_logger) << "Creating folder with name = " << request.name << " under parent folder " << request.parentId;
|
||||
|
||||
Core::FunctionReplyObject ret;
|
||||
Folder data;
|
||||
std::vector<int> parentPath;
|
||||
|
||||
if (request.parentId() > 0 && m_objectFolderMap.contains(request.parentId()))
|
||||
parentPath = m_objectFolderMap.value(request.parentId())->getPath();
|
||||
if (request.parentId > 0 && m_objectFolderMap.contains(request.parentId))
|
||||
parentPath = m_objectFolderMap.value(request.parentId)->getPath();
|
||||
|
||||
if (parentPath.size() == 0)
|
||||
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting Folder on root level"));
|
||||
@@ -91,13 +91,13 @@ Core::FunctionReplyObject HandlerFolder::folderCreateRequest(const FileManagemen
|
||||
std::vector<int> path = parentPath;
|
||||
path.push_back(9999); // dummy id, only needed to retrieve later the proper id
|
||||
|
||||
data.name(request.name());
|
||||
data.path(path);
|
||||
data.isEditable(request.isEditable());
|
||||
data.isHidden(request.isHidden());
|
||||
data.parentId(request.parentId());
|
||||
data.operatorId(request.operatorId());
|
||||
data.lastModified(QDateTime::currentMSecsSinceEpoch());
|
||||
data.name = request.name;
|
||||
data.path = path;
|
||||
data.isEditable = request.isEditable;
|
||||
data.isHidden = request.isHidden;
|
||||
data.parentId = request.parentId;
|
||||
data.operatorId = request.operatorId;
|
||||
data.lastModified = QDateTime::currentMSecsSinceEpoch();
|
||||
|
||||
ObjectFolder *ifs(new ObjectFolder(m_mainHandler));
|
||||
ret = ifs->createObject(data);
|
||||
@@ -109,13 +109,13 @@ Core::FunctionReplyObject HandlerFolder::folderCreateRequest(const FileManagemen
|
||||
}
|
||||
else
|
||||
{
|
||||
data.id(ifs->getId());
|
||||
data.id = ifs->getId();
|
||||
|
||||
// update path with the real id
|
||||
path = parentPath;
|
||||
path.resize(parentPath.size() + 1, ifs->getId());
|
||||
data.path(path);
|
||||
data.lastModified(QDateTime::currentMSecsSinceEpoch());
|
||||
data.path = path;
|
||||
data.lastModified = QDateTime::currentMSecsSinceEpoch();
|
||||
|
||||
ret = ifs->updateObject(data);
|
||||
if (ret.error())
|
||||
@@ -137,20 +137,20 @@ Core::FunctionReplyObject HandlerFolder::folderCreateRequest(const FileManagemen
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
Core::FunctionReplyObject HandlerFolder::folderModifyRequest(const FileManagement::FolderModifyRequest &request)
|
||||
{
|
||||
ObjectFolder *ifs = m_objectFolderMap.value(request.id());
|
||||
ObjectFolder *ifs = m_objectFolderMap.value(request.id);
|
||||
if (ifs == nullptr)
|
||||
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "Folder with id %1 not found")).arg(request.id());
|
||||
return Core::FunctionReplyObject(request.id, tr_lts("dds", "Folder with id %1 not found")).arg(request.id);
|
||||
|
||||
Folder newData;
|
||||
|
||||
newData.id(request.id());
|
||||
newData.name(request.name());
|
||||
newData.path(request.path());
|
||||
newData.isEditable(request.isEditable());
|
||||
newData.parentId(request.parentId());
|
||||
newData.operatorId(request.operatorId());
|
||||
newData.lastModified(QDateTime::currentMSecsSinceEpoch());
|
||||
newData.isHidden(request.isHidden());
|
||||
newData.id = request.id;
|
||||
newData.name = request.name;
|
||||
newData.path = request.path;
|
||||
newData.isEditable = request.isEditable;
|
||||
newData.parentId = request.parentId;
|
||||
newData.operatorId = request.operatorId;
|
||||
newData.lastModified = QDateTime::currentMSecsSinceEpoch();
|
||||
newData.isHidden = request.isHidden;
|
||||
|
||||
return ifs->updateObject(newData);
|
||||
}
|
||||
@@ -160,9 +160,9 @@ void HandlerFolder::onPathCreateRequest(const rti::core::SampleIdentity &cookie,
|
||||
{
|
||||
Core::FunctionReplyObject ret;
|
||||
|
||||
int parentFolderId = request.parentId();
|
||||
int parentFolderId = request.parentId;
|
||||
DEBUG_LOG(m_logger) << "parentFolderId: " << parentFolderId;
|
||||
for (const std::string &folderName : request.path())
|
||||
for (const std::string &folderName : request.path)
|
||||
{
|
||||
int folderId = dtc()->findFolder(parentFolderId, QString::fromStdString(folderName));
|
||||
DEBUG_LOG(m_logger) << "folderId: " << folderId << ", folderName: " << folderName;
|
||||
@@ -180,12 +180,12 @@ void HandlerFolder::onPathCreateRequest(const rti::core::SampleIdentity &cookie,
|
||||
|
||||
// Folder does not exist => create folder
|
||||
FolderModifyRequest folderRequest;
|
||||
folderRequest.name(folderName);
|
||||
folderRequest.parentId(parentFolderId);
|
||||
folderRequest.path(ifs->getPath());
|
||||
folderRequest.isEditable(request.isEditable());
|
||||
folderRequest.isHidden(request.isHidden());
|
||||
folderRequest.operatorId(request.operatorId());
|
||||
folderRequest.name = folderName;
|
||||
folderRequest.parentId = parentFolderId;
|
||||
folderRequest.path = ifs->getPath();
|
||||
folderRequest.isEditable = request.isEditable;
|
||||
folderRequest.isHidden = request.isHidden;
|
||||
folderRequest.operatorId = request.operatorId;
|
||||
|
||||
ret = folderCreateRequest(folderRequest);
|
||||
|
||||
@@ -208,22 +208,22 @@ void HandlerFolder::onFolderRemoveRequest(const rti::core::SampleIdentity &cooki
|
||||
{
|
||||
Core::FunctionReplyObject ret;
|
||||
|
||||
ObjectFolder *ifs = m_objectFolderMap.value(request.id());
|
||||
ObjectFolder *ifs = m_objectFolderMap.value(request.id);
|
||||
if (ifs == nullptr)
|
||||
{
|
||||
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "Folder with id %1 not found")).arg(request.id());
|
||||
ret = Core::FunctionReplyObject(request.id, tr_lts("dds", "Folder with id %1 not found")).arg(request.id);
|
||||
fts()->folderRemoveReply(cookie, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_mainHandler->dds()->topicLockMaster()->isLocked(ifs->getData(), m_mainHandler->exerciseId()))
|
||||
{
|
||||
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "Folder '%1' is used by another user!")).arg(ifs->getName());
|
||||
ret = Core::FunctionReplyObject(request.id, tr_lts("dds", "Folder '%1' is used by another user!")).arg(ifs->getName());
|
||||
fts()->folderRemoveReply(cookie, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
ret = removeFolder(request.id());
|
||||
ret = removeFolder(request.id);
|
||||
|
||||
delete ifs;
|
||||
|
||||
@@ -273,17 +273,17 @@ void HandlerFolder::onFileContentRemoveRequest(const rti::core::SampleIdentity &
|
||||
const Core::RemoveElementRequest &request)
|
||||
{
|
||||
Core::FunctionReplyObject ret;
|
||||
ObjectFileContent *ifs = m_mainHandler->getHandlerFileContent()->getObjectFileContentMap().value(request.id());
|
||||
ObjectFileContent *ifs = m_mainHandler->getHandlerFileContent()->getObjectFileContentMap().value(request.id);
|
||||
if (ifs == nullptr)
|
||||
{
|
||||
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "FileContent with id %1 not found")).arg(request.id());
|
||||
ret = Core::FunctionReplyObject(request.id, tr_lts("dds", "FileContent with id %1 not found")).arg(request.id);
|
||||
fts()->fileContentRemoveReply(cookie, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_mainHandler->dds()->topicLockMaster()->isLocked(ifs->getData(), m_mainHandler->exerciseId()))
|
||||
{
|
||||
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "FileContent '%1' is used by another user!")).arg(ifs->getName());
|
||||
ret = Core::FunctionReplyObject(request.id, tr_lts("dds", "FileContent '%1' is used by another user!")).arg(ifs->getName());
|
||||
fts()->folderRemoveReply(cookie, ret);
|
||||
return;
|
||||
}
|
||||
@@ -296,7 +296,7 @@ void HandlerFolder::onFileContentRemoveRequest(const rti::core::SampleIdentity &
|
||||
{
|
||||
// delete ObjectFileContent
|
||||
delete ifs;
|
||||
m_mainHandler->getHandlerFileContent()->getObjectFileContentMap().remove(request.id());
|
||||
m_mainHandler->getHandlerFileContent()->getObjectFileContentMap().remove(request.id);
|
||||
}
|
||||
|
||||
fts()->fileContentRemoveReply(cookie, ret);
|
||||
@@ -315,7 +315,7 @@ void HandlerFolder::removeFilesForFolder(int folderId)
|
||||
{
|
||||
if (file->getFolderId() == folderId)
|
||||
{
|
||||
request.id(file->getId());
|
||||
request.id = file->getId();
|
||||
auto ret = m_mainHandler->getHandlerFileContent()->fileContentRemoveRequest(request);
|
||||
if (ret.error())
|
||||
WARNING_LOG(m_logger) << ret();
|
||||
|
||||
+79
-79
@@ -30,37 +30,37 @@ ObjectFileContent::~ObjectFileContent()
|
||||
|
||||
bool ObjectFileContent::isValid() const
|
||||
{
|
||||
return m_data.id() > 0;
|
||||
return m_data.id > 0;
|
||||
}
|
||||
|
||||
bool ObjectFileContent::isUsed() const
|
||||
{
|
||||
return m_data.isUsed();
|
||||
return m_data.isUsed;
|
||||
}
|
||||
bool ObjectFileContent::isHidden() const
|
||||
{
|
||||
return m_data.isHidden();
|
||||
return m_data.isHidden;
|
||||
}
|
||||
|
||||
static FileContent toFileContent(const FileContentModifyRequest &request)
|
||||
{
|
||||
FileContent data;
|
||||
data.id(request.id());
|
||||
data.name(request.name());
|
||||
data.folderId(request.folderId());
|
||||
data.fileCategory(request.fileCategory());
|
||||
data.fileType(request.fileType());
|
||||
data.fileStatus(request.fileStatus());
|
||||
data.exerciseId(request.exerciseId());
|
||||
data.phaseId(request.phaseId());
|
||||
data.isTemplate(request.isTemplate());
|
||||
data.isHidden(request.isHidden());
|
||||
data.isUsedBy(request.isUsedBy());
|
||||
data.usedBy(request.usedBy());
|
||||
data.properties(request.properties());
|
||||
data.exportFileName(request.exportFileName());
|
||||
data.lastModified(request.lastModified());
|
||||
data.operatorId(request.operatorId());
|
||||
data.id = request.id;
|
||||
data.name = request.name;
|
||||
data.folderId = request.folderId;
|
||||
data.fileCategory = request.fileCategory;
|
||||
data.fileType = request.fileType;
|
||||
data.fileStatus = request.fileStatus;
|
||||
data.exerciseId = request.exerciseId;
|
||||
data.phaseId = request.phaseId;
|
||||
data.isTemplate = request.isTemplate;
|
||||
data.isHidden = request.isHidden;
|
||||
data.isUsedBy = request.isUsedBy;
|
||||
data.usedBy = request.usedBy;
|
||||
data.properties = request.properties;
|
||||
data.exportFileName = request.exportFileName;
|
||||
data.lastModified = request.lastModified;
|
||||
data.operatorId = request.operatorId;
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -69,147 +69,147 @@ Core::FunctionReplyObject ObjectFileContent::createObject(const FileContentModif
|
||||
{
|
||||
m_data = toFileContent(request);
|
||||
|
||||
m_data.id(0);
|
||||
m_data.isUsed(false);
|
||||
m_data.id = 0;
|
||||
m_data.isUsed = false;
|
||||
|
||||
Database::FlmFileContent dbData(toDbData(m_data));
|
||||
|
||||
//m_content = request.content();
|
||||
dbData.content = QByteArray::fromRawData(reinterpret_cast<const char *>(&request.content()[0]), request.content().size());
|
||||
dbData.content = QByteArray::fromRawData(reinterpret_cast<const char *>(&request.content[0]), request.content.size());
|
||||
|
||||
if (!db()->insert(dbData))
|
||||
{
|
||||
QString errText = db()->getLastError().databaseText();
|
||||
ERROR_LOG(m_logger) << "Error inserting FileContent into database: " << errText;
|
||||
if (db()->getLastError().nativeErrorCode().contains(QStringLiteral("23505")))
|
||||
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting FileContent into database: unique key violation (folder, name, type, status, operator) for file name '%1'")).arg(m_data.name());
|
||||
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting FileContent into database: unique key violation (folder, name, type, status, operator) for file name '%1'")).arg(QString::fromStdString(m_data.name));
|
||||
else
|
||||
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting FileContent with name %1 into database: %2")).arg(m_data.name()).arg(errText);
|
||||
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting FileContent with name %1 into database: %2")).arg(QString::fromStdString(m_data.name)).arg(errText);
|
||||
}
|
||||
|
||||
m_data.id(dbData.id);
|
||||
DEBUG_LOG(m_logger) << "New FileContent Id: " << m_data.id();
|
||||
m_data.id = dbData.id;
|
||||
DEBUG_LOG(m_logger) << "New FileContent Id: " << m_data.id;
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectFileContent::updateObject(const FileContentModifyRequest &request)
|
||||
{
|
||||
if (!isValid())
|
||||
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "Object not valid/blocked"));
|
||||
return Core::FunctionReplyObject(request.id, tr_lts("dds", "Object not valid/blocked"));
|
||||
|
||||
m_data = toFileContent(request);
|
||||
Database::FlmFileContent dbData(toDbData(m_data));
|
||||
|
||||
//m_content = request.content();
|
||||
DEBUG_LOG(m_logger) << "Content size: " << request.content().size();
|
||||
dbData.content = QByteArray::fromRawData(reinterpret_cast<const char *>(&request.content()[0]), request.content().size());
|
||||
DEBUG_LOG(m_logger) << "Content size: " << request.content.size();
|
||||
dbData.content = QByteArray::fromRawData(reinterpret_cast<const char *>(&request.content[0]), request.content.size());
|
||||
|
||||
if (!db()->update(dbData))
|
||||
{
|
||||
QString errText = db()->getLastError().databaseText();
|
||||
ERROR_LOG(m_logger) << "Error updating FileContent into database: " << errText;
|
||||
if (db()->getLastError().nativeErrorCode().contains(QStringLiteral("23505")))
|
||||
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "Error updating FileContent into database: unique key violation (folder, name, type, status, operator) for file name '%1'")).arg(m_data.name());
|
||||
return Core::FunctionReplyObject(request.id, tr_lts("dds", "Error updating FileContent into database: unique key violation (folder, name, type, status, operator) for file name '%1'")).arg(QString::fromStdString(m_data.name));
|
||||
else
|
||||
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "Error updating FileContent with name %1 into database: %2")).arg(m_data.name()).arg(errText);
|
||||
return Core::FunctionReplyObject(request.id, tr_lts("dds", "Error updating FileContent with name %1 into database: %2")).arg(QString::fromStdString(m_data.name)).arg(errText);
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "Data changed for FileContent Id: " << m_data.id();
|
||||
DEBUG_LOG(m_logger) << "Data changed for FileContent Id: " << m_data.id;
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectFileContent::setUsed(bool isUsed)
|
||||
{
|
||||
if (!isValid())
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "Trying to update an already removed FileContent object"));
|
||||
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "Trying to update an already removed FileContent object"));
|
||||
|
||||
m_data.isUsed(isUsed);
|
||||
m_data.isUsed = isUsed;
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectFileContent::changeStatus(const FileContentChangeStatusRequest &request)
|
||||
{
|
||||
if (!isValid())
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "Trying to update an already removed FileContent object"));
|
||||
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "Trying to update an already removed FileContent object"));
|
||||
|
||||
m_data.id(request.id());
|
||||
m_data.fileStatus(request.fileStatus());
|
||||
m_data.operatorId(request.operatorId());
|
||||
m_data.lastModified(request.lastModified());
|
||||
m_data.id = request.id;
|
||||
m_data.fileStatus = request.fileStatus;
|
||||
m_data.operatorId = request.operatorId;
|
||||
m_data.lastModified = request.lastModified;
|
||||
|
||||
if (!db()->updateStatus(m_data.id(), m_data.fileStatus(), m_data.operatorId()))
|
||||
if (!db()->updateStatus(m_data.id, m_data.fileStatus, m_data.operatorId))
|
||||
{
|
||||
QString errText = db()->getLastError().databaseText();
|
||||
ERROR_LOG(m_logger) << "Error updating FileContent status into database: " << errText;
|
||||
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "Error updating FileContent status into database: %1")).arg(errText);
|
||||
return Core::FunctionReplyObject(request.id, tr_lts("dds", "Error updating FileContent status into database: %1")).arg(errText);
|
||||
}
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectFileContent::setUsedBy(const FileContentSetUsedRequest &request)
|
||||
{
|
||||
if (!isValid())
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "Trying to update an already removed FileContent object"));
|
||||
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "Trying to update an already removed FileContent object"));
|
||||
|
||||
m_data.id(request.id());
|
||||
m_data.isUsedBy(request.isUsedBy());
|
||||
m_data.usedBy(request.usedBy());
|
||||
m_data.operatorId(request.operatorId());
|
||||
m_data.lastModified(request.lastModified());
|
||||
m_data.id = request.id;
|
||||
m_data.isUsedBy = request.isUsedBy;
|
||||
m_data.usedBy = request.usedBy;
|
||||
m_data.operatorId = request.operatorId;
|
||||
m_data.lastModified = request.lastModified;
|
||||
|
||||
if (!db()->setUsedBy(m_data.id(), m_data.isUsedBy(), m_data.usedBy(), m_data.operatorId()))
|
||||
if (!db()->setUsedBy(m_data.id, m_data.isUsedBy, m_data.usedBy, m_data.operatorId))
|
||||
{
|
||||
QString errText = db()->getLastError().databaseText();
|
||||
ERROR_LOG(m_logger) << "Error updating FileContent used status into database: " << errText;
|
||||
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "Error updating FileContent used status into database: %1")).arg(errText);
|
||||
return Core::FunctionReplyObject(request.id, tr_lts("dds", "Error updating FileContent used status into database: %1")).arg(errText);
|
||||
}
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
|
||||
Core::FunctionReplyObject ObjectFileContent::removeObject()
|
||||
{
|
||||
if (isUsed())
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "FileContent still in use"));
|
||||
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "FileContent still in use"));
|
||||
|
||||
if (!db()->removeFlmFileContent(m_data.id()))
|
||||
if (!db()->removeFlmFileContent(m_data.id))
|
||||
{
|
||||
QString errText = db()->getLastError().databaseText();
|
||||
ERROR_LOG(m_logger) << "FileContent with id " << m_data.id() << " can not be removed from database: " << errText;
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "FileContent with id %1 can not be removed from database: %2")).arg(m_data.id()).arg(errText);
|
||||
ERROR_LOG(m_logger) << "FileContent with id " << m_data.id << " can not be removed from database: " << errText;
|
||||
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "FileContent with id %1 can not be removed from database: %2")).arg(m_data.id).arg(errText);
|
||||
}
|
||||
|
||||
if (!dts()->removeFileContentByKey(m_data.id()))
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "FileContent %1 can not be taken from DDS")).arg(m_data.id());
|
||||
if (!dts()->removeFileContentByKey(m_data.id))
|
||||
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "FileContent %1 can not be taken from DDS")).arg(m_data.id);
|
||||
|
||||
//m_content.clear();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
void ObjectFileContent::onPublishData()
|
||||
{
|
||||
INFO_LOG(m_logger) << "Publish FileContent-data to dds (" << m_data.id() << ") ...";
|
||||
INFO_LOG(m_logger) << "Publish FileContent-data to dds (" << m_data.id << ") ...";
|
||||
|
||||
if (!dts()->publish(m_data))
|
||||
ERROR_LOG(m_logger) << "Error publishing FileContent-data to dds";
|
||||
@@ -224,25 +224,25 @@ Database::FlmFileContent ObjectFileContent::toDbData(const FileContent &ddsData)
|
||||
{
|
||||
Database::FlmFileContent dbData;
|
||||
|
||||
dbData.id = ddsData.id();
|
||||
dbData.name = QString::fromStdString(ddsData.name());
|
||||
dbData.isTemplate = ddsData.isTemplate();
|
||||
dbData.isHidden = ddsData.isHidden();
|
||||
dbData.fileCategoryId = ddsData.fileCategory();
|
||||
dbData.folderId = ddsData.folderId();
|
||||
dbData.fileTypeId = ddsData.fileType();
|
||||
dbData.operatorId = ddsData.operatorId();
|
||||
if (ddsData.exerciseId().is_set())
|
||||
dbData.id = ddsData.id;
|
||||
dbData.name = QString::fromStdString(ddsData.name);
|
||||
dbData.isTemplate = ddsData.isTemplate;
|
||||
dbData.isHidden = ddsData.isHidden;
|
||||
dbData.fileCategoryId = ddsData.fileCategory;
|
||||
dbData.folderId = ddsData.folderId;
|
||||
dbData.fileTypeId = ddsData.fileType;
|
||||
dbData.operatorId = ddsData.operatorId;
|
||||
if (ddsData.exerciseId.is_set())
|
||||
{
|
||||
dbData.exerciseId = ddsData.exerciseId().get();
|
||||
if (ddsData.phaseId().is_set())
|
||||
dbData.phaseId = ddsData.phaseId().get();
|
||||
dbData.exerciseId = ddsData.exerciseId.get();
|
||||
if (ddsData.phaseId.is_set())
|
||||
dbData.phaseId = ddsData.phaseId.get();
|
||||
}
|
||||
dbData.fileStatusId = ddsData.fileStatus();
|
||||
dbData.isUsedBy = ddsData.isUsedBy();
|
||||
dbData.usedBy = ddsData.usedBy();
|
||||
dbData.properties = QString::fromStdString(ddsData.properties());
|
||||
dbData.lastModified = ddsData.lastModified();
|
||||
dbData.fileStatusId = ddsData.fileStatus;
|
||||
dbData.isUsedBy = ddsData.isUsedBy;
|
||||
dbData.usedBy = ddsData.usedBy;
|
||||
dbData.properties = QString::fromStdString(ddsData.properties);
|
||||
dbData.lastModified = ddsData.lastModified;
|
||||
|
||||
return dbData;
|
||||
}
|
||||
|
||||
@@ -32,10 +32,10 @@ public:
|
||||
Core::FunctionReplyObject setUsedBy(const FileContentSetUsedRequest &request);
|
||||
Core::FunctionReplyObject removeObject();
|
||||
|
||||
qint32 getId() const { return m_data.id(); }
|
||||
qint32 getFolderId() const { return m_data.folderId(); }
|
||||
qint32 getId() const { return m_data.id; }
|
||||
qint32 getFolderId() const { return m_data.folderId; }
|
||||
const FileContent &getData() const { return m_data; }
|
||||
QString getName() const { return QString::fromStdString(m_data.name()); }
|
||||
QString getName() const { return QString::fromStdString(m_data.name); }
|
||||
// const std::vector<uint8_t> &getContent() const { return m_content; }
|
||||
|
||||
bool isValid() const;
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
bool isHidden() const;
|
||||
|
||||
Core::FunctionReplyObject setUsed(bool isUsed);
|
||||
void setExportFileName(const std::string &fileName) { m_data.exportFileName().set(fileName); }
|
||||
void setExportFileName(const std::string &fileName) { m_data.exportFileName = fileName; }
|
||||
// void setContent(std::vector<uint8_t> &&content) { m_content = std::move(content); }
|
||||
|
||||
// convert methods
|
||||
|
||||
+24
-24
@@ -23,21 +23,21 @@ ObjectFileTypeInfo::~ObjectFileTypeInfo()
|
||||
|
||||
bool ObjectFileTypeInfo::isValid() const
|
||||
{
|
||||
return m_data.id() > 0;
|
||||
return m_data.id > 0;
|
||||
}
|
||||
|
||||
bool ObjectFileTypeInfo::isUsed() const
|
||||
{
|
||||
return m_data.isUsed();
|
||||
return m_data.isUsed;
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectFileTypeInfo::createObject(const FileTypeInfo &data)
|
||||
{
|
||||
m_data = data;
|
||||
|
||||
if (m_data.id() <= 0)
|
||||
if (m_data.id <= 0)
|
||||
{
|
||||
m_data.isUsed(false);
|
||||
m_data.isUsed = false;
|
||||
|
||||
Database::FlmFileTypeInfo dbData;
|
||||
dbData = toDbData(data);
|
||||
@@ -45,63 +45,63 @@ Core::FunctionReplyObject ObjectFileTypeInfo::createObject(const FileTypeInfo &d
|
||||
if (!db()->insert(dbData))
|
||||
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting FileTypeInfo-data into database"));
|
||||
|
||||
m_data.id(dbData.id);
|
||||
DEBUG_LOG(m_logger) << "New FileTypeInfo Id: " << m_data.id();
|
||||
m_data.id = dbData.id;
|
||||
DEBUG_LOG(m_logger) << "New FileTypeInfo Id: " << m_data.id;
|
||||
}
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectFileTypeInfo::updateObject(const FileTypeInfo &data)
|
||||
{
|
||||
if (!isValid())
|
||||
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Object not valid/blocked"));
|
||||
return Core::FunctionReplyObject(data.id, tr_lts("dds", "Object not valid/blocked"));
|
||||
|
||||
if (!db()->update(toDbData(data)))
|
||||
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Error updating FileTypeInfo-data into database"));
|
||||
return Core::FunctionReplyObject(data.id, tr_lts("dds", "Error updating FileTypeInfo-data into database"));
|
||||
|
||||
m_data = data;
|
||||
DEBUG_LOG(m_logger) << "Data changed for FileTypeInfo Id: " << m_data.id();
|
||||
DEBUG_LOG(m_logger) << "Data changed for FileTypeInfo Id: " << m_data.id;
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectFileTypeInfo::setUsed(bool isUsed)
|
||||
{
|
||||
if (!isValid())
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "Trying to update an already removed FileTypeInfo object"));
|
||||
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "Trying to update an already removed FileTypeInfo object"));
|
||||
|
||||
m_data.isUsed(isUsed);
|
||||
m_data.isUsed = isUsed;
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectFileTypeInfo::removeObject()
|
||||
{
|
||||
if (isUsed())
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "FileTypeInfo still in use"));
|
||||
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "FileTypeInfo still in use"));
|
||||
|
||||
if (!db()->removeFlmFileTypeInfo(m_data.id()))
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "FileTypeInfo %1 can not be removed")).arg(m_data.id());
|
||||
if (!db()->removeFlmFileTypeInfo(m_data.id))
|
||||
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "FileTypeInfo %1 can not be removed")).arg(m_data.id);
|
||||
|
||||
if (!dts()->removeFileTypeInfoByKey(m_data.id()))
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "FileTypeInfo %1 can not be taken from DDS")).arg(m_data.id());
|
||||
if (!dts()->removeFileTypeInfoByKey(m_data.id))
|
||||
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "FileTypeInfo %1 can not be taken from DDS")).arg(m_data.id);
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
void ObjectFileTypeInfo::onPublishData()
|
||||
{
|
||||
INFO_LOG(m_logger) << "Publish FileTypeInfo-data to dds (" << m_data.id() << ") ...";
|
||||
INFO_LOG(m_logger) << "Publish FileTypeInfo-data to dds (" << m_data.id << ") ...";
|
||||
|
||||
if (!dts()->publish(m_data))
|
||||
ERROR_LOG(m_logger) << "Error publishing FileTypeInfo-data to dds";
|
||||
@@ -116,9 +116,9 @@ Database::FlmFileTypeInfo ObjectFileTypeInfo::toDbData(const FileTypeInfo &ddsDa
|
||||
{
|
||||
Database::FlmFileTypeInfo dbData;
|
||||
|
||||
dbData.id = ddsData.id();
|
||||
dbData.description = QString::fromStdString(ddsData.description());
|
||||
dbData.extension = QString::fromStdString(ddsData.extension());
|
||||
dbData.id = ddsData.id;
|
||||
dbData.description = QString::fromStdString(ddsData.description);
|
||||
dbData.extension = QString::fromStdString(ddsData.extension);
|
||||
|
||||
return dbData;
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@ public:
|
||||
Core::FunctionReplyObject updateObject(const FileTypeInfo &data);
|
||||
Core::FunctionReplyObject removeObject();
|
||||
|
||||
qint32 getId() const { return m_data.id(); }
|
||||
QString getExtension() const { return QString::fromStdString(m_data.extension()); }
|
||||
qint32 getId() const { return m_data.id; }
|
||||
QString getExtension() const { return QString::fromStdString(m_data.extension); }
|
||||
|
||||
bool isValid() const;
|
||||
bool isUsed() const;
|
||||
|
||||
@@ -25,21 +25,21 @@ ObjectFolder::~ObjectFolder()
|
||||
|
||||
bool ObjectFolder::isValid() const
|
||||
{
|
||||
return m_data.id() > 0;
|
||||
return m_data.id > 0;
|
||||
}
|
||||
|
||||
bool ObjectFolder::isUsed() const
|
||||
{
|
||||
return m_data.isUsed();
|
||||
return m_data.isUsed;
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectFolder::createObject(const Folder &data)
|
||||
{
|
||||
m_data = data;
|
||||
|
||||
if (m_data.id() <= 0)
|
||||
if (m_data.id <= 0)
|
||||
{
|
||||
m_data.isUsed(false);
|
||||
m_data.isUsed = false;
|
||||
|
||||
Database::FlmFolder dbData;
|
||||
dbData = toDbData(data);
|
||||
@@ -49,26 +49,26 @@ Core::FunctionReplyObject ObjectFolder::createObject(const Folder &data)
|
||||
QString errText = db()->getLastError().databaseText();
|
||||
ERROR_LOG(m_logger) << "Error inserting Folder into database: " << errText;
|
||||
if (db()->getLastError().nativeErrorCode().contains(QStringLiteral("23505")))
|
||||
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting Folder into database: unique key violation inserting folder '%1'")).arg(m_data.name());
|
||||
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting Folder into database: unique key violation inserting folder '%1'")).arg(QString::fromStdString(m_data.name));
|
||||
if (db()->getLastError().nativeErrorCode().contains(QStringLiteral("23503")))
|
||||
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting Folder into database: foreign key violation inserting folder '%1'")).arg(m_data.name());
|
||||
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting Folder into database: foreign key violation inserting folder '%1'")).arg(QString::fromStdString(m_data.name));
|
||||
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting Folder into database: %1")).arg(errText);
|
||||
}
|
||||
|
||||
m_data.id(dbData.id);
|
||||
DEBUG_LOG(m_logger) << "New Folder Id: " << m_data.id();
|
||||
m_data.id = dbData.id;
|
||||
DEBUG_LOG(m_logger) << "New Folder Id: " << m_data.id;
|
||||
}
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectFolder::updateObject(const Folder &data)
|
||||
{
|
||||
if (!isValid())
|
||||
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Object not valid/blocked"));
|
||||
return Core::FunctionReplyObject(data.id, tr_lts("dds", "Object not valid/blocked"));
|
||||
|
||||
Database::FlmFolder dbData(toDbData(data));
|
||||
|
||||
@@ -76,52 +76,52 @@ Core::FunctionReplyObject ObjectFolder::updateObject(const Folder &data)
|
||||
{
|
||||
QString errText = db()->getLastError().databaseText();
|
||||
ERROR_LOG(m_logger) << "Error updating Folder into database: " << errText;
|
||||
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Error updating Folder into database: %1")).arg(errText);
|
||||
return Core::FunctionReplyObject(data.id, tr_lts("dds", "Error updating Folder into database: %1")).arg(errText);
|
||||
}
|
||||
|
||||
m_data = data;
|
||||
DEBUG_LOG(m_logger) << "Data changed for Folder Id: " << m_data.id();
|
||||
DEBUG_LOG(m_logger) << "Data changed for Folder Id: " << m_data.id;
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectFolder::setUsed(bool isUsed)
|
||||
{
|
||||
if (!isValid())
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "Trying to update an already removed Folder object"));
|
||||
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "Trying to update an already removed Folder object"));
|
||||
|
||||
m_data.isUsed(isUsed);
|
||||
m_data.isUsed = isUsed;
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectFolder::removeObject()
|
||||
{
|
||||
if (isUsed())
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "Folder still in use"));
|
||||
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "Folder still in use"));
|
||||
|
||||
if (!db()->removeFlmFolder(m_data.id()))
|
||||
if (!db()->removeFlmFolder(m_data.id))
|
||||
{
|
||||
QString errText = db()->getLastError().databaseText();
|
||||
ERROR_LOG(m_logger) << "Folder with id " << m_data.id() << " can not be removed from database: " << errText;
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "Folder with id %1 can not be removed from database: %2")).arg(m_data.id()).arg(errText);
|
||||
ERROR_LOG(m_logger) << "Folder with id " << m_data.id << " can not be removed from database: " << errText;
|
||||
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "Folder with id %1 can not be removed from database: %2")).arg(m_data.id).arg(errText);
|
||||
}
|
||||
|
||||
if (!dts()->removeFolderByKey(m_data.id()))
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "Folder with id %1 can not be taken from DDS")).arg(m_data.id());
|
||||
if (!dts()->removeFolderByKey(m_data.id))
|
||||
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "Folder with id %1 can not be taken from DDS")).arg(m_data.id);
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
void ObjectFolder::onPublishData()
|
||||
{
|
||||
INFO_LOG(m_logger) << "Publish Folder-data to dds (" << m_data.id() << ") ...";
|
||||
INFO_LOG(m_logger) << "Publish Folder-data to dds (" << m_data.id << ") ...";
|
||||
|
||||
if (!dts()->publish(m_data))
|
||||
ERROR_LOG(m_logger) << "Error publishing Folder-data to dds";
|
||||
@@ -136,14 +136,14 @@ Database::FlmFolder ObjectFolder::toDbData(const Folder &ddsData)
|
||||
{
|
||||
Database::FlmFolder dbData;
|
||||
|
||||
dbData.id = ddsData.id();
|
||||
dbData.name = QString::fromStdString(ddsData.name());
|
||||
dbData.path = LtsUtils::IntArray(ddsData.path());
|
||||
dbData.isEditable = ddsData.isEditable();
|
||||
dbData.isHidden = ddsData.isHidden();
|
||||
dbData.parentId = ddsData.parentId();
|
||||
dbData.operatorId = ddsData.operatorId();
|
||||
dbData.lastModified = ddsData.lastModified();
|
||||
dbData.id = ddsData.id;
|
||||
dbData.name = QString::fromStdString(ddsData.name);
|
||||
dbData.path = LtsUtils::IntArray(ddsData.path);
|
||||
dbData.isEditable = ddsData.isEditable;
|
||||
dbData.isHidden = ddsData.isHidden;
|
||||
dbData.parentId = ddsData.parentId;
|
||||
dbData.operatorId = ddsData.operatorId;
|
||||
dbData.lastModified = ddsData.lastModified;
|
||||
|
||||
return dbData;
|
||||
}
|
||||
|
||||
@@ -29,20 +29,20 @@ public:
|
||||
Core::FunctionReplyObject updateObject(const Folder &data);
|
||||
Core::FunctionReplyObject removeObject();
|
||||
|
||||
qint32 getId() const { return m_data.id(); }
|
||||
qint32 getId() const { return m_data.id; }
|
||||
Folder getData() const { return m_data; }
|
||||
QString getName() const { return QString::fromStdString(m_data.name()); }
|
||||
QString getName() const { return QString::fromStdString(m_data.name); }
|
||||
std::vector<int32_t> getPath() const
|
||||
{
|
||||
return m_data.path();
|
||||
return m_data.path;
|
||||
}
|
||||
qint32 getParentId() const
|
||||
{
|
||||
return m_data.path().size() > 1 ? m_data.path().at(m_data.path().size() - 2) : 0;
|
||||
return m_data.path.size() > 1 ? m_data.path.at(m_data.path.size() - 2) : 0;
|
||||
}
|
||||
bool pathContains(const int32_t &val) const
|
||||
{
|
||||
for (auto i : m_data.path())
|
||||
for (auto i : m_data.path)
|
||||
if (i == val) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user