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;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
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.SerializationUtils;
import org.apache.logging.log4j.LogManager;
......@@ -54,8 +55,7 @@ public class DatabaseHandler {
//Cleanup hook
Runtime.getRuntime().addShutdownHook(new Thread(ds::close));
} catch (Exception e) {
//TODO: Localize Strings in this class
logger.fatal("FATAL ERROR: Creation of embedded database failed!");
logger.fatal(Localization.getText("DatabaseHandler.setupFailure"));
logger.fatal(e.getMessage());
}
......@@ -81,8 +81,7 @@ public class DatabaseHandler {
}
} catch (SQLException e) {
//TODO: Localize String
logger.fatal("FATAL ERROR: Creation of CityDoctorModel database table failed!");
logger.fatal(Localization.getText("DatabaseHandler.tableFailure"));
logger.fatal(e.getMessage());
}
}
......@@ -114,8 +113,7 @@ public class DatabaseHandler {
}
}
} catch (SQLException e) {
//TODO: Localize String
logger.error("Saving of city object {} to embedded database failed!", co.getGmlId());
logger.error(Localization.getText("DatabaseHandler.marshallingFailure"), co.getGmlId());
logger.error(e.getMessage());
}
}
......@@ -143,8 +141,7 @@ public class DatabaseHandler {
ps.setBinaryStream(3, bis, bytes.length);
ps.addBatch();
} catch (SerializationException e) {
//TODO: Localize String
logger.error("Serialization of CityObject {} failed",co.getGmlId());
logger.error(Localization.getText("DatabaseHandler.serializationFailure"),co.getGmlId());
logger.error(e.getMessage());
}
}
......@@ -152,14 +149,12 @@ public class DatabaseHandler {
con.commit();
} catch (SQLException e) {
con.rollback();
//TODO: Localize String
logger.error("Batch-commit aborted: Saving of CityObject {} to embedded database critically failed!", id);
logger.error(Localization.getText("DatabaseHandler.batchCommitFailure"), id);
logger.error(e.getMessage());
return false;
}
} catch (SQLException e){
//TODO: Localize String
logger.error("Connection to embedded database could not be opened!");
logger.error(Localization.getText("DatabaseHandler.connectionFailure"));
logger.error(e.getMessage());
return false;
}
......@@ -194,8 +189,7 @@ public class DatabaseHandler {
throw new RuntimeException(e);
}
} catch (SQLException e) {
//TODO: Localize String
logger.error("Loading of city object from embedded database failed!");
logger.error(Localization.getText("DatabaseHandler.unmarshallingFailure"), id);
logger.error(e.getMessage());
}
......@@ -212,8 +206,7 @@ public class DatabaseHandler {
}
}
} catch (SQLException e) {
//TODO: Localize String
logger.error("Fetching ids of all features with errors failed!");
logger.error(Localization.getText("DatabaseHandler.fetchErrorIdsFailure"));
logger.error(e.getMessage());
}
return ids;
......@@ -227,8 +220,7 @@ public class DatabaseHandler {
cos.addAll(retrieveCityObjects(rs));
}
} catch (SQLException e) {
//TODO: Localize String
logger.error("Connection to database failed while trying to get all CityObjects!");
logger.error(Localization.getText("DatabaseHandler.getAllCityObjectsFailure"));
logger.debug(e.getMessage());
}
return cos;
......@@ -270,8 +262,7 @@ public class DatabaseHandler {
}
}
} catch (SQLException e) {
//TODO: Localize String
logger.error("Connection to database failed while trying to get buffer intersecting objects!");
logger.error(Localization.getText("DatabaseHandler.getBufferIntersectFailure"),gmlID);
logger.debug(e.getMessage());
}
return intersectingObjects;
......@@ -296,8 +287,7 @@ public class DatabaseHandler {
}
}
} catch (SQLException e) {
//TODO: Localize String
logger.error("Connection to database failed while trying to get bbox intersecting objects!");
logger.error(Localization.getText("DatabaseHandler.getBBoxIntersectFailure"),id);
logger.debug(e.getMessage());
}
return intersectingObjects;
......@@ -315,8 +305,7 @@ public class DatabaseHandler {
}
}
} catch (SQLException e) {
//TODO: Localize String
logger.error("Connection to database failed while trying to get bbox intersecting objects!");
logger.error(Localization.getText("DatabaseHandler.getFeatureCountFailure"));
logger.debug(e.getMessage());
}
return count;
......
......@@ -149,4 +149,16 @@ ErrorItemVisitor.distance=Distance
ErrorItemVisitor.pointTouchesEdge=Point touches edge
ErrorItemVisitor.degeneratedRing=Degenerated ring
ErrorItemVisitor.deviation=Deviation
ErrorItemVisitor.triangles=Triangles
\ No newline at end of file
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
......@@ -147,4 +147,16 @@ ErrorItemVisitor.distance=Distanz
ErrorItemVisitor.pointTouchesEdge=Punkt ber\u00fchrt Kante
ErrorItemVisitor.degeneratedRing=Degenerierter Ring
ErrorItemVisitor.deviation=Abweichung
ErrorItemVisitor.triangles=Dreiecke
\ No newline at end of file
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