From acb139601a5658545d3b8493bcec771aa637a2db Mon Sep 17 00:00:00 2001 From: Notmoo-PC\Notmoo Date: Sun, 4 Jun 2017 17:44:00 +0200 Subject: [PATCH] Refactor structure projet --- .idea/Positionning_server.iml | 39 ++++++++++++++++++++++++++++++++++++++- .idea/artifacts/positioning_server_war.xml | 8 ++++++++ .idea/artifacts/positioning_server_war_exploded.xml | 29 +++++++++++++++++++++++++++++ .idea/compiler.xml | 16 ++++++++++++++++ .idea/misc.xml | 16 ++++++++++++++++ .idea/modules.xml | 2 +- PositioningServer/.idea/compiler.xml | 18 ------------------ PositioningServer/.idea/encodings.xml | 6 ------ PositioningServer/.idea/libraries/Maven__antlr_antlr_2_7_6.xml | 13 ------------- PositioningServer/.idea/libraries/Maven__commons_collections_commons_collections_3_1.xml | 13 ------------- PositioningServer/.idea/libraries/Maven__dom4j_dom4j_1_6_1.xml | 13 ------------- PositioningServer/.idea/libraries/Maven__javassist_javassist_3_9_0_GA.xml | 13 ------------- PositioningServer/.idea/libraries/Maven__javax_javaee_web_api_6_0.xml | 13 ------------- PositioningServer/.idea/libraries/Maven__javax_transaction_jta_1_1.xml | 13 ------------- PositioningServer/.idea/libraries/Maven__log4j_log4j_1_2_14.xml | 13 ------------- PositioningServer/.idea/libraries/Maven__org_hibernate_hibernate_annotations_3_5_6_Final.xml | 13 ------------- PositioningServer/.idea/libraries/Maven__org_hibernate_hibernate_commons_annotations_3_2_0_Final.xml | 13 ------------- PositioningServer/.idea/libraries/Maven__org_hibernate_hibernate_core_3_5_6_Final.xml | 13 ------------- PositioningServer/.idea/libraries/Maven__org_hibernate_javax_persistence_hibernate_jpa_2_0_api_1_0_0_Final.xml | 13 ------------- PositioningServer/.idea/libraries/Maven__org_postgresql_postgresql_9_4_1212.xml | 13 ------------- PositioningServer/.idea/libraries/Maven__org_slf4j_slf4j_api_1_5_8.xml | 13 ------------- PositioningServer/.idea/libraries/Maven__org_slf4j_slf4j_log4j12_1_5_8.xml | 13 ------------- PositioningServer/.idea/libraries/Maven__xml_apis_xml_apis_1_0_b2.xml | 13 ------------- PositioningServer/.idea/misc.xml | 52 ---------------------------------------------------- PositioningServer/.idea/modules.xml | 9 --------- PositioningServer/.idea/uiDesigner.xml | 124 ---------------------------------------------------------------------------------------------------------------------------- PositioningServer/.idea/workspace.xml | 1159 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- PositioningServer/PositioningServer.iml | 29 ----------------------------- PositioningServer/Server_Servlets/Server_Servlets.iml | 14 -------------- PositioningServer/Server_Servlets/pom.xml | 76 ---------------------------------------------------------------------------- PositioningServer/Server_Servlets/src/WEB-INF/web.xml | 19 ------------------- PositioningServer/Server_Servlets/src/main/java/com/utbm/lo53/CalibrationServlet.java | 31 ------------------------------- PositioningServer/Server_Servlets/src/main/java/com/utbm/lo53/PositioningServlet.java | 31 ------------------------------- PositioningServer/Server_Servlets/src/main/webapp/index.jsp | 13 ------------- PositioningServer/pom.xml | 60 ------------------------------------------------------------ PositioningServer/src/main/java/ServerApp.java | 18 ------------------ PositioningServer/src/main/java/com/utbm/lo53/dao/DebianDao.java | 9 --------- PositioningServer/src/main/java/com/utbm/lo53/dao/HibernateDao.java | 175 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- PositioningServer/src/main/java/com/utbm/lo53/repository/AccessPoint.java | 35 ----------------------------------- PositioningServer/src/main/java/com/utbm/lo53/repository/Location.java | 50 -------------------------------------------------- PositioningServer/src/main/java/com/utbm/lo53/repository/Mape.java | 77 ----------------------------------------------------------------------------- PositioningServer/src/main/java/com/utbm/lo53/repository/RssiRecord.java | 69 --------------------------------------------------------------------- PositioningServer/src/main/java/com/utbm/lo53/repository/TempRssi.java | 54 ------------------------------------------------------ PositioningServer/src/main/java/com/utbm/lo53/service/CalibrationService.java | 26 -------------------------- PositioningServer/src/main/java/com/utbm/lo53/service/ConnectionService.java | 12 ------------ PositioningServer/src/main/java/com/utbm/lo53/service/PositioningService.java | 95 ----------------------------------------------------------------------------------------------- PositioningServer/src/main/java/com/utbm/lo53/utils/HibernateUtil.java | 22 ---------------------- PositioningServer/src/main/resources/hibernate.cfg.xml | 21 --------------------- PositioningServer/target/classes/ServerApp.class | Bin 766 -> 0 bytes PositioningServer/target/classes/com/utbm/lo53/dao/DebianDao.class | Bin 440 -> 0 bytes PositioningServer/target/classes/com/utbm/lo53/dao/HibernateDao$ITransactionProcess.class | Bin 413 -> 0 bytes PositioningServer/target/classes/com/utbm/lo53/dao/HibernateDao$TransactionCallBack.class | Bin 1395 -> 0 bytes PositioningServer/target/classes/com/utbm/lo53/dao/HibernateDao.class | Bin 9197 -> 0 bytes PositioningServer/target/classes/com/utbm/lo53/repository/AccessPoint.class | Bin 1188 -> 0 bytes PositioningServer/target/classes/com/utbm/lo53/repository/Location.class | Bin 1639 -> 0 bytes PositioningServer/target/classes/com/utbm/lo53/repository/Mape.class | Bin 2114 -> 0 bytes PositioningServer/target/classes/com/utbm/lo53/repository/RssiRecord.class | Bin 2083 -> 0 bytes PositioningServer/target/classes/com/utbm/lo53/repository/TempRssi.class | Bin 1719 -> 0 bytes PositioningServer/target/classes/com/utbm/lo53/service/CalibrationService.class | Bin 1285 -> 0 bytes PositioningServer/target/classes/com/utbm/lo53/service/ConnectionService.class | Bin 572 -> 0 bytes PositioningServer/target/classes/com/utbm/lo53/service/PositioningService.class | Bin 6031 -> 0 bytes PositioningServer/target/classes/com/utbm/lo53/utils/HibernateUtil.class | Bin 1353 -> 0 bytes PositioningServer/target/classes/hibernate.cfg.xml | 21 --------------------- pom.xml | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ positioning_server.iml | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ project/.idea/artifacts/servlets.xml | 15 --------------- project/.idea/compiler.xml | 19 ------------------- project/.idea/libraries/Maven__antlr_antlr_2_7_6.xml | 13 ------------- project/.idea/libraries/Maven__commons_collections_commons_collections_3_1.xml | 13 ------------- project/.idea/libraries/Maven__dom4j_dom4j_1_6_1.xml | 13 ------------- project/.idea/libraries/Maven__javassist_javassist_3_9_0_GA.xml | 13 ------------- project/.idea/libraries/Maven__javax_javaee_web_api_6_0.xml | 13 ------------- project/.idea/libraries/Maven__javax_transaction_jta_1_1.xml | 13 ------------- project/.idea/libraries/Maven__log4j_log4j_1_2_14.xml | 13 ------------- project/.idea/libraries/Maven__org_hibernate_hibernate_annotations_3_5_6_Final.xml | 13 ------------- project/.idea/libraries/Maven__org_hibernate_hibernate_commons_annotations_3_2_0_Final.xml | 13 ------------- project/.idea/libraries/Maven__org_hibernate_hibernate_core_3_5_6_Final.xml | 13 ------------- project/.idea/libraries/Maven__org_hibernate_javax_persistence_hibernate_jpa_2_0_api_1_0_0_Final.xml | 13 ------------- project/.idea/libraries/Maven__org_postgresql_postgresql_9_4_1212.xml | 13 ------------- project/.idea/libraries/Maven__org_slf4j_slf4j_api_1_5_8.xml | 13 ------------- project/.idea/libraries/Maven__org_slf4j_slf4j_log4j12_1_5_8.xml | 13 ------------- project/.idea/libraries/Maven__xml_apis_xml_apis_1_0_b2.xml | 13 ------------- project/.idea/misc.xml | 13 ------------- project/.idea/modules.xml | 10 ---------- project/.idea/workspace.xml | 1107 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- project/pom.xml | 66 ------------------------------------------------------------------ project/project.iml | 29 ----------------------------- project/server_core/pom.xml | 16 ---------------- project/server_core/server_core.iml | 29 ----------------------------- project/server_core/src/main/java/ServerApp.java | 18 ------------------ project/server_core/src/main/java/dao/DebianDao.java | 12 ------------ project/server_core/src/main/java/dao/HibernateDao.java | 208 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- project/server_core/src/main/java/repository/AccessPoint.java | 35 ----------------------------------- project/server_core/src/main/java/repository/Location.java | 50 -------------------------------------------------- project/server_core/src/main/java/repository/Map.java | 68 -------------------------------------------------------------------- project/server_core/src/main/java/repository/RssiRecord.java | 68 -------------------------------------------------------------------- project/server_core/src/main/java/repository/TempRssi.java | 62 -------------------------------------------------------------- project/server_core/src/main/java/service/CalibrationService.java | 32 -------------------------------- project/server_core/src/main/java/service/MapService.java | 24 ------------------------ project/server_core/src/main/java/service/MeasurementService.java | 27 --------------------------- project/server_core/src/main/java/service/PositioningService.java | 102 ------------------------------------------------------------------------------------------------------ project/server_core/src/main/java/utils/HibernateUtil.java | 21 --------------------- project/server_core/src/main/resources/hibernate.cfg.xml | 21 --------------------- project/server_servlet/pom.xml | 29 ----------------------------- project/server_servlet/server_servlet.iml | 31 ------------------------------- project/server_servlet/src/main/java/APMeasurementServlet.java | 51 --------------------------------------------------- project/server_servlet/src/main/java/CalibrationServlet.java | 45 --------------------------------------------- project/server_servlet/src/main/java/MapByteServlet.java | 37 ------------------------------------- project/server_servlet/src/main/java/MapScaleServlet.java | 45 --------------------------------------------- project/server_servlet/src/main/java/PositioningServlet.java | 75 --------------------------------------------------------------------------- project/server_servlet/src/main/webapp/META-INF/MANIFEST.MF | 2 -- project/server_servlet/src/main/webapp/WEB-INF/web.xml | 62 -------------------------------------------------------------- src/main/java/core/ServerApp.java | 18 ++++++++++++++++++ src/main/java/core/dao/DebianDao.java | 12 ++++++++++++ src/main/java/core/dao/HibernateDao.java | 210 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/core/repository/AccessPoint.java | 35 +++++++++++++++++++++++++++++++++++ src/main/java/core/repository/Location.java | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/core/repository/Map.java | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/core/repository/RssiRecord.java | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/core/repository/TempRssi.java | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/core/service/CalibrationService.java | 32 ++++++++++++++++++++++++++++++++ src/main/java/core/service/MapService.java | 24 ++++++++++++++++++++++++ src/main/java/core/service/MeasurementService.java | 27 +++++++++++++++++++++++++++ src/main/java/core/service/PositioningService.java | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/core/utils/HibernateUtil.java | 21 +++++++++++++++++++++ src/main/java/servlet/APMeasurementServlet.java | 45 +++++++++++++++++++++++++++++++++++++++++++++ src/main/java/servlet/CalibrationServlet.java | 47 +++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/servlet/MapByteServlet.java | 39 +++++++++++++++++++++++++++++++++++++++ src/main/java/servlet/MapScaleServlet.java | 40 ++++++++++++++++++++++++++++++++++++++++ src/main/java/servlet/PositioningServlet.java | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/resources/hibernate.cfg.xml | 21 +++++++++++++++++++++ src/main/webapp/META-INF/MANIFEST.MF | 2 ++ src/main/webapp/WEB-INF/web.xml | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 133 files changed, 1296 insertions(+), 5146 deletions(-) create mode 100644 .idea/artifacts/positioning_server_war.xml create mode 100644 .idea/artifacts/positioning_server_war_exploded.xml create mode 100644 .idea/compiler.xml create mode 100644 .idea/misc.xml delete mode 100644 PositioningServer/.idea/compiler.xml delete mode 100644 PositioningServer/.idea/encodings.xml delete mode 100644 PositioningServer/.idea/libraries/Maven__antlr_antlr_2_7_6.xml delete mode 100644 PositioningServer/.idea/libraries/Maven__commons_collections_commons_collections_3_1.xml delete mode 100644 PositioningServer/.idea/libraries/Maven__dom4j_dom4j_1_6_1.xml delete mode 100644 PositioningServer/.idea/libraries/Maven__javassist_javassist_3_9_0_GA.xml delete mode 100644 PositioningServer/.idea/libraries/Maven__javax_javaee_web_api_6_0.xml delete mode 100644 PositioningServer/.idea/libraries/Maven__javax_transaction_jta_1_1.xml delete mode 100644 PositioningServer/.idea/libraries/Maven__log4j_log4j_1_2_14.xml delete mode 100644 PositioningServer/.idea/libraries/Maven__org_hibernate_hibernate_annotations_3_5_6_Final.xml delete mode 100644 PositioningServer/.idea/libraries/Maven__org_hibernate_hibernate_commons_annotations_3_2_0_Final.xml delete mode 100644 PositioningServer/.idea/libraries/Maven__org_hibernate_hibernate_core_3_5_6_Final.xml delete mode 100644 PositioningServer/.idea/libraries/Maven__org_hibernate_javax_persistence_hibernate_jpa_2_0_api_1_0_0_Final.xml delete mode 100644 PositioningServer/.idea/libraries/Maven__org_postgresql_postgresql_9_4_1212.xml delete mode 100644 PositioningServer/.idea/libraries/Maven__org_slf4j_slf4j_api_1_5_8.xml delete mode 100644 PositioningServer/.idea/libraries/Maven__org_slf4j_slf4j_log4j12_1_5_8.xml delete mode 100644 PositioningServer/.idea/libraries/Maven__xml_apis_xml_apis_1_0_b2.xml delete mode 100644 PositioningServer/.idea/misc.xml delete mode 100644 PositioningServer/.idea/modules.xml delete mode 100644 PositioningServer/.idea/uiDesigner.xml delete mode 100644 PositioningServer/.idea/workspace.xml delete mode 100644 PositioningServer/PositioningServer.iml delete mode 100644 PositioningServer/Server_Servlets/Server_Servlets.iml delete mode 100644 PositioningServer/Server_Servlets/pom.xml delete mode 100644 PositioningServer/Server_Servlets/src/WEB-INF/web.xml delete mode 100644 PositioningServer/Server_Servlets/src/main/java/com/utbm/lo53/CalibrationServlet.java delete mode 100644 PositioningServer/Server_Servlets/src/main/java/com/utbm/lo53/PositioningServlet.java delete mode 100644 PositioningServer/Server_Servlets/src/main/webapp/index.jsp delete mode 100644 PositioningServer/pom.xml delete mode 100644 PositioningServer/src/main/java/ServerApp.java delete mode 100644 PositioningServer/src/main/java/com/utbm/lo53/dao/DebianDao.java delete mode 100644 PositioningServer/src/main/java/com/utbm/lo53/dao/HibernateDao.java delete mode 100644 PositioningServer/src/main/java/com/utbm/lo53/repository/AccessPoint.java delete mode 100644 PositioningServer/src/main/java/com/utbm/lo53/repository/Location.java delete mode 100644 PositioningServer/src/main/java/com/utbm/lo53/repository/Mape.java delete mode 100644 PositioningServer/src/main/java/com/utbm/lo53/repository/RssiRecord.java delete mode 100644 PositioningServer/src/main/java/com/utbm/lo53/repository/TempRssi.java delete mode 100644 PositioningServer/src/main/java/com/utbm/lo53/service/CalibrationService.java delete mode 100644 PositioningServer/src/main/java/com/utbm/lo53/service/ConnectionService.java delete mode 100644 PositioningServer/src/main/java/com/utbm/lo53/service/PositioningService.java delete mode 100644 PositioningServer/src/main/java/com/utbm/lo53/utils/HibernateUtil.java delete mode 100644 PositioningServer/src/main/resources/hibernate.cfg.xml delete mode 100644 PositioningServer/target/classes/ServerApp.class delete mode 100644 PositioningServer/target/classes/com/utbm/lo53/dao/DebianDao.class delete mode 100644 PositioningServer/target/classes/com/utbm/lo53/dao/HibernateDao$ITransactionProcess.class delete mode 100644 PositioningServer/target/classes/com/utbm/lo53/dao/HibernateDao$TransactionCallBack.class delete mode 100644 PositioningServer/target/classes/com/utbm/lo53/dao/HibernateDao.class delete mode 100644 PositioningServer/target/classes/com/utbm/lo53/repository/AccessPoint.class delete mode 100644 PositioningServer/target/classes/com/utbm/lo53/repository/Location.class delete mode 100644 PositioningServer/target/classes/com/utbm/lo53/repository/Mape.class delete mode 100644 PositioningServer/target/classes/com/utbm/lo53/repository/RssiRecord.class delete mode 100644 PositioningServer/target/classes/com/utbm/lo53/repository/TempRssi.class delete mode 100644 PositioningServer/target/classes/com/utbm/lo53/service/CalibrationService.class delete mode 100644 PositioningServer/target/classes/com/utbm/lo53/service/ConnectionService.class delete mode 100644 PositioningServer/target/classes/com/utbm/lo53/service/PositioningService.class delete mode 100644 PositioningServer/target/classes/com/utbm/lo53/utils/HibernateUtil.class delete mode 100644 PositioningServer/target/classes/hibernate.cfg.xml create mode 100644 pom.xml create mode 100644 positioning_server.iml delete mode 100644 project/.idea/artifacts/servlets.xml delete mode 100644 project/.idea/compiler.xml delete mode 100644 project/.idea/libraries/Maven__antlr_antlr_2_7_6.xml delete mode 100644 project/.idea/libraries/Maven__commons_collections_commons_collections_3_1.xml delete mode 100644 project/.idea/libraries/Maven__dom4j_dom4j_1_6_1.xml delete mode 100644 project/.idea/libraries/Maven__javassist_javassist_3_9_0_GA.xml delete mode 100644 project/.idea/libraries/Maven__javax_javaee_web_api_6_0.xml delete mode 100644 project/.idea/libraries/Maven__javax_transaction_jta_1_1.xml delete mode 100644 project/.idea/libraries/Maven__log4j_log4j_1_2_14.xml delete mode 100644 project/.idea/libraries/Maven__org_hibernate_hibernate_annotations_3_5_6_Final.xml delete mode 100644 project/.idea/libraries/Maven__org_hibernate_hibernate_commons_annotations_3_2_0_Final.xml delete mode 100644 project/.idea/libraries/Maven__org_hibernate_hibernate_core_3_5_6_Final.xml delete mode 100644 project/.idea/libraries/Maven__org_hibernate_javax_persistence_hibernate_jpa_2_0_api_1_0_0_Final.xml delete mode 100644 project/.idea/libraries/Maven__org_postgresql_postgresql_9_4_1212.xml delete mode 100644 project/.idea/libraries/Maven__org_slf4j_slf4j_api_1_5_8.xml delete mode 100644 project/.idea/libraries/Maven__org_slf4j_slf4j_log4j12_1_5_8.xml delete mode 100644 project/.idea/libraries/Maven__xml_apis_xml_apis_1_0_b2.xml delete mode 100644 project/.idea/misc.xml delete mode 100644 project/.idea/modules.xml delete mode 100644 project/.idea/workspace.xml delete mode 100644 project/pom.xml delete mode 100644 project/project.iml delete mode 100644 project/server_core/pom.xml delete mode 100644 project/server_core/server_core.iml delete mode 100644 project/server_core/src/main/java/ServerApp.java delete mode 100644 project/server_core/src/main/java/dao/DebianDao.java delete mode 100644 project/server_core/src/main/java/dao/HibernateDao.java delete mode 100644 project/server_core/src/main/java/repository/AccessPoint.java delete mode 100644 project/server_core/src/main/java/repository/Location.java delete mode 100644 project/server_core/src/main/java/repository/Map.java delete mode 100644 project/server_core/src/main/java/repository/RssiRecord.java delete mode 100644 project/server_core/src/main/java/repository/TempRssi.java delete mode 100644 project/server_core/src/main/java/service/CalibrationService.java delete mode 100644 project/server_core/src/main/java/service/MapService.java delete mode 100644 project/server_core/src/main/java/service/MeasurementService.java delete mode 100644 project/server_core/src/main/java/service/PositioningService.java delete mode 100644 project/server_core/src/main/java/utils/HibernateUtil.java delete mode 100644 project/server_core/src/main/resources/hibernate.cfg.xml delete mode 100644 project/server_servlet/pom.xml delete mode 100644 project/server_servlet/server_servlet.iml delete mode 100644 project/server_servlet/src/main/java/APMeasurementServlet.java delete mode 100644 project/server_servlet/src/main/java/CalibrationServlet.java delete mode 100644 project/server_servlet/src/main/java/MapByteServlet.java delete mode 100644 project/server_servlet/src/main/java/MapScaleServlet.java delete mode 100644 project/server_servlet/src/main/java/PositioningServlet.java delete mode 100644 project/server_servlet/src/main/webapp/META-INF/MANIFEST.MF delete mode 100644 project/server_servlet/src/main/webapp/WEB-INF/web.xml create mode 100644 src/main/java/core/ServerApp.java create mode 100644 src/main/java/core/dao/DebianDao.java create mode 100644 src/main/java/core/dao/HibernateDao.java create mode 100644 src/main/java/core/repository/AccessPoint.java create mode 100644 src/main/java/core/repository/Location.java create mode 100644 src/main/java/core/repository/Map.java create mode 100644 src/main/java/core/repository/RssiRecord.java create mode 100644 src/main/java/core/repository/TempRssi.java create mode 100644 src/main/java/core/service/CalibrationService.java create mode 100644 src/main/java/core/service/MapService.java create mode 100644 src/main/java/core/service/MeasurementService.java create mode 100644 src/main/java/core/service/PositioningService.java create mode 100644 src/main/java/core/utils/HibernateUtil.java create mode 100644 src/main/java/servlet/APMeasurementServlet.java create mode 100644 src/main/java/servlet/CalibrationServlet.java create mode 100644 src/main/java/servlet/MapByteServlet.java create mode 100644 src/main/java/servlet/MapScaleServlet.java create mode 100644 src/main/java/servlet/PositioningServlet.java create mode 100644 src/main/resources/hibernate.cfg.xml create mode 100644 src/main/webapp/META-INF/MANIFEST.MF create mode 100644 src/main/webapp/WEB-INF/web.xml diff --git a/.idea/Positionning_server.iml b/.idea/Positionning_server.iml index d6ebd48..e4f06c8 100644 --- a/.idea/Positionning_server.iml +++ b/.idea/Positionning_server.iml @@ -1,8 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + diff --git a/.idea/artifacts/positioning_server_war.xml b/.idea/artifacts/positioning_server_war.xml new file mode 100644 index 0000000..6ba9988 --- /dev/null +++ b/.idea/artifacts/positioning_server_war.xml @@ -0,0 +1,8 @@ + + + $PROJECT_DIR$/target + + + + + \ No newline at end of file diff --git a/.idea/artifacts/positioning_server_war_exploded.xml b/.idea/artifacts/positioning_server_war_exploded.xml new file mode 100644 index 0000000..912b8bd --- /dev/null +++ b/.idea/artifacts/positioning_server_war_exploded.xml @@ -0,0 +1,29 @@ + + + $PROJECT_DIR$/target/positioning_server + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..1cb4004 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..6409283 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml index b18e385..1b43c0b 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,7 +2,7 @@ - + \ No newline at end of file diff --git a/PositioningServer/.idea/compiler.xml b/PositioningServer/.idea/compiler.xml deleted file mode 100644 index b8cb880..0000000 --- a/PositioningServer/.idea/compiler.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/PositioningServer/.idea/encodings.xml b/PositioningServer/.idea/encodings.xml deleted file mode 100644 index 3649061..0000000 --- a/PositioningServer/.idea/encodings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/PositioningServer/.idea/libraries/Maven__antlr_antlr_2_7_6.xml b/PositioningServer/.idea/libraries/Maven__antlr_antlr_2_7_6.xml deleted file mode 100644 index c8d18a7..0000000 --- a/PositioningServer/.idea/libraries/Maven__antlr_antlr_2_7_6.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/PositioningServer/.idea/libraries/Maven__commons_collections_commons_collections_3_1.xml b/PositioningServer/.idea/libraries/Maven__commons_collections_commons_collections_3_1.xml deleted file mode 100644 index 01dd005..0000000 --- a/PositioningServer/.idea/libraries/Maven__commons_collections_commons_collections_3_1.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/PositioningServer/.idea/libraries/Maven__dom4j_dom4j_1_6_1.xml b/PositioningServer/.idea/libraries/Maven__dom4j_dom4j_1_6_1.xml deleted file mode 100644 index 14681ee..0000000 --- a/PositioningServer/.idea/libraries/Maven__dom4j_dom4j_1_6_1.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/PositioningServer/.idea/libraries/Maven__javassist_javassist_3_9_0_GA.xml b/PositioningServer/.idea/libraries/Maven__javassist_javassist_3_9_0_GA.xml deleted file mode 100644 index 8d8be19..0000000 --- a/PositioningServer/.idea/libraries/Maven__javassist_javassist_3_9_0_GA.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/PositioningServer/.idea/libraries/Maven__javax_javaee_web_api_6_0.xml b/PositioningServer/.idea/libraries/Maven__javax_javaee_web_api_6_0.xml deleted file mode 100644 index 6f532e6..0000000 --- a/PositioningServer/.idea/libraries/Maven__javax_javaee_web_api_6_0.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/PositioningServer/.idea/libraries/Maven__javax_transaction_jta_1_1.xml b/PositioningServer/.idea/libraries/Maven__javax_transaction_jta_1_1.xml deleted file mode 100644 index 3047243..0000000 --- a/PositioningServer/.idea/libraries/Maven__javax_transaction_jta_1_1.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/PositioningServer/.idea/libraries/Maven__log4j_log4j_1_2_14.xml b/PositioningServer/.idea/libraries/Maven__log4j_log4j_1_2_14.xml deleted file mode 100644 index 2825a67..0000000 --- a/PositioningServer/.idea/libraries/Maven__log4j_log4j_1_2_14.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/PositioningServer/.idea/libraries/Maven__org_hibernate_hibernate_annotations_3_5_6_Final.xml b/PositioningServer/.idea/libraries/Maven__org_hibernate_hibernate_annotations_3_5_6_Final.xml deleted file mode 100644 index d26bdad..0000000 --- a/PositioningServer/.idea/libraries/Maven__org_hibernate_hibernate_annotations_3_5_6_Final.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/PositioningServer/.idea/libraries/Maven__org_hibernate_hibernate_commons_annotations_3_2_0_Final.xml b/PositioningServer/.idea/libraries/Maven__org_hibernate_hibernate_commons_annotations_3_2_0_Final.xml deleted file mode 100644 index dbb890e..0000000 --- a/PositioningServer/.idea/libraries/Maven__org_hibernate_hibernate_commons_annotations_3_2_0_Final.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/PositioningServer/.idea/libraries/Maven__org_hibernate_hibernate_core_3_5_6_Final.xml b/PositioningServer/.idea/libraries/Maven__org_hibernate_hibernate_core_3_5_6_Final.xml deleted file mode 100644 index 2083af8..0000000 --- a/PositioningServer/.idea/libraries/Maven__org_hibernate_hibernate_core_3_5_6_Final.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/PositioningServer/.idea/libraries/Maven__org_hibernate_javax_persistence_hibernate_jpa_2_0_api_1_0_0_Final.xml b/PositioningServer/.idea/libraries/Maven__org_hibernate_javax_persistence_hibernate_jpa_2_0_api_1_0_0_Final.xml deleted file mode 100644 index 6b42b8a..0000000 --- a/PositioningServer/.idea/libraries/Maven__org_hibernate_javax_persistence_hibernate_jpa_2_0_api_1_0_0_Final.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/PositioningServer/.idea/libraries/Maven__org_postgresql_postgresql_9_4_1212.xml b/PositioningServer/.idea/libraries/Maven__org_postgresql_postgresql_9_4_1212.xml deleted file mode 100644 index ad56bbd..0000000 --- a/PositioningServer/.idea/libraries/Maven__org_postgresql_postgresql_9_4_1212.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/PositioningServer/.idea/libraries/Maven__org_slf4j_slf4j_api_1_5_8.xml b/PositioningServer/.idea/libraries/Maven__org_slf4j_slf4j_api_1_5_8.xml deleted file mode 100644 index 0ea470a..0000000 --- a/PositioningServer/.idea/libraries/Maven__org_slf4j_slf4j_api_1_5_8.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/PositioningServer/.idea/libraries/Maven__org_slf4j_slf4j_log4j12_1_5_8.xml b/PositioningServer/.idea/libraries/Maven__org_slf4j_slf4j_log4j12_1_5_8.xml deleted file mode 100644 index f4725a3..0000000 --- a/PositioningServer/.idea/libraries/Maven__org_slf4j_slf4j_log4j12_1_5_8.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/PositioningServer/.idea/libraries/Maven__xml_apis_xml_apis_1_0_b2.xml b/PositioningServer/.idea/libraries/Maven__xml_apis_xml_apis_1_0_b2.xml deleted file mode 100644 index c36e717..0000000 --- a/PositioningServer/.idea/libraries/Maven__xml_apis_xml_apis_1_0_b2.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/PositioningServer/.idea/misc.xml b/PositioningServer/.idea/misc.xml deleted file mode 100644 index 6dc7b63..0000000 --- a/PositioningServer/.idea/misc.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/PositioningServer/.idea/modules.xml b/PositioningServer/.idea/modules.xml deleted file mode 100644 index 4cf1a76..0000000 --- a/PositioningServer/.idea/modules.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/PositioningServer/.idea/uiDesigner.xml b/PositioningServer/.idea/uiDesigner.xml deleted file mode 100644 index e96534f..0000000 --- a/PositioningServer/.idea/uiDesigner.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/PositioningServer/.idea/workspace.xml b/PositioningServer/.idea/workspace.xml deleted file mode 100644 index 56df425..0000000 --- a/PositioningServer/.idea/workspace.xml +++ /dev/null @@ -1,1159 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1494341366447 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - file://$PROJECT_DIR$/src/main/java/com/utbm/lo53/dao/HibernateDao.java - 77 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No facets are configured - - - - - - - - - - - - - - - 1.8 - - - - - - - - PositioningServer - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/PositioningServer/PositioningServer.iml b/PositioningServer/PositioningServer.iml deleted file mode 100644 index 924ebe1..0000000 --- a/PositioningServer/PositioningServer.iml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/PositioningServer/Server_Servlets/Server_Servlets.iml b/PositioningServer/Server_Servlets/Server_Servlets.iml deleted file mode 100644 index f599562..0000000 --- a/PositioningServer/Server_Servlets/Server_Servlets.iml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/PositioningServer/Server_Servlets/pom.xml b/PositioningServer/Server_Servlets/pom.xml deleted file mode 100644 index 6bdeb0c..0000000 --- a/PositioningServer/Server_Servlets/pom.xml +++ /dev/null @@ -1,76 +0,0 @@ - - 4.0.0 - - com.utbm.lo53 - Server_Servlet - 1.0-SNAPSHOT - war - - Server_Servlet - - - ${project.build.directory}/endorsed - UTF-8 - - - - - javax - javaee-web-api - 6.0 - provided - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - 1.6 - 1.6 - - ${endorsed.dir} - - - - - org.apache.maven.plugins - maven-war-plugin - 2.1.1 - - false - - - - org.apache.maven.plugins - maven-dependency-plugin - 2.1 - - - validate - - copy - - - ${endorsed.dir} - true - - - javax - javaee-endorsed-api - 6.0 - jar - - - - - - - - - - diff --git a/PositioningServer/Server_Servlets/src/WEB-INF/web.xml b/PositioningServer/Server_Servlets/src/WEB-INF/web.xml deleted file mode 100644 index 5a3d07e..0000000 --- a/PositioningServer/Server_Servlets/src/WEB-INF/web.xml +++ /dev/null @@ -1,19 +0,0 @@ - - calibrationServlet - servlets.com.utbm.lo53.CalibrationServlet - - - - calibrationServlet - /calibration - - - - positioningServlet - servlets.PositioningServlet - - - - positioningServlet - /positioning - \ No newline at end of file diff --git a/PositioningServer/Server_Servlets/src/main/java/com/utbm/lo53/CalibrationServlet.java b/PositioningServer/Server_Servlets/src/main/java/com/utbm/lo53/CalibrationServlet.java deleted file mode 100644 index ef7e7eb..0000000 --- a/PositioningServer/Server_Servlets/src/main/java/com/utbm/lo53/CalibrationServlet.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.utbm.lo53; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - * Created by Guillaume on 15/05/2017. - */ -//TODO à compiler et à placer dans le dossier WEB-INF\Servlets -public class CalibrationServlet extends HttpServlet{ - @Override - public void service (final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) - throws ServletException, IOException { - //TODO - } - - @Override - public void doGet(final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) - throws ServletException, IOException { - service(servletRequest, servletResponse); - } - - @Override - public void doPost(final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) - throws ServletException, IOException { - service(servletRequest, servletResponse); - } -} diff --git a/PositioningServer/Server_Servlets/src/main/java/com/utbm/lo53/PositioningServlet.java b/PositioningServer/Server_Servlets/src/main/java/com/utbm/lo53/PositioningServlet.java deleted file mode 100644 index 7f51871..0000000 --- a/PositioningServer/Server_Servlets/src/main/java/com/utbm/lo53/PositioningServlet.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.utbm.lo53; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - * Created by Guillaume on 15/05/2017. - */ -//TODO à compiler et à placer dans le dossier WEB-INF\Servlets -public class PositioningServlet extends HttpServlet{ - @Override - public void service (final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) - throws ServletException, IOException { - //TODO - } - - @Override - public void doGet(final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) - throws ServletException, IOException { - service(servletRequest, servletResponse); - } - - @Override - public void doPost(final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) - throws ServletException, IOException { - service(servletRequest, servletResponse); - } -} diff --git a/PositioningServer/Server_Servlets/src/main/webapp/index.jsp b/PositioningServer/Server_Servlets/src/main/webapp/index.jsp deleted file mode 100644 index ab292c3..0000000 --- a/PositioningServer/Server_Servlets/src/main/webapp/index.jsp +++ /dev/null @@ -1,13 +0,0 @@ -<%@page contentType="text/html" pageEncoding="UTF-8"%> - - - - - - JSP Page - - -

