Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+133
@@ -0,0 +1,133 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
|
||||
INCLUDE(MacroRTIDDSGen)
|
||||
INCLUDE(MacroCodeGenIdl)
|
||||
|
||||
SET(xml_FILE cod_service.xml)
|
||||
|
||||
#
|
||||
# --- Library svcCodCommon --------------------------------------------------------------------------------
|
||||
#
|
||||
SET(SRCS_common
|
||||
cod_export.h
|
||||
logger.cpp
|
||||
logger.h
|
||||
)
|
||||
|
||||
# Generate cod_enums.idl / cod.idl
|
||||
CODEGEN_IDL_SVC(SRCS_common ${xml_FILE})
|
||||
# Generate cod_db_impl.cpp/.h, cod_db.h
|
||||
CODEGEN_DATABASE(SRCS_common ${xml_FILE})
|
||||
|
||||
# Generate *.cpp/*.hpp from idl
|
||||
RTIDDSGEN(SRCS_common cod_enums.idl)
|
||||
RTIDDSGEN(SRCS_common cod.idl)
|
||||
|
||||
# Generate cod_dt[s,c]_types.h, cod_ft[s,c]_types.h
|
||||
CODEGEN_TOPIC_TYPEDEFS(SRCS_common ${xml_FILE})
|
||||
# generate cod_[d|f]tc.h
|
||||
CODEGEN_CLIENT_TOPICS_IFC(SRCS_common ${xml_FILE})
|
||||
|
||||
NGL_ADD_LIBRARY(AAR SV WS svcCodCommon SHARED ${SRCS_common})
|
||||
NGL_TARGET_INCLUDE_DIRECTORIES(svcCodCommon
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
)
|
||||
NGL_TARGET_LINK_LIBRARIES(svcCodCommon
|
||||
PRIVATE
|
||||
RTI::nddscpp2
|
||||
PUBLIC
|
||||
Qt5::Core
|
||||
ddscore
|
||||
ngldb
|
||||
NGLLogger
|
||||
)
|
||||
NGL_INSTALL_TARGET(svcCodCommon)
|
||||
|
||||
#
|
||||
# --- Library svcCodClient --------------------------------------------------------------------------------
|
||||
#
|
||||
SET(SRCS_client
|
||||
cod_export.h
|
||||
)
|
||||
# generate cod_[d|f]tc_impl.[cpp|h]
|
||||
CODEGEN_CLIENT_TOPICS_IMPL(SRCS_client ${xml_FILE})
|
||||
|
||||
NGL_ADD_LIBRARY(AAR SV WS svcCodClient SHARED ${SRCS_client})
|
||||
NGL_TARGET_INCLUDE_DIRECTORIES(svcCodClient
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
)
|
||||
|
||||
NGL_TARGET_LINK_LIBRARIES(svcCodClient
|
||||
PRIVATE
|
||||
RTI::nddscpp2
|
||||
ddsconnector
|
||||
PUBLIC
|
||||
svcCodCommon
|
||||
ddsftc
|
||||
)
|
||||
NGL_INSTALL_TARGET(svcCodClient)
|
||||
|
||||
#
|
||||
# --- Library svcCodServer --------------------------------------------------------------------------------
|
||||
#
|
||||
SET(SRCS_server
|
||||
cod_export.h
|
||||
dds_handler.cpp
|
||||
dds_handler.h
|
||||
initialization.cpp
|
||||
initialization.h
|
||||
handler_codification_data.cpp
|
||||
handler_codification_data.h
|
||||
object_codification_data.cpp
|
||||
object_codification_data.h
|
||||
settings.cpp
|
||||
settings.h
|
||||
${xml_FILE}
|
||||
)
|
||||
# generate cod_[d|f]ts.h, cod_[d|f]ts_impl.[cpp|h]
|
||||
CODEGEN_SERVER_TOPICS(SRCS_server ${xml_FILE})
|
||||
# Generate cod.sql, cod.xml
|
||||
CODEGEN_SQL(SRCS_server ${xml_FILE})
|
||||
|
||||
NGL_ADD_LIBRARY(AAR SV svcCodServer SHARED ${SRCS_server})
|
||||
NGL_TARGET_INCLUDE_DIRECTORIES(svcCodServer
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
)
|
||||
|
||||
NGL_TARGET_LINK_LIBRARIES(svcCodServer
|
||||
PRIVATE
|
||||
RTI::nddscpp2
|
||||
ddsconnector
|
||||
ddsfts
|
||||
PUBLIC
|
||||
svcCodCommon
|
||||
Qt5::Core
|
||||
svcCoreClient
|
||||
ddsconnector
|
||||
nglsettings
|
||||
ngldb
|
||||
ProjectConfig
|
||||
NGLLogger
|
||||
ngltools
|
||||
)
|
||||
NGL_INSTALL_TARGET(svcCodServer)
|
||||
|
||||
#
|
||||
# --- Topic Type Plugin --------------------------------------------------------------
|
||||
#
|
||||
CREATE_TOPIC_TYPE_PLUGIN(${xml_FILE})
|
||||
|
||||
# Uncomment if necessary
|
||||
#ADD_SUBDIRECTORY(UnitTests)
|
||||
#ADD_SUBDIRECTORY(ModuleTests)
|
||||
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Export definitions
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hanna E. Rathje, SLSE, 2015-08-04
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#ifndef COD_COMMON_EXPORT
|
||||
# ifdef BUILD_STATIC_LIBRARIES
|
||||
# define COD_COMMON_EXPORT
|
||||
# else
|
||||
# if defined(MAKE_SVCCODCOMMON_LIB)
|
||||
# define COD_COMMON_EXPORT Q_DECL_EXPORT
|
||||
# ifndef WIN32
|
||||
# ifdef NDDSUSERDllExport
|
||||
# undef NDDSUSERDllExport
|
||||
# endif
|
||||
# define NDDSUSERDllExport Q_DECL_EXPORT
|
||||
# endif
|
||||
# else
|
||||
# define COD_COMMON_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef COD_CLIENT_EXPORT
|
||||
# ifdef BUILD_STATIC_LIBRARIES
|
||||
# define COD_CLIENT_EXPORT
|
||||
# else
|
||||
# if defined(MAKE_SVCCODCLIENT_LIB)
|
||||
# define COD_CLIENT_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
# define COD_CLIENT_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef COD_SERVER_EXPORT
|
||||
# ifdef BUILD_STATIC_LIBRARIES
|
||||
# define COD_SERVER_EXPORT
|
||||
# else
|
||||
# if defined(MAKE_SVCCODSERVER_LIB)
|
||||
# define COD_SERVER_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
# define COD_SERVER_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<service namespace="CodificationManagement" abbreviation="COD" procNames="CodificationManagement" exerciseDependency="Exercise">
|
||||
<rcs>
|
||||
<Id Id="$Id$"/>
|
||||
<HeadURL HeadURL="$HeadURL$"/>
|
||||
<Author Author="$Author$"/>
|
||||
</rcs>
|
||||
<operatorRights offset="8">
|
||||
<guiPlugin name="CodificationManagement" offset="1">
|
||||
<operatorRightGroup name="Codification Tables" description="Edit Codification Data">
|
||||
<operatorRight right="CodificationDataEdit" value="1" description="Edit Codification Data"/>
|
||||
</operatorRightGroup>
|
||||
<operatorRightGroup name="Codification Tables BLUFOR" description="Show Codification Data BLUFOR">
|
||||
<operatorRight right="CodificationDataShowBLUFOR" value="3" description="Show Codification Data BLUFOR"/>
|
||||
</operatorRightGroup>
|
||||
<operatorRightGroup name="Codification Tables OPFOR" description="Show Codification Data OPFOR">
|
||||
<operatorRight right="CodificationDataShowOPFOR" value="2" description="Show Codification Data OPFOR"/>
|
||||
</operatorRightGroup>
|
||||
</guiPlugin>
|
||||
</operatorRights>
|
||||
<tables>
|
||||
<table name="cod_codification_table" comment="Contains the data of one coding table consisting of the four different table types - Numeral code table - Authentication table - Logistical term table - Descriptive table ">
|
||||
<column name="id" datatype="integer" isPrimaryKey="1">
|
||||
<sequence start="1" increment="1"/>
|
||||
</column>
|
||||
<column name="numeral_code_table_column_index" datatype="text" comment="Contains the column index values in csv-format. Max. number of column values is 13. An index value consists of one character, all characters are possible including umlauts. "/>
|
||||
<column name="numeral_code_table_row_index" datatype="text" comment="Contains the row index values in csv-format. Number of row index values is fixed to 13. An index value consists of one character, all characters are possible including umlauts."/>
|
||||
<column name="authentication_table_column_index" datatype="text" comment="Contains the column index values in csv-format. Number of column index values is fixed to 5. An index value consists of one fixed character. "/>
|
||||
<column name="authentication_table_row_index" datatype="text" comment="Contains the row index values in csv-format. Number of row index values is fixed to 13. An index value consists of one fixed character. "/>
|
||||
<column name="authentication_table_matirx" datatype="text" comment="Contains the matrix values in csv-format. An matix value consists of two numeral character in range 00-99. "/>
|
||||
<column name="logistical_term_table_column_index" datatype="text" comment="Contains the column index values in csv-format. Number of column index values is fixed to 5. An index value consists of one character, all characters are possible including umlauts."/>
|
||||
<column name="logistical_term_table_row_index" datatype="text" comment="Contains the row index values in csv-format. Number of row index values is fixed to 5. An index value consists of one character, all characters are possible including umlauts."/>
|
||||
<column name="logistical_term_table_matrix" datatype="text" comment="Contains logistical terms in csv-format. Number of row index values is fixed to 5. A term consists of max. two rows of each max. 10 characters, all characters are possible including umlauts."/>
|
||||
<column name="phrase_table" datatype="text" comment="Contains 13 pairs of real term/phrase in csv-format. Each term/phrase consists of each 15 character, all characters are possible including umlauts."/>
|
||||
<column name="note" datatype="text" comment="Contains an additionally description "/>
|
||||
<column name="identifier" datatype="text"/>
|
||||
<column name="validity_time" datatype="bigint"/>
|
||||
<column name="party_id" datatype="integer"/>
|
||||
<constraint name="UQ_cod_codification_table_id" type="unique">
|
||||
<column name="id"/>
|
||||
</constraint>
|
||||
</table>
|
||||
</tables>
|
||||
<views/>
|
||||
<dbServiceStructs>
|
||||
<serviceStruct name="CodCodificationTable" table="cod_codification_table"/>
|
||||
<table name="cod_codification_table"/>
|
||||
</dbServiceStructs>
|
||||
<topicTypes>
|
||||
<topicType name="CodificationData" isDataObject="1" routeToClient="1" routeToServer="0" routeInReplay="0" baseValueType="Core::BaseEntity">
|
||||
<column name="numeralCodeTableColumnIndex" idlType="string" comment="Contains the column index values in csv-format. Max. number of column values is 13. An index value consists of one character, all characters are possible including umlauts. "/>
|
||||
<column name="numeralCodeTableRowIndex" idlType="string" comment="Contains the row index values in csv-format. Number of row index values is fixed to 13. An index value consists of one character, all characters are possible including umlauts."/>
|
||||
<column name="authenticationTableColumnIndex" idlType="string" comment="Contains the column index values in csv-format. Number of column index values is fixed to 5. An index value consists of one fixed character. "/>
|
||||
<column name="authenticationTableRowIndex" idlType="string" comment="Contains the row index values in csv-format. Number of row index values is fixed to 13. An index value consists of one fixed character. "/>
|
||||
<column name="authenticationTableMatirx" idlType="string" comment="Contains the matrix values in csv-format. An matix value consists of two numeral character in range 00-99. "/>
|
||||
<column name="logisticalTermTableColumnIndex" idlType="string" comment="Contains the column index values in csv-format. Number of column index values is fixed to 5. An index value consists of one character, all characters are possible including umlauts."/>
|
||||
<column name="logisticalTermTableRowIndex" idlType="string" comment="Contains the row index values in csv-format. Number of row index values is fixed to 5. An index value consists of one character, all characters are possible including umlauts."/>
|
||||
<column name="logisticalTermTableMatrix" idlType="string" comment="Contains logistical terms in csv-format. Number of row index values is fixed to 5. A term consists of max. two rows of each max. 10 characters, all characters are possible including umlauts."/>
|
||||
<column name="phraseTable" idlType="string" comment="Contains 13 pairs of real term/phrase in csv-format. Each term/phrase consists of each 15 character, all characters are possible including umlauts."/>
|
||||
<column name="note" idlType="string" comment="Contains an additionally description "/>
|
||||
<column name="identifier" idlType="string"/>
|
||||
<column name="validityTime" idlType="long long" comment="Contains the validity time for the especially codifikation data table"/>
|
||||
<column name="partyId" idlType="long"/>
|
||||
</topicType>
|
||||
</topicTypes>
|
||||
<functionTopics>
|
||||
<functionTopic name="CodificationDataModify" requestTopicType="CodificationData" replyTopicType="Core::FunctionReply" requestTopicName="CodificationDataModifyRequest" replyTopicName="CodificationDataModifyReply" routeInReplay="0"/>
|
||||
<functionTopic name="CodificationDataRemove" requestTopicType="Core::RemoveElementRequest" replyTopicType="Core::FunctionReply" requestTopicName="CodificationDataRemoveRequest" replyTopicName="CodificationDataRemoveReply" routeInReplay="0"/>
|
||||
</functionTopics>
|
||||
<enumerations>
|
||||
<enumeration name="DummyEnum">
|
||||
<attribute key="val1" value="1"/>
|
||||
<attribute key="val2" value="2"/>
|
||||
</enumeration>
|
||||
</enumerations>
|
||||
</service>
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* DDS Handler for CodificationManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-11-14
|
||||
*/
|
||||
|
||||
#include "dds_handler.h"
|
||||
|
||||
using namespace CodificationManagement;
|
||||
|
||||
DdsHandler::DdsHandler(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector)
|
||||
: m_ddsConnector(ddsConnector)
|
||||
, m_logger(getLogger("DdsHandler"))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "DdsHandler(" << m_ddsConnector->getDomainId() << ") for partition: " << m_ddsConnector->getDefaultPartition();
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool DdsHandler::init(const QStringList &qosFileList)
|
||||
{
|
||||
INFO_LOG(m_logger) << "--- Start CodificationManagement DDSHandler.";
|
||||
|
||||
if (!m_ddsConnector->init(qosFileList))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error initializing dds connections - aborting";
|
||||
return false;
|
||||
}
|
||||
|
||||
// default initialize Publisher and Subscriber
|
||||
m_ddsConnector->initPublisherSubscriber();
|
||||
|
||||
m_topicLockMaster = std::make_shared<Core::TopicLockMaster>(m_ddsConnector);
|
||||
|
||||
// DTS
|
||||
m_ddsDts = CodificationManagement::Interface::Dts::create(m_ddsConnector);
|
||||
bool bRet = m_ddsDts->enableAll();
|
||||
INFO_LOG(m_logger) << "Dts initialised";
|
||||
|
||||
// FTS
|
||||
m_ddsFts = CodificationManagement::Interface::Fts::create(m_ddsConnector);
|
||||
bRet &= m_ddsFts->enableAll();
|
||||
INFO_LOG(m_logger) << "Fts initialised";
|
||||
|
||||
return bRet;
|
||||
} // end of init()
|
||||
|
||||
int DdsHandler::exerciseId() const
|
||||
{
|
||||
if (m_ddsConnector)
|
||||
return m_ddsConnector->getPartitionId();
|
||||
return -1;
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* DDS Handler for CodificationManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-11-14
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <DDS/Core/topic_lock_master.h>
|
||||
#include <CodificationManagement/cod_dts.h>
|
||||
#include <CodificationManagement/cod_fts.h>
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
class DdsHandler final
|
||||
{
|
||||
public:
|
||||
explicit DdsHandler(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector);
|
||||
~DdsHandler() = default;
|
||||
|
||||
bool init(const QStringList &qosFileList = QStringList());
|
||||
|
||||
std::shared_ptr<Core::TopicLockMaster> topicLockMaster() const { return m_topicLockMaster; }
|
||||
|
||||
std::shared_ptr<CodificationManagement::Interface::Dts> dts() const { return m_ddsDts; }
|
||||
std::shared_ptr<CodificationManagement::Interface::Fts> fts() const { return m_ddsFts; }
|
||||
|
||||
int exerciseId() const;
|
||||
|
||||
private:
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
std::shared_ptr<Core::TopicLockMaster> m_topicLockMaster;
|
||||
std::shared_ptr<CodificationManagement::Interface::Dts> m_ddsDts;
|
||||
std::shared_ptr<CodificationManagement::Interface::Fts> m_ddsFts;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
} // Namespace CodificationManagement
|
||||
@@ -0,0 +1,131 @@
|
||||
/**
|
||||
* Handler for codification data
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-11-18
|
||||
*/
|
||||
|
||||
#include "handler_codification_data.h"
|
||||
#include "object_codification_data.h"
|
||||
|
||||
using namespace CodificationManagement;
|
||||
|
||||
HandlerCodificationData::HandlerCodificationData(const std::shared_ptr<DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<DbHandler> &dbHandler)
|
||||
: Interface::Fts::CodificationDataModifyRequestHandler(ddsHandler->fts())
|
||||
, Interface::Fts::CodificationDataRemoveRequestHandler(ddsHandler->fts())
|
||||
, m_ddsHandler(ddsHandler)
|
||||
, m_dbHandler(dbHandler)
|
||||
, m_logger(getLogger("HandlerCodificationData"))
|
||||
{
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
HandlerCodificationData::~HandlerCodificationData()
|
||||
{
|
||||
qDeleteAll(m_codificationdataObjMap);
|
||||
} // end of dtor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool HandlerCodificationData::init()
|
||||
{
|
||||
QVector<Database::CodCodificationTable> dataVec;
|
||||
// read all CodificationDatas from database
|
||||
if (!m_dbHandler->db()->select(dataVec))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error reading data from database!";
|
||||
return true;
|
||||
}
|
||||
|
||||
// create objects
|
||||
for (const Database::CodCodificationTable &data : qAsConst(dataVec))
|
||||
{
|
||||
CodificationManagement::CodificationData ddsData = ObjectCodificationData::toDdsData(data);
|
||||
ObjectCodificationData *ifs(new ObjectCodificationData(m_ddsHandler, m_dbHandler));
|
||||
Core::FunctionReplyObject ret = ifs->createObject(ddsData);
|
||||
if (ret.error())
|
||||
{
|
||||
delete ifs;
|
||||
ERROR_LOG(m_logger) << ret();
|
||||
return false;
|
||||
}
|
||||
m_codificationdataObjMap.insert(ifs->getId(), ifs);
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "m_codificationdataObjMap.size() = " << m_codificationdataObjMap.size();
|
||||
|
||||
return true;
|
||||
} // end of init()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void HandlerCodificationData::onCodificationDataModifyRequest(const rti::core::SampleIdentity &cookie,
|
||||
const CodificationData &request)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onCodificationDataModifyRequest: " << request;
|
||||
auto ret = request.id() > 0 ? codificationDataModifyRequest(request) : codificationDataCreateRequest(request);
|
||||
if (ret.error())
|
||||
WARNING_LOG(m_logger) << ret();
|
||||
m_ddsHandler->fts()->codificationDataModifyReply(cookie, ret);
|
||||
} // end of onCodificationDataModifyRequest()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
Core::FunctionReplyObject HandlerCodificationData::codificationDataCreateRequest(const CodificationData &request)
|
||||
{
|
||||
ObjectCodificationData *ifs(new ObjectCodificationData(m_ddsHandler, m_dbHandler));
|
||||
Core::FunctionReplyObject ret = ifs->createObject(request);
|
||||
if (ret.error())
|
||||
delete ifs;
|
||||
else
|
||||
m_codificationdataObjMap.insert(ifs->getId(), ifs);
|
||||
|
||||
return ret;
|
||||
} // end of onCodificationDataCreateRequest()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
Core::FunctionReplyObject HandlerCodificationData::codificationDataModifyRequest(const CodificationData &request)
|
||||
{
|
||||
ObjectCodificationData *ifs = m_codificationdataObjMap.value(request.id());
|
||||
if (ifs == nullptr)
|
||||
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "Codification table with id %1 not found")).arg(request.id());
|
||||
|
||||
return ifs->updateObject(request);
|
||||
} // end of onCodificationDataModifyRequest()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void HandlerCodificationData::onCodificationDataRemoveRequest(const rti::core::SampleIdentity &cookie,
|
||||
const Core::RemoveElementRequest &request)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onCodificationDataRemoveRequest: " << request;
|
||||
|
||||
|
||||
ObjectCodificationData *ifs = m_codificationdataObjMap.value(request.id());
|
||||
if (ifs == nullptr)
|
||||
{
|
||||
Core::FunctionReplyObject ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "Codification table with id %1 not found")).arg(request.id());
|
||||
ERROR_LOG(m_logger) << ret();
|
||||
m_ddsHandler->fts()->codificationDataRemoveReply(cookie, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_ddsHandler->topicLockMaster()->isLocked(ifs->getData(), m_ddsHandler->exerciseId()))
|
||||
{
|
||||
Core::FunctionReplyObject ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "Codification '%1' is used by another user!")).arg(ifs->getData().identifier());
|
||||
m_ddsHandler->fts()->codificationDataRemoveReply(cookie, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ret = ifs->removeObject();
|
||||
if (ret.error())
|
||||
ERROR_LOG(m_logger) << ret();
|
||||
else
|
||||
{
|
||||
// delete codification object
|
||||
delete ifs;
|
||||
m_codificationdataObjMap.remove(request.id());
|
||||
}
|
||||
|
||||
m_ddsHandler->fts()->codificationDataRemoveReply(cookie, ret);
|
||||
|
||||
} // end of onCodificationDataRemoveRequest()
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Handler for codification data
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-11-18
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QMap>
|
||||
|
||||
#include "dds_handler.h"
|
||||
#include "initialization.h"
|
||||
#include "logger.h"
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
class ObjectCodificationData;
|
||||
class HandlerCodificationData final
|
||||
: protected Interface::Fts::CodificationDataModifyRequestHandler
|
||||
, protected Interface::Fts::CodificationDataRemoveRequestHandler
|
||||
{
|
||||
public:
|
||||
HandlerCodificationData(const std::shared_ptr<DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<DbHandler> &dbHandler);
|
||||
|
||||
~HandlerCodificationData();
|
||||
|
||||
bool init();
|
||||
|
||||
|
||||
private: // FTS methods
|
||||
void onCodificationDataModifyRequest(const rti::core::SampleIdentity &cookie,
|
||||
const CodificationData &request) override final;
|
||||
Core::FunctionReplyObject codificationDataCreateRequest(const CodificationData &request);
|
||||
Core::FunctionReplyObject codificationDataModifyRequest(const CodificationData &request);
|
||||
void onCodificationDataRemoveRequest(const rti::core::SampleIdentity &cookie,
|
||||
const Core::RemoveElementRequest &request) override final;
|
||||
|
||||
|
||||
private: // attributes
|
||||
std::shared_ptr<DdsHandler> m_ddsHandler;
|
||||
std::shared_ptr<DbHandler> m_dbHandler;
|
||||
QMap<int, ObjectCodificationData *> m_codificationdataObjMap;
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
/**
|
||||
* Initialization for CodificationManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-11-14
|
||||
*/
|
||||
|
||||
#include "initialization.h"
|
||||
#include "settings.h"
|
||||
#include "handler_codification_data.h"
|
||||
#include <CodificationManagement/cod_db.h>
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <DDS/Core/pacemaker.h>
|
||||
|
||||
using namespace CodificationManagement;
|
||||
|
||||
Initialization::Initialization()
|
||||
: m_logger(getLogger("Initialization"))
|
||||
{
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
Initialization::~Initialization()
|
||||
{
|
||||
m_handlerCodificationData = nullptr;
|
||||
m_ddsHandler = nullptr;
|
||||
m_dbHandler = nullptr;
|
||||
} // end of dtor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool Initialization::initialize(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector,
|
||||
const QSqlDatabase &sqlDb)
|
||||
{
|
||||
INFO_LOG(m_logger) << "Start CodificationManagement Initialization.";
|
||||
|
||||
// initialize DDS
|
||||
m_ddsHandler = std::make_shared<DdsHandler>(ddsConnector);
|
||||
if (!m_ddsHandler->init())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Initialisation DdsHandler failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
// initialize database
|
||||
m_dbHandler = std::make_shared<DbHandler>();
|
||||
if (!m_dbHandler->init(ddsConnector->getPartitionId(), sqlDb))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Initialisation DbHandler failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
// create HandlerCodificationData
|
||||
m_handlerCodificationData.reset(new HandlerCodificationData(m_ddsHandler, m_dbHandler));
|
||||
|
||||
INFO_LOG(m_logger) << "CodificationManagement Initialization initialized. pacemakerState: Running ";
|
||||
|
||||
return true;
|
||||
} // end of init()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool Initialization::loadFromDatabase()
|
||||
{
|
||||
if (!m_ddsHandler || !m_dbHandler || !m_handlerCodificationData)
|
||||
return false;
|
||||
if (!m_handlerCodificationData->init())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Initialisation HandlerCodificationData failed.";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Initialization for CodificationManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-11-14
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <ngldb/db_service_handler.h>
|
||||
#include <CodificationManagement/cod_export.h>
|
||||
#include <CodificationManagement/logger.h>
|
||||
|
||||
class QSqlDatabase;
|
||||
namespace CodificationManagement
|
||||
{
|
||||
class DdsHandler;
|
||||
class DatabaseInterface;
|
||||
using DbHandler = NGLDB::DbServiceHandler<DatabaseInterface>;
|
||||
class HandlerCodificationData;
|
||||
|
||||
class COD_SERVER_EXPORT Initialization final
|
||||
{
|
||||
public:
|
||||
Initialization();
|
||||
~Initialization();
|
||||
|
||||
bool initialize(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector, const QSqlDatabase &sqlDb);
|
||||
bool loadFromDatabase();
|
||||
|
||||
private: // attributes
|
||||
std::shared_ptr<DdsHandler> m_ddsHandler; ///< Pointer to DDS handler
|
||||
std::shared_ptr<DbHandler> m_dbHandler; ///< Pointer to DB handler
|
||||
std::shared_ptr<HandlerCodificationData> m_handlerCodificationData; ///< Pointer to codification data handler
|
||||
|
||||
NGL::INGLLogger &m_logger; ///< Interface to the Logging-Facility
|
||||
|
||||
};
|
||||
} // namespace CodificationManagement
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Logger for CodificationManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-11-14
|
||||
*/
|
||||
#include "logger.h"
|
||||
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
|
||||
LOGGER_T getLogger(const char *name)
|
||||
{
|
||||
static const char ns[] = "COD.";
|
||||
std::string loggerName;
|
||||
const size_t len = strlen(name);
|
||||
loggerName.reserve(sizeof(ns) + len);
|
||||
loggerName.append(ns, sizeof(ns) - 1);
|
||||
loggerName.append(name, len);
|
||||
|
||||
try
|
||||
{
|
||||
return NGL::NGLLoggerBootstrap::getNGLRootLogger().
|
||||
getNGLLogger(loggerName);
|
||||
}
|
||||
catch (const std::exception &ex)
|
||||
{
|
||||
fprintf(stderr, "Error retrieving logger: %s", ex.what());
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace CodificationManagement
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Logger for CodificationManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-11-14
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
#include "cod_export.h"
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
using LOGGER_T = NGL::INGLLogger &;
|
||||
|
||||
COD_COMMON_EXPORT LOGGER_T getLogger(const char *name);
|
||||
inline LOGGER_T getLogger(const QString &loggerName)
|
||||
{
|
||||
return getLogger(loggerName.toUtf8().constData());
|
||||
}
|
||||
} // namespace CodificationManagement
|
||||
@@ -0,0 +1,168 @@
|
||||
/**
|
||||
* Codification data object
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-11-18
|
||||
*/
|
||||
|
||||
#include "object_codification_data.h"
|
||||
#include "dds_handler.h"
|
||||
|
||||
using namespace CodificationManagement;
|
||||
|
||||
ObjectCodificationData::ObjectCodificationData(const std::shared_ptr<DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<DbHandler> &dbHandler)
|
||||
: m_ddsHandler(ddsHandler)
|
||||
, m_dbHandler(dbHandler)
|
||||
, m_logger(getLogger("ObjectCodificationData"))
|
||||
{
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ObjectCodificationData::~ObjectCodificationData()
|
||||
{
|
||||
m_ddsHandler->dts()->removeCodificationDataByKey(m_ddsData.id());
|
||||
} // end of dtor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
Core::FunctionReplyObject ObjectCodificationData::createObject(const CodificationData &ddsData)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "ObjectCodificationData::createObject()";
|
||||
|
||||
m_ddsData = ddsData;
|
||||
if (m_ddsData.id() <= 0)
|
||||
{
|
||||
m_ddsData.isUsed(false);
|
||||
|
||||
Database::CodCodificationTable dbData;
|
||||
dbData = toDbData(ddsData);
|
||||
|
||||
if (!m_dbHandler->db()->insert(dbData))
|
||||
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting codification_table data into database"));
|
||||
|
||||
m_ddsData.id(dbData.id);
|
||||
DEBUG_LOG(m_logger) << "New codificationTable id: " << m_ddsData.id();
|
||||
}
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_ddsData.id());
|
||||
} // end of createObject()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
Core::FunctionReplyObject ObjectCodificationData::updateObject(const CodificationManagement::CodificationData &ddsData)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "ObjectCodificationData::updateObject()";
|
||||
|
||||
if (!isValid())
|
||||
return Core::FunctionReplyObject(ddsData.id(), tr_lts("dds", "Object not valid/blocked"));
|
||||
|
||||
// convert request ddsData -> dbData
|
||||
Database::CodCodificationTable dbData;
|
||||
dbData = toDbData(ddsData);
|
||||
|
||||
if (!m_dbHandler->db()->update(dbData))
|
||||
return Core::FunctionReplyObject(ddsData.id(), tr_lts("dds", "Error updating codification_table data in database"));
|
||||
// update internal objectdata
|
||||
m_ddsData = ddsData;
|
||||
DEBUG_LOG(m_logger) << "Data changed for codification_table id: " << m_ddsData.id();
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_ddsData.id());
|
||||
|
||||
} // end of updateObject()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
Core::FunctionReplyObject ObjectCodificationData::removeObject()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "ObjectCodificationData::removeObject()";
|
||||
|
||||
if (isUsed())
|
||||
return Core::FunctionReplyObject(m_ddsData.id(), tr_lts("dds", "codification_table data still in use"));
|
||||
|
||||
if (!m_dbHandler->db()->removeCodCodificationTable(m_ddsData.id()))
|
||||
return Core::FunctionReplyObject(m_ddsData.id(), tr_lts("dds", "codification_table with id %1 can not be removed")).arg(m_ddsData.id());
|
||||
|
||||
DEBUG_LOG(m_logger) << "Removed codification_table id " << m_ddsData.id();
|
||||
m_ddsHandler->dts()->removeCodificationDataByKey(m_ddsData.id());
|
||||
|
||||
return Core::FunctionReplyObject(m_ddsData.id());
|
||||
} // end of removeObject()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void ObjectCodificationData::onPublishData()
|
||||
{
|
||||
INFO_LOG(m_logger) << "Publish CodificationData data to dds (" << m_ddsData.id() << ") ...";
|
||||
|
||||
if (!m_ddsHandler->dts()->publish(m_ddsData))
|
||||
ERROR_LOG(m_logger) << "Error publishing CodificationData data to dds";
|
||||
} // end of onPublishData()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool ObjectCodificationData::isValid() const
|
||||
{
|
||||
return m_ddsData.id() > 0;
|
||||
} // end of isValid()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool ObjectCodificationData::isUsed() const
|
||||
{
|
||||
return m_ddsData.isUsed();
|
||||
} // end of isUsed()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
CodificationManagement::CodificationData ObjectCodificationData::toDdsData(const Database::CodCodificationTable &dbData)
|
||||
{
|
||||
CodificationManagement::CodificationData ddsData;
|
||||
|
||||
ddsData.id(dbData.id);
|
||||
ddsData.numeralCodeTableColumnIndex(dbData.numeralCodeTableColumnIndex.toStdString());
|
||||
ddsData.numeralCodeTableRowIndex(dbData.numeralCodeTableRowIndex.toStdString());
|
||||
ddsData.authenticationTableColumnIndex(dbData.authenticationTableColumnIndex.toStdString());
|
||||
ddsData.authenticationTableRowIndex(dbData.authenticationTableRowIndex.toStdString());
|
||||
ddsData.authenticationTableMatirx(dbData.authenticationTableMatirx.toStdString());
|
||||
ddsData.logisticalTermTableColumnIndex(dbData.logisticalTermTableColumnIndex.toStdString());
|
||||
ddsData.logisticalTermTableRowIndex(dbData.logisticalTermTableRowIndex.toStdString());
|
||||
ddsData.logisticalTermTableMatrix(dbData.logisticalTermTableMatrix.toStdString());
|
||||
ddsData.phraseTable(dbData.phraseTable.toStdString());
|
||||
ddsData.note(dbData.note.toStdString());
|
||||
ddsData.identifier(dbData.identifier.toStdString()),
|
||||
ddsData.validityTime(dbData.validityTime);
|
||||
ddsData.partyId(dbData.partyId);
|
||||
|
||||
// init data not in db
|
||||
ddsData.isDeleted(false);
|
||||
ddsData.isUsed(false);
|
||||
|
||||
return ddsData;
|
||||
} // end of toDdsData()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
Database::CodCodificationTable ObjectCodificationData::toDbData(const CodificationManagement::CodificationData &ddsData)
|
||||
{
|
||||
Database::CodCodificationTable dbData;
|
||||
|
||||
dbData.id = ddsData.id();
|
||||
dbData.numeralCodeTableColumnIndex = QString::fromStdString(ddsData.numeralCodeTableColumnIndex());
|
||||
dbData.numeralCodeTableRowIndex = QString::fromStdString(ddsData.numeralCodeTableRowIndex());
|
||||
dbData.authenticationTableColumnIndex = QString::fromStdString(ddsData.authenticationTableColumnIndex());
|
||||
dbData.authenticationTableRowIndex = QString::fromStdString(ddsData.authenticationTableRowIndex());
|
||||
dbData.authenticationTableMatirx = QString::fromStdString(ddsData.authenticationTableMatirx());
|
||||
dbData.logisticalTermTableColumnIndex = QString::fromStdString(ddsData.logisticalTermTableColumnIndex());
|
||||
dbData.logisticalTermTableRowIndex = QString::fromStdString(ddsData.logisticalTermTableRowIndex());
|
||||
dbData.logisticalTermTableMatrix = QString::fromStdString(ddsData.logisticalTermTableMatrix());
|
||||
dbData.phraseTable = QString::fromStdString(ddsData.phraseTable());
|
||||
dbData.note = QString::fromStdString(ddsData.note());
|
||||
dbData.identifier = QString::fromStdString(ddsData.identifier());
|
||||
dbData.validityTime = ddsData.validityTime();
|
||||
dbData.partyId = ddsData.partyId();
|
||||
|
||||
return dbData;
|
||||
} // end of toDbData()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Codification data object
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-11-18
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "initialization.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include <CodificationManagement/cod_fts.h>
|
||||
#include <CodificationManagement/cod_db.h>
|
||||
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
class ObjectCodificationData final
|
||||
{
|
||||
public:
|
||||
explicit ObjectCodificationData(const std::shared_ptr<DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<DbHandler> &dbHandler);
|
||||
|
||||
~ObjectCodificationData();
|
||||
|
||||
Core::FunctionReplyObject createObject(const CodificationManagement::CodificationData &ddsData);
|
||||
Core::FunctionReplyObject updateObject(const CodificationManagement::CodificationData &ddsData);
|
||||
Core::FunctionReplyObject removeObject();
|
||||
|
||||
qint32 getId() const { return m_ddsData.id(); }
|
||||
QString getName() const { return QString::fromStdString(m_ddsData.name()); }
|
||||
const CodificationData &getData() const { return m_ddsData; }
|
||||
|
||||
bool isValid() const;
|
||||
bool isUsed() const;
|
||||
|
||||
// convert methodes
|
||||
static CodificationManagement::CodificationData toDdsData(const Database::CodCodificationTable &dbData); // db -> dds
|
||||
static Database::CodCodificationTable toDbData(const CodificationManagement::CodificationData &ddsData); // dds -> db
|
||||
|
||||
protected:
|
||||
void onPublishData();
|
||||
|
||||
private:
|
||||
std::shared_ptr<DdsHandler> m_ddsHandler;
|
||||
std::shared_ptr<DbHandler> m_dbHandler;
|
||||
CodificationData m_ddsData;
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
};
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* Settings for CodificationManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-11-14
|
||||
*/
|
||||
|
||||
|
||||
#include "settings.h"
|
||||
|
||||
#include <QtCore/QSettings>
|
||||
#include <nglsettings/nglsettings_settings.h>
|
||||
#include <ngltools/ngltools_filesystem.h>
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
class NGLSettingsClass : public NGL::Settings
|
||||
{
|
||||
public:
|
||||
NGLSettingsClass()
|
||||
: NGL::Settings(s_iniFile.isEmpty() ? NGL::findProjectConfigFile() : s_iniFile)
|
||||
{}
|
||||
static void setIniFile(const QString &fn)
|
||||
{
|
||||
s_iniFile = fn;
|
||||
}
|
||||
static QString s_iniFile;
|
||||
};
|
||||
QString NGLSettingsClass::s_iniFile;
|
||||
Q_GLOBAL_STATIC(NGLSettingsClass, s)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
NGL::Settings *Settings::settings()
|
||||
{
|
||||
return s();
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void Settings::setIniFile(const QString &ini)
|
||||
{
|
||||
NGLSettingsClass::setIniFile(ini);
|
||||
}
|
||||
|
||||
} // namespace CodificationManagement
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Settings for CodificationManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-11-14
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <QString>
|
||||
#include <CodificationManagement/cod_export.h>
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class Settings;
|
||||
}
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
namespace Settings
|
||||
{
|
||||
NGL::Settings *settings();
|
||||
COD_SERVER_EXPORT void setIniFile(const QString &ini);
|
||||
}
|
||||
|
||||
} // namespace CodificationManagement
|
||||
Reference in new issue
Block a user