diff --git a/src/Server/.idea/.idea.REST API/.idea/workspace.xml b/src/Server/.idea/.idea.REST API/.idea/workspace.xml
index d7f9255..1fe2d9e 100755
--- a/src/Server/.idea/.idea.REST API/.idea/workspace.xml
+++ b/src/Server/.idea/.idea.REST API/.idea/workspace.xml
@@ -8,23 +8,12 @@
-
-
-
+
-
-
-
-
-
-
-
-
-
-
+
@@ -131,7 +120,7 @@
-
+
diff --git a/src/Server/Console/Program.cs b/src/Server/Console/Program.cs
index ab867a4..9b5aea9 100755
--- a/src/Server/Console/Program.cs
+++ b/src/Server/Console/Program.cs
@@ -19,7 +19,7 @@ internal static class Program {
{ "", new Root() },
{ "database", new RouteDatabase(cassandraSession) },
{ "database/metadata", new RouteMetadata(cassandraSession) },
- { "database/route", new RouteMap(cassandraSession) },
+ { "database/path", new RoutePath(cassandraSession) },
{ "roomba/control", new RouteControl() }
};
diff --git a/src/Server/Console/Routes/RouteMap.cs b/src/Server/Console/Routes/RoutePath.cs
similarity index 83%
rename from src/Server/Console/Routes/RouteMap.cs
rename to src/Server/Console/Routes/RoutePath.cs
index 98c8407..e68c0e3 100644
--- a/src/Server/Console/Routes/RouteMap.cs
+++ b/src/Server/Console/Routes/RoutePath.cs
@@ -6,9 +6,9 @@ using Console.JsonClasses;
namespace Console.Routes;
-public class RouteMap(ISession cassandraSession): IRoute {
+public class RoutePath(ISession cassandraSession): IRoute {
///
- /// GET request for the database/mapped route, return a map based on given criteria.
+ /// GET request for the database/path route, return a path of a map based on given criteria.
///
public HttpResponse Get(HttpRequest request) {
try {
@@ -27,7 +27,6 @@ public class RouteMap(ISession cassandraSession): IRoute {
if (selectStatement == null) throw new Exception("No valid search criteria given, give one of (id).");
-
// Execute the query and return all rows in an array
var rowSet = cassandraSession.Execute(selectStatement);
@@ -43,8 +42,8 @@ public class RouteMap(ISession cassandraSession): IRoute {
}
///
- /// POST request for the database route, insert a new map containing
- /// object data into the database.
+ /// POST request for the database/path route, insert a new path containing
+ /// routing data into the database.
///
public HttpResponse Post(HttpRequest request) {
try {
@@ -55,6 +54,22 @@ public class RouteMap(ISession cassandraSession): IRoute {
throw new Exception("objectData is null");
}
+ if (parsedBody?.id == null) {
+ throw new Exception("id is null");
+ }
+
+ var selectStatement =
+ parsedBody?.id != null ? cassandraSession.Prepare(@"SELECT * FROM Roommapper.Maps WHERE Id = ?;")
+ .Bind(Guid.Parse(parsedBody.id)) :
+ throw new Exception("No valid search criteria given, give one of (id).");
+
+ // Execute the query and return all rows in an array
+ var rowSet = cassandraSession.Execute(selectStatement);
+
+ if (rowSet.IsExhausted()) {
+ throw new Exception("No matching map found with the given criteria.");
+ }
+
// Prepare the insert statement, bind the values, and execute the query
// Using a prepare due to the potential of SQL injection when accepting
// any form of user data.
diff --git a/src/Server/Console/bin/Debug/net8.0/Console.dll b/src/Server/Console/bin/Debug/net8.0/Console.dll
index 5aa069c..ee6bf23 100755
Binary files a/src/Server/Console/bin/Debug/net8.0/Console.dll and b/src/Server/Console/bin/Debug/net8.0/Console.dll differ
diff --git a/src/Server/Console/bin/Debug/net8.0/Console.pdb b/src/Server/Console/bin/Debug/net8.0/Console.pdb
index b4ce524..74b6ef2 100755
Binary files a/src/Server/Console/bin/Debug/net8.0/Console.pdb and b/src/Server/Console/bin/Debug/net8.0/Console.pdb differ
diff --git a/src/Web/src/components/mapCanvas.jsx b/src/Web/src/components/mapCanvas.jsx
index add36e6..25102b1 100644
--- a/src/Web/src/components/mapCanvas.jsx
+++ b/src/Web/src/components/mapCanvas.jsx
@@ -33,28 +33,10 @@ export default class MapCanvas extends React.Component {
this.draw();
}
- async getLinePoints() {
+ async getLinePoints(endpoint = '') {
try {
const { searchOption, inputValue } = this.state;
- const url = `${API_ENDPOINT}/database?${searchOption}=${inputValue}`;
- const data = await (await fetch(url)).json();
-
- // Combine all found sets into a singular array.
- const map = [];
- if (!Array.isArray(data) || data.length < 1) return map;
- data.forEach((set) => set.Objects.forEach((coord) => map.push(coord)));
-
- return map;
- } catch (ex) {
- return;
- // this.props.onError(ex);
- }
- }
-
- async getRoutePoints() {
- try {
- const { searchOption, inputValue } = this.state;
- const url = `${API_ENDPOINT}/database/route?id=${inputValue}`;
+ const url = `${API_ENDPOINT}/database/${endpoint}?${searchOption}=${inputValue}`;
const data = await (await fetch(url)).json();
// Combine all found sets into a singular array.
@@ -74,7 +56,8 @@ export default class MapCanvas extends React.Component {
const ctx = this.canvasRef.current.getContext('2d');
// Get the points to draw from the server
const points = await this.getLinePoints();
- const route = await this.getRoutePoints();
+ const route = await this.getLinePoints("path");
+ // const route = await this.getRoutePoints();
// Set the font for the text we will draw on the canvas
ctx.font = "24px Comic Sans MS";