Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+129
@@ -0,0 +1,129 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The ClientMessage class is an abstract base class for concrete ClientMessage objects
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLST, 2017-12-05
|
||||
*/
|
||||
#include "client_message.h"
|
||||
|
||||
#include "WebSocketInterface/Messages/reply_message.h"
|
||||
#include "WebSocketInterface/json_keys.h"
|
||||
#include "WebSocketInterface/data_manager.h"
|
||||
|
||||
#include <QtCore/QJsonDocument>
|
||||
#include <QtCore/QUuid>
|
||||
#include <QJsonObject>
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
namespace WebSocketInterface
|
||||
{
|
||||
namespace Messages
|
||||
{
|
||||
using namespace JsonKeys;
|
||||
|
||||
// ####### ClientMessageFactory begin #######
|
||||
ClientMessageFactory::ClientMessageFactory(DataManager *dataManager)
|
||||
: LtsWebSocket::AbstractClientMessageFactory(getLogger("ClientMessageFactory"))
|
||||
, m_dataManager(dataManager)
|
||||
{}
|
||||
|
||||
LtsWebSocket::AbstractClientMessage *ClientMessageFactory::createMessage(LtsWebSocket::ReplyHandler *client,
|
||||
const QString &message)
|
||||
{
|
||||
LtsWebSocket::AbstractClientMessage *result = checkAttributes(client, message);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
if (m_type == OcBaseDownload::WebSocketInterface::JsonKeys::BASE_DL_REQUEST())
|
||||
result = new BaseDlRequest(m_dataManager, client, m_type, m_typeId, m_uuid); // Todo: Check whether typeId is correct
|
||||
|
||||
if (m_type == ParticipantManagement::WebSocketInterface::JsonKeys::OC_POSITION_DATA()) // Todo: Check whether typeId is correct
|
||||
result = new OcPositionRequest(m_dataManager, client, m_type, m_typeId, m_uuid, QJsonDocument::fromJson(message.toUtf8()).object().value(QStringLiteral("data")).toObject() );
|
||||
|
||||
/********************************************************
|
||||
* Warning: 6006 has been negotiated with ESG for ADLER *
|
||||
********************************************************/
|
||||
if (m_type == ParticipantManagement::WebSocketInterface::JsonKeys::PARTY_BASE_DATA())
|
||||
result = new PartyRequest(m_dataManager, client, m_type, 6006, m_uuid); // Todo: Check whether typeId is correct
|
||||
|
||||
return checkResult(client, message, result);
|
||||
}
|
||||
// ####### ClientMessageFactory end #######
|
||||
|
||||
// ####### ClientMessage begin #######
|
||||
ClientMessage::ClientMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonObject &data)
|
||||
: LtsWebSocket::AbstractClientMessage(client, type, typeId, uuid, data)
|
||||
, m_dataManager(dataManager)
|
||||
{}
|
||||
// ####### ClientMessage end #######
|
||||
|
||||
// ####### PartyRequest begin #######
|
||||
PartyRequest::PartyRequest(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid)
|
||||
: ClientMessage(dataManager, client, type, typeId, uuid)
|
||||
{}
|
||||
|
||||
void PartyRequest::process()
|
||||
{
|
||||
m_client->addReply(m_dataManager->partyBaseData(m_uuid));
|
||||
}
|
||||
|
||||
bool PartyRequest::hasValidData() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ####### BaseDlRequest begin #######
|
||||
BaseDlRequest::BaseDlRequest(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid)
|
||||
: ClientMessage(dataManager, client, type, typeId, uuid)
|
||||
{}
|
||||
|
||||
void BaseDlRequest::process()
|
||||
{
|
||||
if (m_dataManager->exerciseId() == 0) // equipment type, type and participant template only in ex_0
|
||||
{
|
||||
m_client->addReply(m_dataManager->equipmentTypeBaseData(m_uuid));
|
||||
m_client->addReply(m_dataManager->typeBaseData(m_uuid));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_client->addReply(m_dataManager->partyBaseData(m_uuid));
|
||||
m_client->addReply(m_dataManager->participantBaseData(m_uuid));
|
||||
}
|
||||
}
|
||||
|
||||
bool BaseDlRequest::hasValidData() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
OcPositionRequest::OcPositionRequest(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonObject &data)
|
||||
: ClientMessage(dataManager, client, type, typeId, uuid, data )
|
||||
{
|
||||
const auto val = data.value(EQUIPMENT_NR());
|
||||
if (val.toInt() > 0)
|
||||
m_equipmentNr = val.toInt();
|
||||
|
||||
}
|
||||
|
||||
void OcPositionRequest::process()
|
||||
{
|
||||
if (m_dataManager->exerciseId() != 0) // equipment type, type and participant template only in ex_0
|
||||
{
|
||||
m_client->addReply(m_dataManager->ocPositionData(m_equipmentNr, m_uuid));
|
||||
}
|
||||
}
|
||||
|
||||
bool OcPositionRequest::hasValidData() const
|
||||
{
|
||||
return m_equipmentNr > 0;
|
||||
}
|
||||
|
||||
// ####### BaseDlRequest end #######
|
||||
|
||||
} // namespace Messages
|
||||
} // namespace WebSocketInterface
|
||||
} // namespace ParticipantManagement
|
||||
Reference in new issue
Block a user