[Schmitzm-commits] r1630 - in trunk: schmitzm-core/src/main/java/de/schmitzm schmitzm-core/src/main/java/de/schmitzm/geotools schmitzm-core/src/main/java/de/schmitzm/geotools/postgres schmitzm-core/src/main/java/de/schmitzm/swing schmitzm-core/src/main/java/de/schmitzm/swing/input schmitzm-gt/src/main/java/de/schmitzm/geotools/io schmitzm-gt/src/main/java/de/schmitzm/geotools/postgres

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Jul 18 13:43:17 CEST 2011


Author: alfonx
Date: 2011-07-18 13:43:16 +0200 (Mon, 18 Jul 2011)
New Revision: 1630

Added:
   trunk/schmitzm-core/src/main/java/de/schmitzm/geotools/
   trunk/schmitzm-core/src/main/java/de/schmitzm/geotools/postgres/
   trunk/schmitzm-core/src/main/java/de/schmitzm/geotools/postgres/PGUtil.java
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/postgres/PGUtilGT.java
Removed:
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/postgres/PGUtil.java
Modified:
   trunk/schmitzm-core/src/main/java/de/schmitzm/swing/MailAddressTextField.java
   trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SimpleFormattedTextField.java
   trunk/schmitzm-core/src/main/java/de/schmitzm/swing/input/DateInputOption.java
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/io/GtDbServerSettings.java
Log:
* PGUtil von schmitzm-gt nach schmitzm-core verschoben
* PGUtilGT extends PGUtil in schmitzm-gt mit den Mehtoden die PG- und GT spezifisch sind.

Added: trunk/schmitzm-core/src/main/java/de/schmitzm/geotools/postgres/PGUtil.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/geotools/postgres/PGUtil.java	2011-07-13 15:50:35 UTC (rev 1629)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/geotools/postgres/PGUtil.java	2011-07-18 11:43:16 UTC (rev 1630)
@@ -0,0 +1,88 @@
+package de.schmitzm.geotools.postgres;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import org.apache.log4j.Logger;
+
+import de.schmitzm.lang.LangUtil;
+
+/**
+ * Hilfsmethoden für PostgreSQL
+ */
+public class PGUtil {
+	static final Logger log = Logger.getLogger(PGUtil.class);
+
+	/**
+	 * Querys the <code>geometry_columns</code> table is part of every postgis
+	 * installation and must/should describe the geometry columns and tables.
+	 */
+	static public String[] getColumnsDescribedInGeometryColumnsTable(Statement s) {
+		String[] columns = new String[0];
+		try {
+			ResultSet askGeoe = s
+					.executeQuery("SELECT f_table_name FROM geometry_columns;");
+			while (askGeoe.next()) {
+				columns = LangUtil.extendArray(columns, askGeoe.getString(1));
+			}
+		} catch (SQLException e) {
+			log.error(e, e);
+		}
+
+		return columns;
+
+	}
+
+	/**
+	 * Creates or Updates
+	 * 
+	 * @param tableName
+	 * @param geoColumnName
+	 * @param srid
+	 */
+	public static void createOrUpdateGeometrsColumnsEntry(String tableName,
+			String geoColumnName, int srid) {
+
+		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;";
+	}
+
+	// TODO isGeoColumn();
+
+	/**
+	 * @param binding
+	 *            Eine "einfache" Javaklasse, die in PG abgebildet werden soll.
+	 * @return einen PG-spezifischen Datentypenamen für einen Javatyp zurück,
+	 *         z.b. "double precision" für <code>Double.class</code>
+	 */
+	public static String getColTypeName(Class<?> binding) {
+
+		if (binding.isAssignableFrom(Double.class)) {
+			return "double precision"; // eg 'number' at oracle
+		} else if (binding.isAssignableFrom(String.class)) {
+			return "text";
+		} else if (binding.isAssignableFrom(Integer.class)) {
+			return "integer";
+		} else if (binding.isAssignableFrom(Long.class)) {
+			return "bigint";
+		}
+
+		throw new RuntimeException("DB Type mapping for " + binding
+				+ " not yet implemented.");
+	}
+
+	/**
+	 * Liefert <code>true</code> wenn ein Schema mit dem Namen in der PG Datenbank existiert.
+	 */
+	static boolean existsSchema(Connection c, String schemaname) throws SQLException {
+		ResultSet rs = c.createStatement().executeQuery("select 1 from pg_catalog.pg_namespace where nspname = '"+schemaname+"'");
+		return rs.next();
+	}
+}


