diff --git a/media/Server/101.002 y2s2 devlog.norg b/media/Server/101.002 y2s2 devlog.norg index 26d4a85..405c4a7 100644 --- a/media/Server/101.002 y2s2 devlog.norg +++ b/media/Server/101.002 y2s2 devlog.norg @@ -330,6 +330,20 @@ version: 3.1.0 robot nogmaals herschrijven maar nu met de nieuwe libraries. Ook zullen alle benodigde routes geimplementeert worden om de Server set af te maken. -* [XVII 06-06-2024] UML diagrammen bijgewerkt - Nu de broncode van de Server en WebUI compleet zijn heb ik de UML diagrammen - bijgewerkt om overeen te komen met de broncode. + +* [XVII 11-06-2024] Route planning toegevoegd + Nu er met Tom afgepsroken is om de routes net zoals de objecten op te slaan, + heb ik een endpoint gemaakt die het zelfde werkt als de mapping, maar dan voor + de routes. Ook heb ik een endpoint gemaakt die de route op de kaart tekent + voor de webUI. + +** Map identificatie + In eerste instantie gebruikte ik steeds de `Id` van een map om hem te + identificeren. In de praktijk is dit helemaal niet handig, dus daarom ben ik + overgestapt op het gebruik van gebruiker invulbare namen. Dit maakt het veel + makkelijker om een bepaalde map te laten zien. + +* [XVII 15-06-2024] UML diagrammen bijgewerkt + Nu de broncode van de Server compleet zijn heb ik de UML diagrammen + bijgewerkt om overeen te komen met de broncode. Ook heb ik de desbetreffende + modules bij elkaar gegroepeerd en de correcte lijntjes getrokken. diff --git a/media/Server/UML/class-diagram-v3.vpp b/media/Server/UML/class-diagram-v3.vpp new file mode 100644 index 0000000..ec30528 Binary files /dev/null and b/media/Server/UML/class-diagram-v3.vpp differ diff --git a/src/Server/.idea/.idea.REST API/.idea/dataSources.local.xml b/src/Server/.idea/.idea.REST API/.idea/dataSources.local.xml index 2403de8..1cbe770 100755 --- a/src/Server/.idea/.idea.REST API/.idea/dataSources.local.xml +++ b/src/Server/.idea/.idea.REST API/.idea/dataSources.local.xml @@ -1,10 +1,9 @@ - + " - true master_key diff --git a/src/Server/.idea/.idea.REST API/.idea/workspace.xml b/src/Server/.idea/.idea.REST API/.idea/workspace.xml index 231935c..d1c0623 100755 --- a/src/Server/.idea/.idea.REST API/.idea/workspace.xml +++ b/src/Server/.idea/.idea.REST API/.idea/workspace.xml @@ -8,15 +8,26 @@ + - - - + + - + + + + + + + + + + + + + + @@ -44,35 +57,35 @@ - { - "keyToString": { - ".NET Project.Console.executor": "Run", - "ASKED_ADD_EXTERNAL_FILES": "true", - "RunOnceActivity.OpenProjectViewOnStart": "true", - "RunOnceActivity.ShowReadmeOnStart": "true", - "d452b4e4-aa15-4fa9-847f-33d4d7fab23d.executor": "Run", - "git-widget-placeholder": "master", - "ignore.virus.scanning.warn.message": "true", - "node.js.detected.package.eslint": "true", - "node.js.detected.package.tslint": "true", - "node.js.selected.package.eslint": "(autodetect)", - "node.js.selected.package.tslint": "(autodetect)", - "nodejs_package_manager_path": "npm", - "settings.editor.selected.configurable": "HotReloadSettingsPage", - "vue.rearranger.settings.migration": "true" + - +}]]> + diff --git a/src/Server/Console/Program.cs b/src/Server/Console/Program.cs index 5ea247b..d891486 100755 --- a/src/Server/Console/Program.cs +++ b/src/Server/Console/Program.cs @@ -7,13 +7,7 @@ using Cassandra; internal static class Program { public static void Main() { - var cluster = Cluster.Builder() - .AddContactPoints("127.0.0.1") - .WithPort(9042) - .Build(); - var cassandraSession = cluster.Connect(); - - InitializeDatabase(cassandraSession); + var cassandraSession = InitializeDatabase(); Dictionary routes = new() { { "", new Root() }, @@ -34,7 +28,13 @@ internal static class Program { } } - private static void InitializeDatabase(ISession session) { + private static ISession InitializeDatabase() { + var cluster = Cluster.Builder() + .AddContactPoints("127.0.0.1") + .WithPort(9042) + .Build(); + var session = cluster.Connect(); + session.Execute(@"CREATE KEYSPACE IF NOT EXISTS roommapper WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'datacenter1' : 1 };"); session.Execute(@" @@ -53,5 +53,7 @@ internal static class Program { Path text, PRIMARY KEY (Id) )"); + + return session; } } diff --git a/src/Server/Console/Routes/RouteControl.cs b/src/Server/Console/Routes/RouteControl.cs index f60092f..9615f6f 100755 --- a/src/Server/Console/Routes/RouteControl.cs +++ b/src/Server/Console/Routes/RouteControl.cs @@ -56,14 +56,14 @@ public class RouteControl: IRoute { } // @todo(wessel): Rewrite, move to other class - public void SendHttpRequest(string Host, string body, string method, string route) { + private void SendHttpRequest(string target, string body, string method, string route) { using (TcpClient client = new TcpClient()) { - string[] host = Host.Split(":"); + string[] host = target.Split(":"); client.Connect(host[0], int.Parse(host[1].Split("/")[0])); using (NetworkStream stream = client.GetStream()) { string httpRequestMessage = $"{method} {route} HTTP/1.1\r\n" + - $"Host: {Host}\r\n" + + $"Host: {target}\r\n" + $"Content-Length: {body.Length}\r\n" + "\r\n" + $"{body}"; diff --git a/src/Server/Console/bin/Debug/net8.0/Console.dll b/src/Server/Console/bin/Debug/net8.0/Console.dll index 36d31f8..addcbea 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.exe b/src/Server/Console/bin/Debug/net8.0/Console.exe index 0d25691..4bce3a1 100755 Binary files a/src/Server/Console/bin/Debug/net8.0/Console.exe and b/src/Server/Console/bin/Debug/net8.0/Console.exe differ diff --git a/src/Server/Console/bin/Debug/net8.0/Console.pdb b/src/Server/Console/bin/Debug/net8.0/Console.pdb index 5dfc8b3..02b8a81 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/Server/Console/bin/Debug/net8.0/LibParse.dll b/src/Server/Console/bin/Debug/net8.0/LibParse.dll index f44c188..a599421 100755 Binary files a/src/Server/Console/bin/Debug/net8.0/LibParse.dll and b/src/Server/Console/bin/Debug/net8.0/LibParse.dll differ diff --git a/src/Server/Console/bin/Debug/net8.0/LibParse.pdb b/src/Server/Console/bin/Debug/net8.0/LibParse.pdb index 82875fa..217f855 100755 Binary files a/src/Server/Console/bin/Debug/net8.0/LibParse.pdb and b/src/Server/Console/bin/Debug/net8.0/LibParse.pdb differ diff --git a/src/Server/Console/bin/Debug/net8.0/LibServer.dll b/src/Server/Console/bin/Debug/net8.0/LibServer.dll index 904f362..3bd4a8a 100755 Binary files a/src/Server/Console/bin/Debug/net8.0/LibServer.dll and b/src/Server/Console/bin/Debug/net8.0/LibServer.dll differ diff --git a/src/Server/Console/bin/Debug/net8.0/LibServer.pdb b/src/Server/Console/bin/Debug/net8.0/LibServer.pdb index ef3ff02..02369d3 100755 Binary files a/src/Server/Console/bin/Debug/net8.0/LibServer.pdb and b/src/Server/Console/bin/Debug/net8.0/LibServer.pdb differ diff --git a/src/Server/LibParse/bin/Debug/net8.0/LibParse.dll b/src/Server/LibParse/bin/Debug/net8.0/LibParse.dll index f44c188..a599421 100755 Binary files a/src/Server/LibParse/bin/Debug/net8.0/LibParse.dll and b/src/Server/LibParse/bin/Debug/net8.0/LibParse.dll differ diff --git a/src/Server/LibParse/bin/Debug/net8.0/LibParse.pdb b/src/Server/LibParse/bin/Debug/net8.0/LibParse.pdb index 82875fa..217f855 100755 Binary files a/src/Server/LibParse/bin/Debug/net8.0/LibParse.pdb and b/src/Server/LibParse/bin/Debug/net8.0/LibParse.pdb differ diff --git a/src/Server/LibServer/Http/Request.cs b/src/Server/LibServer/Http/Request.cs index c1a9c96..636dcc8 100755 --- a/src/Server/LibServer/Http/Request.cs +++ b/src/Server/LibServer/Http/Request.cs @@ -4,17 +4,16 @@ public class HttpRequest { private const string LogPrefix = "\u001b[47m[ WWW ]\u001b[0m"; public string? Route; - public string? _httpVersion, _host, _body, _header; - public Method? _method; - public Dictionary QueryString = new(); + private string? _httpVersion, _host, _header; + public readonly Dictionary QueryString = new(); - public Method? Method => _method; - public string? Body => _body; + public Method? Method { get; private set; } + public string? Body { get; private set; } public int Parse(string raw) { // _body starts after 2 new lines, cast to `_body` var body = raw.Split("\r\n\r\n"); - _body = body.Length > 1 ? string.Join("\r\n\r\n", body.Skip(1).ToArray()) : ""; + Body = body.Length > 1 ? string.Join("\r\n\r\n", body.Skip(1).ToArray()) : ""; // Split the raw request into parts (one line per part) var parts = raw.Split("\r\n"); @@ -27,7 +26,7 @@ public class HttpRequest { if (i == 0) { if (!parts[0].Contains("HTTP")) return -1; var first = parts[0].Split(" "); - _method = MethodClass.StringToMethod(first[0].ToUpper()); + Method = MethodClass.StringToMethod(first[0].ToUpper()); Route = first[1]; _httpVersion = first[2].Split("/")[1]; } else { @@ -67,8 +66,8 @@ public class HttpRequest { Console.WriteLine("{0} _httpVersion:\t{1}", LogPrefix, _httpVersion); Console.WriteLine("{0} _host:\t\t{1}", LogPrefix, _host); Console.WriteLine("{0} Route:\t\t{1}", LogPrefix, Route); - Console.WriteLine("{0} _method:\t\t{1}", LogPrefix, _method); + Console.WriteLine("{0} _method:\t\t{1}", LogPrefix, Method); Console.WriteLine("{0} _headers:\n{1}", LogPrefix, _header); - Console.WriteLine("{0} _body:\n{1}", LogPrefix, _body); + Console.WriteLine("{0} _body:\n{1}", LogPrefix, Body); } } diff --git a/src/Server/LibServer/Router/Route.cs b/src/Server/LibServer/Router/Route.cs index 85cd2e7..08e5e7c 100755 --- a/src/Server/LibServer/Router/Route.cs +++ b/src/Server/LibServer/Router/Route.cs @@ -1,6 +1,6 @@ namespace LibServer.Router; -using LibServer.Http; +using Http; public interface IRoute { public HttpResponse Get(HttpRequest _) { return MethodNotAllowed(); } diff --git a/src/Server/LibServer/bin/Debug/net8.0/LibServer.dll b/src/Server/LibServer/bin/Debug/net8.0/LibServer.dll index 904f362..3bd4a8a 100755 Binary files a/src/Server/LibServer/bin/Debug/net8.0/LibServer.dll and b/src/Server/LibServer/bin/Debug/net8.0/LibServer.dll differ diff --git a/src/Server/LibServer/bin/Debug/net8.0/LibServer.pdb b/src/Server/LibServer/bin/Debug/net8.0/LibServer.pdb index ef3ff02..02369d3 100755 Binary files a/src/Server/LibServer/bin/Debug/net8.0/LibServer.pdb and b/src/Server/LibServer/bin/Debug/net8.0/LibServer.pdb differ diff --git a/src/Server/REST API.sln.DotSettings.user b/src/Server/REST API.sln.DotSettings.user index 879bd4b..4bc068e 100755 --- a/src/Server/REST API.sln.DotSettings.user +++ b/src/Server/REST API.sln.DotSettings.user @@ -1,5 +1,5 @@  INFO - <SessionState ContinuousTestingMode="0" IsActive="True" Name="ParseJsonToAnonymousObject" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> - <Project Location="C:\Users\wesse\OneDrive - Hogeschool Inholland\roommapper\src\Server\Tests" Presentation="&lt;Tests&gt;" /> + <SessionState ContinuousTestingMode="0" IsActive="True" Name="ParseJsonToAnonymousObject" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> + <Project Location="C:\Users\wesse\OneDrive - Hogeschool Inholland\roommapper\src\Server\Tests" Presentation="&lt;Tests&gt;" /> </SessionState> \ No newline at end of file diff --git a/src/Server/Tests/bin/Debug/net8.0/CoverletSourceRootsMapping_Tests b/src/Server/Tests/bin/Debug/net8.0/CoverletSourceRootsMapping_Tests index 7035000..84e94b0 100755 Binary files a/src/Server/Tests/bin/Debug/net8.0/CoverletSourceRootsMapping_Tests and b/src/Server/Tests/bin/Debug/net8.0/CoverletSourceRootsMapping_Tests differ