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>
170 lines
5.1 KiB
C++
170 lines
5.1 KiB
C++
/**
|
|
* Asset object
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Iuliana Ojog, SLSE, 2017-09-20
|
|
*/
|
|
|
|
#include "object_asset.h"
|
|
#include "main_handler.h"
|
|
|
|
#include <LtsUtils/LtsUtilsCore/dds_vector.h>
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
namespace AssetManagement
|
|
{
|
|
ObjectAsset::ObjectAsset(MainHandler *mainHandler)
|
|
: m_mainHandler(mainHandler)
|
|
, m_logger(getLogger("ObjectAsset"))
|
|
{
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
ObjectAsset::~ObjectAsset()
|
|
{
|
|
if (isValid())
|
|
m_mainHandler->dds()->dts()->removeAssetByKey(m_data.id());
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
bool ObjectAsset::isValid() const
|
|
{
|
|
return m_data.id() > 0;
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
bool ObjectAsset::isUsed() const
|
|
{
|
|
return m_data.isUsed();
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
Core::FunctionReplyObject ObjectAsset::createObject(const Asset &data)
|
|
{
|
|
m_data = data;
|
|
|
|
if (m_data.id() <= 0)
|
|
{
|
|
m_data.isUsed(false);
|
|
|
|
Database::AsmAsset dbData(toDbData(data));
|
|
|
|
if (!m_mainHandler->db()->insert(dbData))
|
|
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting AsmAsset-data into database"));
|
|
|
|
m_data.id(dbData.id);
|
|
DEBUG_LOG(m_logger) << "New assetId: " << m_data.id();
|
|
}
|
|
|
|
// Publish Data via DTS
|
|
onPublishData();
|
|
|
|
return Core::FunctionReplyObject(m_data.id());
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
Core::FunctionReplyObject ObjectAsset::updateObject(const Asset &data)
|
|
{
|
|
if (!isValid())
|
|
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Object not valid/blocked"));
|
|
|
|
Database::AsmAsset dbData;
|
|
dbData = toDbData(data);
|
|
|
|
if (!m_mainHandler->db()->update(dbData))
|
|
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Error updating AsmAsset-data into database"));
|
|
|
|
m_data = data;
|
|
DEBUG_LOG(m_logger) << "Data changed for assetId: " << m_data.id();
|
|
|
|
// Publish Data via DTS
|
|
onPublishData();
|
|
|
|
return Core::FunctionReplyObject(m_data.id());
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
Core::FunctionReplyObject ObjectAsset::setUsed(bool isUsed)
|
|
{
|
|
if (!isValid())
|
|
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "Trying to update an already removed AsmAsset object"));
|
|
|
|
m_data.isUsed(isUsed);
|
|
|
|
// Publish Data via DTS
|
|
onPublishData();
|
|
|
|
return Core::FunctionReplyObject(m_data.id());
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
Core::FunctionReplyObject ObjectAsset::removeObject()
|
|
{
|
|
if (isUsed())
|
|
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "Asset still in use"));
|
|
|
|
if (!m_mainHandler->db()->removeAsmAsset(m_data.id()))
|
|
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "Asset with id %1 can not be removed from DB")).arg(m_data.id());
|
|
|
|
if (!m_mainHandler->dds()->dts()->removeAssetByKey(m_data.id()))
|
|
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "Asset with id %1 can not be removed from DDS")).arg(m_data.id());
|
|
|
|
return Core::FunctionReplyObject(m_data.id());
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
void ObjectAsset::onPublishData()
|
|
{
|
|
INFO_LOG(m_logger) << "Publish AsmAsset-data to dds (" << m_data.id() << ") ...";
|
|
|
|
if (!m_mainHandler->dds()->dts()->publish(m_data))
|
|
ERROR_LOG(m_logger) << "Error publishing AsmAsset-data to dds";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------------
|
|
// convert methods
|
|
// -------------------------------------------------------------------------------------------------------
|
|
|
|
// AssetManagement::Asset => Database::AsmAsset
|
|
Database::AsmAsset ObjectAsset::toDbData(const Asset &ddsData)
|
|
{
|
|
Database::AsmAsset dbData;
|
|
|
|
dbData.id = ddsData.id();
|
|
dbData.name = QString::fromStdString(ddsData.name());
|
|
dbData.assetTypeId = ddsData.assetTypeId();
|
|
dbData.locationId = ddsData.locationId();
|
|
dbData.subLocation = ddsData.subLocation();
|
|
dbData.certificate = LtsUtils::toQByteArray(ddsData.certificate());
|
|
dbData.properties = QString::fromStdString(ddsData.properties());
|
|
|
|
return dbData;
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------------
|
|
// Database::AsmAsset => AssetManagement::Asset
|
|
Asset ObjectAsset::toDdsData(const Database::AsmAsset &dbData)
|
|
{
|
|
Asset ddsData;
|
|
|
|
ddsData.id(dbData.id);
|
|
ddsData.name(dbData.name.toStdString());
|
|
ddsData.assetTypeId(dbData.assetTypeId);
|
|
ddsData.locationId(dbData.locationId);
|
|
ddsData.subLocation(dbData.subLocation);
|
|
ddsData.certificate(LtsUtils::convert<std::vector<uint8_t>>(dbData.certificate));
|
|
ddsData.properties(dbData.properties.toStdString());
|
|
|
|
// init data not in db
|
|
ddsData.isDeleted(false);
|
|
ddsData.isUsed(false);
|
|
|
|
return ddsData;
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------------
|
|
|
|
} // Namespace AssetManagement
|