Property changes on: trunk/schmitzm-core/src/main/java/de/schmitzm/geotools/postgres/PGUtil.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/MailAddressTextField.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/MailAddressTextField.java	2011-07-13 15:50:35 UTC (rev 1629)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/MailAddressTextField.java	2011-07-18 11:43:16 UTC (rev 1630)
@@ -2,7 +2,6 @@
 
 import java.text.MessageFormat;
 
-import javax.swing.JComponent;
 import javax.swing.JFormattedTextField;
 
 /**

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SimpleFormattedTextField.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SimpleFormattedTextField.java	2011-07-13 15:50:35 UTC (rev 1629)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SimpleFormattedTextField.java	2011-07-18 11:43:16 UTC (rev 1630)
@@ -2,19 +2,14 @@
 
 import java.awt.Color;
 import java.text.Format;
-import java.text.MessageFormat;
 import java.text.ParseException;
 
 import javax.swing.InputVerifier;
 import javax.swing.JComponent;
 import javax.swing.JFormattedTextField;
-import javax.swing.JTextField;
-import javax.swing.SwingUtilities;
 
 import org.apache.commons.lang.StringUtils;
 
-import de.schmitzm.lang.LangUtil;
-
 /**
  * {@link JFormattedTextField} which resticts no input, but marks the
  * invalid input in a highlight color.

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/input/DateInputOption.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/input/DateInputOption.java	2011-07-13 15:50:35 UTC (rev 1629)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/input/DateInputOption.java	2011-07-18 11:43:16 UTC (rev 1630)
@@ -1,12 +1,7 @@
 package de.schmitzm.swing.input;
 
-import java.text.DateFormat;
 import java.util.Date;
 
-import javax.swing.JComponent;
-import javax.swing.JPasswordField;
-import javax.swing.JTextField;
-
 import com.toedter.calendar.JDateChooser;
 
 /**

Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/io/GtDbServerSettings.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/io/GtDbServerSettings.java	2011-07-13 15:50:35 UTC (rev 1629)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/io/GtDbServerSettings.java	2011-07-18 11:43:16 UTC (rev 1630)
@@ -16,7 +16,7 @@
 import org.geotools.jdbc.JDBCDataStore;
 import org.geotools.jdbc.JDBCDataStoreFactory;
 
-import de.schmitzm.geotools.postgres.PGUtil;
+import de.schmitzm.geotools.postgres.PGUtilGT;
 import de.schmitzm.swing.input.BooleanInputOption;
 import de.schmitzm.swing.input.ManualInputOption;
 import de.schmitzm.swing.input.ManualInputOption.PasswordViewable;
@@ -439,7 +439,7 @@
 				dc = createNewDatabaseConnection();
 				try {
 
-					cachedGeometryTableNames = PGUtil
+					cachedGeometryTableNames = PGUtilGT
 							.getColumnsDescribedInGeometryColumnsTable(dc
 									.createStatement());
 

Deleted: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/postgres/PGUtil.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/postgres/PGUtil.java	2011-07-13 15:50:35 UTC (rev 1629)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/postgres/PGUtil.java	2011-07-18 11:43:16 UTC (rev 1630)
@@ -1,103 +0,0 @@
-package de.schmitzm.geotools.postgres;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import org.apache.log4j.Logger;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-
-import de.schmitzm.lang.LangUtil;
-
-/**
- * Hilfsmethoden für PostgreSQL
- */
-public class PGUtil {
-	static final Logger log = Logger.getLogger(PGUtil.class);
-
-	/**
-	 * Querys the <code>geometry_columns</code> table is part of every postgis
-	 * installation and must/should describe the geometry columns and tables.
-	 */
-	static public String[] getColumnsDescribedInGeometryColumnsTable(Statement s) {
-		String[] columns = new String[0];
-		try {
-			ResultSet askGeoe = s
-					.executeQuery("SELECT f_table_name FROM geometry_columns;");
-			while (askGeoe.next()) {
-				columns = LangUtil.extendArray(columns, askGeoe.getString(1));
-			}
-		} catch (SQLException e) {
-			log.error(e, e);
-		}
-
-		return columns;
-
-	}
-
-	public static int getSridForCRS(CoordinateReferenceSystem crs) {
-		String full = crs.toWKT().toUpperCase(); // ...
-		// AUTHORITY["EPSG","900913"]]
-		String s1 = "AUTHORITY[\"EPSG\",\"";
-		int p1 = full.indexOf(s1);
-		if (p1 >= 0) {
-			String s = full.substring(p1 + s1.length());
-			int p2 = s.indexOf("\"]");
-			if (p2 > 0) {
-				s = s.substring(0, p2);
-				return Integer.parseInt(s);
-			}
-		}
-		return -1;
-	}
-
-	public static void createOrUpdateGeometrsColumnsEntry(String tableName,
-			String geoColumnName, CoordinateReferenceSystem crs) {
-		createOrUpdateGeometrsColumnsEntry(tableName, geoColumnName,
-				getSridForCRS(crs));
-	}
-
-	/**
-	 * Creates or Updates
-	 * 
-	 * @param tableName
-	 * @param geoColumnName
-	 * @param srid
-	 */
-	public static void createOrUpdateGeometrsColumnsEntry(String tableName,
-			String geoColumnName, int srid) {
-
-		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;";
-	}
-
-	// TODO isGeoColumn();
-
-	/**
-	 * @param binding
-	 *            Eine "einfache" Javaklasse, die in PG abgebildet werden soll.
-	 * @return einen PG-spezifischen Datentypenamen für einen Javatyp zurück,
-	 *         z.b. "double precision" für <code>Double.class</code>
-	 */
-	public static String getColTypeName(Class<?> binding) {
-
-		if (binding.isAssignableFrom(Double.class)) {
-			return "double precision"; // eg 'number' at oracle
-		} else if (binding.isAssignableFrom(String.class)) {
-			return "text";
-		} else if (binding.isAssignableFrom(Integer.class)) {
-			return "integer";
-		} else if (binding.isAssignableFrom(Long.class)) {
-			return "bigint";
-		}
-
-		throw new RuntimeException("DB Type mapping for " + binding
-				+ " not yet implemented.");
-	}
-
-}

