Session 022: Migrate Lts/Tools (72 submodules) to Qt6
- Copied complete Lts/Tools directory from qt5-before to qt6-after - Updated 32 CMakeLists.txt files (Qt5:: → Qt6::) - Tools subdirectory already included in parent Lts/CMakeLists.txt - All 72 tool submodules now present in qt6-migrated-legatus - Includes: Adler, ArAssets, ConfigX, DBAdministration, DBUpdate, DdsView, InfrastructureManagement, and 67 more tools - C++17 standard (RTI 7.7.0 compatibility maintained) - Tests deferred until final validation phase Migration progress: ✅ Lts/Application (68 files) ✅ Lts/DDS (verified Qt6-ready) ✅ Lts/Plugins (60 submodules, verified) ✅ Lts/Projects (5 submodules, verified) ✅ Lts/Proxies (13 submodules, verified) ✅ Lts/Services (47 submodules, verified) ✅ Lts/Tools (72 submodules, copied + CMake updated) ✅ Lts/Viewer (LtsFileDialog, LtsReportDisplay, SituationMap) 🟡 TetraIF (partial) 🟡 Z (partial: nglwidgets, QtSingleApplication, qsql_informix, WMS_Interface)
This commit is contained in:
1 parent
01dce5fe52
commit
d5c13033e2
1792 files changed
+982018
No files matched your search
Executable
+127
@@ -0,0 +1,127 @@
|
||||
#ifndef OBJECTMETHODS_H
|
||||
#define OBJECTMETHODS_H
|
||||
|
||||
#include <qhttpserverresponse.h>
|
||||
#include <qsqldatabase.h>
|
||||
|
||||
#include "dbQuery.h"
|
||||
#include "isValidGeoJsonObject.h"
|
||||
#include "types.h"
|
||||
|
||||
#include <qhttpserverrequest.h>
|
||||
#include <qjsondocument.h>
|
||||
#include <qjsonobject.h>
|
||||
#include <QtCore/QDebug>
|
||||
#include <qjsonarray.h>
|
||||
|
||||
namespace ObjectMethods {
|
||||
|
||||
// Set common response headers for CORS and content-type
|
||||
void setCommonHeaders(QHttpServerResponse &response) {
|
||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||
response.setHeader("Content-Type", "application/json");
|
||||
}
|
||||
|
||||
// Handle errors and return a response with a specific status code
|
||||
QHttpServerResponse createErrorResponse(const QString &errorMessage, QHttpServerResponse::StatusCode statusCode) {
|
||||
QHttpServerResponse response(errorMessage, statusCode);
|
||||
setCommonHeaders(response);
|
||||
return response;
|
||||
}
|
||||
|
||||
// Validate and insert GeoJSON feature into the database
|
||||
QHttpServerResponse handleGeoJSONFeature(const QJsonObject &jsonObj) {
|
||||
QString error;
|
||||
GeoJSONFeature geoJsonObj = geoJsonObj.fromJson(jsonObj);
|
||||
|
||||
if (!isValidGeoJSONFeature(geoJsonObj.toJson(), error)) {
|
||||
return createErrorResponse(error, QHttpServerResponse::StatusCode::BadRequest);
|
||||
}
|
||||
|
||||
insertGeoObjectToDb(geoJsonObj.toJson());
|
||||
return QHttpServerResponse(QString(), QHttpServerResponse::StatusCode::Ok);
|
||||
}
|
||||
|
||||
QHttpServerResponse postObjects(const QHttpServerRequest &request) {
|
||||
auto body = request.body();
|
||||
QJsonDocument jsonRequest = QJsonDocument::fromJson(body);
|
||||
|
||||
if (!jsonRequest.isObject() && !jsonRequest.isArray()) {
|
||||
return createErrorResponse("Invalid JSON", QHttpServerResponse::StatusCode::BadRequest);
|
||||
}
|
||||
|
||||
// Handle single object or an array of objects
|
||||
if (jsonRequest.isObject()) {
|
||||
return handleGeoJSONFeature(jsonRequest.object());
|
||||
} else if (jsonRequest.isArray()) {
|
||||
for (const QJsonValue &obj : jsonRequest.array()) {
|
||||
if (obj.isObject()) {
|
||||
QHttpServerResponse response = handleGeoJSONFeature(obj.toObject());
|
||||
if (response.statusCode() == QHttpServerResponse::StatusCode::BadRequest) {
|
||||
return response; // Return error response immediately if one is found
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return QHttpServerResponse(QString(), QHttpServerResponse::StatusCode::Ok);
|
||||
}
|
||||
|
||||
QHttpServerResponse getGeoObjectsInterval(const QHttpServerRequest &request) {
|
||||
if (!request.query().hasQueryItem("replayId") || !request.query().hasQueryItem("start") || !request.query().hasQueryItem("end")) {
|
||||
return createErrorResponse("Query param is missing", QHttpServerResponse::StatusCode::BadRequest);
|
||||
}
|
||||
|
||||
QString replayId = request.query().queryItemValue("replayId");
|
||||
QString start_timestamp = request.query().queryItemValue("start");
|
||||
QString end_timestamp = request.query().queryItemValue("end");
|
||||
|
||||
QJsonArray array = getGeoObjectsIntervallFromDb(replayId, start_timestamp, end_timestamp);
|
||||
|
||||
QHttpServerResponse response(array, QHttpServerResponse::StatusCode::Ok);
|
||||
setCommonHeaders(response);
|
||||
return response;
|
||||
}
|
||||
|
||||
QHttpServerResponse getReplayInitInformation(const QHttpServerRequest &request) {
|
||||
if (!request.query().hasQueryItem("replayId")) {
|
||||
return createErrorResponse("replayId is missing", QHttpServerResponse::StatusCode::BadRequest);
|
||||
}
|
||||
|
||||
QJsonObject obj = getReplayInitInformationsFromDb(request.query().queryItemValue("replayId"));
|
||||
QHttpServerResponse response(obj, QHttpServerResponse::StatusCode::Ok);
|
||||
setCommonHeaders(response);
|
||||
return response;
|
||||
}
|
||||
|
||||
QHttpServerResponse postBookmark(const QHttpServerRequest &request) {
|
||||
auto body = request.body();
|
||||
QJsonDocument jsonRequest = QJsonDocument::fromJson(body);
|
||||
QString error;
|
||||
|
||||
if (jsonRequest["name"].isNull() || jsonRequest["timestamp"].isNull()) {
|
||||
error = "values are missing";
|
||||
return createErrorResponse(error, QHttpServerResponse::StatusCode::BadRequest);
|
||||
}
|
||||
|
||||
insertBookmark(jsonRequest.object());
|
||||
QHttpServerResponse response(error, QHttpServerResponse::StatusCode::Ok);
|
||||
setCommonHeaders(response);
|
||||
return response;
|
||||
}
|
||||
|
||||
QHttpServerResponse getBookmarks(const QHttpServerRequest &request) {
|
||||
if (!request.query().hasQueryItem("replayId")) {
|
||||
return createErrorResponse("replayId is missing", QHttpServerResponse::StatusCode::BadRequest);
|
||||
}
|
||||
|
||||
QJsonArray array = getBookmarkFromDB(request.query().queryItemValue("replayId"));
|
||||
|
||||
QHttpServerResponse response(array, QHttpServerResponse::StatusCode::Ok);
|
||||
setCommonHeaders(response);
|
||||
return response;
|
||||
}
|
||||
|
||||
} // namespace ObjectMethods
|
||||
|
||||
#endif // OBJECTMETHODS_H
|
||||
Reference in new issue
Block a user