Index: tags/org.gvsig.postgresql-2.0.29/pom.xml
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/pom.xml	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/pom.xml	(revision 121)
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>org.gvsig.postgresql</artifactId>
+  <version>2.0.29</version>
+  <packaging>pom</packaging>
+  <name>${project.artifactId}</name>
+  <description>PostgreSQL support fort DAL and gvSIG</description>
+  <parent>
+      <groupId>org.gvsig</groupId>
+      <artifactId>org.gvsig.desktop</artifactId>
+      <version>2.0.90</version>
+  </parent>
+
+  <url>https://devel.gvsig.org/redmine/projects/gvsig-postgresql</url>
+  <scm>
+      <connection>scm:svn:https://devel.gvsig.org/svn/gvsig-postgresql/tags/org.gvsig.postgresql-2.0.29</connection>
+      <developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-postgresql/tags/org.gvsig.postgresql-2.0.29</developerConnection>
+      <url>https://devel.gvsig.org/redmine/projects/gvsig-postgresql/repository/show/tags/org.gvsig.postgresql-2.0.29</url>
+  </scm>
+
+    <repositories>
+        <repository>
+            <id>gvsig-public-http-repository</id>
+            <name>gvSIG maven public HTTP repository</name>
+            <url>http://devel.gvsig.org/m2repo/j2se</url>
+            <releases>
+                <enabled>true</enabled>
+                <updatePolicy>daily</updatePolicy>
+                <checksumPolicy>warn</checksumPolicy>
+            </releases>
+            <snapshots>
+                <enabled>true</enabled>
+                <updatePolicy>daily</updatePolicy>
+                <checksumPolicy>warn</checksumPolicy>
+            </snapshots>
+        </repository>
+    </repositories>
+  
+  
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-release-plugin</artifactId>
+				<configuration>
+					<tagBase>https://devel.gvsig.org/svn/gvsig-postgresql/tags/</tagBase>
+					<goals>deploy</goals>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
+
+
+  <dependencyManagement>
+      <dependencies>
+          <dependency>
+            <groupId>org.gvsig</groupId>
+            <artifactId>org.gvsig.postgresql.provider</artifactId>
+            <version>2.0.29</version>
+          </dependency>
+          <dependency>
+            <groupId>org.gvsig</groupId>
+            <artifactId>org.gvsig.postgresql.app.mainplugin</artifactId>
+            <version>2.0.29</version>
+          </dependency>
+      </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <scope>compile</scope>
+        </dependency>
+  </dependencies>
+
+  
+  <modules>
+    <module>org.gvsig.postgresql.app</module>
+    <module>org.gvsig.postgresql.provider</module>
+  </modules>
+
+
+</project>
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLConnectionParameters.java
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLConnectionParameters.java	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLConnectionParameters.java	(revision 121)
@@ -0,0 +1,45 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+*
+* Copyright (C) 2007-2008 Infrastructures and Transports Department
+* of the Valencian Government (CIT)
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+* MA  02110-1301, USA.
+*
+*/
+
+/*
+* AUTHORS (In addition to CIT):
+* 2009 IVER T.I   {{Task}}
+*/
+
+/**
+ *
+ */
+package org.gvsig.fmap.dal.store.postgresql;
+
+import org.gvsig.fmap.dal.store.jdbc.JDBCConnectionParameters;
+
+/**
+ * @author jmvivo
+ *
+ */
+public interface PostgreSQLConnectionParameters extends
+		JDBCConnectionParameters {
+
+	public static final String DYNFIELDNAME_USESSL = "UseSSL";
+
+	public Boolean getUseSSL();
+}
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLLibrary.java
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLLibrary.java	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLLibrary.java	(revision 121)
@@ -0,0 +1,135 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+
+/*
+* AUTHORS (In addition to CIT):
+* 2008 IVER T.I. S.A.   {{Task}}
+*/
+
+package org.gvsig.fmap.dal.store.postgresql;
+
+import org.gvsig.fmap.dal.DALLibrary;
+import org.gvsig.fmap.dal.DALLocator;
+import org.gvsig.fmap.dal.resource.spi.ResourceManagerProviderServices;
+import org.gvsig.fmap.dal.spi.DataManagerProviderServices;
+import org.gvsig.fmap.dal.store.db.DBHelper;
+import org.gvsig.fmap.dal.store.jdbc.JDBCLibrary;
+import org.gvsig.metadata.exceptions.MetadataException;
+import org.gvsig.tools.library.AbstractLibrary;
+import org.gvsig.tools.library.LibraryException;
+
+public class PostgreSQLLibrary extends AbstractLibrary {
+
+	static String DEFAULT_JDCB_DRIVER_NAME = "org.postgresql.Driver";
+
+    @Override
+    public void doRegistration() {
+        registerAsServiceOf(DALLibrary.class);
+        require(JDBCLibrary.class);
+    }
+
+	public static String getJdbcUrl(String host, Integer port, String db) {
+		String url = null;
+		if(host != null){
+		    String sport = "";
+		    if (port != null) {
+		        sport = ":" + port;
+		    }
+		    url = "jdbc:postgresql://" + host + sport + "/" + db;
+		}
+		return url;
+	}
+
+
+	@Override
+	protected void doInitialize() throws LibraryException {
+	}
+
+
+	@Override
+	protected void doPostInitialize() throws LibraryException {
+		LibraryException ex=null;
+
+		new JDBCLibrary().postInitialize();
+
+		 DBHelper.registerParametersDefinition(
+				 PostgreSQLStoreParameters.PARAMETERS_DEFINITION_NAME,
+				 PostgreSQLStoreParameters.class,
+				 "PostgreSQLParameters.xml"
+		);
+		DBHelper.registerParametersDefinition(
+				PostgreSQLNewStoreParameters.PARAMETERS_DEFINITION_NAME,
+				PostgreSQLNewStoreParameters.class,
+				"PostgreSQLParameters.xml"
+		);
+		DBHelper.registerParametersDefinition(
+				PostgreSQLServerExplorerParameters.PARAMETERS_DEFINITION_NAME, 
+				PostgreSQLServerExplorerParameters.class, 
+				"PostgreSQLParameters.xml"
+		);
+		DBHelper.registerParametersDefinition(
+				PostgreSQLResourceParameters.PARAMETERS_DEFINITION_NAME, 
+				PostgreSQLResourceParameters.class, 
+				"PostgreSQLParameters.xml"
+		);
+		try {
+			DBHelper.registerMetadataDefinition(
+					PostgreSQLStoreProvider.METADATA_DEFINITION_NAME, 
+					PostgreSQLStoreProvider.class, 
+					"PostgreSQLMetadata.xml"
+			);
+		} catch (MetadataException e) {
+			ex = new LibraryException(this.getClass(),e);
+		}
+		
+		ResourceManagerProviderServices resman = (ResourceManagerProviderServices) DALLocator
+		.getResourceManager();
+
+		
+		if (!resman.getResourceProviders().contains(PostgreSQLResource.NAME)) {
+			resman.register(PostgreSQLResource.NAME,
+					PostgreSQLResource.DESCRIPTION, PostgreSQLResource.class,
+					PostgreSQLResourceParameters.class);
+		}
+		
+		
+		DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator
+				.getDataManager();
+		
+		if (!dataman.getStoreProviders().contains(PostgreSQLStoreProvider.NAME)) {
+			dataman.registerStoreProvider(PostgreSQLStoreProvider.NAME,
+					PostgreSQLStoreProvider.class,
+					PostgreSQLStoreParameters.class);
+		}
+		
+		if (!dataman.getExplorerProviders().contains(
+				PostgreSQLStoreProvider.NAME)) {
+			dataman.registerExplorerProvider(PostgreSQLServerExplorer.NAME,
+					PostgreSQLServerExplorer.class,
+					PostgreSQLServerExplorerParameters.class);
+		}
+		if( ex!=null ) {
+			throw ex;
+		}
+	}
+
+}
\ No newline at end of file
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLSetProvider.java
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLSetProvider.java	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLSetProvider.java	(revision 121)
@@ -0,0 +1,210 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+*
+* Copyright (C) 2007-2008 Infrastructures and Transports Department
+* of the Valencian Government (CIT)
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+* MA  02110-1301, USA.
+*
+*/
+
+/*
+* AUTHORS (In addition to CIT):
+* 2009 IVER T.I   {{Task}}
+*/
+
+/**
+ *
+ */
+package org.gvsig.fmap.dal.store.postgresql;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.cresques.cts.IProjection;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.gvsig.fmap.dal.exception.DataException;
+import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
+import org.gvsig.fmap.dal.feature.FeatureQuery;
+import org.gvsig.fmap.dal.feature.FeatureStore;
+import org.gvsig.fmap.dal.feature.FeatureType;
+import org.gvsig.fmap.dal.feature.exception.CreateGeometryException;
+import org.gvsig.fmap.dal.store.db.DBStoreParameters;
+import org.gvsig.fmap.dal.store.jdbc.JDBCSetProvider;
+import org.gvsig.fmap.dal.store.jdbc.JDBCStoreProvider;
+import org.gvsig.fmap.geom.primitive.Envelope;
+import org.gvsig.tools.evaluator.Evaluator;
+import org.gvsig.tools.evaluator.EvaluatorFieldValue;
+import org.gvsig.tools.evaluator.EvaluatorFieldsInfo;
+
+/**
+ * @author jmvivo
+ *
+ */
+public class PostgreSQLSetProvider extends JDBCSetProvider {
+
+    private static Logger logger = LoggerFactory.getLogger(PostgreSQLSetProvider.class);
+    
+	public PostgreSQLSetProvider(JDBCStoreProvider store, FeatureQuery query,
+			FeatureType featureType) throws DataException {
+		super(store, query, featureType);
+	}
+
+
+	/*
+	 * (non-Javadoc)
+	 *
+	 * @see org.gvsig.fmap.dal.feature.spi.FeatureSetProvider#canFilter()
+	 */
+	public boolean canFilter() {
+		// TODO more checks
+		if (!super.canFilter()) {
+			return false;
+		}
+		return true;
+
+	}
+	
+    protected String getSqlForEvaluator(Evaluator filter) {
+        
+        String resp = null;
+        if (filter != null && filter.getSQL() != null) {
+            // =================================================
+            EvaluatorFieldsInfo info = filter.getFieldsInfo();
+            String filterString = filter.getSQL();
+            
+            String[] filterNames = null;
+            String[] finalNames = null;
+            
+            if (info == null) {
+                filterNames = getFieldNames(getFeatureType());
+            } else {
+                filterNames = info.getFieldNames();
+            }
+            
+            finalNames = new String[filterNames.length];
+            FeatureAttributeDescriptor attr;
+            for (int i = 0; i < filterNames.length; i++) {
+                attr = getFeatureType().getAttributeDescriptor(filterNames[i]);
+                if (attr == null) {
+                    finalNames[i] = filterNames[i];
+                    continue;
+                }
+                finalNames[i] = getEscapedFieldName(attr.getName());
+            }
+
+            for (int i = 0; i < filterNames.length; i++) {
+                if (!filterNames[i].equals(finalNames[i])) {
+                    filterString = filterString.replaceAll(
+                            "\\b" + filterNames[i] + "\\b",
+                            finalNames[i]);
+                }
+            }
+            resp = filterString;        
+        }
+        // ================================
+        // In any case, append working area filter
+        
+        try {
+            resp = appendWorkingAreaCondition(resp);
+        } catch (Exception e) {
+            logger.error("While appending working area condition.", e);
+        }
+        return resp;
+    }	
+    
+    private String[] getFieldNames(FeatureType ft) {
+        
+        if (ft == null) {
+            return new String[0];
+        }
+        FeatureAttributeDescriptor[] atts = ft.getAttributeDescriptors();
+        String[] resp = new String[atts.length];
+        for (int i=0; i<atts.length; i++) {
+            resp[i] = atts[i].getName();
+        }
+        return resp;
+    }
+    
+    private String getFunctionName(String newFunctionName) {
+        
+        PostgreSQLStoreProvider pg_sto_prov = (PostgreSQLStoreProvider) this.getStore();
+        PostgreSQLHelper hpr = pg_sto_prov.getPgHelper();
+        if (hpr == null) {
+            logger.info("Unable to get PG helper.", new Exception("Helper is null"));
+            return newFunctionName;
+        } else {
+            return hpr.getFunctionName(newFunctionName);
+        }
+    }
+
+
+    private String appendWorkingAreaCondition(String sql) throws Exception {
+        
+        
+        DBStoreParameters dbParams = 
+        (DBStoreParameters) getStore().getParameters();
+        
+        Envelope wa = dbParams.getWorkingArea(); 
+        if (wa == null) {
+            return sql;
+        } else {
+            
+            FeatureStore fstore = this.getStore().getFeatureStore();
+            String geoname =
+                fstore.getDefaultFeatureType().getDefaultGeometryAttributeName();
+            
+            StringBuffer strbuf = new StringBuffer();
+            
+            if (sql == null)  {
+                strbuf.append(
+                    getFunctionName("ST_Intersects") + "("
+                    + getFunctionName("ST_GeomFromText") + "('");
+            } else {
+                strbuf.append("(");
+                strbuf.append(sql);
+                strbuf.append(") AND "
+                    + getFunctionName("ST_Intersects") + "("
+                    + getFunctionName("ST_GeomFromText") + "('");
+            }
+            
+            String workAreaWkt = null;
+            workAreaWkt = wa.getGeometry().convertToWKT();
+            strbuf.append(workAreaWkt);
+            strbuf.append("', ");
+            
+            PostgreSQLStoreProvider sprov = (PostgreSQLStoreProvider) getStore();
+            PostgreSQLHelper helper = sprov.getPgHelper();
+            
+            IProjection proj = dbParams.getCRS();
+            int sridInt = helper.getProviderSRID(proj); 
+            if (sridInt == -1) {
+                throw new CreateGeometryException(
+                        new Exception("CRS is null or unknown."));
+            } else {
+                strbuf.append(Integer.toString(sridInt));
+            }
+            strbuf.append("), " + getFunctionName("ST_Envelope") + "(");
+            strbuf.append(helper.escapeFieldName(geoname));
+            strbuf.append("))");
+            
+            return strbuf.toString();
+        }
+    }
+	
+
+}
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLResource.java
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLResource.java	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLResource.java	(revision 121)
@@ -0,0 +1,220 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+*
+* Copyright (C) 2007-2008 Infrastructures and Transports Department
+* of the Valencian Government (CIT)
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+* MA  02110-1301, USA.
+*
+*/
+
+/*
+* AUTHORS (In addition to CIT):
+* 2009 IVER T.I   {{Task}}
+*/
+
+package org.gvsig.fmap.dal.store.postgresql;
+
+import java.sql.SQLException;
+import java.text.MessageFormat;
+
+import javax.sql.DataSource;
+
+import org.apache.commons.dbcp.BasicDataSource;
+import org.gvsig.fmap.dal.exception.DataException;
+import org.gvsig.fmap.dal.exception.InitializeException;
+import org.gvsig.fmap.dal.resource.exception.AccessResourceException;
+import org.gvsig.fmap.dal.store.jdbc.JDBCResource;
+import org.gvsig.fmap.dal.store.jdbc.JDBCResourceParameters;
+import org.gvsig.fmap.dal.store.jdbc.exception.JDBCDriverClassNotFoundException;
+import org.gvsig.fmap.dal.store.jdbc.exception.JDBCException;
+import org.gvsig.fmap.dal.store.jdbc.exception.JDBCSQLException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class PostgreSQLResource extends JDBCResource {
+	
+	final static private Logger logger = LoggerFactory
+			.getLogger(PostgreSQLResource.class);
+
+	public final static String NAME = "PostgreSQLResource";
+	public static final String DESCRIPTION = "PostgreSQL Connection";
+
+	public PostgreSQLResource(PostgreSQLResourceParameters parameters)
+			throws InitializeException {
+		super(parameters);
+	}
+
+	public String getName() throws AccessResourceException {
+		PostgreSQLResourceParameters params = (PostgreSQLResourceParameters) this.getParameters();
+		return MessageFormat.format("PostgreSQLResource({0},{1})",
+				new Object[] { params.getUrl(),params.getUser() });
+	}
+        
+        public String toString() {
+            try {
+                return this.getName();
+            } catch(Exception ex) {
+                return super.toString();
+            }
+        }
+
+	protected void connectToDB() throws DataException {
+		if (this.dataSource != null) {
+			return;
+		}
+		JDBCResourceParameters jdbcParams = (JDBCResourceParameters) this
+				.getParameters();
+		BasicDataSource dataSource = new BasicDataSource();
+		dataSource.setDriverClassName(jdbcParams.getJDBCDriverClassName());
+		dataSource.setUsername(jdbcParams.getUser());
+		dataSource.setPassword(jdbcParams.getPassword());
+		dataSource.setUrl(jdbcParams.getUrl());
+
+		dataSource.setMaxWait(60L * 1000); // FIXME
+
+		// FIXME Set Pool parameters:
+		/*
+		dataSource.setMaxActive(maxActive);
+		dataSource.setMaxIdle(maxActive);
+		dataSource.setMaxOpenPreparedStatements(maxActive);
+		dataSource.setMaxWait(maxActive);
+		dataSource.setInitialSize(initialSize);
+		dataSource.setDefaultReadOnly(defaultReadOnly);
+		dataSource.setDefaultTransactionIsolation(defaultTransactionIsolation);
+		dataSource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
+		dataSource.setMinIdle(minIdle);
+		dataSource.setTestOnBorrow(testOnBorrow);
+		dataSource.setTestOnReturn(testOnReturn);
+		dataSource.setTestWhileIdle(testOnReturn);
+		dataSource
+				.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
+
+		dataSource.setAccessToUnderlyingConnectionAllowed(allow);
+		dataSource.setLoginTimeout(seconds);
+		dataSource.setLogWriter(out);
+		*/
+
+		this.dataSource = dataSource;
+	}	
+	protected void registerJDBCDriver() throws InitializeException {
+		String className = ((JDBCResourceParameters) getParameters())
+				.getJDBCDriverClassName();
+		if (className == null) {
+			return;
+		}
+
+		Class theClass = null;
+		try {
+			theClass = Class.forName(className);
+		} catch (Exception e){
+			throw new InitializeException(e);
+		}
+		if (theClass == null) {
+			try {
+				throw new JDBCDriverClassNotFoundException(this.getName(),
+						className);
+			} catch (AccessResourceException e) {
+				throw new InitializeException(e);
+
+			}
+		}
+	}
+	
+	protected DataSource createDataSource() {
+		PostgreSQLResourceParameters jdbcParams = (PostgreSQLResourceParameters) this
+				.getParameters();
+		BasicDataSource dataSource = new BasicDataSource();
+		dataSource.setDriverClassName(jdbcParams.getJDBCDriverClassName());
+		dataSource.setUsername(jdbcParams.getUser());
+		dataSource.setPassword(jdbcParams.getPassword());
+		dataSource.setUrl(jdbcParams.getUrl());
+
+		dataSource.setMaxWait(60L * 1000); // FIXME
+
+		// FIXME Set Pool parameters:
+		/*
+		dataSource.setMaxActive(maxActive);
+		dataSource.setMaxIdle(maxActive);
+		dataSource.setMaxOpenPreparedStatements(maxActive);
+		dataSource.setMaxWait(maxActive);
+		dataSource.setInitialSize(initialSize);
+		dataSource.setDefaultReadOnly(defaultReadOnly);
+		dataSource.setDefaultTransactionIsolation(defaultTransactionIsolation);
+		dataSource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
+		dataSource.setMinIdle(minIdle);
+		dataSource.setTestOnBorrow(testOnBorrow);
+		dataSource.setTestOnReturn(testOnReturn);
+		dataSource.setTestWhileIdle(testOnReturn);
+		dataSource
+			.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
+
+		dataSource.setAccessToUnderlyingConnectionAllowed(allow);
+		dataSource.setLoginTimeout(seconds);
+		dataSource.setLogWriter(out);
+		 */
+		return dataSource;
+	}
+	
+	
+	public boolean isConnected() {
+		if (dataSource == null) {
+			return false;
+		}
+		if (dataSource instanceof BasicDataSource) {
+			return ((BasicDataSource) dataSource).getNumActive() > 0
+					|| ((BasicDataSource) dataSource).getNumIdle() > 0;
+		}
+		return true;
+	}	
+	
+	private void logPoolStatus(String src) {
+		if (logger.isDebugEnabled() ) {
+			logger.debug(src + "  " + this.getStatusInformation());
+		}
+
+	}
+        
+        public String getStatusInformation() {
+		if ( !(dataSource instanceof BasicDataSource) ) {
+                    return "Connected: " + this.isConnected();
+                }
+        	BasicDataSource ds = (BasicDataSource) dataSource;
+                String s = "Connected: " + this.isConnected() + ", " +
+                        "actives: "+ ds.getNumActive() + "/"+ ds.getMaxActive() + ", " + 
+                        "idle: " + ds.getNumIdle() + "/"+ ds.getMaxIdle() ;
+                return s;
+        }
+
+        
+
+        private static class CanGetConnectionException extends JDBCSQLException {
+            public CanGetConnectionException(String datasource, SQLException cause) {
+                super("Can't get a connection to the data source (%(datasource))", cause, "_CanGetConnectionException", 0);
+                setValue("datasource", datasource);
+            }
+        }
+    
+	protected synchronized Object getTheConnection() throws DataException {
+		try {
+			Object conn = this.dataSource.getConnection();
+			logPoolStatus("getTheConnection");
+			return conn;
+		} catch (SQLException e) {
+			throw new CanGetConnectionException(this.toString(),e);
+		}
+	}	
+
+}
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLServerExplorer.java
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLServerExplorer.java	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLServerExplorer.java	(revision 121)
@@ -0,0 +1,245 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+
+/*
+ * AUTHORS (In addition to CIT):
+ * 2009 IVER T.I   {{Task}}
+ */
+/**
+ *
+ */
+package org.gvsig.fmap.dal.store.postgresql;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.logging.Level;
+
+import org.gvsig.fmap.dal.DataStoreParameters;
+import org.gvsig.fmap.dal.NewDataStoreParameters;
+import org.gvsig.fmap.dal.exception.DataException;
+import org.gvsig.fmap.dal.exception.InitializeException;
+import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
+import org.gvsig.fmap.dal.exception.RemoveException;
+import org.gvsig.fmap.dal.resource.exception.AccessResourceException;
+import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices;
+import org.gvsig.fmap.dal.store.jdbc.JDBCHelper;
+import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorer;
+import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters;
+import org.gvsig.fmap.dal.store.jdbc.TransactionalAction;
+import org.gvsig.fmap.dal.store.jdbc.exception.JDBCExecuteSQLException;
+import org.gvsig.fmap.dal.store.jdbc.exception.JDBCSQLException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author jmvivo
+ *
+ */
+public class PostgreSQLServerExplorer extends JDBCServerExplorer {
+
+    final static private Logger logger = LoggerFactory
+            .getLogger(PostgreSQLServerExplorer.class);
+
+    public static final String NAME = "PostgreSQLExplorer";
+
+    public PostgreSQLServerExplorer(
+            PostgreSQLServerExplorerParameters parameters,
+            DataServerExplorerProviderServices services)
+            throws InitializeException {
+        super(parameters, services);
+    }
+
+    private PostgreSQLServerExplorerParameters getPostgreSQLParameters() {
+        return (PostgreSQLServerExplorerParameters) getParameters();
+    }
+
+    protected JDBCHelper createHelper() throws InitializeException {
+        return new PostgreSQLHelper(this, getPostgreSQLParameters());
+    }
+
+    public String getStoreName() {
+        return PostgreSQLStoreProvider.NAME;
+    }
+
+    public String getProviderName() {
+        return NAME;
+    }
+
+    protected JDBCStoreParameters createStoreParams()
+            throws InitializeException, ProviderNotRegisteredException {
+        PostgreSQLStoreParameters orgParams = (PostgreSQLStoreParameters) super
+                .createStoreParams();
+
+        orgParams.setUseSSL(getPostgreSQLParameters().getUseSSL());
+
+        return orgParams;
+    }
+
+	// ****************************
+    public boolean canAdd() {
+        return true;
+    }
+
+    public DataStoreParameters getOpenParameters() throws DataException {
+        PostgreSQLServerExplorerParameters parameters = getPostgreSQLParameters();
+        PostgreSQLStoreParameters params = new PostgreSQLStoreParameters();
+        params.setHost(parameters.getHost());
+        params.setPort(parameters.getPort());
+        params.setDBName(parameters.getDBName());
+        params.setUser(parameters.getUser());
+        params.setPassword(parameters.getPassword());
+        params.setCatalog(parameters.getCatalog());
+        params.setSchema(parameters.getSchema());
+        params.setJDBCDriverClassName(parameters.getJDBCDriverClassName());
+        params.setUrl(parameters.getUrl());
+        return params;
+    }
+
+    protected void checkIsMine(DataStoreParameters dsp) {
+        if (!(dsp instanceof PostgreSQLConnectionParameters)) {
+            // FIXME Excpetion ???
+            throw new IllegalArgumentException(
+                    "not instance of PostgreSQLStoreParameters");
+        }
+        super.checkIsMine(dsp);
+
+        PostgreSQLConnectionParameters pgp = (PostgreSQLConnectionParameters) dsp;
+        if (pgp.getUseSSL().booleanValue() != getPostgreSQLParameters()
+                .getUseSSL()) {
+            throw new IllegalArgumentException("worng explorer: Host");
+        }
+    }
+
+    public void remove(DataStoreParameters dsp) throws RemoveException {
+        final PostgreSQLStoreParameters pgParams = (PostgreSQLStoreParameters) dsp;
+
+        TransactionalAction action = new TransactionalAction() {
+            public boolean continueTransactionAllowed() {
+                return false;
+            }
+
+            public Object action(Connection conn) throws DataException {
+
+                Statement st;
+                try {
+                    st = conn.createStatement();
+                } catch (SQLException e) {
+                    throw new JDBCSQLException(e);
+                }
+
+                String sqlDrop = "Drop table "
+                        + pgParams.tableID();
+
+                StringBuilder strb = new StringBuilder();
+                strb.append("Delete from GEOMETRY_COLUMNS where f_table_schema = ");
+                if (pgParams.getSchema() == null || pgParams.getSchema().length() == 0) {
+                    strb.append("current_schema() ");
+                } else {
+                    strb.append('\'');
+                    strb.append(pgParams.getSchema());
+                    strb.append("' ");
+                }
+                strb.append("and f_table_name = '");
+                strb.append(pgParams.getTable());
+                strb.append('\'');
+
+                String sqlDeleteFromGeometry_column = strb.toString();
+                try {
+                    try {
+                        JDBCHelper.execute(st, sqlDrop);
+                    } catch (SQLException e) {
+                        throw new JDBCExecuteSQLException(sqlDrop, e);
+                    }
+
+                    try {
+                        JDBCHelper.execute(st, sqlDeleteFromGeometry_column);
+                    } catch (SQLException e) {
+                        throw new JDBCExecuteSQLException(
+                                sqlDeleteFromGeometry_column, e);
+                    }
+
+                } finally {
+                    try {
+                        st.close();
+                    } catch (SQLException e) {
+                    };
+                }
+                return null;
+            }
+        };
+        try {
+            this.helper.doConnectionAction(action);
+        } catch (Exception e) {
+            throw new RemoveException(this.getProviderName(), e);
+        }
+    }
+
+    public NewDataStoreParameters getAddParameters() throws DataException {
+        PostgreSQLServerExplorerParameters parameters = getPostgreSQLParameters();
+        PostgreSQLNewStoreParameters params = new PostgreSQLNewStoreParameters();
+        params.setHost(parameters.getHost());
+        params.setPort(parameters.getPort());
+        params.setDBName(parameters.getDBName());
+        params.setUser(parameters.getUser());
+        params.setPassword(parameters.getPassword());
+        params.setCatalog(parameters.getCatalog());
+        params.setSchema(parameters.getSchema());
+        params.setJDBCDriverClassName(parameters.getJDBCDriverClassName());
+        params.setUrl(parameters.getUrl());
+        params.setUseSSL(parameters.getUseSSL());
+
+        params.setDefaultFeatureType(this.getServerExplorerProviderServices()
+                .createNewFeatureType());
+
+        return params;
+    }
+
+    public boolean hasGeometrySupport() {
+        return true;
+    }
+
+    protected PostgreSQLHelper getPgHelper() {
+        return (PostgreSQLHelper) getHelper();
+    }
+
+    @Override
+    public List getDataStoreProviderNames() {
+        List x = new ArrayList(1);
+        x.add(PostgreSQLStoreProvider.NAME);
+        return x;
+    }
+
+    public void updateTableStatistics(String tableName) throws JDBCExecuteSQLException {
+        String sql="";
+        if( tableName.startsWith("\"") ) {
+            sql = "VACUUM ANALYZE " + tableName ;
+        } else {
+            sql = "VACUUM ANALYZE \"" + tableName + "\"";
+        }
+        this.getHelper().execute(sql);
+    }
+
+}
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLStoreProvider.java
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLStoreProvider.java	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLStoreProvider.java	(revision 121)
@@ -0,0 +1,395 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+*
+* Copyright (C) 2007-2008 Infrastructures and Transports Department
+* of the Valencian Government (CIT)
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+* MA  02110-1301, USA.
+*
+*/
+
+/*
+* AUTHORS (In addition to CIT):
+* 2009 IVER T.I   {{Task}}
+*/
+
+package org.gvsig.fmap.dal.store.postgresql;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.gvsig.fmap.dal.DALLocator;
+import org.gvsig.fmap.dal.DataManager;
+import org.gvsig.fmap.dal.DataServerExplorer;
+import org.gvsig.fmap.dal.DataTypes;
+import org.gvsig.fmap.dal.exception.DataException;
+import org.gvsig.fmap.dal.exception.InitializeException;
+import org.gvsig.fmap.dal.exception.ReadException;
+import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
+import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
+import org.gvsig.fmap.dal.feature.FeatureQuery;
+import org.gvsig.fmap.dal.feature.FeatureType;
+import org.gvsig.fmap.dal.feature.spi.FeatureProvider;
+import org.gvsig.fmap.dal.feature.spi.FeatureSetProvider;
+import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
+import org.gvsig.fmap.dal.store.db.DBHelper;
+import org.gvsig.fmap.dal.store.jdbc.JDBCHelper;
+import org.gvsig.fmap.dal.store.jdbc.JDBCStoreProviderWriter;
+import org.gvsig.fmap.geom.Geometry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class PostgreSQLStoreProvider extends JDBCStoreProviderWriter {
+
+	public final static Logger logger = LoggerFactory
+			.getLogger(PostgreSQLStoreProvider.class);
+
+	public static final String NAME = "PostgreSQL";
+	public static final String DESCRIPTION = "PostgreSQL source";
+
+	public static final String METADATA_DEFINITION_NAME = NAME;
+	
+	public PostgreSQLStoreProvider(PostgreSQLStoreParameters params,
+			DataStoreProviderServices storeServices)
+			throws InitializeException {
+		super(params, storeServices, DBHelper.newMetadataContainer(METADATA_DEFINITION_NAME));
+	}
+
+	private PostgreSQLStoreParameters getPGParameters() {
+		return (PostgreSQLStoreParameters) this.getParameters();
+	}
+
+	protected JDBCHelper createHelper() throws InitializeException {
+	    JDBCHelper resp = new PostgreSQLHelper(this, getPGParameters());
+	    
+	    return resp;
+	}
+
+
+
+	protected String fixFilter(String _filter) {
+		if (_filter == null) {
+			return null;
+		}
+		
+		String filter = fixFunctionNames(_filter);
+
+		// Transform SRS to code
+		// GeomFromText\s*\(\s*'[^']*'\s*,\s*('[^']*')\s*\)
+		
+		String geom_from_text = this.getFunctionName("ST_GeomFromText");
+		Pattern pattern = Pattern
+				.compile(geom_from_text + "\\s*\\(\\s*'[^']*'\\s*,\\s*'([^']*)'\\s*\\)");
+		Matcher matcher = pattern.matcher(filter);
+		StringBuilder strb = new StringBuilder();
+		int pos = 0;
+		String srsCode;
+		while (matcher.find(pos)) {
+			strb.append(filter.substring(pos, matcher.start(1)));
+			srsCode = matcher.group(1).trim();
+			if (srsCode.startsWith("'")) {
+				srsCode = srsCode.substring(1);
+			}
+			if (srsCode.endsWith("'")) {
+				srsCode = srsCode.substring(0, srsCode.length() - 1);
+			}
+			strb.append(helper.getProviderSRID(srsCode));
+			strb.append(filter.substring(matcher.end(1), matcher.end()));
+			pos = matcher.end();
+
+		}
+		strb.append(filter.substring(pos));
+
+		return strb.toString();
+	}
+
+
+    public String getName() {
+		return NAME;
+	}
+
+	public FeatureSetProvider createSet(FeatureQuery query,
+			FeatureType featureType) throws DataException {
+
+		return new PostgreSQLSetProvider(this, query, featureType);
+	}
+
+
+	public DataServerExplorer getExplorer() throws ReadException {
+		DataManager manager = DALLocator.getDataManager();
+		PostgreSQLServerExplorerParameters exParams;
+		PostgreSQLStoreParameters params = getPGParameters();
+		try {
+			exParams = (PostgreSQLServerExplorerParameters) manager
+					.createServerExplorerParameters(PostgreSQLServerExplorer.NAME);
+			exParams.setUrl(params.getUrl());
+			exParams.setHost(params.getHost());
+			exParams.setPort(params.getPort());
+			exParams.setDBName(params.getDBName());
+			exParams.setUser(params.getUser());
+			exParams.setPassword(params.getPassword());
+			exParams.setCatalog(params.getCatalog());
+			exParams.setSchema(params.getSchema());
+			exParams.setJDBCDriverClassName(params.getJDBCDriverClassName());
+			exParams.setUseSSL(params.getUseSSL());
+
+			return manager.openServerExplorer(PostgreSQLServerExplorer.NAME, exParams);
+		} catch (DataException e) {
+			throw new ReadException(this.getName(), e);
+		} catch (ValidateDataParametersException e) {
+			throw new ReadException(this.getName(), e);
+		}
+	}
+
+	public boolean allowAutomaticValues() {
+		return true;
+	}
+
+
+	public boolean hasGeometrySupport() {
+		return true;
+	}
+
+
+	protected PostgreSQLHelper getPgHelper() {
+		return (PostgreSQLHelper) getHelper();
+	}
+
+
+
+	public boolean canWriteGeometry(int geometryType, int geometrySubtype)
+			throws DataException {
+		FeatureType type = getFeatureStore().getDefaultFeatureType();
+		FeatureAttributeDescriptor geomAttr = type.getAttributeDescriptor(type
+								.getDefaultGeometryAttributeName());
+		if (geomAttr == null) {
+			return false;
+		}
+		if (geometrySubtype != geomAttr.getGeometrySubType()) {
+			return false;
+		}
+		switch (geomAttr.getGeometryType()) {
+		case Geometry.TYPES.GEOMETRY:
+			return true;
+
+		case Geometry.TYPES.MULTISURFACE:
+			return geometryType == Geometry.TYPES.MULTISURFACE
+					|| geometryType == Geometry.TYPES.SURFACE;
+
+		case Geometry.TYPES.MULTIPOINT:
+			return geometryType == Geometry.TYPES.MULTIPOINT
+					|| geometryType == Geometry.TYPES.POINT;
+
+		case Geometry.TYPES.MULTICURVE:
+			return geometryType == Geometry.TYPES.MULTICURVE
+					|| geometryType == Geometry.TYPES.CURVE;
+
+		case Geometry.TYPES.MULTISOLID:
+			return geometryType == Geometry.TYPES.MULTISOLID
+					|| geometryType == Geometry.TYPES.SOLID;
+
+		default:
+			return geometryType == geomAttr.getGeometryType();
+		}
+
+	}
+
+
+	protected void addToListFeatureValues(FeatureProvider featureProvider,
+			FeatureAttributeDescriptor attrOfList,
+			FeatureAttributeDescriptor attr,
+			List<Object> values) throws DataException {
+
+		super.addToListFeatureValues(featureProvider, attrOfList, attr, values);
+		if (attr.getType() == DataTypes.GEOMETRY) {
+			values.add(helper.getProviderSRID(attr.getSRS()));
+		}
+	}
+
+	protected void prepareAttributeForInsert(
+			FeatureAttributeDescriptor attr, List<String> fields, List<String> values) {
+
+		if (attr.getType() == DataTypes.GEOMETRY) {
+			fields.add(helper.escapeFieldName(attr.getName()));
+			values.add(getFunctionName("ST_GeomFromWKB") + "(?,?)");
+		} else {
+			super.prepareAttributeForInsert(attr, fields, values);
+		}
+
+	}
+
+	protected void prepareAttributeForUpdate(FeatureAttributeDescriptor attr,
+			List<String> values) {
+		if (attr.getType() == DataTypes.GEOMETRY) {
+			values.add(helper.escapeFieldName(attr.getName())
+					+ " = " + getFunctionName("ST_GeomFromWKB") + "(?,?)");
+		} else {
+			super.prepareAttributeForUpdate(attr, values);
+		}
+	}
+
+	protected String getSqlStatementAddField(FeatureAttributeDescriptor attr,
+			List<String> additionalStatement) throws DataException {
+		if (attr.getType() == DataTypes.GEOMETRY) {
+			PostgreSQLStoreParameters params = getPGParameters();
+			additionalStatement.addAll(	((PostgreSQLHelper) helper)
+					.getSqlGeometyFieldAdd(attr, params.getTable(), params
+							.getSchema()));
+
+		}
+		return super.getSqlStatementAddField(attr, additionalStatement);
+
+	}
+	private String getSqlGeometyFieldDrop(FeatureAttributeDescriptor attr) {
+		StringBuilder strb = new StringBuilder();
+		PostgreSQLStoreParameters params = getPGParameters();
+		strb.append("Delete from geometry_columns where f_geometry_column = '");
+		strb.append(attr.getName());
+		strb.append("' and f_table_nam = '");
+		strb.append(params.getTable());
+		strb.append("' and f_table_schema = ");
+		if (params.getSchema() == null || params.getSchema().length() == 0) {
+			strb.append("current_schema()");
+		} else {
+			strb.append("'");
+			strb.append(params.getSchema());
+			strb.append("'");
+		}
+		if (params.getCatalog() != null && params.getCatalog().length() > 0) {
+			strb.append(" and f_table_catalog = '");
+			strb.append(params.getCatalog());
+			strb.append("'");
+		}
+		return strb.toString();
+	}
+
+	protected String getSqlStatementDropField(FeatureAttributeDescriptor attr,
+			List<String> additionalStatement) {
+		String result = super.getSqlStatementDropField(attr,
+				additionalStatement);
+		if (attr.getType() == DataTypes.GEOMETRY) {
+			additionalStatement.add(getSqlGeometyFieldDrop(attr));
+		}
+		return result;
+	}
+
+	protected List<String> getSqlStatementAlterField(
+			FeatureAttributeDescriptor attrOrg,
+			FeatureAttributeDescriptor attrTrg, List<String> additionalStatement)
+			throws DataException {
+		//
+		List<String> actions = super.getSqlStatementAlterField(attrOrg, attrTrg,
+				additionalStatement);
+		PostgreSQLStoreParameters params = getPGParameters();
+		if (attrOrg.getDataType() != attrTrg.getDataType()) {
+			if (attrOrg.getType() == DataTypes.GEOMETRY) {
+				additionalStatement.add(getSqlGeometyFieldDrop(attrOrg));
+			}
+			if (attrTrg.getType() == DataTypes.GEOMETRY) {
+				additionalStatement.addAll(((PostgreSQLHelper) helper)
+						.getSqlGeometyFieldAdd(attrTrg, params.getTable(),
+								params.getSchema()));
+			}
+		}
+		if (attrOrg.getDataType() == attrTrg.getDataType()
+				&& attrTrg.getType() == DataTypes.GEOMETRY) {
+			// TODO Checks SRS and GeomType/Subtype
+		}
+
+		return actions;
+	}
+	
+
+	private String getFunctionName(String newFunctionName) {
+        
+        PostgreSQLHelper hpr = getPgHelper();
+        if (hpr == null) {
+            logger.info("Unable to get PG helper.", new Exception("Helper is null"));
+            return newFunctionName;
+        } else {
+            return hpr.getFunctionName(newFunctionName);
+        }
+    }
+	
+    private String fixFunctionNames(String _filter) {
+        
+        Properties props = this.getPgHelper().getBeforePostgis13Properties();
+        Iterator iter = props.keySet().iterator();
+        String kstr = null;
+        String vstr = null;
+        
+        String resp = _filter;
+        
+        while (iter.hasNext()) {
+            kstr = (String) iter.next();
+            vstr = getPgHelper().getFunctionName(kstr);
+            resp = replace(resp, kstr, vstr);
+        }
+        return resp;
+    }
+
+    private String replace(String str, String oldstr, String newstr) {
+        
+        if (oldstr == null || newstr == null ||
+            oldstr.length() == 0 || oldstr.equals(newstr)) {
+            return str;
+        }
+        
+        String lowerstr = str.toLowerCase();
+        String lowerold = oldstr.toLowerCase();
+        
+        if (lowerstr.indexOf(lowerold) == -1) {
+            // nothing to do
+            return str;
+        }
+        
+        Pattern p = Pattern.compile(lowerold, Pattern.LITERAL);
+        String[] parts = p.split(lowerstr); 
+        
+        StringBuffer resp = new StringBuffer();
+        int auxind = 0;
+        resp.append(str.subSequence(0, parts[0].length()));
+        for (int i=1; i<parts.length; i++) {
+            resp.append(newstr);
+            auxind = getIndex(parts, i-1, oldstr.length());
+            resp.append(str.subSequence(auxind, auxind + parts[i].length()));
+        }
+        return resp.toString();
+    }
+
+    /**
+     * This method gets the index where the n-th part (0-based)
+     * starts in the original string
+     * 
+     * @param parts
+     * @param n
+     * @param length
+     * @return
+     */
+    private int getIndex(String[] parts, int till_n, int length) {
+        
+        int resp = 0;
+        for (int i=0; i<(till_n+1); i++) {
+            resp = resp + parts[i].length();
+            resp = resp + length;
+        }
+        return resp;
+    }
+
+    
+}
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLNewStoreParameters.java
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLNewStoreParameters.java	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLNewStoreParameters.java	(revision 121)
@@ -0,0 +1,54 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.fmap.dal.store.postgresql;
+
+import org.gvsig.fmap.dal.feature.EditableFeatureType;
+import org.gvsig.fmap.dal.feature.FeatureType;
+import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters;
+import org.gvsig.fmap.dal.store.jdbc.JDBCNewStoreParameters;
+
+public class PostgreSQLNewStoreParameters extends JDBCNewStoreParameters
+        implements NewFeatureStoreParameters, PostgreSQLConnectionParameters {
+
+    public static final String PARAMETERS_DEFINITION_NAME = "PostgreSQLNewStoreParameters";
+
+    public PostgreSQLNewStoreParameters() {
+        super(PARAMETERS_DEFINITION_NAME, PostgreSQLStoreProvider.NAME);
+    }
+
+    public EditableFeatureType getDefaultFeatureType() {
+        return (EditableFeatureType) this.getDynValue(FEATURETYPE_PARAMTER_NAME);
+    }
+
+    public void setDefaultFeatureType(FeatureType featureType) {
+        this.setDynValue(FEATURETYPE_PARAMTER_NAME, featureType);
+    }
+
+    public Boolean getUseSSL() {
+        return (Boolean) this.getDynValue(DYNFIELDNAME_USESSL);
+    }
+
+    public void setUseSSL(Boolean useSSL) {
+        this.setDynValue(DYNFIELDNAME_USESSL, useSSL);
+    }
+
+}
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLResourceParameters.java
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLResourceParameters.java	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLResourceParameters.java	(revision 121)
@@ -0,0 +1,68 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+*
+* Copyright (C) 2007-2008 Infrastructures and Transports Department
+* of the Valencian Government (CIT)
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+* MA  02110-1301, USA.
+*
+*/
+
+/*
+* AUTHORS (In addition to CIT):
+* 2009 IVER T.I   {{Task}}
+*/
+
+package org.gvsig.fmap.dal.store.postgresql;
+
+import org.gvsig.fmap.dal.store.jdbc.JDBCResourceParameters;
+
+public class PostgreSQLResourceParameters extends JDBCResourceParameters
+		implements PostgreSQLConnectionParameters {
+
+	public static final String PARAMETERS_DEFINITION_NAME = "PostgreSQLResourceParameters";
+
+	public PostgreSQLResourceParameters() {
+		super(PARAMETERS_DEFINITION_NAME,PostgreSQLResource.NAME);
+	}
+
+    public PostgreSQLResourceParameters(String url, String host, Integer port,
+			String dbName, String user, String password,
+			String jdbcDriverClassName, Boolean ssl) {
+		super(PARAMETERS_DEFINITION_NAME,PostgreSQLResource.NAME,url, host, port, dbName, user, password, jdbcDriverClassName);
+		if (ssl != null) {
+			this.setUseSSL(ssl.booleanValue());
+		}
+	}
+
+	public String getUrl() {
+		return PostgreSQLLibrary.getJdbcUrl(getHost(),
+				getPort(),
+				getDBName());
+	}
+
+	public Boolean getUseSSL() {
+		return (Boolean) this.getDynValue(DYNFIELDNAME_USESSL);
+	}
+
+	public void setUseSSL(Boolean useSSL) {
+		this.setDynValue(DYNFIELDNAME_USESSL, useSSL);
+	}
+
+	public void setUseSSL(boolean useSSL) {
+		this.setDynValue(DYNFIELDNAME_USESSL, new Boolean(useSSL));
+	}
+
+}
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLServerExplorerParameters.java
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLServerExplorerParameters.java	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLServerExplorerParameters.java	(revision 121)
@@ -0,0 +1,73 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+*
+* Copyright (C) 2007-2008 Infrastructures and Transports Department
+* of the Valencian Government (CIT)
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+* MA  02110-1301, USA.
+*
+*/
+
+/*
+* AUTHORS (In addition to CIT):
+* 2009 IVER T.I   {{Task}}
+*/
+
+/**
+ *
+ */
+package org.gvsig.fmap.dal.store.postgresql;
+
+import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
+import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters;
+
+public class PostgreSQLServerExplorerParameters extends
+		JDBCServerExplorerParameters implements PostgreSQLConnectionParameters {
+
+
+	public static final String PARAMETERS_DEFINITION_NAME = "PostgreSQLServerExplorerParameters";
+
+	public PostgreSQLServerExplorerParameters() {
+		super(PARAMETERS_DEFINITION_NAME, PostgreSQLServerExplorer.NAME);
+	}
+
+	public Boolean getUseSSL() {
+		return (Boolean) this.getDynValue(DYNFIELDNAME_USESSL);
+	}
+
+	public void setUseSSL(Boolean useSSL) {
+		this.setDynValue(DYNFIELDNAME_USESSL, useSSL);
+	}
+
+	public void setUseSSL(boolean useSSL) {
+		this.setDynValue(DYNFIELDNAME_USESSL, new Boolean(useSSL));
+	}
+
+	public void validate() throws ValidateDataParametersException {
+		if (getJDBCDriverClassName() == null) {
+			setJDBCDriverClassName(PostgreSQLLibrary.DEFAULT_JDCB_DRIVER_NAME);
+		}
+		if (getUrl() == null) {
+			setUrl(PostgreSQLLibrary.getJdbcUrl(getHost(), getPort(),
+					getDBName()));
+		}
+
+		if (getPort() == null) {
+			setPort(new Integer(5432));
+		}
+		super.validate();
+	}
+
+}
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLHelper.java
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLHelper.java	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLHelper.java	(revision 121)
@@ -0,0 +1,1006 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+*
+* Copyright (C) 2007-2008 Infrastructures and Transports Department
+* of the Valencian Government (CIT)
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+* MA  02110-1301, USA.
+*
+*/
+
+/*
+* AUTHORS (In addition to CIT):
+* 2009 IVER T.I   {{Task}}
+*/
+
+/**
+ *
+ */
+package org.gvsig.fmap.dal.store.postgresql;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import org.cresques.cts.IProjection;
+import org.postgresql.PGResultSetMetaData;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.gvsig.fmap.crs.CRSFactory;
+import org.gvsig.fmap.dal.DALLocator;
+import org.gvsig.fmap.dal.DataTypes;
+import org.gvsig.fmap.dal.NewDataStoreParameters;
+import org.gvsig.fmap.dal.exception.DataException;
+import org.gvsig.fmap.dal.exception.InitializeException;
+import org.gvsig.fmap.dal.exception.ReadException;
+import org.gvsig.fmap.dal.exception.WriteException;
+import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
+import org.gvsig.fmap.dal.feature.EditableFeatureType;
+import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
+import org.gvsig.fmap.dal.feature.FeatureType;
+import org.gvsig.fmap.dal.feature.exception.CreateGeometryException;
+import org.gvsig.fmap.dal.feature.exception.UnsupportedDataTypeException;
+import org.gvsig.fmap.dal.resource.ResourceAction;
+import org.gvsig.fmap.dal.resource.spi.ResourceManagerProviderServices;
+import org.gvsig.fmap.dal.store.jdbc.ConnectionAction;
+import org.gvsig.fmap.dal.store.jdbc.JDBCHelper;
+import org.gvsig.fmap.dal.store.jdbc.JDBCHelperUser;
+import org.gvsig.fmap.dal.store.jdbc.JDBCNewStoreParameters;
+import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters;
+import org.gvsig.fmap.dal.store.jdbc.exception.JDBCException;
+import org.gvsig.fmap.dal.store.jdbc.exception.JDBCExecutePreparedSQLException;
+import org.gvsig.fmap.dal.store.jdbc.exception.JDBCExecuteSQLException;
+import org.gvsig.fmap.dal.store.jdbc.exception.JDBCPreparingSQLException;
+import org.gvsig.fmap.dal.store.jdbc.exception.JDBCSQLException;
+import org.gvsig.fmap.geom.Geometry;
+import org.gvsig.fmap.geom.primitive.Envelope;
+import org.gvsig.tools.ToolsLocator;
+import org.gvsig.tools.exception.BaseException;
+
+/**
+ * @author jmvivo
+ *
+ */
+public class PostgreSQLHelper extends JDBCHelper {
+
+	private static Logger logger = LoggerFactory
+			.getLogger(PostgreSQLHelper.class);
+
+	private Map pgSR2SRSID = new TreeMap();
+	private Map srsID2pgSR = new TreeMap();
+	
+	private static Properties beforePostgis13 = null;
+    private int[] postGISVersion = { 0,0,0 };
+    private boolean versionSet = false;
+
+	PostgreSQLHelper(JDBCHelperUser consumer,
+			PostgreSQLConnectionParameters params)
+			throws InitializeException {
+
+		super(consumer, params);
+	}
+
+	protected void initializeResource() throws InitializeException {
+		ResourceManagerProviderServices manager = (ResourceManagerProviderServices) DALLocator
+		.getResourceManager();
+		PostgreSQLResource resource = (PostgreSQLResource) manager
+		.createAddResource(
+				PostgreSQLResource.NAME, new Object[] {
+						params.getUrl(), params.getHost(),
+						params.getPort(), params.getDBName(), params.getUser(),
+						params.getPassword(),
+						params.getJDBCDriverClassName(),
+						((PostgreSQLConnectionParameters) params).getUseSSL() });
+		this.setResource(resource);
+	}
+
+
+	protected String getDefaultSchema(Connection conn)
+			throws JDBCException {
+		if (defaultSchema == null) {
+			String sql = "Select current_schema()";
+			ResultSet rs = null;
+			Statement st = null;
+			String schema = null;
+			try {
+				st = conn.createStatement();
+				try {
+					rs = JDBCHelper.executeQuery(st, sql); 
+				} catch (java.sql.SQLException e) {
+					throw new JDBCExecuteSQLException(sql, e);
+				}
+				rs.next();
+				schema = rs.getString(1);
+			} catch (java.sql.SQLException e) {
+				throw new JDBCSQLException(e);
+			} finally {
+				try {rs.close();} catch (Exception e) {logger.error("Exception clossing resulset", e);};
+				try {st.close();} catch (Exception e) {logger.error("Exception clossing statement", e);};
+				rs = null;
+				st = null;
+			}
+			defaultSchema = schema;
+		}
+
+		return defaultSchema;
+	}
+
+    public Envelope getFullEnvelopeOfField(
+            JDBCStoreParameters storeParams,
+            String geometryAttrName, Envelope limit)
+            throws DataException {
+
+        StringBuilder strb = new StringBuilder();
+        strb.append("Select " + getFunctionName("ST_AsBinary") + "("
+                + getFunctionName("ST_Extent") + "(");
+        strb.append(escapeFieldName(geometryAttrName));
+        strb.append(")) from ");
+
+        if (storeParams.getSQL() != null
+                && storeParams.getSQL().trim().length() > 0) {
+            strb.append('(');
+            strb.append(storeParams.getSQL());
+            strb.append(") as _subquery_alias_ ");
+        } else {
+            strb.append(storeParams.tableID());
+        }
+
+        if (limit != null || (storeParams.getBaseFilter() != null
+                && storeParams.getBaseFilter().trim().length() > 0)) {
+            strb.append(" where  ");
+
+            if (limit != null) {
+                strb.append(" ( " + getFunctionName("ST_Intersects") + "("
+                        + getFunctionName("ST_GeomFromText") + "('");
+                String workAreaWkt = null;
+                try {
+                    workAreaWkt = limit.getGeometry().convertToWKT();
+                } catch (Exception e) {
+                    throw new CreateGeometryException(e);
+                }
+                strb.append(workAreaWkt);
+                strb.append("', ");
+
+                IProjection proj = storeParams.getCRS();
+                int sridInt = this.getProviderSRID(proj);
+                if (sridInt == -1) {
+                    throw new CreateGeometryException(
+                            new Exception("CRS is null or unknown."));
+                } else {
+                    strb.append(Integer.toString(sridInt));
+                }
+                strb.append("), " + getFunctionName("ST_Envelope") + "(");
+                strb.append(escapeFieldName(geometryAttrName));
+                strb.append(")) ) ");
+
+            }
+            if (storeParams.getBaseFilter() != null && storeParams.getBaseFilter().trim().length() > 0) {
+                if (limit != null) {
+                    strb.append(" and ");
+                }
+                strb.append(" ( ");
+                strb.append(storeParams.getBaseFilter());
+                strb.append(" ) ");
+            }
+
+        }
+
+        final String sql = strb.toString();
+
+        this.open();
+
+        return (Envelope) getResource().execute(new ResourceAction() {
+            public String toString() {
+                return "getEnvelope";
+            }
+
+            public Object run() throws Exception {
+                ResultSet rs = null;
+                Statement st = null;
+                Connection conn = null;
+                Envelope fullEnvelope = null;
+
+                Envelope emptyEnv
+                        = geomManager.createEnvelope(Geometry.SUBTYPES.GEOM2D);
+
+                try {
+
+                    conn = getConnection();
+                    st = conn.createStatement();
+                    try {
+                        rs = JDBCHelper.executeQuery(st, sql);
+                    } catch (java.sql.SQLException e) {
+                        throw new JDBCExecuteSQLException(sql, e);
+                    }
+                    if (!rs.next()) {
+                        return emptyEnv;
+                    }
+
+                    byte[] data = rs.getBytes(1);
+                    if (data == null) {
+                        return emptyEnv;
+                    }
+
+                    Geometry geom = geomManager.createFrom(data);
+
+                    fullEnvelope = geom.getEnvelope();
+
+                    return fullEnvelope;
+                } catch (java.sql.SQLException e) {
+                    throw new JDBCSQLException(e);
+                } catch (BaseException e) {
+                    throw new ReadException(user.getProviderName(), e);
+                } finally {
+                    try {
+                        rs.close();
+                    } catch (Exception e) {
+                    }
+                    try {
+                        st.close();
+                    } catch (Exception e) {
+                    }
+                    try {
+                        conn.close();
+                    } catch (Exception e) {
+                    }
+                    rs = null;
+                    st = null;
+                    conn = null;
+                }
+            }
+        });
+    }
+
+	@Override
+	protected boolean supportsGeometry() {
+		return true;
+	}
+
+	/**
+	 * Fill <code>featureType</code> geometry attributes with SRS and ShapeType
+	 * information stored in the table GEOMETRY_COLUMNS
+	 *
+	 * @param conn
+	 * @param rsMetadata
+	 * @param featureType
+	 * @throws ReadException
+	 */
+	protected void loadSRS_and_shapeType(Connection conn,
+			ResultSetMetaData rsMetadata, EditableFeatureType featureType,
+			String baseSchema, String baseTable)
+			throws JDBCException {
+
+		Statement st = null;
+		ResultSet rs = null;
+		try {
+			// Sacamos la lista de los attributos geometricos
+			EditableFeatureAttributeDescriptor attr;
+			List geoAttrs = new ArrayList();
+
+			Iterator iter = featureType.iterator();
+			while (iter.hasNext()) {
+				attr = (EditableFeatureAttributeDescriptor) iter.next();
+				if (attr.getType() == DataTypes.GEOMETRY) {
+					geoAttrs.add(attr);
+				}
+			}
+			if (geoAttrs.size() < 1) {
+				return;
+			}
+
+
+			// preparamos un set con las lista de tablas de origen
+			// de los campos
+			class TableId {
+				public String schema=null;
+				public String table=null;
+				public String field = null;
+
+				public void appendToSQL(StringBuilder strb) {
+					if (schema == null || schema.length() == 0) {
+						strb
+								.append("( F_TABLE_SCHEMA = current_schema() AND F_TABLE_NAME = '");
+					} else {
+						strb.append("( F_TABLE_SCHEMA = '");
+						strb.append(schema);
+						strb.append("' AND F_TABLE_NAME = '");
+					}
+					strb.append(table);
+					strb.append("' AND F_GEOMETRY_COLUMN = '");
+					strb.append(field);
+					strb.append("' )");
+				}
+
+			}
+			Comparator cmp = new Comparator(){
+				public int compare(Object arg0, Object arg1) {
+					TableId a0 = (TableId) arg0;
+					TableId a1 = (TableId) arg1;
+
+					int aux = a0.field.compareTo(a1.field);
+					if (aux != 0) {
+					    return aux;
+					}
+
+					aux = a0.table.compareTo(a1.table);
+                    if (aux != 0) {
+                        return aux;
+                    }
+					
+                    if (a0.schema == null) {
+                        if (a1.schema == null) {
+                            aux = 0;
+                        } else {
+                            aux = -1;
+                        }
+                    } else {
+                        if (a1.schema == null) {
+                            aux = -1;
+                        } else {
+                            aux = a0.schema.compareTo(a1.schema);
+                        }
+                    }
+					return aux;
+				}
+			};
+			TreeSet set = new TreeSet(cmp);
+			TableId tableId;
+			iter = geoAttrs.iterator();
+			int rsIndex;
+			while (iter.hasNext()) {
+				attr = (EditableFeatureAttributeDescriptor) iter.next();
+				tableId = new TableId();
+				rsIndex = attr.getIndex() + 1;
+
+				if (baseSchema == null && baseTable == null) {
+					if (rsMetadata instanceof PGResultSetMetaData) {
+						tableId.schema = ((PGResultSetMetaData) rsMetadata)
+								.getBaseSchemaName(rsIndex);
+						tableId.table = ((PGResultSetMetaData) rsMetadata)
+								.getBaseTableName(rsIndex);
+						tableId.field = ((PGResultSetMetaData) rsMetadata)
+								.getBaseColumnName(rsIndex);
+
+					} else {
+						tableId.schema = rsMetadata.getSchemaName(rsIndex);
+						tableId.table = rsMetadata.getTableName(rsIndex);
+						tableId.field = rsMetadata.getColumnName(rsIndex);
+					}
+				} else {
+					tableId.schema = baseSchema;
+					tableId.table = baseTable;
+					tableId.field = rsMetadata.getColumnName(rsIndex);
+				}
+				if (tableId.table == null || tableId.table.length() == 0) {
+					// Si no tiene tabla origen (viene de algun calculo por ej.)
+					// lo saltamos ya que no estara en la tabla GEOMETRY_COLUMNS
+					continue;
+				}
+				set.add(tableId);
+			}
+
+			if (set.size() == 0) {
+				return;
+			}
+
+			// Preparamos una sql para que nos saque el resultado
+			StringBuilder strb = new StringBuilder();
+			strb.append("Select geometry_columns.*,auth_name || ':' || auth_srid as SRSID ");
+			strb.append("from geometry_columns left join spatial_ref_sys on ");
+			strb.append("geometry_columns.srid = spatial_ref_sys.srid WHERE ");
+			iter = set.iterator();
+			for (int i=0;i<set.size()-1;i++) {
+				tableId = (TableId) iter.next();
+				tableId.appendToSQL(strb);
+				strb.append(" OR ");
+			}
+			tableId = (TableId) iter.next();
+			tableId.appendToSQL(strb);
+			String sql = strb.toString();
+
+
+			st = conn.createStatement();
+			try {
+				rs = JDBCHelper.executeQuery(st,sql);
+			} catch (SQLException e) {
+				throw new JDBCExecuteSQLException(sql, e);
+			}
+			String srsID;
+			int pgSrid;
+			int geometryType;
+			int geometrySubtype;
+			String geomTypeStr;
+			int dimensions;
+			IProjection srs;
+
+			while (rs.next()){
+				srsID = rs.getString("SRSID");
+				pgSrid = rs.getInt("SRID");
+				geomTypeStr = rs.getString("TYPE").toUpperCase();
+				geometryType = Geometry.TYPES.GEOMETRY;
+				if (geomTypeStr.startsWith("POINT")) {
+					geometryType = Geometry.TYPES.POINT;
+				} else if (geomTypeStr.startsWith("LINESTRING")) {
+					geometryType = Geometry.TYPES.CURVE;
+				} else if (geomTypeStr.startsWith("POLYGON")) {
+					geometryType = Geometry.TYPES.SURFACE;
+				} else if (geomTypeStr.startsWith("MULTIPOINT")) {
+					geometryType = Geometry.TYPES.MULTIPOINT;
+				} else if (geomTypeStr.startsWith("MULTILINESTRING")) {
+					geometryType = Geometry.TYPES.MULTICURVE;
+				} else if (geomTypeStr.startsWith("MULTIPOLYGON")) {
+					geometryType = Geometry.TYPES.MULTISURFACE;
+				}
+				dimensions = rs.getInt("coord_dimension");
+				geometrySubtype = Geometry.SUBTYPES.GEOM2D;
+				if (dimensions > 2) {
+					if (dimensions == 3) {
+						if (geomTypeStr.endsWith("M")) {
+							geometrySubtype = Geometry.SUBTYPES.GEOM2DM;
+						} else {
+							geometrySubtype = Geometry.SUBTYPES.GEOM3D;
+						}
+
+					} else {
+						geometrySubtype = Geometry.SUBTYPES.GEOM3DM;
+					}
+				}
+				addToPgSRToSRSID(pgSrid, srsID);
+
+
+				iter = geoAttrs.iterator();
+				while (iter.hasNext()) {
+					attr = (EditableFeatureAttributeDescriptor) iter.next();
+					rsIndex = attr.getIndex() + 1;
+					if (!rsMetadata.getColumnName(rsIndex).equals(
+							rs.getString("f_geometry_column"))) {
+						continue;
+					}
+
+					if (baseSchema == null && baseTable == null) {
+
+						if (rsMetadata instanceof PGResultSetMetaData) {
+							if (!((PGResultSetMetaData) rsMetadata)
+									.getBaseTableName(rsIndex).equals(
+											rs.getString("f_table_name"))) {
+								continue;
+							}
+							String curSchema = rs.getString("f_table_schema");
+							String metaSchema = ((PGResultSetMetaData) rsMetadata)
+									.getBaseSchemaName(rsIndex);
+							if (!metaSchema.equals(curSchema)) {
+								if (metaSchema.length() == 0
+										&& metaSchema == getDefaultSchema(conn)) {
+								} else {
+									continue;
+								}
+							}
+
+						} else {
+
+							if (!rsMetadata.getTableName(rsIndex).equals(
+									rs.getString("f_table_name"))) {
+								continue;
+							}
+							String curSchema = rs.getString("f_table_schema");
+							String metaSchema = rsMetadata
+									.getSchemaName(rsIndex);
+							if (!metaSchema.equals(curSchema)) {
+								if (metaSchema.length() == 0
+										&& metaSchema == getDefaultSchema(conn)) {
+								} else {
+									continue;
+								}
+							}
+						}
+					}
+					attr.setGeometryType(geometryType);
+					attr.setGeometrySubType(geometrySubtype);
+					if (srsID != null && srsID.length() > 0) {
+						attr.setSRS(CRSFactory.getCRS(srsID));
+					}
+					iter.remove();
+				}
+				iter = geoAttrs.iterator();
+				while (iter.hasNext()) {
+					attr = (EditableFeatureAttributeDescriptor) iter.next();
+					attr.setSRS(null);
+					attr.setGeometryType(Geometry.TYPES.GEOMETRY);
+
+				}
+			}
+
+		} catch (java.sql.SQLException e) {
+			throw new JDBCSQLException(e);
+		} finally {
+			try {rs.close();} catch (Exception e) {	};
+			try {st.close();} catch (Exception e) {	};
+		}
+
+	}
+
+
+	public String getSqlColumnTypeDescription(FeatureAttributeDescriptor attr) {
+		if (attr.getType() == DataTypes.GEOMETRY) {
+			return "geometry";
+		}
+		return super.getSqlColumnTypeDescription(attr);
+	}
+
+
+	public int getPostgisGeomDimensions(int geometrySubType) {
+		switch (geometrySubType) {
+		case Geometry.SUBTYPES.GEOM2D:
+			return 2;
+		case Geometry.SUBTYPES.GEOM2DM:
+		case Geometry.SUBTYPES.GEOM3D:
+			return 3;
+
+		case Geometry.SUBTYPES.GEOM3DM:
+			return 4;
+		default:
+			throw new UnsupportedDataTypeException(
+					ToolsLocator.getDataTypesManager().getTypeName(DataTypes.GEOMETRY),
+					DataTypes.GEOMETRY);
+		}
+	}
+
+	public String getPostgisGeomType(int geometryType, int geometrySubType) {
+		String pgGeomType;
+		switch (geometryType) {
+		case Geometry.TYPES.GEOMETRY:
+			pgGeomType = "GEOMETRY";
+			break;
+		case Geometry.TYPES.POINT:
+			pgGeomType = "POINT";
+			break;
+		case Geometry.TYPES.CURVE:
+			pgGeomType = "LINESTRING";
+			break;
+		case Geometry.TYPES.SURFACE:
+			pgGeomType = "POLYGON";
+			break;
+		case Geometry.TYPES.MULTIPOINT:
+			pgGeomType = "MULTIPOINT";
+			break;
+		case Geometry.TYPES.MULTICURVE:
+			pgGeomType = "MULTILINESTRING";
+			break;
+		case Geometry.TYPES.MULTISURFACE:
+			pgGeomType = "MULTIPOLYGON";
+			break;
+		default:
+                    logger.warn("Can't determine PostGIS geometry type, use GEOMETRY.");
+                    pgGeomType = "GEOMETRY";
+		}
+		if (geometrySubType == Geometry.SUBTYPES.GEOM2DM
+				|| geometrySubType == Geometry.SUBTYPES.GEOM3DM) {
+			pgGeomType = pgGeomType + "M";
+		} /* else  if (geometrySubType == Geometry.SUBTYPES.GEOM3D) {
+			throw new UnsupportedGeometryException(geometryType,
+					geometrySubType);
+                   /
+		} */
+		return pgGeomType;
+	}
+
+	public int getProviderSRID(String srs) {
+		if (srs != null) {
+			Integer pgSRID = (Integer) srsID2pgSR.get(srs);
+			if (pgSRID != null) {
+				return pgSRID.intValue();
+			}
+
+			return searchpgSRID(srs);
+
+		}
+		return -1;
+	}
+
+
+	public int getProviderSRID(IProjection srs) {
+		if (srs != null) {
+			Integer pgSRID = (Integer) srsID2pgSR.get(srs.getAbrev());
+			if (pgSRID != null) {
+				return pgSRID.intValue();
+			}
+
+			return searchpgSRID(srs);
+
+		}
+		return -1;
+	}
+
+	private int searchpgSRID(final IProjection srs) {
+		if (srs == null) {
+			return -1;
+		}
+		return searchpgSRID(srs.getAbrev());
+	}
+
+	private int searchpgSRID(final String srsID) {
+		if (srsID == null) {
+			return -1;
+		}
+
+		ConnectionAction action = new ConnectionAction(){
+
+			public Object action(Connection conn) throws DataException {
+
+				String[] abrev = srsID.split(":");
+				StringBuilder sqlb = new StringBuilder();
+				sqlb.append("select srid from spatial_ref_sys where ");
+				if (abrev.length > 1) {
+					sqlb.append("auth_name = ? and ");
+				}
+				sqlb.append("auth_srid = ?");
+
+				String sql = sqlb.toString();
+				PreparedStatement st;
+				try {
+					st = conn.prepareStatement(sql);
+				} catch (SQLException e){
+					throw new JDBCPreparingSQLException(sql,e);
+				}
+				ResultSet rs = null;
+				try{
+					int i=0;
+					if (abrev.length > 1){
+						st.setString(i+1, abrev[i]);
+						i++;
+					}
+					st.setInt(i + 1, Integer.parseInt(abrev[i]));
+
+					try{
+						rs = JDBCHelper.executeQuery(st,sql); 
+                                                
+					} catch (SQLException e){
+						throw new JDBCExecutePreparedSQLException(sql, abrev, e);
+					}
+
+					if (!rs.next()) {
+						return null;
+					}
+
+					return new Integer(rs.getInt(1));
+
+				} catch (SQLException e){
+					throw new JDBCSQLException(e);
+				} finally{
+					try {rs.close(); } catch (Exception e) {};
+					try {st.close(); } catch (Exception e) {};
+				}
+
+			}
+
+		};
+
+		Integer pgSRSID = null;
+		try {
+			pgSRSID = (Integer) doConnectionAction(action);
+		} catch (Exception e) {
+			logger.error("Excetion searching pgSRS", e);
+			return -1;
+		}
+
+		if (pgSRSID != null) {
+			addToPgSRToSRSID(pgSRSID.intValue(), srsID);
+			return pgSRSID.intValue();
+		}
+		return -1;
+
+	}
+
+	private void addToPgSRToSRSID(int pgSRID, String srsId) {
+		if (pgSRID < 0 || srsId == null || srsId.length() == 0) {
+			return;
+		}
+		Integer pgSRIDInteger = new Integer(pgSRID);
+		pgSR2SRSID.put(pgSRIDInteger, srsId);
+		srsID2pgSR.put(srsId, pgSRIDInteger);
+	}
+
+        public List<String> getSqlGeometyFieldAdd(FeatureAttributeDescriptor attr,
+                String table, String schema) {
+                    // SELECT AddGeometryColumn({schema}, {table}, {field}, {srid}(int),
+            // {geomType}(Str), {dimensions}(int))
+
+                    // gemoType:
+                    /*
+             * POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING,
+             * MULTIPOLYGON, GEOMETRYCOLLECTION POINTM, LINESTRINGM, POLYGONM,
+             * MULTIPOINTM, MULTILINESTRINGM, MULTIPOLYGONM, GEOMETRYCOLLECTIONM
+             */
+            List<String> sqls = new ArrayList<String>();
+
+            StringBuilder strb = new StringBuilder();
+            strb.append("SELECT AddGeometryColumn('");
+            if ( schema != null && schema.length() > 0 ) {
+                strb.append(schema);
+                strb.append("', '");
+            }
+            strb.append(table);
+            strb.append("', '");
+            strb.append(attr.getName().toLowerCase());
+            strb.append("', ");
+            strb.append(getProviderSRID(attr.getSRS()));
+            strb.append(", '");
+
+            strb.append(getPostgisGeomType(
+                    attr.getGeometryType(),
+                    attr.getGeometrySubType()
+            )
+            );
+            strb.append("', ");
+            strb.append(getPostgisGeomDimensions(attr.getGeometrySubType()));
+            strb.append(")");
+
+            sqls.add(strb.toString());
+
+            return sqls;
+        }
+
+	public String getSqlFieldName(FeatureAttributeDescriptor attribute) {
+		if (attribute.getType() == DataTypes.GEOMETRY) {
+			return getFunctionName("ST_AsBinary") + "("
+			    + super.getSqlFieldName(attribute) + ")";
+		}
+		return super.getSqlFieldName(attribute);
+	}
+
+	protected EditableFeatureAttributeDescriptor createAttributeFromJDBC(
+			EditableFeatureType type, Connection conn,
+			ResultSetMetaData rsMetadata, int colIndex) throws SQLException {
+		if (rsMetadata.getColumnType(colIndex) == java.sql.Types.OTHER) {
+			if (rsMetadata.getColumnTypeName(colIndex).equalsIgnoreCase(
+					"geometry")) {
+				EditableFeatureAttributeDescriptor attr = type.add(rsMetadata.getColumnName(colIndex),
+						DataTypes.GEOMETRY);
+				// Set default values for geometry type
+		                attr.setGeometryType(Geometry.TYPES.GEOMETRY);
+		                attr.setGeometrySubType(Geometry.SUBTYPES.GEOM2D);
+		                return attr;
+
+			}
+		}
+
+		return super.createAttributeFromJDBC(type, conn, rsMetadata, colIndex);
+	}
+
+	public List getAdditionalSqlToCreate(NewDataStoreParameters ndsp,
+			FeatureType fType) {
+		FeatureAttributeDescriptor attr;
+		Iterator iter = fType.iterator();
+		List result = new ArrayList();
+		PostgreSQLNewStoreParameters pgNdsp = (PostgreSQLNewStoreParameters) ndsp;
+		while (iter.hasNext()){
+			attr = (FeatureAttributeDescriptor) iter.next();
+			if (attr.getType() == DataTypes.GEOMETRY){
+				result.addAll(getSqlGeometyFieldAdd(attr, pgNdsp.getTable(),
+						pgNdsp
+						.getSchema()));
+			}
+                        if( attr.isIndexed() ) {
+                            result.add(getCreateIndexStatement((JDBCNewStoreParameters) ndsp, attr));
+                        }
+                        if( attr.isAutomatic() ) {
+                            // Añadimos los GRANT para la secuencia asociada a la tabla.
+                            String table = "\""+pgNdsp.getSchema() +"\".\""+pgNdsp.getTable()+"_"+attr.getName()+"_seq\" ";
+                            result.addAll(this.createGrantStatements(pgNdsp, table));
+                        }
+		}
+
+              
+		return result;
+	}
+
+        protected String getCreateIndexStatement(JDBCNewStoreParameters params,FeatureAttributeDescriptor attr ) {
+            String indexName = "idx_"+params.getTable()+"_"+attr.getName();
+            
+            String statement = "CREATE ";
+            if( !attr.allowIndexDuplicateds() ) {
+                statement += " UNIQUE ";
+            }
+            statement += "INDEX \""+indexName+"\" ";
+            statement += "ON " + params.tableID() + " ";
+            if( attr.getType()==DataTypes.GEOMETRY ) {
+                statement += " USING GIST ";
+                statement += "( \"" + attr.getName()+ "\")";
+            } else {
+                statement += "( \"" + attr.getName()+ "\"";
+                if( attr.isIndexAscending() ) {
+                    statement += " ASC )";
+                } else {
+                    statement += " DESC )";
+                }
+            }
+            return statement;
+        }
+        
+	public String getSqlFieldDescription(FeatureAttributeDescriptor attr)
+			throws DataException {
+		if (attr.getType() == DataTypes.GEOMETRY){
+			return null;
+		}
+		return super.getSqlFieldDescription(attr);
+	}
+
+
+	public boolean allowAutomaticValues() {
+		return Boolean.TRUE;
+	}
+
+	public boolean supportOffset() {
+		return true;
+	}
+
+	public boolean supportsUnion() {
+		return true;
+	}
+	
+	public String escapeFieldName(String field) {
+		/*
+		if (!reservedWord(field) && 
+				field.matches("[a-z][a-z0-9_]*")) {
+			return field;
+		}
+		*/
+		String quote = getIdentifierQuoteString();
+		return quote + field + quote;
+	}
+	
+    protected EditableFeatureAttributeDescriptor createAttributeFromJDBCNativeType(
+        EditableFeatureType fType, ResultSetMetaData rsMetadata, int colIndex)
+        throws SQLException {
+
+        EditableFeatureAttributeDescriptor column;
+
+        String nativeType = rsMetadata.getColumnTypeName(colIndex);
+
+        if (nativeType.startsWith("int")) {
+            column = fType.add(rsMetadata.getColumnName(colIndex),
+                DataTypes.INT);
+            column.setAdditionalInfo("SQLType", new Integer(rsMetadata
+                .getColumnType(colIndex)));
+            column.setAdditionalInfo("SQLTypeName", rsMetadata
+                .getColumnTypeName(colIndex));
+            return column;
+        }
+        return super.createAttributeFromJDBCNativeType(fType, rsMetadata, colIndex);
+    }
+
+    public Object dalValueToJDBC(
+        FeatureAttributeDescriptor attributeDescriptor, Object object)
+        throws WriteException {
+           if ("int2".equals(attributeDescriptor.getAdditionalInfo("SQLTypeName"))) {
+                return new Short(String.valueOf(object));
+            }
+
+        return super.dalValueToJDBC(attributeDescriptor, object);
+    }
+    
+    // =======================================
+    
+
+    public String getFunctionName(String newFuncName) {
+        
+        if (!versionSet) {
+            postGISVersion = getPostgisVersion();
+            versionSet = true;
+        }
+        return getFunctionNameForVersion(newFuncName, postGISVersion);
+    }
+
+    private String getFunctionNameForVersion(String newFuncName, int[] pv) {
+        
+        if (newFuncName == null || pv == null) {
+            return newFuncName;
+        }
+        
+        if (pv.length < 2) {
+            // cannot compare
+            return newFuncName;
+        }
+        
+        if (pv[0] > 1) {
+            return newFuncName;
+        }
+        
+        if (pv[0] == 1 && pv[1] >= 3) {
+            return newFuncName;
+        }
+        
+        Properties pp = this.getBeforePostgis13Properties();
+        String k = newFuncName.toLowerCase();
+        String v = pp.getProperty(k);
+        if (v == null) {
+            return newFuncName;
+        } else {
+            return v;
+        }
+    }
+
+
+    private int[] getPostgisVersion() {
+
+        String sql = "SELECT PostGIS_Lib_Version()";
+        ResultSet rs = null;
+        Statement st = null;
+        String v = null;
+        Connection conn = null;
+        try {
+            conn = this.getConnection();
+            st = conn.createStatement();
+            rs = JDBCHelper.executeQuery(st,sql); 
+            rs.next();
+            v = rs.getString(1);
+            if (v == null) {
+                throw new Exception("Returned version is NULL");
+            }
+        } catch (Exception exc) {
+            logger.error("Unable to get Postgis version: " + exc.getMessage(), exc);
+            return null;
+        } finally {
+            try { rs.close(); } catch (Exception e) {};
+            try { st.close(); } catch (Exception e) {};
+            try { conn.close(); } catch (Exception e) {};
+        }
+
+        String[] vv = v.split("\\.");
+        int[] resp = new int[3];
+        try {
+            for (int i=0; i<3; i++) {
+                resp[i] = Integer.parseInt(vv[i]);
+            }
+        } catch (Exception exc) {
+            logger.error("Unable to parse version: " + v, exc);
+            return null;
+        }
+        return resp;
+    }
+    
+    
+    
+    protected Properties getBeforePostgis13Properties() {
+        if (beforePostgis13 == null) {
+            
+            beforePostgis13 = new Properties();
+            // Left side MUST be in lower case
+            // Right side will be used if Postgis version < 1.3
+            beforePostgis13.setProperty("st_intersects", "Intersects");
+            beforePostgis13.setProperty("st_extent", "Extent");
+            beforePostgis13.setProperty("st_envelope", "Envelope");
+            beforePostgis13.setProperty("st_asbinary", "AsBinary");
+            beforePostgis13.setProperty("st_geomfromtext", "GeomFromText");
+            beforePostgis13.setProperty("st_geomfromwkb", "GeomFromWKB");
+        }
+        return beforePostgis13;
+    }
+    
+
+
+}
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLStoreParameters.java
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLStoreParameters.java	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLStoreParameters.java	(revision 121)
@@ -0,0 +1,74 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+*
+* Copyright (C) 2007-2008 Infrastructures and Transports Department
+* of the Valencian Government (CIT)
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+* MA  02110-1301, USA.
+*
+*/
+
+/*
+* AUTHORS (In addition to CIT):
+* 2009 IVER T.I   {{Task}}
+*/
+
+package org.gvsig.fmap.dal.store.postgresql;
+
+import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
+import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters;
+
+public class PostgreSQLStoreParameters extends JDBCStoreParameters implements
+		PostgreSQLConnectionParameters {
+    public static final String PARAMETERS_DEFINITION_NAME = "PostgreSQLStoreParameters";
+
+
+	public PostgreSQLStoreParameters() {
+		super(PARAMETERS_DEFINITION_NAME, PostgreSQLStoreProvider.NAME);
+	}
+
+	public PostgreSQLStoreParameters(String parametersDefinitionName) {
+		super(parametersDefinitionName, PostgreSQLStoreProvider.NAME);
+	}
+
+	public Boolean getUseSSL() {
+		return (Boolean) this.getDynValue(DYNFIELDNAME_USESSL);
+	}
+
+	public void setUseSSL(Boolean useSSL) {
+		this.setDynValue(DYNFIELDNAME_USESSL, useSSL);
+	}
+
+	public void setUseSSL(boolean useSSL) {
+		this.setDynValue(DYNFIELDNAME_USESSL, new Boolean(useSSL));
+	}
+
+
+	public void validate() throws ValidateDataParametersException {
+		if (getJDBCDriverClassName() == null) {
+			setJDBCDriverClassName(PostgreSQLLibrary.DEFAULT_JDCB_DRIVER_NAME);
+		}
+		if (getUrl() == null) {
+			setUrl(PostgreSQLLibrary.getJdbcUrl(getHost(), getPort(),
+					getDBName()));
+		}
+
+		if (getPort() == null) {
+			setPort(new Integer(5432));
+		}
+		super.validate();
+	}
+
+}
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/resources/META-INF/services/org.gvsig.tools.library.Library	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/resources/META-INF/services/org.gvsig.tools.library.Library	(revision 121)
@@ -0,0 +1 @@
+org.gvsig.fmap.dal.store.postgresql.PostgreSQLLibrary
\ No newline at end of file
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/resources/org/gvsig/fmap/dal/store/postgresql/PostgreSQLMetadata.xml
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/resources/org/gvsig/fmap/dal/store/postgresql/PostgreSQLMetadata.xml	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/resources/org/gvsig/fmap/dal/store/postgresql/PostgreSQLMetadata.xml	(revision 121)
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<definitions>
+  <version>1.0.0</version>
+  <classes>
+    <class name="PostgreSQL" namespace="Metadata">
+      <extends>
+      	<class name="JDBC" namespace="Metadata"/>
+      </extends>
+      <description>Metadata of a PostgreSQL store</description>
+      <fields>
+      </fields>
+    </class>
+
+  </classes>
+</definitions>  
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/resources/org/gvsig/fmap/dal/store/postgresql/PostgreSQLParameters.xml
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/resources/org/gvsig/fmap/dal/store/postgresql/PostgreSQLParameters.xml	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/main/resources/org/gvsig/fmap/dal/store/postgresql/PostgreSQLParameters.xml	(revision 121)
@@ -0,0 +1,52 @@
+<?xml version="1.0"?>
+<definitions>
+  <version>1.0.0</version>
+  <classes>
+    <class name="PostgreSQLResourceParameters">
+      <extends>
+        <class>JDBCResourceParameters</class>
+      </extends>
+      <fields>
+        <field name="JDBCDriverClass" type="string" mandatory="true"
+          defaultValue="org.postgresql.Driver" group="Advanced">
+          <description>JDBC Driver class</description>
+        </field>
+		<field name="port" type="integer" mandatory="false"
+          defaultValue="5432" group="Connection">
+          <description></description>
+        </field>
+        <field name="UseSSL" type="boolean" mandatory="false"
+          defaultValue="false" group="Basic">
+          <description>Use SSL connetion</description>
+        </field>
+      </fields>
+    </class>
+
+    <class name="PostgreSQLStoreParameters">
+      <extends>
+        <class>JDBCStoreParameters</class>
+        <class>PostgreSQLResourceParameters</class>
+      </extends>
+      <fields/>
+    </class>
+
+    <class name="PostgreSQLNewStoreParameters">
+      <extends>
+        <class>JDBCNewStoreParameters</class>
+        <class>PostgreSQLResourceParameters</class>
+      </extends>
+      <fields/>
+    </class>
+
+
+    <class name="PostgreSQLServerExplorerParameters">
+      <extends>
+        <class>PostgreSQLResourceParameters</class>
+        <class>JDBCServerExplorerParameters</class>
+      </extends>
+      <fields/>
+    </class>
+
+
+  </classes>
+</definitions>  
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/test/java/org/gvsig/fmap/dal/store/postgresql/TestPostgreSQLWrite.java
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/test/java/org/gvsig/fmap/dal/store/postgresql/TestPostgreSQLWrite.java	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/test/java/org/gvsig/fmap/dal/store/postgresql/TestPostgreSQLWrite.java	(revision 121)
@@ -0,0 +1,240 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+*
+* Copyright (C) 2007-2008 Infrastructures and Transports Department
+* of the Valencian Government (CIT)
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+* MA  02110-1301, USA.
+*
+*/
+
+/*
+* AUTHORS (In addition to CIT):
+* 2009 IVER T.I   {{Task}}
+*/
+
+/**
+ *
+ */
+package org.gvsig.fmap.dal.store.postgresql;
+
+import java.util.Iterator;
+
+import org.gvsig.fmap.dal.DataStoreParameters;
+import org.gvsig.fmap.dal.exception.DataException;
+import org.gvsig.fmap.dal.feature.BaseTestEditableFeatureStore;
+import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
+import org.gvsig.fmap.dal.feature.EditableFeatureType;
+import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
+import org.gvsig.fmap.dal.feature.FeatureQuery;
+import org.gvsig.fmap.dal.feature.FeatureStore;
+import org.gvsig.fmap.dal.feature.FeatureStoreTransform;
+import org.gvsig.fmap.dal.feature.FeatureType;
+import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters;
+import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorer;
+import org.gvsig.fmap.geom.Geometry;
+import org.gvsig.fmap.geom.operation.towkt.ToWKT;
+import org.gvsig.tools.evaluator.Evaluator;
+import org.gvsig.tools.evaluator.EvaluatorData;
+import org.gvsig.tools.evaluator.EvaluatorException;
+import org.gvsig.tools.evaluator.EvaluatorFieldsInfo;
+
+
+
+/**
+ * @author jmvivo
+ *
+ */
+// public class TestPostgreSQL extends BaseTestEditableFeatureStore {
+public class TestPostgreSQLWrite extends BaseTestEditableFeatureStore {
+
+
+	private JDBCServerExplorer myExplorer;
+	private PostgreSQLNewStoreParameters newParams;
+
+	@Override
+	protected void doSetUp() throws Exception {
+		// Initialize wkt geom operation
+		int wktCode = ToWKT.CODE;
+	}
+
+	public DataStoreParameters getDefaultDataStoreParameters()
+			throws DataException {
+		PostgreSQLStoreParameters pgParameters = null;
+		pgParameters = (PostgreSQLStoreParameters) dataManager
+				.createStoreParameters(PostgreSQLStoreProvider.NAME);
+
+		pgParameters.setHost("localhost");
+		pgParameters.setUser("postgres");
+		pgParameters.setPassword("postgres");
+		pgParameters.setDBName("gis");
+		pgParameters.setTable("muni10000_peq");
+
+		return pgParameters;
+	}
+
+	public boolean hasExplorer() {
+		return true;
+	}
+
+	public void testLoadMetadata() throws Exception {
+		DataStoreParameters params = this.getDefaultDataStoreParameters();
+
+		FeatureStore store = null;
+		store = (FeatureStore) dataManager.createStore(params);
+		FeatureType fType = store.getDefaultFeatureType();
+		FeatureAttributeDescriptor geomAttr;
+
+
+
+		if (fType.getDefaultGeometryAttributeIndex() >= 0) {
+			assertNotNull(store.getEnvelope());
+			geomAttr = fType.getAttributeDescriptor(fType
+					.getDefaultGeometryAttributeIndex());
+			assertTrue(geomAttr.getGeometryType() == Geometry.TYPES.MULTISURFACE);
+			assertTrue(geomAttr.getGeometrySubType() == Geometry.SUBTYPES.GEOM2D);
+			assertNotNull(store.getDynValue("CRS"));
+
+		}
+
+	}
+
+	public void testCloserConnection() throws Exception {
+
+		DataStoreParameters params = this.getDefaultDataStoreParameters();
+
+		FeatureStore store = null;
+		store = (FeatureStore) dataManager.createStore(params);
+
+		FeatureQuery query = store.createFeatureQuery();
+
+		query.getOrder().add("gid", true);
+
+		query.setFilter(new Evaluator() {
+
+			public Object evaluate(EvaluatorData data)
+					throws EvaluatorException {
+				// TODO Auto-generated method stub
+				return Boolean.TRUE;
+			}
+
+			public String getSQL() {
+				return "true = true";
+			}
+
+			public String getDescription() {
+				// TODO Auto-generated method stub
+				return null;
+			}
+
+			public String getName() {
+				return "AlwaysTrue";
+			}
+
+			public EvaluatorFieldsInfo getFieldsInfo() {
+				// TODO Auto-generated method stub
+				return null;
+			}
+
+		});
+
+		FeatureStoreTransform transform = new StringsToLowerTransform();
+		transform.setFeatureStore(store);
+
+		store.getTransforms().add(transform);
+
+		transform = new StringsToLowerTransform();
+		transform.setFeatureStore(store);
+
+		store.getTransforms().add(transform);
+
+		transform = new StringsToLowerTransform();
+		transform.setFeatureStore(store);
+
+		store.getTransforms().add(transform);
+
+		for (int i = 0; i < 30; i++) {
+			// this.fullStoreIteratorTest(store);
+
+			this.testIterationFastAndStandart(store, query);
+		}
+
+
+		store.dispose();
+
+	}
+
+	public boolean usesResources() {
+		return true;
+	}
+
+	public NewFeatureStoreParameters getDefaultNewDataStoreParameters()
+			throws Exception {
+		PostgreSQLStoreParameters parameters = (PostgreSQLStoreParameters) this
+				.getDefaultDataStoreParameters();
+
+		FeatureStore store = null;
+
+		if (this.myExplorer == null) {
+			store = (FeatureStore) dataManager.createStore(parameters);
+			myExplorer = (JDBCServerExplorer) store.getExplorer();
+		}
+		if (this.newParams == null) {
+			if (store == null){
+				store = (FeatureStore) dataManager.createStore(parameters);
+			}
+
+			newParams = (PostgreSQLNewStoreParameters) myExplorer
+					.getAddParameters();
+
+			newParams.setTable(parameters.getTable() + "_test");
+			FeatureType ftOrg = store.getDefaultFeatureType();
+			EditableFeatureType ftTrg = (EditableFeatureType) newParams
+					.getDefaultFeatureType();
+			FeatureAttributeDescriptor org;
+			EditableFeatureAttributeDescriptor trg;
+			Iterator iter = ftOrg.iterator();
+			while (iter.hasNext()) {
+				org = (FeatureAttributeDescriptor) iter.next();
+				trg = ftTrg.add(org.getName(), org.getType());
+				trg.setAllowNull(org.allowNull());
+				trg.setDefaultValue(org.getDefaultValue());
+				trg.setGeometrySubType(org.getGeometrySubType());
+				trg.setGeometryType(org.getGeometryType());
+				trg.setIsAutomatic(org.isAutomatic());
+				trg.setIsPrimaryKey(org.isPrimaryKey());
+				trg.setIsReadOnly(org.isReadOnly());
+				trg.setMaximumOccurrences(org.getMaximumOccurrences());
+				trg.setMinimumOccurrences(org.getMinimumOccurrences());
+				trg.setPrecision(org.getPrecision());
+				trg.setSize(org.getSize());
+				trg.setSRS(org.getSRS());
+			}
+			ftTrg.setDefaultGeometryAttributeName(ftOrg
+					.getDefaultGeometryAttributeName());
+			ftTrg.setHasOID(ftOrg.hasOID());
+
+		}
+		if (store != null){
+			store.dispose();
+		}
+
+		return this.newParams;
+	}
+
+	public boolean resourcesNotifyChanges() {
+		return false;
+	}
+}
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/test/java/org/gvsig/fmap/dal/store/postgresql/TestReadAndWriteGeom.java
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/test/java/org/gvsig/fmap/dal/store/postgresql/TestReadAndWriteGeom.java	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/test/java/org/gvsig/fmap/dal/store/postgresql/TestReadAndWriteGeom.java	(revision 121)
@@ -0,0 +1,280 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+*
+* Copyright (C) 2007-2008 Infrastructures and Transports Department
+* of the Valencian Government (CIT)
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+* MA  02110-1301, USA.
+*
+*/
+
+
+
+package org.gvsig.fmap.dal.store.postgresql;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.text.MessageFormat;
+
+import org.gvsig.fmap.geom.Geometry;
+import org.gvsig.fmap.geom.GeometryLocator;
+import org.gvsig.fmap.geom.GeometryManager;
+import org.gvsig.fmap.geom.operation.fromwkb.FromWKB;
+import org.gvsig.fmap.geom.operation.fromwkb.FromWKBGeometryOperationContext;
+import org.gvsig.fmap.geom.operation.towkb.ToWKB;
+import org.gvsig.fmap.geom.operation.towkt.ToWKT;
+import org.gvsig.fmap.geom.primitive.Point;
+import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
+
+public class TestReadAndWriteGeom extends AbstractLibraryAutoInitTestCase {
+	private static final int FEATURES_TO_INSERT = 12000;
+	private static final String TABLE_NAME_INSERT = "testReadadnwritegeom_testcase";
+	private static final String FIELD_NAME_INSERT = "geom";
+	private Connection conn;
+	private GeometryManager geoManager;
+	private static String SQL_FOR_READ_TEST = "Select {0} from medio_ejes";
+
+	@Override
+	protected void doSetUp() throws Exception {
+		geoManager = GeometryLocator.getGeometryManager();
+
+		Class klass = Class.forName(PostgreSQLLibrary.DEFAULT_JDCB_DRIVER_NAME);
+		if (klass == null) {
+			throw new Exception("Driver not found: "
+					+ PostgreSQLLibrary.DEFAULT_JDCB_DRIVER_NAME);
+		}
+
+		// inicializamos operaciones de geometrias de las que dependemos
+		int code = FromWKB.CODE;
+		code = ToWKB.CODE;
+		code = ToWKT.CODE;
+		conn = DriverManager.getConnection(PostgreSQLLibrary.getJdbcUrl(
+				"localhost", 5432, "gis"), "postgres", "postgres");
+	}
+
+	public void testInsertWKB() throws Exception {
+		PreparedStatement pst = null;
+		try {
+			crearTablaTest();
+			Point geom = geoManager.createPoint(0, 0,
+					Geometry.SUBTYPES.GEOM2D);
+			pst = conn.prepareStatement(
+					"Insert into "
+					+ TABLE_NAME_INSERT.toLowerCase() +
+					"  ("
+					+ FIELD_NAME_INSERT + ") Values (GeomFromWKB(?))");
+
+
+			int i;
+			for (i = 1; i <= FEATURES_TO_INSERT; i++) {
+				pst.clearParameters();
+				geom.setX(i);
+				geom.setY(i);
+				pst.setBytes(1,
+					(byte[]) geom.invokeOperation(
+							ToWKB.CODE,
+							null)
+					);
+
+				pst.executeUpdate();
+			}
+
+			System.out
+					.println("TestReadAndWriteGeom.testInsertPostgis() Inserteds= i");
+
+
+
+
+		} finally {
+			if (pst != null) {
+				try {pst.close();} catch (SQLException e) {e.printStackTrace();}
+			}
+
+		}
+
+
+	}
+
+	private void crearTablaTest() throws SQLException {
+		execute("DROP TABLE IF EXISTS " + TABLE_NAME_INSERT.toLowerCase());
+		execute("Delete from geometry_columns  where  f_table_name = '"
+				+ TABLE_NAME_INSERT.toLowerCase() + "'");
+		execute("CREATE TABLE " + TABLE_NAME_INSERT.toLowerCase()
+				+ " (id serial PRIMARY KEY)");
+		execute("Select AddGeometryColumn('" + TABLE_NAME_INSERT.toLowerCase()
+				+ "','"
+				+ FIELD_NAME_INSERT + "',-1,'GEOMETRY',2)");
+	}
+
+	private void execute(String sql) throws SQLException {
+		Statement st = null;
+		try {
+			st = conn.createStatement();
+			st.execute(sql);
+		} finally {
+			if (st != null) {
+				try {st.close();} catch (SQLException e) {e.printStackTrace();}
+			}
+		}
+
+	}
+
+	public String getSQLForRead(String geoColumn) {
+		return MessageFormat.format(SQL_FOR_READ_TEST, geoColumn);
+
+	}
+
+	public void testReadBinary() throws Exception {
+		// st.execute("declare " + getTableName() + myCursorId +
+		// "_wkb_cursor binary scroll cursor with hold for " + sqlAux);
+		// rs = st.executeQuery("fetch forward " + FETCH_SIZE+ " in " +
+		// getTableName() + myCursorId + "_wkb_cursor");
+
+		Statement st = null;
+		ResultSet rs = null;
+		long count = 0;
+		Geometry geom;
+
+		try {
+			st = conn.createStatement();
+			String cursorName = "myCursor___xxx";
+			st.execute("declare " + cursorName
+					+ "_wkb_cursor binary scroll cursor with hold for "
+					+ getSQLForRead("the_geom"));
+			rs = st.executeQuery("fetch forward all in " + cursorName
+					+ "_wkb_cursor");
+			byte[] buff;
+			FromWKBGeometryOperationContext opContext = new FromWKBGeometryOperationContext();
+			while (rs.next()) {
+				count++;
+				buff = rs.getBytes(1);
+			}
+
+			System.out
+					.println("TestReadAndWriteGeom.testReadPostgis() Count = "
+							+ count);
+
+		} finally {
+			if (st != null) {
+				try {
+					st.close();
+				} catch (SQLException e) {
+					e.printStackTrace();
+				}
+			}
+			if (rs != null) {
+				try {
+					rs.close();
+				} catch (SQLException e) {
+					e.printStackTrace();
+				}
+			}
+		}
+
+	}
+
+	public void testReadWKB() throws Exception {
+		Statement st = null;
+		ResultSet rs = null;
+		long count = 0;
+		Geometry geom;
+
+		byte[] buff;
+		FromWKBGeometryOperationContext opContext = new FromWKBGeometryOperationContext();
+		try {
+			st = conn.createStatement();
+			rs = st.executeQuery(getSQLForRead("asBinary(the_geom)"));
+			while (rs.next()) {
+				count++;
+				buff = rs.getBytes(1);
+			}
+
+			System.out
+					.println("TestReadAndWriteGeom.testReadPostgis() Count = "
+							+ count);
+
+
+		} finally {
+			if (st != null) {
+				try {
+					st.close();
+				} catch (SQLException e) {
+					e.printStackTrace();
+				}
+			}
+			if (rs != null) {
+				try {
+					rs.close();
+				} catch (SQLException e) {
+					e.printStackTrace();
+				}
+			}
+		}
+	}
+
+//	public void testReadPostgis() throws Exception {
+//		Statement st = null;
+//		ResultSet rs = null;
+//		long count = 0;
+//		Geometry geom;
+//		PGgeometry pgGeom;
+//		PostGIS2Geometry converter = new PostGIS2Geometry();
+//		try {
+//			st = conn.createStatement();
+//			rs = st.executeQuery(getSQLForRead("the_geom"));
+//			while (rs.next()) {
+//				count++;
+//				pgGeom = (PGgeometry) rs.getObject(1);
+//				if (pgGeom != null) {
+//					geom = converter.getGeometry(pgGeom);
+//					assertNotNull(geom);
+//				}
+//			}
+//
+//
+//			System.out
+//					.println("TestReadAndWriteGeom.testReadPostgis() Count = "
+//							+ count);
+//
+//
+//		} finally {
+//			if (st != null) {
+//				try {
+//					st.close();
+//				} catch (SQLException e) {
+//					e.printStackTrace();
+//				}
+//			}
+//			if (rs != null) {
+//				try {
+//					rs.close();
+//				} catch (SQLException e) {
+//					e.printStackTrace();
+//				}
+//			}
+//		}
+//	}
+
+
+	protected void tearDown() throws Exception {
+		super.tearDown();
+		conn.close();
+	}
+
+}
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/test/java/org/gvsig/fmap/dal/store/postgresql/TestPostgreSQL.java
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/test/java/org/gvsig/fmap/dal/store/postgresql/TestPostgreSQL.java	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/test/java/org/gvsig/fmap/dal/store/postgresql/TestPostgreSQL.java	(revision 121)
@@ -0,0 +1,175 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+*
+* Copyright (C) 2007-2008 Infrastructures and Transports Department
+* of the Valencian Government (CIT)
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+* MA  02110-1301, USA.
+*
+*/
+
+/*
+* AUTHORS (In addition to CIT):
+* 2009 IVER T.I   {{Task}}
+*/
+
+/**
+ *
+ */
+package org.gvsig.fmap.dal.store.postgresql;
+
+import org.gvsig.fmap.dal.DataStoreParameters;
+import org.gvsig.fmap.dal.exception.DataException;
+import org.gvsig.fmap.dal.feature.BaseTestFeatureStore;
+import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
+import org.gvsig.fmap.dal.feature.FeatureQuery;
+import org.gvsig.fmap.dal.feature.FeatureStore;
+import org.gvsig.fmap.dal.feature.FeatureStoreTransform;
+import org.gvsig.fmap.dal.feature.FeatureType;
+import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters;
+import org.gvsig.fmap.geom.Geometry;
+import org.gvsig.tools.evaluator.Evaluator;
+import org.gvsig.tools.evaluator.EvaluatorData;
+import org.gvsig.tools.evaluator.EvaluatorException;
+import org.gvsig.tools.evaluator.EvaluatorFieldsInfo;
+
+/**
+ * @author jmvivo
+ *
+ */
+// public class TestPostgreSQL extends BaseTestEditableFeatureStore {
+public class TestPostgreSQL extends BaseTestFeatureStore {
+
+	@Override
+	protected void doSetUp() throws Exception {
+		super.doSetUp();
+	}
+
+	public DataStoreParameters getDefaultDataStoreParameters()
+			throws DataException {
+		PostgreSQLStoreParameters pgParameters = null;
+		pgParameters = (PostgreSQLStoreParameters) dataManager
+				.createStoreParameters(PostgreSQLStoreProvider.NAME);
+
+		pgParameters.setHost("localhost");
+		pgParameters.setUser("postgres");
+		pgParameters.setPassword("postgres");
+		pgParameters.setDBName("gis");
+		pgParameters.setTable("muni10000_peq");
+
+		return pgParameters;
+	}
+
+	public boolean hasExplorer() {
+		return true;
+	}
+
+	public void testLoadMetadata() throws Exception {
+		DataStoreParameters params = this.getDefaultDataStoreParameters();
+
+		FeatureStore store = null;
+		store = (FeatureStore) dataManager.createStore(params);
+		FeatureType fType = store.getDefaultFeatureType();
+		FeatureAttributeDescriptor geomAttr;
+
+
+
+		if (fType.getDefaultGeometryAttributeIndex() >= 0) {
+			assertNotNull(store.getEnvelope());
+			geomAttr = fType.getAttributeDescriptor(fType
+					.getDefaultGeometryAttributeIndex());
+			assertTrue(geomAttr.getGeometryType() == Geometry.TYPES.MULTISURFACE);
+			assertTrue(geomAttr.getGeometrySubType() == Geometry.SUBTYPES.GEOM2D);
+			assertNotNull(store.getDynValue("CRS"));
+
+		}
+
+	}
+
+	public void testCloserConnection() throws Exception {
+
+		DataStoreParameters params = this.getDefaultDataStoreParameters();
+
+		FeatureStore store = null;
+		store = (FeatureStore) dataManager.createStore(params);
+
+		FeatureQuery query = store.createFeatureQuery();
+
+		query.getOrder().add("gid", true);
+
+		query.setFilter(new Evaluator() {
+
+			public Object evaluate(EvaluatorData data)
+					throws EvaluatorException {
+				// TODO Auto-generated method stub
+				return Boolean.TRUE;
+			}
+
+			public String getSQL() {
+				return "true = true";
+			}
+
+			public String getDescription() {
+				// TODO Auto-generated method stub
+				return null;
+			}
+
+			public String getName() {
+				return "AlwaysTrue";
+			}
+
+			public EvaluatorFieldsInfo getFieldsInfo() {
+				// TODO Auto-generated method stub
+				return null;
+			}
+
+		});
+
+		FeatureStoreTransform transform = new StringsToLowerTransform();
+		transform.setFeatureStore(store);
+
+		store.getTransforms().add(transform);
+
+		transform = new StringsToLowerTransform();
+		transform.setFeatureStore(store);
+
+		store.getTransforms().add(transform);
+
+		transform = new StringsToLowerTransform();
+		transform.setFeatureStore(store);
+
+		store.getTransforms().add(transform);
+
+		for (int i = 0; i < 30; i++) {
+			// this.fullStoreIteratorTest(store);
+
+			this.testIterationFastAndStandart(store, query);
+		}
+
+
+		store.dispose();
+
+	}
+
+	public boolean usesResources() {
+		return true;
+	}
+
+	public NewFeatureStoreParameters getDefaultNewDataStoreParameters()
+			throws Exception {
+		// TODO Auto-generated method stub
+		return null;
+	}
+}
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/test/java/org/gvsig/fmap/dal/store/postgresql/DatabaseMetadataChecks.java
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/test/java/org/gvsig/fmap/dal/store/postgresql/DatabaseMetadataChecks.java	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/src/test/java/org/gvsig/fmap/dal/store/postgresql/DatabaseMetadataChecks.java	(revision 121)
@@ -0,0 +1,97 @@
+/**
+ * 
+ */
+package org.gvsig.fmap.dal.store.postgresql;
+
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+
+/**
+ * @author cordin
+ * 
+ */
+public class DatabaseMetadataChecks {
+
+	// Columns as specified by the DatabaseMetadata.getTables javadoc
+	private static final String[] COLUMNS = new String[] {
+	// Metadata resultset column names
+			"TABLE_CAT", // String => table catalog (may be null)
+			"TABLE_SCHEM", // String => table schema (may be null)
+			"TABLE_NAME", // String => table name
+			"TABLE_TYPE", // String => table type. Typical types are "TABLE",
+						// "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY",
+						// "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
+			"REMARKS", // String => explanatory comment on the table
+			"TYPE_CAT", // String => the types catalog (may be null)
+			"TYPE_SCHEM", // String => the types schema (may be null)
+			"TYPE_NAME", // String => type name (may be null)
+			"SELF_REFERENCING_COL_NAME", // String => name of the designated
+										// "identifier" column of a typed
+										// table (may be null)
+			"REF_GENERATION", // String => specifies how values in
+							// SELF_REFERENCING_COL_NAME are created. Values
+							// are "SYSTEM", "USER", "DERIVED". (may be
+							// null)
+	};
+
+	public void showTables() throws Exception {
+
+		Connection conn = DriverManager.getConnection(
+				"jdbc:postgresql://localhost/gvsigDB", "gvsig", "gvsig");
+
+		try {
+			// Statement st = conn.createStatement();
+			// String sql = "select tablename from pg_tables";
+			// ResultSet result = st.executeQuery(sql);
+
+			DatabaseMetaData metadata = conn.getMetaData();
+			ResultSet result = metadata.getTables(null, null, null,
+					new String[] { "TABLE", "VIEW" });
+			ResultSetMetaData resultMD = result.getMetaData();
+			String[] columns = new String[resultMD.getColumnCount()];
+			for (int i = 0; i < columns.length; i++) {
+				columns[i] = resultMD.getColumnName(i + 1);
+			}
+
+			for (int i = 0; i < columns.length; i++) {
+				System.out.print(columns[i]);
+				System.out.print(";");
+			}
+			System.out.println();
+			while (result.next()) {
+				
+				for (int i = 0; i < columns.length; i++) {
+					System.out.print(result.getString(columns[i]));
+					System.out.print(";");
+				}
+				System.out.println();
+			}
+
+		} finally {
+			try {
+				conn.close();
+			} catch (SQLException e) {
+				e.printStackTrace();
+			}
+		}
+
+	}
+
+	/**
+	 * @param args
+	 */
+	public static void main(String[] args) {
+		try {
+			new DatabaseMetadataChecks().showTables();
+		} catch (Exception e) {
+			e.printStackTrace();
+			System.exit(-1);
+		}
+		System.exit(0);
+	}
+
+}
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/pom.xml
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/pom.xml	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider/pom.xml	(revision 121)
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>org.gvsig.postgresql.provider</artifactId>
+  <packaging>jar</packaging>
+  <name>${project.artifactId}</name>
+  <description>DAL provider for PostgeSQL files</description>
+  <parent>
+      <groupId>org.gvsig</groupId>
+      <artifactId>org.gvsig.postgresql</artifactId>
+      <version>2.0.29</version>
+  </parent>
+
+  <dependencies>
+    <dependency>
+        <groupId>com.googlecode.log4jdbc</groupId>
+        <artifactId>log4jdbc</artifactId>
+        <scope>compile</scope>
+    </dependency>
+    <dependency>
+        <groupId>org.gvsig</groupId>
+        <artifactId>org.gvsig.tools.lib</artifactId>
+        <scope>compile</scope>
+    </dependency>
+    <dependency>
+        <groupId>org.gvsig</groupId>
+        <artifactId>org.gvsig.projection.api</artifactId>
+        <scope>compile</scope>
+    </dependency>
+    <dependency>
+        <groupId>org.gvsig</groupId>
+        <artifactId>org.gvsig.fmap.dal.api</artifactId>
+        <scope>compile</scope>
+    </dependency>
+    
+    <dependency>
+        <groupId>org.gvsig</groupId>
+        <artifactId>org.gvsig.fmap.dal.db.jdbc</artifactId>
+        <scope>compile</scope>
+    </dependency>
+
+    <dependency>
+        <groupId>org.gvsig</groupId>
+        <artifactId>org.gvsig.fmap.dal.db.lib</artifactId>
+        <scope>compile</scope>
+    </dependency>
+    
+    <dependency>
+        <groupId>org.gvsig</groupId>
+        <artifactId>org.gvsig.fmap.dal.spi</artifactId>
+        <scope>compile</scope>
+    </dependency>
+    <dependency>
+        <groupId>org.gvsig</groupId>
+        <artifactId>org.gvsig.metadata.lib.basic.api</artifactId>
+        <scope>compile</scope>
+    </dependency>
+    <dependency>
+        <groupId>org.gvsig</groupId>
+        <artifactId>org.gvsig.fmap.geometry.api</artifactId>
+        <scope>compile</scope>
+    </dependency>
+    
+    <dependency>
+        <groupId>org.gvsig</groupId>
+        <artifactId>org.gvsig.fmap.geometry.operation</artifactId>
+        <scope>compile</scope>
+    </dependency>
+    
+    <dependency>
+        <groupId>org.gvsig</groupId>
+        <artifactId>org.gvsig.timesupport.lib.api</artifactId>
+        <scope>compile</scope>
+    </dependency>  
+    <dependency>
+      <groupId>org.gvsig</groupId>
+      <artifactId>org.gvsig.utils</artifactId>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>postgresql</groupId>
+      <artifactId>postgresql</artifactId>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>commons-dbcp</groupId>
+      <artifactId>commons-dbcp</artifactId>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>commons-collections</groupId>
+      <artifactId>commons-collections</artifactId>
+      <scope>compile</scope>
+    </dependency>
+
+
+    <!-- TESTS -->
+    <dependency>
+      <groupId>org.gvsig</groupId>
+      <artifactId>org.gvsig.tools.lib</artifactId>
+      <type>test-jar</type>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.gvsig</groupId>
+      <artifactId>org.gvsig.compat.se</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.gvsig</groupId>
+      <artifactId>org.gvsig.fmap.dal.impl</artifactId>
+      <type>test-jar</type>
+      <scope>test</scope>
+    </dependency>
+    
+    <!--
+    <dependency>
+      <groupId>org.gvsig</groupId>
+      <artifactId>org.gvsig.fmap.dal.index.spatial.jts</artifactId>
+      <scope>test</scope>
+    </dependency>
+    -->
+    
+    <dependency>
+      <groupId>org.gvsig</groupId>
+      <artifactId>org.gvsig.fmap.geometry.generalpath</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.gvsig</groupId>
+      <artifactId>org.gvsig.projection.cresques.impl</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.gvsig</groupId>
+      <artifactId>org.gvsig.timesupport.lib.impl</artifactId>
+      <scope>test</scope>
+    </dependency>   
+
+
+  </dependencies>
+
+</project>