Copied: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/postgres/PGUtilGT.java (from rev 1629, trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/postgres/PGUtil.java)
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/postgres/PGUtil.java	2011-07-13 15:50:35 UTC (rev 1629)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/postgres/PGUtilGT.java	2011-07-18 11:43:16 UTC (rev 1630)
@@ -0,0 +1,34 @@
+package de.schmitzm.geotools.postgres;
+
+import org.apache.log4j.Logger;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
+
+/**
+ * Hilfsmethoden für PostgreSQL
+ */
+public class PGUtilGT extends PGUtil {
+	static final Logger log = Logger.getLogger(PGUtilGT.class);
+
+	public static int getSridForCRS(CoordinateReferenceSystem crs) {
+		String full = crs.toWKT().toUpperCase(); // ...
+		// AUTHORITY["EPSG","900913"]]
+		String s1 = "AUTHORITY[\"EPSG\",\"";
+		int p1 = full.indexOf(s1);
+		if (p1 >= 0) {
+			String s = full.substring(p1 + s1.length());
+			int p2 = s.indexOf("\"]");
+			if (p2 > 0) {
+				s = s.substring(0, p2);
+				return Integer.parseInt(s);
+			}
+		}
+		return -1;
+	}
+
+	public static void createOrUpdateGeometrsColumnsEntry(String tableName,
+			String geoColumnName, CoordinateReferenceSystem crs) {
+		createOrUpdateGeometrsColumnsEntry(tableName, geoColumnName,
+				getSridForCRS(crs));
+	}
+
+}


Property changes on: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/postgres/PGUtilGT.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id URL
Name: svn:eol-style
   + native



More information about the Schmitzm-commits mailing list