From 6c4d4c17f3e24605f22c68159eeac3e60087639b Mon Sep 17 00:00:00 2001 From: Martin <ms618@hdm-stuttgart.de> Date: Mon, 18 Dec 2023 19:13:41 +0100 Subject: [PATCH] Update: Minor Fixes --- .idea/sqldialects.xml | 2 +- .../Persistance/Classes/OracleDB.java | 6 ---- .../Persistance/Classes/RuntimeInfo.java | 25 +++++++++----- .../Scripts/DDL_Script_AzureDB.sql | 33 +++++++++++++++++++ .../{DDL_Script.sql => DDL_Script_Oracle.sql} | 0 5 files changed, 51 insertions(+), 15 deletions(-) create mode 100644 src/main/java/de/hdm_stuttgart/battlearena/Persistance/Scripts/DDL_Script_AzureDB.sql rename src/main/java/de/hdm_stuttgart/battlearena/Persistance/Scripts/{DDL_Script.sql => DDL_Script_Oracle.sql} (100%) diff --git a/.idea/sqldialects.xml b/.idea/sqldialects.xml index 1a51ae13..202cd50f 100644 --- a/.idea/sqldialects.xml +++ b/.idea/sqldialects.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <project version="4"> <component name="SqlDialectMappings"> - <file url="file://$PROJECT_DIR$/src/main/java/de/hdm_stuttgart/battlearena/Persistance/Scripts/DDL_Script.sql" dialect="AZURE" /> + <file url="file://$PROJECT_DIR$/src/main/java/de/hdm_stuttgart/battlearena/Persistance/Scripts/DDL_Script_Oracle.sql" dialect="AZURE" /> <file url="PROJECT" dialect="AZURE" /> </component> <component name="SqlResolveMappings"> diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Persistance/Classes/OracleDB.java b/src/main/java/de/hdm_stuttgart/battlearena/Persistance/Classes/OracleDB.java index 363c42bc..596c158b 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Persistance/Classes/OracleDB.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Persistance/Classes/OracleDB.java @@ -125,12 +125,6 @@ public class OracleDB implements IDataBase { } /* - public void createCommunityMap(Persistence persistence){ - //try to insert new entry in CommunityMaps Table - if check by unique-id fails, error message that map already exists! - //make hash of madata before trying to insert - //save data in communityMaps Arraylist - } - public void updateCommunityStats(Persistence persistence){ //Update the commulative Stats } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Persistance/Classes/RuntimeInfo.java b/src/main/java/de/hdm_stuttgart/battlearena/Persistance/Classes/RuntimeInfo.java index c37c7409..4a696230 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Persistance/Classes/RuntimeInfo.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Persistance/Classes/RuntimeInfo.java @@ -14,23 +14,32 @@ public class RuntimeInfo { private LinkedHashMap<String, String> mapNames; public MapData mapCreated; //to store parsed Data from MapCreator for Upload to SQL public String communityMapSelected; - protected ArrayList<String> coreMapsListLocal; - protected ArrayList<String> communityMapsListLocal; + protected ArrayList<String> coreMapsListLocal; //include mapID + protected ArrayList<String> communityMapsListLocal; //include mapID protected ArrayList<String> communityMapsListRemote; + public String mapTileString; //Maxe chose this name private RuntimeInfo(){}; public static RuntimeInfo getInstance(){ return runtimeInfoSingleton; } - private String getMap(String mapSelected) throws RuntimeException{ - for(int i = 0; i < persistenceInst.coreMaps.size(); i++){ - if(persistenceInst.coreMaps.get(i).getMapID().equals("mapSelected")){ - return persistenceInst.coreMaps.get(i).getMapID(); - } + private void setMap(String mapSelected, boolean choseCoremaps){ + if(choseCoremaps) { + for (int mapListIndex = 0; mapListIndex < persistenceInst.coreMaps.size(); mapListIndex++) { + if (persistenceInst.coreMaps.get(mapListIndex).getMapID().equals("mapSelected")) { + mapTileString = persistenceInst.coreMaps.get(mapListIndex).getMapID(); + } + } + } + else { + for (int mapListIndex = 0; mapListIndex < persistenceInst.communityMaps.size(); mapListIndex++) { + if (persistenceInst.communityMaps.get(mapListIndex).getMapID().equals("mapSelected")) { + mapTileString = persistenceInst.coreMaps.get(mapListIndex).getMapID(); + } + } } - throw new RuntimeException("no Map found"); } public void getCommunityMap(){ diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Persistance/Scripts/DDL_Script_AzureDB.sql b/src/main/java/de/hdm_stuttgart/battlearena/Persistance/Scripts/DDL_Script_AzureDB.sql new file mode 100644 index 00000000..e3160edb --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Persistance/Scripts/DDL_Script_AzureDB.sql @@ -0,0 +1,33 @@ +--Note: DDL to be run as admin on MsSQL (AzureDB); + +DROP TABLE coremaps; +DROP TABLE communitymaps; + +CREATE TABLE coremaps( + map_id CHAR(40) NOT NULL UNIQUE, --SHA1 hash is 40 chars length in hex + map_name VARCHAR(30) NOT NULL, + map_width INTEGER NOT NULL, + map_height INTEGER NOT NULL, + map_data VARCHAR(1682) NOT NULL); --allows for map size up to 29x29 + +CREATE TABLE communitymaps( + map_id CHAR(40) NOT NULL UNIQUE, --SHA1 hash is 40 chars length in hex + map_name VARCHAR(30) NOT NULL, + map_width INTEGER NOT NULL, + map_height INTEGER NOT NULL, + map_data VARCHAR(1682) NOT NULL); --allows for map size up to 29x29 + +INSERT INTO coremaps (map_id, map_name, map_width, map_height, map_data) +VALUES ('a593cafd1d061f0f463a2d2051bf4718aaaf5c48', + 'Arena1', + 18, + 18, + '4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 1 2 1 1 1 1 2 2 2 1 1 1 1 1 1 1 3 4 2 1 1 1 1 1 2 2 2 1 1 1 1 2 1 1 3 4 1 1 1 2 2 4 3 3 1 4 3 3 3 3 2 2 3 4 1 1 1 2 2 4 1 1 1 1 1 1 1 3 1 2 3 4 1 1 1 2 2 4 1 3 3 3 1 1 1 3 2 2 3 4 1 1 1 2 2 4 1 1 1 1 1 1 1 3 2 1 3 4 1 1 1 2 2 4 3 3 1 4 3 3 3 3 2 1 3 4 1 1 1 1 1 1 2 2 2 1 1 1 1 1 1 1 3 4 1 1 1 2 2 4 3 3 1 3 3 3 3 3 2 1 3 4 1 1 1 1 2 4 3 3 1 3 3 3 3 3 1 1 3 4 1 1 1 1 2 4 3 3 1 3 3 3 3 3 2 2 3 4 1 1 1 1 1 4 3 3 1 3 3 3 3 3 1 2 3 4 1 2 1 1 1 1 2 2 2 1 1 1 1 1 1 1 3 4 1 1 2 1 1 1 2 2 2 1 1 1 1 1 1 1 3 4 1 1 1 2 2 4 3 3 1 3 3 3 3 3 2 2 3 4 1 1 1 2 2 4 3 3 1 3 3 3 3 3 2 2 3 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3'); + +INSERT INTO coremaps (map_id, map_name, map_width, map_height, map_data) +VALUES ('e559d8fbb53b333f5839cb3c6c0c515395afe344', + 'Arena2', + 18, + 18, + '4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 1 2 1 1 1 1 2 2 2 1 1 1 1 1 1 1 2 4 2 1 1 1 1 1 2 2 2 1 1 1 1 2 3 1 3 4 1 1 1 2 2 4 3 3 1 4 3 3 3 3 2 2 3 4 1 1 1 2 2 4 1 1 1 1 1 1 1 3 1 2 3 4 1 1 1 2 2 4 1 3 3 3 1 1 1 3 2 2 3 4 1 1 1 2 2 4 1 1 1 1 1 1 1 3 2 1 3 4 1 1 1 2 2 4 3 3 1 4 3 3 3 3 2 1 3 4 1 1 1 1 1 1 2 2 2 1 1 1 1 1 1 1 3 4 1 1 1 2 2 4 3 3 1 3 3 3 3 3 2 1 3 4 1 1 1 1 2 4 3 3 1 3 3 3 3 3 1 1 3 4 1 1 1 1 2 4 3 3 1 3 3 3 3 3 2 2 3 4 1 1 1 1 1 4 3 3 1 3 3 3 3 3 1 2 3 4 1 2 1 1 1 1 2 2 2 1 1 1 1 1 1 1 3 4 1 1 2 1 1 1 2 2 2 1 1 1 1 1 1 1 3 4 1 1 1 2 2 4 3 3 1 3 3 3 3 3 2 2 3 4 1 1 1 2 2 4 3 3 1 3 3 3 3 3 2 2 3 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3'); + diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Persistance/Scripts/DDL_Script.sql b/src/main/java/de/hdm_stuttgart/battlearena/Persistance/Scripts/DDL_Script_Oracle.sql similarity index 100% rename from src/main/java/de/hdm_stuttgart/battlearena/Persistance/Scripts/DDL_Script.sql rename to src/main/java/de/hdm_stuttgart/battlearena/Persistance/Scripts/DDL_Script_Oracle.sql -- GitLab