Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
Executable
+156
@@ -0,0 +1,156 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
|
||||
INCLUDE(MacroRTIDDSGen)
|
||||
INCLUDE(MacroCodeGenIdl)
|
||||
|
||||
SET(xml_FILE evl_service.xml)
|
||||
|
||||
#
|
||||
# --- Library svcEvlCommon --------------------------------------------------------------------------------
|
||||
#
|
||||
SET(SRCS_common
|
||||
evl_export.h
|
||||
san_category_line_json.cpp
|
||||
san_category_line_json.h
|
||||
evl_db_impl_custom.cpp
|
||||
evl_db_impl_custom.h
|
||||
logger.cpp
|
||||
logger.h
|
||||
)
|
||||
|
||||
# Generate evl_enums.idl / evl.idl
|
||||
CODEGEN_IDL_SVC(SRCS_common ${xml_FILE})
|
||||
# Generate evl_db.cpp, evl_db_impl.cpp/.h
|
||||
CODEGEN_DATABASE_SQL(SRCS_common ${xml_FILE})
|
||||
|
||||
# Generate evl_db_structs.cpp/.h
|
||||
CODEGEN_DATABASE_STRUCTS(SRCS_common ${xml_FILE})
|
||||
|
||||
# Generate *.cpp/*.hpp from idl
|
||||
RTIDDSGEN(SRCS_common evl_enums.idl)
|
||||
RTIDDSGEN(SRCS_common evl.idl)
|
||||
|
||||
# Generate evl_dt[s,c]_types.h, evl_ft[s,c]_types.h
|
||||
CODEGEN_TOPIC_TYPEDEFS(SRCS_common ${xml_FILE})
|
||||
# Generate evl_[d|f]tc.h
|
||||
CODEGEN_CLIENT_TOPICS_IFC(SRCS_common ${xml_FILE})
|
||||
|
||||
NGL_ADD_LIBRARY(AAR SV WS svcEvlCommon SHARED ${SRCS_common})
|
||||
NGL_TARGET_INCLUDE_DIRECTORIES(svcEvlCommon
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
)
|
||||
NGL_TARGET_LINK_LIBRARIES(svcEvlCommon
|
||||
PRIVATE
|
||||
RTI::nddscpp2
|
||||
PUBLIC
|
||||
Qt5::Core
|
||||
ddscore
|
||||
NGLLogger
|
||||
ngldb
|
||||
)
|
||||
NGL_INSTALL_TARGET(svcEvlCommon)
|
||||
|
||||
#
|
||||
# --- Library svcEvlClient --------------------------------------------------------------------------------
|
||||
#
|
||||
SET(SRCS_client
|
||||
evl_export.h
|
||||
)
|
||||
# generate evl_[d|f]tc.h, evl_[d|f]tc_impl.[cpp|h]
|
||||
CODEGEN_CLIENT_TOPICS_IMPL(SRCS_client ${xml_FILE})
|
||||
|
||||
NGL_ADD_LIBRARY(AAR SV WS svcEvlClient SHARED ${SRCS_client})
|
||||
NGL_TARGET_INCLUDE_DIRECTORIES(svcEvlClient
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
)
|
||||
|
||||
NGL_TARGET_LINK_LIBRARIES(svcEvlClient
|
||||
PRIVATE
|
||||
RTI::nddscpp2
|
||||
ddsconnector
|
||||
PUBLIC
|
||||
svcEvlCommon
|
||||
ddsftc
|
||||
)
|
||||
NGL_INSTALL_TARGET(svcEvlClient)
|
||||
|
||||
#
|
||||
# --- Library svcEvlServer --------------------------------------------------------------------------------
|
||||
#
|
||||
SET(SRCS_server
|
||||
evl_export.h
|
||||
|
||||
initialization.cpp
|
||||
initialization.h
|
||||
dds_handler.cpp
|
||||
dds_handler.h
|
||||
object_criterium.cpp
|
||||
object_criterium.h
|
||||
object_evaluation_element.cpp
|
||||
object_evaluation_element.h
|
||||
handler_criterium.cpp
|
||||
handler_criterium.h
|
||||
|
||||
handler_comment.cpp
|
||||
handler_comment.h
|
||||
object_comment.cpp
|
||||
object_comment.h
|
||||
|
||||
handler_san_nine_liner.cpp
|
||||
handler_san_nine_liner.h
|
||||
object_san_nine_liner.cpp
|
||||
object_san_nine_liner.h
|
||||
object_san_category_line.cpp
|
||||
object_san_category_line.h
|
||||
|
||||
settings.cpp
|
||||
settings.h
|
||||
${xml_FILE}
|
||||
)
|
||||
|
||||
# generate evl_[d|f]ts.h, evl_[d|f]ts_impl.[cpp|h]
|
||||
CODEGEN_SERVER_TOPICS(SRCS_server ${xml_FILE})
|
||||
# Generate evl.sql, evl.xml
|
||||
CODEGEN_SQL(SRCS_server ${xml_FILE})
|
||||
|
||||
NGL_ADD_LIBRARY(AAR SV svcEvlServer SHARED ${SRCS_server})
|
||||
NGL_TARGET_INCLUDE_DIRECTORIES(svcEvlServer
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
)
|
||||
|
||||
NGL_TARGET_LINK_LIBRARIES(svcEvlServer
|
||||
PRIVATE
|
||||
RTI::nddscpp2
|
||||
ddsconnector
|
||||
ddsfts
|
||||
PUBLIC
|
||||
svcEvlCommon
|
||||
ddsconnector
|
||||
nglsettings
|
||||
ngldb
|
||||
ProjectConfig
|
||||
NGLLogger
|
||||
ngltools
|
||||
LtsCoordTrans
|
||||
)
|
||||
NGL_INSTALL_TARGET(svcEvlServer)
|
||||
|
||||
#
|
||||
# --- Topic Type Plugin --------------------------------------------------------------
|
||||
#
|
||||
CREATE_TOPIC_TYPE_PLUGIN(${xml_FILE})
|
||||
|
||||
# Uncomment if necessary
|
||||
#ADD_SUBDIRECTORY(UnitTests)
|
||||
ADD_SUBDIRECTORY(ModuleTests)
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
|
||||
SET(SRCS_MRK_TEST
|
||||
evl_tests.cpp
|
||||
)
|
||||
SET(HDRS_MRK_TEST
|
||||
evl_tests.h
|
||||
)
|
||||
|
||||
IF(BUILD_TESTING)
|
||||
IF(TARGET svcEvlClient)
|
||||
|
||||
# Testing FunctionTopic Functionality (FTC)
|
||||
ADD_EXECUTABLE(evlTests ${SRCS_MRK_TEST} ${HDRS_MRK_TEST})
|
||||
TARGET_LINK_LIBRARIES(evlTests
|
||||
Qt5::Core
|
||||
Qt5::Test
|
||||
RTI::nddscpp2
|
||||
svcEvlClient
|
||||
LtsCommandLineParser
|
||||
ddsconnector
|
||||
nglcoreapplication
|
||||
)
|
||||
IF(NOT BUILD_RPM)
|
||||
NGL_INSTALL(AAR SV TARGETS evlTests DESTINATION bin/test)
|
||||
# NGL_INSTALL(AAR SV FILES ../log4cxx_evl.props DESTINATION bin/test)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
+867
@@ -0,0 +1,867 @@
|
||||
/**
|
||||
* Evl Function Topic test executable
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-04-18
|
||||
*/
|
||||
#include "evl_tests.h"
|
||||
|
||||
#include <nglapplication/nglcoreapplication.h>
|
||||
#include <LtsCommandLineParser/LtsCommandLineParser.h>
|
||||
#include <QTimer>
|
||||
#include <QDateTime>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
#include <QTest>
|
||||
|
||||
#include <Evaluations/evl_ftc.h>
|
||||
#include <Evaluations/evl_dtc.h>
|
||||
|
||||
#include "Evaluations/san_category_line_json.h"
|
||||
|
||||
using namespace Evaluations;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
EvlTests::EvlTests(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_logger(getLogger("EvlTests"))
|
||||
{
|
||||
qRegisterMetaType<Core::FunctionReply>("Core::FunctionReply");
|
||||
|
||||
// connect(m_dtc.get(), &Interface::Dtc::evaluationCriteriumChanged,
|
||||
// this, &EvlTests::onReceiveCriteriumChanged, Qt::UniqueConnection);
|
||||
|
||||
} // end of ctor()
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool EvlTests::init(int domainId, int exerciseId, int testId, int operatorId, int criteriumId, int elementId, int sanNineLinerId)
|
||||
{
|
||||
INFO_LOG(m_logger) << "EvlTests::init() "
|
||||
<< " domainId:" << domainId
|
||||
<< " exerciseId:" << exerciseId
|
||||
<< " testId: " << testId
|
||||
<< " criteriumId: " << criteriumId
|
||||
<< " sanNineLinerId: " << sanNineLinerId;
|
||||
|
||||
m_testId = testId;
|
||||
m_exerciseId = exerciseId;
|
||||
m_criteriumId = criteriumId;
|
||||
m_elementId = elementId;
|
||||
m_operatorId = operatorId;
|
||||
m_sanNineLinerId = sanNineLinerId;
|
||||
|
||||
DEBUG_LOG(m_logger) << "Operator Id = " << m_operatorId;
|
||||
|
||||
// initialize DDS
|
||||
m_ddsConnector.reset(new DDSConnector::DdsConnector(domainId, IDL::PartitionType::Exercise, exerciseId));
|
||||
if (!m_ddsConnector->init())
|
||||
return false;
|
||||
m_ddsConnector->initPublisherSubscriber();
|
||||
|
||||
// Access to FTC
|
||||
DEBUG_LOG(m_logger) << "create ftc";
|
||||
m_ftc = Evaluations::Interface::Ftc::create(m_ddsConnector);
|
||||
DEBUG_LOG(m_logger) << "init ftc";
|
||||
bool bRet = m_ftc->enableAll();
|
||||
DEBUG_LOG(m_logger) << "init end - bRet = " << bRet;
|
||||
|
||||
// Access to DTC
|
||||
DEBUG_LOG(m_logger) << "create dtc";
|
||||
m_dtc = Evaluations::Interface::Dtc::create(m_ddsConnector);
|
||||
DEBUG_LOG(m_logger) << "init dtc";
|
||||
bRet = m_dtc->enableAll();
|
||||
DEBUG_LOG(m_logger) << "init end - bRet = " << bRet;
|
||||
|
||||
return bRet;
|
||||
} // end of init()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void EvlTests::startTest()
|
||||
{
|
||||
INFO_LOG(m_logger) << "startTest() ******* "
|
||||
<< " exerciseId: " << m_exerciseId
|
||||
<< " testId: " << m_testId
|
||||
<< " criteriumId: " << m_criteriumId
|
||||
<< " operatorId: " << m_operatorId;
|
||||
|
||||
if (m_testId <= 1)
|
||||
QTimer::singleShot(0, this, &EvlTests::tryCreateCriterium);
|
||||
else if (m_testId == 2)
|
||||
QTimer::singleShot(0, this, &EvlTests::tryModifyCriterium);
|
||||
else if (m_testId == 3)
|
||||
QTimer::singleShot(0, this, &EvlTests::tryRemoveCriterium);
|
||||
else if (m_testId == 4)
|
||||
QTimer::singleShot(0, this, &EvlTests::tryCreateElement);
|
||||
else if (m_testId == 5)
|
||||
QTimer::singleShot(0, this, &EvlTests::tryModifyElement);
|
||||
else if (m_testId == 6)
|
||||
QTimer::singleShot(0, this, &EvlTests::tryRemoveElement);
|
||||
|
||||
else if (m_testId == 7)
|
||||
QTimer::singleShot(0, this, &EvlTests::tryCreateSanNineLiner);
|
||||
else if (m_testId == 8)
|
||||
QTimer::singleShot(0, this, &EvlTests::tryModifySanNineLiner);
|
||||
else if (m_testId == 9)
|
||||
QTimer::singleShot(0, this, &EvlTests::tryRemoveSanNineLiner);
|
||||
|
||||
|
||||
else if (m_testId == 10)
|
||||
QTimer::singleShot(0, this, &EvlTests::tryGetAllCriteria);
|
||||
else if (m_testId == 11)
|
||||
QTimer::singleShot(0, this, &EvlTests::tryGetCriterium);
|
||||
else if (m_testId == 12)
|
||||
QTimer::singleShot(0, this, &EvlTests::tryGetSanNineLiner);
|
||||
else
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Unknown test case !";
|
||||
failExit();
|
||||
}
|
||||
INFO_LOG(m_logger) << "endTest ******* ";
|
||||
QTimer::singleShot(0, qApp, QCoreApplication::quit);
|
||||
|
||||
} // end of startTest()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void EvlTests::tryCreateCriterium()
|
||||
{
|
||||
m_eTestStep = eCreateCriterium;
|
||||
EvlCriteriumModifyRequest data;
|
||||
|
||||
data.id(0); // id = 0 -> Create request
|
||||
data.name("Test Criterium");
|
||||
data.description("Test description");
|
||||
data.operatorId(m_operatorId);
|
||||
|
||||
INFO_LOG(m_logger) << "trying to send EvlCriteriumModifyRequest";
|
||||
if (!m_ftc->evlCriteriumModifyRequest(data, this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting create data";
|
||||
failExit();
|
||||
}
|
||||
QTest::qWait(1000);
|
||||
} // end of tryCreateCriterium()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void EvlTests::tryModifyCriterium()
|
||||
{
|
||||
m_eTestStep = eModifyCriterium;
|
||||
EvlCriteriumModifyRequest data;
|
||||
|
||||
data.id(m_criteriumId);
|
||||
data.name("Name criterium modified");
|
||||
data.description("Description modified");
|
||||
data.operatorId(m_operatorId);
|
||||
|
||||
INFO_LOG(m_logger) << "trying to send EvlCriteriumModifyRequest for criteriumId:" << data.id();
|
||||
if (!m_ftc->evlCriteriumModifyRequest(data, this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting modify data for criteriumId:" << data.id();
|
||||
failExit();
|
||||
}
|
||||
QTest::qWait(1000);
|
||||
} // end of tryModifyCriterium()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void EvlTests::tryRemoveCriterium()
|
||||
{
|
||||
m_eTestStep = eRemoveCriterium;
|
||||
EvlCriteriumRemoveRequest data;
|
||||
|
||||
data.id(m_criteriumId);
|
||||
|
||||
INFO_LOG(m_logger) << "trying to send remove request for criteriumId:" << data.id();
|
||||
if (!m_ftc->evlCriteriumRemoveRequest(data, this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting remove data for criteriumId:" << data.id();
|
||||
failExit();
|
||||
}
|
||||
QTest::qWait(1000);
|
||||
} // end of tryRemoveCriterum()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void EvlTests::tryGetAllCriteria()
|
||||
{
|
||||
m_eTestStep = eGetAllCriteria;
|
||||
DEBUG_LOG(m_logger) << "trying to get all criteria";
|
||||
|
||||
m_dtc->waitForHistoricalDataEvaluationCriterium(5000);
|
||||
m_criteriumId = -1;
|
||||
auto cb = [this] (const Evaluations::EvaluationCriterium &c)
|
||||
{
|
||||
m_criteriumId = c.id();
|
||||
INFO_LOG(m_logger) << "Evl(" << c.id() << ") :"
|
||||
<< " name:" << c.name()
|
||||
<< " desc:" << c.description()
|
||||
<< " operatorId:" << c.operatorId();
|
||||
};
|
||||
m_dtc->evaluationCriteriums(cb);
|
||||
if (m_criteriumId == -1)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting all criterium data";
|
||||
failExit();
|
||||
}
|
||||
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
||||
} // end of tryGetAllCriteria()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void EvlTests::tryGetCriterium()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "trying to get criterium with id:" << m_criteriumId;
|
||||
|
||||
if(m_testId > 1)
|
||||
{
|
||||
m_eTestStep = eGetCriterium;
|
||||
}
|
||||
|
||||
if (m_criteriumId <= 0)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "invalid criteriumId - test aborted.";
|
||||
failExit();
|
||||
}
|
||||
|
||||
m_dtc->waitForHistoricalDataEvaluationCriterium(5000);
|
||||
Evaluations::EvaluationCriterium data = m_dtc->evaluationCriterium(m_criteriumId);
|
||||
|
||||
if (data.id() <= 0)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error receiving data for criteriumId " << m_criteriumId << " returnVal: " << data.id();
|
||||
failExit();
|
||||
}
|
||||
else
|
||||
{
|
||||
INFO_LOG(m_logger) << "Evl(" << data.id() << ") :"
|
||||
<< " name:" << data.name()
|
||||
<< " desc:" << data.description()
|
||||
<< " operatorId:" << data.operatorId();
|
||||
}
|
||||
|
||||
if (m_testId == 0)
|
||||
{
|
||||
if (!onCompareCreatedData(data))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Compare created data failed!";
|
||||
failExit();
|
||||
}
|
||||
else
|
||||
{
|
||||
QTimer::singleShot(0, this, &EvlTests::tryModifyCriterium);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
QTimer::singleShot(0, qApp, QCoreApplication::quit);
|
||||
|
||||
} // end of tryGetCriterium()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void EvlTests::tryCreateElement()
|
||||
{
|
||||
m_eTestStep = eCreateElement;
|
||||
EvlElementModifyRequest data;
|
||||
|
||||
data.id(0);
|
||||
data.criteriumId(m_criteriumId);
|
||||
data.timestamp(QDateTime::currentMSecsSinceEpoch());
|
||||
data.note("Test test test");
|
||||
data.phaseId(1);
|
||||
data.rating(10);
|
||||
|
||||
QJsonObject obj;
|
||||
obj[QStringLiteral("actualStream")] = QJsonValue(QStringLiteral("av_0011"));
|
||||
obj[QStringLiteral("allStreams")] = QJsonValue(QStringLiteral("av_0011, av_0012, av_0013"));
|
||||
data.videoContent().set(QJsonDocument(obj).toJson().constData());
|
||||
|
||||
obj[QStringLiteral("actualStream")] = QJsonValue(QStringLiteral("vhf01"));
|
||||
obj[QStringLiteral("allStreams")] = QJsonValue(QStringLiteral("vhf01, hf01, hf02, vhf03"));
|
||||
data.audioContent().set(QJsonDocument(obj).toJson().constData());
|
||||
|
||||
INFO_LOG(m_logger) << "trying to send evlElementModifyRequest";
|
||||
if (!m_ftc->evlElementModifyRequest(data, this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting create data";
|
||||
failExit();
|
||||
}
|
||||
QTest::qWait(1000);
|
||||
} // end of tryCreateElement()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void EvlTests::tryModifyElement()
|
||||
{
|
||||
m_eTestStep = eModifyElement;
|
||||
EvlElementModifyRequest data;
|
||||
|
||||
data.id(m_elementId);
|
||||
data.criteriumId(m_criteriumId);
|
||||
data.timestamp(QDateTime::currentMSecsSinceEpoch());
|
||||
data.note("Test1 test2 test3");
|
||||
data.phaseId(2);
|
||||
data.rating(5);
|
||||
|
||||
QJsonObject obj;
|
||||
obj[QStringLiteral("actualStream")] = QJsonValue(QStringLiteral("av_0013"));
|
||||
obj[QStringLiteral("allStreams")] = QJsonValue(QStringLiteral("av_0011, av_0012, av_0013"));
|
||||
data.videoContent().set(QJsonDocument(obj).toJson().constData());
|
||||
|
||||
obj[QStringLiteral("actualStream")] = QJsonValue(QStringLiteral("hf01"));
|
||||
obj[QStringLiteral("allStreams")] = QJsonValue(QStringLiteral("vhf01, hf01, hf02, vhf03"));
|
||||
data.audioContent().set(QJsonDocument(obj).toJson().constData());
|
||||
|
||||
INFO_LOG(m_logger) << "trying to send evlElementModifyRequest for elementId:" << data.id();
|
||||
if (!m_ftc->evlElementModifyRequest(data, this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting modify data for snapshotId:" << data.id();
|
||||
failExit();
|
||||
}
|
||||
QTest::qWait(1000);
|
||||
} // end of tryModifyElement()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void EvlTests::tryRemoveElement()
|
||||
{
|
||||
m_eTestStep = eRemoveElement;
|
||||
EvlElementRemoveRequest data;
|
||||
|
||||
data.id(m_elementId);
|
||||
data.criteriumId(m_criteriumId);
|
||||
|
||||
INFO_LOG(m_logger) << "trying to send remove request for elementId:" << data.id();
|
||||
if (!m_ftc->evlElementRemoveRequest(data, this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting remove data for elementId:" << data.id();
|
||||
failExit();
|
||||
}
|
||||
QTest::qWait(1000);
|
||||
} // end of tryRemoveElement()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void EvlTests::tryCreateSanNineLiner()
|
||||
{
|
||||
m_eTestStep = eCreateSanNineLiner;
|
||||
SanNineLinerModifyRequest data;
|
||||
|
||||
data.id(0);
|
||||
data.lastModified(QDateTime::currentMSecsSinceEpoch());
|
||||
data.line1_position(Core::GeoPosition2D(0.100000, 0.2450000));
|
||||
data.line2_radioFrequencyCallSignSuffix("32.00 FM, Troublemaker");
|
||||
|
||||
Database::SanCategoryLine cl;
|
||||
std::vector<Database::SanCategoryLine> vecCl;
|
||||
|
||||
cl.line = 3;
|
||||
cl.amount = 1;
|
||||
cl.category = QStringLiteral("A");
|
||||
vecCl.push_back(std::move(cl));
|
||||
|
||||
cl.amount = 2;
|
||||
cl.category = QStringLiteral("B");
|
||||
vecCl.push_back(std::move(cl));
|
||||
|
||||
cl.amount = 1;
|
||||
cl.category = QStringLiteral("D");
|
||||
vecCl.push_back(std::move(cl));
|
||||
|
||||
cl.line = 4;
|
||||
cl.amount = 2;
|
||||
cl.category = QStringLiteral("D");
|
||||
vecCl.push_back(std::move(cl));
|
||||
|
||||
cl.line = 5;
|
||||
cl.amount = 2;
|
||||
cl.category = QStringLiteral("A");
|
||||
vecCl.push_back(std::move(cl));
|
||||
|
||||
cl.amount = 3;
|
||||
cl.category = QStringLiteral("B");
|
||||
vecCl.push_back(std::move(cl));
|
||||
|
||||
cl.line = 6;
|
||||
cl.category = QStringLiteral("D");
|
||||
vecCl.push_back(std::move(cl));
|
||||
|
||||
cl.line = 7;
|
||||
cl.category = QStringLiteral("C");
|
||||
vecCl.push_back(std::move(cl));
|
||||
|
||||
cl.line = 8;
|
||||
cl.amount = 2;
|
||||
cl.category = QStringLiteral("A");
|
||||
vecCl.push_back(std::move(cl));
|
||||
|
||||
cl.amount = 3;
|
||||
cl.category = QStringLiteral("C");
|
||||
vecCl.push_back(std::move(cl));
|
||||
|
||||
cl.line = 9;
|
||||
cl.category = QStringLiteral("None");
|
||||
vecCl.push_back(std::move(cl));
|
||||
|
||||
QJsonDocument doc = SanCategoryLine::toJson(vecCl);
|
||||
data.lines(doc.toJson().toStdString());
|
||||
|
||||
INFO_LOG(m_logger) << "lines: " << data.lines();
|
||||
|
||||
INFO_LOG(m_logger) << "trying to send sanNineLinerRequest";
|
||||
if (!m_ftc->sanNineLinerModifyRequest(data, this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting create data";
|
||||
failExit();
|
||||
}
|
||||
QTest::qWait(1000);
|
||||
} // end of tryCreateElement()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void EvlTests::tryModifySanNineLiner()
|
||||
{
|
||||
m_eTestStep = eModifySanNineLiner;
|
||||
SanNineLinerModifyRequest data;
|
||||
|
||||
data.id(m_sanNineLinerId);
|
||||
data.lastModified(QDateTime::currentMSecsSinceEpoch());
|
||||
data.line1_position(Core::GeoPosition2D(0.200000, 0.4560000));
|
||||
data.line2_radioFrequencyCallSignSuffix("39.000 FM, Troublemaker");
|
||||
|
||||
Database::SanCategoryLine cl;
|
||||
std::vector<Database::SanCategoryLine> vecCl;
|
||||
|
||||
cl.line = 3;
|
||||
cl.amount = 2;
|
||||
cl.category = QStringLiteral("A");
|
||||
vecCl.push_back(std::move(cl));
|
||||
|
||||
cl.amount = 1;
|
||||
cl.category = QStringLiteral("B");
|
||||
vecCl.push_back(std::move(cl));
|
||||
|
||||
|
||||
cl.line = 4;
|
||||
cl.amount = 1;
|
||||
cl.category = QStringLiteral("A");
|
||||
vecCl.push_back(std::move(cl));
|
||||
|
||||
cl.line = 5;
|
||||
cl.amount = 1;
|
||||
cl.category = QStringLiteral("A");
|
||||
vecCl.push_back(std::move(cl));
|
||||
|
||||
cl.amount = 1;
|
||||
cl.category = QStringLiteral("B");
|
||||
vecCl.push_back(std::move(cl));
|
||||
|
||||
cl.line = 6;
|
||||
cl.amount = 0;
|
||||
cl.category = QStringLiteral("D");
|
||||
vecCl.push_back(std::move(cl));
|
||||
|
||||
cl.line = 7;
|
||||
cl.category = QStringLiteral("C");
|
||||
vecCl.push_back(std::move(cl));
|
||||
|
||||
cl.line = 8;
|
||||
cl.amount = 1;
|
||||
cl.category = QStringLiteral("A");
|
||||
vecCl.push_back(std::move(cl));
|
||||
|
||||
cl.amount = 1;
|
||||
cl.category = QStringLiteral("C");
|
||||
vecCl.push_back(std::move(cl));
|
||||
|
||||
cl.line = 9;
|
||||
cl.amount = 0;
|
||||
cl.category = QStringLiteral("None");
|
||||
vecCl.push_back(std::move(cl));
|
||||
|
||||
QJsonDocument doc = SanCategoryLine::toJson(vecCl);
|
||||
data.lines(doc.toJson().toStdString());
|
||||
|
||||
INFO_LOG(m_logger) << "lines: " << data.lines();
|
||||
|
||||
INFO_LOG(m_logger) << "trying to send sanNineLinerRequest";
|
||||
if (!m_ftc->sanNineLinerModifyRequest(data, this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting modify data";
|
||||
failExit();
|
||||
}
|
||||
QTest::qWait(1000);
|
||||
} // end of tryModifySanNineLiner()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void EvlTests::tryRemoveSanNineLiner()
|
||||
{
|
||||
m_eTestStep = eRemoveSanNineLiner;
|
||||
EvlCriteriumRemoveRequest data;
|
||||
|
||||
data.id(m_sanNineLinerId);
|
||||
|
||||
INFO_LOG(m_logger) << "trying to send remove request for sanNineLinerId:" << data.id();
|
||||
if (!m_ftc->sanNineLinerRemoveRequest(data, this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting remove data for sanNineLinerId:" << data.id();
|
||||
failExit();
|
||||
}
|
||||
QTest::qWait(1000);
|
||||
} // end of tryRemoveSanNineLiner()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void EvlTests::tryGetSanNineLiner()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "trying to get sanNineLinerId with id:" << m_sanNineLinerId;
|
||||
|
||||
if(m_testId > 1)
|
||||
{
|
||||
m_eTestStep = eGetSanNineLiner;
|
||||
}
|
||||
|
||||
if (m_sanNineLinerId <= 0)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "invalid sanNineLinerId - test aborted.";
|
||||
failExit();
|
||||
}
|
||||
|
||||
m_dtc->waitForHistoricalDataSanNineLiner(5000);
|
||||
Evaluations::SanNineLiner data = m_dtc->sanNineLiner(m_sanNineLinerId);
|
||||
|
||||
if (data.id() <= 0)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error receiving data for sanNineLiner " << m_sanNineLinerId << " returnVal: " << data.id();
|
||||
failExit();
|
||||
}
|
||||
else
|
||||
{
|
||||
INFO_LOG(m_logger) << "SanNineLiner(" << data.id() << ") :"
|
||||
<< " lastModified: " << data.lastModified()
|
||||
<< " position lat: " << data.line1_position().lat()
|
||||
<< " position lon: " << data.line1_position().lon()
|
||||
<< " radiofreq, CallSign: " << data.line2_RadioFrequencyCallSignSuffix()
|
||||
<< " lines: " << data.lines();
|
||||
|
||||
}
|
||||
|
||||
if (m_testId == 0)
|
||||
{
|
||||
if (!onCompareCreatedData(data))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Compare created data failed!";
|
||||
failExit();
|
||||
}
|
||||
else
|
||||
{
|
||||
QTimer::singleShot(0, this, &EvlTests::tryModifySanNineLiner);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
QTimer::singleShot(0, qApp, QCoreApplication::quit);
|
||||
|
||||
} // end of tryGetSanNineLiner()
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void EvlTests::onEvlCriteriumModifyReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
INFO_LOG(m_logger) << "Got onEvlCriteriumModifyReply with id " << replyObject.id()
|
||||
<< " and errorString " << replyObject.translated();
|
||||
|
||||
m_criteriumId = replyObject.id();
|
||||
|
||||
if (replyObject.error())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting create data";
|
||||
failExit();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Requesting create data ok. Got new id:" << replyObject.id() << " ... ok.";
|
||||
}
|
||||
|
||||
QTimer::singleShot(0, this, &EvlTests::tryGetCriterium);
|
||||
} // end of onEvlCriteriumModifyReply()
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void EvlTests::onEvlCriteriumRemoveReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
INFO_LOG(m_logger) << "Got removeReply with id " << replyObject.id()
|
||||
<< " and errorString " << replyObject.translated();
|
||||
|
||||
if (replyObject.error())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting remove data for criteriumId:" << replyObject.id();
|
||||
failExit();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Requesting remove data for criteriumd:" << replyObject.id() << " ... ok.";
|
||||
}
|
||||
|
||||
QTimer::singleShot(0, qApp, QCoreApplication::quit);
|
||||
|
||||
} // end of onEvlCriteriumRemoveReply()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void EvlTests::onEvlElementModifyReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
INFO_LOG(m_logger) << "Got modifyReply with id " << replyObject.id()
|
||||
<< " and errorString " << replyObject.translated();
|
||||
|
||||
m_elementId = replyObject.id();
|
||||
|
||||
if (replyObject.error())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting modify data";
|
||||
failExit();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Requesting modify data ok. Got id:" << replyObject.id() << " ... ok.";
|
||||
}
|
||||
|
||||
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
||||
|
||||
} // end of onEvlElementModifyReply()
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void EvlTests::onEvlElementRemoveReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
INFO_LOG(m_logger) << "Got removeReply with id " << replyObject.id()
|
||||
<< " and errorString " << replyObject.translated();
|
||||
|
||||
if (replyObject.error())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting remove data for elementId:" << replyObject.id();
|
||||
failExit();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Requesting remove data for elementId:" << replyObject.id() << " ... ok.";
|
||||
}
|
||||
|
||||
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
||||
|
||||
} // end of onEvlElementRemoveReplyF()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void EvlTests::onSanNineLinerModifyReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
INFO_LOG(m_logger) << "Got onSanNineLinerModifyReply with id " << replyObject.id()
|
||||
<< " and errorString " << replyObject.translated();
|
||||
|
||||
m_sanNineLinerId = replyObject.id();
|
||||
|
||||
if (replyObject.error())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting create data";
|
||||
failExit();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Requesting create data ok. Got new id:" << replyObject.id() << " ... ok.";
|
||||
}
|
||||
|
||||
QTimer::singleShot(0, this, &EvlTests::tryGetSanNineLiner);
|
||||
} // end of onSanNineLinerModifyReply()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void EvlTests::onSanNineLinerRemoveReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
INFO_LOG(m_logger) << "Got removeReply with id " << replyObject.id()
|
||||
<< " and errorString " << replyObject.translated();
|
||||
|
||||
if (replyObject.error())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting remove data for sanNineLinerId:" << replyObject.id();
|
||||
failExit();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Requesting remove data for sanNineLinerId:" << replyObject.id() << " ... ok.";
|
||||
}
|
||||
|
||||
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
||||
|
||||
} // end of onEvlElemonEvlElementRemoveReply()
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void EvlTests::onReceiveCriteriumChanged(const EvaluationCriterium &data, DataModification modType)
|
||||
{
|
||||
INFO_LOG(m_logger) << "onReceiveCriteriumChanged() criteriumId:" << data.id()
|
||||
<< " modificationType: = " << (int)modType<< " received";
|
||||
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
INFO_LOG(m_logger) << "*** Criterium added received. criteriumId:" << data.id();
|
||||
break;
|
||||
|
||||
case DataModification::eModified:
|
||||
INFO_LOG(m_logger) << "*** Criterium modified received. criteriumId:" << data.id();
|
||||
break;
|
||||
|
||||
case DataModification::eRemoved:
|
||||
INFO_LOG(m_logger) << "*** Criterium removed received. criteriumId:" << data.id();
|
||||
break;
|
||||
}
|
||||
|
||||
} // end of onReceiveCriteriumChanged()
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void EvlTests::getCriteriumModifyRequestData(EvlCriteriumModifyRequest &data)
|
||||
{
|
||||
data.name("Name criterium modified");
|
||||
data.description("Description modified");
|
||||
data.operatorId(m_operatorId);
|
||||
|
||||
} // end of getCriteriumModifyRequestData()
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void EvlTests::getSanNineLinerModifyRequestData(SanNineLinerModifyRequest &data)
|
||||
{
|
||||
data.line1_position(Core::GeoPosition2D(0.200000, 0.4560000));
|
||||
data.line2_radioFrequencyCallSignSuffix("39.000 FM, Troublemaker");
|
||||
} // end of getNineLinerModifyRequestData()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool EvlTests::onCompareCreatedData(EvaluationCriterium &data)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "start onCompareCreatedData() for id :" << data.id();
|
||||
|
||||
// Vergleicht die zurueckgelesen Datan mit den statischen create Daten
|
||||
|
||||
EvlCriteriumModifyRequest createData;
|
||||
|
||||
getCriteriumModifyRequestData(createData);
|
||||
|
||||
if (createData.name() != data.name())
|
||||
return false;
|
||||
|
||||
if (createData.operatorId() != data.operatorId())
|
||||
return false;
|
||||
|
||||
if (createData.description() != data.description())
|
||||
return false;
|
||||
|
||||
|
||||
DEBUG_LOG(m_logger) << "successfully finished onCompareCreatedData() for id :" << data.id();
|
||||
|
||||
return true;
|
||||
} // end of onCompareCreatedData()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool EvlTests::onCompareCreatedData(SanNineLiner &data)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "start onCompareCreatedData() for id :" << data.id();
|
||||
|
||||
SanNineLinerModifyRequest createData;
|
||||
|
||||
getSanNineLinerModifyRequestData(createData);
|
||||
|
||||
if (createData.line1_position() != data.line1_position())
|
||||
return false;
|
||||
|
||||
if (createData.line2_radioFrequencyCallSignSuffix() != data.line2_RadioFrequencyCallSignSuffix())
|
||||
return false;
|
||||
|
||||
DEBUG_LOG(m_logger) << "successfully finished onCompareCreatedData() for id :" << data.id();
|
||||
|
||||
return true;
|
||||
} // end of onCompareCreatedData()
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void EvlTests::failExit()
|
||||
{
|
||||
m_bTestsSuccessful = false;
|
||||
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
class CmdLineParser : public LtsCommandLineParser::LtsCommandLineParser
|
||||
{
|
||||
public:
|
||||
CmdLineParser()
|
||||
: LtsCommandLineParser()
|
||||
{
|
||||
addOption( { QStringList() << QLatin1String("t") << QLatin1String("testId")
|
||||
, QLatin1String("TestId.")
|
||||
, QLatin1String("Default: 0 (all FTC/DTC tests), 1 create, 2 modify, 3 remove, 10 getAllCriteria, 11 getCriterium")
|
||||
, QLatin1String("0")
|
||||
} );
|
||||
|
||||
addOption( { QStringList() << QLatin1String("o") << QLatin1String("operatorId")
|
||||
, QLatin1String("OperatorId.")
|
||||
, QLatin1String("Used in tests 1, 2.")
|
||||
, QLatin1String("0")
|
||||
} );
|
||||
|
||||
addOption( { QStringList() << QLatin1String("c") << QLatin1String("criteriumId")
|
||||
, QLatin1String("CriteriumId.")
|
||||
, QLatin1String("Used for tests 2, 3, 4, 5, 6 & 11 only to select the criterium")
|
||||
, QLatin1String("0")
|
||||
} );
|
||||
|
||||
addOption( { QStringList() << QLatin1String("l") << QLatin1String("elementId")
|
||||
, QLatin1String("ElementId.")
|
||||
, QLatin1String("Used for tests 4, 5 & 6 only to select the elementId")
|
||||
, QLatin1String("0")
|
||||
} );
|
||||
addOption( { QStringList() << QLatin1String("s") << QLatin1String("sanNineLinerId")
|
||||
, QLatin1String("SanNineLinerId.")
|
||||
, QLatin1String("Used for tests 7, 8 & 9 only to select the sanNineLinerId")
|
||||
, QLatin1String("0")
|
||||
} );
|
||||
}
|
||||
|
||||
int testId() const { return isSet(QLatin1String("t")) ? value(QLatin1String("t")).toInt() : -1; }
|
||||
int operatorId() const { return isSet(QLatin1String("o")) ? value(QLatin1String("o")).toInt() : -1; }
|
||||
int criteriumId() const { return isSet(QLatin1String("c")) ? value(QLatin1String("c")).toInt() : -1; }
|
||||
int elementId() const { return isSet(QLatin1String("l")) ? value(QLatin1String("l")).toInt() : -1; }
|
||||
int sanNineLinerId() const { return isSet(QLatin1String("s")) ? value(QLatin1String("s")).toInt() : -1; }
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
NGLCoreApplication app(argc, argv);
|
||||
|
||||
int iRet = -1;
|
||||
CmdLineParser options;
|
||||
if (!options.init())
|
||||
return iRet;
|
||||
|
||||
app.createLogger("EVL", options.exerciseId());
|
||||
|
||||
std::unique_ptr<Evaluations::EvlTests> EvlTests(new Evaluations::EvlTests);
|
||||
if(!EvlTests->init(options.domainId(), options.exerciseId(), options.testId(), options.operatorId(), options.criteriumId(), options.elementId(), options.sanNineLinerId() ))
|
||||
return iRet;
|
||||
|
||||
QTimer::singleShot(2000, EvlTests.get(), &Evaluations::EvlTests::startTest);
|
||||
|
||||
STARTUP_LOG(app.baseLogger());
|
||||
|
||||
app.exec();
|
||||
|
||||
iRet = EvlTests->testsSuccessful() ? 0 : 1;
|
||||
fprintf(stderr, "%d\n", iRet);
|
||||
|
||||
DEBUG_LOG(app.baseLogger()) << "** TEST result = " << iRet;
|
||||
|
||||
SHUTDOWN_LOG(app.baseLogger());
|
||||
|
||||
return iRet;
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
+129
@@ -0,0 +1,129 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
*
|
||||
* EXM Function Topic test executable
|
||||
*
|
||||
* ModuleTests for create/modify/remove marker
|
||||
* ---------------------------------------------------
|
||||
* Client FTC is implemented
|
||||
*
|
||||
* => (!) Preconditon:
|
||||
* - Service svcMarkerManagent running
|
||||
*
|
||||
* -------------------------------------------------
|
||||
*
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-04-18
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Evaluations/evl_ftc.h>
|
||||
#include <Evaluations/evl_ftc_types.h>
|
||||
#include <Evaluations/evl_dtc.h>
|
||||
#include <Evaluations/evl_dtc_types.h>
|
||||
#include <Evaluations/logger.h>
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
|
||||
namespace Evaluations
|
||||
{
|
||||
class EvlTests : public QObject
|
||||
, protected Evaluations::Interface::Ftc::EvlCriteriumModifyReplyHandler
|
||||
, protected Evaluations::Interface::Ftc::EvlCriteriumRemoveReplyHandler
|
||||
, protected Evaluations::Interface::Ftc::EvlElementModifyReplyHandler
|
||||
, protected Evaluations::Interface::Ftc::EvlElementRemoveReplyHandler
|
||||
, protected Evaluations::Interface::Ftc::SanNineLinerModifyReplyHandler
|
||||
, protected Evaluations::Interface::Ftc::SanNineLinerRemoveReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit EvlTests(QObject *parent = nullptr);
|
||||
~EvlTests() = default;
|
||||
|
||||
bool init(int domainId, int exerciseId, int testId, int operatorId, int criteriumId, int elementId, int sanNineLinerId);
|
||||
bool testsSuccessful() const { return m_bTestsSuccessful; }
|
||||
|
||||
public Q_SLOTS:
|
||||
void startTest();
|
||||
|
||||
protected Q_SLOTS:
|
||||
// used to check FTC
|
||||
void tryCreateCriterium();
|
||||
void tryModifyCriterium();
|
||||
void tryRemoveCriterium();
|
||||
|
||||
void tryCreateElement();
|
||||
void tryModifyElement();
|
||||
void tryRemoveElement();
|
||||
|
||||
// used to check DTC
|
||||
void tryGetAllCriteria();
|
||||
void tryGetCriterium();
|
||||
void tryGetSanNineLiner();
|
||||
|
||||
void tryCreateSanNineLiner();
|
||||
void tryModifySanNineLiner();
|
||||
void tryRemoveSanNineLiner();
|
||||
|
||||
// used to check DTC signal/slot connection
|
||||
void onReceiveCriteriumChanged(const EvaluationCriterium &data, DataModification modType);
|
||||
|
||||
protected:
|
||||
// Callbackfunctions for FTC
|
||||
void onEvlCriteriumModifyReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
void onEvlCriteriumRemoveReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
|
||||
void onEvlElementModifyReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
void onEvlElementRemoveReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
|
||||
void onSanNineLinerModifyReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
void onSanNineLinerRemoveReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
|
||||
private Q_SLOTS:
|
||||
bool onCompareCreatedData(EvaluationCriterium &data);
|
||||
bool onCompareCreatedData(SanNineLiner &data);
|
||||
|
||||
private:
|
||||
void getCriteriumModifyRequestData(EvlCriteriumModifyRequest &data);
|
||||
void getSanNineLinerModifyRequestData(SanNineLinerModifyRequest &data);
|
||||
void failExit();
|
||||
|
||||
private:
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
std::shared_ptr<Evaluations::Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<Evaluations::Interface::Dtc> m_dtc;
|
||||
|
||||
int m_exerciseId = 0;
|
||||
int m_testId = 0;
|
||||
int m_operatorId = 0;
|
||||
int m_criteriumId = 0;
|
||||
int m_elementId = 0;
|
||||
int m_sanNineLinerId = 0;
|
||||
|
||||
enum TestStep
|
||||
{
|
||||
eUnknown,
|
||||
eCreateCriterium,
|
||||
eModifyCriterium,
|
||||
eRemoveCriterium,
|
||||
eGetAllCriteria,
|
||||
eGetCriterium,
|
||||
eCreateElement,
|
||||
eModifyElement,
|
||||
eRemoveElement,
|
||||
eCreateSanNineLiner,
|
||||
eModifySanNineLiner,
|
||||
eRemoveSanNineLiner,
|
||||
eGetSanNineLiner
|
||||
}
|
||||
m_eTestStep = eUnknown;
|
||||
|
||||
bool m_bTestsSuccessful = true;
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Evaluations
|
||||
Executable
+45
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* DdsHandler for DDS
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hanna E. Rathje, SLSE, 2015-09-02
|
||||
*/
|
||||
|
||||
#include "dds_handler.h"
|
||||
|
||||
#include <DDS/Core/pacemaker.h>
|
||||
|
||||
namespace Evaluations
|
||||
{
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
bool DdsHandler::init(const QStringList &qosFileList)
|
||||
{
|
||||
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_ddsDts = Evaluations::Interface::Dts::create(m_ddsConnector);
|
||||
bool bRet = m_ddsDts->enableAll();
|
||||
INFO_LOG(m_logger) << "Dts initialised";
|
||||
|
||||
m_ddsFts = Evaluations::Interface::Fts::create(m_ddsConnector);
|
||||
bRet &= m_ddsFts->enableAll();
|
||||
INFO_LOG(m_logger) << "Fts initialised: ";
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
} // Namespace Evaluations
|
||||
Executable
+38
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* DdsHandler for DDS
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hanna E. Rathje, SLSE, 2015-09-02
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <Evaluations/evl_dts.h>
|
||||
#include <Evaluations/evl_fts.h>
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
namespace Evaluations
|
||||
{
|
||||
class DdsHandler final
|
||||
{
|
||||
public:
|
||||
explicit DdsHandler(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector);
|
||||
~DdsHandler() = default;
|
||||
|
||||
bool init(const QStringList &qosFileList = QStringList());
|
||||
|
||||
std::shared_ptr<Evaluations::Interface::Dts> dts() const { return m_ddsDts; }
|
||||
std::shared_ptr<Evaluations::Interface::Fts> fts() const { return m_ddsFts; }
|
||||
|
||||
private:
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
std::shared_ptr<Evaluations::Interface::Dts> m_ddsDts;
|
||||
std::shared_ptr<Evaluations::Interface::Fts> m_ddsFts;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
} // namespace Evaluations
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Custom db functions (extends tab_db_impl.cpp/.h)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "evl_db_impl_custom.h"
|
||||
#include <ngldb/nsqlquery.h>
|
||||
#include <ngldb/sql_query_janitor.h>
|
||||
#include <QRegularExpression>
|
||||
|
||||
namespace Evaluations
|
||||
{
|
||||
// custom procs, body must be implemented by user
|
||||
bool DatabaseInterfaceImplCustom::removeCategoryLinesPerNineLiner(qint64 nineLinerId)
|
||||
{
|
||||
const QString tableName = getTableName(QStringLiteral("san_category_line"));
|
||||
const QString stmt = QStringLiteral("DELETE FROM ") + tableName + QStringLiteral(" WHERE nine_liner_id = :id");
|
||||
|
||||
if (!m_query)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "m_query not initialized";
|
||||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
SqlQueryJanitor janitor(m_query);
|
||||
|
||||
if (!m_query->prepare(stmt))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not prepare statement: " << stmt;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_query->bindValue(QStringLiteral(":id"), nineLinerId);
|
||||
|
||||
if (!m_query->exec())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not execute statement: " << stmt;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
} // query scope
|
||||
}
|
||||
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Custom db functions (extends tab_db_impl.cpp/.h)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <Evaluations/evl_db_impl.h>
|
||||
|
||||
namespace Evaluations
|
||||
{
|
||||
class DatabaseInterfaceImplCustom final : public DatabaseInterfaceImpl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using DatabaseInterfaceImpl::DatabaseInterfaceImpl;
|
||||
|
||||
bool removeCategoryLinesPerNineLiner(qint64 nineLinerId);
|
||||
};
|
||||
|
||||
} // namespace Evaluations
|
||||
Executable
+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 EVL_COMMON_EXPORT
|
||||
# ifdef BUILD_STATIC_LIBRARIES
|
||||
# define EVL_COMMON_EXPORT
|
||||
# else
|
||||
# if defined(MAKE_SVCEVLCOMMON_LIB)
|
||||
# define EVL_COMMON_EXPORT Q_DECL_EXPORT
|
||||
# ifndef WIN32
|
||||
# ifdef NDDSUSERDllExport
|
||||
# undef NDDSUSERDllExport
|
||||
# endif
|
||||
# define NDDSUSERDllExport Q_DECL_EXPORT
|
||||
# endif
|
||||
# else
|
||||
# define EVL_COMMON_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef EVL_CLIENT_EXPORT
|
||||
# ifdef BUILD_STATIC_LIBRARIES
|
||||
# define EVL_CLIENT_EXPORT
|
||||
# else
|
||||
# if defined(MAKE_SVCEVLCLIENT_LIB)
|
||||
# define EVL_CLIENT_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
# define EVL_CLIENT_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef EVL_SERVER_EXPORT
|
||||
# ifdef BUILD_STATIC_LIBRARIES
|
||||
# define EVL_SERVER_EXPORT
|
||||
# else
|
||||
# if defined(MAKE_SVCEVLSERVER_LIB)
|
||||
# define EVL_SERVER_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
# define EVL_SERVER_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
Executable
+236
@@ -0,0 +1,236 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<service namespace="Evaluations" abbreviation="EVL" procNames="Evaluations" exerciseDependency="Exercise">
|
||||
<rcs>
|
||||
<Id Id="$Id$"/>
|
||||
<HeadURL HeadURL="$HeadURL$"/>
|
||||
<Author Author="$Author$"/>
|
||||
</rcs>
|
||||
<operatorRights offset="10">
|
||||
<guiPlugin name="EvaluationEdit" offset="1">
|
||||
<operatorRightGroup name="EvaluationElements" description="Edit Evaluation Elements">
|
||||
<operatorRight right="EvaluationElementEdit" value="1" description="Edit Evaluation Elements"/>
|
||||
</operatorRightGroup>
|
||||
<operatorRightGroup name="Evaluations" description="Edit evaluations">
|
||||
<operatorRight right="EvaluationEdit" value="1" description="Edit evaluation"/>
|
||||
<operatorRight right="EvaluationShow" value="2" description="Show evaluation"/>
|
||||
</operatorRightGroup>
|
||||
</guiPlugin>
|
||||
<guiPlugin name="SanNineLinerEdit" offset="2">
|
||||
<operatorRightGroup name="SanNineLiner" description="SanNineLiner operator rights">
|
||||
<operatorRight right="SanNineLinerEdit" value="1" description="Edit SanNineLiner"/>
|
||||
<operatorRight right="SanNineLinerShow" value="2" description="Show SanNineLiner"/>
|
||||
</operatorRightGroup>
|
||||
</guiPlugin>
|
||||
</operatorRights>
|
||||
<tables>
|
||||
<table name="evl_comment">
|
||||
<column name="id" datatype="bigint" isPrimaryKey="1" isForeignKey="1">
|
||||
<sequence start="1" increment="1"/>
|
||||
</column>
|
||||
<column name="ts" datatype="timestamp"/>
|
||||
<column name="sender_operator_id" datatype="bigint" isForeignKey="1"/>
|
||||
<column name="receiver_operator_id" datatype="bigint" isOptional="1" isForeignKey="1"/>
|
||||
<column name="text" datatype="text"/>
|
||||
<column name="hierarchy" datatype="text"/>
|
||||
<column name="schema_id" datatype="bigint" isForeignKey="1"/>
|
||||
<column name="element_id" datatype="bigint"/>
|
||||
<foreignKey name="FK_evl_comment_evl_schema">
|
||||
<source table="evl_comment" column="schema_id"/>
|
||||
<destination table="evl_schema" column="id"/>
|
||||
</foreignKey>
|
||||
<foreignKey name="FK_evl_comment_opm_operator_sender">
|
||||
<source table="evl_comment" column="sender_operator_id"/>
|
||||
<destination service="OperatorManagement" serviceAbbr="opm" schema="opm" table="opm_operator" column="id"/>
|
||||
</foreignKey>
|
||||
<foreignKey name="FK_evl_comment_opm_operator_receiver">
|
||||
<source table="evl_comment" column="receiver_operator_id"/>
|
||||
<destination service="OperatorManagement" serviceAbbr="opm" schema="opm" table="opm_operator" column="id"/>
|
||||
</foreignKey>
|
||||
</table>
|
||||
<table name="evl_criterium">
|
||||
<column name="id" datatype="bigint" isPrimaryKey="1">
|
||||
<sequence start="1" increment="1"/>
|
||||
</column>
|
||||
<column name="name" datatype="text"/>
|
||||
<column name="description" datatype="text"/>
|
||||
<column name="operator_id" datatype="bigint" isForeignKey="1"/>
|
||||
<foreignKey name="FK_evl_criterium_opm_operator">
|
||||
<source table="evl_criterium" column="operator_id"/>
|
||||
<destination service="OperatorManagement" serviceAbbr="opm" schema="opm" table="opm_operator" column="id"/>
|
||||
</foreignKey>
|
||||
</table>
|
||||
<table name="evl_element">
|
||||
<column name="id" datatype="bigint" isPrimaryKey="1">
|
||||
<sequence start="1" increment="1"/>
|
||||
</column>
|
||||
<column name="time" datatype="bigint"/>
|
||||
<column name="duration" datatype="integer"/>
|
||||
<column name="rating" datatype="integer"/>
|
||||
<column name="note" datatype="text"/>
|
||||
<column name="phase_id" datatype="integer"/>
|
||||
<column name="criterium_id" datatype="bigint" isForeignKey="1"/>
|
||||
<column name="audio_content" datatype="jsonb" isOptional="1"/>
|
||||
<column name="video_content" datatype="jsonb" isOptional="1"/>
|
||||
<column name="situation_content" datatype="jsonb" isOptional="1"/>
|
||||
<foreignKey name="FK_evl_element_evl_criterium">
|
||||
<source table="evl_element" column="criterium_id"/>
|
||||
<destination table="evl_criterium" column="id"/>
|
||||
</foreignKey>
|
||||
</table>
|
||||
<table name="evl_schema">
|
||||
<column name="id" datatype="bigint" isPrimaryKey="1">
|
||||
<sequence start="1" increment="1"/>
|
||||
</column>
|
||||
<column name="schemadata" datatype="text"/>
|
||||
<column name="send_to_ta" datatype="boolean"/>
|
||||
</table>
|
||||
<table name="san_category_line">
|
||||
<column name="id" datatype="bigint" isPrimaryKey="1">
|
||||
<sequence start="1" increment="1"/>
|
||||
</column>
|
||||
<column name="nine_liner_id" datatype="bigint" isForeignKey="1"/>
|
||||
<column name="line" datatype="integer"/>
|
||||
<column name="amount" datatype="integer"/>
|
||||
<column name="category" datatype="text"/>
|
||||
<foreignKey name="FK_san_category_line_san_9liner">
|
||||
<source table="san_category_line" column="nine_liner_id"/>
|
||||
<destination table="san_nine_liner" column="id"/>
|
||||
</foreignKey>
|
||||
</table>
|
||||
<table name="san_nine_liner">
|
||||
<column name="id" datatype="bigint" isPrimaryKey="1">
|
||||
<sequence start="1" increment="1"/>
|
||||
</column>
|
||||
<column name="last_modified" datatype="bigint"/>
|
||||
<column name="position" datatype="point_2d"/>
|
||||
<column name="radio_frequency_suffix_callsign" datatype="text"/>
|
||||
<column name="position_x_m" datatype="double precision"/>
|
||||
<column name="position_y_m" datatype="double precision"/>
|
||||
</table>
|
||||
</tables>
|
||||
<views/>
|
||||
<dbServiceStructs>
|
||||
<serviceStruct name="EvlComment" table="evl_comment"/>
|
||||
<serviceStruct name="EvlCriterium" table="evl_criterium"/>
|
||||
<serviceStruct name="EvlElement" table="evl_element"/>
|
||||
<serviceStruct name="EvlSchema" table="evl_schema"/>
|
||||
<serviceStruct name="SanCategoryLine" table="san_category_line"/>
|
||||
<serviceStruct name="SanNineLiner" table="san_nine_liner">
|
||||
<function name="removeCategoryLinesPerNineLiner" returns="bool">
|
||||
<parameter pos="1" name="nineLinerId" type="qint64"/>
|
||||
</function>
|
||||
</serviceStruct>
|
||||
<table name="evl_comment"/>
|
||||
<table name="evl_criterium"/>
|
||||
<table name="evl_element"/>
|
||||
<table name="evl_schema"/>
|
||||
<table name="san_category_line"/>
|
||||
<table name="san_nine_liner"/>
|
||||
</dbServiceStructs>
|
||||
<topicTypes>
|
||||
<topicType name="EvaluationComment" isDataObject="1" autosubscribe="1" routeToClient="1" routeToServer="0" routeInReplay="0">
|
||||
<column name="id" idlType="long" isKey="1"/>
|
||||
<column name="ts" idlType="long long"/>
|
||||
<column name="senderOperatorId" idlType="long"/>
|
||||
<column name="receiverOperatorId" idlType="long" isOptional="1"/>
|
||||
<column name="text" idlType="string"/>
|
||||
<column name="schemaId" idlType="long"/>
|
||||
<column name="hierarchy" idlType="string"/>
|
||||
<column name="elementId" idlType="long"/>
|
||||
</topicType>
|
||||
<topicType name="EvaluationCriterium" isDataObject="1" autosubscribe="1" routeToClient="1" routeToServer="0" routeInReplay="0">
|
||||
<column name="id" idlType="long" isKey="1"/>
|
||||
<column name="name" idlType="string"/>
|
||||
<column name="description" idlType="string"/>
|
||||
<column name="operatorId" idlType="long"/>
|
||||
</topicType>
|
||||
<topicType name="EvaluationElement" isDataObject="1" autosubscribe="1" routeToClient="1" routeToServer="0" routeInReplay="0">
|
||||
<column name="id" idlType="long" isKey="1"/>
|
||||
<column name="timestamp" idlType="long long"/>
|
||||
<column name="situation" idlType="boolean"/>
|
||||
<column name="video" idlType="boolean"/>
|
||||
<column name="audio" idlType="boolean"/>
|
||||
<column name="duration" idlType="long"/>
|
||||
<column name="rating" idlType="long"/>
|
||||
<column name="note" idlType="string"/>
|
||||
<column name="phaseId" idlType="long"/>
|
||||
<column name="criteriumId" idlType="long"/>
|
||||
<column name="audioContent" idlType="string" isOptional="1"/>
|
||||
<column name="videoContent" idlType="string" isOptional="1"/>
|
||||
<column name="situationContent" idlType="string" isOptional="1"/>
|
||||
</topicType>
|
||||
<topicType name="EvaluationSchema" isDataObject="1" autosubscribe="1" routeToClient="1" routeToServer="0" routeInReplay="0">
|
||||
<column name="id" idlType="long" isKey="1"/>
|
||||
<column name="schemadata" idlType="string"/>
|
||||
<column name="sendToTa" idlType="boolean"/>
|
||||
</topicType>
|
||||
<topicType name="EvlCommentModifyRequest">
|
||||
<column name="id" idlType="long"/>
|
||||
<column name="ts" idlType="long long"/>
|
||||
<column name="senderOperatorId" idlType="long"/>
|
||||
<column name="receiverOperatorId" idlType="long" isOptional="1"/>
|
||||
<column name="text" idlType="string"/>
|
||||
<column name="hierarchy" idlType="string"/>
|
||||
<column name="schemaId" idlType="long"/>
|
||||
<column name="elementId" idlType="long"/>
|
||||
</topicType>
|
||||
<topicType name="EvlCriteriumModifyRequest">
|
||||
<column name="id" idlType="long"/>
|
||||
<column name="name" idlType="string"/>
|
||||
<column name="description" idlType="string"/>
|
||||
<column name="operatorId" idlType="long"/>
|
||||
</topicType>
|
||||
<topicType name="EvlElementModifyRequest">
|
||||
<column name="id" idlType="long"/>
|
||||
<column name="timestamp" idlType="long long"/>
|
||||
<column name="duration" idlType="long"/>
|
||||
<column name="rating" idlType="long"/>
|
||||
<column name="note" idlType="string"/>
|
||||
<column name="phaseId" idlType="long"/>
|
||||
<column name="criteriumId" idlType="long"/>
|
||||
<column name="audioContent" idlType="string" isOptional="1"/>
|
||||
<column name="videoContent" idlType="string" isOptional="1"/>
|
||||
<column name="situationContent" idlType="string" isOptional="1"/>
|
||||
</topicType>
|
||||
<topicType name="EvlElementRemoveRequest">
|
||||
<column name="id" idlType="long"/>
|
||||
<column name="criteriumId" idlType="long"/>
|
||||
</topicType>
|
||||
<topicType name="EvlSchemaModifyRequest">
|
||||
<column name="id" idlType="long"/>
|
||||
<column name="schemadata" idlType="string"/>
|
||||
<column name="sendToTa" idlType="boolean"/>
|
||||
</topicType>
|
||||
<topicType name="SanNineLiner" isDataObject="1" autosubscribe="1" routeToClient="1" routeToServer="0" routeInReplay="0">
|
||||
<column name="id" idlType="long" isKey="1"/>
|
||||
<column name="lastModified" idlType="long long"/>
|
||||
<column name="line1_position" idlType="Core::GeoPosition2D"/>
|
||||
<column name="line2_RadioFrequencyCallSignSuffix" idlType="string"/>
|
||||
<column name="lines" idlType="string"/>
|
||||
</topicType>
|
||||
<topicType name="SanNineLinerModifyRequest">
|
||||
<column name="id" idlType="long"/>
|
||||
<column name="lastModified" idlType="long long"/>
|
||||
<column name="line1_position" idlType="Core::GeoPosition2D"/>
|
||||
<column name="line2_radioFrequencyCallSignSuffix" idlType="string"/>
|
||||
<column name="lines" idlType="string"/>
|
||||
</topicType>
|
||||
</topicTypes>
|
||||
<functionTopics>
|
||||
<functionTopic name="EvlCommentModify" requestTopicType="EvlCommentModifyRequest" replyTopicType="Core::FunctionReply" requestTopicName="EvlCommentModifyRequest" replyTopicName="EvlCommentModifyReply" routeInReplay="0"/>
|
||||
<functionTopic name="EvlCriteriumModify" requestTopicType="EvlCriteriumModifyRequest" replyTopicType="Core::FunctionReply" requestTopicName="EvlCriteriumModifyRequest" replyTopicName="EvlCriteriumModifyReply" routeInReplay="0"/>
|
||||
<functionTopic name="EvlCriteriumRemove" requestTopicType="Core::RemoveElementRequest" replyTopicType="Core::FunctionReply" requestTopicName="EvlCriteriumRemoveRequest" replyTopicName="EvlCriteriumRemoveReply" routeInReplay="0"/>
|
||||
<functionTopic name="EvlElementModify" requestTopicType="EvlElementModifyRequest" replyTopicType="Core::FunctionReply" requestTopicName="EvlElementModifyRequest" replyTopicName="EvlElementModifyReply" routeInReplay="0"/>
|
||||
<functionTopic name="EvlElementRemove" requestTopicType="EvlElementRemoveRequest" replyTopicType="Core::FunctionReply" requestTopicName="EvlElementRemoveRequest" replyTopicName="EvlElementRemoveReply" routeInReplay="0"/>
|
||||
<functionTopic name="EvlSchemaModify" requestTopicType="EvlSchemaModifyRequest" replyTopicType="Core::FunctionReply" requestTopicName="EvlSchemaModifyRequest" replyTopicName="EvlSchemaModifyReply" routeInReplay="0"/>
|
||||
<functionTopic name="SanNineLinerModify" requestTopicType="SanNineLinerModifyRequest" replyTopicType="Core::FunctionReply" requestTopicName="SanNineLinerModifyRequest" replyTopicName="SanNineLinerModifyReply" routeInReplay="0"/>
|
||||
<functionTopic name="SanNineLinerRemove" requestTopicType="Core::RemoveElementRequest" replyTopicType="Core::FunctionReply" requestTopicName="SanNineLinerRemoveRequest" replyTopicName="SanNineLinerRemoveReply" routeInReplay="0"/>
|
||||
</functionTopics>
|
||||
<enumerations>
|
||||
<enumeration name="DummyEvlMedium">
|
||||
<attribute key="Situation" value="1"/>
|
||||
<attribute key="Audio" value="2"/>
|
||||
<attribute key="Video" value="3"/>
|
||||
</enumeration>
|
||||
</enumerations>
|
||||
</service>
|
||||
Executable
+167
@@ -0,0 +1,167 @@
|
||||
/**
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Last, NLSE, 2018-01-11
|
||||
*/
|
||||
|
||||
#include "handler_comment.h"
|
||||
#include "object_comment.h"
|
||||
#include "settings.h"
|
||||
|
||||
namespace Evaluations
|
||||
{
|
||||
|
||||
HandlerComment::HandlerComment(const std::shared_ptr<DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<DatabaseInterface> &db)
|
||||
: Interface::Fts::EvlCommentModifyRequestHandler(ddsHandler->fts())
|
||||
, Interface::Fts::EvlSchemaModifyRequestHandler(ddsHandler->fts())
|
||||
, m_ddsHandler(ddsHandler)
|
||||
, m_db(db)
|
||||
, m_logger(getLogger("HandlerComment"))
|
||||
{}
|
||||
|
||||
HandlerComment::~HandlerComment()
|
||||
{
|
||||
qDeleteAll(m_mapObjectSchema);
|
||||
qDeleteAll(m_mapObjectComment);
|
||||
}
|
||||
|
||||
bool HandlerComment::init()
|
||||
{
|
||||
bool bRet = true;
|
||||
// Comment
|
||||
auto cbComment = [this, &bRet] (const Database::EvlComment &data)
|
||||
{
|
||||
ObjectComment *ifs(new ObjectComment(m_ddsHandler, m_db));
|
||||
Core::FunctionReplyObject ret = ifs->createObject(data);
|
||||
if (ret.error())
|
||||
{
|
||||
delete ifs;
|
||||
ERROR_LOG(m_logger) << ret();
|
||||
bRet = false;
|
||||
return;
|
||||
}
|
||||
m_mapObjectComment.insert(ifs->getId(), ifs);
|
||||
};
|
||||
if (!m_db->select(cbComment) || !bRet)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error reading data from database!";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Schema
|
||||
auto cbSchema = [this, &bRet] (const Database::EvlSchema &data)
|
||||
{
|
||||
ObjectSchema *ifs(new ObjectSchema(m_ddsHandler, m_db));
|
||||
Core::FunctionReplyObject ret = ifs->createObject(data);
|
||||
if (ret.error())
|
||||
{
|
||||
delete ifs;
|
||||
ERROR_LOG(m_logger) << ret();
|
||||
bRet = false;
|
||||
return;
|
||||
}
|
||||
m_mapObjectSchema.insert(ifs->getId(), ifs);
|
||||
};
|
||||
if (!m_db->select(cbSchema) || !bRet)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error reading data from database!";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_mapObjectSchema.isEmpty())
|
||||
createDefaultSchema();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void HandlerComment::createDefaultSchema()
|
||||
{
|
||||
rti::core::SampleIdentity cookie;
|
||||
EvlSchemaModifyRequest request;
|
||||
|
||||
request.id(0);
|
||||
request.schemadata() = Evaluations::Settings::defaultSchema().toStdString();
|
||||
request.sendToTa(false);
|
||||
onEvlSchemaModifyRequest(cookie, request);
|
||||
}
|
||||
|
||||
|
||||
void HandlerComment::onEvlCommentModifyRequest(const rti::core::SampleIdentity &cookie,
|
||||
const EvlCommentModifyRequest &request)
|
||||
{
|
||||
Database::EvlComment data;
|
||||
data.id = request.id();
|
||||
data.ts = QDateTime::fromMSecsSinceEpoch(request.ts());
|
||||
data.senderOperatorId = request.senderOperatorId();
|
||||
|
||||
if (request.receiverOperatorId().is_set())
|
||||
data.receiverOperatorId = request.receiverOperatorId().get();
|
||||
|
||||
data.text = QString::fromStdString(request.text());
|
||||
data.hierarchy = QString::fromStdString(request.hierarchy());
|
||||
data.schemaId = request.schemaId();
|
||||
data.elementId = request.elementId();
|
||||
|
||||
|
||||
Core::FunctionReplyObject ret;
|
||||
if (request.id() <= 0)
|
||||
{
|
||||
ObjectComment *ifs(new ObjectComment(m_ddsHandler, m_db));
|
||||
ret = ifs->createObject(data);
|
||||
|
||||
if (ret.error())
|
||||
{
|
||||
delete ifs;
|
||||
ifs = nullptr;
|
||||
ERROR_LOG(m_logger) << ret();
|
||||
}
|
||||
else
|
||||
m_mapObjectComment.insert(ifs->getId(), ifs);
|
||||
}
|
||||
else
|
||||
{
|
||||
data.id = request.id();
|
||||
ObjectComment *ifs = m_mapObjectComment.value(data.id);
|
||||
ret = ifs->updateObject(data);
|
||||
}
|
||||
|
||||
m_ddsHandler->fts()->evlCommentModifyReply(cookie, ret);
|
||||
}
|
||||
|
||||
|
||||
void HandlerComment::onEvlSchemaModifyRequest(const rti::core::SampleIdentity &cookie,
|
||||
const EvlSchemaModifyRequest &request)
|
||||
{
|
||||
Database::EvlSchema data;
|
||||
data.id = request.id();
|
||||
data.schemadata = QString::fromStdString(request.schemadata());
|
||||
data.sendToTa = request.sendToTa();
|
||||
|
||||
Core::FunctionReplyObject ret;
|
||||
if (request.id() <= 0 && !m_mapObjectSchema.contains(std::abs(request.id())))
|
||||
{
|
||||
ObjectSchema *ifs(new ObjectSchema(m_ddsHandler, m_db));
|
||||
ret = ifs->createObject(data);
|
||||
|
||||
if (ret.error())
|
||||
{
|
||||
delete ifs;
|
||||
ifs = nullptr;
|
||||
ERROR_LOG(m_logger) << ret();
|
||||
}
|
||||
else
|
||||
m_mapObjectSchema.insert(ifs->getId(), ifs);
|
||||
}
|
||||
else
|
||||
{
|
||||
ObjectSchema *ifs = m_mapObjectSchema.value(std::abs(data.id));
|
||||
ret = ifs->updateObject(data);
|
||||
}
|
||||
|
||||
m_ddsHandler->fts()->evlSchemaModifyReply(cookie, ret);
|
||||
}
|
||||
} // Namespace Evaluations
|
||||
Executable
+48
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Last, NLSE, 2018-01-11
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QHash>
|
||||
|
||||
#include "dds_handler.h"
|
||||
#include "logger.h"
|
||||
#include <Evaluations/evl_db.h>
|
||||
|
||||
namespace Evaluations
|
||||
{
|
||||
class ObjectComment;
|
||||
class ObjectSchema;
|
||||
|
||||
class HandlerComment final
|
||||
: protected Interface::Fts::EvlCommentModifyRequestHandler
|
||||
, protected Interface::Fts::EvlSchemaModifyRequestHandler
|
||||
{
|
||||
public:
|
||||
HandlerComment(const std::shared_ptr<DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<Evaluations::DatabaseInterface> &db);
|
||||
|
||||
~HandlerComment();
|
||||
|
||||
bool init();
|
||||
|
||||
private:
|
||||
void onEvlCommentModifyRequest(const rti::core::SampleIdentity &cookie,
|
||||
const EvlCommentModifyRequest &request) override final;
|
||||
|
||||
void onEvlSchemaModifyRequest(const rti::core::SampleIdentity &cookie,
|
||||
const EvlSchemaModifyRequest &request) override final;
|
||||
|
||||
private:
|
||||
void createDefaultSchema();
|
||||
QHash<int, ObjectComment *> m_mapObjectComment;
|
||||
QHash<int, ObjectSchema *> m_mapObjectSchema;
|
||||
|
||||
std::shared_ptr<DdsHandler> m_ddsHandler;
|
||||
std::shared_ptr<DatabaseInterface> m_db;
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
}
|
||||
+214
@@ -0,0 +1,214 @@
|
||||
/**
|
||||
* Handler for all exercise objects
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hanna E. Rathje, SLSE, 2015-09-03
|
||||
*/
|
||||
|
||||
#include "handler_criterium.h"
|
||||
#include "object_criterium.h"
|
||||
#include "object_evaluation_element.h"
|
||||
|
||||
namespace Evaluations
|
||||
{
|
||||
|
||||
HandlerCriterium::HandlerCriterium(const std::shared_ptr<DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<DatabaseInterface> &db)
|
||||
: Interface::Fts::EvlCriteriumModifyRequestHandler(ddsHandler->fts())
|
||||
, Interface::Fts::EvlCriteriumRemoveRequestHandler(ddsHandler->fts())
|
||||
, Interface::Fts::EvlElementModifyRequestHandler(ddsHandler->fts())
|
||||
, Interface::Fts::EvlElementRemoveRequestHandler(ddsHandler->fts())
|
||||
, m_ddsHandler(ddsHandler)
|
||||
, m_db(db)
|
||||
, m_logger(getLogger("HandlerCriterium"))
|
||||
{}
|
||||
|
||||
HandlerCriterium::~HandlerCriterium()
|
||||
{
|
||||
qDeleteAll(m_criteriumObjMap);
|
||||
}
|
||||
|
||||
bool HandlerCriterium::init()
|
||||
{
|
||||
bool bRet = true;
|
||||
|
||||
// create criterium objects
|
||||
auto cbCriterim = [this, &bRet](const Database::EvlCriterium & data)
|
||||
{
|
||||
ObjectCriterium *ifs(new ObjectCriterium(m_ddsHandler, m_db));
|
||||
Core::FunctionReplyObject ret = ifs->createObject(data);
|
||||
if (ret.error())
|
||||
{
|
||||
delete ifs;
|
||||
ERROR_LOG(m_logger) << ret();
|
||||
bRet = false;
|
||||
return;
|
||||
}
|
||||
m_criteriumObjMap.insert(ifs->getId(), ifs);
|
||||
};
|
||||
if (!m_db->select(cbCriterim) || !bRet)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error reading data from database!";
|
||||
return false;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "m_criteriumObjMap.size() = " << m_criteriumObjMap.size();
|
||||
|
||||
auto cbElement = [this, &bRet](const Database::EvlElement & data)
|
||||
{
|
||||
ObjectCriterium *ifs = m_criteriumObjMap.value(data.criteriumId);
|
||||
if (!ifs)
|
||||
return;
|
||||
|
||||
ObjectEvaluationElement *oee = new ObjectEvaluationElement(m_ddsHandler, m_db);
|
||||
Core::FunctionReplyObject ret = oee->createObject(data);
|
||||
if (ret.error())
|
||||
{
|
||||
delete oee;
|
||||
ERROR_LOG(m_logger) << ret();
|
||||
bRet = false;
|
||||
return;
|
||||
}
|
||||
ifs->addElement(oee);
|
||||
};
|
||||
if (!m_db->select(cbElement) || !bRet)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error reading data from database!";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void HandlerCriterium::onEvlCriteriumModifyRequest(const rti::core::SampleIdentity &cookie,
|
||||
const EvlCriteriumModifyRequest &request)
|
||||
{
|
||||
Database::EvlCriterium data;
|
||||
data.name = QString::fromStdString(request.name());
|
||||
data.description = QString::fromStdString(request.description());
|
||||
data.operatorId = request.operatorId();
|
||||
|
||||
Core::FunctionReplyObject ret;
|
||||
if (request.id() <= 0)
|
||||
{
|
||||
ObjectCriterium *ifs = new ObjectCriterium(m_ddsHandler, m_db);
|
||||
ret = ifs->createObject(data);
|
||||
|
||||
if (ret.error())
|
||||
{
|
||||
delete ifs;
|
||||
ifs = nullptr;
|
||||
ERROR_LOG(m_logger) << ret();
|
||||
}
|
||||
else
|
||||
m_criteriumObjMap.insert(ifs->getId(), ifs);
|
||||
}
|
||||
else
|
||||
{
|
||||
data.id = request.id();
|
||||
ObjectCriterium *ifs = m_criteriumObjMap.value(data.id);
|
||||
ret = ifs->updateObject(data);
|
||||
}
|
||||
|
||||
m_ddsHandler->fts()->evlCriteriumModifyReply(cookie, ret);
|
||||
}
|
||||
|
||||
void HandlerCriterium::onEvlCriteriumRemoveRequest(const rti::core::SampleIdentity &cookie,
|
||||
const Core::RemoveElementRequest &request)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onEvlCriteriumRemoveRequest: " << request;
|
||||
|
||||
ObjectCriterium *ifs = m_criteriumObjMap.value(request.id());
|
||||
Core::FunctionReplyObject ret;
|
||||
if (!ifs)
|
||||
{
|
||||
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "No EvlCriterium with id %1 found")).arg(request.id());
|
||||
m_ddsHandler->fts()->evlCriteriumRemoveReply(cookie, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
ret = ifs->removeObject();
|
||||
m_ddsHandler->fts()->evlCriteriumRemoveReply(cookie, ret);
|
||||
}
|
||||
|
||||
void HandlerCriterium::onEvlElementModifyRequest(const rti::core::SampleIdentity &cookie,
|
||||
const EvlElementModifyRequest &request)
|
||||
{
|
||||
ObjectCriterium *ifs = m_criteriumObjMap.value(request.criteriumId());
|
||||
|
||||
Core::FunctionReplyObject ret;
|
||||
if (!ifs)
|
||||
{
|
||||
ret = Core::FunctionReplyObject(request.criteriumId(), tr_lts("dds", "No EvlCriterium with id %1 found")).arg(request.criteriumId());
|
||||
m_ddsHandler->fts()->evlElementModifyReply(cookie, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
Database::EvlElement data;
|
||||
|
||||
data.criteriumId = request.criteriumId();
|
||||
data.id = request.id();
|
||||
data.duration = request.duration();
|
||||
data.note = QString::fromStdString(request.note());
|
||||
data.phaseId = request.phaseId();
|
||||
data.rating = request.rating();
|
||||
data.time = request.timestamp();
|
||||
if (request.audioContent().is_set())
|
||||
data.audioContent = QString::fromStdString(request.audioContent().get());
|
||||
if (request.videoContent().is_set())
|
||||
data.videoContent = QString::fromStdString(request.videoContent().get());
|
||||
if (request.situationContent().is_set())
|
||||
data.situationContent = QString::fromStdString(request.situationContent().get());
|
||||
|
||||
if (data.id <= 0)
|
||||
{
|
||||
data.id = 0;
|
||||
ObjectEvaluationElement *oee = new ObjectEvaluationElement(m_ddsHandler, m_db);
|
||||
ret = oee->createObject(data);
|
||||
|
||||
if (!ret.error())
|
||||
ifs->addElement(oee);
|
||||
}
|
||||
else
|
||||
{
|
||||
ObjectEvaluationElement *oee = ifs->getElement(data.id);
|
||||
if (!oee)
|
||||
ret = Core::FunctionReplyObject(data.id, tr_lts("dds", "No EvaluationElement with id %1 found")).arg(data.id);
|
||||
else
|
||||
{
|
||||
ret = oee->updateObject(data);
|
||||
|
||||
if (!ret.error())
|
||||
ifs->addElement(oee);
|
||||
}
|
||||
}
|
||||
|
||||
m_ddsHandler->fts()->evlElementModifyReply(cookie, ret);
|
||||
}
|
||||
|
||||
void HandlerCriterium::onEvlElementRemoveRequest(const rti::core::SampleIdentity &cookie,
|
||||
const EvlElementRemoveRequest &request)
|
||||
{
|
||||
ObjectCriterium *ifs = m_criteriumObjMap.value(request.criteriumId());
|
||||
|
||||
Core::FunctionReplyObject ret;
|
||||
if (!ifs)
|
||||
{
|
||||
ret = Core::FunctionReplyObject(request.criteriumId(), tr_lts("dds", "No EvlCriterium with id %1 found")).arg(request.criteriumId());
|
||||
m_ddsHandler->fts()->evlElementModifyReply(cookie, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
ObjectEvaluationElement *oee = ifs->getElement(request.id());
|
||||
if (!oee)
|
||||
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "No EvaluationElement with id %1 found")).arg(request.id());
|
||||
else
|
||||
{
|
||||
ret = oee->removeObject();
|
||||
ifs->removeElement(request.id());
|
||||
}
|
||||
|
||||
m_ddsHandler->fts()->evlElementRemoveReply(cookie, ret);
|
||||
}
|
||||
|
||||
} // namespace Evaluations
|
||||
Executable
+50
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Handler for all Language HMI objects
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hanna E. Rathje, SLSE, 2015-09-03
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QHash>
|
||||
|
||||
#include "dds_handler.h"
|
||||
#include "logger.h"
|
||||
#include <Evaluations/evl_db.h>
|
||||
|
||||
namespace Evaluations
|
||||
{
|
||||
class ObjectCriterium;
|
||||
class HandlerCriterium final
|
||||
: protected Interface::Fts::EvlCriteriumModifyRequestHandler
|
||||
, protected Interface::Fts::EvlCriteriumRemoveRequestHandler
|
||||
, protected Interface::Fts::EvlElementModifyRequestHandler
|
||||
, protected Interface::Fts::EvlElementRemoveRequestHandler
|
||||
{
|
||||
public:
|
||||
explicit HandlerCriterium(const std::shared_ptr<DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<Evaluations::DatabaseInterface> &db);
|
||||
|
||||
~HandlerCriterium();
|
||||
|
||||
bool init();
|
||||
|
||||
private:
|
||||
void onEvlCriteriumModifyRequest(const rti::core::SampleIdentity &cookie,
|
||||
const EvlCriteriumModifyRequest &request) override final;
|
||||
void onEvlCriteriumRemoveRequest(const rti::core::SampleIdentity &cookie,
|
||||
const Core::RemoveElementRequest &request) override final;
|
||||
void onEvlElementModifyRequest(const rti::core::SampleIdentity &cookie,
|
||||
const EvlElementModifyRequest &request) override final;
|
||||
void onEvlElementRemoveRequest(const rti::core::SampleIdentity &cookie,
|
||||
const EvlElementRemoveRequest &request) override final;
|
||||
|
||||
private:
|
||||
QHash<int, ObjectCriterium *> m_criteriumObjMap;
|
||||
std::shared_ptr<DdsHandler> m_ddsHandler;
|
||||
std::shared_ptr<DatabaseInterface> m_db;
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
};
|
||||
}
|
||||
+190
@@ -0,0 +1,190 @@
|
||||
/**
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Last, NLSE, 2018-01-11
|
||||
*/
|
||||
|
||||
#include "handler_san_nine_liner.h"
|
||||
#include "object_san_nine_liner.h"
|
||||
#include "object_san_category_line.h"
|
||||
#include "san_category_line_json.h"
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
|
||||
#include "settings.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
|
||||
namespace Evaluations
|
||||
{
|
||||
|
||||
HandlerSanNineLiner::HandlerSanNineLiner(const std::shared_ptr<DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<DatabaseInterface> &db)
|
||||
: Interface::Fts::SanNineLinerModifyRequestHandler(ddsHandler->fts())
|
||||
, Interface::Fts::SanNineLinerRemoveRequestHandler(ddsHandler->fts())
|
||||
, m_ddsHandler(ddsHandler)
|
||||
, m_db(db)
|
||||
, m_logger(getLogger("HandlerSanNineLiner"))
|
||||
{}
|
||||
|
||||
HandlerSanNineLiner::~HandlerSanNineLiner()
|
||||
{
|
||||
qDeleteAll(m_mapObjectSanNineLiner);
|
||||
}
|
||||
|
||||
bool HandlerSanNineLiner::init()
|
||||
{
|
||||
bool bRet = true;
|
||||
// Comment
|
||||
auto cbSanNineLiner = [this, &bRet] (const Database::SanNineLiner &data)
|
||||
{
|
||||
ObjectSanNineLiner *ifs(new ObjectSanNineLiner(m_ddsHandler, m_db));
|
||||
Core::FunctionReplyObject ret = ifs->createObject(data);
|
||||
if (ret.error())
|
||||
{
|
||||
delete ifs;
|
||||
ERROR_LOG(m_logger) << ret();
|
||||
bRet = false;
|
||||
return;
|
||||
}
|
||||
m_mapObjectSanNineLiner.insert(ifs->getId(), ifs);
|
||||
};
|
||||
if (!m_db->select(cbSanNineLiner) || !bRet)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error reading data from database!";
|
||||
return false;
|
||||
}
|
||||
|
||||
// add categoryLine to sanNineLiner object
|
||||
auto cb = [this] (const Database::SanCategoryLine &data)
|
||||
{
|
||||
ObjectSanNineLiner *objSan = m_mapObjectSanNineLiner.value(data.nineLinerId);
|
||||
if (!objSan)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Cannot find nineLiner Id = " << data.nineLinerId
|
||||
<< " for categoryLineId " << data.id;
|
||||
return;
|
||||
}
|
||||
objSan->addLineCategory(data);
|
||||
};
|
||||
|
||||
if (!m_db->select(cb))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error reading data from database!";
|
||||
return false;
|
||||
}
|
||||
|
||||
// publish
|
||||
for (ObjectSanNineLiner *objSan : qAsConst(m_mapObjectSanNineLiner))
|
||||
objSan->onPublishData();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void HandlerSanNineLiner::onSanNineLinerModifyRequest(const rti::core::SampleIdentity &cookie,
|
||||
const SanNineLinerModifyRequest &request)
|
||||
{
|
||||
Database::SanNineLiner data;
|
||||
data.id = request.id();
|
||||
data.lastModified = request.lastModified();
|
||||
data.position = QPointF(request.line1_position().lon(), request.line1_position().lat());
|
||||
|
||||
LtsCoordTrans::UtmCoordinate coord(LtsCoordTrans::UtmCoordinate::fromGeographic(request.line1_position().lon(),
|
||||
request.line1_position().lat()));
|
||||
data.positionXM = coord.x;
|
||||
data.positionYM = coord.y;
|
||||
|
||||
data.radioFrequencySuffixCallsign = QString::fromStdString(request.line2_radioFrequencyCallSignSuffix());
|
||||
|
||||
INFO_LOG(m_logger) << "lines: " << request.lines();
|
||||
|
||||
Core::FunctionReplyObject ret;
|
||||
ObjectSanNineLiner *ifs = nullptr;
|
||||
if (request.id() <= 0)
|
||||
{
|
||||
ifs = new ObjectSanNineLiner(m_ddsHandler, m_db);
|
||||
ret = ifs->createObject(data);
|
||||
|
||||
if (ret.error())
|
||||
{
|
||||
delete ifs;
|
||||
ifs = nullptr;
|
||||
ERROR_LOG(m_logger) << ret();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_mapObjectSanNineLiner.insert(ifs->getId(), ifs);
|
||||
data.id = ifs->getId();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
data.id = request.id();
|
||||
ifs = m_mapObjectSanNineLiner.value(data.id);
|
||||
ret = ifs->updateObject(data);
|
||||
}
|
||||
|
||||
if (!ifs)
|
||||
{
|
||||
m_ddsHandler->fts()->sanNineLinerModifyReply(cookie, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
// delete old entries
|
||||
if (!m_db->removeCategoryLinesPerNineLiner(data.id))
|
||||
ERROR_LOG(m_logger) << "Error while deleting old entries for nineLinerId " << data.id;
|
||||
|
||||
ifs->removeCategoryLines();
|
||||
|
||||
// line3 - line9 in object_san_category_line
|
||||
INFO_LOG(m_logger) << "data.id: " << data.id;
|
||||
|
||||
QVector<Database::SanCategoryLine> linesCategory = SanCategoryLine::fromJson(request.lines(), data.id);
|
||||
INFO_LOG(m_logger) << "LinesCategory count: " << linesCategory.count();
|
||||
|
||||
for (Database::SanCategoryLine cl : qAsConst(linesCategory))
|
||||
{
|
||||
ObjectSanCategoryLine *ifsCl(new ObjectSanCategoryLine(m_ddsHandler, m_db));
|
||||
ret = ifsCl->createObject(cl);
|
||||
if (ret.error())
|
||||
ERROR_LOG(m_logger) << ret();
|
||||
else
|
||||
{
|
||||
cl.id = ifsCl->getId();
|
||||
ifs->addLineCategory(cl);
|
||||
}
|
||||
}
|
||||
|
||||
ifs->onPublishData();
|
||||
ret.setId(ifs->getId());
|
||||
|
||||
m_ddsHandler->fts()->sanNineLinerModifyReply(cookie, ret);
|
||||
}
|
||||
|
||||
void HandlerSanNineLiner::onSanNineLinerRemoveRequest(const rti::core::SampleIdentity &cookie,
|
||||
const Core::RemoveElementRequest &request)
|
||||
{
|
||||
|
||||
ObjectSanNineLiner *ifs = m_mapObjectSanNineLiner.value(request.id());
|
||||
|
||||
Core::FunctionReplyObject ret;
|
||||
if (!ifs)
|
||||
{
|
||||
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "SanNineLiner with id %1 not found")).arg(request.id());
|
||||
m_ddsHandler->fts()->sanNineLinerRemoveReply(cookie, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_db->removeCategoryLinesPerNineLiner(request.id()))
|
||||
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "SanCategoryLine with id %1 not found")).arg(request.id());
|
||||
else
|
||||
{
|
||||
ifs->removeObject();
|
||||
m_mapObjectSanNineLiner.remove(request.id());
|
||||
}
|
||||
|
||||
m_ddsHandler->fts()->sanNineLinerRemoveReply(cookie, ret);
|
||||
}
|
||||
|
||||
|
||||
} // Namespace Evaluations
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Last, NLSE, 2018-01-11
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QHash>
|
||||
|
||||
#include "dds_handler.h"
|
||||
#include "logger.h"
|
||||
#include <Evaluations/evl_db.h>
|
||||
|
||||
namespace Evaluations
|
||||
{
|
||||
class ObjectSanNineLiner;
|
||||
|
||||
|
||||
class HandlerSanNineLiner
|
||||
: protected Interface::Fts::SanNineLinerModifyRequestHandler
|
||||
, protected Interface::Fts::SanNineLinerRemoveRequestHandler
|
||||
{
|
||||
public:
|
||||
HandlerSanNineLiner(const std::shared_ptr<DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<DatabaseInterface> &db);
|
||||
|
||||
~HandlerSanNineLiner();
|
||||
|
||||
bool init();
|
||||
|
||||
private:
|
||||
void onSanNineLinerModifyRequest(const rti::core::SampleIdentity &cookie,
|
||||
const SanNineLinerModifyRequest &request) override final;
|
||||
|
||||
void onSanNineLinerRemoveRequest(const rti::core::SampleIdentity &cookie,
|
||||
const Core::RemoveElementRequest &request) override final;
|
||||
|
||||
private:
|
||||
QHash<int, ObjectSanNineLiner *> m_mapObjectSanNineLiner;
|
||||
|
||||
std::shared_ptr<DdsHandler> m_ddsHandler;
|
||||
std::shared_ptr<DatabaseInterface> m_db;
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
} // Namespace Evaluations
|
||||
Executable
+98
@@ -0,0 +1,98 @@
|
||||
/**
|
||||
* Initialization for AssetManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "initialization.h"
|
||||
#include "settings.h"
|
||||
#include "handler_criterium.h"
|
||||
#include "handler_comment.h"
|
||||
#include "handler_san_nine_liner.h"
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <ngldb/db_service_handler.h>
|
||||
#include <DDS/Core/pacemaker.h>
|
||||
|
||||
namespace Evaluations
|
||||
{
|
||||
|
||||
Initialization::Initialization()
|
||||
: m_ddsHandler(nullptr)
|
||||
, m_dbHandler(nullptr)
|
||||
, m_handlerCriterium(nullptr)
|
||||
, m_handlerComment(nullptr)
|
||||
, m_logger(getLogger("Initialization"))
|
||||
{}
|
||||
|
||||
Initialization::~Initialization()
|
||||
{
|
||||
m_handlerComment = nullptr;
|
||||
m_handlerCriterium = nullptr;
|
||||
m_ddsHandler = nullptr;
|
||||
m_dbHandler = nullptr;
|
||||
}
|
||||
|
||||
bool Initialization::initialize(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector,
|
||||
const QSqlDatabase &sqlDb)
|
||||
{
|
||||
INFO_LOG(m_logger) << "Start Evaluations Initialization.";
|
||||
|
||||
// initialize DDS
|
||||
m_ddsHandler = std::make_shared<DdsHandler>(ddsConnector);
|
||||
if (!m_ddsHandler->init())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Initialisation ddsHandler failed.";
|
||||
return false;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "Initialisation ddsHandler succesful.";
|
||||
|
||||
|
||||
// initialize database
|
||||
m_dbHandler = std::make_shared<DbHandler>();
|
||||
if (!m_dbHandler->init(ddsConnector->getPartitionId(), sqlDb))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Initialisation dbHandler failed.";
|
||||
return false;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "Initialisation dbHandler succesful.";
|
||||
|
||||
|
||||
// HandlerCriterium
|
||||
m_handlerCriterium.reset(new HandlerCriterium(m_ddsHandler, m_dbHandler->db()));
|
||||
|
||||
// HandlerComment
|
||||
m_handlerComment.reset(new HandlerComment(m_ddsHandler, m_dbHandler->db()));
|
||||
|
||||
// HandlerNineLiner
|
||||
m_handlerSanNineLiner.reset(new HandlerSanNineLiner(m_ddsHandler, m_dbHandler->db()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Initialization::loadFromDatabase()
|
||||
{
|
||||
if (!m_ddsHandler || !m_dbHandler || !m_handlerCriterium || !m_handlerComment || !m_handlerSanNineLiner)
|
||||
return false;
|
||||
if (!m_handlerCriterium->init())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Initialisation HandlerCriterium failed.";
|
||||
return false;
|
||||
}
|
||||
if (!m_handlerComment->init())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Initialisation HandlerComment failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_handlerSanNineLiner->init())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Initialisation HandlerSanNineLiner failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace Evaluations
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* MainHandler for AereaEffectSimulation
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <ngldb/db_service_handler.h>
|
||||
#include <Evaluations/evl_export.h>
|
||||
#include <Evaluations/logger.h>
|
||||
|
||||
class QSqlDatabase;
|
||||
namespace Evaluations
|
||||
{
|
||||
class DdsHandler;
|
||||
class DatabaseInterface;
|
||||
class HandlerCriterium;
|
||||
class HandlerComment;
|
||||
class HandlerSanNineLiner;
|
||||
using DbHandler = NGLDB::DbServiceHandler<DatabaseInterface>;
|
||||
|
||||
class EVL_SERVER_EXPORT Initialization
|
||||
{
|
||||
public:
|
||||
Initialization();
|
||||
~Initialization();
|
||||
|
||||
bool initialize(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector, const QSqlDatabase &sqlDb);
|
||||
bool loadFromDatabase();
|
||||
|
||||
private:
|
||||
std::shared_ptr<DdsHandler> m_ddsHandler;
|
||||
std::shared_ptr<DbHandler> m_dbHandler;
|
||||
std::unique_ptr<HandlerCriterium> m_handlerCriterium;
|
||||
std::unique_ptr<HandlerComment> m_handlerComment;
|
||||
std::unique_ptr<HandlerSanNineLiner> m_handlerSanNineLiner;
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
};
|
||||
} // namespace Evaluations
|
||||
Executable
+37
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Building Config - logging facility
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
namespace Evaluations
|
||||
{
|
||||
|
||||
LOGGER_T getLogger(const char *name)
|
||||
{
|
||||
static const char ns[] = "EVL.";
|
||||
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 Evaluations
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Logging for Evaluations
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
#include "evl_export.h"
|
||||
|
||||
namespace Evaluations
|
||||
{
|
||||
using LOGGER_T = NGL::INGLLogger &;
|
||||
|
||||
EVL_COMMON_EXPORT LOGGER_T getLogger(const char *name);
|
||||
inline LOGGER_T getLogger(const QString &loggerName)
|
||||
{
|
||||
return getLogger(loggerName.toUtf8().constData());
|
||||
}
|
||||
} // namespace Evaluations
|
||||
Executable
+143
@@ -0,0 +1,143 @@
|
||||
/**
|
||||
* Handler for the HMI language
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "object_comment.h"
|
||||
|
||||
namespace Evaluations
|
||||
{
|
||||
ObjectComment::ObjectComment(const std::shared_ptr<DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<DatabaseInterface> &db)
|
||||
: m_ddsHandler(ddsHandler)
|
||||
, m_db(db)
|
||||
, m_logger(getLogger("ObjectComment"))
|
||||
{
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectComment::createObject(const Database::EvlComment &data)
|
||||
{
|
||||
m_data = data;
|
||||
if (m_data.id <= 0)
|
||||
{
|
||||
if (!m_db->insert(m_data))
|
||||
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting EvlComment-data into database"));
|
||||
}
|
||||
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectComment::updateObject(const Database::EvlComment &data)
|
||||
{
|
||||
if (!m_db->update(data))
|
||||
return Core::FunctionReplyObject(data.id, tr_lts("dds", "Error updating EvlComment-data into database"));
|
||||
|
||||
m_data = data;
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectComment::removeObject()
|
||||
{
|
||||
if (!m_db->removeEvlComment(m_data.id))
|
||||
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "EvlComment with id %1 can not be removed")).arg(m_data.id);
|
||||
|
||||
m_ddsHandler->dts()->removeEvaluationCommentByKey(m_data.id);
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
void ObjectComment::onPublishData()
|
||||
{
|
||||
Evaluations::EvaluationComment ddsData;
|
||||
|
||||
ddsData.id(m_data.id);
|
||||
ddsData.ts(m_data.ts.toMSecsSinceEpoch());
|
||||
ddsData.senderOperatorId(m_data.senderOperatorId);
|
||||
if (!m_data.receiverOperatorId.isNull())
|
||||
ddsData.receiverOperatorId(m_data.receiverOperatorId.toUInt());
|
||||
ddsData.text(m_data.text.toStdString());
|
||||
ddsData.hierarchy(m_data.hierarchy.toStdString());
|
||||
ddsData.schemaId(m_data.schemaId);
|
||||
ddsData.elementId(m_data.elementId);
|
||||
|
||||
INFO_LOG(m_logger) << "Publish EvlComment-data to dds (" << m_data.id << ") ...";
|
||||
|
||||
if (!m_ddsHandler->dts()->publish(ddsData))
|
||||
ERROR_LOG(m_logger) << "Error publishing EvlComment-data to dds";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ObjectSchema::ObjectSchema(const std::shared_ptr<DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<DatabaseInterface> &db)
|
||||
: m_ddsHandler(ddsHandler)
|
||||
, m_db(db)
|
||||
, m_logger(getLogger("ObjectSchema"))
|
||||
{
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectSchema::createObject(const Database::EvlSchema &data)
|
||||
{
|
||||
bool originOc = false;
|
||||
m_data = data;
|
||||
if (m_data.id <= 0)
|
||||
{
|
||||
if (m_data.id < 0)
|
||||
{
|
||||
originOc = true;
|
||||
m_data.id = std::abs(data.id); // change to positive for oc-laptop
|
||||
}
|
||||
|
||||
if (!m_db->insert(m_data))
|
||||
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting EvlSchema-data into database"));
|
||||
}
|
||||
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject((originOc) ? (m_data.id * -1) : (m_data.id));
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectSchema::updateObject(const Database::EvlSchema &data)
|
||||
{
|
||||
Database::EvlSchema tmpData = data;
|
||||
tmpData.id = std::abs(data.id);
|
||||
|
||||
if (!m_db->update(tmpData))
|
||||
return Core::FunctionReplyObject(data.id, tr_lts("dds", "Error updating EvlSchema-data into database"));
|
||||
|
||||
m_data = tmpData;
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(data.id);
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectSchema::removeObject()
|
||||
{
|
||||
if (!m_db->removeEvlSchema(m_data.id))
|
||||
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "EvlSchema with id %1 can not be removed")).arg(m_data.id);
|
||||
|
||||
m_ddsHandler->dts()->removeEvaluationSchemaByKey(m_data.id);
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
void ObjectSchema::onPublishData()
|
||||
{
|
||||
Evaluations::EvaluationSchema ddsData;
|
||||
|
||||
ddsData.id(m_data.id);
|
||||
ddsData.schemadata(m_data.schemadata.toStdString());
|
||||
ddsData.sendToTa(m_data.sendToTa);
|
||||
|
||||
INFO_LOG(m_logger) << "Publish EvlSchema-data to dds (id = " << m_data.id << ", send to training area = " << m_data.sendToTa << ") ...";
|
||||
|
||||
if (!m_ddsHandler->dts()->publish(ddsData))
|
||||
ERROR_LOG(m_logger) << "Error publishing EvlSchema-data to dds";
|
||||
}
|
||||
} // Namespace Evaluations
|
||||
Executable
+67
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* Exercise object
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* Philipp Last
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "dds_handler.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include <DDS/Core/function_reply_object.h>
|
||||
|
||||
// Generated
|
||||
#include <Evaluations/evl_db.h>
|
||||
|
||||
|
||||
namespace Evaluations
|
||||
{
|
||||
class ObjectComment final
|
||||
{
|
||||
public:
|
||||
ObjectComment(const std::shared_ptr<DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<DatabaseInterface> &db);
|
||||
~ObjectComment() = default;
|
||||
|
||||
Core::FunctionReplyObject createObject(const Database::EvlComment &data);
|
||||
Core::FunctionReplyObject updateObject(const Database::EvlComment &data);
|
||||
Core::FunctionReplyObject removeObject();
|
||||
|
||||
int getId() const { return m_data.id; }
|
||||
|
||||
protected:
|
||||
void onPublishData();
|
||||
|
||||
private:
|
||||
std::shared_ptr<DdsHandler> m_ddsHandler;
|
||||
std::shared_ptr<DatabaseInterface> m_db;
|
||||
Database::EvlComment m_data;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
class ObjectSchema final
|
||||
{
|
||||
public:
|
||||
ObjectSchema(const std::shared_ptr<DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<DatabaseInterface> &db);
|
||||
~ObjectSchema() = default;
|
||||
|
||||
Core::FunctionReplyObject createObject(const Database::EvlSchema &data);
|
||||
Core::FunctionReplyObject updateObject(const Database::EvlSchema &data);
|
||||
Core::FunctionReplyObject removeObject();
|
||||
|
||||
int getId() const { return m_data.id; }
|
||||
|
||||
protected:
|
||||
void onPublishData();
|
||||
|
||||
private:
|
||||
std::shared_ptr<DdsHandler> m_ddsHandler;
|
||||
std::shared_ptr<DatabaseInterface> m_db;
|
||||
Database::EvlSchema m_data;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* Handler for the HMI language
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "object_criterium.h"
|
||||
#include "object_evaluation_element.h"
|
||||
|
||||
namespace Evaluations
|
||||
{
|
||||
|
||||
ObjectCriterium::ObjectCriterium(const std::shared_ptr<DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<DatabaseInterface> &db)
|
||||
: m_ddsHandler(ddsHandler)
|
||||
, m_db(db)
|
||||
, m_logger(getLogger("ObjectCriterium"))
|
||||
{
|
||||
}
|
||||
|
||||
ObjectCriterium::~ObjectCriterium()
|
||||
{
|
||||
qDeleteAll(m_elementsMap);
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectCriterium::createObject(const Database::EvlCriterium &data)
|
||||
{
|
||||
m_data = data;
|
||||
if (m_data.id <= 0)
|
||||
{
|
||||
if (!m_db->insert(m_data))
|
||||
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting EvlCriterium-data into database"));
|
||||
}
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectCriterium::updateObject(const Database::EvlCriterium &data)
|
||||
{
|
||||
if (!m_db->update(data))
|
||||
return Core::FunctionReplyObject(data.id, tr_lts("dds", "Error updating EvlCriterium-data into database"));
|
||||
|
||||
m_data = data;
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectCriterium::removeObject()
|
||||
{
|
||||
if (!m_db->removeEvlCriterium(m_data.id))
|
||||
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "EvlCriterium with id %1 can not be removed")).arg(m_data.id);
|
||||
|
||||
for (ObjectEvaluationElement *oee : qAsConst(m_elementsMap))
|
||||
oee->removeObject();
|
||||
qDeleteAll(m_elementsMap);
|
||||
m_elementsMap.clear();
|
||||
|
||||
m_ddsHandler->dts()->removeEvaluationCriteriumByKey(m_data.id);
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
void ObjectCriterium::onPublishData()
|
||||
{
|
||||
Evaluations::EvaluationCriterium ddsData;
|
||||
|
||||
ddsData.id(m_data.id);
|
||||
ddsData.name(m_data.name.toStdString());
|
||||
ddsData.description(m_data.description.toStdString());
|
||||
ddsData.operatorId(m_data.operatorId);
|
||||
|
||||
INFO_LOG(m_logger) << "Publish EvlCriterium-data to dds (" << m_data.id << ") ...";
|
||||
|
||||
if (!m_ddsHandler->dts()->publish(ddsData))
|
||||
ERROR_LOG(m_logger) << "Error publishing EvlCriterium-data to dds";
|
||||
}
|
||||
|
||||
void ObjectCriterium::addElement(ObjectEvaluationElement *oee)
|
||||
{
|
||||
m_elementsMap.insert(oee->getId(), oee);
|
||||
}
|
||||
|
||||
} // Namespace Evaluations
|
||||
Executable
+50
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Exercise object
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "dds_handler.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include <DDS/Core/function_reply_object.h>
|
||||
|
||||
// Generated
|
||||
#include <Evaluations/evl_db.h>
|
||||
|
||||
|
||||
namespace Evaluations
|
||||
{
|
||||
class ObjectEvaluationElement;
|
||||
class ObjectCriterium final
|
||||
{
|
||||
public:
|
||||
explicit ObjectCriterium(const std::shared_ptr<DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<DatabaseInterface> &db);
|
||||
~ObjectCriterium();
|
||||
|
||||
Core::FunctionReplyObject createObject(const Database::EvlCriterium &data);
|
||||
Core::FunctionReplyObject updateObject(const Database::EvlCriterium &data);
|
||||
Core::FunctionReplyObject removeObject();
|
||||
|
||||
ObjectEvaluationElement *getElement(int id) const { return m_elementsMap.value(id);}
|
||||
void addElement(ObjectEvaluationElement *oee);
|
||||
void removeElement(int id) { m_elementsMap.remove(id);}
|
||||
|
||||
int getId() const { return m_data.id; }
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onPublishData();
|
||||
|
||||
private:
|
||||
std::shared_ptr<DdsHandler> m_ddsHandler;
|
||||
std::shared_ptr<DatabaseInterface> m_db;
|
||||
Database::EvlCriterium m_data;
|
||||
QHash<qint32, ObjectEvaluationElement *> m_elementsMap;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
};
|
||||
}
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* Handler for the HMI language
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "object_evaluation_element.h"
|
||||
|
||||
namespace Evaluations
|
||||
{
|
||||
|
||||
ObjectEvaluationElement::ObjectEvaluationElement(const std::shared_ptr<DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<DatabaseInterface> &db)
|
||||
: m_ddsHandler(ddsHandler)
|
||||
, m_db(db)
|
||||
, m_logger(getLogger("ObjectEvaluationElement"))
|
||||
{
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectEvaluationElement::createObject(const Database::EvlElement &data)
|
||||
{
|
||||
m_data = data;
|
||||
|
||||
if (m_data.id <= 0)
|
||||
{
|
||||
if (!m_db->insert(m_data))
|
||||
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting EvlElement-data into database"));
|
||||
}
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectEvaluationElement::updateObject(const Database::EvlElement &data)
|
||||
{
|
||||
if (!m_db->update(data))
|
||||
return Core::FunctionReplyObject(data.id, tr_lts("dds", "Error updating EvlElement-data into database"));
|
||||
|
||||
m_data = data;
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectEvaluationElement::removeObject()
|
||||
{
|
||||
if (!m_db->removeEvlElement(m_data.id))
|
||||
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "Error removing EvlElement-data into database"));
|
||||
|
||||
m_ddsHandler->dts()->removeEvaluationElementByKey(m_data.id);
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
void ObjectEvaluationElement::onPublishData()
|
||||
{
|
||||
Evaluations::EvaluationElement ddsData;
|
||||
|
||||
ddsData.id(m_data.id);
|
||||
ddsData.criteriumId(m_data.criteriumId);
|
||||
ddsData.phaseId(m_data.phaseId);
|
||||
ddsData.duration(m_data.duration);
|
||||
ddsData.situation(!m_data.situationContent.isNull());
|
||||
ddsData.video(!m_data.videoContent.isNull());
|
||||
ddsData.audio(!m_data.audioContent.isNull());
|
||||
ddsData.note(m_data.note.toStdString());
|
||||
ddsData.rating(m_data.rating);
|
||||
ddsData.timestamp(m_data.time);
|
||||
|
||||
if (!m_data.audioContent.isNull())
|
||||
ddsData.audioContent(m_data.audioContent.toString().toStdString());
|
||||
if (!m_data.videoContent.isNull())
|
||||
ddsData.videoContent(m_data.videoContent.toString().toStdString());
|
||||
if (!m_data.situationContent.isNull())
|
||||
ddsData.situationContent(m_data.situationContent.toString().toStdString());
|
||||
|
||||
INFO_LOG(m_logger) << "Publish EvlElement-data to dds (" << m_data.id << ") ...";
|
||||
|
||||
if (!m_ddsHandler->dts()->publish(ddsData))
|
||||
ERROR_LOG(m_logger) << "Error publishing EvlEvaluationElement-data to dds";
|
||||
}
|
||||
|
||||
} // Namespace Evaluations
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Exercise object
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "dds_handler.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include <DDS/Core/function_reply_object.h>
|
||||
|
||||
// Generated
|
||||
#include <Evaluations/evl_db.h>
|
||||
|
||||
|
||||
namespace Evaluations
|
||||
{
|
||||
|
||||
class ObjectEvaluationElement final
|
||||
{
|
||||
public:
|
||||
explicit ObjectEvaluationElement(const std::shared_ptr<DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<DatabaseInterface> &db);
|
||||
~ObjectEvaluationElement() = default;
|
||||
|
||||
Core::FunctionReplyObject createObject(const Database::EvlElement &data);
|
||||
Core::FunctionReplyObject updateObject(const Database::EvlElement &data);
|
||||
Core::FunctionReplyObject removeObject();
|
||||
|
||||
int getId() const { return m_data.id; }
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onPublishData();
|
||||
|
||||
private:
|
||||
std::shared_ptr<DdsHandler> m_ddsHandler;
|
||||
std::shared_ptr<DatabaseInterface> m_db;
|
||||
Database::EvlElement m_data;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
};
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Handler for the HMI language
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "object_san_category_line.h"
|
||||
|
||||
namespace Evaluations
|
||||
{
|
||||
ObjectSanCategoryLine::ObjectSanCategoryLine(const std::shared_ptr<DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<DatabaseInterface> &db)
|
||||
: m_ddsHandler(ddsHandler)
|
||||
, m_db(db)
|
||||
, m_logger(getLogger("ObjectSanCategoryLine"))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Core::FunctionReplyObject ObjectSanCategoryLine::createObject(const Database::SanCategoryLine &data)
|
||||
{
|
||||
INFO_LOG(m_logger) << "SanCategoryLine: nineLiner: " << data.nineLinerId << " line: " << data.line << ", amount: " << data.amount << ", category: " << data.category;
|
||||
m_data = data;
|
||||
if (m_data.id <= 0)
|
||||
{
|
||||
if (!m_db->insert(m_data))
|
||||
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting SanCategoryLine-data into database"));
|
||||
}
|
||||
|
||||
INFO_LOG(m_logger) << "New data id: " << m_data.id;
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectSanCategoryLine::updateObject(const Database::SanCategoryLine &data)
|
||||
{
|
||||
if (!m_db->update(data))
|
||||
return Core::FunctionReplyObject(data.id, tr_lts("dds", "Error updating SanCategoryLine-data into database"));
|
||||
|
||||
m_data = data;
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectSanCategoryLine::removeObject()
|
||||
{
|
||||
if (!m_db->removeSanCategoryLine(m_data.id))
|
||||
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "SanCategoryLine with id %1 can not be removed")).arg(m_data.id);
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
} // Namespace Evaluations
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* Exercise object
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* Philipp Last
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "dds_handler.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include <DDS/Core/function_reply_object.h>
|
||||
|
||||
// Generated
|
||||
#include <Evaluations/evl_db.h>
|
||||
|
||||
|
||||
namespace Evaluations
|
||||
{
|
||||
class ObjectSanCategoryLine final
|
||||
{
|
||||
public:
|
||||
ObjectSanCategoryLine(const std::shared_ptr<DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<DatabaseInterface> &db);
|
||||
~ObjectSanCategoryLine() = default;
|
||||
|
||||
Core::FunctionReplyObject createObject(const Database::SanCategoryLine &data);
|
||||
Core::FunctionReplyObject updateObject(const Database::SanCategoryLine &data);
|
||||
Core::FunctionReplyObject removeObject();
|
||||
|
||||
int getId() const { return m_data.id; }
|
||||
|
||||
protected:
|
||||
void onPublishData();
|
||||
|
||||
private:
|
||||
std::shared_ptr<DdsHandler> m_ddsHandler;
|
||||
std::shared_ptr<DatabaseInterface> m_db;
|
||||
Database::SanCategoryLine m_data;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
* Handler for the HMI language
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "object_san_nine_liner.h"
|
||||
#include "san_category_line_json.h"
|
||||
|
||||
namespace Evaluations
|
||||
{
|
||||
ObjectSanNineLiner::ObjectSanNineLiner(const std::shared_ptr<DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<DatabaseInterface> &db)
|
||||
: m_ddsHandler(ddsHandler)
|
||||
, m_db(db)
|
||||
, m_logger(getLogger("ObjectSanNineLiner"))
|
||||
{
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectSanNineLiner::createObject(const Database::SanNineLiner &data)
|
||||
{
|
||||
m_data = data;
|
||||
if (m_data.id <= 0)
|
||||
{
|
||||
if (!m_db->insert(m_data))
|
||||
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting ObjSanNineLiner-data into database"));
|
||||
}
|
||||
|
||||
// done in handler
|
||||
//onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectSanNineLiner::updateObject(const Database::SanNineLiner &data)
|
||||
{
|
||||
if (!m_db->update(data))
|
||||
return Core::FunctionReplyObject(data.id, tr_lts("dds", "Error updating EvlComment-data into database"));
|
||||
|
||||
m_data = data;
|
||||
|
||||
// done in handler
|
||||
//onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectSanNineLiner::removeObject()
|
||||
{
|
||||
if (!m_db->removeSanNineLiner(m_data.id))
|
||||
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "EvlComment with id %1 can not be removed")).arg(m_data.id);
|
||||
|
||||
m_ddsHandler->dts()->removeSanNineLinerByKey(m_data.id);
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
void ObjectSanNineLiner::addLineCategory(const Database::SanCategoryLine &data)
|
||||
{
|
||||
m_lines.push_back(std::move(data));
|
||||
}
|
||||
|
||||
void ObjectSanNineLiner::removeCategoryLines()
|
||||
{
|
||||
m_lines.clear();
|
||||
}
|
||||
|
||||
void ObjectSanNineLiner::onPublishData()
|
||||
{
|
||||
Evaluations::SanNineLiner ddsData;
|
||||
|
||||
ddsData.id(m_data.id);
|
||||
ddsData.lastModified(m_data.lastModified);
|
||||
ddsData.line1_position(Core::GeoPosition2D(m_data.position.x(), m_data.position.y()));
|
||||
ddsData.line2_RadioFrequencyCallSignSuffix(m_data.radioFrequencySuffixCallsign.toStdString());
|
||||
|
||||
QJsonDocument doc = SanCategoryLine::toJson(m_lines);
|
||||
ddsData.lines(QString::fromUtf8(doc.toJson(QJsonDocument::Compact)).toStdString());
|
||||
|
||||
INFO_LOG(m_logger) << "Publish SanNineLiner-data to dds (" << m_data.id << ") other lines: " << ddsData.lines();
|
||||
|
||||
if (!m_ddsHandler->dts()->publish(ddsData))
|
||||
ERROR_LOG(m_logger) << "Error publishing SanNineLiner-data to dds";
|
||||
}
|
||||
|
||||
} // Namespace Evaluations
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Exercise object
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* Philipp Last
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "dds_handler.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include <DDS/Core/function_reply_object.h>
|
||||
|
||||
// Generated
|
||||
#include <Evaluations/evl_db.h>
|
||||
|
||||
|
||||
namespace Evaluations
|
||||
{
|
||||
class ObjectSanNineLiner final
|
||||
{
|
||||
public:
|
||||
ObjectSanNineLiner(const std::shared_ptr<DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<DatabaseInterface> &db);
|
||||
~ObjectSanNineLiner() = default;
|
||||
|
||||
Core::FunctionReplyObject createObject(const Database::SanNineLiner &data);
|
||||
Core::FunctionReplyObject updateObject(const Database::SanNineLiner &data);
|
||||
Core::FunctionReplyObject removeObject();
|
||||
|
||||
int getId() const { return m_data.id; }
|
||||
void addLineCategory(const Database::SanCategoryLine &data);
|
||||
void removeCategoryLines();
|
||||
|
||||
void onPublishData();
|
||||
protected:
|
||||
|
||||
private:
|
||||
std::shared_ptr<DdsHandler> m_ddsHandler;
|
||||
std::shared_ptr<DatabaseInterface> m_db;
|
||||
Database::SanNineLiner m_data;
|
||||
std::vector<Database::SanCategoryLine> m_lines;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
}
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hanna E. Rathje, NLE, 12.05.2020
|
||||
*/
|
||||
|
||||
#include "san_category_line_json.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QDebug>
|
||||
|
||||
namespace Evaluations
|
||||
{
|
||||
|
||||
SanCategoryLine::SanCategoryLine()
|
||||
: m_logger(getLogger("ObjectSanCategoryLine"))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QVector<Database::SanCategoryLine> SanCategoryLine::fromJson(const std::string &line, int nineLinerId)
|
||||
{
|
||||
QJsonParseError jError;
|
||||
QJsonDocument doc(QJsonDocument::fromJson(QByteArray::fromStdString(line), &jError));
|
||||
if (jError.error)
|
||||
{
|
||||
//ERROR_LOG(m_logger) << "Can not parse json document: " << jError.errorString();
|
||||
return QVector<Database::SanCategoryLine>();
|
||||
}
|
||||
|
||||
const QJsonObject rootObj = doc.object();
|
||||
const QJsonArray arrCategoryLines(rootObj[QStringLiteral("categoryLines")].toArray());
|
||||
//INFO_LOG(m_logger) << "Lines: " << arrCategoryLines.count();
|
||||
|
||||
QVector<Database::SanCategoryLine> categoryLines;
|
||||
categoryLines.reserve(arrCategoryLines.size());
|
||||
|
||||
for (const auto &val : arrCategoryLines)
|
||||
{
|
||||
const QJsonObject obj = val.toObject();
|
||||
Database::SanCategoryLine cl;
|
||||
cl.id = obj[QStringLiteral("id")].toInt();
|
||||
cl.line = obj[QStringLiteral("line")].toInt();
|
||||
cl.amount = obj[QStringLiteral("amount")].toInt();
|
||||
cl.category = obj[QStringLiteral("category")].toString();
|
||||
cl.nineLinerId = nineLinerId;
|
||||
categoryLines.append(cl);
|
||||
}
|
||||
|
||||
return categoryLines;
|
||||
}
|
||||
|
||||
QJsonDocument SanCategoryLine::toJson(std::vector<Database::SanCategoryLine> vecCategoryLines)
|
||||
{
|
||||
QJsonArray arr;
|
||||
for (const Database::SanCategoryLine &cl : qAsConst(vecCategoryLines))
|
||||
{
|
||||
QJsonObject obj;
|
||||
obj[QStringLiteral("id")] = cl.id;
|
||||
obj[QStringLiteral("line")] = cl.line;
|
||||
obj[QStringLiteral("amount")] = cl.amount;
|
||||
obj[QStringLiteral("category")] = cl.category;
|
||||
|
||||
//INFO_LOG(m_logger) << "toJsonDocument: id: " << cl.id << ", line: " << cl.line << ", amount: " << cl.amount << ", category: " << cl.category;
|
||||
arr.append(obj);
|
||||
}
|
||||
|
||||
QJsonObject objArray;
|
||||
objArray[QStringLiteral("categoryLines")] = arr;
|
||||
QJsonDocument doc(objArray);
|
||||
|
||||
return doc;
|
||||
}
|
||||
|
||||
} // Namespace Evaluations
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <Evaluations/evl_db_structs.h>
|
||||
|
||||
namespace Evaluations
|
||||
{
|
||||
class EVL_COMMON_EXPORT SanCategoryLine
|
||||
{
|
||||
public:
|
||||
SanCategoryLine();
|
||||
~SanCategoryLine() = default;
|
||||
|
||||
public:
|
||||
static QVector<Database::SanCategoryLine> fromJson(const std::string &line, int nineLinerId);
|
||||
static QJsonDocument toJson(std::vector<Database::SanCategoryLine> vecCategoryLines);
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
}
|
||||
Executable
+49
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* Settings for Evaluations
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "settings.h"
|
||||
|
||||
#include <QtCore/QSettings>
|
||||
#include <nglsettings/nglsettings_settings.h>
|
||||
#include <ngltools/ngltools_filesystem.h>
|
||||
|
||||
namespace Evaluations
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
QString Settings::defaultSchema()
|
||||
{
|
||||
QString strJsonSchema = QStringLiteral("[ { \"id\": 1, \"parentId\": 0, \"state\": 0, \"text\": \"<%1>\"} ]").arg(QStringLiteral("folder name"));
|
||||
return s()->settings()->value(QStringLiteral("EVL/defaultSchema"), strJsonSchema).toString();
|
||||
}
|
||||
|
||||
} // namespace Evaluations
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Settings for Evaluations
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <QString>
|
||||
#include <Evaluations/evl_export.h>
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class Settings;
|
||||
}
|
||||
|
||||
namespace Evaluations
|
||||
{
|
||||
namespace Settings
|
||||
{
|
||||
NGL::Settings *settings();
|
||||
EVL_SERVER_EXPORT void setIniFile(const QString &ini);
|
||||
QString defaultSchema();
|
||||
}
|
||||
|
||||
} // namespace Evaluations
|
||||
Reference in new issue
Block a user