Major Changes:
- Merged latest Qt5 devel content from dlbo (292 files changed, 7 new dirs)
- Consolidated forward-declarations and include folders
- Removed unneeded modules per Niklas' repo check list
Build System Fixes:
- Fixed CMake VERSION_GREATER syntax in ParticipantManagement/CMakeLists.txt
- Added VLC packages (libvlc-dev, vlc-plugin-base) to docker_build.sh
- Added PostgreSQL dev packages (libpq-dev, postgresql-server-dev-all) to Dockerfile
- Fixed locale warnings (ANSI_X3.4-1968 → C.UTF-8)
- Fixed ArcGIS SDK path warnings when BUILD_ARCGIS=OFF
Code Generation Fixes:
- Fixed IDL enum collisions (PortType→CorePortType/DdsutPortType, PdmEventType)
- Fixed Grantlee template svc_translation.cpp.grantlee:
- Changed {{ idl_enum.name }}_def:: to {{ idl_enum.name }}::
- Fixed .underlying() calls for C++11 scoped enums (enum class)
- Removed generated files from repo (moc_*, *_dtc.h, *_ftc.h)
Validation:
- BUILD_RTI=ON: SUCCESS
- BUILD_RTI=OFF: SUCCESS
- C++17 standard maintained for RTI 7.7 compatibility
- Ubuntu 26.04 Docker environment verified
Remaining Warnings (expected):
- BgViewer, KDChart, KDReports, Poppler-Qt6 not found (optional features)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
252 lines
8.5 KiB
C++
252 lines
8.5 KiB
C++
/**
|
|
* @RDE_HEADER@
|
|
* Object file content
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Iuliana Ojog, SLSE, 2017-04-03
|
|
*/
|
|
|
|
#include "object_file_content.h"
|
|
#include "flm_db_impl_custom.h"
|
|
|
|
|
|
namespace FileManagement
|
|
{
|
|
ObjectFileContent::ObjectFileContent(MainHandler *mainHandler)
|
|
: Base(mainHandler, getLogger("ObjectFileContent"))
|
|
{
|
|
}
|
|
|
|
ObjectFileContent::ObjectFileContent(const FileContent &data, MainHandler *mainHandler)
|
|
: Base(mainHandler, getLogger("ObjectFileContent"))
|
|
, m_data(data)
|
|
{
|
|
}
|
|
|
|
ObjectFileContent::~ObjectFileContent()
|
|
{
|
|
}
|
|
|
|
bool ObjectFileContent::isValid() const
|
|
{
|
|
return m_data.id() > 0;
|
|
}
|
|
|
|
bool ObjectFileContent::isUsed() const
|
|
{
|
|
return m_data.isUsed();
|
|
}
|
|
bool ObjectFileContent::isHidden() const
|
|
{
|
|
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());
|
|
|
|
return data;
|
|
}
|
|
|
|
Core::FunctionReplyObject ObjectFileContent::createObject(const FileContentModifyRequest &request)
|
|
{
|
|
m_data = toFileContent(request);
|
|
|
|
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());
|
|
|
|
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());
|
|
else
|
|
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting FileContent with name %1 into database: %2")).arg(m_data.name()).arg(errText);
|
|
}
|
|
|
|
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());
|
|
}
|
|
|
|
Core::FunctionReplyObject ObjectFileContent::updateObject(const FileContentModifyRequest &request)
|
|
{
|
|
if (!isValid())
|
|
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());
|
|
|
|
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());
|
|
else
|
|
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "Error updating FileContent with name %1 into database: %2")).arg(m_data.name()).arg(errText);
|
|
}
|
|
|
|
DEBUG_LOG(m_logger) << "Data changed for FileContent Id: " << m_data.id();
|
|
|
|
// Publish Data via DTS
|
|
onPublishData();
|
|
|
|
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"));
|
|
|
|
m_data.isUsed(isUsed);
|
|
|
|
// Publish Data via DTS
|
|
onPublishData();
|
|
|
|
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"));
|
|
|
|
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()))
|
|
{
|
|
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);
|
|
}
|
|
|
|
// Publish Data via DTS
|
|
onPublishData();
|
|
|
|
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"));
|
|
|
|
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()))
|
|
{
|
|
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);
|
|
}
|
|
|
|
// Publish Data via DTS
|
|
onPublishData();
|
|
|
|
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"));
|
|
|
|
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);
|
|
}
|
|
|
|
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());
|
|
}
|
|
|
|
void ObjectFileContent::onPublishData()
|
|
{
|
|
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";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------------
|
|
// convert methods
|
|
// -------------------------------------------------------------------------------------------------------
|
|
|
|
// FileManagement::FileContent => Database::FileContent
|
|
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.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();
|
|
|
|
return dbData;
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------------
|
|
} // Namespace FileManagement
|