[Schmitzm-commits] r1834 - trunk/schmitzm-db/src/main/java/de/schmitzm/postgres
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Mon Jan 23 01:50:43 CET 2012
Author: alfonx
Date: 2012-01-23 01:50:41 +0100 (Mon, 23 Jan 2012)
New Revision: 1834
Modified:
trunk/schmitzm-db/src/main/java/de/schmitzm/postgres/PGColumn.java
trunk/schmitzm-db/src/main/java/de/schmitzm/postgres/PGUtil.java
Log:
Modified: trunk/schmitzm-db/src/main/java/de/schmitzm/postgres/PGColumn.java
===================================================================
--- trunk/schmitzm-db/src/main/java/de/schmitzm/postgres/PGColumn.java 2012-01-22 12:27:51 UTC (rev 1833)
+++ trunk/schmitzm-db/src/main/java/de/schmitzm/postgres/PGColumn.java 2012-01-23 00:50:41 UTC (rev 1834)
@@ -51,4 +51,20 @@
+ hasDefault + "]";
}
+ public boolean isNumeric() {
+ if (typename.startsWith("float"))
+ return true;
+ if (typename.startsWith("serial"))
+ return true;
+ if (typename.startsWith("long"))
+ return true;
+ if (typename.startsWith("byte"))
+ return true;
+ if (typename.startsWith("int"))
+ return true;
+ if (typename.startsWith("double"))
+ return true;
+ return false;
+ }
+
}
Modified: trunk/schmitzm-db/src/main/java/de/schmitzm/postgres/PGUtil.java
===================================================================
--- trunk/schmitzm-db/src/main/java/de/schmitzm/postgres/PGUtil.java 2012-01-22 12:27:51 UTC (rev 1833)
+++ trunk/schmitzm-db/src/main/java/de/schmitzm/postgres/PGUtil.java 2012-01-23 00:50:41 UTC (rev 1834)
@@ -110,8 +110,10 @@
}
/**
- * Querys the <code>geometry_columns</code> table is part of every POSTGIS installation and must/should describe the
- * geometry columns and tables.
+ * Querys the <code>geometry_columns</code> table. It is part of every POSTGIS installation and must/should describe
+ * the geometry columns and tables.
+ *
+ * @deprecated
*/
static public String[] getColumnsDescribedInGeometryColumnsTable(Statement s) {
String[] columns = new String[0];
@@ -130,26 +132,69 @@
}
return columns;
+ }
+ /**
+ * Querys the <code>geometry_columns</code> table. It is part of every POSTGIS installation and must/should describe
+ * the geometry columns and tables.
+ *
+ * @deprecated
+ */
+ static public String[] create(Statement s) {
+ String[] columns = new String[0];
+ try {
+ ResultSet rs = s.executeQuery("SELECT f_table_name FROM geometry_columns;");
+ try {
+
+ while (rs.next()) {
+ columns = LangUtil.extendArray(columns, rs.getString(1));
+ }
+ } finally {
+ rs.close();
+ }
+ } catch (SQLException e) {
+ log.error(e, e);
+ }
+
+ return columns;
}
/**
* Creates or Updates
*
* @param tableName
+ * darf auch schema. enthalten, sonst schema public
* @param geoColumnName
* @param srid
+ * @param type
+ * "POINT" "MULTIPOLYGON", etc.
+ *
+ * @Deprecated tut es noch nicht
+ *
*/
- @Deprecated
- // tut noch nicht
- public static void createOrUpdateGeometrysColumnsEntry(String tableName, String geoColumnName, int srid) {
+ public static void createOrUpdateGeometrysColumnsEntry(Connection c, String tableName, String geoColumnName,
+ int srid, String type) {
- String createGeometryEntrySQL = "INSERT INTO geometry_columns (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, \"type\") VALUES ( '', 'public', '"
- + tableName + "', '" + geoColumnName + "', 2, " + srid + ",'MULTIPOLYGON' ) LIMIT 1;";
+ String schema = "public";
+ if (tableName.contains(".")) {
+ final String[] split = tableName.split("\\.");
+ schema = split[0];
+ tableName = split[1];
+ }
+
+ String createGeometryEntrySQL = "INSERT INTO geometry_columns (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, \"type\") VALUES ( '', '"
+ + schema
+ + "', '"
+ + tableName
+ + "', '"
+ + geoColumnName
+ + "', 2, "
+ + srid
+ + ",'"
+ + type.toUpperCase()
+ + "' );";
}
- // TODO isGeoColumn();
-
/**
* @param binding
* Eine "einfache" Javaklasse, die in PG abgebildet werden soll.
@@ -301,7 +346,6 @@
List<PGColumn> cols = new ArrayList<PGColumn>();
String schema = "public";
-
if (tableName.contains(".")) {
final String[] split = tableName.split("\\.");
schema = split[0];
More information about the Schmitzm-commits
mailing list