Commit d73e3bea authored by Luna Riegel's avatar Luna Riegel
Browse files

Style: Add Localization for DatabaseHandler

parent 0363193c
...@@ -8,6 +8,7 @@ import de.hft.stuttgart.citydoctor2.datastructure.CityObject; ...@@ -8,6 +8,7 @@ import de.hft.stuttgart.citydoctor2.datastructure.CityObject;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry; import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.datastructure.GmlId; import de.hft.stuttgart.citydoctor2.datastructure.GmlId;
import de.hft.stuttgart.citydoctor2.utils.Localization;
import org.apache.commons.lang3.SerializationException; import org.apache.commons.lang3.SerializationException;
import org.apache.commons.lang3.SerializationUtils; import org.apache.commons.lang3.SerializationUtils;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
...@@ -54,8 +55,7 @@ public class DatabaseHandler { ...@@ -54,8 +55,7 @@ public class DatabaseHandler {
//Cleanup hook //Cleanup hook
Runtime.getRuntime().addShutdownHook(new Thread(ds::close)); Runtime.getRuntime().addShutdownHook(new Thread(ds::close));
} catch (Exception e) { } catch (Exception e) {
//TODO: Localize Strings in this class logger.fatal(Localization.getText("DatabaseHandler.setupFailure"));
logger.fatal("FATAL ERROR: Creation of embedded database failed!");
logger.fatal(e.getMessage()); logger.fatal(e.getMessage());
} }
...@@ -81,8 +81,7 @@ public class DatabaseHandler { ...@@ -81,8 +81,7 @@ public class DatabaseHandler {
} }
} catch (SQLException e) { } catch (SQLException e) {
//TODO: Localize String logger.fatal(Localization.getText("DatabaseHandler.tableFailure"));
logger.fatal("FATAL ERROR: Creation of CityDoctorModel database table failed!");
logger.fatal(e.getMessage()); logger.fatal(e.getMessage());
} }
} }
...@@ -114,8 +113,7 @@ public class DatabaseHandler { ...@@ -114,8 +113,7 @@ public class DatabaseHandler {
} }
} }
} catch (SQLException e) { } catch (SQLException e) {
//TODO: Localize String logger.error(Localization.getText("DatabaseHandler.marshallingFailure"), co.getGmlId());
logger.error("Saving of city object {} to embedded database failed!", co.getGmlId());
logger.error(e.getMessage()); logger.error(e.getMessage());
} }
} }
...@@ -143,8 +141,7 @@ public class DatabaseHandler { ...@@ -143,8 +141,7 @@ public class DatabaseHandler {
ps.setBinaryStream(3, bis, bytes.length); ps.setBinaryStream(3, bis, bytes.length);
ps.addBatch(); ps.addBatch();
} catch (SerializationException e) { } catch (SerializationException e) {
//TODO: Localize String logger.error(Localization.getText("DatabaseHandler.serializationFailure"),co.getGmlId());
logger.error("Serialization of CityObject {} failed",co.getGmlId());
logger.error(e.getMessage()); logger.error(e.getMessage());
} }
} }
...@@ -152,14 +149,12 @@ public class DatabaseHandler { ...@@ -152,14 +149,12 @@ public class DatabaseHandler {
con.commit(); con.commit();
} catch (SQLException e) { } catch (SQLException e) {
con.rollback(); con.rollback();
//TODO: Localize String logger.error(Localization.getText("DatabaseHandler.batchCommitFailure"), id);
logger.error("Batch-commit aborted: Saving of CityObject {} to embedded database critically failed!", id);
logger.error(e.getMessage()); logger.error(e.getMessage());
return false; return false;
} }
} catch (SQLException e){ } catch (SQLException e){
//TODO: Localize String logger.error(Localization.getText("DatabaseHandler.connectionFailure"));
logger.error("Connection to embedded database could not be opened!");
logger.error(e.getMessage()); logger.error(e.getMessage());
return false; return false;
} }
...@@ -194,8 +189,7 @@ public class DatabaseHandler { ...@@ -194,8 +189,7 @@ public class DatabaseHandler {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} catch (SQLException e) { } catch (SQLException e) {
//TODO: Localize String logger.error(Localization.getText("DatabaseHandler.unmarshallingFailure"), id);
logger.error("Loading of city object from embedded database failed!");
logger.error(e.getMessage()); logger.error(e.getMessage());
} }
...@@ -212,8 +206,7 @@ public class DatabaseHandler { ...@@ -212,8 +206,7 @@ public class DatabaseHandler {
} }
} }
} catch (SQLException e) { } catch (SQLException e) {
//TODO: Localize String logger.error(Localization.getText("DatabaseHandler.fetchErrorIdsFailure"));
logger.error("Fetching ids of all features with errors failed!");
logger.error(e.getMessage()); logger.error(e.getMessage());
} }
return ids; return ids;
...@@ -227,8 +220,7 @@ public class DatabaseHandler { ...@@ -227,8 +220,7 @@ public class DatabaseHandler {
cos.addAll(retrieveCityObjects(rs)); cos.addAll(retrieveCityObjects(rs));
} }
} catch (SQLException e) { } catch (SQLException e) {
//TODO: Localize String logger.error(Localization.getText("DatabaseHandler.getAllCityObjectsFailure"));
logger.error("Connection to database failed while trying to get all CityObjects!");
logger.debug(e.getMessage()); logger.debug(e.getMessage());
} }
return cos; return cos;
...@@ -270,8 +262,7 @@ public class DatabaseHandler { ...@@ -270,8 +262,7 @@ public class DatabaseHandler {
} }
} }
} catch (SQLException e) { } catch (SQLException e) {
//TODO: Localize String logger.error(Localization.getText("DatabaseHandler.getBufferIntersectFailure"),gmlID);
logger.error("Connection to database failed while trying to get buffer intersecting objects!");
logger.debug(e.getMessage()); logger.debug(e.getMessage());
} }
return intersectingObjects; return intersectingObjects;
...@@ -296,8 +287,7 @@ public class DatabaseHandler { ...@@ -296,8 +287,7 @@ public class DatabaseHandler {
} }
} }
} catch (SQLException e) { } catch (SQLException e) {
//TODO: Localize String logger.error(Localization.getText("DatabaseHandler.getBBoxIntersectFailure"),id);
logger.error("Connection to database failed while trying to get bbox intersecting objects!");
logger.debug(e.getMessage()); logger.debug(e.getMessage());
} }
return intersectingObjects; return intersectingObjects;
...@@ -315,8 +305,7 @@ public class DatabaseHandler { ...@@ -315,8 +305,7 @@ public class DatabaseHandler {
} }
} }
} catch (SQLException e) { } catch (SQLException e) {
//TODO: Localize String logger.error(Localization.getText("DatabaseHandler.getFeatureCountFailure"));
logger.error("Connection to database failed while trying to get bbox intersecting objects!");
logger.debug(e.getMessage()); logger.debug(e.getMessage());
} }
return count; return count;
......
...@@ -150,3 +150,15 @@ ErrorItemVisitor.pointTouchesEdge=Point touches edge ...@@ -150,3 +150,15 @@ ErrorItemVisitor.pointTouchesEdge=Point touches edge
ErrorItemVisitor.degeneratedRing=Degenerated ring ErrorItemVisitor.degeneratedRing=Degenerated ring
ErrorItemVisitor.deviation=Deviation ErrorItemVisitor.deviation=Deviation
ErrorItemVisitor.triangles=Triangles ErrorItemVisitor.triangles=Triangles
DatabaseHandler.setupFailure=FATAL ERROR: Creation of embedded database failed!
DatabaseHandler.tableFailure=FATAL ERROR: Creation of features table failed!
DatabaseHandler.marshallingFailure=Writing CityObject {} to database failed!
DatabaseHandler.serializationFailure=Serialization of CityObject {} failed!
DatabaseHandler.batchCommitFailure=Batch-commit aborted: Critical failure while trying to write CityObject {} to database!
DatabaseHandler.connectionFailure=Connection to embedded database could not be opened!
DatabaseHandler.unmarshallingFailure=Loading of CityObject {} from embedded database failed!
DatabaseHandler.fetchErrorIdsFailure=Fetching list of GmlIDs of CityObjects with errors failed!
DatabaseHandler.getAllCityObjectsFailure=Fetching of all CityObjects failed!
DatabaseHandler.getBufferIntersectFailure=Connection to database failed while trying to fetch buffer intersecting objects of CityObject {}
DatabaseHandler.getBBoxIntersectFailure= Connection to database failed while trying to fetch bbox intersecting objects of CityObject {}
DatabaseHandler.getFeatureCountFailure=Connection to database failed while trying to get count of CityObjects!
\ No newline at end of file
...@@ -148,3 +148,15 @@ ErrorItemVisitor.pointTouchesEdge=Punkt ber\u00fchrt Kante ...@@ -148,3 +148,15 @@ ErrorItemVisitor.pointTouchesEdge=Punkt ber\u00fchrt Kante
ErrorItemVisitor.degeneratedRing=Degenerierter Ring ErrorItemVisitor.degeneratedRing=Degenerierter Ring
ErrorItemVisitor.deviation=Abweichung ErrorItemVisitor.deviation=Abweichung
ErrorItemVisitor.triangles=Dreiecke ErrorItemVisitor.triangles=Dreiecke
DatabaseHandler.setupFailure=FATAL ERROR: Erstellen der eingebetteten Datenbank fehlgeschlagen!
DatabaseHandler.tableFailure=FATAL ERROR: Erstellen der features Tabelle fehlgeschlagen!
DatabaseHandler.marshallingFailure=Schreiben von CityObject {} in die Datenbank fehlgeschlagen!
DatabaseHandler.serializationFailure=Serialisierung von CityObject {} fehlgeschlagen!
DatabaseHandler.batchCommitFailure=Batch-commit abgebrochen: Kritischer Fehler beim Versuch CityObject {} in die Datenbank zu schreiben!
DatabaseHandler.connectionFailure=Verbindung zur eingebetteten Datenbank konnte nicht hergestellt werden!
DatabaseHandler.unmarshallingFailure=Laden von CityObject {} aus der Datenbank fehlgeschlagen!
DatabaseHandler.fetchErrorIdsFailure=Abfragen der Liste von CityObjects mit Fehlern ist fehlgeschlagen!
DatabaseHandler.getAllCityObjectsFailure=Abfrage nach allen CityObjects ist fehlgeschlagen!
DatabaseHandler.getBufferIntersectFailure=Verbindung zur Datenbank konnte nicht hergestellt werden, abfragen der Buffer-Intersections von CityObject {} fehlgeschlagen!
DatabaseHandler.getBBoxIntersectFailure=Verbindung zur Datenbank konnte nicht hergestellt werden, abfragen der BBox-Intersections von CityObject {} fehlgeschlagen!
DatabaseHandler.getFeatureCountFailure=Verbindung zur Datenbank konnte nicht hergestellt werden, abfragen der Anzahl an CityObjects fehlgeschlagen!
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment