Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,120 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* ISM Object Mounting Point Asset
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Iuliana Ojog, SLSE, 2016-11-26
|
||||
*/
|
||||
|
||||
#include "object_mounting_point_asset.h"
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
namespace InfrastructureManagement
|
||||
{
|
||||
ObjectMountingPointAsset::ObjectMountingPointAsset(MainHandler *mainHandler)
|
||||
: Base(mainHandler, getLogger("ObjectMountingPointAsset"))
|
||||
{
|
||||
}
|
||||
|
||||
ObjectMountingPointAsset::~ObjectMountingPointAsset()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
Core::FunctionReplyObject ObjectMountingPointAsset::createObject(const MountingPointAsset &data)
|
||||
{
|
||||
m_data = data;
|
||||
|
||||
if (m_data.id() <= 0)
|
||||
{
|
||||
Database::IsmMountingPointAsset dbData;
|
||||
dbData = toDbData(data);
|
||||
|
||||
if (!db()->insert(dbData))
|
||||
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting IsmMountingPointAsset-data into database"));
|
||||
|
||||
m_data.id(dbData.id);
|
||||
DEBUG_LOG(m_logger) << "New Id: " << m_data.id();
|
||||
}
|
||||
|
||||
// Publish Data via DDS
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
Core::FunctionReplyObject ObjectMountingPointAsset::updateObject(const MountingPointAsset &data)
|
||||
{
|
||||
Database::IsmMountingPointAsset dbData = toDbData(data);
|
||||
|
||||
if (!db()->update(dbData))
|
||||
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Error updating IsmMountingPointAsset-data into database"));
|
||||
|
||||
m_data = data;
|
||||
DEBUG_LOG(m_logger) << "Data changed for Id: " << m_data.id();
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
Core::FunctionReplyObject ObjectMountingPointAsset::removeObject()
|
||||
{
|
||||
if (!db()->removeIsmMountingPointAsset(m_data.id()))
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "MountingPointAsset with id %1 can not be removed from DB")).arg(m_data.id());
|
||||
|
||||
if (!dts()->removeMountingPointAssetByKey(m_data.id()))
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "MountingPointAsset with id %1 can not be removed from DDS")).arg(m_data.id());
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
void ObjectMountingPointAsset::onPublishData()
|
||||
{
|
||||
INFO_LOG(m_logger) << "Publish IsmMountingPointAsset-data to dds (" << m_data.id() << ") ...";
|
||||
|
||||
if (!dts()->publish(m_data))
|
||||
ERROR_LOG(m_logger) << "Error publishing IsmMountingPointAsset-data to dds";
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
// convert methods
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
|
||||
// InfrastructureManagement::MountingPointAsset => Database::IsmMountingPointAsset
|
||||
Database::IsmMountingPointAsset ObjectMountingPointAsset::toDbData(const MountingPointAsset &ddsData)
|
||||
{
|
||||
Database::IsmMountingPointAsset dbData;
|
||||
|
||||
dbData.id = ddsData.id();
|
||||
dbData.assetId = ddsData.assetId();
|
||||
dbData.structureElementId = ddsData.structureElementId();
|
||||
dbData.name = QString::fromStdString(ddsData.name());
|
||||
dbData.lastUpdated = QDateTime::fromMSecsSinceEpoch(ddsData.lastUpdated());
|
||||
|
||||
return dbData;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
// Database::IsmMountingPointAsset => InfrastructureManagement::MountingPointAsset
|
||||
MountingPointAsset ObjectMountingPointAsset::toDdsData(const Database::IsmMountingPointAsset &dbData)
|
||||
{
|
||||
MountingPointAsset ddsData;
|
||||
|
||||
ddsData.id(dbData.id);
|
||||
ddsData.assetId(dbData.assetId);
|
||||
ddsData.structureElementId(dbData.structureElementId);
|
||||
ddsData.name(dbData.name.toStdString());
|
||||
ddsData.lastUpdated(dbData.lastUpdated.toMSecsSinceEpoch());
|
||||
|
||||
return ddsData;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
|
||||
} // Namespace InfrastructureManagement
|
||||
Reference in new issue
Block a user