/** * @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 #include "WebSocketInterface/json_keys.h" #include #include namespace ServiceManagement { namespace WebSocketInterface { namespace Messages { using namespace JsonKeys; using namespace LtsWebSocket::JsonKeys; // ####### ServicePortsInformationMessage begin ####### /******************************************************** * Warning: 6002 has been negotiated with ESG for ADLER * ********************************************************/ ServicePortsInformationMessage::ServicePortsInformationMessage(const QVector &data, const QString &uuid) : ReplyMessage (SERVICE_PORTS_INFORMATION(), 6002, uuid) // Todo check whether TypeID is correct. { QJsonArray exercises; for (const auto &exercise : data) { QJsonArray services; for (const auto &service : exercise.services) { QJsonArray ports; for (const auto &port : service.ports) { ports.append(QJsonObject({{NUMBER(),port.number}, {TYPE_ID(),port.type}, {PROPERTIES(), port.properties} })); } services.append(QJsonObject({{NAME(), service.name}, {NAME_ABBR(), service.abbreviation}, {PORTS(), ports} })); } QJsonObject obj({{EXERCISE_ID(), exercise.exerciseId}, {SERVICES(), services} }); if (exercise.replayPartitionId.is_set()) obj.insert(REPLAY_PARTITION_ID(), exercise.replayPartitionId.get()); exercises.append(obj); } m_jsonRepresentation.insert(DATA(), exercises); } // ####### ServicePortsInformationMessage end ####### } // namespace Messages } // namespace WebSocketInterface } // namespace ServiceManagement