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
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/QJsonObject>
|
||||
|
||||
#include <LtsWebSocket/client_message_factory.h>
|
||||
#include <LtsWebSocket/client_message.h>
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
namespace WebSocketInterface
|
||||
{
|
||||
class DataManager;
|
||||
|
||||
namespace Messages
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief The ClientMessageFactory class creates ClientMessages which will then be processed
|
||||
*/
|
||||
class ClientMessageFactory final : public LtsWebSocket::AbstractClientMessageFactory
|
||||
{
|
||||
public:
|
||||
explicit ClientMessageFactory(DataManager *dataManager);
|
||||
|
||||
/**
|
||||
* @brief create Only way to create a ClientMessage object
|
||||
* @param message Text message which will be converted to a ClientMessage object
|
||||
* @return A ClientMessage object, which represents a concrete ClientMessage
|
||||
*/
|
||||
LtsWebSocket::AbstractClientMessage *createMessage(LtsWebSocket::ReplyHandler *client,
|
||||
const QString &message);
|
||||
|
||||
private:
|
||||
DataManager *m_dataManager;
|
||||
|
||||
}; // class ClientMessageFactory
|
||||
|
||||
/**
|
||||
* @brief The ClientMessage class is an abstract base class for concrete ClientMessage objects
|
||||
*/
|
||||
class ClientMessage : public LtsWebSocket::AbstractClientMessage
|
||||
{
|
||||
protected: // method
|
||||
explicit ClientMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonObject &data = QJsonObject());
|
||||
|
||||
protected: // attributes
|
||||
DataManager *m_dataManager;
|
||||
}; // class ClientMessage
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief The PartyRequest class handles the party DL request and sends multiple all party data for the exercise
|
||||
*/
|
||||
class PartyRequest : public ClientMessage
|
||||
{
|
||||
public:
|
||||
explicit PartyRequest(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid);
|
||||
|
||||
void process();
|
||||
bool hasValidData() const;
|
||||
}; // class BaseDlRequest
|
||||
|
||||
/**
|
||||
* @brief The BaseDlRequest class handles the base DL request and sends multiple replys depending on the data requested
|
||||
*/
|
||||
class BaseDlRequest : public ClientMessage
|
||||
{
|
||||
public:
|
||||
explicit BaseDlRequest(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid);
|
||||
|
||||
void process();
|
||||
bool hasValidData() const;
|
||||
}; // class BaseDlRequest
|
||||
/**
|
||||
* @brief The BaseDlRequest class handles the base DL request and sends multiple replys depending on the data requested
|
||||
*/
|
||||
class OcPositionRequest : public ClientMessage
|
||||
{
|
||||
public:
|
||||
explicit OcPositionRequest(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonObject &data);
|
||||
|
||||
void process();
|
||||
bool hasValidData() const;
|
||||
private:
|
||||
int m_equipmentNr = 0;
|
||||
|
||||
}; // class BaseDlRequest
|
||||
|
||||
} // namespace Messages
|
||||
} // namespace WebSocketInterface
|
||||
} // namespace ParticipantManagement
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The ReplyMessage class is an abstract base class for all possible messages which are sent to the client
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLST, 2017-12-05
|
||||
*/
|
||||
#include "reply_message.h"
|
||||
|
||||
#include <LtsWebSocket/json_keys.h>
|
||||
#include "WebSocketInterface/json_keys.h"
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
namespace WebSocketInterface
|
||||
{
|
||||
namespace Messages
|
||||
{
|
||||
using namespace JsonKeys;
|
||||
using namespace LtsWebSocket::JsonKeys;
|
||||
|
||||
// ####### EquipmentTypeBaseData begin #######
|
||||
EquipmentTypeBaseData::EquipmentTypeBaseData(const QJsonArray &data, const QString &uuid)
|
||||
: LtsWebSocket::ReplyMessage (EQUIPMENT_TYPE_BASE_DATA(), 1, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(DATA(), data);
|
||||
}
|
||||
// ####### EquipmentTypeBaseData end #######
|
||||
|
||||
// ####### TypeBaseData begin #######
|
||||
TypeBaseData::TypeBaseData(const QJsonArray &data, const QString &uuid)
|
||||
: LtsWebSocket::ReplyMessage (TYPE_BASE_DATA(), 2, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(DATA(), data);
|
||||
}
|
||||
// ####### TypeBaseData end #######
|
||||
|
||||
// ####### PartyBaseData begin #######
|
||||
/********************************************************
|
||||
* Warning: 6006 has been negotiated with ESG for ADLER *
|
||||
********************************************************/
|
||||
PartyBaseData::PartyBaseData(const QJsonArray &data, const QString &uuid)
|
||||
: LtsWebSocket::ReplyMessage (PARTY_BASE_DATA(), 6006, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(DATA(), data);
|
||||
}
|
||||
// ####### PartyBaseData end #######
|
||||
|
||||
// ####### ParticipantBaseData begin #######
|
||||
ParticipantBaseData::ParticipantBaseData(const QJsonArray &data, const QString &uuid)
|
||||
: LtsWebSocket::ReplyMessage (PARTICIPANT_BASE_DATA(), 4, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(DATA(), data);
|
||||
}
|
||||
|
||||
OcPositionData::OcPositionData(const QJsonObject &data, const QString &uuid)
|
||||
: LtsWebSocket::ReplyMessage (OC_POSITION_DATA(), 5, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(DATA(), data);
|
||||
}
|
||||
|
||||
// ####### ParticipantBaseData end #######
|
||||
|
||||
} // namespace Messages
|
||||
} // namespace WebSocketInterface
|
||||
} // namespace ParticipantManagement
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The ReplyMessage class is an abstract base class for all possible messages which are sent to the client
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLST, 2017-12-05
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <LtsWebSocket/reply_message.h>
|
||||
|
||||
#include <QJsonArray>
|
||||
#include <QString>
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
namespace WebSocketInterface
|
||||
{
|
||||
namespace Messages
|
||||
{
|
||||
/**
|
||||
* @brief The EquipmentTypeBaseData class equipment type data for base DL
|
||||
*/
|
||||
class EquipmentTypeBaseData : public LtsWebSocket::ReplyMessage
|
||||
{
|
||||
public:
|
||||
explicit EquipmentTypeBaseData(const QJsonArray &data, const QString &uuid);
|
||||
}; // class EquipmentTypeBaseData
|
||||
|
||||
/**
|
||||
* @brief The TypeBaseData class type data for base DL
|
||||
*/
|
||||
class TypeBaseData : public LtsWebSocket::ReplyMessage
|
||||
{
|
||||
public:
|
||||
explicit TypeBaseData(const QJsonArray &data, const QString &uuid);
|
||||
}; // class TypeBaseData
|
||||
|
||||
/**
|
||||
* @brief The ParticipantTemplateBaseData class participant template data for base DL
|
||||
*/
|
||||
class ParticipantTemplateBaseData : public LtsWebSocket::ReplyMessage
|
||||
{
|
||||
public:
|
||||
explicit ParticipantTemplateBaseData(const QJsonArray &data, const QString &uuid);
|
||||
}; // class ParticipantTemplateBaseData
|
||||
|
||||
/**
|
||||
* @brief The PartyBaseData class party data for base DL
|
||||
*/
|
||||
class PartyBaseData : public LtsWebSocket::ReplyMessage
|
||||
{
|
||||
public:
|
||||
explicit PartyBaseData(const QJsonArray &data, const QString &uuid);
|
||||
}; // class PartyBaseData
|
||||
|
||||
/**
|
||||
* @brief The ParticipantOrganisationBaseData class participant organisation data for base DL
|
||||
*/
|
||||
class ParticipantOrganisationBaseData : public LtsWebSocket::ReplyMessage
|
||||
{
|
||||
public:
|
||||
explicit ParticipantOrganisationBaseData(const QJsonArray &data, const QString &uuid);
|
||||
}; // class ParticipantOrganisationBaseData
|
||||
|
||||
/**
|
||||
* @brief The ParticipantBaseData class participant data for base DL
|
||||
*/
|
||||
class ParticipantBaseData : public LtsWebSocket::ReplyMessage
|
||||
{
|
||||
public:
|
||||
explicit ParticipantBaseData(const QJsonArray &data, const QString &uuid);
|
||||
}; // class ParticipantBaseData
|
||||
|
||||
/**
|
||||
* @brief The ParticipantBaseData class participant data for base DL
|
||||
*/
|
||||
class OcPositionData : public LtsWebSocket::ReplyMessage
|
||||
{
|
||||
public:
|
||||
explicit OcPositionData(const QJsonObject &data, const QString &uuid);
|
||||
}; // class ParticipantBaseData
|
||||
|
||||
|
||||
} // namespace Messages
|
||||
} // namespace WebSocketInterface
|
||||
} // namespace ParticipantManagement
|
||||
|
||||
Reference in new issue
Block a user