Hello World!

- - diff --git a/PositioningServer/pom.xml b/PositioningServer/pom.xml deleted file mode 100644 index b3cf36e..0000000 --- a/PositioningServer/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - 4.0.0 - - com.utbm.lo53 - PositioningServer - 1.0-SNAPSHOT - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.8 - 1.8 - - - - - - - - - org.postgresql - postgresql - 9.4.1212 - - - - - org.hibernate - hibernate-core - 3.5.6-Final - - - - - org.hibernate - hibernate-annotations - 3.5.6-Final - - - - - org.slf4j - slf4j-log4j12 - 1.5.8 - runtime - - - - javassist - javassist - 3.9.0.GA - runtime - - - \ No newline at end of file diff --git a/PositioningServer/src/main/java/ServerApp.java b/PositioningServer/src/main/java/ServerApp.java deleted file mode 100644 index 37b24a3..0000000 --- a/PositioningServer/src/main/java/ServerApp.java +++ /dev/null @@ -1,18 +0,0 @@ -import com.utbm.lo53.dao.HibernateDao; -import com.utbm.lo53.repository.AccessPoint; -import com.utbm.lo53.repository.Mape; - -/** - * Created by Guillaume on 09/05/2017. - */ -public class ServerApp { - public static void main(String args[]){ - HibernateDao dao = new HibernateDao(); - AccessPoint ap = new AccessPoint(); - ap.setMac_addr("aa:aa:aa:aa:aa:aa:aa:aa"); - dao.saveAccessPoint(ap); - /* - Mape mape = new Mape(); - dao.saveMap(mape);/**/ - } -} diff --git a/PositioningServer/src/main/java/com/utbm/lo53/dao/DebianDao.java b/PositioningServer/src/main/java/com/utbm/lo53/dao/DebianDao.java deleted file mode 100644 index 079842f..0000000 --- a/PositioningServer/src/main/java/com/utbm/lo53/dao/DebianDao.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.utbm.lo53.dao; - -/** - * Created by Guillaume on 09/05/2017. - */ -public class DebianDao { - - public String getMacAddr(String ipAddr){return null;} -} diff --git a/PositioningServer/src/main/java/com/utbm/lo53/dao/HibernateDao.java b/PositioningServer/src/main/java/com/utbm/lo53/dao/HibernateDao.java deleted file mode 100644 index f4761b2..0000000 --- a/PositioningServer/src/main/java/com/utbm/lo53/dao/HibernateDao.java +++ /dev/null @@ -1,175 +0,0 @@ -package com.utbm.lo53.dao; - -import com.utbm.lo53.repository.*; -import com.utbm.lo53.utils.HibernateUtil; -import org.hibernate.HibernateException; -import org.hibernate.Query; -import org.hibernate.Session; - -import java.util.ArrayList; -import java.util.List; - -/** - * Created by Guillaume on 09/05/2017. - */ -public class HibernateDao { - - public HibernateDao () { - } - - private TransactionCallBack execTransactionProcess(ITransactionProcess itp) { - Session session = HibernateUtil.getSessionFactory().openSession(); - TransactionCallBack reply = new TransactionCallBack(); - try { - session.beginTransaction(); - reply = itp.exec(session); - session.getTransaction().commit(); - reply.setStatus(true); - return reply; - } catch (HibernateException he) { - he.printStackTrace(); - if (session.getTransaction() != null) { - try { - session.getTransaction().rollback(); - } catch (HibernateException he2) { - he2.printStackTrace(); - } - } - } finally { - if (session != null) { - try { - session.close(); - } catch (HibernateException ex) { - ex.printStackTrace(); - } - } - } - return reply; - } - private List internal_getData(Class clazz){ - TransactionCallBack callBack = execTransactionProcess((session)->{ - TransactionCallBack reply = new TransactionCallBack(); - Query query = session.createQuery("from "+clazz.getSimpleName()); - List results = query.list(); - for(Object result : results){ - if(clazz.isInstance(result)) - reply.getResults().add(result); - } - return reply; - }); - return callBack.getResults(); - } - private boolean internal_saveData(Object... objs){ - TransactionCallBack callBack = execTransactionProcess((session)->{ - TransactionCallBack reply = new TransactionCallBack(); - for(Object obj : objs){ - session.persist(obj); - } - return reply; - }); - - return callBack!=null && callBack.isStatus(); - } - - public boolean saveTempRssi(TempRssi... trs){ - return internal_saveData(trs); - } - public List getTempRssi(String macAddr){ - if(macAddr == null) - return new ArrayList<>(); - - TransactionCallBack callBack = execTransactionProcess((session)->{ - TransactionCallBack reply = new TransactionCallBack(); - Query query = session.createQuery("from TempRssi tr where tr.client_mac_addr = :mac_addr"); - query.setParameter("mac_addr", macAddr); - List results = query.list(); - for(Object result : results){ - if(result instanceof TempRssi) - reply.getResults().add(result); - } - return reply; - }); - return callBack.getResults(); - } - - public boolean saveRssiRecord(RssiRecord... rssis){ - return internal_saveData(rssis); - } - public List getRssiRecord(){ - return internal_getData(RssiRecord.class); - } - public List getRssiRecord(Integer locationID){ - if(locationID == null) - return getRssiRecord(); - - TransactionCallBack callBack = execTransactionProcess((session)->{ - TransactionCallBack reply = new TransactionCallBack(); - Query query = session.createQuery("from RssiRecord rr where rr.id = :id"); - query.setParameter("id", locationID); - List results = query.list(); - for(Object result : results){ - if(result instanceof RssiRecord) - reply.getResults().add(result); - } - return reply; - }); - return callBack.getResults(); - } - - public List getLocations(){ - return internal_getData(Location.class); - } - - public boolean saveAccessPoint (final AccessPoint... aps) { - return internal_saveData(aps); - } - public List getAccessPoint () { - return internal_getData(AccessPoint.class); - } - - public boolean saveMap(final Mape mape){return internal_saveData(mape);} - public Mape getMap(int mapId){ - TransactionCallBack callBack = execTransactionProcess((session)->{ - TransactionCallBack reply = new TransactionCallBack(); - Query query = session.createQuery("from Mape m where m.id = :id"); - query.setParameter("id", mapId); - List results = query.list(); - for(Object result : results){ - if(result instanceof RssiRecord) - reply.getResults().add(result); - } - return reply; - }); - return (callBack.getResults().isEmpty()?null:(Mape)callBack.getResults().get(0)); - } - - private interface ITransactionProcess{ - public TransactionCallBack exec(Session tr); - } - - private class TransactionCallBack{ - private boolean status; - private List results; - - public TransactionCallBack () { - status = false; - results = new ArrayList(); - } - - public boolean isStatus () { - return status; - } - - public void setStatus (final boolean status) { - this.status = status; - } - - public List getResults () { - return results; - } - - public void setResults (final List results) { - this.results = results; - } - } -} diff --git a/PositioningServer/src/main/java/com/utbm/lo53/repository/AccessPoint.java b/PositioningServer/src/main/java/com/utbm/lo53/repository/AccessPoint.java deleted file mode 100644 index 8a3ef08..0000000 --- a/PositioningServer/src/main/java/com/utbm/lo53/repository/AccessPoint.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.utbm.lo53.repository; - -import java.io.Serializable; -import javax.persistence.*; - -/** - * Created by Guillaume on 09/05/2017. - */ -@Entity -@Table(name ="ACCESS_POINT") -public class AccessPoint implements Serializable{ - @Id @GeneratedValue - private Integer id; - - private String mac_addr; - - public AccessPoint () { - } - - public AccessPoint(Integer id, String mac_addr){ - this.mac_addr = mac_addr; - } - - public Integer getId(){return id;} - - public void setId(Integer id){this.id = id;} - - public String getMac_addr () { - return mac_addr; - } - - public void setMac_addr (final String mac_addr) { - this.mac_addr = mac_addr; - } -} diff --git a/PositioningServer/src/main/java/com/utbm/lo53/repository/Location.java b/PositioningServer/src/main/java/com/utbm/lo53/repository/Location.java deleted file mode 100644 index de6e66d..0000000 --- a/PositioningServer/src/main/java/com/utbm/lo53/repository/Location.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.utbm.lo53.repository; - -import javax.persistence.*; -import java.io.Serializable; - -/** - * Created by Guillaume on 09/05/2017. - */ -@Entity -@Table(name = "LOCATION") -public class Location implements Serializable { - @Id @GeneratedValue - private Integer id; - private Double x, y; - - @OneToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "id", nullable = false) - private Mape mape; - - public Location () { - } - - public Integer getId(){return id;} - - public void setId(Integer id){this.id = id;} - - public Double getX () { - return x; - } - - public void setX (final Double x) { - this.x = x; - } - - public Double getY () { - return y; - } - - public void setY (final Double y) { - this.y = y; - } - - public Mape getMape () { - return mape; - } - - public void setMape (final Mape mape) { - this.mape = mape; - } -} diff --git a/PositioningServer/src/main/java/com/utbm/lo53/repository/Mape.java b/PositioningServer/src/main/java/com/utbm/lo53/repository/Mape.java deleted file mode 100644 index dba7d2b..0000000 --- a/PositioningServer/src/main/java/com/utbm/lo53/repository/Mape.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.utbm.lo53.repository; - -import javax.persistence.*; -import java.io.Serializable; - -/** - * Created by Guillaume on 09/05/2017. - */ -@Entity -@Table(name = "MAPE") -public class Mape implements Serializable{ - @Id @GeneratedValue - private Integer id; - private Integer px_width, px_height; - private Byte[] content; - private String desc; - private Double m_width, m_height; - - public Mape () { - } - - public Integer getId () { - return id; - } - - public void setId (final Integer id) { - this.id = id; - } - - public Integer getPx_width () { - return px_width; - } - - public void setPx_width (final Integer px_width) { - this.px_width = px_width; - } - - public Integer getPx_height () { - return px_height; - } - - public void setPx_height (final Integer px_height) { - this.px_height = px_height; - } - - public Byte[] getContent () { - return content; - } - - public void setContent (final Byte[] content) { - this.content = content; - } - - public String getDesc () { - return desc; - } - - public void setDesc (final String desc) { - this.desc = desc; - } - - public Double getM_width () { - return m_width; - } - - public void setM_width (final Double m_width) { - this.m_width = m_width; - } - - public Double getM_height () { - return m_height; - } - - public void setM_height (final Double m_height) { - this.m_height = m_height; - } -} diff --git a/PositioningServer/src/main/java/com/utbm/lo53/repository/RssiRecord.java b/PositioningServer/src/main/java/com/utbm/lo53/repository/RssiRecord.java deleted file mode 100644 index f613a1c..0000000 --- a/PositioningServer/src/main/java/com/utbm/lo53/repository/RssiRecord.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.utbm.lo53.repository; - -import javax.persistence.*; -import java.io.Serializable; - -/** - * Created by Guillaume on 09/05/2017. - */ -@Entity -@Table (name = "RSSI_RECORD") -public class RssiRecord implements Serializable { - @Id @GeneratedValue - private Integer id; - - - @OneToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "id", nullable = false) - private Location loc; - - @OneToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "id", nullable = false) - private AccessPoint ap; - - private Double avg; - private Double stdDev; - - public RssiRecord () { - } - - public RssiRecord(Location loc, AccessPoint ap, Double avg, Double stdDev){ - id = null; - this.loc = loc; - this.ap = ap; - this.avg = avg; - this.stdDev = stdDev; - } - - public Location getLoc () { - return loc; - } - - public void setLoc (final Location loc) { - this.loc = loc; - } - - public AccessPoint getAp () { - return ap; - } - - public void setAp (final AccessPoint ap) { - this.ap = ap; - } - - public Double getAvg () { - return avg; - } - - public void setAvg (final Double avg) { - this.avg = avg; - } - - public Double getStdDev () { - return stdDev; - } - - public void setStdDev (final Double stdDev) { - this.stdDev = stdDev; - } -} diff --git a/PositioningServer/src/main/java/com/utbm/lo53/repository/TempRssi.java b/PositioningServer/src/main/java/com/utbm/lo53/repository/TempRssi.java deleted file mode 100644 index b80ce13..0000000 --- a/PositioningServer/src/main/java/com/utbm/lo53/repository/TempRssi.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.utbm.lo53.repository; - -import javax.persistence.*; - -/** - * Created by Guillaume on 09/05/2017. - */ -@Entity -@Table (name = "TEMP_RSSI") -public class TempRssi { - @Id @GeneratedValue - private Integer id; - - @OneToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "id", nullable = false) - private AccessPoint ap; - - private String client_mac_addr; - private Double avg, stdDev; - - public TempRssi () {} - - public AccessPoint getAp () { - return ap; - } - - public void setAp (final AccessPoint ap) { - this.ap = ap; - } - - public String getClient_mac_addr () { - return client_mac_addr; - } - - public void setClient_mac_addr (final String client_mac_addr) { - this.client_mac_addr = client_mac_addr; - } - - public Double getAvg () { - return avg; - } - - public void setAvg (final Double avg) { - this.avg = avg; - } - - public Double getStdDev () { - return stdDev; - } - - public void setStdDev (final Double stdDev) { - this.stdDev = stdDev; - } -} diff --git a/PositioningServer/src/main/java/com/utbm/lo53/service/CalibrationService.java b/PositioningServer/src/main/java/com/utbm/lo53/service/CalibrationService.java deleted file mode 100644 index 8034289..0000000 --- a/PositioningServer/src/main/java/com/utbm/lo53/service/CalibrationService.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.utbm.lo53.service; - -import com.utbm.lo53.dao.HibernateDao; -import com.utbm.lo53.repository.AccessPoint; -import com.utbm.lo53.repository.RssiRecord; - -import java.util.List; - -/** - * Created by Guillaume on 09/05/2017. - */ -public class CalibrationService { - - private HibernateDao dao; - - public CalibrationService(){this.dao = new HibernateDao();} - public CalibrationService(HibernateDao dao){this.dao = dao;} - - public boolean registerCalibrationData(RssiRecord... records){ - return dao.saveRssiRecord(records); - } - public boolean registerAp(AccessPoint ap){ - return dao.saveAccessPoint(ap); - } - public List getAllAccessPoints(){return dao.getAccessPoint();} -} diff --git a/PositioningServer/src/main/java/com/utbm/lo53/service/ConnectionService.java b/PositioningServer/src/main/java/com/utbm/lo53/service/ConnectionService.java deleted file mode 100644 index 321e450..0000000 --- a/PositioningServer/src/main/java/com/utbm/lo53/service/ConnectionService.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.utbm.lo53.service; - -/** - * Created by Guillaume on 09/05/2017. - */ -public class ConnectionService { - - - public void queryApData(boolean tryAgainMessage){} - public void acknoledge(){} - public void sendPosition(){} -} diff --git a/PositioningServer/src/main/java/com/utbm/lo53/service/PositioningService.java b/PositioningServer/src/main/java/com/utbm/lo53/service/PositioningService.java deleted file mode 100644 index a969627..0000000 --- a/PositioningServer/src/main/java/com/utbm/lo53/service/PositioningService.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.utbm.lo53.service; - -import com.utbm.lo53.dao.HibernateDao; -import com.utbm.lo53.repository.Location; -import com.utbm.lo53.repository.RssiRecord; -import com.utbm.lo53.repository.TempRssi; - -import java.util.ArrayList; -import java.util.List; - -/** - * Created by Guillaume on 09/05/2017. - */ -public class PositioningService { - - private static final double DEFAULT_POSITIONING_PRECISION = 7.5; - - private HibernateDao dao; - - public PositioningService () { - this.dao = new HibernateDao(); - } - public PositioningService (HibernateDao dao) { - this.dao = dao; - } - - public Location getLocation (String clientMacAddr) { - Location bestLoc = null; - double bestLocProbability = -1; - for(Location loc : dao.getLocations()) { - //Liste des RSSISample pour une position donnée, chaque RSSISample étant - //assossié à un AccessPoint - List rssis = dao.getRssiRecord(loc.getId()); - - //Liste des RSSISample associé à un ap, mesuré pour un client - List clientRssi = dao.getTempRssi(clientMacAddr); - - double currentLocProbability = probability(clientRssi, rssis, DEFAULT_POSITIONING_PRECISION); - if(bestLocProbability == -1 || currentLocProbability > bestLocProbability){ - bestLoc = loc; - bestLocProbability = currentLocProbability; - } - } - return bestLoc; - } - - private double probability(List temps, List rssis, double precision){ - try { - double probability = 1; - for (TempRssi temp : temps) { - RssiRecord rssi = find(temp.getAp().getMac_addr(), rssis); - probability*=gauss_probability(temp.getAvg(), temp.getStdDev(), rssi.getAvg(), rssi.getStdDev(), precision); - } - return probability; - }catch(IllegalArgumentException e){ - e.printStackTrace(); - return -1; - } - } - private double gauss_probability(double avg1, double std1, double avg2, double std2, double precision){ - final double - valDebut = Math.min(avg1-3*std1, avg2-3*std2), - valFin = Math.max(avg1+3*std1, avg2+3*std2); - double - rectDebut = valDebut, - rectFin = valDebut+precision, - probabilite = 0; - - do{ - probabilite+=Math.min( gauss(avg1, std1, (rectDebut+rectFin)/2), gauss(avg2, std2, (rectDebut+rectFin)/2)); - rectDebut = rectFin; - rectFin+=precision; - }while(rectFin rrs){ - final List results = new ArrayList<>(); - rrs.stream().filter(rr->rr.getAp().getMac_addr().equals(macAddr)).forEach(rr->results.add(rr)); - - switch(results.size()){ - case 0: - throw new IllegalArgumentException("No matching RssiRecord for mac address <"+macAddr+">"); - case 1: - return results.get(0); - default : - throw new IllegalArgumentException("Several("+results.size()+") matching RssiRecord for mac address <"+macAddr+">"); - } - } - - -} diff --git a/PositioningServer/src/main/java/com/utbm/lo53/utils/HibernateUtil.java b/PositioningServer/src/main/java/com/utbm/lo53/utils/HibernateUtil.java deleted file mode 100644 index 8e5a130..0000000 --- a/PositioningServer/src/main/java/com/utbm/lo53/utils/HibernateUtil.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.utbm.lo53.utils; - -import org.hibernate.SessionFactory; -import org.hibernate.cfg.AnnotationConfiguration; -import org.hibernate.cfg.Configuration; - -public class HibernateUtil { - - private static final SessionFactory sessionFactory = buildSessionFactory(); - private static SessionFactory buildSessionFactory() { - try { - // Create the SessionFactory from hibernate.cfg.xml - return new AnnotationConfiguration().configure().buildSessionFactory(); - } catch (Exception ex) { - System.err.println("Initial SessionFactory creation failed." + ex); - throw new ExceptionInInitializerError(ex); - } - } - public static SessionFactory getSessionFactory() { - return sessionFactory; - } -} \ No newline at end of file diff --git a/PositioningServer/src/main/resources/hibernate.cfg.xml b/PositioningServer/src/main/resources/hibernate.cfg.xml deleted file mode 100644 index b48ea48..0000000 --- a/PositioningServer/src/main/resources/hibernate.cfg.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - org.postgresql.Driver - jdbc:postgresql://localhost:5432/LO53_BDD - org.hibernate.dialect.PostgreSQLDialect - lo53_user - lo53 - 1 - update - - - - - - - - \ No newline at end of file diff --git a/PositioningServer/target/classes/ServerApp.class b/PositioningServer/target/classes/ServerApp.class deleted file mode 100644 index e45a78c..0000000 Binary files a/PositioningServer/target/classes/ServerApp.class and /dev/null differ diff --git a/PositioningServer/target/classes/com/utbm/lo53/dao/DebianDao.class b/PositioningServer/target/classes/com/utbm/lo53/dao/DebianDao.class deleted file mode 100644 index 0e48177..0000000 Binary files a/PositioningServer/target/classes/com/utbm/lo53/dao/DebianDao.class and /dev/null differ diff --git a/PositioningServer/target/classes/com/utbm/lo53/dao/HibernateDao$ITransactionProcess.class b/PositioningServer/target/classes/com/utbm/lo53/dao/HibernateDao$ITransactionProcess.class deleted file mode 100644 index c4ce194..0000000 Binary files a/PositioningServer/target/classes/com/utbm/lo53/dao/HibernateDao$ITransactionProcess.class and /dev/null differ diff --git a/PositioningServer/target/classes/com/utbm/lo53/dao/HibernateDao$TransactionCallBack.class b/PositioningServer/target/classes/com/utbm/lo53/dao/HibernateDao$TransactionCallBack.class deleted file mode 100644 index dadcb5f..0000000 Binary files a/PositioningServer/target/classes/com/utbm/lo53/dao/HibernateDao$TransactionCallBack.class and /dev/null differ diff --git a/PositioningServer/target/classes/com/utbm/lo53/dao/HibernateDao.class b/PositioningServer/target/classes/com/utbm/lo53/dao/HibernateDao.class deleted file mode 100644 index 5ed4291..0000000 Binary files a/PositioningServer/target/classes/com/utbm/lo53/dao/HibernateDao.class and /dev/null differ diff --git a/PositioningServer/target/classes/com/utbm/lo53/repository/AccessPoint.class b/PositioningServer/target/classes/com/utbm/lo53/repository/AccessPoint.class deleted file mode 100644 index 0507331..0000000 Binary files a/PositioningServer/target/classes/com/utbm/lo53/repository/AccessPoint.class and /dev/null differ diff --git a/PositioningServer/target/classes/com/utbm/lo53/repository/Location.class b/PositioningServer/target/classes/com/utbm/lo53/repository/Location.class deleted file mode 100644 index 6f72956..0000000 Binary files a/PositioningServer/target/classes/com/utbm/lo53/repository/Location.class and /dev/null differ diff --git a/PositioningServer/target/classes/com/utbm/lo53/repository/Mape.class b/PositioningServer/target/classes/com/utbm/lo53/repository/Mape.class deleted file mode 100644 index 14f7bd8..0000000 Binary files a/PositioningServer/target/classes/com/utbm/lo53/repository/Mape.class and /dev/null differ diff --git a/PositioningServer/target/classes/com/utbm/lo53/repository/RssiRecord.class b/PositioningServer/target/classes/com/utbm/lo53/repository/RssiRecord.class deleted file mode 100644 index 033919e..0000000 Binary files a/PositioningServer/target/classes/com/utbm/lo53/repository/RssiRecord.class and /dev/null differ diff --git a/PositioningServer/target/classes/com/utbm/lo53/repository/TempRssi.class b/PositioningServer/target/classes/com/utbm/lo53/repository/TempRssi.class deleted file mode 100644 index baaf54c..0000000 Binary files a/PositioningServer/target/classes/com/utbm/lo53/repository/TempRssi.class and /dev/null differ diff --git a/PositioningServer/target/classes/com/utbm/lo53/service/CalibrationService.class b/PositioningServer/target/classes/com/utbm/lo53/service/CalibrationService.class deleted file mode 100644 index ff70162..0000000 Binary files a/PositioningServer/target/classes/com/utbm/lo53/service/CalibrationService.class and /dev/null differ diff --git a/PositioningServer/target/classes/com/utbm/lo53/service/ConnectionService.class b/PositioningServer/target/classes/com/utbm/lo53/service/ConnectionService.class deleted file mode 100644 index aea6e7f..0000000 Binary files a/PositioningServer/target/classes/com/utbm/lo53/service/ConnectionService.class and /dev/null differ diff --git a/PositioningServer/target/classes/com/utbm/lo53/service/PositioningService.class b/PositioningServer/target/classes/com/utbm/lo53/service/PositioningService.class deleted file mode 100644 index fda5486..0000000 Binary files a/PositioningServer/target/classes/com/utbm/lo53/service/PositioningService.class and /dev/null differ diff --git a/PositioningServer/target/classes/com/utbm/lo53/utils/HibernateUtil.class b/PositioningServer/target/classes/com/utbm/lo53/utils/HibernateUtil.class deleted file mode 100644 index 0219891..0000000 Binary files a/PositioningServer/target/classes/com/utbm/lo53/utils/HibernateUtil.class and /dev/null differ diff --git a/PositioningServer/target/classes/hibernate.cfg.xml b/PositioningServer/target/classes/hibernate.cfg.xml deleted file mode 100644 index b48ea48..0000000 --- a/PositioningServer/target/classes/hibernate.cfg.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - org.postgresql.Driver - jdbc:postgresql://localhost:5432/LO53_BDD - org.hibernate.dialect.PostgreSQLDialect - lo53_user - lo53 - 1 - update - - - - - - - - \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..785f070 --- /dev/null +++ b/pom.xml @@ -0,0 +1,77 @@ + + 4.0.0 + com.utbm.lo53 + positioning_server + war + 1.0-SNAPSHOT + positioning_server Maven Webapp + http://maven.apache.org + + + + + + junit + junit + 3.8.1 + test + + + + javax + javaee-web-api + 6.0 + provided + + + + + org.postgresql + postgresql + 9.4.1212 + + + + + org.hibernate + hibernate-core + 3.5.6-Final + + + + + org.hibernate + hibernate-annotations + 3.5.6-Final + + + + + org.slf4j + slf4j-log4j12 + 1.5.8 + runtime + + + + javassist + javassist + 3.9.0.GA + runtime + + + + positioning_server + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + diff --git a/positioning_server.iml b/positioning_server.iml new file mode 100644 index 0000000..4d758a5 --- /dev/null +++ b/positioning_server.iml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/project/.idea/artifacts/servlets.xml b/project/.idea/artifacts/servlets.xml deleted file mode 100644 index 902d4de..0000000 --- a/project/.idea/artifacts/servlets.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - $PROJECT_DIR$/out/artifacts/servlets - - - - - - - - - - - - \ No newline at end of file diff --git a/project/.idea/compiler.xml b/project/.idea/compiler.xml deleted file mode 100644 index 70ac13f..0000000 --- a/project/.idea/compiler.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/project/.idea/libraries/Maven__antlr_antlr_2_7_6.xml b/project/.idea/libraries/Maven__antlr_antlr_2_7_6.xml deleted file mode 100644 index c8d18a7..0000000 --- a/project/.idea/libraries/Maven__antlr_antlr_2_7_6.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/project/.idea/libraries/Maven__commons_collections_commons_collections_3_1.xml b/project/.idea/libraries/Maven__commons_collections_commons_collections_3_1.xml deleted file mode 100644 index 01dd005..0000000 --- a/project/.idea/libraries/Maven__commons_collections_commons_collections_3_1.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/project/.idea/libraries/Maven__dom4j_dom4j_1_6_1.xml b/project/.idea/libraries/Maven__dom4j_dom4j_1_6_1.xml deleted file mode 100644 index 14681ee..0000000 --- a/project/.idea/libraries/Maven__dom4j_dom4j_1_6_1.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/project/.idea/libraries/Maven__javassist_javassist_3_9_0_GA.xml b/project/.idea/libraries/Maven__javassist_javassist_3_9_0_GA.xml deleted file mode 100644 index 8d8be19..0000000 --- a/project/.idea/libraries/Maven__javassist_javassist_3_9_0_GA.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/project/.idea/libraries/Maven__javax_javaee_web_api_6_0.xml b/project/.idea/libraries/Maven__javax_javaee_web_api_6_0.xml deleted file mode 100644 index 6f532e6..0000000 --- a/project/.idea/libraries/Maven__javax_javaee_web_api_6_0.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/project/.idea/libraries/Maven__javax_transaction_jta_1_1.xml b/project/.idea/libraries/Maven__javax_transaction_jta_1_1.xml deleted file mode 100644 index 3047243..0000000 --- a/project/.idea/libraries/Maven__javax_transaction_jta_1_1.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/project/.idea/libraries/Maven__log4j_log4j_1_2_14.xml b/project/.idea/libraries/Maven__log4j_log4j_1_2_14.xml deleted file mode 100644 index 2825a67..0000000 --- a/project/.idea/libraries/Maven__log4j_log4j_1_2_14.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/project/.idea/libraries/Maven__org_hibernate_hibernate_annotations_3_5_6_Final.xml b/project/.idea/libraries/Maven__org_hibernate_hibernate_annotations_3_5_6_Final.xml deleted file mode 100644 index d26bdad..0000000 --- a/project/.idea/libraries/Maven__org_hibernate_hibernate_annotations_3_5_6_Final.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/project/.idea/libraries/Maven__org_hibernate_hibernate_commons_annotations_3_2_0_Final.xml b/project/.idea/libraries/Maven__org_hibernate_hibernate_commons_annotations_3_2_0_Final.xml deleted file mode 100644 index dbb890e..0000000 --- a/project/.idea/libraries/Maven__org_hibernate_hibernate_commons_annotations_3_2_0_Final.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/project/.idea/libraries/Maven__org_hibernate_hibernate_core_3_5_6_Final.xml b/project/.idea/libraries/Maven__org_hibernate_hibernate_core_3_5_6_Final.xml deleted file mode 100644 index 2083af8..0000000 --- a/project/.idea/libraries/Maven__org_hibernate_hibernate_core_3_5_6_Final.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/project/.idea/libraries/Maven__org_hibernate_javax_persistence_hibernate_jpa_2_0_api_1_0_0_Final.xml b/project/.idea/libraries/Maven__org_hibernate_javax_persistence_hibernate_jpa_2_0_api_1_0_0_Final.xml deleted file mode 100644 index 6b42b8a..0000000 --- a/project/.idea/libraries/Maven__org_hibernate_javax_persistence_hibernate_jpa_2_0_api_1_0_0_Final.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/project/.idea/libraries/Maven__org_postgresql_postgresql_9_4_1212.xml b/project/.idea/libraries/Maven__org_postgresql_postgresql_9_4_1212.xml deleted file mode 100644 index ad56bbd..0000000 --- a/project/.idea/libraries/Maven__org_postgresql_postgresql_9_4_1212.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/project/.idea/libraries/Maven__org_slf4j_slf4j_api_1_5_8.xml b/project/.idea/libraries/Maven__org_slf4j_slf4j_api_1_5_8.xml deleted file mode 100644 index 0ea470a..0000000 --- a/project/.idea/libraries/Maven__org_slf4j_slf4j_api_1_5_8.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/project/.idea/libraries/Maven__org_slf4j_slf4j_log4j12_1_5_8.xml b/project/.idea/libraries/Maven__org_slf4j_slf4j_log4j12_1_5_8.xml deleted file mode 100644 index f4725a3..0000000 --- a/project/.idea/libraries/Maven__org_slf4j_slf4j_log4j12_1_5_8.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/project/.idea/libraries/Maven__xml_apis_xml_apis_1_0_b2.xml b/project/.idea/libraries/Maven__xml_apis_xml_apis_1_0_b2.xml deleted file mode 100644 index c36e717..0000000 --- a/project/.idea/libraries/Maven__xml_apis_xml_apis_1_0_b2.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/project/.idea/misc.xml b/project/.idea/misc.xml deleted file mode 100644 index e8942bd..0000000 --- a/project/.idea/misc.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/project/.idea/modules.xml b/project/.idea/modules.xml deleted file mode 100644 index 30a22c7..0000000 --- a/project/.idea/modules.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/project/.idea/workspace.xml b/project/.idea/workspace.xml deleted file mode 100644 index bd6cba3..0000000 --- a/project/.idea/workspace.xml +++ /dev/null @@ -1,1107 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1495960020203 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - servlets - - - - - - - - No facets are configured - - - - - - - - - - - - - - - 1.8 - - - - - - - - server_servlet - - - - - - - - Maven: antlr:antlr:2.7.6 - - - - - - - - \ No newline at end of file diff --git a/project/pom.xml b/project/pom.xml deleted file mode 100644 index 0929d1e..0000000 --- a/project/pom.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - 4.0.0 - - com.utbm.lo53 - project - pom - 1.0-SNAPSHOT - - server_core - server_servlet - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.8 - 1.8 - - - - - - - - org.postgresql - postgresql - 9.4.1212 - - - - - org.hibernate - hibernate-core - 3.5.6-Final - - - - - org.hibernate - hibernate-annotations - 3.5.6-Final - - - - - org.slf4j - slf4j-log4j12 - 1.5.8 - runtime - - - - javassist - javassist - 3.9.0.GA - runtime - - - - \ No newline at end of file diff --git a/project/project.iml b/project/project.iml deleted file mode 100644 index 924ebe1..0000000 --- a/project/project.iml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/project/server_core/pom.xml b/project/server_core/pom.xml deleted file mode 100644 index 8599beb..0000000 --- a/project/server_core/pom.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - project - com.utbm.lo53 - 1.0-SNAPSHOT - - jar - 4.0.0 - - server_core - - - \ No newline at end of file diff --git a/project/server_core/server_core.iml b/project/server_core/server_core.iml deleted file mode 100644 index 924ebe1..0000000 --- a/project/server_core/server_core.iml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/project/server_core/src/main/java/ServerApp.java b/project/server_core/src/main/java/ServerApp.java deleted file mode 100644 index 650bc9d..0000000 --- a/project/server_core/src/main/java/ServerApp.java +++ /dev/null @@ -1,18 +0,0 @@ -import dao.HibernateDao; -import repository.AccessPoint; -import repository.Map; - -/** - * Created by Guillaume on 09/05/2017. - */ -public class ServerApp { - public static void main(String args[]){ - HibernateDao dao = new HibernateDao(); - AccessPoint ap = new AccessPoint(); - ap.setMac_addr("aa:aa:aa:aa:aa:aa:aa:aa"); - dao.saveAccessPoint(ap); - - Map map = new Map(); - dao.saveMap(map);/**/ - } -} diff --git a/project/server_core/src/main/java/dao/DebianDao.java b/project/server_core/src/main/java/dao/DebianDao.java deleted file mode 100644 index fe54292..0000000 --- a/project/server_core/src/main/java/dao/DebianDao.java +++ /dev/null @@ -1,12 +0,0 @@ -package dao; - -/** - * Created by Guillaume on 09/05/2017. - */ -public class DebianDao { - - public String getMacAddr(String ipAddr){ - //TODO - return null; - } -} diff --git a/project/server_core/src/main/java/dao/HibernateDao.java b/project/server_core/src/main/java/dao/HibernateDao.java deleted file mode 100644 index 953355e..0000000 --- a/project/server_core/src/main/java/dao/HibernateDao.java +++ /dev/null @@ -1,208 +0,0 @@ -package dao; - -import repository.*; -import utils.HibernateUtil; -import org.hibernate.HibernateException; -import org.hibernate.Query; -import org.hibernate.Session; - -import java.util.ArrayList; -import java.util.List; - -/** - * Created by Guillaume on 09/05/2017. - */ -public class HibernateDao { - - public HibernateDao () { - } - - private TransactionCallBack execTransactionProcess(ITransactionProcess itp) { - Session session = HibernateUtil.getSessionFactory().openSession(); - TransactionCallBack reply = new TransactionCallBack(); - try { - session.beginTransaction(); - reply = itp.exec(session); - session.getTransaction().commit(); - reply.setStatus(true); - return reply; - } catch (HibernateException he) { - he.printStackTrace(); - if (session.getTransaction() != null) { - try { - session.getTransaction().rollback(); - } catch (HibernateException he2) { - he2.printStackTrace(); - } - } - } finally { - if (session != null) { - try { - session.close(); - } catch (HibernateException ex) { - ex.printStackTrace(); - } - } - } - return reply; - } - private List internal_getData(Class clazz){ - TransactionCallBack callBack = execTransactionProcess((session)->{ - TransactionCallBack reply = new TransactionCallBack(); - Query query = session.createQuery("from "+clazz.getSimpleName()); - List results = query.list(); - for(Object result : results){ - if(clazz.isInstance(result)) - reply.getResults().add(result); - } - return reply; - }); - return callBack.getResults(); - } - private boolean internal_saveData(Object... objs){ - TransactionCallBack callBack = execTransactionProcess((session)->{ - TransactionCallBack reply = new TransactionCallBack(); - for(Object obj : objs){ - session.persist(obj); - } - return reply; - }); - - return callBack!=null && callBack.isStatus(); - } - - public boolean saveTempRssi(TempRssi... trs){ - return internal_saveData(trs); - } - public List getTempRssi(String macAddr){ - if(macAddr == null) - return new ArrayList<>(); - - TransactionCallBack callBack = execTransactionProcess((session)->{ - TransactionCallBack reply = new TransactionCallBack(); - Query query = session.createQuery("from TempRssi tr where tr.client_mac_addr = :mac_addr"); - query.setParameter("mac_addr", macAddr); - List results = query.list(); - for(Object result : results){ - if(result instanceof TempRssi) - reply.getResults().add(result); - } - return reply; - }); - return callBack.getResults(); - } - - public boolean saveRssiRecord(RssiRecord... rssis){ - return internal_saveData(rssis); - } - public List getRssiRecord(){ - return internal_getData(RssiRecord.class); - } - public List getRssiRecord(Integer locationID){ - if(locationID == null) - return getRssiRecord(); - - TransactionCallBack callBack = execTransactionProcess((session)->{ - TransactionCallBack reply = new TransactionCallBack(); - Query query = session.createQuery("from RssiRecord rr where rr.id = :id"); - query.setParameter("id", locationID); - List results = query.list(); - for(Object result : results){ - if(result instanceof RssiRecord) - reply.getResults().add(result); - } - return reply; - }); - return callBack.getResults(); - } - - public List getLocations(){ - return internal_getData(Location.class); - } - - public boolean saveAccessPoint (final AccessPoint... aps) { - return internal_saveData(aps); - } - public List getAccessPoint () { - return internal_getData(AccessPoint.class); - } - - public boolean saveMap(final Map map){return internal_saveData(map);} - public Map getMap(int mapId){ - TransactionCallBack callBack = execTransactionProcess((session)->{ - TransactionCallBack reply = new TransactionCallBack(); - Query query = session.createQuery("from Map m where m.id = :id"); - query.setParameter("id", mapId); - List results = query.list(); - for(Object result : results){ - if(result instanceof Map) - reply.getResults().add(result); - } - return reply; - }); - return (callBack.getResults().isEmpty()?null:(Map)callBack.getResults().get(0)); - } - - public List getAccessPoints(String apMacAddress) { - TransactionCallBack callBack = execTransactionProcess((session)->{ - TransactionCallBack reply = new TransactionCallBack(); - Query query = session.createQuery("from AccessPoint ap where ap.mac_addr = :addr"); - query.setParameter("addr", apMacAddress); - List results = query.list(); - for(Object result : results){ - if(result instanceof AccessPoint) - reply.getResults().add(result); - } - return reply; - }); - - List reply = new ArrayList<>(); - callBack.getResults().forEach(result->reply.add((AccessPoint)result)); - return reply; - } - - public Location getLocation(int Location) { - TransactionCallBack callBack = execTransactionProcess((session)->{ - TransactionCallBack reply = new TransactionCallBack(); - Query query = session.createQuery("from Location loc where loc.id = :id"); - query.setParameter("id", Location); - List results = query.list(); - for(Object result : results){ - if(result instanceof Location) - reply.getResults().add(result); - } - return reply; - }); - return (callBack.getResults().isEmpty()?null:(Location)callBack.getResults().get(0)); - } - - private interface ITransactionProcess{ - TransactionCallBack exec(Session tr); - } - - private class TransactionCallBack{ - private boolean status; - private List results; - - public TransactionCallBack () { - status = false; - results = new ArrayList(); - } - - public boolean isStatus () { - return status; - } - - public void setStatus (final boolean status) { - this.status = status; - } - - public List getResults () { - return results; - } - - public void setResults (final List results) { - this.results = results; - } - } -} diff --git a/project/server_core/src/main/java/repository/AccessPoint.java b/project/server_core/src/main/java/repository/AccessPoint.java deleted file mode 100644 index f0d43bf..0000000 --- a/project/server_core/src/main/java/repository/AccessPoint.java +++ /dev/null @@ -1,35 +0,0 @@ -package repository; - -import java.io.Serializable; -import javax.persistence.*; - -/** - * Created by Guillaume on 09/05/2017. - */ -@Entity -@Table(name ="ACCESS_POINT") -public class AccessPoint implements Serializable{ - @Id @GeneratedValue - private int id; - - private String mac_addr; - - public AccessPoint () { - } - - public AccessPoint(Integer id, String mac_addr){ - this.mac_addr = mac_addr; - } - - public Integer getId(){return id;} - - public void setId(Integer id){this.id = id;} - - public String getMac_addr () { - return mac_addr; - } - - public void setMac_addr (final String mac_addr) { - this.mac_addr = mac_addr; - } -} diff --git a/project/server_core/src/main/java/repository/Location.java b/project/server_core/src/main/java/repository/Location.java deleted file mode 100644 index 48f6451..0000000 --- a/project/server_core/src/main/java/repository/Location.java +++ /dev/null @@ -1,50 +0,0 @@ -package repository; - -import javax.persistence.*; -import java.io.Serializable; - -/** - * Created by Guillaume on 09/05/2017. - */ -@Entity -@Table(name = "LOCATION") -public class Location implements Serializable { - @Id @GeneratedValue - private int id; - private Double x, y; - - @OneToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "id", nullable = false) - private Map map; - - public Location () { - } - - public Integer getId(){return id;} - - public void setId(Integer id){this.id = id;} - - public Double getX () { - return x; - } - - public void setX (final Double x) { - this.x = x; - } - - public Double getY () { - return y; - } - - public void setY (final Double y) { - this.y = y; - } - - public Map getMap() { - return map; - } - - public void setMap(final Map map) { - this.map = map; - } -} diff --git a/project/server_core/src/main/java/repository/Map.java b/project/server_core/src/main/java/repository/Map.java deleted file mode 100644 index 66b2552..0000000 --- a/project/server_core/src/main/java/repository/Map.java +++ /dev/null @@ -1,68 +0,0 @@ -package repository; - -import javax.persistence.*; -import java.io.Serializable; - -/** - * Created by Guillaume on 09/05/2017. - */ -@Entity -@Table(name = "MAP") -public class Map implements Serializable{ - @Id @GeneratedValue - private int id; - private Double x_topLeft, y_topLeft; - private Byte[] content; - private Double x_bottomRight, y_bottomRight; - - public Map() { - } - - public Integer getId () { - return id; - } - - public void setId (final Integer id) { - this.id = id; - } - - public Double getX_topLeft () { - return x_topLeft; - } - - public void setX_topLeft (final Double x_topLeft) { - this.x_topLeft = x_topLeft; - } - - public Double getY_topLeft () { - return y_topLeft; - } - - public void setY_topLeft (final Double y_topLeft) { - this.y_topLeft = y_topLeft; - } - - public Byte[] getContent () { - return content; - } - - public void setContent (final Byte[] content) { - this.content = content; - } - - public Double getX_bottomRight () { - return x_bottomRight; - } - - public void setX_bottomRight (final Double x_bottomRight) { - this.x_bottomRight = x_bottomRight; - } - - public Double getY_bottomRight () { - return y_bottomRight; - } - - public void setY_bottomRight (final Double y_bottomRight) { - this.y_bottomRight = y_bottomRight; - } -} diff --git a/project/server_core/src/main/java/repository/RssiRecord.java b/project/server_core/src/main/java/repository/RssiRecord.java deleted file mode 100644 index 51e41d0..0000000 --- a/project/server_core/src/main/java/repository/RssiRecord.java +++ /dev/null @@ -1,68 +0,0 @@ -package repository; - -import javax.persistence.*; -import java.io.Serializable; - -/** - * Created by Guillaume on 09/05/2017. - */ -@Entity -@Table (name = "RSSI_RECORD") -public class RssiRecord implements Serializable { - @Id @GeneratedValue - private int id; - - - @OneToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "id", nullable = false) - private Location loc; - - @OneToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "id", nullable = false) - private AccessPoint ap; - - private Double avg; - private Double stdDev; - - public RssiRecord () { - } - - public RssiRecord(Location loc, AccessPoint ap, Double avg, Double stdDev){ - this.loc = loc; - this.ap = ap; - this.avg = avg; - this.stdDev = stdDev; - } - - public Location getLoc () { - return loc; - } - - public void setLoc (final Location loc) { - this.loc = loc; - } - - public AccessPoint getAp () { - return ap; - } - - public void setAp (final AccessPoint ap) { - this.ap = ap; - } - - public Double getAvg () { - return avg; - } - - public void setAvg (final Double avg) { - this.avg = avg; - } - - public Double getStdDev () { - return stdDev; - } - - public void setStdDev (final Double stdDev) { - this.stdDev = stdDev; - } -} diff --git a/project/server_core/src/main/java/repository/TempRssi.java b/project/server_core/src/main/java/repository/TempRssi.java deleted file mode 100644 index e903af7..0000000 --- a/project/server_core/src/main/java/repository/TempRssi.java +++ /dev/null @@ -1,62 +0,0 @@ -package repository; - -import javax.persistence.*; - -/** - * Created by Guillaume on 09/05/2017. - */ -@Entity -@Table (name = "TEMP_RSSI") -public class TempRssi { - @Id @GeneratedValue - private int id; - - @OneToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "id", nullable = false) - private AccessPoint ap; - - private String client_mac_addr; - private Double avg, stdDev; - - public TempRssi () {} - - public TempRssi (final AccessPoint accessPoint, final String clientMacAddr, final double avg, - final double stdDev) { - ap = accessPoint; - client_mac_addr = clientMacAddr; - this.avg = avg; - this.stdDev = stdDev; - } - - public AccessPoint getAp () { - return ap; - } - - public void setAp (final AccessPoint ap) { - this.ap = ap; - } - - public String getClient_mac_addr () { - return client_mac_addr; - } - - public void setClient_mac_addr (final String client_mac_addr) { - this.client_mac_addr = client_mac_addr; - } - - public Double getAvg () { - return avg; - } - - public void setAvg (final Double avg) { - this.avg = avg; - } - - public Double getStdDev () { - return stdDev; - } - - public void setStdDev (final Double stdDev) { - this.stdDev = stdDev; - } -} diff --git a/project/server_core/src/main/java/service/CalibrationService.java b/project/server_core/src/main/java/service/CalibrationService.java deleted file mode 100644 index 90760d9..0000000 --- a/project/server_core/src/main/java/service/CalibrationService.java +++ /dev/null @@ -1,32 +0,0 @@ -package service; - -import dao.HibernateDao; -import repository.AccessPoint; -import repository.Location; -import repository.RssiRecord; - -import java.util.List; - -/** - * Created by Guillaume on 09/05/2017. - */ -public class CalibrationService { - - private HibernateDao dao; - - public CalibrationService(){this.dao = new HibernateDao();} - public CalibrationService(HibernateDao dao){this.dao = dao;} - - public boolean addCalibrationData(int locationId, String apMacAddress, double avg, double stdDev){ - Location loc = dao.getLocation(locationId); - AccessPoint ap = dao.getAccessPoints(apMacAddress).get(0); - return dao.saveRssiRecord(new RssiRecord(loc, ap, avg, stdDev)); - } - public boolean registerCalibrationData(RssiRecord... records){ - return dao.saveRssiRecord(records); - } - public boolean registerAp(AccessPoint ap){ - return dao.saveAccessPoint(ap); - } - public List getAllAccessPoints(){return dao.getAccessPoint();} -} diff --git a/project/server_core/src/main/java/service/MapService.java b/project/server_core/src/main/java/service/MapService.java deleted file mode 100644 index 0719446..0000000 --- a/project/server_core/src/main/java/service/MapService.java +++ /dev/null @@ -1,24 +0,0 @@ -package service; - -import dao.HibernateDao; -import repository.Map; - -/** - * Created by Guillaume on 29/05/2017. - */ -public class MapService { - - private HibernateDao dao; - - public MapService(){ - dao = new HibernateDao(); - } - - public Byte[] getMapContent(int mapId){ - return dao.getMap(mapId).getContent(); - } - - public Map getMap(int mapId){ - return dao.getMap(mapId); - } -} diff --git a/project/server_core/src/main/java/service/MeasurementService.java b/project/server_core/src/main/java/service/MeasurementService.java deleted file mode 100644 index 03ff9c4..0000000 --- a/project/server_core/src/main/java/service/MeasurementService.java +++ /dev/null @@ -1,27 +0,0 @@ -package service; - -import dao.HibernateDao; -import repository.AccessPoint; -import repository.TempRssi; - -import java.util.List; - -/** - * Created by Guillaume on 29/05/2017. - */ -public class MeasurementService { - - private HibernateDao dao; - - public MeasurementService(){ - dao = new HibernateDao(); - } - - public void registerMeasurement(String apMacAddr, String clientMacAddr, double avg, double stdDev){ - List aps = dao.getAccessPoints(apMacAddr); - - if(aps.size()>0){ - dao.saveTempRssi(new TempRssi(aps.get(0), clientMacAddr, avg, stdDev)); - } - } -} diff --git a/project/server_core/src/main/java/service/PositioningService.java b/project/server_core/src/main/java/service/PositioningService.java deleted file mode 100644 index 611b5fe..0000000 --- a/project/server_core/src/main/java/service/PositioningService.java +++ /dev/null @@ -1,102 +0,0 @@ -package service; - -import dao.DebianDao; -import dao.HibernateDao; -import repository.Location; -import repository.RssiRecord; -import repository.TempRssi; - -import java.util.ArrayList; -import java.util.List; - -/** - * Created by Guillaume on 09/05/2017. - */ -public class PositioningService { - - private static final double DEFAULT_POSITIONING_PRECISION = 7.5; - - private HibernateDao hibDao; - private DebianDao debDao; - - public PositioningService () { - this.debDao = new DebianDao(); - this.hibDao = new HibernateDao(); - } - - public Location getLocation (String ipAddr) { - - //Liste des RSSISample associé à un ap, mesuré pour un client - List clientRssi = hibDao.getTempRssi(debDao.getMacAddr(ipAddr)); - - if(clientRssi.size()>=3) { - Location bestLoc = null; - double bestLocProbability = -1; - for (Location loc : hibDao.getLocations()) { - //Liste des RSSISample pour une position donnée, chaque RSSISample étant - //assossié à un AccessPoint - List rssis = hibDao.getRssiRecord(loc.getId()); - - - double currentLocProbability = probability(clientRssi, rssis, DEFAULT_POSITIONING_PRECISION); - if (bestLocProbability == -1 || currentLocProbability > bestLocProbability) { - bestLoc = loc; - bestLocProbability = currentLocProbability; - } - } - return bestLoc; - } - return null; - } - - private double probability(List temps, List rssis, double precision){ - try { - double probability = 1; - for (TempRssi temp : temps) { - RssiRecord rssi = find(temp.getAp().getMac_addr(), rssis); - probability*=gauss_probability(temp.getAvg(), temp.getStdDev(), rssi.getAvg(), rssi.getStdDev(), precision); - } - return probability; - }catch(IllegalArgumentException e){ - e.printStackTrace(); - return -1; - } - } - private double gauss_probability(double avg1, double std1, double avg2, double std2, double precision){ - final double - valDebut = Math.min(avg1-3*std1, avg2-3*std2), - valFin = Math.max(avg1+3*std1, avg2+3*std2); - double - rectDebut = valDebut, - rectFin = valDebut+precision, - probabilite = 0; - - do{ - probabilite+=Math.min( gauss(avg1, std1, (rectDebut+rectFin)/2), gauss(avg2, std2, (rectDebut+rectFin)/2)); - rectDebut = rectFin; - rectFin+=precision; - }while(rectFin rrs){ - final List results = new ArrayList<>(); - rrs.stream().filter(rr->rr.getAp().getMac_addr().equals(macAddr)).forEach(rr->results.add(rr)); - - switch(results.size()){ - case 0: - throw new IllegalArgumentException("No matching RssiRecord for mac address <"+macAddr+">"); - case 1: - return results.get(0); - default : - throw new IllegalArgumentException("Several("+results.size()+") matching RssiRecord for mac address <"+macAddr+">"); - } - } - - public String getMacAddr (final String clientIpAddr) { - return debDao.getMacAddr(clientIpAddr); - } -} diff --git a/project/server_core/src/main/java/utils/HibernateUtil.java b/project/server_core/src/main/java/utils/HibernateUtil.java deleted file mode 100644 index 9a1968c..0000000 --- a/project/server_core/src/main/java/utils/HibernateUtil.java +++ /dev/null @@ -1,21 +0,0 @@ -package utils; - -import org.hibernate.SessionFactory; -import org.hibernate.cfg.AnnotationConfiguration; - -public class HibernateUtil { - - private static final SessionFactory sessionFactory = buildSessionFactory(); - private static SessionFactory buildSessionFactory() { - try { - // Create the SessionFactory from hibernate.cfg.xml - return new AnnotationConfiguration().configure().buildSessionFactory(); - } catch (Exception ex) { - System.err.println("Initial SessionFactory creation failed." + ex); - throw new ExceptionInInitializerError(ex); - } - } - public static SessionFactory getSessionFactory() { - return sessionFactory; - } -} \ No newline at end of file diff --git a/project/server_core/src/main/resources/hibernate.cfg.xml b/project/server_core/src/main/resources/hibernate.cfg.xml deleted file mode 100644 index 619c7c5..0000000 --- a/project/server_core/src/main/resources/hibernate.cfg.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - org.postgresql.Driver - jdbc:postgresql://localhost:5432/LO53_BDD - org.hibernate.dialect.PostgreSQLDialect - lo53_user - lo53 - 1 - create - - - - - - - - \ No newline at end of file diff --git a/project/server_servlet/pom.xml b/project/server_servlet/pom.xml deleted file mode 100644 index af9d102..0000000 --- a/project/server_servlet/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - project - com.utbm.lo53 - 1.0-SNAPSHOT - - war - 4.0.0 - - server_servlet - - - - javax - javaee-web-api - 6.0 - provided - - - com.utbm.lo53 - server_core - 1.0-SNAPSHOT - - - - \ No newline at end of file diff --git a/project/server_servlet/server_servlet.iml b/project/server_servlet/server_servlet.iml deleted file mode 100644 index 0d6a9f3..0000000 --- a/project/server_servlet/server_servlet.iml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/project/server_servlet/src/main/java/APMeasurementServlet.java b/project/server_servlet/src/main/java/APMeasurementServlet.java deleted file mode 100644 index 2df1e99..0000000 --- a/project/server_servlet/src/main/java/APMeasurementServlet.java +++ /dev/null @@ -1,51 +0,0 @@ -import repository.Location; -import service.MeasurementService; -import service.PositioningService; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.net.DatagramPacket; -import java.net.DatagramSocket; -import java.net.Inet4Address; -import java.net.InetAddress; - -import static java.lang.Thread.sleep; - -/** - * Created by Guillaume on 29/05/2017. - */ -public class APMeasurementServlet extends HttpServlet { - @Override - public void service (final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) - throws ServletException, IOException { - - String apMacAddr = servletRequest.getParameter("AP_MAC"); - String clientMacAddr = servletRequest.getParameter("CLIENT_MAC"); - Double avg = Double.parseDouble(servletRequest.getParameter("AVG")); - Double stdDev = Double.parseDouble(servletRequest.getParameter("STD_DEV")); - - if(apMacAddr!=null && !apMacAddr.isEmpty() && clientMacAddr!=null && !clientMacAddr.isEmpty() && avg!=null && stdDev!=null) { - MeasurementService mServ = new MeasurementService(); - mServ.registerMeasurement(apMacAddr, clientMacAddr, avg, stdDev); - servletResponse.setStatus(200); - }else{ - servletResponse.setStatus(400); - } - - } - - @Override - public void doGet (final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) - throws ServletException, IOException { - service(servletRequest, servletResponse); - } - - @Override - public void doPost (final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) - throws ServletException, IOException { - service(servletRequest, servletResponse); - } -} \ No newline at end of file diff --git a/project/server_servlet/src/main/java/CalibrationServlet.java b/project/server_servlet/src/main/java/CalibrationServlet.java deleted file mode 100644 index 603da74..0000000 --- a/project/server_servlet/src/main/java/CalibrationServlet.java +++ /dev/null @@ -1,45 +0,0 @@ -import service.CalibrationService; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - * Created by Guillaume on 15/05/2017. - */ -public class CalibrationServlet extends HttpServlet{ - @Override - public void service (final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) - throws ServletException, IOException { - - try { - int locId = Integer.parseInt(servletRequest.getParameter("LOCATION_ID")); - String apMacAddr = servletRequest.getParameter("AP_MAC_ADDRESS"); - double avg = Double.parseDouble(servletRequest.getParameter("AVG")); - double stdDev = Double.parseDouble(servletRequest.getParameter("STD_DEV")); - - new CalibrationService().addCalibrationData(locId, apMacAddr, avg, stdDev); - }catch(Exception e){ - e.printStackTrace(); - try{ - servletResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); - }catch(IllegalStateException ex){ - ex.printStackTrace(); - } - } - } - - @Override - public void doGet(final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) - throws ServletException, IOException { - service(servletRequest, servletResponse); - } - - @Override - public void doPost(final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) - throws ServletException, IOException { - service(servletRequest, servletResponse); - } -} diff --git a/project/server_servlet/src/main/java/MapByteServlet.java b/project/server_servlet/src/main/java/MapByteServlet.java deleted file mode 100644 index 73c89fd..0000000 --- a/project/server_servlet/src/main/java/MapByteServlet.java +++ /dev/null @@ -1,37 +0,0 @@ -import repository.Map; -import service.MapService; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - * Created by Guillaume on 29/05/2017. - */ -public class MapByteServlet extends HttpServlet { - @Override - public void service (final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) - throws ServletException, IOException { - - MapService mapService = new MapService(); - int mapId = Integer.parseInt(servletRequest.getParameter("MAP_ID")); - Map map = mapService.getMap(mapId); - - servletResponse.setContentType("image/png"); - servletResponse.getWriter().print(map.getContent()); - } - - @Override - public void doGet(final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) - throws ServletException, IOException { - service(servletRequest, servletResponse); - } - - @Override - public void doPost(final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) - throws ServletException, IOException { - service(servletRequest, servletResponse); - } -} \ No newline at end of file diff --git a/project/server_servlet/src/main/java/MapScaleServlet.java b/project/server_servlet/src/main/java/MapScaleServlet.java deleted file mode 100644 index 7d56682..0000000 --- a/project/server_servlet/src/main/java/MapScaleServlet.java +++ /dev/null @@ -1,45 +0,0 @@ -import repository.Location; -import repository.Map; -import service.MapService; -import service.PositioningService; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.net.DatagramPacket; -import java.net.DatagramSocket; -import java.net.InetAddress; - -import static java.lang.Thread.sleep; - -/** - * Created by Guillaume on 29/05/2017. - */ -public class MapScaleServlet extends HttpServlet { - @Override - public void service (final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) - throws ServletException, IOException { - - MapService mapService = new MapService(); - int mapId = Integer.parseInt(servletRequest.getParameter("MAP_ID")); - Map map = mapService.getMap(mapId); - - servletResponse.setContentType("text/plain"); - servletResponse.getWriter().print(String.format("{x1:%f;y1:%f;x2:%f;y2:%f}", map.getX_topLeft() - , map.getY_topLeft(), map.getX_bottomRight(), map.getY_bottomRight())); - } - - @Override - public void doGet(final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) - throws ServletException, IOException { - service(servletRequest, servletResponse); - } - - @Override - public void doPost(final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) - throws ServletException, IOException { - service(servletRequest, servletResponse); - } -} diff --git a/project/server_servlet/src/main/java/PositioningServlet.java b/project/server_servlet/src/main/java/PositioningServlet.java deleted file mode 100644 index bf7b552..0000000 --- a/project/server_servlet/src/main/java/PositioningServlet.java +++ /dev/null @@ -1,75 +0,0 @@ -import repository.Location; -import service.PositioningService; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.net.DatagramPacket; -import java.net.DatagramSocket; -import java.net.Inet4Address; -import java.net.InetAddress; - -import static java.lang.Thread.sleep; - -/** - * Created by Guillaume on 15/05/2017. - */ -public class PositioningServlet extends HttpServlet{ - @Override - public void service (final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) - throws ServletException, IOException { - - - String clientIpAddr = servletRequest.getParameter("CLIENT_IP"); - PositioningService posServ = new PositioningService(); - - multicastPositioningRequest(posServ.getMacAddr(clientIpAddr)); - - - Location loc = null; - do{ - try{ - sleep(500l); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - loc = posServ.getLocation(clientIpAddr); - }while(loc==null); - - servletResponse.setContentType("text/plain"); - servletResponse.getWriter().print(String.format("{x:%f;y:%f;map:%d}", loc.getX(), loc.getY(), loc.getMap().getId())); - } - - @Override - public void doGet(final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) - throws ServletException, IOException { - service(servletRequest, servletResponse); - } - - @Override - public void doPost(final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) - throws ServletException, IOException { - service(servletRequest, servletResponse); - } - - private void multicastPositioningRequest(String clientMacAddress){ - try (DatagramSocket socket = new DatagramSocket(4445)){ - - byte[] buf = new byte[256]; - - String dString = "LOCATE=" + clientMacAddress + ";SERV=" + Inet4Address.getLocalHost().getHostAddress(); - buf = dString.getBytes(); - - // send it - InetAddress group = InetAddress.getByName("230.0.0.1"); - DatagramPacket packet = new DatagramPacket(buf, buf.length, group, 4446); - socket.send(packet); - } catch (IOException e) { - e.printStackTrace(); - } - - } -} diff --git a/project/server_servlet/src/main/webapp/META-INF/MANIFEST.MF b/project/server_servlet/src/main/webapp/META-INF/MANIFEST.MF deleted file mode 100644 index 59499bc..0000000 --- a/project/server_servlet/src/main/webapp/META-INF/MANIFEST.MF +++ /dev/null @@ -1,2 +0,0 @@ -Manifest-Version: 1.0 - diff --git a/project/server_servlet/src/main/webapp/WEB-INF/web.xml b/project/server_servlet/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index c629d30..0000000 --- a/project/server_servlet/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - LO53 - Positioning server - LO53 project for 2017 spring semester. - - - - calibrationServlet - classes.CalibrationServlet - - - - calibrationServlet - /calibration - - - - - positioningServlet - classes.PositioningServlet - - - - positioningServlet - /positioning/request - - - - - apMeasurementServlet - classes.APMeasurementServlet - - - - apMeasurementServlet - /ap/measurement - - - - - mapScaleServlet - classes.MapScaleServlet - - - - mapScaleServlet - /map/scale - - - - - mapByteServlet - classes.MapByteServlet - - - - mapByteServlet - /map/byte - - \ No newline at end of file diff --git a/src/main/java/core/ServerApp.java b/src/main/java/core/ServerApp.java new file mode 100644 index 0000000..a027eeb --- /dev/null +++ b/src/main/java/core/ServerApp.java @@ -0,0 +1,18 @@ +import core.dao.HibernateDao; +import core.repository.AccessPoint; +import core.repository.Map; + +/** + * Created by Guillaume on 09/05/2017. + */ +public class ServerApp { + public static void main(String args[]){ + HibernateDao dao = new HibernateDao(); + AccessPoint ap = new AccessPoint(); + ap.setMac_addr("aa:aa:aa:aa:aa:aa:aa:aa"); + dao.saveAccessPoint(ap); + + Map map = new Map(); + dao.saveMap(map);/**/ + } +} diff --git a/src/main/java/core/dao/DebianDao.java b/src/main/java/core/dao/DebianDao.java new file mode 100644 index 0000000..dbf8e28 --- /dev/null +++ b/src/main/java/core/dao/DebianDao.java @@ -0,0 +1,12 @@ +package core.dao; + +/** + * Created by Guillaume on 09/05/2017. + */ +public class DebianDao { + + public String getMacAddr(String ipAddr){ + //TODO + return null; + } +} diff --git a/src/main/java/core/dao/HibernateDao.java b/src/main/java/core/dao/HibernateDao.java new file mode 100644 index 0000000..410afba --- /dev/null +++ b/src/main/java/core/dao/HibernateDao.java @@ -0,0 +1,210 @@ +package core.dao; + +import core.repository.*; +import core.utils.HibernateUtil; +import org.hibernate.HibernateException; +import org.hibernate.Query; +import org.hibernate.Session; + +import java.util.ArrayList; +import java.util.List; + + + +/** + * Created by Guillaume on 09/05/2017. + */ +public class HibernateDao { + + public HibernateDao () { + } + + private TransactionCallBack execTransactionProcess(ITransactionProcess itp) { + Session session = HibernateUtil.getSessionFactory().openSession(); + TransactionCallBack reply = new TransactionCallBack(); + try { + session.beginTransaction(); + reply = itp.exec(session); + session.getTransaction().commit(); + reply.setStatus(true); + return reply; + } catch (HibernateException he) { + he.printStackTrace(); + if (session.getTransaction() != null) { + try { + session.getTransaction().rollback(); + } catch (HibernateException he2) { + he2.printStackTrace(); + } + } + } finally { + if (session != null) { + try { + session.close(); + } catch (HibernateException ex) { + ex.printStackTrace(); + } + } + } + return reply; + } + private List internal_getData(Class clazz){ + TransactionCallBack callBack = execTransactionProcess((session)->{ + TransactionCallBack reply = new TransactionCallBack(); + Query query = session.createQuery("from "+clazz.getSimpleName()); + List results = query.list(); + for(Object result : results){ + if(clazz.isInstance(result)) + reply.getResults().add(result); + } + return reply; + }); + return callBack.getResults(); + } + private boolean internal_saveData(Object... objs){ + TransactionCallBack callBack = execTransactionProcess((session)->{ + TransactionCallBack reply = new TransactionCallBack(); + for(Object obj : objs){ + session.persist(obj); + } + return reply; + }); + + return callBack!=null && callBack.isStatus(); + } + + public boolean saveTempRssi(TempRssi... trs){ + return internal_saveData(trs); + } + public List getTempRssi(String macAddr){ + if(macAddr == null) + return new ArrayList<>(); + + TransactionCallBack callBack = execTransactionProcess((session)->{ + TransactionCallBack reply = new TransactionCallBack(); + Query query = session.createQuery("from TempRssi tr where tr.client_mac_addr = :mac_addr"); + query.setParameter("mac_addr", macAddr); + List results = query.list(); + for(Object result : results){ + if(result instanceof TempRssi) + reply.getResults().add((TempRssi)result); + } + return reply; + }); + return callBack.getResults(); + } + + public boolean saveRssiRecord(RssiRecord... rssis){ + return internal_saveData(rssis); + } + public List getRssiRecord(){ + return internal_getData(RssiRecord.class); + } + public List getRssiRecord(Integer locationID){ + if(locationID == null) + return getRssiRecord(); + + TransactionCallBack callBack = execTransactionProcess((session)->{ + TransactionCallBack reply = new TransactionCallBack(); + Query query = session.createQuery("from RssiRecord rr where rr.id = :id"); + query.setParameter("id", locationID); + List results = query.list(); + for(Object result : results){ + if(result instanceof RssiRecord) + reply.getResults().add(result); + } + return reply; + }); + return callBack.getResults(); + } + + public List getLocations(){ + return internal_getData(Location.class); + } + + public boolean saveAccessPoint (final AccessPoint... aps) { + return internal_saveData(aps); + } + public List getAccessPoint () { + return internal_getData(AccessPoint.class); + } + + public boolean saveMap(final Map map){return internal_saveData(map);} + public Map getMap(int mapId){ + TransactionCallBack callBack = execTransactionProcess((session)->{ + TransactionCallBack reply = new TransactionCallBack(); + Query query = session.createQuery("from Map m where m.id = :id"); + query.setParameter("id", mapId); + List results = query.list(); + for(Object result : results){ + if(result instanceof Map) + reply.getResults().add(result); + } + return reply; + }); + return (callBack.getResults().isEmpty()?null:(Map)callBack.getResults().get(0)); + } + + public List getAccessPoints(String apMacAddress) { + TransactionCallBack callBack = execTransactionProcess((session)->{ + TransactionCallBack reply = new TransactionCallBack(); + Query query = session.createQuery("from AccessPoint ap where ap.mac_addr = :addr"); + query.setParameter("addr", apMacAddress); + List results = query.list(); + for(Object result : results){ + if(result instanceof AccessPoint) + reply.getResults().add(result); + } + return reply; + }); + + List reply = new ArrayList<>(); + callBack.getResults().forEach(result->reply.add((AccessPoint)result)); + return reply; + } + + public Location getLocation(int Location) { + TransactionCallBack callBack = execTransactionProcess((session)->{ + TransactionCallBack reply = new TransactionCallBack(); + Query query = session.createQuery("from Location loc where loc.id = :id"); + query.setParameter("id", Location); + List results = query.list(); + for(Object result : results){ + if(result instanceof Location) + reply.getResults().add(result); + } + return reply; + }); + return (callBack.getResults().isEmpty()?null:(Location)callBack.getResults().get(0)); + } + + private interface ITransactionProcess{ + TransactionCallBack exec(Session tr); + } + + private class TransactionCallBack{ + private boolean status; + private List results; + + TransactionCallBack () { + status = false; + results = new ArrayList(); + } + + boolean isStatus () { + return status; + } + + void setStatus (final boolean status) { + this.status = status; + } + + List getResults () { + return results; + } + + void setResults (final List results) { + this.results = results; + } + } +} diff --git a/src/main/java/core/repository/AccessPoint.java b/src/main/java/core/repository/AccessPoint.java new file mode 100644 index 0000000..527a21e --- /dev/null +++ b/src/main/java/core/repository/AccessPoint.java @@ -0,0 +1,35 @@ +package core.repository; + +import java.io.Serializable; +import javax.persistence.*; + +/** + * Created by Guillaume on 09/05/2017. + */ +@Entity +@Table(name ="ACCESS_POINT") +public class AccessPoint implements Serializable{ + @Id @GeneratedValue + private int id; + + private String mac_addr; + + public AccessPoint () { + } + + public AccessPoint(Integer id, String mac_addr){ + this.mac_addr = mac_addr; + } + + public Integer getId(){return id;} + + public void setId(Integer id){this.id = id;} + + public String getMac_addr () { + return mac_addr; + } + + public void setMac_addr (final String mac_addr) { + this.mac_addr = mac_addr; + } +} diff --git a/src/main/java/core/repository/Location.java b/src/main/java/core/repository/Location.java new file mode 100644 index 0000000..410ddbd --- /dev/null +++ b/src/main/java/core/repository/Location.java @@ -0,0 +1,50 @@ +package core.repository; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * Created by Guillaume on 09/05/2017. + */ +@Entity +@Table(name = "LOCATION") +public class Location implements Serializable { + @Id @GeneratedValue + private int id; + private Double x, y; + + @OneToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "id", nullable = false) + private Map map; + + public Location () { + } + + public Integer getId(){return id;} + + public void setId(Integer id){this.id = id;} + + public Double getX () { + return x; + } + + public void setX (final Double x) { + this.x = x; + } + + public Double getY () { + return y; + } + + public void setY (final Double y) { + this.y = y; + } + + public Map getMap() { + return map; + } + + public void setMap(final Map map) { + this.map = map; + } +} diff --git a/src/main/java/core/repository/Map.java b/src/main/java/core/repository/Map.java new file mode 100644 index 0000000..55d55b3 --- /dev/null +++ b/src/main/java/core/repository/Map.java @@ -0,0 +1,68 @@ +package core.repository; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * Created by Guillaume on 09/05/2017. + */ +@Entity +@Table(name = "MAP") +public class Map implements Serializable{ + @Id @GeneratedValue + private int id; + private Double x_topLeft, y_topLeft; + private Byte[] content; + private Double x_bottomRight, y_bottomRight; + + public Map() { + } + + public Integer getId () { + return id; + } + + public void setId (final Integer id) { + this.id = id; + } + + public Double getX_topLeft () { + return x_topLeft; + } + + public void setX_topLeft (final Double x_topLeft) { + this.x_topLeft = x_topLeft; + } + + public Double getY_topLeft () { + return y_topLeft; + } + + public void setY_topLeft (final Double y_topLeft) { + this.y_topLeft = y_topLeft; + } + + public Byte[] getContent () { + return content; + } + + public void setContent (final Byte[] content) { + this.content = content; + } + + public Double getX_bottomRight () { + return x_bottomRight; + } + + public void setX_bottomRight (final Double x_bottomRight) { + this.x_bottomRight = x_bottomRight; + } + + public Double getY_bottomRight () { + return y_bottomRight; + } + + public void setY_bottomRight (final Double y_bottomRight) { + this.y_bottomRight = y_bottomRight; + } +} diff --git a/src/main/java/core/repository/RssiRecord.java b/src/main/java/core/repository/RssiRecord.java new file mode 100644 index 0000000..863a727 --- /dev/null +++ b/src/main/java/core/repository/RssiRecord.java @@ -0,0 +1,68 @@ +package core.repository; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * Created by Guillaume on 09/05/2017. + */ +@Entity +@Table (name = "RSSI_RECORD") +public class RssiRecord implements Serializable { + @Id @GeneratedValue + private int id; + + + @OneToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "id", nullable = false) + private Location loc; + + @OneToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "id", nullable = false) + private AccessPoint ap; + + private Double avg; + private Double stdDev; + + public RssiRecord () { + } + + public RssiRecord(Location loc, AccessPoint ap, Double avg, Double stdDev){ + this.loc = loc; + this.ap = ap; + this.avg = avg; + this.stdDev = stdDev; + } + + public Location getLoc () { + return loc; + } + + public void setLoc (final Location loc) { + this.loc = loc; + } + + public AccessPoint getAp () { + return ap; + } + + public void setAp (final AccessPoint ap) { + this.ap = ap; + } + + public Double getAvg () { + return avg; + } + + public void setAvg (final Double avg) { + this.avg = avg; + } + + public Double getStdDev () { + return stdDev; + } + + public void setStdDev (final Double stdDev) { + this.stdDev = stdDev; + } +} diff --git a/src/main/java/core/repository/TempRssi.java b/src/main/java/core/repository/TempRssi.java new file mode 100644 index 0000000..84688ed --- /dev/null +++ b/src/main/java/core/repository/TempRssi.java @@ -0,0 +1,62 @@ +package core.repository; + +import javax.persistence.*; + +/** + * Created by Guillaume on 09/05/2017. + */ +@Entity +@Table (name = "TEMP_RSSI") +public class TempRssi { + @Id @GeneratedValue + private int id; + + @OneToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "id", nullable = false) + private AccessPoint ap; + + private String client_mac_addr; + private Double avg, stdDev; + + public TempRssi () {} + + public TempRssi (final AccessPoint accessPoint, final String clientMacAddr, final double avg, + final double stdDev) { + ap = accessPoint; + client_mac_addr = clientMacAddr; + this.avg = avg; + this.stdDev = stdDev; + } + + public AccessPoint getAp () { + return ap; + } + + public void setAp (final AccessPoint ap) { + this.ap = ap; + } + + public String getClient_mac_addr () { + return client_mac_addr; + } + + public void setClient_mac_addr (final String client_mac_addr) { + this.client_mac_addr = client_mac_addr; + } + + public Double getAvg () { + return avg; + } + + public void setAvg (final Double avg) { + this.avg = avg; + } + + public Double getStdDev () { + return stdDev; + } + + public void setStdDev (final Double stdDev) { + this.stdDev = stdDev; + } +} diff --git a/src/main/java/core/service/CalibrationService.java b/src/main/java/core/service/CalibrationService.java new file mode 100644 index 0000000..f50c486 --- /dev/null +++ b/src/main/java/core/service/CalibrationService.java @@ -0,0 +1,32 @@ +package core.service; + +import core.dao.HibernateDao; +import core.repository.AccessPoint; +import core.repository.Location; +import core.repository.RssiRecord; + +import java.util.List; + +/** + * Created by Guillaume on 09/05/2017. + */ +public class CalibrationService { + + private HibernateDao dao; + + public CalibrationService(){this.dao = new HibernateDao();} + public CalibrationService(HibernateDao dao){this.dao = dao;} + + public boolean addCalibrationData(int locationId, String apMacAddress, double avg, double stdDev){ + Location loc = dao.getLocation(locationId); + AccessPoint ap = dao.getAccessPoints(apMacAddress).get(0); + return dao.saveRssiRecord(new RssiRecord(loc, ap, avg, stdDev)); + } + public boolean registerCalibrationData(RssiRecord... records){ + return dao.saveRssiRecord(records); + } + public boolean registerAp(AccessPoint ap){ + return dao.saveAccessPoint(ap); + } + public List getAllAccessPoints(){return dao.getAccessPoint();} +} diff --git a/src/main/java/core/service/MapService.java b/src/main/java/core/service/MapService.java new file mode 100644 index 0000000..9f0e344 --- /dev/null +++ b/src/main/java/core/service/MapService.java @@ -0,0 +1,24 @@ +package core.service; + +import core.dao.HibernateDao; +import core.repository.Map; + +/** + * Created by Guillaume on 29/05/2017. + */ +public class MapService { + + private HibernateDao dao; + + public MapService(){ + dao = new HibernateDao(); + } + + public Byte[] getMapContent(int mapId){ + return dao.getMap(mapId).getContent(); + } + + public Map getMap(int mapId){ + return dao.getMap(mapId); + } +} diff --git a/src/main/java/core/service/MeasurementService.java b/src/main/java/core/service/MeasurementService.java new file mode 100644 index 0000000..46e6a16 --- /dev/null +++ b/src/main/java/core/service/MeasurementService.java @@ -0,0 +1,27 @@ +package core.service; + +import core.dao.HibernateDao; +import core.repository.AccessPoint; +import core.repository.TempRssi; + +import java.util.List; + +/** + * Created by Guillaume on 29/05/2017. + */ +public class MeasurementService { + + private HibernateDao dao; + + public MeasurementService(){ + dao = new HibernateDao(); + } + + public void registerMeasurement(String apMacAddr, String clientMacAddr, double avg, double stdDev){ + List aps = dao.getAccessPoints(apMacAddr); + + if(aps.size()>0){ + dao.saveTempRssi(new TempRssi(aps.get(0), clientMacAddr, avg, stdDev)); + } + } +} diff --git a/src/main/java/core/service/PositioningService.java b/src/main/java/core/service/PositioningService.java new file mode 100644 index 0000000..0a599cc --- /dev/null +++ b/src/main/java/core/service/PositioningService.java @@ -0,0 +1,102 @@ +package core.service; + +import core.dao.DebianDao; +import core.dao.HibernateDao; +import core.repository.Location; +import core.repository.RssiRecord; +import core.repository.TempRssi; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by Guillaume on 09/05/2017. + */ +public class PositioningService { + + private static final double DEFAULT_POSITIONING_PRECISION = 7.5; + + private HibernateDao hibDao; + private DebianDao debDao; + + public PositioningService () { + this.debDao = new DebianDao(); + this.hibDao = new HibernateDao(); + } + + public Location getLocation (String ipAddr) { + + //Liste des RSSISample associé à un ap, mesuré pour un client + List clientRssi = hibDao.getTempRssi(debDao.getMacAddr(ipAddr)); + + if(clientRssi.size()>=3) { + Location bestLoc = null; + double bestLocProbability = -1; + for (Location loc : hibDao.getLocations()) { + //Liste des RSSISample pour une position donnée, chaque RSSISample étant + //assossié à un AccessPoint + List rssis = hibDao.getRssiRecord(loc.getId()); + + + double currentLocProbability = probability(clientRssi, rssis, DEFAULT_POSITIONING_PRECISION); + if (bestLocProbability == -1 || currentLocProbability > bestLocProbability) { + bestLoc = loc; + bestLocProbability = currentLocProbability; + } + } + return bestLoc; + } + return null; + } + + private double probability(List temps, List rssis, double precision){ + try { + double probability = 1; + for (TempRssi temp : temps) { + RssiRecord rssi = find(temp.getAp().getMac_addr(), rssis); + probability*=gauss_probability(temp.getAvg(), temp.getStdDev(), rssi.getAvg(), rssi.getStdDev(), precision); + } + return probability; + }catch(IllegalArgumentException e){ + e.printStackTrace(); + return -1; + } + } + private double gauss_probability(double avg1, double std1, double avg2, double std2, double precision){ + final double + valDebut = Math.min(avg1-3*std1, avg2-3*std2), + valFin = Math.max(avg1+3*std1, avg2+3*std2); + double + rectDebut = valDebut, + rectFin = valDebut+precision, + probabilite = 0; + + do{ + probabilite+=Math.min( gauss(avg1, std1, (rectDebut+rectFin)/2), gauss(avg2, std2, (rectDebut+rectFin)/2)); + rectDebut = rectFin; + rectFin+=precision; + }while(rectFin rrs){ + final List results = new ArrayList<>(); + rrs.stream().filter(rr->rr.getAp().getMac_addr().equals(macAddr)).forEach(rr->results.add(rr)); + + switch(results.size()){ + case 0: + throw new IllegalArgumentException("No matching RssiRecord for mac address <"+macAddr+">"); + case 1: + return results.get(0); + default : + throw new IllegalArgumentException("Several("+results.size()+") matching RssiRecord for mac address <"+macAddr+">"); + } + } + + public String getMacAddr (final String clientIpAddr) { + return debDao.getMacAddr(clientIpAddr); + } +} diff --git a/src/main/java/core/utils/HibernateUtil.java b/src/main/java/core/utils/HibernateUtil.java new file mode 100644 index 0000000..56b5f19 --- /dev/null +++ b/src/main/java/core/utils/HibernateUtil.java @@ -0,0 +1,21 @@ +package core.utils; + +import org.hibernate.SessionFactory; +import org.hibernate.cfg.AnnotationConfiguration; + +public class HibernateUtil { + + private static final SessionFactory sessionFactory = buildSessionFactory(); + private static SessionFactory buildSessionFactory() { + try { + // Create the SessionFactory from hibernate.cfg.xml + return new AnnotationConfiguration().configure().buildSessionFactory(); + } catch (Exception ex) { + System.err.println("Initial SessionFactory creation failed." + ex); + throw new ExceptionInInitializerError(ex); + } + } + public static SessionFactory getSessionFactory() { + return sessionFactory; + } +} \ No newline at end of file diff --git a/src/main/java/servlet/APMeasurementServlet.java b/src/main/java/servlet/APMeasurementServlet.java new file mode 100644 index 0000000..39f139e --- /dev/null +++ b/src/main/java/servlet/APMeasurementServlet.java @@ -0,0 +1,45 @@ +package servlet; + +import core.service.MeasurementService; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + * Created by Guillaume on 29/05/2017. + */ +public class APMeasurementServlet extends HttpServlet { + @Override + public void service (final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) + throws ServletException, IOException { + + String apMacAddr = servletRequest.getParameter("AP_MAC"); + String clientMacAddr = servletRequest.getParameter("CLIENT_MAC"); + Double avg = Double.parseDouble(servletRequest.getParameter("AVG")); + Double stdDev = Double.parseDouble(servletRequest.getParameter("STD_DEV")); + + if(apMacAddr!=null && !apMacAddr.isEmpty() && clientMacAddr!=null && !clientMacAddr.isEmpty() && avg!=null && stdDev!=null) { + MeasurementService mServ = new MeasurementService(); + mServ.registerMeasurement(apMacAddr, clientMacAddr, avg, stdDev); + servletResponse.setStatus(200); + }else{ + servletResponse.setStatus(400); + } + + } + + @Override + public void doGet (final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) + throws ServletException, IOException { + service(servletRequest, servletResponse); + } + + @Override + public void doPost (final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) + throws ServletException, IOException { + service(servletRequest, servletResponse); + } +} \ No newline at end of file diff --git a/src/main/java/servlet/CalibrationServlet.java b/src/main/java/servlet/CalibrationServlet.java new file mode 100644 index 0000000..dde456c --- /dev/null +++ b/src/main/java/servlet/CalibrationServlet.java @@ -0,0 +1,47 @@ +package servlet; + +import core.service.CalibrationService; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + * Created by Guillaume on 15/05/2017. + */ +public class CalibrationServlet extends HttpServlet{ + @Override + public void service (final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) + throws ServletException, IOException { + + try { + int locId = Integer.parseInt(servletRequest.getParameter("LOCATION_ID")); + String apMacAddr = servletRequest.getParameter("AP_MAC_ADDRESS"); + double avg = Double.parseDouble(servletRequest.getParameter("AVG")); + double stdDev = Double.parseDouble(servletRequest.getParameter("STD_DEV")); + + new CalibrationService().addCalibrationData(locId, apMacAddr, avg, stdDev); + }catch(Exception e){ + e.printStackTrace(); + try{ + servletResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + }catch(IllegalStateException ex){ + ex.printStackTrace(); + } + } + } + + @Override + public void doGet(final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) + throws ServletException, IOException { + service(servletRequest, servletResponse); + } + + @Override + public void doPost(final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) + throws ServletException, IOException { + service(servletRequest, servletResponse); + } +} diff --git a/src/main/java/servlet/MapByteServlet.java b/src/main/java/servlet/MapByteServlet.java new file mode 100644 index 0000000..fcac301 --- /dev/null +++ b/src/main/java/servlet/MapByteServlet.java @@ -0,0 +1,39 @@ +package servlet; + +import core.repository.Map; +import core.service.MapService; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + * Created by Guillaume on 29/05/2017. + */ +public class MapByteServlet extends HttpServlet { + @Override + public void service (final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) + throws ServletException, IOException { + + MapService mapService = new MapService(); + int mapId = Integer.parseInt(servletRequest.getParameter("MAP_ID")); + Map map = mapService.getMap(mapId); + + servletResponse.setContentType("image/png"); + servletResponse.getWriter().print(map.getContent()); + } + + @Override + public void doGet(final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) + throws ServletException, IOException { + service(servletRequest, servletResponse); + } + + @Override + public void doPost(final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) + throws ServletException, IOException { + service(servletRequest, servletResponse); + } +} \ No newline at end of file diff --git a/src/main/java/servlet/MapScaleServlet.java b/src/main/java/servlet/MapScaleServlet.java new file mode 100644 index 0000000..2582f25 --- /dev/null +++ b/src/main/java/servlet/MapScaleServlet.java @@ -0,0 +1,40 @@ +package servlet; + +import core.repository.Map; +import core.service.MapService; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + * Created by Guillaume on 29/05/2017. + */ +public class MapScaleServlet extends HttpServlet { + @Override + public void service (final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) + throws ServletException, IOException { + + MapService mapService = new MapService(); + int mapId = Integer.parseInt(servletRequest.getParameter("MAP_ID")); + Map map = mapService.getMap(mapId); + + servletResponse.setContentType("text/plain"); + servletResponse.getWriter().print(String.format("{x1:%f;y1:%f;x2:%f;y2:%f}", map.getX_topLeft() + , map.getY_topLeft(), map.getX_bottomRight(), map.getY_bottomRight())); + } + + @Override + public void doGet(final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) + throws ServletException, IOException { + service(servletRequest, servletResponse); + } + + @Override + public void doPost(final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) + throws ServletException, IOException { + service(servletRequest, servletResponse); + } +} diff --git a/src/main/java/servlet/PositioningServlet.java b/src/main/java/servlet/PositioningServlet.java new file mode 100644 index 0000000..e54e54f --- /dev/null +++ b/src/main/java/servlet/PositioningServlet.java @@ -0,0 +1,77 @@ +package servlet; + +import core.repository.Location; +import core.service.PositioningService; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.Inet4Address; +import java.net.InetAddress; + +import static java.lang.Thread.sleep; + +/** + * Created by Guillaume on 15/05/2017. + */ +public class PositioningServlet extends HttpServlet{ + @Override + public void service (final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) + throws ServletException, IOException { + + + String clientIpAddr = servletRequest.getParameter("CLIENT_IP"); + PositioningService posServ = new PositioningService(); + + multicastPositioningRequest(posServ.getMacAddr(clientIpAddr)); + + + Location loc = null; + do{ + try{ + sleep(500l); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + loc = posServ.getLocation(clientIpAddr); + }while(loc==null); + + servletResponse.setContentType("text/plain"); + servletResponse.getWriter().print(String.format("{x:%f;y:%f;map:%d}", loc.getX(), loc.getY(), loc.getMap().getId())); + } + + @Override + public void doGet(final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) + throws ServletException, IOException { + service(servletRequest, servletResponse); + } + + @Override + public void doPost(final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) + throws ServletException, IOException { + service(servletRequest, servletResponse); + } + + private void multicastPositioningRequest(String clientMacAddress){ + try (DatagramSocket socket = new DatagramSocket(4445)){ + + byte[] buf = new byte[256]; + + String dString = "LOCATE=" + clientMacAddress + ";SERV=" + Inet4Address.getLocalHost().getHostAddress(); + buf = dString.getBytes(); + + // send it + InetAddress group = InetAddress.getByName("230.0.0.1"); + DatagramPacket packet = new DatagramPacket(buf, buf.length, group, 4446); + socket.send(packet); + } catch (IOException e) { + e.printStackTrace(); + } + + } +} diff --git a/src/main/resources/hibernate.cfg.xml b/src/main/resources/hibernate.cfg.xml new file mode 100644 index 0000000..c8b81fb --- /dev/null +++ b/src/main/resources/hibernate.cfg.xml @@ -0,0 +1,21 @@ + + + + + + org.postgresql.Driver + jdbc:postgresql://localhost:5432/LO53_BDD + org.hibernate.dialect.PostgreSQLDialect + lo53_user + lo53 + 1 + create + + + + + + + + \ No newline at end of file diff --git a/src/main/webapp/META-INF/MANIFEST.MF b/src/main/webapp/META-INF/MANIFEST.MF new file mode 100644 index 0000000..59499bc --- /dev/null +++ b/src/main/webapp/META-INF/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..c629d30 --- /dev/null +++ b/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,62 @@ + + + + + LO53 - Positioning server + LO53 project for 2017 spring semester. + + + + calibrationServlet + classes.CalibrationServlet + + + + calibrationServlet + /calibration + + + + + positioningServlet + classes.PositioningServlet + + + + positioningServlet + /positioning/request + + + + + apMeasurementServlet + classes.APMeasurementServlet + + + + apMeasurementServlet + /ap/measurement + + + + + mapScaleServlet + classes.MapScaleServlet + + + + mapScaleServlet + /map/scale + + + + + mapByteServlet + classes.MapByteServlet + + + + mapByteServlet + /map/byte + + \ No newline at end of file -- libgit2 0.21.4