Property changes on: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.provider
___________________________________________________________________
Added: svn:ignore
   + target


Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/resources/META-INF/services/org.gvsig.tools.library.Library	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/resources/META-INF/services/org.gvsig.tools.library.Library	(revision 121)
@@ -0,0 +1 @@
+org.gvsig.exportto.swing.prov.postgresql.ExporttoV2PostgreSQLProviderLibrary
\ No newline at end of file
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/assembly/gvsig-plugin-package.xml
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/assembly/gvsig-plugin-package.xml	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/assembly/gvsig-plugin-package.xml	(revision 121)
@@ -0,0 +1,50 @@
+<assembly>
+  <id>gvsig-plugin-package</id>
+  <formats>
+    <format>zip</format>
+  </formats>
+  <baseDirectory>${project.artifactId}</baseDirectory>
+  <includeBaseDirectory>true</includeBaseDirectory>
+  <files>
+    <file>
+      <source>target/${project.artifactId}-${project.version}.jar</source>
+      <outputDirectory>lib</outputDirectory>
+    </file>
+    <file>
+      <source>target/package.info</source>
+    </file>
+    <file>
+      <source>src/main/resources-plugin/config.xml</source>
+    </file>
+  </files>
+
+  <dependencySets>
+  
+    <dependencySet>
+      <useProjectArtifact>false</useProjectArtifact>
+      <useTransitiveDependencies>false</useTransitiveDependencies>
+      <outputDirectory>lib</outputDirectory>
+      <includes>
+        <include>org.gvsig:org.gvsig.postgresql.provider</include>
+      </includes>
+    </dependencySet>
+    
+    <dependencySet>
+      <useProjectArtifact>false</useProjectArtifact>
+      <useTransitiveDependencies>false</useTransitiveDependencies>
+      <outputDirectory>lib</outputDirectory>
+      <includes>
+		<include>postgresql:postgresql</include>
+		<include>commons-dbcp:commons-dbcp</include>
+		<include>commons-collections:commons-collections</include>
+		<include>commons-pool:commons-pool</include>
+      </includes>
+    </dependencySet>
+    
+  </dependencySets>
+
+</assembly>
+
+
+
+
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/java/org/gvsig/postgresql/exportto/ExporttoPostgreSQLProviderLibrary.java
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/java/org/gvsig/postgresql/exportto/ExporttoPostgreSQLProviderLibrary.java	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/java/org/gvsig/postgresql/exportto/ExporttoPostgreSQLProviderLibrary.java	(revision 121)
@@ -0,0 +1,59 @@
+/**
+ * gvSIG. Desktop Geographic Information System.
+ *
+ * Copyright (C) 2007-2013 gvSIG Association.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * For any additional information, do not hesitate to contact us
+ * at info AT gvsig.com, or visit our website www.gvsig.com.
+ */
+package org.gvsig.postgresql.exportto;
+
+import org.gvsig.tools.library.AbstractLibrary;
+import org.gvsig.tools.library.LibraryException;
+import org.gvsig.tools.service.spi.ProviderManager;
+import org.gvsig.exportto.swing.ExporttoSwingLibrary;
+import org.gvsig.exportto.swing.spi.ExporttoSwingProviderLocator;
+
+/**
+ * Library to initialize and register the file Exporto provider
+ * implementation.
+ * 
+ * @author gvSIG Team
+ * @version $Id$
+ */
+public class ExporttoPostgreSQLProviderLibrary extends AbstractLibrary {
+
+    @Override
+    public void doRegistration() {
+        registerAsServiceOf(ExporttoSwingLibrary.class);
+    }
+
+    @Override
+    protected void doInitialize() throws LibraryException {
+        // Nothing to do
+    }
+
+    @Override
+    protected void doPostInitialize() throws LibraryException {
+        ProviderManager providerManager =
+            ExporttoSwingProviderLocator.getManager();
+        providerManager
+            .addProviderFactory(new ExporttoPostgreSQLProviderFactory());
+    }
+
+}
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/java/org/gvsig/postgresql/exportto/ExporttoPostgreSQLProviderFactory.java
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/java/org/gvsig/postgresql/exportto/ExporttoPostgreSQLProviderFactory.java	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/java/org/gvsig/postgresql/exportto/ExporttoPostgreSQLProviderFactory.java	(revision 121)
@@ -0,0 +1,63 @@
+/**
+ * gvSIG. Desktop Geographic Information System.
+ *
+ * Copyright (C) 2007-2013 gvSIG Association.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * For any additional information, do not hesitate to contact us
+ * at info AT gvsig.com, or visit our website www.gvsig.com.
+ */
+package org.gvsig.postgresql.exportto;
+
+import org.cresques.cts.IProjection;
+
+import org.gvsig.exportto.swing.ExporttoSwingManager;
+import org.gvsig.exportto.swing.spi.AbstractExporttoProviderFactory;
+import org.gvsig.fmap.dal.feature.FeatureStore;
+import org.gvsig.tools.dynobject.DynObject;
+import org.gvsig.tools.service.ServiceException;
+import org.gvsig.tools.service.spi.Provider;
+import org.gvsig.tools.service.spi.ProviderServices;
+
+/**
+ * Factory of file {@link ExportoProvider} objects.
+ * 
+ * @author gvSIG Team
+ * @version $Id$
+ */
+public class ExporttoPostgreSQLProviderFactory extends
+    AbstractExporttoProviderFactory {
+
+    private static final String PROVIDER_NAME = "PostgreSQLv2";
+
+    public ExporttoPostgreSQLProviderFactory() {
+        super(new int[] {
+            ExporttoSwingManager.VECTORIAL_TABLE_WITHOUT_GEOMETRY,
+            ExporttoSwingManager.VECTORIAL_TABLE_WITH_GEOMETRY });
+    }
+
+    public Provider create(DynObject parameters, ProviderServices services)
+        throws ServiceException {
+        return new ExporttoPostgreSQLProvider(services,
+            (FeatureStore) parameters.getDynValue(PARAMETER_FEATURESTORE),
+            (IProjection) parameters.getDynValue(PARAMETER_PROJECTION));
+    }
+
+    public String getName() {
+        return PROVIDER_NAME;
+    }
+}
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/java/org/gvsig/postgresql/exportto/package.html
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/java/org/gvsig/postgresql/exportto/package.html	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/java/org/gvsig/postgresql/exportto/package.html	(revision 121)
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+
+    gvSIG. Desktop Geographic Information System.
+
+    Copyright (C) 2007-2013 gvSIG Association.
+
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License
+    as published by the Free Software Foundation; either version 3
+    of the License, or (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+    MA  02110-1301, USA.
+
+    For any additional information, do not hesitate to contact us
+    at info AT gvsig.com, or visit our website www.gvsig.com.
+
+-->
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<title>org.gvsig.exporto package documentation</title>
+</head>
+<body>
+
+	<p>Exporto provider which gets Exporto from a file.</p>
+
+</body>
+</html>
\ No newline at end of file
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/java/org/gvsig/postgresql/exportto/panel/DefaultConnectionPanel.java
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/java/org/gvsig/postgresql/exportto/panel/DefaultConnectionPanel.java	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/java/org/gvsig/postgresql/exportto/panel/DefaultConnectionPanel.java	(revision 121)
@@ -0,0 +1,67 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.gvsig.postgresql.exportto.panel;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import javax.swing.JComponent;
+import javax.swing.JPanel;
+import org.gvsig.andami.PluginsLocator;
+import org.gvsig.andami.PluginsManager;
+import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorerParameters;
+import org.gvsig.tools.swing.api.Component;
+import org.gvsig.geodb.ExtDB_Spatial;
+
+/**
+ *
+ * @author jjdelcerro
+ */
+public class DefaultConnectionPanel extends JPanel implements Component {
+
+    private String name = null;
+    private DBServerExplorerParameters explorerParameters = null;
+    private String explorerNameFilter = null;
+
+    
+    public DefaultConnectionPanel() {
+        
+    }
+    
+    public void setFilterByExplorerName(String explorerNameFilter) {
+        this.explorerNameFilter = explorerNameFilter;
+    }
+    
+    public JComponent asJComponent() {
+        return this;
+    }
+    
+    protected Map<String,DBServerExplorerParameters> getUserConections() {
+        PluginsManager pluginsManager = PluginsLocator.getManager();
+        ExtDB_Spatial geodbExtension = pluginsManager.getExtension(ExtDB_Spatial.class);
+        Map<String, DBServerExplorerParameters> connections = geodbExtension.getUserConnections();
+        if( this.explorerNameFilter == null ) {
+            return connections;
+        }
+        Map<String,DBServerExplorerParameters> filteredConnections = new HashMap<String,DBServerExplorerParameters>();
+        
+        Iterator<Map.Entry<String,DBServerExplorerParameters>> it = connections.entrySet().iterator();
+        while( it.hasNext() ) {
+            Map.Entry<String,DBServerExplorerParameters> entry = it.next();
+            if( this.explorerNameFilter.equalsIgnoreCase(entry.getValue().getExplorerName()) ) {
+                filteredConnections.put(entry.getKey(), entry.getValue());
+            }
+        }
+        return filteredConnections;
+    }
+    
+    protected void initComponents() {
+        
+    }
+    
+    
+}
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/java/org/gvsig/postgresql/exportto/panel/SelectTableNamePanel.java
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/java/org/gvsig/postgresql/exportto/panel/SelectTableNamePanel.java	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/java/org/gvsig/postgresql/exportto/panel/SelectTableNamePanel.java	(revision 121)
@@ -0,0 +1,72 @@
+/**
+ * gvSIG. Desktop Geographic Information System.
+ *
+ * Copyright (C) 2007-2013 gvSIG Association.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * For any additional information, do not hesitate to contact us
+ * at info AT gvsig.com, or visit our website www.gvsig.com.
+ */
+package org.gvsig.postgresql.exportto.panel;
+
+import java.awt.BorderLayout;
+import javax.swing.JTextField;
+import org.gvsig.exportto.swing.ExporttoSwingLocator;
+import org.gvsig.exportto.swing.ExporttoSwingManager;
+import org.gvsig.exportto.swing.spi.ExporttoPanelValidationException;
+import org.gvsig.exportto.swing.spi.ExporttoSwingProviderPanel;
+
+/**
+ * @author gvSIG Team
+ * @version $Id$
+ * 
+ */
+public class SelectTableNamePanel extends ExporttoSwingProviderPanel {
+
+    private static final long serialVersionUID = 6269512983586358017L;
+
+    private static final ExporttoSwingManager EXPORTTO_SWING_MANAGER =
+        ExporttoSwingLocator.getSwingManager();
+
+    protected JTextField textField = null;
+
+    protected void initializeComponents() {
+        this.setLayout(new BorderLayout());
+        textField = new JTextField();
+        add(textField, BorderLayout.NORTH);
+    }
+
+    public String getText() {
+        String field = textField.getText();
+        if ((field == null) || (field.equals(""))) {
+            return null;
+        }
+        return field;
+    }
+    
+    public String getPanelTitle() {
+        return EXPORTTO_SWING_MANAGER.getTranslation("intro_tablename");
+    }
+
+    public boolean isValidPanel() throws ExporttoPanelValidationException {
+        if (getText() == null || getText().equals("")) {
+            throw new ExporttoPanelValidationException(
+                "The table cannot be empty");
+        }
+        return true;
+    }
+}
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/java/org/gvsig/postgresql/exportto/panel/SelectPkPanel.java
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/java/org/gvsig/postgresql/exportto/panel/SelectPkPanel.java	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/java/org/gvsig/postgresql/exportto/panel/SelectPkPanel.java	(revision 121)
@@ -0,0 +1,115 @@
+/**
+ * gvSIG. Desktop Geographic Information System.
+ *
+ * Copyright (C) 2007-2013 gvSIG Association.
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * For any additional information, do not hesitate to contact us at info AT
+ * gvsig.com, or visit our website www.gvsig.com.
+ */
+package org.gvsig.postgresql.exportto.panel;
+
+import java.awt.BorderLayout;
+
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import org.gvsig.exportto.swing.ExporttoSwingLocator;
+import org.gvsig.exportto.swing.ExporttoSwingManager;
+import org.gvsig.exportto.swing.spi.ExporttoPanelValidationException;
+import org.gvsig.exportto.swing.spi.ExporttoSwingProviderPanel;
+import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
+import org.gvsig.fmap.dal.feature.FeatureType;
+
+/**
+ * @author gvSIG Team
+ * @version $Id$
+ *
+ */
+public class SelectPkPanel extends ExporttoSwingProviderPanel {
+
+    private static final long serialVersionUID = 2652404227373508779L;
+
+    private static final ExporttoSwingManager EXPORTTO_SWING_MANAGER
+            = ExporttoSwingLocator.getSwingManager();
+
+    private FeatureType featType = null;
+    protected JTextField textField = null;
+
+    public SelectPkPanel() {
+        super();
+    }
+
+    public SelectPkPanel(FeatureType ft) {
+        super();
+        featType = ft;
+    }
+
+    protected void initializeComponents() {
+        this.setLayout(new BorderLayout());
+
+        JPanel topPanel = new JPanel(new BorderLayout());
+        textField = new JTextField();
+
+        String msg = EXPORTTO_SWING_MANAGER.getTranslation(
+                "_Enter_new_field_name_for_primary_key_or_blank_to_not_add_primary_key");
+        topPanel.add(new JLabel(msg + ":"), BorderLayout.NORTH);
+        topPanel.add(textField, BorderLayout.CENTER);
+        // ==============================================
+        add(topPanel, BorderLayout.NORTH);
+    }
+
+    public String getText() {
+        String field = textField.getText();
+        if ((field == null) || (field.trim().equals(""))) {
+            return null;
+        }
+        return field;
+    }
+
+    @Override
+    public String getPanelTitle() {
+        return EXPORTTO_SWING_MANAGER.getTranslation("_Primary_key");
+    }
+
+    @Override
+    public boolean isValidPanel() throws ExporttoPanelValidationException {
+        String txt = this.getText();
+        if (isFieldName(txt, featType)) {
+            throw new ExporttoPanelValidationException(
+                    EXPORTTO_SWING_MANAGER.getTranslation(
+                            "_Field_name_already_exists"));
+        }
+        return true;
+    }
+
+    private boolean isFieldName(String txt, FeatureType ft) {
+
+        if (ft == null || txt == null) {
+            return false;
+        }
+
+        FeatureAttributeDescriptor[] atts = ft.getAttributeDescriptors();
+        for (int i = 0; i < atts.length; i++) {
+            if (atts[i].getName().equals(txt)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+}
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/java/org/gvsig/postgresql/exportto/ExporttoPostgreSQLProvider.java
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/java/org/gvsig/postgresql/exportto/ExporttoPostgreSQLProvider.java	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/java/org/gvsig/postgresql/exportto/ExporttoPostgreSQLProvider.java	(revision 121)
@@ -0,0 +1,130 @@
+/**
+ * gvSIG. Desktop Geographic Information System.
+ *
+ * Copyright (C) 2007-2013 gvSIG Association.
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * For any additional information, do not hesitate to contact us at info AT
+ * gvsig.com, or visit our website www.gvsig.com.
+ */
+package org.gvsig.postgresql.exportto;
+
+import org.cresques.cts.IProjection;
+import org.gvsig.exportto.ExporttoService;
+import org.gvsig.exportto.swing.prov.jdbc.ExporrtoJDBCService;
+import org.gvsig.exportto.swing.prov.jdbc.panel.JDBCConnectionPanel;
+import org.gvsig.exportto.swing.spi.ExporttoSwingProvider;
+import org.gvsig.exportto.swing.spi.ExporttoSwingProviderPanel;
+import org.gvsig.fmap.dal.feature.FeatureStore;
+import org.gvsig.fmap.dal.feature.FeatureType;
+import org.gvsig.tools.service.spi.AbstractProvider;
+import org.gvsig.tools.service.spi.ProviderServices;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.gvsig.postgresql.exportto.panel.SelectPkPanel;
+import org.gvsig.postgresql.exportto.panel.SelectTableNamePanel;
+
+        
+/**
+ * Exporto provider which gets Exporto from a file.
+ *
+ * @author gvSIG Team
+ * @version $Id$
+ */
+public class ExporttoPostgreSQLProvider extends AbstractProvider
+        implements ExporttoSwingProvider {
+
+    private static Logger logger = LoggerFactory.getLogger(
+            ExporttoPostgreSQLProvider.class);
+
+    protected SelectTableNamePanel selectTableNamePanel = null;
+    protected SelectPkPanel selectPkPanel = null;
+    protected JDBCConnectionPanel jdbcConnectionPanel = null;
+
+    protected FeatureStore featureStore;
+    protected IProjection projection;
+
+    /**
+     * Constructor.
+     *
+     * @param providerServices the services for the provider
+     * @param file to get the Exporto from
+     */
+    public ExporttoPostgreSQLProvider(ProviderServices providerServices,
+            FeatureStore featureStore, IProjection projection) {
+        super(providerServices);
+        this.featureStore = featureStore;
+        this.projection = projection;
+
+        selectTableNamePanel = new SelectTableNamePanel();
+
+        FeatureType ftype = null;
+        try {
+            ftype = featureStore.getDefaultFeatureType();
+        } catch (Exception exc) {
+            logger.error("While getting feature type.", exc);
+        }
+        selectPkPanel = new SelectPkPanel(ftype);
+        jdbcConnectionPanel = new JDBCConnectionPanel();
+    }
+
+    public String getStoreName() {
+        return "PostgreSQL";
+    }
+
+    public String getExplorerName() {
+        return "PostgreSQLExplorer";
+    }
+
+    public int getPanelCount() {
+        return 3;
+    }
+
+    public ExporttoSwingProviderPanel getPanelAt(int index) {
+        switch (index) {
+            case 0:
+                return selectTableNamePanel;
+            case 1:
+                return selectPkPanel;
+            case 2:
+                return jdbcConnectionPanel;
+        }
+        return null;
+    }
+
+    public ExporttoService createExporttoService() {
+        ConnectionSettings connectionSettings
+                = jdbcConnectionPanel.getConnectionSettings();
+
+        int port = -1;
+        if (connectionSettings.getPort() != null
+                && connectionSettings.getPort().length() > 0) {
+            port = Integer.valueOf(connectionSettings.getPort());
+        }
+
+        String schema = null;
+        if (connectionSettings.getSchema() != null
+                && connectionSettings.getSchema().length() > 0) {
+            schema = connectionSettings.getSchema();
+        }
+
+        return new ExporrtoJDBCService(featureStore,
+                connectionSettings.getDb(), schema, selectTableNamePanel.getText(),
+                selectPkPanel.getText(), connectionSettings.getUser(),
+                connectionSettings.getPassw(), connectionSettings.getHost(), port,
+                getExplorerName(), getStoreName(), this.projection);
+    }
+}
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/resources-plugin/config.xml
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/resources-plugin/config.xml	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/resources-plugin/config.xml	(revision 121)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<plugin-config>
+  <libraries library-dir="lib/"/>
+  <depends plugin-name="org.gvsig.app.mainplugin"/>
+  <resourceBundle name="text"/>
+  <extensions>
+     <extension class-name="org.gvsig.andami.LibraryExtension" active="false"/>
+  </extensions>    
+</plugin-config>
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/pom.xml
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/pom.xml	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/pom.xml	(revision 121)
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>org.gvsig.postgresql.app.export</artifactId>
+  <packaging>jar</packaging>
+  <name>Export: PostgreSQL support</name>
+  <description>Export support for PostgreSQL</description>
+
+  <parent>
+      <groupId>org.gvsig</groupId>
+      <artifactId>org.gvsig.postgresql.app</artifactId>
+      <version>2.0.21-SNAPSHOT</version>
+  </parent>
+
+  <dependencies>
+    <dependency>
+        <groupId>org.gvsig</groupId>
+        <artifactId>org.gvsig.tools.lib</artifactId>
+        <scope>compile</scope>
+    </dependency>
+    <dependency>
+        <groupId>org.gvsig</groupId>
+        <artifactId>org.gvsig.andami</artifactId>
+        <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.gvsig</groupId>
+      <artifactId>org.gvsig.exportto.lib.api</artifactId>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.gvsig</groupId>
+      <artifactId>org.gvsig.exportto.swing.api</artifactId>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.gvsig</groupId>
+      <artifactId>org.gvsig.exportto.swing.spi</artifactId>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.gvsig</groupId>
+      <artifactId>org.gvsig.exportto.swing.prov.jdbc</artifactId>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.gvsig</groupId>
+      <artifactId>org.gvsig.geodb.app.mainplugin</artifactId>
+      <scope>compile</scope>
+    </dependency>
+    
+    
+    <dependency>
+      <groupId>postgresql</groupId>
+      <artifactId>postgresql</artifactId>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>commons-dbcp</groupId>
+      <artifactId>commons-dbcp</artifactId>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>commons-collections</groupId>
+      <artifactId>commons-collections</artifactId>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>commons-pool</groupId>
+      <artifactId>commons-pool</artifactId>
+      <scope>runtime</scope>
+    </dependency>
+    
+  </dependencies>
+  
+    <properties>
+        <!-- Package info property values -->
+        <!-- Default values in org.gvsig.desktop -->
+        <gvsig.package.info.state>testing</gvsig.package.info.state>
+        <gvsig.package.info.official>true</gvsig.package.info.official>
+        <gvsig.package.info.dependencies>required: org.gvsig.app.mainplugin -ge 2.0.1</gvsig.package.info.dependencies>
+        <gvsig.package.info.categories>Formats,Vector,Database</gvsig.package.info.categories>
+        <gvsig.package.info.poolURL>http://devel.gvsig.org/download/projects/gvsig-postgresql/pool/</gvsig.package.info.poolURL>
+    </properties>
+  
+
+</project>
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/buildNumber.properties
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/buildNumber.properties	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/buildNumber.properties	(revision 121)
@@ -0,0 +1,2 @@
+#Tue Oct 08 20:52:46 CEST 2013
+buildNumber=2077
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.mainplugin/buildNumber.properties
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.mainplugin/buildNumber.properties	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.mainplugin/buildNumber.properties	(revision 121)
@@ -0,0 +1,2 @@
+#Thu Apr 02 14:14:26 CEST 2015
+buildNumber=2086
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml	(revision 121)
@@ -0,0 +1,50 @@
+<assembly>
+  <id>gvsig-plugin-package</id>
+  <formats>
+    <format>zip</format>
+  </formats>
+  <baseDirectory>${project.artifactId}</baseDirectory>
+  <includeBaseDirectory>true</includeBaseDirectory>
+  <files>
+    <file>
+      <source>target/${project.artifactId}-${project.version}.jar</source>
+      <outputDirectory>lib</outputDirectory>
+    </file>
+    <file>
+      <source>target/package.info</source>
+    </file>
+    <file>
+      <source>src/main/resources-plugin/config.xml</source>
+    </file>
+  </files>
+
+  <dependencySets>
+  
+    <dependencySet>
+      <useProjectArtifact>false</useProjectArtifact>
+      <useTransitiveDependencies>false</useTransitiveDependencies>
+      <outputDirectory>lib</outputDirectory>
+      <includes>
+        <include>org.gvsig:org.gvsig.postgresql.provider</include>
+      </includes>
+    </dependencySet>
+    
+    <dependencySet>
+      <useProjectArtifact>false</useProjectArtifact>
+      <useTransitiveDependencies>false</useTransitiveDependencies>
+      <outputDirectory>lib</outputDirectory>
+      <includes>
+		<include>postgresql:postgresql</include>
+		<include>commons-dbcp:commons-dbcp</include>
+		<include>commons-collections:commons-collections</include>
+		<include>commons-pool:commons-pool</include>
+      </includes>
+    </dependencySet>
+    
+  </dependencySets>
+
+</assembly>
+
+
+
+
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.mainplugin/src/main/resources-plugin/config.xml
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.mainplugin/src/main/resources-plugin/config.xml	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.mainplugin/src/main/resources-plugin/config.xml	(revision 121)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<plugin-config>
+  <libraries library-dir="lib/"/>
+  <depends plugin-name="org.gvsig.app.mainplugin"/>
+  <resourceBundle name="text"/>
+  <extensions>
+     <extension class-name="org.gvsig.andami.LibraryExtension" active="false"/>
+  </extensions>    
+</plugin-config>
Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.mainplugin/pom.xml
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.mainplugin/pom.xml	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.mainplugin/pom.xml	(revision 121)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>org.gvsig.postgresql.app.mainplugin</artifactId>
+  <packaging>jar</packaging>
+  <name>Formats: PostgreSQL support</name>
+  <description>PostgreSQL file format support</description>
+
+  <parent>
+      <groupId>org.gvsig</groupId>
+      <artifactId>org.gvsig.postgresql.app</artifactId>
+      <version>2.0.29</version>
+  </parent>
+
+  <dependencies>
+    <dependency>
+        <groupId>org.gvsig</groupId>
+        <artifactId>org.gvsig.tools.lib</artifactId>
+        <scope>compile</scope>
+    </dependency>
+    <dependency>
+        <groupId>org.gvsig</groupId>
+        <artifactId>org.gvsig.andami</artifactId>
+        <scope>compile</scope>
+    </dependency>
+    <dependency>
+        <groupId>org.gvsig</groupId>
+        <artifactId>org.gvsig.postgresql.provider</artifactId>
+        <scope>compile</scope>
+    </dependency>
+    
+    <dependency>
+      <groupId>postgresql</groupId>
+      <artifactId>postgresql</artifactId>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>commons-dbcp</groupId>
+      <artifactId>commons-dbcp</artifactId>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>commons-collections</groupId>
+      <artifactId>commons-collections</artifactId>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>commons-pool</groupId>
+      <artifactId>commons-pool</artifactId>
+      <scope>runtime</scope>
+    </dependency>
+    
+  </dependencies>
+  
+    <properties>
+        <!-- Package info property values -->
+        <!-- Default values in org.gvsig.desktop -->
+        <gvsig.package.info.state>testing</gvsig.package.info.state>
+        <gvsig.package.info.official>true</gvsig.package.info.official>
+        <gvsig.package.info.dependencies>required: org.gvsig.app.mainplugin -ge 2.0.1</gvsig.package.info.dependencies>
+        <gvsig.package.info.categories>Formats,Vector,Database</gvsig.package.info.categories>
+        <gvsig.package.info.poolURL>https://devel.gvsig.org/download/projects/gvsig-postgresql/pool/</gvsig.package.info.poolURL>
+    </properties>
+  
+
+</project>

Property changes on: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/org.gvsig.postgresql.app.mainplugin
___________________________________________________________________
Added: svn:ignore
   + target
.buildNumber.properties.swp


Index: tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/pom.xml
===================================================================
--- tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/pom.xml	(revision 0)
+++ tags/org.gvsig.postgresql-2.0.29/org.gvsig.postgresql.app/pom.xml	(revision 121)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>org.gvsig.postgresql.app</artifactId>
+  <packaging>pom</packaging>
+  <name>${project.artifactId}</name>
+  <parent>
+      <groupId>org.gvsig</groupId>
+      <artifactId>org.gvsig.postgresql</artifactId>
+      <version>2.0.29</version>
+  </parent>
+
+  <modules>
+    <module>org.gvsig.postgresql.app.mainplugin</module>
+    <!--
+    <module>org.gvsig.postgresql.app.export</module>
+    -->
+  </modules>
+
+</project>

Property changes on: tags/org.gvsig.postgresql-2.0.29
___________________________________________________________________
Added: svn:ignore
   + .pom.xml.swp


