Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/resource/db/AbstractDBResourceNoBlocker.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/resource/db/AbstractDBResourceNoBlocker.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/resource/db/AbstractDBResourceNoBlocker.java	(revision 38285)
@@ -0,0 +1,181 @@
+/* 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.resource.db;
+
+import org.gvsig.fmap.dal.exception.DataException;
+import org.gvsig.fmap.dal.exception.InitializeException;
+import org.gvsig.fmap.dal.resource.ResourceParameters;
+import org.gvsig.fmap.dal.resource.exception.AccessResourceException;
+import org.gvsig.fmap.dal.resource.exception.ResourceException;
+import org.gvsig.fmap.dal.resource.spi.AbstractNonBlockingResource;
+
+/**
+ * <p>
+ * Abstract Data Base Resource implementation that allow the concurrent access.
+ * </p>
+ * 
+ * <p>
+ * Useful for Pooled Data Base Access.
+ * </p>
+ * 
+ * @author jmvivo
+ *
+ */
+public abstract class AbstractDBResourceNoBlocker extends AbstractNonBlockingResource {
+
+	/**
+	 * Default constructor
+	 *
+	 * @param parameters
+	 * @throws InitializeException
+	 */
+	protected AbstractDBResourceNoBlocker(DBResourceParameters parameters)
+			throws InitializeException {
+		super(parameters);
+	}
+
+	/**
+	 * Return a connection to the data base.<br>
+	 * Connect to the Data Base if is needed
+	 *
+	 * @return connection to the data base
+	 */
+	public Object get() throws AccessResourceException {
+		if (!isConnected()) {
+			try {
+				this.connect();
+			} catch (DataException e) {
+				throw new AccessResourceException(this, e);
+			}
+		}
+		try {
+			return getTheConnection();
+		} catch (DataException e) {
+			throw new AccessResourceException(this, e);
+		}
+	}
+
+	/**
+	 * Return a connection to the data base.<br>
+	 * Connect to the Data Base if is needed
+	 *
+	 *
+	 * @return connection to the data base
+	 * @see #get()
+	 */
+	public Object getConnection() throws AccessResourceException {
+		return get();
+	}
+
+	/**
+	 * inform if connection to the data base is established
+	 *
+	 * @return
+	 */
+	public abstract boolean isConnected();
+
+	/**
+	 * Establish connection to data base
+	 *
+	 * @throws DataException
+	 */
+	public final void connect() throws DataException {
+		if (this.isConnected()) {
+			return;
+		}
+		prepare();
+		connectToDB();
+	}
+
+	/**
+	 * final implementation method to Establish connection to data base<br>
+	 * Called from {@link #get()}<br>
+	 * <br>
+	 *
+	 *
+	 * @throws DataException
+	 */
+	protected abstract void connectToDB() throws DataException;
+
+	/**
+	 * final implementation method to get a connection to data base<br>
+	 * Called from {@link #connect()}<br>
+	 * <br>
+	 * This method is called with the connection establish
+	 *
+	 * @throws DataException
+	 */
+	protected abstract Object getTheConnection() throws DataException;
+
+	/**
+	 * Check if parameters is the same for this resource.<br>
+	 * <br>
+	 *
+	 * <strong>Note:</strong> override this method to add checks for specify
+	 * final implementation parameters
+	 *
+	 *
+	 * @see AbstractResource#isThis(ResourceParameters)
+	 */
+	public boolean isThis(ResourceParameters parameters)
+			throws ResourceException {
+		if (!(parameters instanceof DBResourceParameters)) {
+			return false;
+		}
+		DBResourceParameters params = (DBResourceParameters) parameters
+				.getCopy();
+		prepare(params);
+		DBResourceParameters myParams = (DBResourceParameters) this
+				.getParameters();
+
+		if (!equals(myParams.getHost(), params.getHost())) {
+			return false;
+		}
+		if (!equals(myParams.getPort(), params.getPort())) {
+			return false;
+		}
+		if (!equals(myParams.getUser(), params.getUser())) {
+			return false;
+		}
+
+		return true;
+	}
+
+	@SuppressWarnings("unchecked")
+	protected boolean equals(Comparable v1, Comparable v2) {
+		if (v1 == v2) {
+			return true;
+		}
+		if ((v1 != null) && (v2 != null)) {
+			return v1.compareTo(v2) == 0;
+		}
+		return false;
+	}
+
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/resource/db/AbstractDBResourceNoBlocker.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/resource/db/DBResourceParameters.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/resource/db/DBResourceParameters.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/resource/db/DBResourceParameters.java	(revision 38285)
@@ -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):
+* 2009 IVER T.I   {{Task}}
+*/
+
+package org.gvsig.fmap.dal.resource.db;
+
+import org.gvsig.fmap.dal.resource.spi.AbstractResourceParameters;
+import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
+import org.gvsig.fmap.dal.store.db.DBHelper;
+import org.gvsig.tools.dynobject.DelegatedDynObject;
+
+/**
+ * Base Abstract class to Data Base Resources Parameters
+ *
+ * @author jmvivo
+ *
+ */
+public abstract class DBResourceParameters extends AbstractResourceParameters
+		implements DBParameters {
+
+    public static final String PARAMETERS_DEFINITION_NAME = "DBResourceParameters";
+	private DelegatedDynObject parameters;
+
+    public DBResourceParameters(String parametersDefinitionName, String typeName) {
+    	this.parameters = (DelegatedDynObject) DBHelper.newParameters(parametersDefinitionName);
+    	this.setDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME, typeName);
+	}
+
+	protected DelegatedDynObject getDelegatedDynObject() {
+		return parameters;
+	}
+
+	public String getTypeName() {
+    	return (String) this.getDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME);
+    }
+    
+    public String getHost() {
+		return (String) this.getDynValue(HOST_PARAMTER_NAME);
+	}
+
+	public Integer getPort() {
+		return (Integer) this.getDynValue(PORT_PARAMTER_NAME);
+	}
+
+	public String getDBName() {
+		return (String) this.getDynValue(DBNAME_PARAMTER_NAME);
+	}
+
+	public String getUser() {
+		return (String) this.getDynValue(USER_PARAMTER_NAME);
+	}
+
+	public String getPassword() {
+		return (String) this.getDynValue(PASSWORD_PARAMTER_NAME);
+	}
+
+	/**
+	 * Set <code>host</code> parameter value
+	 *
+	 * @param host
+	 */
+	public void setHost(String host) {
+		this.setDynValue(HOST_PARAMTER_NAME, host);
+	}
+
+	/**
+	 * Set <code>port</code> parameter value
+	 *
+	 * @param port
+	 */
+	public void setPort(int port) {
+		this.setDynValue(PORT_PARAMTER_NAME, new Integer(port));
+	}
+
+	/**
+	 * Set <code>port</code> parameter value
+	 *
+	 * @param port
+	 */
+	public void setPort(Integer port) {
+		this.setDynValue(PORT_PARAMTER_NAME, port);
+	}
+
+	/**
+	 * Set <code>data base name</code> parameter value
+	 *
+	 * @param data
+	 *            base name
+	 */
+	public void setDBName(String dbName) {
+		this.setDynValue(DBNAME_PARAMTER_NAME, dbName);
+	}
+
+	/**
+	 * Set <code>user</code> parameter value
+	 * 
+	 * @param user
+	 */
+	public void setUser(String user) {
+		this.setDynValue(USER_PARAMTER_NAME, user);
+	}
+
+	/**
+	 * Set <code>password</code> parameter value
+	 * 
+	 * @param password
+	 */
+	public void setPassword(String password) {
+		this.setDynValue(PASSWORD_PARAMTER_NAME, password);
+	}
+
+}
\ No newline at end of file

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/resource/db/DBResourceParameters.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/resource/db/DBResourceLibrary.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/resource/db/DBResourceLibrary.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/resource/db/DBResourceLibrary.java	(revision 38285)
@@ -0,0 +1,65 @@
+/* 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.resource.db;
+
+import org.gvsig.fmap.dal.DALDbLibrary;
+import org.gvsig.fmap.dal.DALLibrary;
+import org.gvsig.fmap.dal.store.db.DBHelper;
+import org.gvsig.tools.library.AbstractLibrary;
+import org.gvsig.tools.library.LibraryException;
+
+/**
+ * Library to initialize Data Base Resources
+ *
+ * @author jmvivo
+ *
+ */
+public class DBResourceLibrary extends AbstractLibrary {
+
+    @Override
+    public void doRegistration() {
+        registerAsServiceOf(DALLibrary.class);
+        require(DALDbLibrary.class);
+    }
+
+	@Override
+	protected void doInitialize() throws LibraryException {
+	}
+
+	@Override
+	protected void doPostInitialize() throws LibraryException {
+		DBHelper.registerParametersDefinition(
+				DBResourceParameters.PARAMETERS_DEFINITION_NAME, 
+				DBResourceParameters.class, 
+				"DBParameters.xml"
+		);
+	}
+}
\ No newline at end of file

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/resource/db/DBResourceLibrary.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/resource/db/AbstractDBResourceBlocker.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/resource/db/AbstractDBResourceBlocker.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/resource/db/AbstractDBResourceBlocker.java	(revision 38285)
@@ -0,0 +1,171 @@
+/* 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.resource.db;
+
+import org.gvsig.fmap.dal.exception.DataException;
+import org.gvsig.fmap.dal.exception.InitializeException;
+import org.gvsig.fmap.dal.resource.ResourceParameters;
+import org.gvsig.fmap.dal.resource.exception.AccessResourceException;
+import org.gvsig.fmap.dal.resource.exception.ResourceException;
+import org.gvsig.fmap.dal.resource.spi.AbstractResource;
+
+/**
+ * Abstract Data Base Resource implementation that prevents the concurrent
+ * access.
+ *
+ * @author jmvivo
+ * 
+ */
+public abstract class AbstractDBResourceBlocker extends AbstractResource
+		implements
+		DBResource {
+
+	/**
+	 * Default constructor
+	 *
+	 * @param parameters
+	 * @throws InitializeException
+	 */
+	protected AbstractDBResourceBlocker(DBResourceParameters parameters)
+			throws InitializeException {
+		super(parameters);
+	}
+
+
+	/**
+	 * Return a connection to the data base.<br>
+	 * Connect to the Data Base if is needed
+	 *
+	 * @return connection to the data base
+	 */
+	public Object get() throws AccessResourceException {
+		if (!isConnected()) {
+			try {
+				this.connect();
+			} catch (DataException e) {
+				throw new AccessResourceException(this, e);
+			}
+		}
+		try {
+			return getTheConnection();
+		} catch (DataException e) {
+			throw new AccessResourceException(this, e);
+		}
+	}
+
+	/**
+	 * Return a connection to the data base.<br>
+	 * Connect to the Data Base if is needed
+	 *
+	 *
+	 * @return connection to the data base
+	 * @see #get()
+	 */
+	public Object getConnection() throws AccessResourceException {
+		return get();
+	}
+
+	/**
+	 * Establish connection to data base
+	 *
+	 * @throws DataException
+	 */
+	public final void connect() throws DataException {
+		if (this.isConnected()) {
+			return;
+		}
+		prepare();
+		connectToDB();
+	}
+
+	/**
+	 * Check if parameters is the same for this resource.<br>
+	 * <br>
+	 *
+	 * <strong>Note:</strong> override this method to add checks for specify
+	 * final implementation parameters
+	 *
+	 *
+	 * @see AbstractResource#isThis(ResourceParameters)
+	 */
+	public boolean isThis(ResourceParameters parameters)
+			throws ResourceException {
+		if (!(parameters instanceof DBResourceParameters)) {
+			return false;
+		}
+		DBResourceParameters params = (DBResourceParameters) parameters
+				.getCopy();
+		prepare(params);
+		DBResourceParameters myParams = (DBResourceParameters) this
+				.getParameters();
+
+		if (!equals(myParams.getHost(), params.getHost())) {
+			return false;
+		}
+		if (!equals(myParams.getPort(), params.getPort())) {
+			return false;
+		}
+		if (!equals(myParams.getUser(), params.getUser())) {
+			return false;
+		}
+
+		return true;
+	}
+
+	@SuppressWarnings("unchecked")
+	protected boolean equals(Comparable v1, Comparable v2) {
+		if (v1 == v2) {
+			return true;
+		}
+		if ((v1 != null) && (v2 != null)) {
+			return v1.compareTo(v2) == 0;
+		}
+		return false;
+	}
+
+	/**
+	 * final implementation method to Establish connection to data base<br>
+	 * Called from {@link #get()}<br>
+	 * <br>
+	 *
+	 *
+	 * @throws DataException
+	 */
+	protected abstract void connectToDB() throws DataException;
+
+	/**
+	 * final implementation method to get a connection to data base<br>
+	 * Called from {@link #connect()}<br>
+	 * <br>
+	 * This method is called with the connection establish
+	 *
+	 * @throws DataException
+	 */
+	protected abstract Object getTheConnection() throws DataException;
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/resource/db/AbstractDBResourceBlocker.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/resource/db/DBParameters.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/resource/db/DBParameters.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/resource/db/DBParameters.java	(revision 38285)
@@ -0,0 +1,99 @@
+/* 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.resource.db;
+
+/**
+ * Interface for describe parameters of a Data Base
+ *
+ *
+ * @author jmvivo
+ *
+ */
+public interface DBParameters {
+
+	/**
+	 * Parameter name for <code>host</code>
+	 */
+	public static final String HOST_PARAMTER_NAME = "host";
+
+	/**
+	 * Parameter name for <code>port</code> 
+	 */
+	public static final String PORT_PARAMTER_NAME = "port";
+
+	/**
+	 * Parameter name for <code>data base name</code> 
+	 */
+	public static final String DBNAME_PARAMTER_NAME = "dbname";
+
+	/**
+	 * Parameter name for <code>user</code>
+	 */
+	public static final String USER_PARAMTER_NAME = "dbuser";
+
+	/**
+	 * Parameter name for <code>password</code>
+	 */
+	public static final String PASSWORD_PARAMTER_NAME = "password";
+
+	/**
+	 * Return the value of <code>host</code> parameter
+	 *
+	 * @return
+	 */
+	public String getHost();
+
+	/**
+	 * Return the value of <code>port</code> parameter
+	 *
+	 * @return
+	 */
+	public Integer getPort();
+
+	/**
+	 * Return the value of <code>data base name</code> parameter
+	 *
+	 * @return
+	 */
+	public String getDBName();
+
+	/**
+	 * Return the value of <code>password</code> parameter
+	 *
+	 * @return
+	 */
+	public String getPassword();
+
+	/**
+	 * Return the value of <code>user</code> parameter
+	 *
+	 * @return
+	 */
+	public String getUser();
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/resource/db/DBParameters.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/resource/db/DBResource.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/resource/db/DBResource.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/resource/db/DBResource.java	(revision 38285)
@@ -0,0 +1,47 @@
+/* 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.resource.db;
+
+import org.gvsig.fmap.dal.resource.Resource;
+
+/**
+ * Interface for Resources of a Data Base
+ *
+ * @author jmvivo
+ *
+ */
+public interface DBResource extends Resource {
+
+	/**
+	 * inform if connection to the data base is established
+	 *
+	 * @return
+	 */
+	public boolean isConnected();
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/resource/db/DBResource.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/serverexplorer/db/DBServerExplorerParameters.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/serverexplorer/db/DBServerExplorerParameters.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/serverexplorer/db/DBServerExplorerParameters.java	(revision 38285)
@@ -0,0 +1,137 @@
+/* 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.serverexplorer.db;
+
+import org.gvsig.fmap.dal.DataServerExplorerParameters;
+import org.gvsig.fmap.dal.spi.AbstractDataParameters;
+import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
+import org.gvsig.fmap.dal.store.db.DBHelper;
+import org.gvsig.tools.dynobject.DelegatedDynObject;
+
+/**
+ * Abstract class of {@link DataServerExplorerParameters} for Data Base type
+ * server
+ *
+ * @author jmvivo
+ *
+ */
+public abstract class DBServerExplorerParameters extends AbstractDataParameters
+		implements DataServerExplorerParameters, DBConnectionParameter {
+
+    public static final String PARAMETERS_DEFINITION_NAME = "DBServerExplorerParameters";
+
+    private DelegatedDynObject parameters;
+
+	public DBServerExplorerParameters(String parametersDefinitionName, String explorerName) {
+		this.parameters = (DelegatedDynObject) DBHelper.newParameters(parametersDefinitionName);
+		this.setDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME, explorerName);
+	}
+
+	public String getExplorerName() {
+		return (String) this.getDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME);
+	}
+	
+	protected DelegatedDynObject getDelegatedDynObject() {
+		return parameters;
+	}
+
+	public String getHost() {
+		return (String) this.getDynValue(HOST_PARAMTER_NAME);
+	}
+
+	public Integer getPort() {
+		return (Integer) this.getDynValue(PORT_PARAMTER_NAME);
+	}
+
+	public String getDBName() {
+		return (String) this.getDynValue(DBNAME_PARAMTER_NAME);
+	}
+
+	public String getUser() {
+		return (String) this.getDynValue(USER_PARAMTER_NAME);
+	}
+
+	public String getPassword() {
+		return (String) this.getDynValue(PASSWORD_PARAMTER_NAME);
+	}
+
+	/**
+	 * Set <code>host</code> parameter value
+	 *
+	 * @param host
+	 */
+	public void setHost(String host) {
+		this.setDynValue(HOST_PARAMTER_NAME, host);
+	}
+
+	/**
+	 * Set <code>port/code> parameter value
+	 *
+	 * @param port
+	 */
+	public void setPort(int port) {
+		this.setDynValue(PORT_PARAMTER_NAME, new Integer(port));
+	}
+
+	/**
+	 * Set <code>port/code> parameter value
+	 *
+	 * @param port
+	 */
+	public void setPort(Integer port) {
+		this.setDynValue(PORT_PARAMTER_NAME, port);
+	}
+
+	/**
+	 * Set <code>data base name/code> parameter value
+	 *
+	 * @param data
+	 *            base name
+	 */
+	public void setDBName(String dbName) {
+		this.setDynValue(DBNAME_PARAMTER_NAME, dbName);
+	}
+
+	/**
+	 * Set <code>user/code> parameter value
+	 *
+	 * @param user
+	 */
+	public void setUser(String user) {
+		this.setDynValue(USER_PARAMTER_NAME, user);
+	}
+
+	/**
+	 * Set <code>password/code> parameter value
+	 * 
+	 * @param password
+	 */
+	public void setPassword(String password) {
+		this.setDynValue(PASSWORD_PARAMTER_NAME, password);
+	}
+
+}
\ No newline at end of file

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/serverexplorer/db/DBServerExplorerParameters.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/serverexplorer/db/DBConnectionParameter.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/serverexplorer/db/DBConnectionParameter.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/serverexplorer/db/DBConnectionParameter.java	(revision 38285)
@@ -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.serverexplorer.db;
+
+import org.gvsig.fmap.dal.resource.db.DBParameters;
+
+/**
+ * Interface for describe parameters of a Data Base connection
+ *
+ *
+ * @author jmvivo
+ *
+ */
+
+public interface DBConnectionParameter extends DBParameters {
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/serverexplorer/db/DBConnectionParameter.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/serverexplorer/db/spi/AbstractDBServerExplorer.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/serverexplorer/db/spi/AbstractDBServerExplorer.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/serverexplorer/db/spi/AbstractDBServerExplorer.java	(revision 38285)
@@ -0,0 +1,106 @@
+/* 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.serverexplorer.db.spi;
+
+import org.gvsig.fmap.dal.DataServerExplorerParameters;
+import org.gvsig.fmap.dal.NewDataStoreParameters;
+import org.gvsig.fmap.dal.exception.DataException;
+import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorer;
+import org.gvsig.fmap.dal.spi.DataServerExplorerProvider;
+import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices;
+import org.gvsig.fmap.dal.spi.DataStoreProvider;
+import org.gvsig.tools.dispose.impl.AbstractDisposable;
+
+/**
+ * Abstract class for {@link DBServerExplorer} implementation
+ *
+ * @author jmvivo
+ *
+ */
+public abstract class AbstractDBServerExplorer extends AbstractDisposable
+		implements DBServerExplorer, DataServerExplorerProvider {
+
+	private DataServerExplorerProviderServices dataServerExplorerProviderServices;
+	private DataServerExplorerParameters dataServerParameters;
+
+	protected AbstractDBServerExplorer(DataServerExplorerParameters parameters,
+			DataServerExplorerProviderServices services) {
+		this.dataServerParameters = parameters;
+		this.dataServerExplorerProviderServices = services;
+	}
+
+	/**
+	 * Return the name of {@link DataStoreProvider} returned by this
+	 * ServerExplorer
+	 *
+	 * @return
+	 */
+	protected abstract String getStoreName();
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorer#canAdd(java.lang.String)
+	 */
+	public boolean canAdd(String storeName) throws DataException {
+		return getStoreName().equals(storeName);
+	}
+
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorer#getAddParameters(java.lang.String)
+	 */
+	public NewDataStoreParameters getAddParameters(String storeName)
+			throws DataException {
+		if (!getStoreName().equals(storeName)) {
+			// FIXME exception
+			throw new IllegalArgumentException();
+		}
+		return getAddParameters();
+	}
+
+	/**
+	 * Return instance of {@link DataServerExplorerProviderServices}
+	 *
+	 */
+	public DataServerExplorerProviderServices getServerExplorerProviderServices() {
+		return dataServerExplorerProviderServices;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorer#getParameters()
+	 */
+	public DataServerExplorerParameters getParameters() {
+		return dataServerParameters;
+	}
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/serverexplorer/db/spi/AbstractDBServerExplorer.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/serverexplorer/db/DBServerExplorer.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/serverexplorer/db/DBServerExplorer.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/serverexplorer/db/DBServerExplorer.java	(revision 38285)
@@ -0,0 +1,89 @@
+/* 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.serverexplorer.db;
+
+import org.gvsig.fmap.dal.DataServerExplorer;
+import org.gvsig.fmap.dal.DataStore;
+import org.gvsig.fmap.dal.DataStoreParameters;
+import org.gvsig.fmap.dal.NewDataStoreParameters;
+import org.gvsig.fmap.dal.exception.CloseException;
+import org.gvsig.fmap.dal.exception.DataException;
+import org.gvsig.fmap.dal.exception.OpenException;
+import org.gvsig.fmap.dal.feature.FeatureType;
+
+/**
+ * Base interface of {@link DataServerExplorer} for Data Base type server
+ *
+ * @author jmvivo
+ *
+ */
+public interface DBServerExplorer extends DataServerExplorer {
+
+	/**
+	 * Return a instance of {@link NewDataStoreParameters} to fill
+	 *
+	 * @return
+	 * @throws DataException
+	 */
+	public NewDataStoreParameters getAddParameters()
+			throws DataException;
+
+	/**
+	 * Return the {@link FeatureType} of the store of <code>dsp</code> store
+	 *
+	 * @param dsp
+	 * @return
+	 * @throws DataException
+	 */
+	public FeatureType getFeatureType(DataStoreParameters dsp)
+			throws DataException;
+	/**
+	 * Open a store defined by <code>dsp</code>
+	 *
+	 * @param dsp
+	 * @return
+	 * @throws DataException
+	 */
+	public DataStore open(DataStoreParameters dsp)
+			throws DataException;
+
+	/**
+	 * Open connection to the server
+	 *
+	 * @throws OpenException
+	 */
+	public void open() throws OpenException;
+
+
+	/**
+	 * Close connection to the server
+	 *
+	 * @throws OpenException
+	 */
+	public void close() throws CloseException;
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/serverexplorer/db/DBServerExplorer.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/DALDbLibrary.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/DALDbLibrary.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/DALDbLibrary.java	(revision 38285)
@@ -0,0 +1,56 @@
+/* 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;
+
+import org.gvsig.tools.library.AbstractLibrary;
+import org.gvsig.tools.library.LibraryException;
+
+/**
+ * Initialize DAL data base basic support
+ *
+ * @author jmvivo
+ * 
+ */
+public class DALDbLibrary extends AbstractLibrary {
+
+    @Override
+    public void doRegistration() {
+        registerAsServiceOf(DALLibrary.class);
+    }
+
+	@Override
+	protected void doInitialize() throws LibraryException {
+	}
+
+	@Override
+	protected void doPostInitialize() throws LibraryException {
+	}
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/DALDbLibrary.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCConnectionParameters.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCConnectionParameters.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCConnectionParameters.java	(revision 38285)
@@ -0,0 +1,91 @@
+/* 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.jdbc;
+
+import org.gvsig.fmap.dal.serverexplorer.db.DBConnectionParameter;
+
+/**
+ * Interface JDBC Store Parameters
+ *
+ * @author jmvivo
+ *
+ */
+public interface JDBCConnectionParameters extends DBConnectionParameter {
+
+	/**
+	 * Parameter name for <code>JDBC driver class name</code>
+	 */
+	public static final String JDBC_DRIVER_CLASS_PARAMTER_NAME = "jdbcdriverclass";
+
+	/**
+	 * Parameter name for <code>catalog</code> 
+	 */
+	public static final String CATALOG_PARAMTER_NAME = "catalog";
+
+	/**
+	 * Parameter name for <code>schema</code> 
+	 */
+	public static final String SCHEMA_PARAMTER_NAME = "schema";
+
+	/**
+	 * Parameter name for <code>JDBC connection URL</code>
+	 */
+	public static final String URL_PARAMTER_NAME = "url";
+
+	/**
+	 * Return <code>JDBC driver class name</code> parameter
+	 *
+	 * @return
+	 */
+	public String getJDBCDriverClassName();
+
+	/**
+	 * Return <code>catalog</code> parameter
+	 *
+	 * @return
+	 */
+	public String getCatalog();
+
+	/**
+	 * Return <code>schema</code> parameter
+	 *
+	 * @return
+	 */
+	public String getSchema();
+
+	/**
+	 * Return <code>JDBC connection URL</code> parameter
+	 * 
+	 * @return
+	 */
+	public String getUrl();
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCConnectionParameters.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCResource.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCResource.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCResource.java	(revision 38285)
@@ -0,0 +1,241 @@
+/* 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.jdbc;
+
+import java.sql.Connection;
+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.ResourceParameters;
+import org.gvsig.fmap.dal.resource.db.AbstractDBResourceNoBlocker;
+import org.gvsig.fmap.dal.resource.exception.AccessResourceException;
+import org.gvsig.fmap.dal.resource.exception.ResourceException;
+import org.gvsig.fmap.dal.store.jdbc.exception.JDBCDriverClassNotFoundException;
+import org.gvsig.fmap.dal.store.jdbc.exception.JDBCSQLException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class JDBCResource extends AbstractDBResourceNoBlocker {
+
+	final static private Logger logger = LoggerFactory
+			.getLogger(JDBCResource.class);
+
+	public final static String NAME = "JDBCResource";
+	public static final String DESCRIPTION = "JDBC Connection";
+
+	protected DataSource dataSource = null;
+
+	public JDBCResource(JDBCResourceParameters parameters)
+			throws InitializeException {
+		super(parameters);
+		registerJDBCDriver();
+
+	}
+
+	public String getName() throws AccessResourceException {
+		JDBCResourceParameters params = (JDBCResourceParameters) this
+				.getParameters();
+		return MessageFormat.format("JDBCResource({0},{1},{2},{3},{4})",
+				new Object[] {
+				params.getJDBCDriverClassName(),
+						params.getHost(), params.getPort(),
+				params.getUser(), params.getDBName() });
+	}
+
+	@SuppressWarnings("unchecked")
+	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);
+
+			}
+		}
+	}
+
+
+	public Connection getJDBCConnection() throws AccessResourceException {
+		return (Connection) get();
+	}
+
+	private void debugPoolStatus(String src) {
+		if (logger.isDebugEnabled() && dataSource instanceof BasicDataSource) {
+			BasicDataSource ds = (BasicDataSource) dataSource;
+			logger.debug(src + "  actives:" + ds.getNumActive() + "("
+					+ ds.getMaxActive() + ") idle:" + ds.getNumIdle() + "("
+					+ ds.getMaxIdle() + ")");
+		}
+
+	}
+
+	protected synchronized Object getTheConnection() throws DataException {
+		try {
+			Object conn = this.dataSource.getConnection();
+			debugPoolStatus("getTheConnection");
+			return conn;
+		} catch (SQLException e) {
+			throw new JDBCSQLException(e);
+		}
+	}
+
+	public boolean isThis(ResourceParameters parameters)
+			throws ResourceException {
+		if (!super.isThis(parameters)) {
+			return false;
+		}
+
+		String dbName = ((JDBCResourceParameters) parameters).getDBName();
+		String myDbName = ((JDBCResourceParameters) getParameters())
+				.getDBName();
+		if (dbName != myDbName) {
+			if (!(dbName != null && dbName.equals(myDbName))) {
+				return false;
+			}
+
+		}
+
+		String driver = ((JDBCResourceParameters) parameters)
+				.getJDBCDriverClassName();
+		String myDriver = ((JDBCResourceParameters) getParameters())
+				.getJDBCDriverClassName();
+		if (driver != myDriver) {
+			if (!(driver != null && driver.equals(myDriver))) {
+				return false;
+			}
+		}
+		return true;
+
+	}
+
+	public boolean isConnected() {
+		if (dataSource == null) {
+			return false;
+		}
+		if (dataSource instanceof BasicDataSource) {
+			return ((BasicDataSource) dataSource).getNumActive() > 0
+					|| ((BasicDataSource) dataSource).getNumIdle() > 0;
+		}
+		return true;
+	}
+
+	protected DataSource createDataSource() {
+		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);
+		 */
+		return dataSource;
+	}
+
+	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;
+	}
+
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCResource.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCServerExplorer.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCServerExplorer.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCServerExplorer.java	(revision 38285)
@@ -0,0 +1,572 @@
+/* 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.jdbc;
+
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.gvsig.fmap.dal.DALLocator;
+import org.gvsig.fmap.dal.DataManager;
+import org.gvsig.fmap.dal.DataStore;
+import org.gvsig.fmap.dal.DataStoreParameters;
+import org.gvsig.fmap.dal.NewDataStoreParameters;
+import org.gvsig.fmap.dal.exception.CloseException;
+import org.gvsig.fmap.dal.exception.DataException;
+import org.gvsig.fmap.dal.exception.InitializeException;
+import org.gvsig.fmap.dal.exception.OpenException;
+import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
+import org.gvsig.fmap.dal.exception.ReadException;
+import org.gvsig.fmap.dal.exception.RemoveException;
+import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
+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.NewFeatureStoreParameters;
+import org.gvsig.fmap.dal.resource.spi.ResourceProvider;
+import org.gvsig.fmap.dal.serverexplorer.db.spi.AbstractDBServerExplorer;
+import org.gvsig.fmap.dal.spi.DataManagerProviderServices;
+import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices;
+import org.gvsig.fmap.dal.store.jdbc.exception.JDBCExecuteSQLException;
+import org.gvsig.fmap.dal.store.jdbc.exception.JDBCSQLException;
+import org.gvsig.tools.exception.BaseException;
+
+
+/**
+ * @author jmvivo
+ *
+ */
+public class JDBCServerExplorer extends AbstractDBServerExplorer
+		implements JDBCHelperUser {
+
+	private static final Logger LOG = LoggerFactory
+			.getLogger(JDBCServerExplorer.class);
+	
+	private static final String METADATA_COLUMN_TABLE_CATALOG = "TABLE_CAT";
+	private static final String METADATA_COLUMN_TABLE_SCHEMA = "TABLE_SCHEM";
+	private static final String METADATA_COLUMN_TABLE_NAME = "TABLE_NAME";
+
+	public static final String NAME = "JDBCServerExplorer";
+	protected JDBCHelper helper;
+
+	private Boolean canAdd;
+
+	public JDBCServerExplorer(JDBCServerExplorerParameters parameters,
+			DataServerExplorerProviderServices services)
+			throws InitializeException {
+		super(parameters, services);
+		this.helper = createHelper();
+	}
+
+	protected JDBCServerExplorerParameters getJDBCParameters() {
+		return (JDBCServerExplorerParameters) getParameters();
+	}
+
+	protected JDBCHelper createHelper() throws InitializeException {
+		return new JDBCHelper(this, getJDBCParameters());
+	}
+
+	protected JDBCHelper getHelper() {
+		return helper;
+	}
+
+
+	public List list() throws DataException {
+		return this.list(MODE_ALL);
+	}
+
+	public List list(boolean showInformationDBTables) throws DataException {
+		return this.list(MODE_ALL, showInformationDBTables);
+	}
+
+	public List list(int mode) throws DataException {
+		JDBCServerExplorerParameters parameters = getJDBCParameters();
+		if (parameters.getShowInformationDBTables() != null) {
+			return this.list(mode, parameters.getShowInformationDBTables()
+					.booleanValue());
+		}
+		Boolean show = (Boolean) parameters
+				.getDynClass()
+				.getDynField(
+						JDBCServerExplorerParameters.SHOWINFORMATIONDBTABLES_PARAMTER_NAME)
+				.getDefaultValue();
+		if (show == null){
+			show = Boolean.FALSE;
+		}
+
+		return this.list(mode, show.booleanValue());
+	}
+
+
+	protected DataManagerProviderServices getManager() {
+		return (DataManagerProviderServices) DALLocator.getDataManager();
+	}
+
+	public boolean hasGeometrySupport() {
+		return false;
+	}
+
+	public boolean closeResourceRequested(ResourceProvider resource) {
+		try {
+			this.helper.close();
+		} catch (CloseException e) {
+			LOG.error("Exception in close Request", e);
+		}
+		return !this.helper.isOpen();
+	}
+
+	public void resourceChanged(ResourceProvider resource) {
+		// Nothing to do
+	}
+
+	public void remove(DataStoreParameters dsp) throws RemoveException {
+		final JDBCStoreParameters dsParams =(JDBCStoreParameters) 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 "
+					+ dsParams.tableID();
+
+				try{
+					try{
+						st.execute(sqlDrop);
+					} catch (SQLException e) {
+						throw new JDBCExecuteSQLException(sqlDrop, 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 {
+		JDBCServerExplorerParameters parameters = getJDBCParameters();
+		JDBCNewStoreParameters params = new JDBCNewStoreParameters();
+		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.setDefaultFeatureType(this.getServerExplorerProviderServices()
+				.createNewFeatureType());
+
+		return params;
+	}
+
+	public void closeDone() throws DataException {
+		// Nothing to do
+	}
+
+	public void opendDone() throws DataException {
+		// Nothin to do
+
+	}
+
+	public DataStore open(DataStoreParameters dsp) throws DataException {
+		checkIsMine(dsp);
+		DataManager dataMan = DALLocator.getDataManager();
+		DataStore store;
+		try {
+			store = dataMan.openStore(dsp.getDataStoreName(), dsp);
+		} catch (ValidateDataParametersException e) {
+			throw new InitializeException(e);
+		}
+
+		return store;
+	}
+
+	protected void checkIsMine(DataStoreParameters dsp) {
+		if (!(dsp instanceof JDBCStoreParameters)) {
+			// FIXME Exception ???
+			throw new IllegalArgumentException(
+					"not instance of FilesystemStoreParameters");
+		}
+
+		// try {
+		// dsp.validate();
+		// } catch (ValidateDataParametersException e) {
+		// throw new IllegalArgumentException("check parameters", e);
+		// }
+
+		JDBCServerExplorerParameters parameters = getJDBCParameters();
+
+		JDBCStoreParameters pgp = (JDBCStoreParameters) dsp;
+		if (!compare(pgp.getHost(), parameters.getHost())) {
+			throw new IllegalArgumentException("wrong explorer: Host (mine: "
+					+ parameters.getHost() + " other:" + pgp.getHost() + ")");
+		}
+		if (!compare(pgp.getPort(), parameters.getPort())) {
+			throw new IllegalArgumentException("wrong explorer: Port (mine: "
+					+ parameters.getPort() + " other:" + pgp.getPort() + ")");
+		}
+		if (!compare(pgp.getDBName(), parameters.getDBName())) {
+			throw new IllegalArgumentException("wrong explorer: DBName (mine: "
+					+ parameters.getDBName() + " other:" + pgp.getDBName()
+					+ ")");
+		}
+		if (parameters.getCatalog() != null && !parameters.getCatalog().trim().equals("")) {
+			// implicit catalog
+			if (!compare(pgp.getCatalog(), parameters.getCatalog())) {
+				throw new IllegalArgumentException(
+						"wrong explorer: Catalog (mine: "
+								+ parameters.getCatalog() + " other:"
+								+ pgp.getCatalog() + ")");
+			}
+		}
+		if (parameters.getSchema() != null && !parameters.getSchema().trim().equals("")) {
+			// implicit schema
+			if (!compare(pgp.getSchema(), parameters.getSchema())) {
+				throw new IllegalArgumentException(
+						"wrong explorer: Schema (mine: "
+								+ parameters.getSchema() + " other:"
+								+ pgp.getSchema() + ")");
+			}
+		}
+	}
+
+	protected boolean compare(Object str1, Object str2) {
+		if (str1 == str2){
+			return true;
+		}
+		if (str1 == null){
+			return false;
+		}
+		return  str1.equals(str2);
+	}
+
+	protected JDBCStoreParameters createStoreParams()
+			throws InitializeException, ProviderNotRegisteredException {
+		DataManagerProviderServices manager = this.getManager();
+		JDBCServerExplorerParameters parameters = getJDBCParameters();
+		JDBCStoreParameters orgParams = (JDBCStoreParameters) manager
+				.createStoreParameters(getStoreName());
+		orgParams.setHost(parameters.getHost());
+		orgParams.setPort(parameters.getPort());
+		orgParams.setDBName(parameters.getDBName());
+		orgParams.setUser(parameters.getUser());
+		orgParams.setPassword(parameters.getPassword());
+        orgParams.setCatalog(parameters.getCatalog());
+        orgParams.setJDBCDriverClassName(parameters.getJDBCDriverClassName());
+        orgParams.setSchema(parameters.getSchema());
+        orgParams.setUrl(parameters.getUrl());
+		return orgParams;
+	}
+
+	public List list(final int mode, final boolean showInformationDBTables)
+			throws DataException {
+
+		final JDBCStoreParameters orgParams = createStoreParams();
+
+		ConnectionAction action = new ConnectionAction() {
+
+			public Object action(Connection conn) throws DataException {
+
+				String[] tableTypes = null;
+				if (!showInformationDBTables) {
+					tableTypes = new String[] { "TABLE", "VIEW" };
+				}
+
+				ResultSet result = null;
+				try {
+					DatabaseMetaData metadata = conn.getMetaData();
+					result = metadata.getTables(null, null, null,
+							tableTypes);
+					List<JDBCStoreParameters> paramList = new ArrayList<JDBCStoreParameters>();
+					while (result.next()) {
+						JDBCStoreParameters params = (JDBCStoreParameters) orgParams
+								.getCopy();
+						params.setCatalog(result
+								.getString(METADATA_COLUMN_TABLE_CATALOG));
+						params.setSchema(result
+								.getString(METADATA_COLUMN_TABLE_SCHEMA));
+						params.setTable(result
+								.getString(METADATA_COLUMN_TABLE_NAME));
+						paramList.add(params);
+					}
+
+					return paramList;
+				} catch (SQLException e) {
+					throw new JDBCSQLException(e);
+				} finally {
+					if (result != null) {
+						try {
+							result.close();
+						} catch (Exception e) {
+							LOG.error("Error closing DatabaseMetadata "
+									+ "getTables() Resultset", e);
+						}
+					}
+				}
+			}
+
+		};
+
+		try {
+			return (List) helper.doConnectionAction(action);
+		} catch (Exception e) {
+			throw new ReadException(this.getProviderName(), e);
+		}
+	}
+
+
+	public void open() throws OpenException {
+		helper.open();
+	}
+
+	public void close() throws CloseException {
+		helper.close();
+	}
+
+	@Override
+	protected void doDispose() throws BaseException {
+		helper.dispose();
+		helper = null;
+	}
+
+	public String getProviderName() {
+		return NAME;
+	}
+
+	protected String getStoreName() {
+		return JDBCStoreProvider.NAME;
+	}
+
+	public boolean canAdd() {
+		if (this.canAdd == null){
+			ConnectionAction action = new ConnectionAction(){
+
+				public Object action(Connection conn) throws DataException {
+					try {
+					DatabaseMetaData metadata = conn.getMetaData();
+						if (metadata.isReadOnly()) {
+							return Boolean.FALSE;
+						}
+						return Boolean.TRUE;
+					} catch (SQLException e) {
+						throw new JDBCSQLException(e);
+					}
+				}
+
+			};
+
+			try {
+				this.canAdd = (Boolean) helper.doConnectionAction(action);
+			} catch (Exception e) {
+				// FIXME Exception
+				throw new RuntimeException(e);
+			}
+		}
+		return this.canAdd.booleanValue();
+	}
+
+	public FeatureType getFeatureType(DataStoreParameters dsp)
+			throws DataException {
+		checkIsMine(dsp);
+
+		// TODO: checks geometry columns and driver geometry supports
+		EditableFeatureType edType = this.getServerExplorerProviderServices()
+				.createNewFeatureType();
+		helper.loadFeatureType(edType, (JDBCStoreParameters) dsp);
+
+		return edType;
+
+	}
+
+
+	public boolean add(String providerName, NewDataStoreParameters ndsp, boolean overwrite)
+			throws DataException {
+
+		/**
+		 * CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE table_name (
+		 * { column_name data_type [ DEFAULT default_expr ] [ column_constraint
+		 * [ ... ] ] | table_constraint | LIKE parent_table [ { INCLUDING |
+		 * EXCLUDING } DEFAULTS ] } [, ... ] ) [ INHERITS ( parent_table [, ...
+		 * ] ) ] [ WITH OIDS | WITHOUT OIDS ] [ ON COMMIT { PRESERVE ROWS |
+		 * DELETE ROWS | DROP } ]
+		 *
+		 * where column_constraint is:
+		 *
+		 * [ CONSTRAINT constraint_name ] { NOT NULL | NULL | UNIQUE | PRIMARY
+		 * KEY | CHECK (expression) | REFERENCES reftable [ ( refcolumn ) ] [
+		 * MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ] [ ON DELETE action ] [ ON
+		 * UPDATE action ] } [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY
+		 * DEFERRED | INITIALLY IMMEDIATE ]
+		 *
+		 * and table_constraint is:
+		 *
+		 * [ CONSTRAINT constraint_name ] { UNIQUE ( column_name [, ... ] ) |
+		 * PRIMARY KEY ( column_name [, ... ] ) | CHECK ( expression ) | FOREIGN
+		 * KEY ( column_name [, ... ] ) REFERENCES reftable [ ( refcolumn [, ...
+		 * ] ) ] [ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ] [ ON DELETE
+		 * action ] [ ON UPDATE action ] } [ DEFERRABLE | NOT DEFERRABLE ] [
+		 * INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
+		 */
+
+		if (!(ndsp instanceof NewFeatureStoreParameters)) {
+			// FIXME exception
+			throw new IllegalArgumentException();
+		}
+		checkIsMine(ndsp);
+
+		NewFeatureStoreParameters nfdsp = (NewFeatureStoreParameters) ndsp;
+
+		StringBuilder sql = new StringBuilder();
+
+		if (!nfdsp.isValid()) {
+			// TODO Exception
+			throw new InitializeException(this.getProviderName(), new Exception(
+					"Parameters not valid"));
+		}
+		try {
+			nfdsp.validate();
+		} catch (ValidateDataParametersException e1) {
+			throw new InitializeException(this.getProviderName(), e1);
+		}
+
+		FeatureType fType = nfdsp.getDefaultFeatureType();
+
+		sql.append("Create table " + ((JDBCStoreParameters) ndsp).tableID()
+				+ "(");
+		Iterator attrs = fType.iterator();
+		String sqlAttr;
+		List sqlAttrs = new ArrayList();
+
+		while (attrs.hasNext()) {
+			sqlAttr = helper
+					.getSqlFieldDescription((FeatureAttributeDescriptor) attrs
+							.next());
+			if (sqlAttr != null) {
+				sqlAttrs.add(sqlAttr);
+			}
+		}
+
+		helper.stringJoin(sqlAttrs, ", ", sql);
+
+		sql.append(")");
+
+		final String sqlCreate = sql.toString();
+		final List sqlAdditional = helper
+				.getAdditionalSqlToCreate(ndsp, fType);
+
+		TransactionalAction action = new TransactionalAction() {
+
+			public boolean continueTransactionAllowed() {
+				// TODO Auto-generated method stub
+				return false;
+			}
+
+			public Object action(Connection conn) throws DataException {
+				Statement st = null;
+
+				try {
+					st = conn.createStatement();
+				} catch (SQLException e1) {
+					throw new JDBCSQLException(e1);
+				}
+				String sql = null;
+
+				try {
+					sql = sqlCreate;
+					st.execute(sql);
+					if (sqlAdditional != null) {
+						Iterator iter = sqlAdditional.iterator();
+						while (iter.hasNext()) {
+							sql = (String) iter.next();
+							st.execute(sql);
+						}
+					}
+
+				} catch (SQLException e) {
+					throw new JDBCExecuteSQLException(sql, e);
+				} finally {
+					try {
+						st.close();
+					} catch (SQLException e) {
+						LOG.error("Exception clossing statement", e);
+					}
+					;
+				}
+
+				return Boolean.TRUE;
+			}
+
+		};
+
+		Boolean result = Boolean.FALSE;
+
+		try {
+			result = (Boolean) helper.doConnectionAction(action);
+		} catch (Exception e) {
+			// FIXME Exception
+			throw new RuntimeException(e);
+		}
+
+		return result.booleanValue();
+	}
+
+	public List getDataStoreProviderNames() {
+		List x = new ArrayList(1);
+		x.add(JDBCStoreProvider.NAME);
+		return x;
+	}
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCServerExplorer.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCIterator.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCIterator.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCIterator.java	(revision 38285)
@@ -0,0 +1,146 @@
+/* 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.jdbc;
+
+import java.util.NoSuchElementException;
+
+import org.gvsig.fmap.dal.exception.DataException;
+import org.gvsig.fmap.dal.exception.OpenException;
+import org.gvsig.fmap.dal.feature.FeatureType;
+import org.gvsig.fmap.dal.feature.spi.AbstractFeatureProviderIterator;
+import org.gvsig.fmap.dal.feature.spi.FeatureProvider;
+import org.gvsig.tools.exception.BaseException;
+
+/**
+ * @author jmvivo
+ *
+ */
+public class JDBCIterator extends AbstractFeatureProviderIterator {
+
+	protected int resultSetID;
+	protected Boolean hasNext = null;
+	protected FeatureType featureType;
+	protected JDBCSetProvider set;
+
+	protected JDBCIterator(JDBCStoreProvider store, JDBCSetProvider set,
+			FeatureType featureType,
+			int resulsetID) throws DataException {
+		super(store);
+		this.resultSetID = resulsetID;
+		this.featureType = featureType;
+		this.set = set;
+		this.hasNext = null;
+		if (this.set != null && resulsetID >= 0){
+	        this.set.addResulsetReference(resulsetID);
+		}
+	}
+
+	private JDBCStoreProvider getJDBCStoreProvider() {
+		return (JDBCStoreProvider) getFeatureStoreProvider();
+	}
+
+    public final Object next() {
+        try {
+            getDataStoreProvider().open();
+        } catch (OpenException e) {
+            throw new RuntimeException(e);
+        }
+        return internalNext();
+    }
+
+    public final boolean hasNext() {
+        return internalHasNext();
+    }
+
+	@Override
+	protected boolean internalHasNext() {
+		if (hasNext == null) {
+			try {
+				if (getJDBCStoreProvider().resulsetNext(resultSetID)) {
+					hasNext = Boolean.TRUE;
+				} else {
+					hasNext = Boolean.FALSE;
+					this.close();
+				}
+			} catch (DataException e) {
+				// FIXME Exception
+				throw new RuntimeException(e);
+			}
+		}
+		return hasNext.booleanValue();
+	}
+
+	@Override
+	protected Object internalNext() {
+		if (!hasNext()) {
+			throw new NoSuchElementException();
+		}
+		FeatureProvider data;
+		try {
+			data = getFeatureProvider();
+		} catch (DataException e) {
+			// FIXME Exception
+			throw new RuntimeException(e);
+		}
+		hasNext = null;
+		return data;
+	}
+
+	public void remove() {
+		throw new UnsupportedOperationException();
+	}
+
+	protected FeatureProvider createFeatureProvider() throws DataException {
+		return getFeatureStoreProvider().createFeatureProvider(featureType);
+	}
+
+	protected FeatureProvider getFeatureProvider() throws DataException {
+		FeatureProvider data = createFeatureProvider();
+		getJDBCStoreProvider().loadFeatureProvider(data, resultSetID);
+		return data;
+	}
+
+	@Override
+	protected void doDispose() throws BaseException {
+		if (resultSetID >= 0){
+			this.close();
+		}
+		this.featureType = null;
+	}
+
+	protected void close() {
+		try {
+			this.set.removeResulsetReference(resultSetID);
+			getJDBCStoreProvider().closeResulset(resultSetID);
+			resultSetID = -1;
+		} catch (DataException e) {
+			throw new RuntimeException(e);
+		}
+	}
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCIterator.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCNewStoreParameters.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCNewStoreParameters.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCNewStoreParameters.java	(revision 38285)
@@ -0,0 +1,51 @@
+/* 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.jdbc;
+
+import org.gvsig.fmap.dal.feature.EditableFeatureType;
+import org.gvsig.fmap.dal.feature.FeatureType;
+import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters;
+
+public class JDBCNewStoreParameters extends JDBCStoreParameters implements
+        NewFeatureStoreParameters {
+
+    public static final String PARAMETERS_DEFINITION_NAME = "JDBCNewStoreParameters";
+
+	public JDBCNewStoreParameters() {
+    	super(PARAMETERS_DEFINITION_NAME);
+	}
+
+	public EditableFeatureType getDefaultFeatureType() {
+		return (EditableFeatureType) this.getDynValue(FEATURETYPE_PARAMTER_NAME);
+	}
+
+	public void setDefaultFeatureType(FeatureType featureType) {
+		this.setDynValue(FEATURETYPE_PARAMTER_NAME, featureType);
+	}
+
+}
\ No newline at end of file

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCNewStoreParameters.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCExecutePreparedSQLException.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCExecutePreparedSQLException.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCExecutePreparedSQLException.java	(revision 38285)
@@ -0,0 +1,102 @@
+/* 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.jdbc.exception;
+
+import java.sql.SQLException;
+import java.util.List;
+
+
+/**
+ * @author jmvivo
+ *
+ */
+public class JDBCExecutePreparedSQLException extends JDBCException {
+
+	/**
+	 *
+	 */
+	private static final long serialVersionUID = 634889167216570034L;
+
+	private final static String MESSAGE_FORMAT = "An JDBC exception was throw when execute SQL: '%(sql)' with params %(params)";
+	private final static String MESSAGE_KEY = "_JDBCExecutePreparedSQLException";
+
+	public JDBCExecutePreparedSQLException(String sql, Object[] parameters,
+			SQLException cause) {
+		super(MESSAGE_FORMAT, cause, MESSAGE_KEY, serialVersionUID);
+		setValue("sql", sql);
+		String params = "{unknow}";
+		if (parameters != null) {
+
+			StringBuilder strb = new StringBuilder();
+			strb.append('[');
+			for (int i = 0; i < parameters.length - 1; i++) {
+				strb.append(getParamValue(parameters[i]));
+				strb.append(", ");
+			}
+			strb.append(getParamValue(parameters[parameters.length - 1]));
+			strb.append(']');
+			params = strb.toString();
+		}
+		setValue("params", params);
+	}
+
+	public JDBCExecutePreparedSQLException(String sql, List parameters,
+			SQLException cause) {
+		super(MESSAGE_FORMAT, cause, MESSAGE_KEY, serialVersionUID);
+		setValue("sql", sql);
+		String params = "{unknow}";
+		if (parameters != null) {
+
+			StringBuilder strb = new StringBuilder();
+			strb.append('[');
+			for (int i = 0; i < parameters.size() - 1; i++) {
+				strb.append(getParamValue(parameters.get(i)));
+				strb.append(", ");
+			}
+			strb.append(getParamValue(parameters.get(parameters.size() - 1)));
+			strb.append(']');
+			params = strb.toString();
+		}
+		setValue("params", params);
+	}
+
+	private String getParamValue(Object param) {
+
+		if (param instanceof String) {
+			return "'" + param + "'";
+		}
+		if (param == null) {
+			return "null";
+		}
+		return param.toString();
+	}
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCExecutePreparedSQLException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCPreparingSQLException.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCPreparingSQLException.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCPreparingSQLException.java	(revision 38285)
@@ -0,0 +1,53 @@
+/* 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.jdbc.exception;
+
+import java.sql.SQLException;
+
+
+/**
+ * @author jmvivo
+ *
+ */
+public class JDBCPreparingSQLException extends JDBCException {
+
+	/**
+	 *
+	 */
+	private static final long serialVersionUID = 396002379466607941L;
+	private final static String MESSAGE_FORMAT = "An JDBC exception was throw when preparing SQL: %(sql)";
+	private final static String MESSAGE_KEY = "_JDBCPreparingSQLException";
+
+	public JDBCPreparingSQLException(String sql, SQLException cause) {
+		super(MESSAGE_FORMAT, cause, MESSAGE_KEY, serialVersionUID);
+		setValue("sql", sql);
+	}
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCPreparingSQLException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/InvalidResultSetIdException.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/InvalidResultSetIdException.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/InvalidResultSetIdException.java	(revision 38285)
@@ -0,0 +1,19 @@
+package org.gvsig.fmap.dal.store.jdbc.exception;
+
+import org.gvsig.fmap.dal.exception.DataException;
+
+public class InvalidResultSetIdException extends DataException {
+
+	/**
+	 *
+	 */
+	private static final long serialVersionUID = 6819010675588720112L;
+
+	private final static String MESSAGE_FORMAT = "ResultSet id (%(id)s) invalid or closed.";
+	private final static String MESSAGE_KEY = "_InvalidResultSetIdException";
+
+	public InvalidResultSetIdException(int id) {
+		super(MESSAGE_FORMAT, MESSAGE_KEY, serialVersionUID);
+		setValue("id", id + "");
+	}
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/InvalidResultSetIdException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCDriverClassNotFoundException.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCDriverClassNotFoundException.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCDriverClassNotFoundException.java	(revision 38285)
@@ -0,0 +1,47 @@
+/* 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.jdbc.exception;
+
+import org.gvsig.fmap.dal.exception.InitializeException;
+
+public class JDBCDriverClassNotFoundException extends InitializeException {
+
+	/**
+	 *
+	 */
+	private static final long serialVersionUID = 3667181771913616775L;
+	private final static String MESSAGE_FORMAT = "Exception intializing '%(resource)': JDBC driver class not found: '%(className)'.";
+	private final static String MESSAGE_KEY = "_InitializeException";
+
+	public JDBCDriverClassNotFoundException(String resource, String className) {
+		super(MESSAGE_FORMAT, MESSAGE_KEY, serialVersionUID);
+		setValue("resource", resource);
+		setValue("className", className);
+	}
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCDriverClassNotFoundException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCTransactionCommitException.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCTransactionCommitException.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCTransactionCommitException.java	(revision 38285)
@@ -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.
+*
+*/
+
+/*
+* AUTHORS (In addition to CIT):
+* 2009 IVER T.I   {{Task}}
+*/
+
+/**
+ *
+ */
+package org.gvsig.fmap.dal.store.jdbc.exception;
+
+
+
+/**
+ * @author jmvivo
+ *
+ */
+public class JDBCTransactionCommitException extends JDBCException {
+
+	/**
+	 *
+	 */
+	private static final long serialVersionUID = 1983159118684700720L;
+	private final static String MESSAGE_FORMAT = "An excetion was throw in commit";
+	private final static String MESSAGE_KEY = "_JDBCTransactionCommitException";
+
+
+
+	public JDBCTransactionCommitException(Exception cause) {
+		super(MESSAGE_FORMAT, cause, MESSAGE_KEY, serialVersionUID);
+	}
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCTransactionCommitException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCException.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCException.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCException.java	(revision 38285)
@@ -0,0 +1,57 @@
+/* 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.jdbc.exception;
+
+import org.gvsig.fmap.dal.exception.DataException;
+
+/**
+ * @author jmvivo
+ *
+ */
+public abstract class JDBCException extends DataException {
+
+	/**
+	 *
+	 */
+	private static final long serialVersionUID = 4083959722123051090L;
+
+
+	protected JDBCException(String messageFormat, Throwable cause,
+			String messageKey, long code) {
+		super(messageFormat, cause, messageKey, code);
+	}
+
+	protected JDBCException(String messageFormat, String messageKey,
+			long code) {
+		super(messageFormat, messageKey, code);
+	}
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCSQLException.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCSQLException.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCSQLException.java	(revision 38285)
@@ -0,0 +1,49 @@
+/* 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.jdbc.exception;
+
+import java.sql.SQLException;
+
+
+public class JDBCSQLException extends JDBCException {
+
+
+	/**
+	 *
+	 */
+	private static final long serialVersionUID = 3706210974175686915L;
+	private final static String MESSAGE_FORMAT = "An JDBC driver exception was throw";
+	private final static String MESSAGE_KEY = "_JDBCSQLException";
+
+
+
+	public JDBCSQLException(SQLException cause) {
+		super(MESSAGE_FORMAT, cause, MESSAGE_KEY, serialVersionUID);
+	}
+
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCTransactionRollbackException.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCTransactionRollbackException.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCTransactionRollbackException.java	(revision 38285)
@@ -0,0 +1,56 @@
+/* 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.jdbc.exception;
+
+import org.gvsig.fmap.dal.exception.DataListException;
+
+
+
+/**
+ * @author jmvivo
+ *
+ */
+public class JDBCTransactionRollbackException extends DataListException {
+
+	/**
+	 *
+	 */
+	private static final long serialVersionUID = 1983159118684700720L;
+	private final static String MESSAGE_FORMAT = "An excetion was throw in rollback";
+	private final static String MESSAGE_KEY = "_JDBCTransactionRollbackException";
+
+
+	public JDBCTransactionRollbackException(Throwable cause, Throwable original) {
+		super(MESSAGE_FORMAT, cause, MESSAGE_KEY, serialVersionUID);
+		this.add(original);
+	}
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCTransactionRollbackException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCUpdateWithoutChangesException.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCUpdateWithoutChangesException.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCUpdateWithoutChangesException.java	(revision 38285)
@@ -0,0 +1,64 @@
+/* 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.jdbc.exception;
+
+import java.util.List;
+
+
+
+public class JDBCUpdateWithoutChangesException extends JDBCException {
+
+
+	/**
+	 *
+	 */
+	private static final long serialVersionUID = 3706210974175686915L;
+	private final static String MESSAGE_FORMAT = "An update SQL statement has no efect: SQL=\"{sql}\" Values='{sqlValues}'";
+	private final static String MESSAGE_KEY = "_JDBCUpdateWithoutChangesException";
+
+
+	public JDBCUpdateWithoutChangesException(String sql, List values) {
+		super(MESSAGE_FORMAT, MESSAGE_KEY, serialVersionUID);
+		this.setValue("sql", sql);
+		if (values == null || values.size() == 0) {
+			this.setValue("sqlValues", "[]");
+		} else {
+			StringBuffer buff = new StringBuffer();
+			buff.append('[');
+			for (int i = 0; i < values.size() - 1; i++) {
+				buff.append(values.get(i));
+				buff.append(',');
+			}
+			buff.append(values.get(values.size() - 1));
+			buff.append(']');
+			this.setValue("sqlValues", buff.toString());
+		}
+
+	}
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCUpdateWithoutChangesException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCExecuteSQLException.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCExecuteSQLException.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCExecuteSQLException.java	(revision 38285)
@@ -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.
+*
+*/
+
+/*
+* AUTHORS (In addition to CIT):
+* 2009 IVER T.I   {{Task}}
+*/
+
+/**
+ *
+ */
+package org.gvsig.fmap.dal.store.jdbc.exception;
+
+import java.sql.SQLException;
+
+
+/**
+ * @author jmvivo
+ *
+ */
+public class JDBCExecuteSQLException extends JDBCException {
+
+	/**
+	 *
+	 */
+	private static final long serialVersionUID = 634889167216570034L;
+
+	private final static String MESSAGE_FORMAT = "An JDBC exception was throw when execute SQL: %(sql)";
+	private final static String MESSAGE_KEY = "_JDBCExecuteSQLException";
+
+	public JDBCExecuteSQLException(String sql, SQLException cause) {
+		super(MESSAGE_FORMAT, cause, MESSAGE_KEY, serialVersionUID);
+		setValue("sql", sql);
+	}
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/exception/JDBCExecuteSQLException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCStoreProviderWriter.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCStoreProviderWriter.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCStoreProviderWriter.java	(revision 38285)
@@ -0,0 +1,734 @@
+/* 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.jdbc;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.gvsig.fmap.dal.exception.DataException;
+import org.gvsig.fmap.dal.exception.InitializeException;
+import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
+import org.gvsig.fmap.dal.feature.FeatureType;
+import org.gvsig.fmap.dal.feature.exception.PerformEditingException;
+import org.gvsig.fmap.dal.feature.spi.FeatureProvider;
+import org.gvsig.fmap.dal.feature.spi.FeatureReferenceProviderServices;
+import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
+import org.gvsig.fmap.dal.store.db.FeatureTypeHelper;
+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.dal.store.jdbc.exception.JDBCUpdateWithoutChangesException;
+import org.gvsig.tools.dynobject.DynObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author jmvivo
+ *
+ */
+public class JDBCStoreProviderWriter extends JDBCStoreProvider {
+
+	final static private Logger logger = LoggerFactory
+			.getLogger(JDBCStoreProviderWriter.class);
+
+
+	protected String appendModeSql;
+	protected List<FeatureAttributeDescriptor> appendModeAttributes;
+
+
+	public JDBCStoreProviderWriter(JDBCStoreParameters params,
+			DataStoreProviderServices storeServices)
+			throws InitializeException {
+		super(params, storeServices);
+	}
+
+	protected JDBCStoreProviderWriter(JDBCStoreParameters params,
+			DataStoreProviderServices storeServices, DynObject metadata)
+			throws InitializeException {
+		super(params, storeServices, metadata);
+	}
+
+
+
+	protected void addToListFeatureValues(FeatureProvider featureProvider,
+			FeatureAttributeDescriptor attrOfList,
+			FeatureAttributeDescriptor attr, List<Object> values) throws DataException {
+		if (attr == null) {
+			if (attrOfList.isPrimaryKey()) {
+				throw new RuntimeException("pk attribute '"
+						+ attrOfList.getName() + "' not found in feature");
+			}
+			values.add(helper
+					.dalValueToJDBC(attr, attrOfList.getDefaultValue()));
+		} else {
+			values.add(helper.dalValueToJDBC(attr, featureProvider.get(attr
+					.getIndex())));
+		}
+
+	}
+
+	protected void addToListFeatureValues(FeatureProvider featureProvider,
+			List<FeatureAttributeDescriptor> attributes, List<Object> values) throws DataException {
+		FeatureAttributeDescriptor attr, attrOfList;
+		FeatureType fType = featureProvider.getType();
+		for (int i = 0; i < attributes.size(); i++) {
+			attrOfList = (FeatureAttributeDescriptor) attributes.get(i);
+			attr = fType.getAttributeDescriptor(attrOfList.getName());
+			addToListFeatureValues(featureProvider, attrOfList, attr, values);
+		}
+	}
+
+	protected void appendToSQLPreparedPkWhereClause(StringBuilder sql,
+			List<FeatureAttributeDescriptor> pkAttributes) {
+		sql.append(" Where ");
+		FeatureAttributeDescriptor attr;
+		for (int i = 0; i < pkAttributes.size() - 1; i++) {
+			attr = (FeatureAttributeDescriptor) pkAttributes.get(i);
+			sql.append(helper.escapeFieldName(attr.getName()));
+			sql.append(" = ? AND ");
+		}
+		attr = (FeatureAttributeDescriptor) pkAttributes.get(pkAttributes
+				.size() - 1);
+		sql.append(helper.escapeFieldName(attr.getName()));
+		sql.append(" = ? ");
+	}
+
+	protected void executeRemovePreparedStatement(Connection conn, String sql,
+			List<FeatureAttributeDescriptor> attributes, Iterator<FeatureReferenceProviderServices> featureReferences) throws DataException {
+				PreparedStatement st;
+				try {
+					st = conn.prepareStatement(sql);
+				} catch (SQLException e) {
+					throw new JDBCPreparingSQLException(sql, e);
+				}
+				try {
+					List<Object> values = new ArrayList<Object>();
+					FeatureReferenceProviderServices featureRef;
+//					FeatureType featureType;
+					while (featureReferences.hasNext()) {
+						st.clearParameters();
+						featureRef = featureReferences.next();
+						values.clear();
+//						featureType = this.getFeatureStore()
+//							.getFeatureType(featureRef.getFeatureTypeId());
+
+						Iterator<FeatureAttributeDescriptor> iter = attributes.iterator();
+						FeatureAttributeDescriptor attr;
+						while (iter.hasNext()) {
+							attr =  iter.next();
+							values.add( helper.dalValueToJDBC(attr, featureRef
+									.getKeyValue(attr.getName())));
+						}
+
+						for (int i = 0; i < values.size(); i++) {
+							st.setObject(i + 1, values.get(i));
+						}
+						try {
+							int nAffected =st.executeUpdate();
+							if (nAffected == 0) {
+								throw new JDBCUpdateWithoutChangesException(sql, values);
+							}
+							if (nAffected > 1){
+								logger.warn("Remove statement affectst to {} rows: {}",
+										nAffected, sql);
+							}
+
+						} catch (SQLException e) {
+							throw new JDBCExecutePreparedSQLException(sql, values, e);
+						}
+
+					}
+				} catch (SQLException e) {
+					throw new JDBCSQLException(e);
+				} finally {
+					try {st.close();} catch (SQLException e) {	};
+				}
+
+			}
+
+	protected void executeUpdatePreparedStatement(Connection conn, String sql,
+			List<FeatureAttributeDescriptor> attributes, Iterator<FeatureProvider> featureProviders) throws DataException {
+				PreparedStatement st;
+				try {
+					st = conn.prepareStatement(sql);
+				} catch (SQLException e) {
+					throw new JDBCPreparingSQLException(sql, e);
+				}
+				try {
+					List<Object> values = new ArrayList<Object>();
+					FeatureProvider featureProvider;
+					while (featureProviders.hasNext()) {
+						st.clearParameters();
+						featureProvider = (FeatureProvider) featureProviders.next();
+						values.clear();
+						addToListFeatureValues(featureProvider, attributes, values);
+						for (int i = 0; i < values.size(); i++) {
+							st.setObject(i + 1, values.get(i));
+						}
+						try {
+							if (st.executeUpdate() == 0) {
+								throw new JDBCUpdateWithoutChangesException(sql, values);
+							}
+						} catch (SQLException e) {
+							throw new JDBCExecutePreparedSQLException(sql, values, e);
+						}
+
+					}
+				} catch (SQLException e) {
+					throw new JDBCSQLException(e);
+				} finally {
+					try {st.close();} catch (SQLException e) {	};
+				}
+
+			}
+
+	protected void performDeletes(Connection conn, Iterator<FeatureReferenceProviderServices> deleteds, List<FeatureAttributeDescriptor> pkAttributes)
+			throws DataException {
+
+				if (pkAttributes.size() < 0) {
+					throw new RuntimeException("Operation requires missing pk");
+				}
+
+				// ************ Prepare SQL ****************
+				StringBuilder sqlb = new StringBuilder();
+				sqlb.append("Delete from ");
+				sqlb.append(getJDBCParameters().tableID());
+				appendToSQLPreparedPkWhereClause(sqlb, pkAttributes);
+				String sql = sqlb.toString();
+				// ************ Prepare SQL (end) ****************
+
+				executeRemovePreparedStatement(conn, sql, pkAttributes, deleteds);
+			}
+
+	protected String getSqlStatementAddField(FeatureAttributeDescriptor attr,
+			List<String> additionalStatement) throws DataException {
+		StringBuilder strb = new StringBuilder();
+		strb.append("ADD ");
+		strb.append(this.helper.getSqlFieldDescription(attr));
+		return strb.toString();
+	}
+
+	protected String getSqlStatementDropField(FeatureAttributeDescriptor attr,List<String> additionalStatement) {
+		// DROP [ COLUMN ] column
+		return " DROP COLUMN "
+				+ this.helper.escapeFieldName(attr.getName());
+
+	}
+
+	public boolean supportsAppendMode() {
+		return true;
+	}
+
+	public void endAppend() throws DataException {
+		appendModeSql = null;
+		appendModeAttributes = null;
+	}
+
+	protected List<String> getSqlStatementAlterField(
+			FeatureAttributeDescriptor attrOrg,
+			FeatureAttributeDescriptor attrTrg, List<String> additionalStatement)
+			throws DataException {
+		//
+		List<String> actions = new ArrayList<String>();
+		StringBuilder strb;
+		if (attrOrg.getDataType() != attrTrg.getDataType()) {
+			// ALTER COLUMN {col} TYPE {type} character varying(35)
+			strb = new StringBuilder();
+			strb.append("ALTER COLUMN ");
+			strb.append(helper.escapeFieldName(attrTrg.getName()));
+			strb.append(" ");
+			strb.append(helper.getSqlColumnTypeDescription(attrTrg));
+
+			actions.add(strb.toString());
+		}
+
+		if (attrOrg.allowNull() != attrTrg.allowNull()) {
+			// ALTER [ COLUMN ] column { SET | DROP } NOT NULL
+
+			strb = new StringBuilder();
+			strb.append("ALTER COLUMN ");
+			strb.append(helper.escapeFieldName(attrTrg.getName()));
+			strb.append(' ');
+			if (attrTrg.allowNull()) {
+				strb.append("SET ");
+			} else {
+				strb.append("DROP ");
+			}
+			strb.append("NOT NULL");
+			actions.add(strb.toString());
+		}
+
+		if (attrOrg.getDefaultValue() != attrTrg.getDefaultValue()) {
+			if (attrTrg.getDefaultValue() == null) {
+				// ALTER [ COLUMN ] column DROP DEFAULT
+
+				strb = new StringBuilder();
+				strb.append("ALTER COLUMN ");
+				strb.append(helper.escapeFieldName(attrTrg.getName()));
+				strb.append(" DROP DEFAULT");
+				actions.add(strb.toString());
+			} else if (!attrTrg.getDefaultValue().equals(
+					attrOrg.getDefaultValue())) {
+				// ALTER [ COLUMN ] column DROP DEFAULT
+
+				strb = new StringBuilder();
+				strb.append("ALTER COLUMN ");
+				strb.append(helper.escapeFieldName(attrTrg.getName()));
+				strb.append(" SET DEFAULT");
+				strb.append(helper.dalValueToJDBC(attrTrg, attrTrg
+						.getDefaultValue()));
+				actions.add(strb.toString());
+			}
+		}
+
+		return actions;
+	}
+
+	protected void performUpdateTable(Connection conn, FeatureType original,
+			FeatureType target) throws DataException {
+
+		/*
+		 *
+		 * ALTER TABLE [ ONLY ] name [ * ] action [, ... ]
+		 */
+
+		List<String> toDrop = new ArrayList<String>();
+		List<String> toAdd = new ArrayList<String>();
+		List<String> toAlter = new ArrayList<String>();
+
+		List<String> additionalStatement = new ArrayList<String>();
+
+		FeatureAttributeDescriptor attrOrg;
+		FeatureAttributeDescriptor attrTrg;
+		Iterator<FeatureAttributeDescriptor> attrs = FeatureTypeHelper.iterator(original);
+		while (attrs.hasNext()) {
+			attrOrg = (FeatureAttributeDescriptor) attrs.next();
+			attrTrg = target.getAttributeDescriptor(attrOrg.getName());
+			if (attrTrg == null) {
+				toDrop.add(getSqlStatementDropField(attrOrg,
+						additionalStatement));
+			} else {
+				toAlter.addAll(getSqlStatementAlterField(attrOrg, attrTrg,additionalStatement));
+			}
+
+		}
+		attrs = FeatureTypeHelper.iterator(target);
+		while (attrs.hasNext()) {
+			attrTrg = (FeatureAttributeDescriptor) attrs.next();
+			if (original.getAttributeDescriptor(attrTrg.getName()) == null) {
+				toAdd.add(getSqlStatementAddField(attrTrg,
+								additionalStatement));
+			}
+		}
+
+		StringBuilder sqlb = new StringBuilder();
+
+		sqlb.append("ALTER TABLE ");
+		sqlb.append(getJDBCParameters().tableID());
+		sqlb.append(' ');
+
+		List<String> actions = new ArrayList<String>();
+		actions.addAll(toDrop);
+		actions.addAll(toAlter);
+		actions.addAll(toAdd);
+
+		Iterator<String> it = actions.iterator();
+		while (it.hasNext()) {
+			if (it.next() == null) {
+				it.remove();
+			}
+		}
+
+		it = additionalStatement.iterator();
+		while (it.hasNext()) {
+			if (it.next() == null) {
+				it.remove();
+			}
+		}
+
+		if (actions.size() < 1) {
+			return;
+		}
+
+		helper.stringJoin(actions, ", ", sqlb);
+
+		String sql = sqlb.toString();
+
+		Statement st = null;
+
+		try {
+			st = conn.createStatement();
+		} catch (SQLException e1) {
+			throw new JDBCSQLException(e1);
+		}
+		try {
+			st.execute(sql);
+			Iterator<String> iter = additionalStatement.iterator();
+			while (iter.hasNext()) {
+				sql = (String) iter.next();
+				st.execute(sql);
+			}
+		} catch (SQLException e1) {
+			throw new JDBCExecuteSQLException(sql, e1);
+		} finally {
+			try {
+				st.close();
+			} catch (Exception e) {
+				logger.error("Exception closing statement", e);
+			}
+			;
+		}
+
+	}
+
+
+	private void perfomInsert(Connection conn, PreparedStatement insertSt,
+			String sql, FeatureProvider feature, List<FeatureAttributeDescriptor> attributes)
+			throws DataException {
+
+		try {
+			insertSt.clearParameters();
+			List<Object> values = new ArrayList<Object>();
+			addToListFeatureValues(feature, attributes, values);
+//			FeatureAttributeDescriptor attr;
+			int j = 1;
+			for (int i = 0; i < values.size(); i++) {
+				insertSt.setObject(j, values.get(i));
+				j++;
+			}
+			if (logger.isDebugEnabled()) {
+				logger.debug("Executing insert. sql={} value={}", new Object[] {
+						sql, values });
+			}
+			try {
+				insertSt.execute();
+			} catch (SQLException e) {
+				throw new JDBCExecutePreparedSQLException(sql, values, e);
+			}
+
+		} catch (SQLException e1) {
+			throw new JDBCSQLException(e1);
+		}
+	}
+
+	public void append(final FeatureProvider featureProvider) throws DataException {
+		TransactionalAction action = new TransactionalAction() {
+			public Object action(Connection conn) throws DataException {
+
+				PreparedStatement st;
+				try {
+					st = conn.prepareStatement(appendModeSql);
+				} catch (SQLException e) {
+					throw new JDBCPreparingSQLException(appendModeSql, e);
+				}
+				try {
+					perfomInsert(conn, st, appendModeSql, featureProvider,
+							appendModeAttributes);
+				} finally {
+					try {
+						st.close();
+					} catch (SQLException e) {
+					}
+					;
+				}
+				return null;
+			}
+
+			public boolean continueTransactionAllowed() {
+				return false;
+			}
+		};
+		try {
+			this.helper.doConnectionAction(action);
+
+			resetCount();
+
+		} catch (Exception e) {
+			throw new PerformEditingException(this.getProviderName(), e);
+		}
+	}
+
+	protected void prepareAttributeForUpdate(FeatureAttributeDescriptor attr,
+			List<String> values) {
+		values.add(helper.escapeFieldName(attr.getName()) + " = ?");
+	}
+
+	protected void prepareAttributeForInsert(FeatureAttributeDescriptor attr,
+			List<String> fields, List<String> values) {
+
+		fields.add(helper.escapeFieldName(attr.getName()));
+		values.add("?");
+
+	}
+
+
+	protected void prepareSQLAndAttributeListForInsert(StringBuilder sqlb,
+			List<FeatureAttributeDescriptor> attributes) throws DataException {
+		/*
+		 * INSERT INTO table [ ( column [, ...] ) ] { DEFAULT VALUES | VALUES (
+		 * { expression | DEFAULT } [, ...] ) [, ...] | query } [ RETURNING * |
+		 * output_expression [ AS output_name ] [, ...] ]
+		 */
+
+		sqlb.append("INSERT INTO ");
+		sqlb.append(getJDBCParameters().tableID());
+
+		sqlb.append(" (");
+
+		FeatureType type = this.getFeatureStore().getDefaultFeatureType();
+
+		List<String> fields = new ArrayList<String>();
+		List<String> values = new ArrayList<String>();
+
+		Iterator<FeatureAttributeDescriptor> iter = FeatureTypeHelper.iterator(type);
+		FeatureAttributeDescriptor attr;
+		while (iter.hasNext()) {
+			attr = iter.next();
+			if (attr.isAutomatic() || attr.isReadOnly()) {
+				continue;
+			}
+			attributes.add(attr);
+			prepareAttributeForInsert(attr, fields, values);
+
+		}
+		if (attributes.size() < 1) {
+			throw new RuntimeException("no fields to set");
+		}
+
+		helper.stringJoin(fields, ", ", sqlb);
+
+		sqlb.append(") VALUES (");
+		helper.stringJoin(values, ", ", sqlb);
+
+		sqlb.append(") ");
+
+	}
+
+
+	protected void performInserts(Connection conn, Iterator<FeatureProvider> inserteds)
+			throws DataException {
+
+		StringBuilder sqlb = new StringBuilder();
+		List<FeatureAttributeDescriptor> attrs = new ArrayList<FeatureAttributeDescriptor>();
+
+		prepareSQLAndAttributeListForInsert(sqlb, attrs);
+
+		String sql = sqlb.toString();
+		PreparedStatement st;
+		try {
+			st = conn.prepareStatement(sql);
+		} catch (SQLException e) {
+			throw new JDBCPreparingSQLException(sql, e);
+		}
+		try {
+			while (inserteds.hasNext()) {
+				perfomInsert(conn, st, sql, inserteds.next(),
+						attrs);
+			}
+		} finally {
+			try {st.close();} catch (SQLException e) {logger.error("Error closing statement", e);};
+		}
+	}
+
+	protected void performUpdates(Connection conn, Iterator<FeatureProvider> updateds,
+			List<FeatureAttributeDescriptor> pkAttributes) throws DataException {
+		/*
+		 * UPDATE [ ONLY ] table [ [ AS ] alias ] SET { column = { expression |
+		 * DEFAULT } | ( column [, ...] ) = ( { expression | DEFAULT } [, ...] )
+		 * } [, ...] [ FROM fromlist ] [ WHERE condition ] [ RETURNING * |
+		 * output_expression [ AS output_name ] [, ...] ]
+		 */
+
+		if (pkAttributes.size() < 0) {
+			throw new RuntimeException("Operation requires missing pk");
+		}
+
+		// ************ Prepare SQL ****************
+
+		StringBuilder sqlb = new StringBuilder();
+		sqlb.append("UPDATE ");
+		sqlb.append(getJDBCParameters().tableID());
+
+		sqlb.append(" SET ");
+
+		List<String> values = new ArrayList<String>();
+
+		FeatureType type = this.getFeatureStore().getDefaultFeatureType();
+
+		Iterator<FeatureAttributeDescriptor> iter = FeatureTypeHelper.iterator(type);
+		FeatureAttributeDescriptor attr;
+		List<FeatureAttributeDescriptor> updateAttrs = new ArrayList<FeatureAttributeDescriptor>();
+		while (iter.hasNext()) {
+			attr = iter.next();
+			if (attr.isPrimaryKey() || attr.isAutomatic() || attr.isReadOnly()) {
+				continue;
+			}
+			updateAttrs.add(attr);
+			prepareAttributeForUpdate(attr, values);
+
+		}
+		if (updateAttrs.size() < 1) {
+			throw new RuntimeException("no fields to set");
+		}
+
+		helper.stringJoin(values, ", ", sqlb);
+
+		sqlb.append(' ');
+		appendToSQLPreparedPkWhereClause(sqlb, pkAttributes);
+
+		String sql = sqlb.toString();
+		// ************ Prepare SQL (end) ****************
+
+		updateAttrs.addAll(pkAttributes);
+
+		executeUpdatePreparedStatement(conn, sql, updateAttrs, updateds);
+	}
+
+
+	public void beginAppend() throws DataException {
+		StringBuilder sqlb = new StringBuilder();
+		List<FeatureAttributeDescriptor> attrs = new ArrayList<FeatureAttributeDescriptor>();
+
+		prepareSQLAndAttributeListForInsert(sqlb, attrs);
+
+		appendModeSql = sqlb.toString();
+		appendModeAttributes = attrs;
+	}
+
+
+	protected TransactionalAction getPerformChangesAction(
+			final Iterator<FeatureReferenceProviderServices> deleteds, 
+			final Iterator<FeatureProvider> inserteds,
+			final Iterator<FeatureProvider> updateds, 
+			final Iterator<FeatureTypeChanged> featureTypesChanged) {
+
+		TransactionalAction action = new TransactionalAction() {
+
+			public Object action(Connection conn) throws DataException {
+
+				if (featureTypesChanged.hasNext()) {
+
+					FeatureTypeChanged item = featureTypesChanged.next();
+					performUpdateTable(conn, item.getSource(), item.getTarget());
+				}
+
+				List<FeatureAttributeDescriptor> pkAttributes = null;
+				if (deleteds.hasNext() || updateds.hasNext()) {
+					pkAttributes = Arrays.asList(getFeatureStore()
+							.getDefaultFeatureType()
+							.getPrimaryKey());
+				}
+
+				if (deleteds.hasNext()) {
+					performDeletes(conn, deleteds, pkAttributes);
+				}
+
+				if (updateds.hasNext()) {
+					performUpdates(conn, updateds, pkAttributes);
+				}
+
+				if (inserteds.hasNext()) {
+					performInserts(conn, inserteds);
+				}
+
+				return null;
+			}
+
+			public boolean continueTransactionAllowed() {
+				return false;
+			}
+
+		};
+
+		return action;
+
+	}
+
+	@SuppressWarnings("unchecked")
+	public void performChanges(Iterator deleteds, Iterator inserteds,
+			Iterator updateds, Iterator featureTypesChanged)
+			throws PerformEditingException {
+
+		boolean countChanged = deleteds.hasNext() || inserteds.hasNext();
+
+		try {
+			this.helper.doConnectionAction(getPerformChangesAction(deleteds,
+					inserteds, updateds, featureTypesChanged));
+
+			this.initFeatureType();
+			if (countChanged) {
+				resetCount();
+			}
+
+		} catch (Exception e) {
+			throw new PerformEditingException(this.getProviderName(), e);
+		}
+	}
+
+
+	public boolean allowWrite() {
+		if (directSQLMode) {
+			return false;
+		}
+		if (getJDBCParameters().getPkFields() == null
+				|| getJDBCParameters().getPkFields().length > 0) {
+			FeatureType ft = null;
+			try {
+				ft = this.getFeatureStore().getDefaultFeatureType();
+			} catch (DataException e) {
+				logger.error("Excepton get default Feature Type", e);
+			}
+
+			if (ft == null) {
+				return false;
+			}
+			FeatureAttributeDescriptor attr;
+			Iterator<FeatureAttributeDescriptor> iter = FeatureTypeHelper.iterator(ft);
+			while (iter.hasNext()) {
+				attr = (FeatureAttributeDescriptor) iter.next();
+				if (attr.isPrimaryKey()) {
+					return true;
+				}
+			}
+			return false;
+
+		} else {
+			return true;
+		}
+	}
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCStoreProviderWriter.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCLibrary.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCLibrary.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCLibrary.java	(revision 38285)
@@ -0,0 +1,123 @@
+/* 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.jdbc;
+
+import org.gvsig.fmap.dal.DALLibrary;
+import org.gvsig.fmap.dal.DALLocator;
+import org.gvsig.fmap.dal.resource.db.DBResourceLibrary;
+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.db.DBStoreLibrary;
+import org.gvsig.metadata.exceptions.MetadataException;
+import org.gvsig.tools.library.AbstractLibrary;
+import org.gvsig.tools.library.LibraryException;
+
+/**
+ * Initialize JDBC Provider Library
+ * 
+ * @author jmvivo
+ *
+ */
+public class JDBCLibrary extends AbstractLibrary {
+
+    @Override
+    public void doRegistration() {
+        registerAsServiceOf(DALLibrary.class);
+        require(DBStoreLibrary.class);
+        require(DBResourceLibrary.class);
+    }
+
+	@Override
+	protected void doInitialize() throws LibraryException {
+	}
+
+	@Override
+	protected void doPostInitialize() throws LibraryException {
+		LibraryException ex=null;
+		
+		DBHelper.registerParametersDefinition(
+				 JDBCStoreParameters.PARAMETERS_DEFINITION_NAME,
+				 JDBCStoreParameters.class,
+				 "JDBCParameters.xml"
+		);
+		DBHelper.registerParametersDefinition(
+				JDBCNewStoreParameters.PARAMETERS_DEFINITION_NAME,
+				JDBCNewStoreParameters.class,
+				"JDBCParameters.xml"
+		);
+		DBHelper.registerParametersDefinition(
+				JDBCServerExplorerParameters.PARAMETERS_DEFINITION_NAME, 
+				JDBCServerExplorerParameters.class, 
+				"JDBCParameters.xml"
+		);
+		DBHelper.registerParametersDefinition(
+				JDBCResourceParameters.PARAMETERS_DEFINITION_NAME, 
+				JDBCResourceParameters.class, 
+				"JDBCParameters.xml"
+		);
+		
+		try {
+			DBHelper.registerMetadataDefinition(
+					JDBCStoreProvider.METADATA_DEFINITION_NAME, 
+					JDBCStoreProvider.class, 
+					"JDBCMetadata.xml"
+			);
+		} catch (MetadataException e) {
+			ex = new LibraryException(this.getClass(),e);
+		}
+		
+		
+    	ResourceManagerProviderServices resman = (ResourceManagerProviderServices) DALLocator
+		.getResourceManager();
+
+		if (!resman.getResourceProviders().contains(JDBCResource.NAME)) {
+			resman.register(JDBCResource.NAME, JDBCResource.DESCRIPTION,
+					JDBCResource.class, JDBCResourceParameters.class);
+		}
+		
+		DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator
+				.getDataManager();
+		
+		
+		if (!dataman.getStoreProviders().contains(JDBCStoreProvider.NAME)) {
+			dataman.registerStoreProvider(JDBCStoreProvider.NAME,
+					JDBCStoreProviderWriter.class, JDBCStoreParameters.class);
+		}
+		
+		if (!dataman.getExplorerProviders().contains(JDBCStoreProvider.NAME)) {
+			dataman.registerExplorerProvider(JDBCServerExplorer.NAME,
+					JDBCServerExplorer.class,
+					JDBCServerExplorerParameters.class);
+		}
+		
+		if( ex!=null ) {
+			throw ex;
+		}
+	}
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCLibrary.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCSetProvider.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCSetProvider.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCSetProvider.java	(revision 38285)
@@ -0,0 +1,417 @@
+/* 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.jdbc;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+import org.gvsig.fmap.dal.DataTypes;
+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.FeatureQueryOrder;
+import org.gvsig.fmap.dal.feature.FeatureType;
+import org.gvsig.fmap.dal.feature.FeatureQueryOrder.FeatureQueryOrderMember;
+import org.gvsig.fmap.dal.feature.spi.AbstractFeatureSetProvider;
+import org.gvsig.tools.evaluator.Evaluator;
+import org.gvsig.tools.evaluator.EvaluatorFieldValue;
+import org.gvsig.tools.evaluator.EvaluatorFieldsInfo;
+import org.gvsig.tools.exception.BaseException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author jmvivo
+ *
+ */
+public class JDBCSetProvider extends AbstractFeatureSetProvider {
+
+	final static private Logger logger = LoggerFactory
+			.getLogger(JDBCSetProvider.class);
+
+	protected String filter;
+	protected String order;
+	protected Long size = null;
+	protected Boolean isEmpty = null;
+
+	protected List resultSetIDReferenced;
+
+	private JDBCHelper helper = null;
+
+	private int defaultFetchSize = 1000;
+
+	private long limit = -1l;
+
+    private boolean directSQLMode;
+
+	public JDBCSetProvider(JDBCStoreProvider store, FeatureQuery query,
+			FeatureType featureType) throws DataException {
+		super(store, query, featureType);
+		this.helper = store.getHelper();
+		this.resultSetIDReferenced = new ArrayList();
+		this.directSQLMode =  store.isDirectSQLMode();
+	
+		if (query.hasFilter() && this.canFilter()) {
+			setFilter(query.getFilter());
+		} else {
+			setFilter(null);
+		}
+
+		if (query.hasOrder() && canOrder()) {
+			setOrder(query.getOrder());
+		} else {
+			setOrder(null);
+		}
+
+		if (query != null) {
+			limit = query.getLimit();
+		}
+	}
+
+	/**
+	 * @return the defaultFetchSize
+	 */
+	public int getDefaultFetchSize() {
+		return defaultFetchSize;
+	}
+
+	/**
+	 * @param defaultFetchSize
+	 *            the defaultFetchSize to set
+	 */
+	public void setDefaultFetchSize(int defaultFetchSize) {
+		this.defaultFetchSize = defaultFetchSize;
+	}
+
+	protected String getSqlForEvaluator(Evaluator filter) {
+		if (filter == null) {
+			return null;
+		}
+		EvaluatorFieldsInfo info = filter.getFieldsInfo();
+		String filterString = filter.getSQL();
+		if (info == null) {
+			return filterString;
+		}
+		String[] filterNames = info.getFieldNames();
+		String[] finalNames = new String[filterNames.length];
+		EvaluatorFieldValue[] fValues;
+
+		List values = new ArrayList();
+
+		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.replaceAll("\\b" + filterNames[i] + "\\b",
+						finalNames[i]);
+			}
+		}
+
+		return filterString;
+	}
+
+
+	protected String getEscapedFieldName(String fieldName) {
+		if (helper == null) {
+			helper = getJDBCStoreProvider().getHelper();
+		}
+		return helper.escapeFieldName(fieldName);
+	}
+
+
+	protected void setOrder(FeatureQueryOrder order) {
+		if (order == null || order.size() == 0) {
+			this.order = null;
+			return;
+		}
+
+		StringBuilder buffer = new StringBuilder();
+		Iterator iter = order.iterator();
+		FeatureQueryOrderMember menber;
+		while (true) {
+			menber = (FeatureQueryOrderMember) iter.next();
+			if (menber.hasEvaluator()) {
+				buffer.append(getSqlForEvaluator(menber.getEvaluator()));
+			} else {
+				buffer.append(getEscapedFieldName(menber.getAttributeName()));
+			}
+			if (menber.getAscending()) {
+				buffer.append(" ASC");
+			} else {
+				buffer.append(" DESC");
+			}
+			if (iter.hasNext()) {
+				buffer.append(", ");
+			} else {
+				buffer.append(' ');
+				break;
+			}
+		}
+
+		this.order = buffer.toString();
+	}
+
+	protected void setFilter(Evaluator filter) {
+		this.filter = getSqlForEvaluator(filter);
+	}
+
+
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.feature.spi.FeatureSetProvider#canFilter()
+	 */
+	public boolean canFilter() {
+		Evaluator filter = getQuery().getFilter();
+		if (directSQLMode){
+		    return false;
+		}
+		if (filter != null) {
+			if (filter.getSQL() == null || filter.getSQL().length() == 0) {
+				return false;
+			} else {
+				// TODO Check Geom fields if
+				EvaluatorFieldsInfo fInfo = filter.getFieldsInfo();
+				if (fInfo == null || fInfo.getFieldNames() == null) {
+					return true;
+				}
+				Iterator names = Arrays.asList(fInfo.getFieldNames())
+						.iterator();
+				String name;
+				int type;
+				while (names.hasNext()) {
+					name = (String) names.next();
+					type =
+							this.getFeatureType()
+									.getAttributeDescriptor(name)
+							.getType();
+					if (type == DataTypes.GEOMETRY
+							&& !this.helper.supportsGeometry()) {
+						return false;
+					}
+
+
+
+				}
+
+				return true;
+			}
+
+		} else{
+			return false;
+		}
+	}
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.feature.spi.FeatureSetProvider#canIterateFromIndex()
+	 */
+	public boolean canIterateFromIndex() {
+		return helper.supportOffset();
+	}
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.feature.spi.FeatureSetProvider#canOrder()
+	 */
+	public boolean canOrder() {
+	    if (directSQLMode){
+	        return false;
+	    }
+		// TODO Check Geom fields if postgis not are available
+		FeatureQuery query = getQuery();
+		if (query.hasOrder()) {
+			Iterator iter = query.getOrder().iterator();
+			FeatureQueryOrderMember menber;
+			String sql;
+			while (iter.hasNext()){
+				menber = (FeatureQueryOrderMember) iter.next();
+				if (menber.hasEvaluator()){
+					sql = menber.getEvaluator().getSQL();
+					if (sql == null || sql.length() == 0) {
+						return false;
+					}
+				}
+			}
+		}
+		return true;
+	}
+
+	private JDBCStoreProvider getJDBCStoreProvider() {
+		return (JDBCStoreProvider) getStore();
+	}
+
+	@Override
+	protected void doDispose() throws BaseException {
+		if (resultSetIDReferenced != null) {
+			Iterator iter = resultSetIDReferenced.iterator();
+			Integer resID;
+			while (iter.hasNext()) {
+				resID = (Integer) iter.next();
+				if (resID != null) {
+					logger.warn(
+						"ResultSet (ID {}) not closed on dispose, will close",
+						resID);
+					try {
+						getJDBCStoreProvider().closeResulset(resID.intValue());
+					} catch (DataException e) {
+						logger.error("Close resulset Exception", e);
+					}
+				}
+				iter.remove();
+			}
+		}
+		resultSetIDReferenced = null;
+		filter = null;
+		order = null;
+		size = null;
+		isEmpty = null;
+	}
+
+	protected String getSQL(long fromIndex) throws DataException {
+		return getJDBCStoreProvider().compoundSelect(getFeatureType(), filter,
+				order, limit, fromIndex);
+
+	}
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.feature.spi.FeatureSetProvider#getSize()
+	 */
+	public long getSize() throws DataException {
+		if (size == null) {
+			size = new Long(getJDBCStoreProvider().getCount(filter));
+		}
+		return size.longValue();
+	}
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.feature.spi.FeatureSetProvider#isEmpty()
+	 */
+	public boolean isEmpty() throws DataException {
+		JDBCStoreProvider store = getJDBCStoreProvider();
+		if (isEmpty == null) {
+			if (size == null) {
+				String sql =
+						store.compoundSelect(getFeatureType(), filter, null, 1,
+								0);
+				int rsID = store.createResultSet(sql, getFetchSize());
+				isEmpty = new Boolean(!store.resulsetNext(rsID));
+				store.closeResulset(rsID);
+			} else {
+				isEmpty = new Boolean(size.longValue() < 1);
+			}
+		}
+		return isEmpty.booleanValue();
+	}
+
+	protected int getFetchSize() {
+		long pageSize = -1;
+		if (getQuery() != null) {
+			pageSize = getQuery().getPageSize();
+			pageSize =
+					pageSize > Integer.MAX_VALUE ? Integer.MAX_VALUE : pageSize;
+		}
+		return (pageSize > 0 ? (int) pageSize : defaultFetchSize);
+	}
+
+	protected JDBCIterator createFastIterator(long index) throws DataException {
+		if (isEmpty != null && isEmpty.booleanValue()) {
+			return new EmptyJDBCIterator(getJDBCStoreProvider());
+		}
+		int rsID =
+				getJDBCStoreProvider().createResultSet(getSQL(index),
+						getFetchSize());
+		return createDefaultFastIterator(rsID);
+	}
+
+	protected JDBCIterator createDefaultFastIterator(int resultSetID)
+			throws DataException {
+		return new JDBCFastIterator(getJDBCStoreProvider(), this,
+				getFeatureType(), resultSetID);
+	}
+
+	protected JDBCIterator createIterator(long index) throws DataException {
+        if (isEmpty != null && isEmpty.booleanValue()) {
+            return new EmptyJDBCIterator(getJDBCStoreProvider());
+        }
+        int rsID =
+                getJDBCStoreProvider().createResultSet(getSQL(index),
+                        getFetchSize());
+        return createDefaultIterator(rsID);
+	}
+
+	protected JDBCIterator createDefaultIterator(int resultSetID)
+			throws DataException {
+		return new JDBCIterator(getJDBCStoreProvider(), this, getFeatureType(),
+				resultSetID);
+	}
+
+	public void addResulsetReference(int resulsetID) {
+		this.resultSetIDReferenced.add(new Integer(resulsetID));
+	}
+
+	public void removeResulsetReference(int resulsetID) {
+		this.resultSetIDReferenced.remove(new Integer(resulsetID));
+	}
+
+	private class EmptyJDBCIterator extends JDBCIterator {
+
+		protected EmptyJDBCIterator(JDBCStoreProvider store) throws DataException {
+			super(store, null, null, -1);
+		}
+
+		@Override
+		protected boolean internalHasNext() {
+			return false;
+		}
+
+		@Override
+		protected Object internalNext() {
+			throw new NoSuchElementException();
+		}
+
+		@Override
+		protected void doDispose() throws BaseException {
+			// nothing to do
+		}
+
+	}
+
+}
\ No newline at end of file

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCSetProvider.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCFastIterator.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCFastIterator.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCFastIterator.java	(revision 38285)
@@ -0,0 +1,62 @@
+/* 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.jdbc;
+
+import org.gvsig.fmap.dal.exception.DataException;
+import org.gvsig.fmap.dal.feature.FeatureType;
+import org.gvsig.fmap.dal.feature.spi.FeatureProvider;
+import org.gvsig.tools.exception.BaseException;
+
+/**
+ * @author jmvivo
+ *
+ */
+public class JDBCFastIterator extends JDBCIterator {
+
+	protected FeatureProvider featureProvider;
+
+	protected JDBCFastIterator(JDBCStoreProvider store, JDBCSetProvider set,
+			FeatureType featureType, int resultsetID) throws DataException {
+		super(store, set, featureType, resultsetID);
+		this.featureProvider = super.createFeatureProvider();
+	}
+
+	protected FeatureProvider createFeatureProvider() throws DataException {
+		return this.featureProvider;
+	}
+
+	@Override
+	protected void doDispose() throws BaseException {
+		super.doDispose();
+		featureProvider = null;
+	}
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCFastIterator.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCStoreProvider.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCStoreProvider.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCStoreProvider.java	(revision 38285)
@@ -0,0 +1,904 @@
+/* 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.jdbc;
+
+import java.security.InvalidParameterException;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.cresques.cts.IProjection;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.gvsig.fmap.dal.DALLocator;
+import org.gvsig.fmap.dal.DataManager;
+import org.gvsig.fmap.dal.DataServerExplorer;
+import org.gvsig.fmap.dal.DataStore;
+import org.gvsig.fmap.dal.DataStoreNotification;
+import org.gvsig.fmap.dal.DataTypes;
+import org.gvsig.fmap.dal.exception.CloseException;
+import org.gvsig.fmap.dal.exception.DataException;
+import org.gvsig.fmap.dal.exception.InitializeException;
+import org.gvsig.fmap.dal.exception.OpenException;
+import org.gvsig.fmap.dal.exception.ReadException;
+import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
+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.FeatureType;
+import org.gvsig.fmap.dal.feature.spi.AbstractFeatureStoreProvider;
+import org.gvsig.fmap.dal.feature.spi.FeatureProvider;
+import org.gvsig.fmap.dal.feature.spi.FeatureReferenceProviderServices;
+import org.gvsig.fmap.dal.feature.spi.FeatureSetProvider;
+import org.gvsig.fmap.dal.resource.ResourceAction;
+import org.gvsig.fmap.dal.resource.exception.ResourceExecuteException;
+import org.gvsig.fmap.dal.resource.spi.ResourceProvider;
+import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
+import org.gvsig.fmap.dal.store.db.DBHelper;
+import org.gvsig.fmap.dal.store.db.FeatureTypeHelper;
+import org.gvsig.fmap.dal.store.jdbc.exception.InvalidResultSetIdException;
+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.JDBCSQLException;
+import org.gvsig.fmap.geom.Geometry;
+import org.gvsig.fmap.geom.operation.towkb.ToWKB;
+import org.gvsig.fmap.geom.primitive.Envelope;
+import org.gvsig.tools.dynobject.DynObject;
+import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException;
+import org.gvsig.tools.exception.BaseException;
+
+
+/**
+ * @author jmvivo
+ *
+ */
+public class JDBCStoreProvider extends AbstractFeatureStoreProvider
+		implements JDBCHelperUser {
+
+	final static private Logger logger = LoggerFactory
+			.getLogger(JDBCStoreProvider.class);
+
+	private List<ResultSetInfo> resulsetList;
+
+	public static String NAME = "JDBC";
+	public static String DESCRIPTION = "JDBC source";
+
+	public static final String METADATA_DEFINITION_NAME = NAME;
+
+	private long mlsecondsToZombie = 1000 * 60 * 10; // 10 Min
+
+	protected JDBCHelper helper;
+
+	protected boolean directSQLMode;
+
+	private Long totalCount = null;
+
+	public JDBCStoreProvider(JDBCStoreParameters params,
+			DataStoreProviderServices storeServices) throws InitializeException {
+		this(
+				params, 
+				storeServices,
+				DBHelper.newMetadataContainer(METADATA_DEFINITION_NAME)
+		);
+	}
+
+	protected JDBCStoreProvider(JDBCStoreParameters params,
+			DataStoreProviderServices storeServices, DynObject metadata)
+			throws InitializeException {
+		super(params, storeServices, metadata);
+
+		resulsetList = new ArrayList<ResultSetInfo>(10);
+
+		helper = createHelper();
+		if (params.getSQL() != null && (params.getSQL()).trim().length() > 0) {
+			directSQLMode = true;
+		}
+
+		this.initFeatureType();
+	}
+
+	public Object getDynValue(String name) throws DynFieldNotFoundException {
+		try {
+			if( DataStore.METADATA_ENVELOPE.equalsIgnoreCase(name) ) {
+				Envelope env = this.getEnvelope();
+				if( env != null ) {
+					return env;
+				}
+			} else if( DataStore.METADATA_CRS.equalsIgnoreCase(name) ) {
+				IProjection proj;
+				proj = this.getFeatureStore().getDefaultFeatureType().getDefaultSRS();
+				if( proj != null ) {
+					return proj;
+				}
+			}
+		} catch (DataException e) {
+			throw new RuntimeException(e);
+		}
+		return super.getDynValue(name);
+	}
+	
+
+	protected JDBCStoreParameters getJDBCParameters() {
+		return (JDBCStoreParameters) this.getParameters();
+	}
+
+
+	/**
+	 * Load data form a resulset.<br>
+	 *
+	 * <strong>Note:</strong><br>
+	 * this method have to perform <code>resouceBegin</code> at the begining and
+	 * <code>resourceEnd</code> at the end of execution.
+	 *
+	 *
+	 * @param data
+	 * @param resulsetID
+	 *
+	 * @return
+	 * @throws DataException
+	 */
+	public void loadFeatureProvider(final FeatureProvider data, final int resultsetID)
+			throws DataException {
+		getResource().execute(new ResourceAction() {
+			public Object run() throws Exception {
+				ResultSet rs = getResultSet(resultsetID);
+				FeatureAttributeDescriptor attr;
+				Iterator<FeatureAttributeDescriptor> iter = FeatureTypeHelper.iterator(data.getType());
+				while (iter.hasNext()) {
+					attr = iter.next();
+					loadFeatureProviderValue(data, rs, attr);
+				}
+				return null;
+			}
+		});
+	}
+
+	protected void loadFeatureProviderValue(FeatureProvider data, ResultSet rs,
+			FeatureAttributeDescriptor attr) throws DataException {
+		if (attr.getType() == DataTypes.GEOMETRY) {
+			byte[] buffer;
+			try {
+				buffer = rs.getBytes(attr.getIndex() + 1);
+				if (buffer == null) {
+					data.set(attr.getIndex(), null);
+				} else {
+					data.set(attr.getIndex(), this.helper.getGeometry(buffer));
+				}
+			} catch (SQLException e) {
+				throw new JDBCSQLException(e);
+			} catch (BaseException e) {
+				throw new ReadException(getProviderName(), e);
+			}
+
+		} else {
+			try {
+				data.set(attr.getIndex(), rs.getObject(attr.getIndex() + 1));
+			} catch (SQLException e) {
+				throw new JDBCSQLException(e);
+			}
+		}
+	}
+
+	public long getTimeToResulSetZombie() {
+		return mlsecondsToZombie;
+	}
+
+	public void setTimeToResulSetZombie(long mlSeconds) {
+		mlsecondsToZombie = mlSeconds;
+	}
+
+	private class ResultSetInfo{
+		private ResultSet resultSet = null;
+		private long lastUse = 0;
+
+		public ResultSetInfo(ResultSet resulSet) {
+			this.resultSet = resulSet;
+			used();
+		}
+
+		private void used() {
+			lastUse = System.currentTimeMillis();
+		}
+
+
+		public ResultSet get() {
+			used();
+			return resultSet;
+		}
+
+		public boolean isZombie() {
+			return System.currentTimeMillis() - lastUse > mlsecondsToZombie;
+		}
+	}
+
+	public final int createResultSet(String sql, int fetchSize)
+			throws DataException {
+        return createResultSet(sql, null, fetchSize);
+	}
+
+	public final int createResultSet(final String sql, final Object[] values,
+			final int fetchSize)
+			throws DataException {
+		logger.debug("Creating resultSet with sql: {}", sql);
+		synchronized (this) {
+			checksResulsets();
+			return ((Integer) getResource().execute(new ResourceAction() {
+				public Object run() throws Exception {
+					ResultSetInfo newRs =
+							new ResultSetInfo(createNewResultSet(sql, values,
+									fetchSize));
+					int newId = getNewId();
+					if (newId < 0) {
+						newId = resulsetList.size();
+						resulsetList.add(newRs);
+					} else {
+						resulsetList.set(newId, newRs);
+					}
+					logger.debug("Created resultset id: {} (total open: {})",
+							newId, getResultsetOpenCount());
+
+					return Integer.valueOf(newId);
+				}
+			})).intValue();
+		}
+	}
+
+	private int getNewId() {
+		int newId;
+		if (resulsetList.size() < 1) {
+			return -1;
+		}
+		for (newId = 0; newId < resulsetList.size(); newId++) {
+			if (resulsetList.get(newId) == null) {
+				return newId;
+			}
+		}
+		return -1;
+	}
+
+	protected final void forceCloseAllResultSet()
+			throws ResourceExecuteException,
+			JDBCException {
+		synchronized (this) {
+			// FIXME: Esto no deberia funcionar. 
+			Iterator iter = resulsetList.iterator();
+			Integer rsID = null;
+			while (iter.hasNext()) {
+				rsID = (Integer) iter.next();
+				if (rsID != null) {
+					try {
+						forceCloseResultSet(rsID.intValue());
+					} catch (InvalidResultSetIdException e) {
+						continue;
+					}
+				}
+				iter.remove();
+			}
+
+		}
+	}
+	
+	protected final void forceCloseResultSet(int rsID)
+			throws ResourceExecuteException, JDBCException,
+			InvalidResultSetIdException {
+		logger.warn("Close forced of resultSet ({})", rsID);
+		closeResulset(rsID);
+	}
+
+	protected final ResultSet getResultSet(int resultsetID)
+			throws InvalidResultSetIdException {
+		if (resultsetID >= resulsetList.size()) {
+			throw new InvalidResultSetIdException(resultsetID);
+		}
+		ResultSetInfo rsInfo = resulsetList.get(resultsetID);
+		if (rsInfo == null) {
+			throw new InvalidResultSetIdException(resultsetID);
+		}
+		return rsInfo.get();
+
+	}
+
+	private ResultSet dropResultSet(int resultsetID)
+			throws InvalidResultSetIdException {
+		if (resultsetID >= resulsetList.size()) {
+			throw new InvalidResultSetIdException(resultsetID);
+		}
+		ResultSetInfo rsInfo = (ResultSetInfo) resulsetList.get(resultsetID);
+		if (rsInfo == null) {
+			throw new InvalidResultSetIdException(resultsetID);
+		}
+		if (resultsetID == resulsetList.size() - 1) {
+			resulsetList.remove(resultsetID);
+		} else {
+			resulsetList.set(resultsetID, null);
+		}
+		return rsInfo.get();
+	}
+
+
+	public final boolean resulsetNext(final int resultsetID)
+			throws JDBCException,
+			InvalidResultSetIdException, ResourceExecuteException {
+		return ((Boolean) getResource().execute(new ResourceAction() {
+			public Object run() throws Exception {
+			    boolean bool = getResultSet(resultsetID).next();
+				return Boolean.valueOf(bool);
+			}
+		})).booleanValue();
+	}
+
+	public final void closeResulset(final int resultsetID)
+			throws JDBCException,
+			InvalidResultSetIdException, ResourceExecuteException {
+		synchronized (this) {
+			getResource().execute(new ResourceAction() {
+				public Object run() throws Exception {
+					ResultSet rs = dropResultSet(resultsetID);
+					closeResulset(rs);
+					return null;
+				}
+			});
+			if (logger.isDebugEnabled()) {
+				logger.debug(" id: " + resultsetID + " (total "
+						+ getResultsetOpenCount() + ")");
+			}
+			checksResulsets();
+		}
+	}
+
+	public final void checksResulsets() throws JDBCException,
+			InvalidResultSetIdException, ResourceExecuteException {
+		synchronized (this) {
+			getResource().execute(new ResourceAction() {
+				public Object run() throws Exception {
+					ResultSetInfo rsInfo;
+					for (int i = 0; i < resulsetList.size(); i++) {
+						rsInfo = (ResultSetInfo) resulsetList.get(i);
+						if (rsInfo == null) {
+							continue;
+						}
+						if (rsInfo.isZombie()) {
+							forceCloseResultSet(i);
+						}
+					}
+					return null;
+				}
+			});
+		}
+	}
+
+	protected void closeResulset(final ResultSet rs) throws JDBCException,
+			ResourceExecuteException {
+		getResource().execute(new ResourceAction() {
+			public Object run() throws Exception {
+				Statement st = rs.getStatement();
+				Connection con = st.getConnection();
+				try {
+					rs.close();
+				} finally {
+					// TODO revisar esto
+					try{ st.close();  } catch (Exception ex){ };
+					try{ con.close(); } catch (Exception ex){ };
+				}
+				return null;
+			}
+		});
+	}
+
+	private int getResultsetOpenCount() {
+		int count = 0;
+		Iterator<ResultSetInfo> iter = resulsetList.iterator();
+		while (iter.hasNext()) {
+			if (iter.next() != null) {
+				count++;
+			}
+		}
+		return count;
+	}
+
+	protected final int openResulsetCount() {
+		int count = 0;
+		Iterator<ResultSetInfo> iter = resulsetList.iterator();
+		while (iter.hasNext()) {
+			if (iter.next() != null) {
+				count++;
+			}
+		}
+		return count;
+	}
+
+	public boolean closeResourceRequested(ResourceProvider resource) {
+		try {
+			checksResulsets();
+			return openResulsetCount() == 0 && closeResource(resource);
+		} catch (DataException e) {
+			logger.error("Exception throws", e);
+			return false;
+		}
+	}
+
+
+	protected String fixFilter(String filter) {
+		if (filter == null) {
+			return null;
+		}
+
+		return filter;
+	}
+
+	protected JDBCHelper createHelper() throws InitializeException {
+		return new JDBCHelper(this, getJDBCParameters());
+	}
+
+	protected JDBCHelper getHelper() {
+		return helper;
+	}
+
+	protected void resetCount() {
+		totalCount = null;
+	}
+
+	/**
+	 * Get feature count for a <code>filter</code>.<br>
+	 *
+	 * <code>filter</code> can be <code>null</code>.<br>
+	 *
+	 * <strong>Note:</strong><br>
+	 * this method have to perform <code>resouceBegin</code> at the begining and
+	 * <code>resourceEnd</code> at the end of execution.
+	 *
+	 *
+	 * @param filter
+	 * @return
+	 * @throws DataException
+	 */
+	protected long getCount(String filter)
+			throws DataException {
+		this.open();
+		if (filter == null && totalCount != null) {
+			return totalCount.longValue();
+		}
+		final String sql = compoundCountSelect(filter);
+
+		long count = ((Long) getResource().execute(new ResourceAction() {
+			public Object run() throws Exception {
+				long count = 0;
+				ResultSet rs = createNewResultSet(sql, null, 1);
+				try {
+					if (rs.next()) {
+						count = rs.getLong(1);
+					}
+				} catch (SQLException e) {
+					throw new JDBCSQLException(e);
+				} finally {
+					closeResulset(rs);
+				}
+				return Long.valueOf(count);
+			}
+		})).longValue();
+
+		if (filter == null) {
+			totalCount = new Long(count);
+		}
+		return count;
+	}
+
+	public void close() throws CloseException {
+		helper.close();
+	}
+
+	public void open() throws OpenException {
+		helper.open();
+	}
+
+	@Override
+	protected FeatureProvider internalGetFeatureProviderByReference(
+			FeatureReferenceProviderServices reference) throws DataException {
+		return internalGetFeatureProviderByReference(reference,
+				getFeatureStore()
+				.getDefaultFeatureType());
+	}
+
+	@Override
+	protected FeatureProvider internalGetFeatureProviderByReference(
+			FeatureReferenceProviderServices reference,
+			FeatureType featureType)
+			throws DataException {
+		StringBuilder filter = new StringBuilder();
+		FeatureAttributeDescriptor[] pk =
+				getFeatureStore().getFeatureType(featureType.getId())
+						.getPrimaryKey();
+
+		List<Object> values = new ArrayList<Object>();
+
+		int i;
+		for (i = 0; i < pk.length - 1; i++) {
+			values.add(
+					helper.dalValueToJDBC(pk[i],
+					reference.getKeyValue(pk[i].getName())));
+			filter.append(helper.getSqlFieldName(pk[i]));
+			filter.append(" = ? AND ");
+		}
+		values.add(helper.dalValueToJDBC(pk[i],
+				reference.getKeyValue(pk[i].getName())));
+		filter.append(helper.getSqlFieldName(pk[i]));
+		filter.append(" = ? ");
+
+		String sql = compoundSelect(featureType, filter.toString(), null, 1, 0);
+
+		FeatureProvider data;
+		int rsId = createResultSet(sql, values.toArray(), 1);
+		try {
+			if (!resulsetNext(rsId)) {
+				throw new RuntimeException("Reference Not found");
+			}
+			data = createFeatureProvider(featureType);
+			loadFeatureProvider(data, rsId);
+		} finally {
+			closeResulset(rsId);
+		}
+
+		return data;
+	}
+
+	public int getOIDType() {
+		return DataTypes.UNKNOWN;
+	}
+
+	protected void initFeatureType() throws InitializeException {
+
+		EditableFeatureType edFType = null;
+		try {
+			edFType = this.getStoreServices().createFeatureType();
+
+			helper.loadFeatureType(edFType, getJDBCParameters());
+
+		} catch (DataException e) {
+			throw new InitializeException(this.getProviderName(), e);
+		}
+
+		FeatureType defaultType = edFType.getNotEditableCopy();
+		List<FeatureType> types = Collections.singletonList(defaultType);
+		this.getStoreServices().setFeatureTypes(types, defaultType);
+	}
+
+	protected ResultSet createNewResultSet(final String sql,
+			final Object[] values, final int fetchSize)
+			throws DataException {
+		this.open();
+		return (ResultSet) getResource().execute(new ResourceAction() {
+			public Object run() throws Exception {
+				Connection conn = null;
+				PreparedStatement st = null;
+				ResultSet rs = null;
+				try {
+
+					conn = helper.getConnection();
+					conn.setAutoCommit(false);
+					st = conn.prepareStatement(sql);
+
+					if (values != null) {
+						Object value;
+						for (int i = 0; i < values.length; i++) {
+							value = values[i];
+							if (value instanceof Geometry) {
+								byte[] bytes;
+								try {
+									bytes =
+											(byte[]) ((Geometry) value).invokeOperation(
+													ToWKB.CODE, null);
+								} catch (BaseException e) {
+									throw new InvalidParameterException();
+								}
+								st.setBytes(i + 1, bytes);
+							}
+							st.setObject(i + 1, value);
+						}
+					}
+
+					if (fetchSize > 0) {
+						st.setFetchSize(fetchSize);
+					}
+					rs = st.executeQuery();
+					if (fetchSize > 0) {
+						rs.setFetchSize(fetchSize);
+					}
+					return rs;
+				} catch (SQLException e) {
+					try {
+						rs.close();
+					} catch (Exception e1) {
+					}
+					try {
+						st.close();
+					} catch (Exception e1) {
+					}
+					try {
+						conn.close();
+					} catch (Exception e1) {
+					}
+					throw new JDBCExecutePreparedSQLException(sql,values,e);
+				}
+			}
+		});
+	}
+
+	protected boolean closeResource(ResourceProvider resource) {
+		try {
+			this.helper.close();
+		} catch (CloseException e) {
+			logger.error("Exception in close Request", e);
+		}
+		return !this.helper.isOpen();
+	}
+
+	protected String compoundCountSelect(String filter) {
+		if (this.directSQLMode) {
+			return null;
+		}
+		// Select
+		StringBuilder sql = new StringBuilder();
+		sql.append("Select count(");
+		String[] pkFields = getJDBCParameters().getPkFields();
+		if (pkFields != null && pkFields.length == 1) {
+			sql.append(helper.escapeFieldName(pkFields[0]));
+		} else {
+			sql.append('*');
+
+		}
+		sql.append(") ");
+
+		sql.append("from ");
+
+		sql.append(getJDBCParameters().tableID());
+		sql.append(' ');
+
+		appendWhere(sql, filter);
+
+		return sql.toString();
+	}
+
+	protected void appendWhere(StringBuilder sql, String filter) {
+		filter = fixFilter(filter);
+		String initialFilter = getJDBCParameters().getBaseFilter();
+		if ((initialFilter != null && initialFilter.length() != 0)
+				|| (filter != null && filter.length() != 0)) {
+			sql.append("where (");
+
+			if (initialFilter != null && initialFilter.length() != 0
+					&& filter != null && filter.length() != 0) {
+				// initialFilter + filter
+				sql.append('(');
+				sql.append(initialFilter);
+				sql.append(") and (");
+				sql.append(filter);
+				sql.append(')');
+			} else if (initialFilter != null && initialFilter.length() != 0) {
+				// initialFilter only
+				sql.append(initialFilter);
+			} else {
+				// filter only
+				sql.append(filter);
+			}
+			sql.append(") ");
+		}
+	}
+
+	public void closeDone() throws DataException {
+		// Do nothing
+	}
+
+	public void opendDone() throws DataException {
+		// Nothing to do
+	}
+
+	public Envelope getEnvelope() throws DataException {
+		this.open();
+		String defaultGeometryAttributeName;
+		defaultGeometryAttributeName = this.getFeatureStore()
+			.getDefaultFeatureType()
+				.getDefaultGeometryAttributeName();
+		if( defaultGeometryAttributeName != null ) {
+			return this.helper.getFullEnvelopeOfField(
+					this.getJDBCParameters(),
+					defaultGeometryAttributeName, 
+					this.getJDBCParameters().getWorkingArea()
+				);
+		}
+		return null;
+	}
+
+	public void resourceChanged(ResourceProvider resource) {
+		this.getStoreServices().notifyChange(
+				DataStoreNotification.RESOURCE_CHANGED,
+				resource);
+	}
+
+	public boolean allowAutomaticValues() {
+		return this.helper.allowAutomaticValues();
+	}
+
+	public DataServerExplorer getExplorer() throws ReadException {
+		DataManager manager = DALLocator.getDataManager();
+		JDBCServerExplorerParameters exParams;
+		JDBCStoreParameters params = getJDBCParameters();
+		try {
+			exParams = (JDBCServerExplorerParameters) manager
+					.createServerExplorerParameters(JDBCServerExplorer.NAME);
+			exParams.setHost(params.getHost());
+			exParams.setPort(params.getPort());
+			exParams.setDBName(params.getDBName());
+			exParams.setUser(params.getUser());
+			exParams.setPassword(params.getPassword());
+			exParams.setUrl(params.getUrl());
+			exParams.setCatalog(params.getCatalog());
+			exParams.setSchema(params.getSchema());
+			exParams.setJDBCDriverClassName(params.getJDBCDriverClassName());
+
+			return manager.openServerExplorer(JDBCServerExplorer.NAME,exParams);
+		} catch (DataException e) {
+			throw new ReadException(this.getProviderName(), e);
+		} catch (ValidateDataParametersException e) {
+			throw new ReadException(this.getProviderName(), e);
+		}
+	}
+
+	@Override
+	protected void doDispose() throws BaseException {
+		this.close();
+		resulsetList = null;
+		this.helper.dispose();
+		super.doDispose();
+	}
+
+	public Object createNewOID() {
+		return null;
+	}
+
+	public String compoundSelect(FeatureType type, String filter, String order,
+			long limit, long offset) throws DataException {
+		StringBuilder sql = new StringBuilder();
+		JDBCStoreParameters params = getJDBCParameters();
+		if (directSQLMode) {
+			sql.append(params.getSQL());
+			sql.append(' ');
+		} else {
+			FeatureAttributeDescriptor[] fields = type
+					.getAttributeDescriptors();
+
+			// Select
+			sql.append("Select ");
+			for (int i = 0; i < fields.length - 1; i++) {
+				sql.append(helper.getSqlFieldName(fields[i]));
+				sql.append(", ");
+			}
+			sql.append(helper.getSqlFieldName(fields[fields.length - 1]));
+			sql.append(' ');
+
+			FeatureAttributeDescriptor[] pkFields = getStoreServices()
+					.getProviderFeatureType(type.getId()).getPrimaryKey();
+
+			if (pkFields != null && pkFields.length > 0) {
+				// checks for pk fields are in select
+				boolean toAdd;
+				for (int i = 0; i < pkFields.length; i++) {
+					toAdd = true;
+					for (int j = 0; j < fields.length; j++) {
+						if (pkFields[i].getName().equals(fields[j].getName())) {
+							toAdd = false;
+							break;
+						}
+						if (toAdd) {
+							sql.append(", ");
+							sql.append(helper.getSqlFieldName(pkFields[i]));
+						}
+					}
+				}
+				sql.append(' ');
+			}
+
+			// table
+			sql.append("from ");
+			sql.append(params.tableID());
+			sql.append(' ');
+
+			// Where
+			appendWhere(sql, filter);
+
+			// Order
+			if ((params.getBaseOrder() != null && params.getBaseOrder()
+					.length() != 0)
+					|| (order != null && order.length() != 0)) {
+				sql.append("order by ");
+
+				if (order != null && order.length() != 0) {
+					// order
+					sql.append(order);
+				} else {
+					// initial order
+					sql.append(params.getBaseOrder());
+				}
+				sql.append(' ');
+			}
+		}
+		// limit offset
+		if (limit > 0 || offset > 0) {
+			sql.append(helper.compoundLimitAndOffset(limit,offset));
+		}
+		return sql.toString();
+	}
+
+	public long getFeatureCount() throws DataException {
+		return getCount(null);
+	}
+
+	public String getProviderName() {
+		return NAME;
+	}
+
+	public boolean hasGeometrySupport() {
+		return false;
+	}
+
+	public FeatureSetProvider createSet(FeatureQuery query,
+			FeatureType featureType) throws DataException {
+
+		return new JDBCSetProvider(this, query, featureType);
+	}
+
+	public Object getSourceId() {
+		return this.getJDBCParameters().getSourceId();
+	}
+	
+	public String getName() {
+		return this.getJDBCParameters().tableID();
+	}
+	
+	public String getFullName() {
+		return this.getJDBCParameters().getHost()+":"+this.getJDBCParameters().getDBName()+":"+this.getJDBCParameters().tableID();
+	}
+	
+
+	public ResourceProvider getResource() {
+		return getHelper().getResource();
+	}
+	
+	protected boolean isDirectSQLMode(){
+	    return directSQLMode;
+	}
+}
\ No newline at end of file

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCStoreProvider.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/ConnectionAction.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/ConnectionAction.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/ConnectionAction.java	(revision 38285)
@@ -0,0 +1,42 @@
+/* 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.jdbc;
+
+import java.sql.Connection;
+
+import org.gvsig.fmap.dal.exception.DataException;
+
+/**
+ * Contains an action to execute with
+ * {@link JDBCHelper#doConnectionAction(ConnectionAction)}
+ * 
+ * @see {@link JDBCHelper#doConnectionAction(ConnectionAction)},
+ *      {@link TransactionalAction}
+ */
+public interface ConnectionAction {
+	Object action(Connection conn) throws DataException;
+}
\ No newline at end of file

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/ConnectionAction.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCResourceParameters.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCResourceParameters.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCResourceParameters.java	(revision 38285)
@@ -0,0 +1,98 @@
+/* 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.jdbc;
+
+import org.gvsig.fmap.dal.resource.db.DBResourceParameters;
+
+public class JDBCResourceParameters extends DBResourceParameters
+		implements JDBCConnectionParameters {
+
+    protected static final String PARAMETERS_DEFINITION_NAME = "JDBCResourceParameters";
+
+	protected JDBCResourceParameters(String parametersDefinitionName, String providerName) {
+		super(parametersDefinitionName,providerName);
+	}
+	
+	public JDBCResourceParameters() {
+		this(PARAMETERS_DEFINITION_NAME, JDBCResource.NAME);
+	}
+
+    public JDBCResourceParameters(String parametersDefinitionName, String providerName, 
+    		String url, String host, Integer port,
+			String dbName, String user, String password, 
+			String jdbcDriverClassName) {
+		this(parametersDefinitionName,providerName);
+
+		this.setUrl(url);
+		this.setHost(host);
+		this.setPort(port);
+		this.setDBName(dbName);
+		this.setUser(user);
+		this.setPassword(password);
+		this.setJDBCDriverClassName(jdbcDriverClassName);
+	}
+
+    public JDBCResourceParameters(String url, String host, Integer port,
+			String dbName,
+			String user, String password, String jdbcDriverClassName) {
+		this(PARAMETERS_DEFINITION_NAME, JDBCResource.NAME, url, host, port, dbName, user, password, jdbcDriverClassName);
+	}
+
+	public void setJDBCDriverClassName(String className) {
+		this.setDynValue(JDBC_DRIVER_CLASS_PARAMTER_NAME, className);
+	}
+
+	public String getJDBCDriverClassName() {
+		return (String) this.getDynValue(JDBC_DRIVER_CLASS_PARAMTER_NAME);
+	}
+
+	public String getCatalog() {
+		return (String) this.getDynValue(CATALOG_PARAMTER_NAME);
+	}
+
+	public void setCatalog(String catalog) {
+		this.setDynValue(CATALOG_PARAMTER_NAME, catalog);
+	}
+
+	public String getSchema() {
+		return (String) this.getDynValue(SCHEMA_PARAMTER_NAME);
+	}
+
+	public void setSchema(String schema) {
+		this.setDynValue(SCHEMA_PARAMTER_NAME, schema);
+	}
+
+	public String getUrl() {
+		return (String) this.getDynValue(URL_PARAMTER_NAME);
+	}
+
+	public void setUrl(String url) {
+		this.setDynValue(URL_PARAMTER_NAME, url);
+	}
+
+}
\ No newline at end of file

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCResourceParameters.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCServerExplorerParameters.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCServerExplorerParameters.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCServerExplorerParameters.java	(revision 38285)
@@ -0,0 +1,94 @@
+/* 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.jdbc;
+
+import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorerParameters;
+
+public class JDBCServerExplorerParameters extends
+		DBServerExplorerParameters implements JDBCConnectionParameters {
+	
+	public static final String PARAMETERS_DEFINITION_NAME = "JDBCServerExplorerParameters";
+
+	public static final String SHOWINFORMATIONDBTABLES_PARAMTER_NAME = "showInformationDBTables";
+
+	public JDBCServerExplorerParameters() {
+		super(PARAMETERS_DEFINITION_NAME, JDBCServerExplorer.NAME);
+	}
+	
+	public JDBCServerExplorerParameters(String parametersDefinitionName, String name) {
+		super(parametersDefinitionName, name);
+	}
+
+	public void setJDBCDriverClassName(String className) {
+		this.setDynValue(JDBC_DRIVER_CLASS_PARAMTER_NAME, className);
+	}
+
+	public String getJDBCDriverClassName() {
+		return (String) this.getDynValue(JDBC_DRIVER_CLASS_PARAMTER_NAME);
+	}
+
+	public String getCatalog() {
+		return (String) this.getDynValue(CATALOG_PARAMTER_NAME);
+	}
+
+	public void setCatalog(String catalog) {
+		this.setDynValue(CATALOG_PARAMTER_NAME, catalog);
+	}
+
+	public String getSchema() {
+		return (String) this.getDynValue(SCHEMA_PARAMTER_NAME);
+	}
+
+	public void setSchema(String schema) {
+		this.setDynValue(SCHEMA_PARAMTER_NAME, schema);
+	}
+
+	public void setShowInformationDBTables(boolean show){
+		this.setShowInformationDBTables(new Boolean(show));
+	}
+
+	public void setShowInformationDBTables(Boolean show) {
+		this.setDynValue(SHOWINFORMATIONDBTABLES_PARAMTER_NAME, show);
+	}
+
+	public Boolean getShowInformationDBTables() {
+		return (Boolean) this.getDynValue(SHOWINFORMATIONDBTABLES_PARAMTER_NAME);
+	}
+
+	public String getUrl() {
+		return (String) this.getDynValue(URL_PARAMTER_NAME);
+	}
+
+	public void setUrl(String url) {
+		this.setDynValue(URL_PARAMTER_NAME, url);
+	}
+
+}
\ No newline at end of file

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCServerExplorerParameters.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/TransactionalAction.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/TransactionalAction.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/TransactionalAction.java	(revision 38285)
@@ -0,0 +1,21 @@
+package org.gvsig.fmap.dal.store.jdbc;
+
+/**
+ * Contains an action to execute with
+ * {@link JDBCHelper#doConnectionAction(ConnectionAction)} inside of a DB
+ * transaction.
+ * 
+ * @see {@link JDBCHelper#doConnectionAction(ConnectionAction)},
+ *      {@link ConnectionAction}
+ */
+public interface TransactionalAction extends ConnectionAction {
+
+	/**
+	 * If before run <code>action</code> there's a transaction open and this
+	 * methos returns <code>false</code> an exception will be throwed
+	 *
+	 * @return
+	 */
+	boolean continueTransactionAllowed();
+
+}
\ No newline at end of file

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/TransactionalAction.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCHelperUser.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCHelperUser.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCHelperUser.java	(revision 38285)
@@ -0,0 +1,62 @@
+/* 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.jdbc;
+
+import org.gvsig.fmap.dal.exception.DataException;
+import org.gvsig.fmap.dal.resource.spi.ResourceConsumer;
+
+/**
+ * Interface for classes that uses {@link JDBCHelperUser}
+ *
+ * @author jmvivo
+ *
+ */
+public interface JDBCHelperUser extends ResourceConsumer {
+
+	/**
+	 * Get the user name
+	 * 
+	 * @return
+	 */
+	String getProviderName();
+
+	/**
+	 * Called when the resource was open
+	 *
+	 * @throws DataException
+	 */
+	void opendDone() throws DataException;
+
+	/**
+	 * Called when the resource was close
+	 *
+	 * @throws DataException
+	 */
+	void closeDone() throws DataException;
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCHelperUser.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCHelper.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCHelper.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCHelper.java	(revision 38285)
@@ -0,0 +1,1103 @@
+/* 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.jdbc;
+
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.cresques.cts.IProjection;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.gvsig.fmap.dal.DALLocator;
+import org.gvsig.fmap.dal.DataTypes;
+import org.gvsig.fmap.dal.NewDataStoreParameters;
+import org.gvsig.fmap.dal.exception.CloseException;
+import org.gvsig.fmap.dal.exception.DataException;
+import org.gvsig.fmap.dal.exception.InitializeException;
+import org.gvsig.fmap.dal.exception.OpenException;
+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.UnsupportedDataTypeException;
+import org.gvsig.fmap.dal.resource.ResourceAction;
+import org.gvsig.fmap.dal.resource.exception.AccessResourceException;
+import org.gvsig.fmap.dal.resource.exception.ResourceExecuteException;
+import org.gvsig.fmap.dal.resource.spi.ResourceConsumer;
+import org.gvsig.fmap.dal.resource.spi.ResourceManagerProviderServices;
+import org.gvsig.fmap.dal.resource.spi.ResourceProvider;
+import org.gvsig.fmap.dal.store.jdbc.exception.JDBCException;
+import org.gvsig.fmap.dal.store.jdbc.exception.JDBCExecuteSQLException;
+import org.gvsig.fmap.dal.store.jdbc.exception.JDBCSQLException;
+import org.gvsig.fmap.dal.store.jdbc.exception.JDBCTransactionCommitException;
+import org.gvsig.fmap.dal.store.jdbc.exception.JDBCTransactionRollbackException;
+import org.gvsig.fmap.geom.Geometry;
+import org.gvsig.fmap.geom.GeometryLocator;
+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.towkb.ToWKBOperationContext;
+import org.gvsig.fmap.geom.primitive.Envelope;
+import org.gvsig.tools.dispose.impl.AbstractDisposable;
+import org.gvsig.tools.exception.BaseException;
+
+/**
+ * @author jmvivo
+ *
+ */
+public class JDBCHelper extends AbstractDisposable implements ResourceConsumer {
+
+	private static Logger logger = LoggerFactory.getLogger(JDBCHelper.class);
+
+	protected JDBCHelperUser user;
+	protected boolean isOpen;
+	protected String name;
+	protected String defaultSchema;
+	protected JDBCConnectionParameters params;
+	private JDBCResource resource;
+
+	protected FromWKB fromWKB = null;
+	protected FromWKBGeometryOperationContext fromWKBContext = null;
+	protected ToWKBOperationContext toWKBContext = new ToWKBOperationContext();
+
+	private Boolean allowAutomaticValues = null;
+	private Boolean supportsUnions = null;
+
+	private String identifierQuoteString;
+
+	protected JDBCHelper(JDBCHelperUser consumer,
+			JDBCConnectionParameters params) throws InitializeException {
+
+		this.user = consumer;
+		this.name = user.getProviderName();
+		this.params = params;
+		initializeResource();
+
+	}
+
+	protected void initializeResource() throws InitializeException {
+		ResourceManagerProviderServices manager = (ResourceManagerProviderServices) DALLocator
+				.getResourceManager();
+		JDBCResource resource = (JDBCResource) manager
+				.createAddResource(
+				JDBCResource.NAME, new Object[] { params.getUrl(),
+						params.getHost(), params.getPort(), params.getDBName(),
+						params.getUser(), params.getPassword(),
+						params.getJDBCDriverClassName() });
+		this.setResource(resource);
+
+	}
+
+	protected final void setResource(JDBCResource resource) {
+		this.resource = resource;
+		this.resource.addConsumer(this);
+	}
+
+	public boolean closeResourceRequested(ResourceProvider resource) {
+		return user.closeResourceRequested(resource);
+	}
+
+	public void resourceChanged(ResourceProvider resource) {
+		user.resourceChanged(resource);
+
+	}
+
+	/**
+	 * open the resource
+	 *
+	 * @return true if the resourse was open in this call
+	 * @throws OpenException
+	 */
+	public boolean open() throws OpenException {
+		if (isOpen) {
+			return false;
+		}
+		// try {
+		// begin();
+		// } catch (ResourceExecuteException e1) {
+		// throw new OpenException(name, e1);
+		// }
+		try {
+			getResource().execute(new ResourceAction() {
+				public Object run() throws Exception {
+					getResource().connect();
+					getResource().notifyOpen();
+
+					user.opendDone();
+
+					isOpen = true;
+					return null;
+				}
+			});
+			return true;
+		} catch (ResourceExecuteException e) {
+			throw new OpenException(name, e);
+			// } finally {
+			// end();
+		}
+
+	}
+
+	public JDBCResource getResource() {
+		return resource;
+	}
+
+	public void close() throws CloseException {
+		if (!isOpen) {
+			return;
+		}
+		// try {
+		// begin();
+		// } catch (ResourceExecuteException e) {
+		// throw new CloseException(name, e);
+		// }
+		try {
+			getResource().execute(new ResourceAction() {
+				public Object run() throws Exception {
+					isOpen = false;
+
+					resource.notifyClose();
+					user.closeDone();
+					return null;
+				}
+			});
+		} catch (ResourceExecuteException e) {
+			throw new CloseException(this.name, e);
+			// } finally {
+			// end();
+		}
+	}
+
+	// public void end() {
+	// resource.end();
+	// }
+	//
+	// public void begin() throws ResourceExecuteException {
+	// this.resource.begin();
+	// }
+
+	public Connection getConnection() throws AccessResourceException {
+		return resource.getJDBCConnection();
+
+	}
+
+	@Override
+	protected void doDispose() throws BaseException {
+		resource.removeConsumer(this);
+	}
+
+	public boolean isOpen() {
+		return isOpen;
+	}
+
+	/**
+	 * Executes an atomic action that uses an DB Connection.<br>
+	 *
+	 * This methos prepares a connection and close it at the end of execution of
+	 * action.<br>
+	 *
+	 * if <code>action</code> is an instance of {@link TransactionalAction} the
+	 * action will be execute inside of a DB transaction.
+	 *
+	 *
+	 * @param action
+	 * @throws Exception
+	 */
+	public Object doConnectionAction(final ConnectionAction action)
+			throws Exception {
+		this.open();
+//		this.begin();
+		return getResource().execute(new ResourceAction() {
+			public Object run() throws Exception {
+				Object result = null;
+				Connection conn = null;
+				boolean beginTrans = false;
+				try {
+					conn = getConnection();
+					if (action instanceof TransactionalAction) {
+						// XXX OJO esta condicion NO ES FIABLE
+						if (!conn.getAutoCommit()) {
+							if (!((TransactionalAction) action)
+									.continueTransactionAllowed()) {
+								// FIXME exception
+								throw new Exception();
+							}
+						}
+						try {
+							conn.setAutoCommit(false);
+						} catch (SQLException e) {
+							throw new JDBCSQLException(e);
+						}
+						beginTrans = true;
+					}
+
+					result = action.action(conn);
+
+					if (beginTrans) {
+						try {
+							conn.commit();
+						} catch (SQLException e) {
+							throw new JDBCTransactionCommitException(e);
+						}
+					}
+
+					return result;
+
+				} catch (Exception e) {
+
+					if (beginTrans) {
+						try {
+							conn.rollback();
+						} catch (Exception e1) {
+							throw new JDBCTransactionRollbackException(e1, e);
+						}
+					}
+					throw e;
+
+				} finally {
+					try {
+						conn.close();
+					} catch (Exception e1) {
+						logger.error("Exception on close connection", e1);
+					}
+					// this.end();
+				}
+			}
+		});
+
+	}
+
+	protected String getDefaultSchema(Connection conn) throws JDBCException {
+		return defaultSchema;
+	}
+
+	protected EditableFeatureAttributeDescriptor createAttributeFromJDBC(
+			EditableFeatureType fType, Connection conn,
+			ResultSetMetaData rsMetadata, int colIndex)
+        throws java.sql.SQLException {
+
+		EditableFeatureAttributeDescriptor column;
+		switch (rsMetadata.getColumnType(colIndex)) {
+		case java.sql.Types.INTEGER:
+			column = fType.add(rsMetadata.getColumnName(colIndex),
+					DataTypes.INT);
+			break;
+		case java.sql.Types.BIGINT:
+			column = fType.add(rsMetadata.getColumnName(colIndex),
+					DataTypes.LONG);
+			break;
+		case java.sql.Types.REAL:
+			column = fType.add(rsMetadata.getColumnName(colIndex),
+					DataTypes.DOUBLE);
+			break;
+		case java.sql.Types.DOUBLE:
+			column = fType.add(rsMetadata.getColumnName(colIndex),
+					DataTypes.DOUBLE);
+			break;
+		case java.sql.Types.CHAR:
+			column = fType.add(rsMetadata.getColumnName(colIndex),
+					DataTypes.STRING);
+			break;
+		case java.sql.Types.VARCHAR:
+		case java.sql.Types.LONGVARCHAR:
+			column = fType.add(rsMetadata.getColumnName(colIndex),
+					DataTypes.STRING);
+			break;
+		case java.sql.Types.FLOAT:
+			column = fType.add(rsMetadata.getColumnName(colIndex),
+					DataTypes.FLOAT);
+			break;
+		case java.sql.Types.DECIMAL:
+			column = fType.add(rsMetadata.getColumnName(colIndex),
+					DataTypes.FLOAT);
+			break;
+		case java.sql.Types.DATE:
+			column = fType.add(rsMetadata.getColumnName(colIndex),
+					DataTypes.DATE);
+			break;
+		case java.sql.Types.TIME:
+			column = fType.add(rsMetadata.getColumnName(colIndex),
+					DataTypes.TIME);
+			break;
+		case java.sql.Types.TIMESTAMP:
+			column = fType.add(rsMetadata.getColumnName(colIndex),
+					DataTypes.TIMESTAMP);
+			break;
+		case java.sql.Types.BOOLEAN:
+			column = fType.add(rsMetadata.getColumnName(colIndex),
+					DataTypes.BOOLEAN);
+			break;
+		case java.sql.Types.BLOB:
+		case java.sql.Types.BINARY:
+		case java.sql.Types.LONGVARBINARY:
+			column = fType.add(rsMetadata.getColumnName(colIndex),
+					DataTypes.BYTEARRAY);
+			break;
+
+		default:
+			column = fType.add(rsMetadata.getColumnName(colIndex),
+					DataTypes.OBJECT);
+			column.setAdditionalInfo("SQLType", new Integer(rsMetadata
+					.getColumnType(colIndex)));
+			column.setAdditionalInfo("SQLTypeName", rsMetadata
+					.getColumnTypeName(colIndex));
+
+			break;
+		}
+
+		return column;
+
+	}
+
+	protected EditableFeatureAttributeDescriptor getAttributeFromJDBC(
+			EditableFeatureType fType, Connection conn,
+			ResultSetMetaData rsMetadata, int colIndex) throws JDBCException {
+		EditableFeatureAttributeDescriptor column;
+		try {
+
+			column = createAttributeFromJDBC(fType, conn, rsMetadata, colIndex);
+			// column.setCaseSensitive(rsMetadata.isCaseSensitive(colIndex));
+			// column.setSqlType(rsMetadata.getColumnType(colIndex));
+			column.setAllowNull(
+					rsMetadata.isNullable(colIndex) == ResultSetMetaData.columnNullable);
+			column.setIsAutomatic(rsMetadata.isAutoIncrement(colIndex));
+			column.setIsReadOnly(rsMetadata.isReadOnly(colIndex));
+			// column.setWritable(rsMetadata.isWritable(colIndex));
+			// column.setClassName(rsMetadata.getColumnClassName(colIndex));
+			// column.setCatalogName(rsMetadata.getCatalogName(colIndex));
+			// column.setDefinitelyWritable(rsMetadata
+			// .isDefinitelyWritable(colIndex));
+			// column.setLabel(rsMetadata.getColumnLabel(colIndex));
+			// column.setSchemaName(rsMetadata.getSchemaName(colIndex));
+			// column.setTableName(rsMetadata.getTableName(colIndex));
+			// column.setCatalogName(rsMetadata.getCatalogName(colIndex));
+			// column.setSqlTypeName();
+			// column.setSearchable(rsMetadata.isSearchable(colIndex));
+			// column.setSigned(rsMetadata.isSigned(colIndex));
+			// column.setCurrency(rsMetadata.isCurrency(colIndex));
+			column.setPrecision(rsMetadata.getPrecision(colIndex));
+			column.setSize(rsMetadata.getColumnDisplaySize(colIndex));
+
+		} catch (java.sql.SQLException e) {
+			throw new JDBCSQLException(e);
+		}
+
+		return column;
+
+	}
+
+	/**
+	 * Fill <code>featureType</code> geometry attributes with SRS and ShapeType
+	 * information
+	 *
+	 * <b>Override this if provider has native eometry support</b>
+	 *
+	 * @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 {
+
+		// Nothing to do
+
+	}
+
+	public void loadFeatureType(EditableFeatureType featureType,
+			JDBCStoreParameters storeParams) throws DataException {
+		if (storeParams.getSQL() != null
+				&& storeParams.getSQL().trim().length() > 0) {
+			loadFeatureType(featureType, storeParams, storeParams.getSQL(),
+					null, null);
+		} else {
+			String sql = "Select * from " + storeParams.tableID()
+					+ " where false";
+			loadFeatureType(featureType, storeParams, sql, storeParams
+					.getSchema(), storeParams.getTable());
+		}
+	}
+
+	public void loadFeatureType(final EditableFeatureType featureType,
+			final JDBCStoreParameters storeParams, final String sql,
+			final String schema, final String table) throws DataException {
+		this.open();
+//		this.begin();
+		getResource().execute(new ResourceAction() {
+			public Object run() throws Exception {
+				Connection conn = null;
+				try {
+					conn = getConnection();
+					
+					String[] pks = storeParams.getPkFields();
+					if (pks == null || pks.length < 1) {
+						if (storeParams.getTable() != null
+								&& storeParams.getTable().trim().length() > 0) {
+							pks = getPksFrom(conn, storeParams);
+							
+						}
+					}
+					
+					loadFeatureType(conn, featureType, sql, pks, storeParams
+							.getDefaultGeometryField(), schema, table);
+					if (storeParams.getCRS()!=null){
+						((EditableFeatureAttributeDescriptor)featureType.getDefaultGeometryAttribute()).setSRS(storeParams.getCRS());
+					}
+					
+				} finally {
+					try {
+						conn.close();
+					} catch (Exception e) {
+					}
+//			this.end();
+				}
+				return null;
+			}
+		});
+	}
+
+	protected String[] getPksFrom(Connection conn, JDBCStoreParameters params)
+		throws JDBCException {
+		try{
+			DatabaseMetaData metadata = conn.getMetaData();
+			ResultSet rsPrimaryKeys = null;
+			ResultSet rs = null;
+			String catalog = params.getCatalog();
+			String schema = params.getSchema();
+
+			try{
+				rs = metadata.getTables(catalog,
+						schema, params.getTable(), null);
+
+				if (!rs.next()) {
+					// No tables found with default values, ignoring catalog
+					rs.close();
+					catalog = null;
+					schema = null;
+					rs = metadata
+							.getTables(catalog, schema, params.getTable(), null);
+
+					if (!rs.next()) {
+						// table not found
+						return null;
+					} else if (rs.next()){
+						// More that one, cant identify
+						return null;
+					}
+
+				} else if (rs.next()) {
+					// More that one, cant identify
+					return null;
+				}
+				rsPrimaryKeys = metadata.getPrimaryKeys(catalog, schema, params
+						.getTable());
+				List pks = new ArrayList();
+				while (rsPrimaryKeys.next()){
+					pks.add(rsPrimaryKeys.getString("COLUMN_NAME"));
+				}
+				return (String[]) pks.toArray(new String[pks.size()]);
+
+
+			} finally {
+				try{if (rs != null) {
+					rs.close();
+				}} catch (SQLException ex) {logger.warn("Exception closing tables rs", ex);};
+				try{if (rsPrimaryKeys != null) {
+					rsPrimaryKeys.close();
+				}} catch (SQLException ex) {logger.warn("Exception closing pk rs", ex);};
+			}
+
+
+		} catch (SQLException e) {
+			logger.warn("Unable to get pk from DatabaseMetada", e);
+			return getPksFromInformationSchema(conn, params);
+		}
+
+	}
+
+	protected String[] getPksFromInformationSchema(Connection conn,
+			JDBCStoreParameters params)
+			throws JDBCException {
+		Statement st;
+		StringBuffer sql = new StringBuffer();
+		ResultSet rs;
+		ArrayList list = new ArrayList();
+
+		/*
+		 select column_name as primary_key
+			from information_schema.table_constraints t_cons
+				inner join information_schema.key_column_usage c on
+					c.constraint_catalog = t_cons.table_catalog and
+				    c.table_schema = t_cons.table_schema and
+				    c.table_name = t_cons.table_name and
+					c.constraint_name = t_cons.constraint_name
+				where t_cons.table_schema = <schema>
+				and t_cons.constraint_catalog = <catalog>
+ 				and t_cons.table_name = <table>
+ 				and constraint_type = 'PRIMARY KEY'
+		 */
+		/*
+		 * SELECT column_name FROM INFORMATION_SCHEMA.constraint_column_usage
+		 * left join INFORMATION_SCHEMA.table_constraints on
+		 * (INFORMATION_SCHEMA.table_constraints.constraint_name =
+		 * INFORMATION_SCHEMA.constraint_column_usage.constraint_name and
+		 * INFORMATION_SCHEMA.table_constraints.table_name =
+		 * INFORMATION_SCHEMA.constraint_column_usage.table_name and
+		 * INFORMATION_SCHEMA.table_constraints.table_schema =
+		 * INFORMATION_SCHEMA.constraint_column_usage.table_schema) WHERE
+		 * INFORMATION_SCHEMA.constraint_column_usage.table_name like
+		 * 'muni10000_peq' AND
+		 * INFORMATION_SCHEMA.constraint_column_usage.table_schema like 'public'
+		 * AND INFORMATION_SCHEMA.constraint_column_usage.table_catalog like
+		 * 'gis' AND constraint_type='PRIMARY KEY'
+		 */
+
+		sql.append("select column_name as primary_key ");
+		sql.append("from information_schema.table_constraints t_cons ");
+		sql.append("inner join information_schema.key_column_usage c on ");
+		sql.append("c.constraint_catalog = t_cons.constraint_catalog and ");
+		sql.append("c.table_schema = t_cons.table_schema and ");
+		sql.append("c.table_name = t_cons.table_name and ");
+		sql.append("c.constraint_name = t_cons.constraint_name ");
+		sql.append("WHERE t_cons.table_name like '");
+
+		sql.append(params.getTable());
+		sql.append("' ");
+		String schema = null;
+
+
+		if (params.getSchema() == null || params.getSchema() == "") {
+			schema = getDefaultSchema(conn);
+		} else {
+			schema = params.getSchema();
+		}
+		if (schema != null) {
+			sql.append(" and t_cons.table_schema like '");
+			sql.append(schema);
+			sql.append("' ");
+		}
+
+		if (params.getCatalog() != null && params.getCatalog() != "") {
+			sql
+					.append(" and t_cons.constraint_catalog like '");
+			sql.append(params.getCatalog());
+			sql.append("' ");
+		}
+
+		sql.append("' and constraint_type = 'PRIMARY KEY'");
+
+		// System.out.println(sql.toString());
+		try {
+			st = conn.createStatement();
+			try {
+				rs = st.executeQuery(sql.toString());
+			} catch (java.sql.SQLException e) {
+				throw new JDBCExecuteSQLException(sql.toString(), e);
+			}
+			while (rs.next()) {
+				list.add(rs.getString(1));
+			}
+			rs.close();
+			st.close();
+
+		} catch (java.sql.SQLException e) {
+			throw new JDBCSQLException(e);
+		}
+		if (list.size() == 0) {
+			return null;
+		}
+
+		return (String[]) list.toArray(new String[0]);
+
+	}
+
+	protected void loadFeatureType(Connection conn,
+			EditableFeatureType featureType, String sql, String[] pks,
+			String defGeomName, String schema, String table)
+			throws DataException {
+
+		Statement stAux = null;
+		ResultSet rs = null;
+		try {
+
+			stAux = conn.createStatement();
+			stAux.setFetchSize(1);
+
+			try {
+				rs = stAux.executeQuery(sql);
+			} catch (SQLException e) {
+				throw new JDBCExecuteSQLException(sql, e);
+			}
+			ResultSetMetaData rsMetadata = rs.getMetaData();
+
+			List pksList = null;
+			if (pks != null) {
+				pksList = Arrays.asList(pks);
+
+			}
+
+			int i;
+			int geometriesColumns = 0;
+			String lastGeometry = null;
+
+			EditableFeatureAttributeDescriptor attr;
+            boolean firstGeometryAttrFound = false;
+			for (i = 1; i <= rsMetadata.getColumnCount(); i++) {
+				attr = getAttributeFromJDBC(featureType, conn, rsMetadata, i);
+				if (pksList != null && pksList.contains(attr.getName())) {
+					attr.setIsPrimaryKey(true);
+				}
+				if (attr.getType() == DataTypes.GEOMETRY) {
+                    geometriesColumns++;
+                    lastGeometry = attr.getName();
+                    // Set the default geometry attribute if it is the one
+                    // given as parameter or it is the first one, just in case.
+                    if (!firstGeometryAttrFound
+                        || lastGeometry.equals(defGeomName)) {
+                        firstGeometryAttrFound = true;
+                        featureType
+                            .setDefaultGeometryAttributeName(lastGeometry);
+                    }
+				}
+
+			}
+
+			if (geometriesColumns > 0) {
+				loadSRS_and_shapeType(conn, rsMetadata, featureType, schema,
+						table);
+			}
+
+			if (defGeomName == null && geometriesColumns == 1) {
+				featureType.setDefaultGeometryAttributeName(lastGeometry);
+				defGeomName = lastGeometry;
+			}
+
+		} catch (java.sql.SQLException e) {
+			throw new JDBCSQLException(e); // FIXME exception
+		} finally {
+			try {
+				rs.close();
+			} catch (Exception e) {
+			}
+			try {
+				stAux.close();
+			} catch (Exception e) {
+			}
+
+		}
+
+	}
+
+	/**
+	 * Override if provider has geometry support
+	 *
+	 * @param storeParams
+	 * @param geometryAttrName
+	 * @param limit
+	 * @return
+	 * @throws DataException
+	 */
+	public Envelope getFullEnvelopeOfField(JDBCStoreParameters storeParams,
+			String geometryAttrName, Envelope limit) throws DataException {
+
+		// TODO
+		return null;
+
+	}
+
+	protected void initializeFromWKBOperation() throws BaseException {
+		if (fromWKB == null) {
+			fromWKB = (FromWKB) GeometryLocator.getGeometryManager()
+                    .getGeometryOperation(FromWKB.CODE);
+			fromWKBContext = new FromWKBGeometryOperationContext();
+		}
+	}
+
+	public Geometry getGeometry(byte[] buffer) throws BaseException {
+		if (buffer == null) {
+			return null;
+		}
+		initializeFromWKBOperation();
+		Geometry geom;
+		try {
+			fromWKBContext.setData(buffer);
+
+			geom = (Geometry) fromWKB.invoke(null, fromWKBContext);
+		} finally {
+			fromWKBContext.setData(null);
+		}
+		return geom;
+	}
+
+	public String escapeFieldName(String field) {
+		if (field.matches("[a-z][a-z0-9_]*")) {
+			return field;
+		}
+		String quote = getIdentifierQuoteString();
+		return quote + field + quote;
+	}
+
+	public Object dalValueToJDBC(
+			FeatureAttributeDescriptor attributeDescriptor, Object object)
+			throws WriteException {
+		if (object == null) {
+			return null;
+		}
+
+		if (attributeDescriptor.getType() != DataTypes.GEOMETRY) {
+			return object;
+		}
+		try {
+			Geometry geom = (Geometry) object;
+
+			toWKBContext.setSrID(-1);
+			IProjection srs = attributeDescriptor.getSRS();
+			if (srs != null) {
+				toWKBContext.setSrID(getProviderSRID(srs));
+			}
+
+			// TODO optimize this
+			// byte[] wkb = (byte[])
+			// geom.invokeOperation(ToWKBNative.CODE,toWKBContext);
+			byte[] wkb = (byte[]) geom.invokeOperation(ToWKB.CODE,
+					toWKBContext);
+			if (wkb == null) {
+				// FIXME excpetion
+				throw new IllegalArgumentException();
+			}
+
+			return wkb;
+		} catch (Exception e) {
+			throw new WriteException(this.name, e);
+		}
+	}
+
+	public String getSqlColumnTypeDescription(FeatureAttributeDescriptor attr) {
+		switch (attr.getType()) {
+		case DataTypes.STRING:
+			if (attr.getSize() < 1 || attr.getSize() > 255) {
+				return "text";
+			} else {
+				return "varchar(" + attr.getSize() + ")";
+			}
+		case DataTypes.BOOLEAN:
+			return "bool";
+
+		case DataTypes.BYTE:
+			return "smallint";
+
+		case DataTypes.DATE:
+			return "date";
+
+		case DataTypes.TIMESTAMP:
+			return "timestamp";
+
+		case DataTypes.TIME:
+			return "time";
+
+		case DataTypes.BYTEARRAY:
+		case DataTypes.GEOMETRY:
+			return "blob";
+
+		case DataTypes.DOUBLE:
+//			if (attr.getPrecision() > 0) {
+//			    return "double precision(" + attr.getPrecision() + ')';
+//			} else {
+		    //It works with PostgreSQL and MySQL. Check with others
+			    return "double precision";
+//			}
+		case DataTypes.FLOAT:
+			return "real";
+
+		case DataTypes.INT:
+			if (attr.isAutomatic() && allowAutomaticValues()) {
+				return "serial";
+			} else {
+				return "integer";
+			}
+		case DataTypes.LONG:
+			if (attr.isAutomatic()) {
+				return "bigserial";
+			} else {
+				return "bigint";
+			}
+
+		default:
+			String typeName = (String) attr.getAdditionalInfo("SQLTypeName");
+			if (typeName != null) {
+				return typeName;
+			}
+
+			throw new UnsupportedDataTypeException(attr.getDataTypeName(), attr
+					.getType());
+		}
+	}
+
+	public int getProviderSRID(String srs) {
+		return -1;
+	}
+
+	public int getProviderSRID(IProjection srs) {
+		return -1;
+	}
+
+	public String getSqlFieldName(FeatureAttributeDescriptor attribute) {
+		return escapeFieldName(attribute.getName());
+	}
+
+	public String getSqlFieldDescription(FeatureAttributeDescriptor attr)
+			throws DataException {
+
+		/**
+		 * column_name data_type [ DEFAULT default_expr ] [ column_constraint [
+		 * ... ] ]
+		 *
+		 * where column_constraint is:
+		 *
+		 * [ CONSTRAINT constraint_name ] { NOT NULL | NULL | UNIQUE | PRIMARY
+		 * KEY | CHECK (expression) | REFERENCES reftable [ ( refcolumn ) ] [
+		 * MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ] [ ON DELETE action ] [ ON
+		 * UPDATE action ] } [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY
+		 * DEFERRED | INITIALLY IMMEDIATE ]
+		 */
+
+		StringBuilder strb = new StringBuilder();
+		// name
+		strb.append(escapeFieldName(attr.getName()));
+		strb.append(" ");
+
+		// Type
+		strb.append(this.getSqlColumnTypeDescription(attr));
+		strb.append(" ");
+
+		boolean allowNull = attr.allowNull()
+				&& !(attr.isPrimaryKey() || attr.isAutomatic());
+		// Default
+		if (attr.getDefaultValue() == null) {
+			if (allowNull) {
+				strb.append("DEFAULT NULL ");
+			}
+		} else {
+			String value = getDefaltFieldValueString(attr);
+			strb.append("DEFAULT '");
+			strb.append(value);
+			strb.append("' ");
+		}
+
+		// Null
+		if (allowNull) {
+			strb.append("NULL ");
+		} else {
+			strb.append("NOT NULL ");
+		}
+
+		// Primery key
+		if (attr.isPrimaryKey()) {
+			strb.append("PRIMARY KEY ");
+		}
+		return strb.toString();
+	}
+
+	protected String getDefaltFieldValueString(FeatureAttributeDescriptor attr)
+			throws WriteException {
+		return dalValueToJDBC(attr, attr.getDefaultValue()).toString();
+	}
+
+	public String compoundLimitAndOffset(long limit, long offset) {
+		StringBuilder sql = new StringBuilder();
+		// limit
+		if (limit > 0) {
+			sql.append(" limit ");
+			sql.append(limit);
+			sql.append(' ');
+		}
+
+		// offset
+		if (offset > 0) {
+			sql.append(" offset ");
+			sql.append(offset);
+			sql.append(' ');
+		}
+		return sql.toString();
+	}
+
+	public boolean supportOffset() {
+		return true;
+	}
+
+	public List getAdditionalSqlToCreate(NewDataStoreParameters ndsp,
+			FeatureType fType) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+
+	public String stringJoin(List listToJoin,String sep){
+		StringBuilder strb = new StringBuilder();
+		stringJoin(listToJoin,sep,strb);
+		return strb.toString();
+	}
+
+	public void stringJoin(List listToJoin, String sep, StringBuilder strb) {
+		if (listToJoin.size() < 1) {
+			return;
+		}
+		if (listToJoin.size() > 1) {
+			for (int i = 0; i < listToJoin.size() - 1; i++) {
+				strb.append(listToJoin.get(i));
+				strb.append(sep);
+			}
+		}
+		strb.append(listToJoin.get(listToJoin.size() - 1));
+	}
+
+	/**
+	 * Inform that provider has supports for geometry store and operations
+	 * natively
+	 *
+	 * @return
+	 */
+	protected boolean supportsGeometry() {
+		return false;
+	}
+
+	public boolean allowAutomaticValues() {
+		if (allowAutomaticValues == null) {
+			ConnectionAction action = new ConnectionAction(){
+
+				public Object action(Connection conn) throws DataException {
+
+					ResultSet rs;
+					try {
+						DatabaseMetaData meta = conn.getMetaData();
+						rs = meta.getTypeInfo();
+						try{
+							while (rs.next()) {
+								if (rs.getInt("DATA_TYPE") == java.sql.Types.INTEGER) {
+									if (rs.getBoolean("AUTO_INCREMENT")) {
+										return Boolean.TRUE;
+									} else {
+										return Boolean.FALSE;
+									}
+								}
+							}
+						}finally{
+							try{ rs.close();} catch (SQLException ex) {logger.error("Exception closing resulset", ex);};
+						}
+					} catch (SQLException e) {
+						throw new JDBCSQLException(e);
+					}
+					return Boolean.FALSE;
+				}
+
+			};
+
+
+
+			try {
+				allowAutomaticValues = (Boolean) doConnectionAction(action);
+			} catch (Exception e) {
+				logger.error("Exception checking for automatic integers", e);
+				allowAutomaticValues = Boolean.FALSE;
+			}
+		}
+		return allowAutomaticValues.booleanValue();
+	}
+
+	public boolean supportsUnion() {
+		if (supportsUnions == null) {
+			ConnectionAction action = new ConnectionAction() {
+
+				public Object action(Connection conn) throws DataException {
+
+					try {
+						DatabaseMetaData meta = conn.getMetaData();
+						return new Boolean(meta.supportsUnion());
+					} catch (SQLException e) {
+						throw new JDBCSQLException(e);
+					}
+				}
+
+			};
+
+			try {
+				supportsUnions = (Boolean) doConnectionAction(action);
+			} catch (Exception e) {
+				logger.error("Exception checking for unions support", e);
+				supportsUnions = Boolean.FALSE;
+			}
+		}
+		return supportsUnions.booleanValue();
+	}
+
+	protected String getIdentifierQuoteString() {
+		if (identifierQuoteString == null) {
+		ConnectionAction action = new ConnectionAction() {
+
+			public Object action(Connection conn) throws DataException {
+
+				try {
+					DatabaseMetaData meta = conn.getMetaData();
+					return meta.getIdentifierQuoteString();
+				} catch (SQLException e) {
+					throw new JDBCSQLException(e);
+				}
+			}
+
+		};
+
+		try {
+			identifierQuoteString = (String) doConnectionAction(action);
+		} catch (Exception e) {
+			logger.error("Exception checking for unions support", e);
+			identifierQuoteString = " ";
+			}
+		}
+		return identifierQuoteString;
+	}
+
+	protected boolean isReservedWord(String field) {
+		// TODO
+		return false;
+	}
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCHelper.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCStoreParameters.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCStoreParameters.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCStoreParameters.java	(revision 38285)
@@ -0,0 +1,289 @@
+/* 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.jdbc;
+
+import java.text.MessageFormat;
+
+import org.gvsig.fmap.dal.store.db.DBStoreParameters;
+
+/**
+ * Parameters class for JDBC generic provider
+ *
+ * @author jmvivo
+ *
+ */
+public class JDBCStoreParameters extends DBStoreParameters
+		implements JDBCConnectionParameters {
+
+	public static final String PARAMETERS_DEFINITION_NAME = "JDBCStoreParameters";
+
+	public JDBCStoreParameters() {
+		super(PARAMETERS_DEFINITION_NAME,JDBCStoreProvider.NAME);
+	}
+
+	protected JDBCStoreParameters(String parametersDefinitionName) {
+		super(parametersDefinitionName,JDBCStoreProvider.NAME);
+	}
+
+	protected JDBCStoreParameters(String parametersDefinitionName, String providerName) {
+		super(parametersDefinitionName,providerName);
+	}
+
+	public boolean isValid() {
+		return this.getHost() != null;
+	}
+
+	public String getHost() {
+		return (String) this.getDynValue(HOST_PARAMTER_NAME);
+	}
+
+	public Integer getPort() {
+		return (Integer) this.getDynValue(PORT_PARAMTER_NAME);
+	}
+
+	public String getDBName() {
+		return (String) this.getDynValue(DBNAME_PARAMTER_NAME);
+	}
+
+	public String getUser() {
+		return (String) this.getDynValue(USER_PARAMTER_NAME);
+	}
+
+	public String getPassword() {
+		return (String) this.getDynValue(PASSWORD_PARAMTER_NAME);
+	}
+
+	public void setHost(String host) {
+		this.setDynValue(HOST_PARAMTER_NAME, host);
+	}
+
+	public void setPort(int port) {
+		this.setDynValue(PORT_PARAMTER_NAME, new Integer(port));
+	}
+
+	public void setPort(Integer port) {
+		this.setDynValue(PORT_PARAMTER_NAME, port);
+	}
+
+	public void setDBName(String dbName) {
+		this.setDynValue(DBNAME_PARAMTER_NAME, dbName);
+	}
+
+	public void setUser(String user) {
+		this.setDynValue(USER_PARAMTER_NAME, user);
+	}
+
+	public void setPassword(String password) {
+		this.setDynValue(PASSWORD_PARAMTER_NAME, password);
+	}
+
+	/**
+	 * Set <code>JDBC Driver class name</code> parameter
+	 *
+	 * @param className
+	 */
+	public void setJDBCDriverClassName(String className) {
+		this.setDynValue(JDBC_DRIVER_CLASS_PARAMTER_NAME, className);
+	}
+
+	public String getJDBCDriverClassName() {
+		return (String) this.getDynValue(JDBC_DRIVER_CLASS_PARAMTER_NAME);
+	}
+
+	public String getCatalog() {
+		return (String) this.getDynValue(CATALOG_PARAMTER_NAME);
+	}
+
+
+	/**
+	 * Set <code>catalog</code> parameter
+	 *
+	 * @param className
+	 */
+	public void setCatalog(String catalog) {
+		this.setDynValue(CATALOG_PARAMTER_NAME, catalog);
+	}
+
+	public String getSchema() {
+		return (String) this.getDynValue(SCHEMA_PARAMTER_NAME);
+	}
+
+	/**
+	 * Set <code>schema</code> parameter
+	 *
+	 * @param className
+	 */
+	public void setSchema(String schema) {
+		this.setDynValue(SCHEMA_PARAMTER_NAME, schema);
+	}
+
+	public String getTable() {
+		return (String) this.getDynValue(TABLE_PARAMTER_NAME);
+	}
+
+	public void setTable(String table) {
+		this.setDynValue(TABLE_PARAMTER_NAME, table);
+	}
+
+	public String getFieldsString() {
+		return (String) this.getDynValue(FIELDS_PARAMTER_NAME);
+	}
+
+	public String[] getFields() {
+		String fields = (String) this.getDynValue(FIELDS_PARAMTER_NAME);
+		if (fields == null) {
+			return null;
+		}
+		// FIXME check for fields with spaces and special chars
+		return fields.split(",");
+	}
+
+	public void setFields(String fields) {
+		this.setDynValue(FIELDS_PARAMTER_NAME, fields);
+	}
+
+	public void setFields(String[] fields) {
+		StringBuilder str = new StringBuilder();
+		for (int i = 0; i < fields.length - 1; i++) {
+			str.append(fields[i]);
+			str.append(",");
+		}
+		str.append(fields[fields.length - 1]);
+
+		this.setDynValue(FIELDS_PARAMTER_NAME, str.toString());
+	}
+
+	public String getSQL() {
+		return (String) this.getDynValue(SQL_PARAMTER_NAME);
+	}
+
+	public void setSQL(String sql) {
+		this.setDynValue(SQL_PARAMTER_NAME, sql);
+	}
+
+	public String getBaseFilter() {
+		return (String) this.getDynValue(BASEFILTER_PARAMTER_NAME);
+	}
+
+	public void setBaseFilter(String initialFilter) {
+		this.setDynValue(BASEFILTER_PARAMTER_NAME, initialFilter);
+	}
+
+	public String getBaseOrder() {
+		return (String) this.getDynValue(BASEORDER_PARAMTER_NAME);
+	}
+
+	public void setBaseOrder(String order) {
+		this.setDynValue(BASEORDER_PARAMTER_NAME, order);
+	}
+
+	public String getPkFieldsString() {
+		return (String) this.getDynValue(PKFIELDS_PARAMTER_NAME);
+	}
+
+	public String[] getPkFields() {
+		String fields = (String) this.getDynValue(PKFIELDS_PARAMTER_NAME);
+		if (fields == null) {
+			return null;
+		}
+		// FIXME check for fields with spaces and special chars
+		return fields.split(",");
+	}
+
+	public void setPkFields(String fields) {
+		this.setDynValue(PKFIELDS_PARAMTER_NAME, fields);
+	}
+
+	public void setPkFields(String[] fields) {
+		StringBuilder str = new StringBuilder();
+		for (int i = 0; i < fields.length - 1; i++) {
+			str.append(fields[i]);
+			str.append(",");
+		}
+		str.append(fields[fields.length - 1]);
+
+		this.setDynValue(PKFIELDS_PARAMTER_NAME, str.toString());
+	}
+
+	/**
+	 * Return table <code>name</code> or <code>schema.tableName</code> if
+	 * <code>schema</code> parameter is set.
+	 *
+	 * @return
+	 */
+	public String tableID() {
+		if (this.getSchema() == null || this.getSchema() == "") {
+            return escapeName(this.getTable());
+		}
+        return escapeName(this.getSchema()) + "." + escapeName(this.getTable());
+	}
+
+    protected String escapeName(String name) {
+        return "\"".concat(name).concat("\"");
+    }
+
+	/**
+	 * Compound a string that can identify the source
+	 *
+	 * @return
+	 */
+	public String getSourceId() {
+		if (getTable() != null) {
+			return MessageFormat.format(
+					"provider={0}:url=\"{1}\":table=\"{2}\":user={3}:driverclass={4}", 
+					this.getDataStoreName(),
+					this.getUrl(),
+					this.getTable(),
+					this.getUser(),
+					this.getJDBCDriverClassName()
+			);
+		}
+		return MessageFormat.format(
+				"provider={0}:url=\"{1}\":sql=\"{2}\":user={3}:driverclass={4}", 
+				this.getDataStoreName(),
+				this.getUrl(),
+				this.getSQL(),
+				this.getUser(),
+				this.getJDBCDriverClassName()
+		);
+	}
+
+	public String getUrl() {
+		return (String) this.getDynValue(URL_PARAMTER_NAME);
+	}
+
+	/**
+	 * Set <code>JDBC connection url</code> parameter
+	 *
+	 * @param url
+	 */
+	public void setUrl(String url) {
+		this.setDynValue(URL_PARAMTER_NAME, url);
+	}
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/jdbc/JDBCStoreParameters.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLResource.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLResource.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLResource.java	(revision 38285)
@@ -0,0 +1,95 @@
+/* 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.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;
+
+public class PostgreSQLResource extends JDBCResource {
+
+	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() });
+	}
+
+	protected void connectToDB() throws DataException {
+		super.connectToDB();
+	}
+
+	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;
+	}
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLResource.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLServerExplorer.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLServerExplorer.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLServerExplorer.java	(revision 38285)
@@ -0,0 +1,227 @@
+/* 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.List;
+
+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.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());
+	}
+
+
+	protected 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;
+	}
+
+	protected void checkIsMine(DataStoreParameters dsp) {
+		if (!(dsp instanceof PostgreSQLStoreParameters)) {
+			// FIXME Excpetion ???
+			throw new IllegalArgumentException(
+					"not instance of PostgreSQLStoreParameters");
+		}
+		super.checkIsMine(dsp);
+
+		PostgreSQLStoreParameters pgp = (PostgreSQLStoreParameters) 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{
+						st.execute(sqlDrop);
+					} catch (SQLException e) {
+						throw new JDBCExecuteSQLException(sqlDrop, e);
+					}
+
+					try {
+						st.execute(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;
+	}
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLServerExplorer.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLStoreProvider.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLStoreProvider.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLStoreProvider.java	(revision 38285)
@@ -0,0 +1,317 @@
+/* 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.List;
+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 {
+		return new PostgreSQLHelper(this, getPGParameters());
+	}
+
+	protected String fixFilter(String filter) {
+		if (filter == null) {
+			return null;
+		}
+
+		// Transform SRS to code
+		// GeomFromText\s*\(\s*'[^']*'\s*,\s*('[^']*')\s*\)
+		Pattern pattern = Pattern
+				.compile("GeomFromText\\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("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())
+					+ " = 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;
+	}
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLStoreProvider.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLNewStoreParameters.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLNewStoreParameters.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLNewStoreParameters.java	(revision 38285)
@@ -0,0 +1,51 @@
+/* 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.feature.EditableFeatureType;
+import org.gvsig.fmap.dal.feature.FeatureType;
+import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters;
+
+public class PostgreSQLNewStoreParameters extends PostgreSQLStoreParameters
+		implements NewFeatureStoreParameters {
+
+    public static final String PARAMETERS_DEFINITION_NAME = "PostgreSQLNewStoreParameters";
+
+    public PostgreSQLNewStoreParameters() {
+    	super(PARAMETERS_DEFINITION_NAME);
+    }
+    
+	public EditableFeatureType getDefaultFeatureType() {
+		return (EditableFeatureType) this.getDynValue(FEATURETYPE_PARAMTER_NAME);
+	}
+
+	public void setDefaultFeatureType(FeatureType featureType) {
+		this.setDynValue(FEATURETYPE_PARAMTER_NAME, featureType);
+	}
+
+}
\ No newline at end of file

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLNewStoreParameters.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLResourceParameters.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLResourceParameters.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLResourceParameters.java	(revision 38285)
@@ -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));
+	}
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLResourceParameters.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLServerExplorerParameters.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLServerExplorerParameters.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLServerExplorerParameters.java	(revision 38285)
@@ -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();
+	}
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLServerExplorerParameters.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLHelper.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLHelper.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLHelper.java	(revision 38285)
@@ -0,0 +1,792 @@
+/* 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.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.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.UnsupportedDataTypeException;
+import org.gvsig.fmap.dal.feature.exception.UnsupportedGeometryException;
+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.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.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.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();
+
+
+	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 = st.executeQuery(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 asbinary(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 __extentfield__ ");
+		} else {
+			strb.append(storeParams.tableID());
+		}
+
+
+		if (limit != null){
+			strb.append(" where  intersects(GeomFromText('");
+			strb.append(limit.toString());
+			strb.append("')), envelope(");
+			strb.append(escapeFieldName(geometryAttrName));
+			strb.append(")) ");
+		}
+
+		final String sql = strb.toString();
+
+		GeometryManager geoMan = GeometryLocator.getGeometryManager();
+
+		this.open();
+
+		return (Envelope) getResource().execute(new ResourceAction() {
+			public Object run() throws Exception {
+				ResultSet rs = null;
+				Statement st = null;
+				String schema = null;
+				Connection conn = null;
+				Envelope fullEnvelope = null;
+				try {
+
+					conn = getConnection();
+					st = conn.createStatement();
+					try {
+						rs = st.executeQuery(sql);
+					} catch (java.sql.SQLException e) {
+						throw new JDBCExecuteSQLException(sql, e);
+					}
+					if (!rs.next()) {
+						return null;
+					}
+
+					byte[] data = rs.getBytes(1);
+					if (data == null) {
+						return null;
+					}
+					initializeFromWKBOperation();
+					fromWKBContext.setData(data);
+					Geometry geom =
+							(Geometry) fromWKB.invoke(null, fromWKBContext);
+
+					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;
+
+					if (!a0.field.equals(a1.field)) {
+						return -1;
+					}
+					if (!a0.table.equals(a1.table)) {
+						return -1;
+					}
+					if (!a0.schema.equals(a1.schema)) {
+						return -1;
+					}
+					return 0;
+				}
+			};
+			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 = st.executeQuery(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:
+			throw new UnsupportedGeometryException(geometryType,
+					geometrySubType);
+		}
+		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 {
+				// select srid from spatial_ref_sys where auth_name = 'EPSG' and
+				// auth_srid = 23030
+				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 = st.executeQuery();
+					} 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());
+		strb.append("', ");
+		// strb.append("-1");
+		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());
+
+		/*ALTER TABLE muni10000_peq_test DROP CONSTRAINT enforce_srid_the_geom;*/
+		/*
+		strb = new StringBuilder();
+		strb.append("Alter table ");
+		if (schema != null && schema.length() > 0) {
+			strb.append(schema);
+			strb.append(".");
+		}
+		strb.append("f_table_name = '");
+		strb.append(table);
+		strb.append("' AND f_geometry_column = '");
+		strb.append(attr.getName());
+		strb.append("' AND srid = -1");
+
+
+		sqls.add(strb.toString());
+		*/
+		return sqls;
+	}
+
+	public String getSqlFieldName(FeatureAttributeDescriptor attribute) {
+		if (attribute.getType() == DataTypes.GEOMETRY) {
+			return "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")) {
+				return type.add(rsMetadata.getColumnName(colIndex),
+						DataTypes.GEOMETRY);
+
+			}
+		}
+
+		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()));
+			}
+		}
+
+		return result;
+	}
+
+	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;
+	}
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLHelper.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLStoreParameters.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLStoreParameters.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLStoreParameters.java	(revision 38285)
@@ -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();
+	}
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLStoreParameters.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLConnectionParameters.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLConnectionParameters.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLConnectionParameters.java	(revision 38285)
@@ -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();
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLConnectionParameters.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLLibrary.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLLibrary.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLLibrary.java	(revision 38285)
@@ -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

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLLibrary.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLSetProvider.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLSetProvider.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLSetProvider.java	(revision 38285)
@@ -0,0 +1,66 @@
+/* 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.DataException;
+import org.gvsig.fmap.dal.feature.FeatureQuery;
+import org.gvsig.fmap.dal.feature.FeatureType;
+import org.gvsig.fmap.dal.store.jdbc.JDBCSetProvider;
+import org.gvsig.fmap.dal.store.jdbc.JDBCStoreProvider;
+
+/**
+ * @author jmvivo
+ *
+ */
+public class PostgreSQLSetProvider extends JDBCSetProvider {
+
+	public PostgreSQLSetProvider(JDBCStoreProvider store, FeatureQuery query,
+			FeatureType featureType) throws DataException {
+		super(store, query, featureType);
+		// TODO Auto-generated constructor stub
+	}
+
+
+	/*
+	 * (non-Javadoc)
+	 *
+	 * @see org.gvsig.fmap.dal.feature.spi.FeatureSetProvider#canFilter()
+	 */
+	public boolean canFilter() {
+		// TODO more checks
+		if (!super.canFilter()) {
+			return false;
+		}
+		return true;
+
+	}
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLSetProvider.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/db/DBHelper.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/db/DBHelper.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/db/DBHelper.java	(revision 38285)
@@ -0,0 +1,67 @@
+package org.gvsig.fmap.dal.store.db;
+
+import java.io.InputStream;
+
+import org.gvsig.metadata.MetadataLocator;
+import org.gvsig.metadata.MetadataManager;
+import org.gvsig.metadata.exceptions.MetadataException;
+import org.gvsig.tools.ToolsLocator;
+import org.gvsig.tools.dynobject.DynObject;
+import org.gvsig.tools.persistence.PersistenceManager;
+
+public final class DBHelper {
+
+	private DBHelper() {
+		// Do nothing
+	}
+	
+	@SuppressWarnings("unchecked")
+	public static void registerParametersDefinition(String name, Class theClass, String filename) {
+		PersistenceManager manager = ToolsLocator.getPersistenceManager();
+		if (manager.getDefinition(name) == null) {
+			InputStream resource = theClass.getResourceAsStream(filename);
+			if( resource==null ) {
+				throw new IllegalArgumentException("File '"+ filename + "' not found as a resource of '"+theClass.getName()+"'.");
+			}
+			manager.addDefinition(
+					theClass,
+					name, 
+					resource,
+					theClass.getClassLoader(), 
+					null, 
+					null
+			);
+		}
+	}
+	
+	@SuppressWarnings("unchecked")
+	public static void registerMetadataDefinition(String name, Class theClass, String filename) throws MetadataException {
+		MetadataManager manager = MetadataLocator.getMetadataManager();
+		if( manager.getDefinition(name)==null ) {
+			InputStream resource = theClass.getResourceAsStream(filename);
+			if( resource==null ) {
+				throw new IllegalArgumentException("File '"+ filename + "' not found as a resource of '"+theClass.getName()+"'.");
+			}
+			manager.addDefinition(
+					name, 
+					theClass.getResourceAsStream(filename),
+					theClass.getClassLoader()
+			);
+		}
+	}
+
+	public static DynObject newParameters(String name) {
+    	return ToolsLocator.getDynObjectManager()
+			.createDynObject(
+				ToolsLocator.getPersistenceManager().getDefinition(name)
+			);
+	}
+	
+	public static DynObject newMetadataContainer(String name) {
+    	return ToolsLocator.getDynObjectManager()
+			.createDynObject(
+				MetadataLocator.getMetadataManager().getDefinition(name)
+			);
+	}
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/db/DBHelper.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/db/DBStoreParameters.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/db/DBStoreParameters.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/db/DBStoreParameters.java	(revision 38285)
@@ -0,0 +1,623 @@
+/* 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.db;
+
+import org.cresques.cts.IProjection;
+import org.gvsig.fmap.dal.DataStoreParameters;
+import org.gvsig.fmap.dal.feature.Feature;
+import org.gvsig.fmap.dal.serverexplorer.db.DBConnectionParameter;
+import org.gvsig.fmap.dal.spi.AbstractDataParameters;
+import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
+import org.gvsig.fmap.geom.primitive.Envelope;
+import org.gvsig.tools.dynobject.DelegatedDynObject;
+
+/**
+ * Abstract Data base Store Parameters
+ *
+ * @author jmvivo
+ *
+ */
+public abstract class DBStoreParameters extends AbstractDataParameters
+		implements
+		DataStoreParameters, DBConnectionParameter {
+
+	public static final String PARAMETERS_DEFINITION_NAME = "DBStoreParameters";
+
+	/**
+	 * Parameter name for specify the feature type in the creacion of
+	 * news stores.
+	 * 
+	 * Is defined only in "new" paramaters.
+	 *
+	 */
+	public static final String FEATURETYPE_PARAMTER_NAME = "FeatureType";
+    
+
+	/**
+	 * Parameter name for <code>sql</code><br>
+	 *
+	 * @see #getSQL()
+	 * @see #setSQL(String)
+	 */
+	public static final String SQL_PARAMTER_NAME = "SQL";
+
+	/**
+	 * Parameter name for <code>fields</code><br>
+	 *
+	 * @see #getFields()
+	 * @see #getFieldsString()
+	 * @see #setFields(String)
+	 * @see #setFields(String[])
+	 */
+	public static final String FIELDS_PARAMTER_NAME = "Fields";
+
+	/**
+	 * Parameter name for <code>initial filter</code><br>
+	 *
+	 * @see #getBaseFilter()
+	 * @see #setBaseFilter(String)
+	 */
+	public static final String BASEFILTER_PARAMTER_NAME = "BaseFilter";
+
+	/**
+	 * Parameter name for <code>initial order</code><br>
+	 *
+	 * @see #getBaseOrder()
+	 * @see #setBaseOrder(String)
+	 */
+	public static final String BASEORDER_PARAMTER_NAME = "BaseOrder";
+
+	/**
+	 * Parameter name for <code>pk fields</code><br>
+	 *
+	 * @see #getPkFields()
+	 * @see #getPkFieldsString()
+	 * @see #setPkFields(String)
+	 * @see #setPkFields(String[])
+	 */
+	public static final String PKFIELDS_PARAMTER_NAME = "PKFields";
+
+	/**
+	 * Parameter name for <code>default geometry</code><br>
+	 *
+	 * @see #getDefaultGeometryField()
+	 * @see #setDefaultGeometryField(String)
+	 */
+	public static final String DEFAULTGEOMETRY_PARAMTER_NAME = "DefaultGeometryField";
+
+	/**
+	 * Parameter name for the name of <code>table</code><br>
+	 *
+	 * @see #getTable()
+	 * @see #setTable(String)
+	 */
+	public static final String TABLE_PARAMTER_NAME = "Table";
+
+	/**
+	 * Parameter name for <code>working area</code><br>O
+	 *
+	 * @see #getWorkingArea()
+	 * @see #setWorkingArea(Envelope)
+	 */
+	public static final String WORKINGAREA_PARAMTER_NAME = "Workingarea";
+
+
+	/**
+	 * Parameter name for <code>CRS</code><br>
+	 * 
+	 * @see #setSRSID(String)
+	 * @see #getSRS()
+	 * @see #setSRS(IProjection)
+	 */
+	public static final String CRS_PARAMTER_NAME = "CRS";
+
+	/**
+	 * This instance contains the value of the current parameters.
+	 */
+	private DelegatedDynObject parameters;
+
+	public DBStoreParameters(String parametersDefinitionName, String providerName) {
+		this.parameters  = (DelegatedDynObject) DBHelper.newParameters(parametersDefinitionName);
+		this.setDynValue( DataStoreProviderServices.PROVIDER_PARAMTER_NAME, providerName);
+	}
+	
+	protected DelegatedDynObject getDelegatedDynObject() {
+		return parameters;
+	}
+
+	public String getDataStoreName() {
+		return (String) this.getDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME);
+	}
+
+	public String getDescription() {
+		return this.getDynClass().getDescription();
+	}
+
+	public boolean isValid() {
+		return this.getHost() != null;
+	}
+
+	public String getHost() {
+		return (String) this.getDynValue(HOST_PARAMTER_NAME);
+	}
+
+	public Integer getPort() {
+		return (Integer) this.getDynValue(PORT_PARAMTER_NAME);
+	}
+
+	public String getDBName() {
+		return (String) this.getDynValue(DBNAME_PARAMTER_NAME);
+	}
+
+	public String getUser() {
+		return (String) this.getDynValue(USER_PARAMTER_NAME);
+	}
+
+	public String getPassword() {
+		return (String) this.getDynValue(PASSWORD_PARAMTER_NAME);
+	}
+
+	public void setHost(String host) {
+		this.setDynValue(HOST_PARAMTER_NAME, host);
+	}
+
+	public void setPort(int port) {
+		this.setDynValue(PORT_PARAMTER_NAME, new Integer(port));
+	}
+
+	/**
+	 * Set <code>port/code> parameter value
+	 *
+	 * @param port
+	 */
+	public void setPort(Integer port) {
+		this.setDynValue(PORT_PARAMTER_NAME, port);
+	}
+
+	/**
+	 * Set <code>data base name/code> parameter value
+	 *
+	 * @param data
+	 *            base name
+	 */
+	public void setDBName(String dbName) {
+		this.setDynValue(DBNAME_PARAMTER_NAME, dbName);
+	}
+
+	/**
+	 * Set <code>user/code> parameter value
+	 *
+	 * @param user
+	 */
+	public void setUser(String user) {
+		this.setDynValue(USER_PARAMTER_NAME, user);
+	}
+
+	/**
+	 * Set <code>password/code> parameter value
+	 *
+	 * @param password
+	 */
+	public void setPassword(String password) {
+		this.setDynValue(PASSWORD_PARAMTER_NAME, password);
+	}
+
+	/**
+	 * Get <code>table</code> parameter value<br>
+	 * <br>
+	 *
+	 * This parameters describes what table or view we want to connect.<br>
+	 *
+	 * Not used if <code>sql</code> parameter set.
+	 *
+	 *
+	 * @param password
+	 *
+	 * @see #setTable(String)
+	 * @see #getSQL()
+	 * @see #setSQL(String)
+	 */
+	public String getTable() {
+		return (String) this.getDynValue(TABLE_PARAMTER_NAME);
+	}
+
+	/**
+	 * Set <code>table</code> parameter value<br>
+	 * <br>
+	 *
+	 * This parameters describes what table or view we want to connect.<br>
+	 *
+	 * Not used if <code>sql</code> parameter set.
+	 *
+	 *
+	 * @param password
+	 *
+	 * @see #getTable(String)
+	 * @see #getSQL()
+	 * @see #setSQL(String)
+	 */
+	public void setTable(String table) {
+		this.setDynValue(TABLE_PARAMTER_NAME, table);
+	}
+
+	/**
+	 * Get a comma separated list of the field names that we want to use.<br>
+	 * <br>
+	 *
+	 * A <code>null</code> or empty string means that we want all fields
+	 * available.
+	 *
+	 * @return
+	 * @see #getFields()
+	 * @see #setFields(String)
+	 * @see #setFields(String[])
+	 */
+	public String getFieldsString() {
+		return (String) this.getDynValue(FIELDS_PARAMTER_NAME);
+	}
+
+	/**
+	 * Get an array of the field names that we want to use.<br>
+	 * <br>
+	 *
+	 * A <code>null</code> means that we want all fields available.
+	 *
+	 * @return
+	 * @see #getFieldsString()
+	 * @see #setFields(String)
+	 * @see #setFields(String[])
+	 */
+	public String[] getFields() {
+		String fields = (String) this.getDynValue(FIELDS_PARAMTER_NAME);
+		if (fields == null) {
+			return null;
+		}
+		// FIXME check for fields with spaces and special chars
+		return fields.split(",");
+	}
+
+	/**
+	 * Set a comma separated list of the field names that we want to use.<br>
+	 * <br>
+	 *
+	 * A <code>null</code> means that we want all fields available.
+	 *
+	 * @return
+	 * @see #getFields()
+	 * @see #getFieldsString()
+	 * @see #setFields(String[])
+	 */
+	public void setFields(String fields) {
+		this.setDynValue(FIELDS_PARAMTER_NAME, fields);
+	}
+
+	/**
+	 * Set an array of the field names that we want to use.<br>
+	 * <br>
+	 *
+	 * A <code>null</code> means that we want all fields available.
+	 *
+	 * @return
+	 * @see #getFieldsString()
+	 * @see #getFields()
+	 * @see #setFields(String)
+	 */
+	public void setFields(String[] fields) {
+		StringBuilder str = new StringBuilder();
+		for (int i = 0; i < fields.length - 1; i++) {
+			str.append(fields[i]);
+			str.append(",");
+		}
+		str.append(fields.length - 1);
+
+		this.setDynValue(FIELDS_PARAMTER_NAME, fields);
+	}
+
+	/**
+	 * Get the SQL to use as source of the store instead a table or a view.<br>
+	 * <br>
+	 *
+	 * If this property is set the store changes his work flow:
+	 * <ul>
+	 * <li>store is in <i>read only</i> mode.</li>
+	 * <li><code>table</code> property is ignored.</li>
+	 * <li><code>pkFields</code> is not identified automatically</li>
+	 * <li>filter and order will be resolved locally <i>(pour performance)</i></li>
+	 * </ul>
+	 *
+	 * @return sql to use
+	 *
+	 * @see #getTable()
+	 * @see #setTable()
+	 * @see #getPkFields()
+	 * @see #setPkFields(String)
+	 */
+	public String getSQL() {
+		return (String) this.getDynValue(SQL_PARAMTER_NAME);
+	}
+
+	/**
+	 * Set the SQL to use as source of the store instead a table or a view.<br>
+	 * <br>
+	 * <strong>Note:</strong>see {@link #getSQL()} for description
+	 *
+	 * @see #getSQL()
+	 * @see #getTable()
+	 * @see #setTable()
+	 * @see #getPkFields()
+	 * @see #setPkFields(String)
+	 */
+	public void setSQL(String sql) {
+		this.setDynValue(SQL_PARAMTER_NAME, sql);
+	}
+
+	/**
+	 * Get initial filter to use.<br>
+	 * <br>
+	 *
+	 * This filter is passed to BD provider on each request as a base filter.
+	 *
+	 * @return filter
+	 *
+	 * @see #setBaseFilter(String)
+	 */
+	public String getBaseFilter() {
+		return (String) this.getDynValue(BASEFILTER_PARAMTER_NAME);
+	}
+
+	/**
+	 * Set initial filter to use.<br>
+	 * <br>
+	 *
+	 * This filter is passed to BD provider on each request as a base filter.
+	 *
+	 * @return filter
+	 *
+	 * @see #getInitialFilter(String)
+	 */
+	public void setBaseFilter(String filter) {
+		this.setDynValue(BASEFILTER_PARAMTER_NAME, filter);
+	}
+
+	/**
+	 * Get initial order to use.<br>
+	 * <br>
+	 *
+	 * This order is used if no custom order is request in query.
+	 *
+	 * @return order
+	 *
+	 * @see #setBaseOrder(String)
+	 */
+	public String getBaseOrder() {
+		return (String) this.getDynValue(BASEORDER_PARAMTER_NAME);
+	}
+
+	/**
+	 * Set initial order to use.<br>
+	 * <br>
+	 *
+	 * This order is used if no custom order is request in query.
+	 *
+	 * @return filter
+	 *
+	 * @see #getBaseOrder()
+	 */
+	public void setBaseOrder(String order) {
+		this.setDynValue(BASEORDER_PARAMTER_NAME, order);
+	}
+
+	/**
+	 * Get a comma separated list of the field names that compound the primary
+	 * key.<br>
+	 * <br>
+	 *
+	 * A <code>null</code> or empty string means that library must detect this
+	 * information.<br>
+	 * <br>
+	 * <strong>Note:</strong>If this parameters is undefined, the library can't
+	 * do this detection, some services will don't be available for this store
+	 * (<i>like selection, editing or {@link Feature#getReference()}</i>)
+	 *
+	 * @return
+	 * @see #getPkFields()
+	 * @see #setPkFields(String)
+	 * @see #setPkFields(String[])
+	 */
+	public String getPkFieldsString() {
+		return (String) this.getDynValue(PKFIELDS_PARAMTER_NAME);
+	}
+
+	/**
+	 * Get an array of the field names that compound the primary key.<br>
+	 * <br>
+	 *
+	 * A <code>null</code> or empty string means that library must detect this
+	 * information.<br>
+	 * <br>
+	 * <strong>Note:</strong> see {@link #getPkFieldsString()}
+	 *
+	 * @return
+	 * @see #getPkFieldsString()
+	 * @see #setPkFields(String)
+	 * @see #setPkFields(String[])
+	 */
+	public String[] getPkFields() {
+		String fields = (String) this.getDynValue(PKFIELDS_PARAMTER_NAME);
+		if (fields == null) {
+			return null;
+		}
+		// FIXME check for fields with spaces and special chars
+		return fields.split(",");
+	}
+
+	/**
+	 * Set a comma separated list of the field names that compound the primary
+	 * key.<br>
+	 * <br>
+	 *
+	 * A <code>null</code> or empty string means that library must detect this
+	 * information.<br>
+	 * <br>
+	 * <strong>Note:</strong> see {@link #getPkFieldsString()}
+	 *
+	 * @return
+	 * @see #getPkFields()
+	 * @see #getPkFieldsString()
+	 * @see #setPkFields(String[])
+	 */
+	public void setPkFields(String fields) {
+		this.setDynValue(PKFIELDS_PARAMTER_NAME, fields);
+	}
+
+	/**
+	 * Set an array of the field names that compound the primary key.<br>
+	 * <br>
+	 *
+	 * A <code>null</code> or empty string means that library must detect this
+	 * information.<br>
+	 * <br>
+	 * <strong>Note:</strong> see {@link #getPkFieldsString()}
+	 *
+	 * @return
+	 * @see #getPkFieldsString()
+	 * @see #getPkFieldsString()
+	 * @see #setPkFields(String)
+	 */
+	public void setPkFields(String[] fields) {
+		StringBuilder str = new StringBuilder();
+		for (int i = 0; i < fields.length - 1; i++) {
+			str.append(fields[i]);
+			str.append(",");
+		}
+		str.append(fields.length - 1);
+
+		this.setDynValue(PKFIELDS_PARAMTER_NAME, fields);
+	}
+
+	/**
+	 * Return the geometry field to use like default geometry (<i>see
+	 * {@link Feature#getDefaultGeometry()}</i>)<br>
+	 * <br>
+	 *
+	 * This option is supported only in geometry providers.<br>
+	 * If this parameters is not set and store has only one field geometry then
+	 * library uses that field as default
+	 *
+	 * @return
+	 *
+	 * @see #setDefaultGeometryField(String)
+	 */
+	public String getDefaultGeometryField() {
+		return (String) this.getDynValue(DEFAULTGEOMETRY_PARAMTER_NAME);
+	}
+
+	/**
+	 * Set the geometry field to use like default geometry.<br>
+	 * See {@link #getDefaultGeometryField()} for description.
+	 *
+	 * @param geomName
+	 *
+	 * @see #getDefaultGeometryField()
+	 */
+	public void setDefaultGeometryField(String geomName) {
+		this.setDynValue(DEFAULTGEOMETRY_PARAMTER_NAME, geomName);
+	}
+
+	/**
+	 * Get the filter by area of {@link #getDefaultGeometryField()} used in this
+	 * store.<br>
+	 * <br>
+	 *
+	 * Supported only for stores with geometric fields
+	 *
+	 * @return
+	 */
+	public Envelope getWorkingArea() {
+		return (Envelope) this.getDynValue(WORKINGAREA_PARAMTER_NAME);
+	}
+
+	/**
+	 * Set the filter by area of {@link #getDefaultGeometryField()} used in this
+	 * store.<br>
+	 * <br>
+	 *
+	 * Supported only for stores with geometric fields
+	 *
+	 */
+	public void setWorkingArea(Envelope workingArea) {
+		this.setDynValue(WORKINGAREA_PARAMTER_NAME, workingArea);
+	}
+
+	/**
+	 * Set manually the SRS for the <code>default geometry</code> field of this
+	 * layer.<br>
+	 * <br>
+	 * 
+	 * if is set to <code>null</code> or empty string means that the library
+	 * must detect it automatically.<br>
+	 * <br>
+	 * 
+	 * Supported only for stores with geometric fields.
+	 * 
+	 * @return
+	 * 
+	 * @see #setSRSID(String)
+	 * @see #getSRSID()
+	 * @see #getSRS()
+	 */
+	public void setCRS(IProjection srs) {
+		setDynValue(CRS_PARAMTER_NAME, srs);
+	}
+
+	public void setCRS(String srs) {
+		setDynValue(CRS_PARAMTER_NAME, srs);
+	}
+
+	/**
+	 * Get the SRS id string set manually for the <code>default geometry</code>
+	 * field of this layer.<br>
+	 * <br>
+	 *
+	 * if is set to <code>null</code> means that the library must detect it
+	 * automatically.<br>
+	 * <br>
+	 *
+	 * Supported only for stores with geometric fields.
+	 *
+	 * @return
+	 *
+	 * @see #setSRSID(String)
+	 * @see #getSRS()
+	 * @see #setSRS(IProjection)
+	 */
+	public IProjection getCRS() {
+		return (IProjection) getDynValue(CRS_PARAMTER_NAME);
+	}
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/db/DBStoreParameters.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/db/DBStoreLibrary.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/db/DBStoreLibrary.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/db/DBStoreLibrary.java	(revision 38285)
@@ -0,0 +1,67 @@
+/* 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.db;
+
+import org.gvsig.fmap.dal.DALLibrary;
+import org.gvsig.fmap.dal.resource.db.DBResourceLibrary;
+import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorerParameters;
+import org.gvsig.tools.library.AbstractLibrary;
+import org.gvsig.tools.library.LibraryException;
+
+/**
+ * Data Base Store Library intialization
+ * 
+ *
+ */
+public class DBStoreLibrary extends AbstractLibrary {
+	
+    @Override
+    public void doRegistration() {
+        registerAsServiceOf(DALLibrary.class);
+        require(DBResourceLibrary.class);
+    }
+
+	@Override
+	protected void doInitialize() throws LibraryException {
+	}
+
+	@Override
+	protected void doPostInitialize() throws LibraryException {
+		DBHelper.registerParametersDefinition(
+				DBStoreParameters.PARAMETERS_DEFINITION_NAME,
+				DBStoreParameters.class,
+				"DBParameters.xml"
+		);
+		DBHelper.registerParametersDefinition(
+				DBServerExplorerParameters.PARAMETERS_DEFINITION_NAME, 
+				DBServerExplorerParameters.class, 
+				"DBParameters.xml"
+		);
+	}
+	
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/db/DBStoreLibrary.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/db/FeatureTypeHelper.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/db/FeatureTypeHelper.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/db/FeatureTypeHelper.java	(revision 38285)
@@ -0,0 +1,15 @@
+package org.gvsig.fmap.dal.store.db;
+
+import java.util.Iterator;
+
+import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
+import org.gvsig.fmap.dal.feature.FeatureType;
+
+public final class FeatureTypeHelper {
+	@SuppressWarnings("unchecked")
+	public static  Iterator<FeatureAttributeDescriptor> iterator(FeatureType type) {
+		return type.iterator();
+	}
+	
+}
+

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/db/FeatureTypeHelper.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLHelper.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLHelper.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLHelper.java	(revision 38285)
@@ -0,0 +1,422 @@
+/* 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.mysql;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import org.gvsig.fmap.dal.DALLocator;
+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.feature.EditableFeatureAttributeDescriptor;
+import org.gvsig.fmap.dal.feature.EditableFeatureType;
+import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
+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.JDBCHelper;
+import org.gvsig.fmap.dal.store.jdbc.JDBCHelperUser;
+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.JDBCExecuteSQLException;
+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.exception.BaseException;
+
+/**
+ * @author jmvivo
+ *
+ */
+public class MySQLHelper extends JDBCHelper {
+
+	MySQLHelper(JDBCHelperUser consumer,
+			MySQLConnectionParameters params)
+			throws InitializeException {
+
+		super(consumer, params);
+	}
+
+	protected void initializeResource() throws InitializeException {
+		ResourceManagerProviderServices manager = (ResourceManagerProviderServices) DALLocator
+		.getResourceManager();
+		MySQLResource resource = (MySQLResource) manager
+		.createAddResource(
+				MySQLResource.NAME, new Object[] {
+						params.getUrl(), params.getHost(),
+						params.getPort(), params.getDBName(), params.getUser(),
+						params.getPassword(),
+						params.getJDBCDriverClassName(),
+						((MySQLConnectionParameters) params).getUseSSL() });
+		this.setResource(resource);
+	}
+
+
+	protected String getDefaultSchema(Connection conn)
+			throws JDBCException {
+		if (defaultSchema == null) {
+			defaultSchema = params.getDBName();
+		}
+
+		return defaultSchema;
+	}
+
+	public Envelope getFullEnvelopeOfField(
+			JDBCStoreParameters storeParams,
+			String geometryAttrName, Envelope limit)
+			throws DataException {
+
+		StringBuilder strb = new StringBuilder();
+		strb.append("Select asbinary(envelope(");
+		strb.append(geometryAttrName);
+		strb.append(")) from ");
+
+		if (storeParams.getSQL() != null
+				&& storeParams.getSQL().trim().length() == 0) {
+			strb.append('(');
+			strb.append(storeParams.getSQL());
+			strb.append(") as __tmp__ ");
+		} else {
+			strb.append(storeParams.tableID());
+		}
+
+
+		if (limit != null){
+			strb.append(" where intersects(GeomFromText('");
+			strb.append(limit.toString());
+			strb.append("')), envelope(");
+			strb.append(geometryAttrName);
+			strb.append(")) ");
+		}
+
+		final String sql = strb.toString();
+
+		try {
+			initializeFromWKBOperation();
+		} catch (BaseException e1) {
+			throw new ReadException(this.name, e1);
+		}
+
+		this.open();
+		return (Envelope) getResource().execute(new ResourceAction() {
+			public Object run() throws Exception {
+				ResultSet rs = null;
+				Statement st = null;
+				String schema = null;
+				Connection conn = null;
+				Envelope fullEnvelope = null;
+				try {
+					conn = getConnection();
+					st = conn.createStatement();
+					try {
+						rs = st.executeQuery(sql);
+					} catch (java.sql.SQLException e) {
+						throw new JDBCExecuteSQLException(sql, e);
+					}
+					while (rs.next()) {
+
+						byte[] data = rs.getBytes(1);
+						if (data == null) {
+							continue;
+						}
+
+						fromWKBContext.setData(data);
+						Geometry geom =
+								(Geometry) fromWKB.invoke(null, fromWKBContext);
+
+						if (fullEnvelope == null) {
+							fullEnvelope = geom.getEnvelope();
+						} else {
+							fullEnvelope.add(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;
+				}
+			}
+		});
+	}
+
+	public String getSqlColumnTypeDescription(FeatureAttributeDescriptor attr) {
+
+		switch (attr.getType()) {
+		case DataTypes.STRING:
+			return "VARCHAR(" + attr.getSize() + ")";
+		case DataTypes.BOOLEAN:
+			return "BOOL";
+
+		case DataTypes.BYTE:
+			return "TINYINT UNSIGNED";
+
+		case DataTypes.DATE:
+			return "DATE";
+
+		case DataTypes.TIMESTAMP:
+			return "TIMESTAMP";
+
+		case DataTypes.TIME:
+			return "TIME";
+
+		case DataTypes.BYTEARRAY:
+			if (attr.getSize() > 0) {
+				return "BLOB(" + attr.getSize() + ")";
+			} else {
+				return "BLOB";
+			}
+
+		case DataTypes.DOUBLE:
+			if (attr.getSize() > 0) {
+				return "DOUBLE(" + attr.getSize() + "," + attr.getPrecision()
+						+ ")";
+			} else {
+				return "DOBLE";
+			}
+		case DataTypes.FLOAT:
+			return "FLOAT";
+
+		case DataTypes.GEOMETRY:
+			switch (attr.getGeometryType()) {
+			case Geometry.TYPES.POINT:
+				return "POINT";
+			case Geometry.TYPES.CURVE:
+				return "LINESTRING";
+			case Geometry.TYPES.SURFACE:
+				return "SURFACE";
+			case Geometry.TYPES.SOLID:
+				return "POLYGON";
+
+			case Geometry.TYPES.MULTIPOINT:
+				return "MULTIPOIN";
+			case Geometry.TYPES.MULTICURVE:
+				return "MULTILINESTRING";
+			case Geometry.TYPES.MULTISURFACE:
+				return "MULTISURFACE";
+			case Geometry.TYPES.MULTISOLID:
+				return "MULTIPOLYGON";
+
+			default:
+				return "GEOMETRY";
+			}
+		case DataTypes.INT:
+			if (attr.getSize() > 0) {
+				return "INT(" + attr.getSize() + ")";
+			}
+		case DataTypes.LONG:
+			return "BIGINT";
+
+		default:
+			String typeName = (String) attr.getAdditionalInfo("SQLTypeName");
+			if (typeName != null) {
+				return typeName;
+			}
+
+			throw new UnsupportedDataTypeException(attr.getDataTypeName(), attr
+					.getType());
+		}
+	}
+
+
+	public String getSqlFieldName(FeatureAttributeDescriptor attribute) {
+		if (attribute.getType() == DataTypes.GEOMETRY) {
+			return "asBinary(" + super.getSqlFieldName(attribute) + ")";
+		}
+		return super.getSqlFieldName(attribute);
+	}
+
+	protected EditableFeatureAttributeDescriptor createAttributeFromJDBC(
+			EditableFeatureType type, Connection conn,
+			ResultSetMetaData rsMetadata, int colIndex) throws SQLException {
+		int colType = rsMetadata.getColumnType(colIndex);
+		if (colType == java.sql.Types.OTHER || colType == java.sql.Types.STRUCT
+				|| colType == java.sql.Types.BLOB
+				|| colType == java.sql.Types.BINARY) {
+			Integer geoType = null;
+
+			if (rsMetadata.getColumnTypeName(colIndex).equalsIgnoreCase(
+					"geometry")) {
+				geoType = new Integer(Geometry.TYPES.GEOMETRY);
+			} else if (rsMetadata.getColumnTypeName(colIndex).equalsIgnoreCase("POINT")) {
+				geoType = new Integer(Geometry.TYPES.POINT);
+			} else if (rsMetadata.getColumnTypeName(colIndex).equalsIgnoreCase("LINESTRING")) {
+				geoType = new Integer(Geometry.TYPES.CURVE);
+			} else if (rsMetadata.getColumnTypeName(colIndex).equalsIgnoreCase("SURFACE")) {
+				geoType = new Integer(Geometry.TYPES.SURFACE);
+			} else if (rsMetadata.getColumnTypeName(colIndex).equalsIgnoreCase("POLYGON")) {
+				geoType = new Integer(Geometry.TYPES.SOLID);
+			} else if (rsMetadata.getColumnTypeName(colIndex).equalsIgnoreCase("MULTIPOIN")) {
+				geoType = new Integer(Geometry.TYPES.MULTIPOINT);
+			} else if (rsMetadata.getColumnTypeName(colIndex).equalsIgnoreCase("MULTILINESTRING")) {
+				geoType = new Integer(Geometry.TYPES.MULTICURVE);
+			} else if (rsMetadata.getColumnTypeName(colIndex).equalsIgnoreCase(
+					"MULTISURFACE")) {
+				geoType = new Integer(Geometry.TYPES.MULTISURFACE);
+			} else if (rsMetadata.getColumnTypeName(colIndex).equalsIgnoreCase(
+					"MULTIPOLYGON")) {
+				geoType = new Integer(Geometry.TYPES.MULTISOLID);
+			}
+			if (geoType != null){
+				EditableFeatureAttributeDescriptor attr = type.add(rsMetadata
+						.getColumnName(colIndex), DataTypes.GEOMETRY);
+                attr.setGeometryType(geoType.intValue());
+                attr.setGeometrySubType(Geometry.SUBTYPES.GEOM2D);
+
+				return attr;
+			}
+
+		}
+
+		return super.createAttributeFromJDBC(type, conn, rsMetadata, colIndex);
+	}
+
+	public boolean allowAutomaticValues() {
+		return Boolean.TRUE;
+	}
+
+
+	public String getSqlFieldDescription(FeatureAttributeDescriptor attr)
+			throws DataException {
+
+		/**
+			column_definition:
+			    data_type [NOT NULL | NULL] [DEFAULT default_value]
+			      [AUTO_INCREMENT] [UNIQUE [KEY] | [PRIMARY] KEY]
+			      [COMMENT 'string'] [reference_definition]
+
+		 */
+
+		StringBuilder strb = new StringBuilder();
+		// name
+		strb.append(escapeFieldName(attr.getName()));
+		strb.append(" ");
+
+		// Type
+		strb.append(this.getSqlColumnTypeDescription(attr));
+		strb.append(" ");
+
+		boolean allowNull = attr.allowNull()
+				&& !(attr.isPrimaryKey() || attr.isAutomatic());
+
+		// Null
+		if (allowNull) {
+			strb.append("NULL ");
+		} else {
+			strb.append("NOT NULL ");
+		}
+		if (attr.isAutomatic()) {
+			strb.append("AUTO_INCREMENT ");
+		}
+
+		// Default
+		if (attr.getDefaultValue() == null) {
+			if (allowNull) {
+				strb.append("DEFAULT NULL ");
+			}
+		} else {
+			String value = getDefaltFieldValueString(attr);
+			strb.append("DEFAULT '");
+			strb.append(value);
+			strb.append("' ");
+		}
+
+		// Primery key
+		if (attr.isPrimaryKey()) {
+			strb.append("PRIMARY KEY ");
+		}
+		return strb.toString();
+	}
+
+	public boolean supportOffset() {
+		return true;
+	}
+
+	public boolean supportsUnion() {
+		return true;
+	}
+
+	@Override
+	protected boolean supportsGeometry() {
+		return false;
+	}
+
+    @Override
+    public String compoundLimitAndOffset(long limit, long offset) {
+        StringBuilder sql = new StringBuilder();
+        if (limit > 0 && offset > 0) {
+            sql.append(" limit ");
+            sql.append(offset);
+            sql.append(",");
+            sql.append(limit);
+            sql.append(' ');
+        }
+        else if (offset > 0) {
+            // From http://dev.mysql.com/doc/refman/5.0/en/select.html:
+            // To retrieve all rows from a certain offset up to the end 
+            // of the result set, you can use some large number for 
+            // the second parameter. This statement retrieves all rows 
+            // from the 96th row to the last:
+            // SELECT * FROM tbl LIMIT 95,18446744073709551615;
+            sql.append(" limit ");
+            sql.append(offset);
+                sql.append(",18446744073709551615 ");
+        }
+        else if (limit > 0) {
+            sql.append(" limit ");
+            sql.append(limit);
+            sql.append(' ');
+        }
+        return sql.toString();
+    }
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLHelper.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLStoreParameters.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLStoreParameters.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLStoreParameters.java	(revision 38285)
@@ -0,0 +1,78 @@
+/* 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.mysql;
+
+import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
+import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters;
+
+public class MySQLStoreParameters extends JDBCStoreParameters implements
+		MySQLConnectionParameters {
+    public static final String PARAMETERS_DEFINITION_NAME = "MySQLStoreParameters";
+
+	public MySQLStoreParameters() {
+		super(PARAMETERS_DEFINITION_NAME, MySQLStoreProvider.NAME);
+	}
+
+	protected MySQLStoreParameters(String parametersDefinitionName) {
+		super(parametersDefinitionName,MySQLStoreProvider.NAME);
+	}
+	
+	public Boolean getUseSSL() {
+		return (Boolean) this.getDynValue(USESSL_PARAMTER_NAME);
+	}
+
+	public void setUseSSL(Boolean useSSL) {
+		this.setDynValue(USESSL_PARAMTER_NAME, useSSL);
+	}
+
+	public void setUseSSL(boolean useSSL) {
+		this.setDynValue(USESSL_PARAMTER_NAME, new Boolean(useSSL));
+	}
+
+
+	public void validate() throws ValidateDataParametersException {
+		if (getJDBCDriverClassName() == null) {
+			setJDBCDriverClassName(MySQLLibrary.DEFAULT_JDCB_DRIVER_NAME);
+		}
+		if (getUrl() == null) {
+			setUrl(MySQLLibrary.getJdbcUrl(getHost(), getPort(),
+					getDBName()));
+		}
+
+		if (getPort() == null) {
+			setPort(new Integer(3306));
+		}
+		super.validate();
+	}
+
+    @Override
+    protected String escapeName(String name) {
+        return "`".concat(name).concat("`");
+    }
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLStoreParameters.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLConnectionParameters.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLConnectionParameters.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLConnectionParameters.java	(revision 38285)
@@ -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.mysql;
+
+import org.gvsig.fmap.dal.store.jdbc.JDBCConnectionParameters;
+
+/**
+ * @author jmvivo
+ *
+ */
+public interface MySQLConnectionParameters extends
+		JDBCConnectionParameters {
+
+	public static final String USESSL_PARAMTER_NAME = "UseSSL";
+
+	public Boolean getUseSSL();
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLConnectionParameters.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLLibrary.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLLibrary.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLLibrary.java	(revision 38285)
@@ -0,0 +1,133 @@
+/* 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.mysql;
+
+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 MySQLLibrary extends AbstractLibrary {
+
+	static String DEFAULT_JDCB_DRIVER_NAME = "com.mysql.jdbc.Driver";
+
+    @Override
+    public void doRegistration() {
+        registerAsServiceOf(DALLibrary.class);
+        require(JDBCLibrary.class);
+    }
+
+	public static String getJdbcUrl(String host, Integer port, String db) {
+		String url;
+		String sport = "";
+		if (port != null) {
+			sport = ":" + port;
+		}
+		url = "jdbc:mysql://" + 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(
+				 MySQLStoreParameters.PARAMETERS_DEFINITION_NAME,
+				 MySQLStoreParameters.class,
+				 "MySQLParameters.xml"
+		);
+		DBHelper.registerParametersDefinition(
+				MySQLNewStoreParameters.PARAMETERS_DEFINITION_NAME,
+				MySQLNewStoreParameters.class,
+				"MySQLParameters.xml"
+		);
+		DBHelper.registerParametersDefinition(
+				MySQLServerExplorerParameters.PARAMETERS_DEFINITION_NAME, 
+				MySQLServerExplorerParameters.class, 
+				"MySQLParameters.xml"
+		);
+		DBHelper.registerParametersDefinition(
+				MySQLResourceParameters.PARAMETERS_DEFINITION_NAME, 
+				MySQLResourceParameters.class, 
+				"MySQLParameters.xml"
+		);
+		try {
+			DBHelper.registerMetadataDefinition(
+					MySQLStoreProvider.METADATA_DEFINITION_NAME, 
+					MySQLStoreProvider.class, 
+					"MySQLMetadata.xml"
+			);
+		} catch (MetadataException e) {
+			ex = new LibraryException(this.getClass(),e);
+		}		
+		
+		ResourceManagerProviderServices resman = (ResourceManagerProviderServices) DALLocator
+		.getResourceManager();
+
+    	
+		if (!resman.getResourceProviders().contains(MySQLResource.NAME)) {
+			resman.register(MySQLResource.NAME,
+					MySQLResource.DESCRIPTION, MySQLResource.class,
+					MySQLResourceParameters.class);
+		}
+		
+		
+		DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator
+				.getDataManager();
+		
+		if (!dataman.getStoreProviders().contains(MySQLStoreProvider.NAME)) {
+			dataman.registerStoreProvider(MySQLStoreProvider.NAME,
+					MySQLStoreProvider.class,
+					MySQLStoreParameters.class);
+		}
+		
+		if (!dataman.getExplorerProviders().contains(
+				MySQLStoreProvider.NAME)) {
+			dataman.registerExplorerProvider(MySQLServerExplorer.NAME,
+					MySQLServerExplorer.class,
+					MySQLServerExplorerParameters.class);
+		}
+		if( ex!=null ) {
+			throw ex;
+		}
+	}
+
+}
\ No newline at end of file

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLLibrary.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLSetProvider.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLSetProvider.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLSetProvider.java	(revision 38285)
@@ -0,0 +1,66 @@
+/* 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.mysql;
+
+import org.gvsig.fmap.dal.exception.DataException;
+import org.gvsig.fmap.dal.feature.FeatureQuery;
+import org.gvsig.fmap.dal.feature.FeatureType;
+import org.gvsig.fmap.dal.store.jdbc.JDBCSetProvider;
+import org.gvsig.fmap.dal.store.jdbc.JDBCStoreProvider;
+
+/**
+ * @author jmvivo
+ *
+ */
+public class MySQLSetProvider extends JDBCSetProvider {
+
+	public MySQLSetProvider(JDBCStoreProvider store, FeatureQuery query,
+			FeatureType featureType) throws DataException {
+		super(store, query, featureType);
+		// TODO Auto-generated constructor stub
+	}
+
+
+	/*
+	 * (non-Javadoc)
+	 *
+	 * @see org.gvsig.fmap.dal.feature.spi.FeatureSetProvider#canFilter()
+	 */
+	public boolean canFilter() {
+		// TODO more checks
+		if (!super.canFilter()) {
+			return false;
+		}
+		return true;
+
+	}
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLSetProvider.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLResource.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLResource.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLResource.java	(revision 38285)
@@ -0,0 +1,95 @@
+/* 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.mysql;
+
+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;
+
+public class MySQLResource extends JDBCResource {
+
+	public final static String NAME = "MySQLResource";
+	public static final String DESCRIPTION = "MySQL Connection";
+
+	public MySQLResource(MySQLResourceParameters parameters)
+			throws InitializeException {
+		super(parameters);
+	}
+
+	public String getName() throws AccessResourceException {
+		MySQLResourceParameters params = (MySQLResourceParameters) this.getParameters();
+		return MessageFormat.format("MySQLResource({0},{1})",
+				new Object[] { params.getUrl(),params.getUser() });
+	}
+
+	protected void connectToDB() throws DataException {
+		super.connectToDB();
+	}
+
+	protected DataSource createDataSource() {
+		MySQLResourceParameters jdbcParams = (MySQLResourceParameters) 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;
+	}
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLResource.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLServerExplorer.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLServerExplorer.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLServerExplorer.java	(revision 38285)
@@ -0,0 +1,209 @@
+/* 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.mysql;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.List;
+
+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.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 MySQLServerExplorer extends JDBCServerExplorer {
+	final static private Logger logger = LoggerFactory
+			.getLogger(MySQLServerExplorer.class);
+
+	public static final String NAME = "MySQLExplorer";
+
+
+
+	public MySQLServerExplorer(
+			MySQLServerExplorerParameters parameters,
+			DataServerExplorerProviderServices services)
+			throws InitializeException {
+		super(parameters, services);
+	}
+
+	private MySQLServerExplorerParameters getMySQLparameters() {
+		return (MySQLServerExplorerParameters) super.getParameters();
+	}
+
+
+	protected JDBCHelper createHelper() throws InitializeException {
+		return new MySQLHelper(this, getMySQLparameters());
+	}
+
+
+	protected String getStoreName() {
+		return MySQLStoreProvider.NAME;
+	}
+
+	public String getProviderName() {
+		return NAME;
+	}
+
+	protected JDBCStoreParameters createStoreParams()
+			throws InitializeException, ProviderNotRegisteredException {
+		MySQLStoreParameters orgParams = (MySQLStoreParameters) super
+				.createStoreParams();
+
+		orgParams.setUseSSL(getMySQLparameters().getUseSSL());
+
+		return orgParams;
+	}
+
+
+	// ****************************
+
+
+	public boolean canAdd() {
+		return true;
+	}
+
+	protected void checkIsMine(DataStoreParameters dsp) {
+		if (!(dsp instanceof MySQLStoreParameters)) {
+			// FIXME Excpetion ???
+			throw new IllegalArgumentException(
+					"not instance of MySQLStoreParameters");
+		}
+		super.checkIsMine(dsp);
+
+		MySQLServerExplorerParameters myParameters = getMySQLparameters();
+		MySQLStoreParameters myp = (MySQLStoreParameters) dsp;
+		if (myp.getUseSSL().booleanValue() != myParameters.getUseSSL()) {
+			throw new IllegalArgumentException("worng explorer: useSSL (mine:"
+					+ myParameters.getUseSSL() + " other:" + myp.getUseSSL()
+					+ ")");
+		}
+	}
+
+	public void remove(DataStoreParameters dsp) throws RemoveException {
+		final MySQLStoreParameters myParams =(MySQLStoreParameters) 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 "
+					+ myParams.tableID();
+
+				try{
+					try{
+						st.execute(sqlDrop);
+					} catch (SQLException e) {
+						throw new JDBCExecuteSQLException(sqlDrop, 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 {
+		MySQLServerExplorerParameters parameters = getMySQLparameters();
+		MySQLNewStoreParameters params = new MySQLNewStoreParameters();
+		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 MySQLHelper getMyHelper() {
+		return (MySQLHelper) getHelper();
+	}
+
+	public List getDataStoreProviderNames() {
+		List x = new ArrayList(1);
+		x.add(MySQLStoreProvider.NAME);
+		return x;
+	}
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLServerExplorer.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLStoreProvider.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLStoreProvider.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLStoreProvider.java	(revision 38285)
@@ -0,0 +1,266 @@
+/* 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.mysql;
+
+import java.util.List;
+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.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 MySQLStoreProvider extends JDBCStoreProviderWriter {
+
+	public final static Logger logger = LoggerFactory
+			.getLogger(MySQLStoreProvider.class);
+
+	public static String NAME = "MySQL";
+	public static String DESCRIPTION = "MySQL source";
+	
+	public static final String METADATA_DEFINITION_NAME = NAME;
+
+	public MySQLStoreProvider(MySQLStoreParameters params,
+			DataStoreProviderServices storeServices)
+			throws InitializeException {
+		super(
+				params, 
+				storeServices,
+				DBHelper.newMetadataContainer(METADATA_DEFINITION_NAME)
+		);
+	}
+
+	private MySQLStoreParameters getMySQLParamters() {
+		return (MySQLStoreParameters) this.getParameters();
+	}
+
+	protected JDBCHelper createHelper() throws InitializeException {
+		return new MySQLHelper(this, getMySQLParamters());
+	}
+
+	protected String fixFilter(String filter) {
+		if (filter == null) {
+			return null;
+		}
+
+		// Transform SRS to code
+		// GeomFromText\s*\(\s*'[^']*'\s*,\s*('[^']*')\s*\)
+		Pattern pattern = Pattern
+				.compile("GeomFromText\\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 MySQLSetProvider(this, query, featureType);
+	}
+
+
+	public DataServerExplorer getExplorer() throws ReadException {
+		DataManager manager = DALLocator.getDataManager();
+		MySQLServerExplorerParameters exParams;
+		MySQLStoreParameters params = getMySQLParamters();
+		try {
+			exParams = (MySQLServerExplorerParameters) manager
+					.createServerExplorerParameters(MySQLServerExplorer.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(MySQLServerExplorer.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 MySQLHelper getMyHelper() {
+		return (MySQLHelper) getHelper();
+	}
+
+	// ************************************************************************************//
+
+	// ************************************************************************************//
+
+
+
+	public boolean canWriteGeometry(int geometryType, int geometrySubtype)
+			throws DataException {
+		FeatureType fType = this.getFeatureStore().getDefaultFeatureType();
+		FeatureAttributeDescriptor geomAttr = fType
+				.getAttributeDescriptor(fType.getDefaultGeometryAttributeName());
+		if (geomAttr == null) {
+			return false;
+		}
+		if (geometrySubtype != Geometry.SUBTYPES.GEOM2D) {
+			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 prepareAttributeForInsert(
+			FeatureAttributeDescriptor attr, List<String> fields, List<String> values) {
+
+		if (attr.getType() == DataTypes.GEOMETRY) {
+			fields.add(helper.escapeFieldName(attr.getName()));
+			values.add("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())
+					+ " = GeomFromWKB(?)");
+		} else {
+			super.prepareAttributeForUpdate(attr, values);
+		}
+	}
+
+	protected List<String> getSqlStatementAlterField(
+			FeatureAttributeDescriptor attrOrg,
+			FeatureAttributeDescriptor attrTrg, List<String> additionalStatement)
+			throws DataException {
+		//
+		List<String> actions = super.getSqlStatementAlterField(attrOrg, attrTrg,
+				additionalStatement);
+		//StringBuilder strb;
+		if (attrOrg.getDataType() != attrTrg.getDataType()) {
+			if (attrOrg.getType() == DataTypes.GEOMETRY) {
+				// FIXME
+				//additionalStatement.add(getSqlGeometyFieldDrop(attrOrg));
+			}
+			if (attrTrg.getType() == DataTypes.GEOMETRY) {
+				// FIXME
+//				additionalStatement.addAll(((MySQLHelper) helper)
+//						.getSqlGeometyFieldAdd(attrTrg, params.getTable(),
+//								params.getSchema()));
+			}
+		}
+		if (attrOrg.getDataType() == attrTrg.getDataType()
+				&& attrTrg.getType() == DataTypes.GEOMETRY) {
+			// TODO Checks SRS and GeomType/Subtype
+		}
+
+		return actions;
+	}
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLStoreProvider.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLNewStoreParameters.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLNewStoreParameters.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLNewStoreParameters.java	(revision 38285)
@@ -0,0 +1,52 @@
+/* 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.mysql;
+
+import org.gvsig.fmap.dal.feature.EditableFeatureType;
+import org.gvsig.fmap.dal.feature.FeatureType;
+import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters;
+
+public class MySQLNewStoreParameters extends MySQLStoreParameters
+		implements
+        NewFeatureStoreParameters {
+
+    public static final String PARAMETERS_DEFINITION_NAME = "MySQLNewStoreParameters";
+
+    public MySQLNewStoreParameters() {
+    	super(PARAMETERS_DEFINITION_NAME);
+    }
+    
+	public EditableFeatureType getDefaultFeatureType() {
+		return (EditableFeatureType) this.getDynValue(FEATURETYPE_PARAMTER_NAME);
+	}
+
+	public void setDefaultFeatureType(FeatureType featureType) {
+		this.setDynValue(FEATURETYPE_PARAMTER_NAME, featureType);
+	}
+
+}
\ No newline at end of file

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLNewStoreParameters.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLResourceParameters.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLResourceParameters.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLResourceParameters.java	(revision 38285)
@@ -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.mysql;
+
+import org.gvsig.fmap.dal.store.jdbc.JDBCResourceParameters;
+
+public class MySQLResourceParameters extends JDBCResourceParameters
+		implements MySQLConnectionParameters {
+
+	protected static final String PARAMETERS_DEFINITION_NAME = "MySQLResourceParameters";
+
+	public MySQLResourceParameters() {
+		super(PARAMETERS_DEFINITION_NAME,MySQLStoreProvider.NAME);
+	}
+
+    public MySQLResourceParameters(String url, String host, Integer port,
+			String dbName, String user, String password,
+			String jdbcDriverClassName, Boolean ssl) {
+		super(PARAMETERS_DEFINITION_NAME,MySQLStoreProvider.NAME, url, host, port, dbName, user, password, jdbcDriverClassName);
+		if (ssl != null) {
+			this.setUseSSL(ssl.booleanValue());
+		}
+	}
+
+    
+	public String getUrl() {
+		return MySQLLibrary.getJdbcUrl(getHost(),
+				getPort(),
+				getDBName());
+	}
+
+	public String getTypeName() {
+		return MySQLResource.NAME;
+	}
+
+	public Boolean getUseSSL() {
+		return (Boolean) this.getDynValue(USESSL_PARAMTER_NAME);
+	}
+
+	public void setUseSSL(Boolean useSSL) {
+		this.setDynValue(USESSL_PARAMTER_NAME, useSSL);
+	}
+
+	public void setUseSSL(boolean useSSL) {
+		this.setDynValue(USESSL_PARAMTER_NAME, new Boolean(useSSL));
+	}
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLResourceParameters.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLServerExplorerParameters.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLServerExplorerParameters.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLServerExplorerParameters.java	(revision 38285)
@@ -0,0 +1,101 @@
+/* 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.mysql;
+
+import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
+import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters;
+
+/**
+ * @author jmvivo
+ *
+ */
+public class MySQLServerExplorerParameters extends
+		JDBCServerExplorerParameters implements MySQLConnectionParameters {
+
+
+	public static final String PARAMETERS_DEFINITION_NAME = "MySQLServerExplorerParameters";
+
+	public MySQLServerExplorerParameters() {
+		super(PARAMETERS_DEFINITION_NAME, MySQLServerExplorer.NAME);
+	}
+	
+	public Boolean getUseSSL() {
+		return (Boolean) this.getDynValue(USESSL_PARAMTER_NAME);
+	}
+
+	public void setUseSSL(Boolean useSSL) {
+		this.setDynValue(USESSL_PARAMTER_NAME, useSSL);
+	}
+
+	public void setUseSSL(boolean useSSL) {
+		this.setDynValue(USESSL_PARAMTER_NAME, new Boolean(useSSL));
+	}
+
+	public void validate() throws ValidateDataParametersException {
+		if (getJDBCDriverClassName() == null) {
+			setJDBCDriverClassName(MySQLLibrary.DEFAULT_JDCB_DRIVER_NAME);
+		}
+		if (getUrl() == null) {
+			setUrl(MySQLLibrary.getJdbcUrl(getHost(), getPort(),
+					getDBName()));
+		}
+
+		if (getPort() == null) {
+			setPort(new Integer(3306));
+		}
+		super.validate();
+	}
+
+
+	protected String getSQLForList(int mode, boolean showInformationDBTables) {
+		StringBuffer sqlBuf = new StringBuffer();
+		sqlBuf
+				.append("SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, false as ISVIEW ");
+		sqlBuf.append(" FROM INFORMATION_SCHEMA.TABLES ");
+		sqlBuf.append(" xxWHERExx ");
+		sqlBuf.append(" union ");
+		sqlBuf
+				.append("SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, true as ISVIEW ");
+		sqlBuf.append(" FROM INFORMATION_SCHEMA.VIEWS ");
+		sqlBuf.append(" xxWHERExx ");
+
+		if (showInformationDBTables) {
+			return sqlBuf.toString().replaceAll("xxWHERExx", "");
+		} else {
+			return sqlBuf.toString().replaceAll("xxWHERExx",
+					"WHERE TABLE_SCHEMA NOT IN ('information_schema','mysql')");
+
+		}
+
+	}
+
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/mysql/MySQLServerExplorerParameters.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/pom.xml
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/pom.xml	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/pom.xml	(revision 38285)
@@ -0,0 +1,389 @@
+<?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.fmap.dal.db</artifactId>
+	<packaging>jar</packaging>
+	<version>2.0-SNAPSHOT</version>
+	<name>libFMap_daldb</name>
+	<parent>
+		<groupId>org.gvsig</groupId>
+		<artifactId>gvsig-base-library-pom</artifactId>
+		<version>2.0-SNAPSHOT</version>
+	</parent>	
+	<properties>
+
+		<!-- jdbc -->
+		<jdbc-jarIncludes>org/gvsig/fmap/dal/store/jdbc/**/**</jdbc-jarIncludes>
+		<jdbc-jarExcludes>NONE</jdbc-jarExcludes>
+
+
+		<!-- postgresql -->
+		<postgresql-jarIncludes>org/gvsig/fmap/dal/store/postgresql/**/**</postgresql-jarIncludes>
+		<postgresql-jarExcludes>NONE</postgresql-jarExcludes>
+
+		<!-- mysql -->
+		<mysql-jarIncludes>org/gvsig/fmap/dal/store/mysql/**/**</mysql-jarIncludes>
+		<mysql-jarExcludes>NONE</mysql-jarExcludes>
+
+		<!-- Common -->
+		<common-jarIncludes>**/**</common-jarIncludes>
+		<build-dir>${basedir}/../build</build-dir>
+        <eclipse.project.name>libFMap_daldb</eclipse.project.name>
+	</properties>
+
+	<dependencies>
+		<dependency>
+			<groupId>org.gvsig</groupId>
+			<artifactId>org.gvsig.fmap.dal</artifactId>
+            <scope>compile</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.gvsig</groupId>
+			<artifactId>org.gvsig.fmap.dal</artifactId>
+			<classifier>spi</classifier>
+            <scope>compile</scope>
+		</dependency>		
+		<dependency>
+			<groupId>org.gvsig</groupId>
+			<artifactId>org.gvsig.fmap.geometry</artifactId>
+			<classifier>operation</classifier>
+            <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>
+		<dependency>
+			<groupId>mysql</groupId>
+			<artifactId>mysql-connector-java</artifactId>
+            <scope>compile</scope>
+		</dependency>
+		<!--TEST-->
+		<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.fmap.dal</artifactId>
+			<classifier>tests</classifier>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.gvsig</groupId>
+			<artifactId>org.gvsig.fmap.dal</artifactId>
+			<classifier>impl</classifier>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.gvsig</groupId>
+			<artifactId>org.gvsig.fmap.dal.index.spatial</artifactId>
+			<classifier>jts</classifier>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.gvsig</groupId>
+			<artifactId>org.gvsig.fmap.geometry</artifactId>
+			<classifier>impl</classifier>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.gvsig</groupId>
+			<artifactId>org.gvsig.projection</artifactId>
+			<classifier>cresques-impl</classifier>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.gvsig</groupId>
+			<artifactId>org.gvsig.utils</artifactId>
+			<scope>test</scope>
+		</dependency>		
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</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</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.gvsig</groupId>
+            <artifactId>org.gvsig.fmap.geometry</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.timesupport.lib.api</artifactId>
+            <scope>compile</scope>
+        </dependency>       
+	</dependencies>
+	<build>
+		<sourceDirectory>src</sourceDirectory>
+		<testSourceDirectory>src-test</testSourceDirectory>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<configuration>
+					<excludes>
+						<exclude>org/gvsig/fmap/data/**</exclude>
+					</excludes>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-javadoc-plugin</artifactId>
+				<configuration>
+					<excludePackageNames>org/gvsig/fmap/data</excludePackageNames>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-jar-plugin</artifactId>
+				<configuration>
+					<excludes>
+						<exclude>${jdbc-jarIncludes}</exclude>
+						<exclude>${postgresql-jarIncludes}</exclude>
+						<exclude>${mysql-jarIncludes}</exclude>
+					</excludes>
+				</configuration>
+				<executions>
+					<!--
+						Generates a jar file only with the DAL JDBC Store classes
+					-->
+					<execution>
+						<id>jdbc</id>
+						<phase>package</phase>
+						<goals>
+							<goal>jar</goal>
+						</goals>
+						<configuration>
+							<classifier>store.jdbc</classifier>
+							<includes>
+								<include>${jdbc-jarIncludes}</include>
+							</includes>
+							<excludes>
+								<exclude>${jdbc-jarExcludes}</exclude>
+							</excludes>
+						</configuration>
+					</execution>
+					<!--
+						Generates a jar file only with the DAL PostgreSQL Store classes
+					-->
+					<execution>
+						<id>postgresql</id>
+						<phase>package</phase>
+						<goals>
+							<goal>jar</goal>
+						</goals>
+						<configuration>
+							<classifier>store.postgresql</classifier>
+							<includes>
+								<include>${postgresql-jarIncludes}</include>
+							</includes>
+							<excludes>
+								<exclude>${postgresql-jarExcludes}</exclude>
+							</excludes>
+						</configuration>
+					</execution>
+					<!--
+						Generates a jar file only with the DAL MySQL Store classes
+					-->
+					<execution>
+						<id>mysql</id>
+						<phase>package</phase>
+						<goals>
+							<goal>jar</goal>
+						</goals>
+						<configuration>
+							<classifier>store.mysql</classifier>
+							<includes>
+								<include>${mysql-jarIncludes}</include>
+							</includes>
+							<excludes>
+								<exclude>${mysql-jarExcludes}</exclude>
+							</excludes>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+			<plugin>
+				<artifactId>maven-antrun-plugin</artifactId>
+				<executions>
+					<execution>
+						<id>services</id>
+						<phase>package</phase>
+						<goals>
+							<goal>run</goal>
+						</goals>
+						<configuration>
+							<tasks>
+								<jar destfile="${project.build.directory}/${project.build.finalName}.jar"
+									update="true">
+									<fileset dir="${basedir}/resources/api" />
+								</jar>
+								<jar destfile="${project.build.directory}/${project.build.finalName}-store.jdbc.jar"
+									update="true">
+									<fileset dir="${basedir}/resources/jdbc" />
+								</jar>
+								<jar destfile="${project.build.directory}/${project.build.finalName}-store.mysql.jar"
+									update="true">
+									<fileset dir="${basedir}/resources/mysql" />
+								</jar>
+								<jar destfile="${project.build.directory}/${project.build.finalName}-store.postgresql.jar"
+									update="true">
+									<fileset dir="${basedir}/resources/postgresql" />
+								</jar>
+							</tasks>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+			<!-- PostgreSQL and MySQL is needed to run the tests -->
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-surefire-plugin</artifactId>
+				<configuration>
+					<additionalClasspathElements>
+						<additionalClasspathElement>${basedir}/resources/api</additionalClasspathElement>
+						<additionalClasspathElement>${basedir}/resources/jdbc</additionalClasspathElement>
+						<additionalClasspathElement>${basedir}/resources/mysql</additionalClasspathElement>
+						<additionalClasspathElement>${basedir}/resources/postgresql</additionalClasspathElement>
+					</additionalClasspathElements>
+					<skipTests>true</skipTests>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
+	<profiles>
+		<profile>
+			<id>eclipse-project</id>
+			<build>
+				<defaultGoal>antrun:run</defaultGoal>
+				<plugins>
+					<plugin>
+						<artifactId>maven-antrun-plugin</artifactId>
+						<configuration>
+							<tasks>
+								<ant antfile="${build-dir}/ant-tasks/eclipse-tasks.xml"
+									target="eclipse.all"/>
+							</tasks>
+						</configuration>
+					</plugin>
+				</plugins>
+			</build>				
+		</profile>			
+	</profiles>
+	<reporting>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-javadoc-plugin</artifactId>
+				<configuration>
+					<doctitle>${project.name} ${project.version}</doctitle>
+					<groups>
+						<group>
+							<title>DAL DB common</title>
+							<packages>org.gvsig.fmap.dal*</packages>
+						</group>
+						<group>
+							<title>DB Store</title>
+							<packages>org.gvsig.fmap.dal.store.db*</packages>
+						</group>
+						<group>
+							<title>JDBC Store</title>
+							<packages>org.gvsig.fmap.dal.store.jdbc*</packages>
+						</group>
+						<group>
+							<title>PostgreSQL Store</title>
+							<packages>org.gvsig.fmap.dal.store.postgresql*</packages>
+						</group>
+						<group>
+							<title>MySQL Store</title>
+							<packages>org.gvsig.fmap.dal.store.mysql*</packages>
+						</group>
+					</groups>
+				</configuration>
+				<reportSets>
+					<reportSet>
+						<id>api</id>
+						<configuration>
+							<excludePackageNames>*.spi:*.impl:*.store</excludePackageNames>
+							<name>Javadoc: API</name>
+							<destDir>apidoc</destDir>
+							<windowtitle>API Documentation</windowtitle>
+							<links>
+							</links>
+						</configuration>
+						<reports>
+							<report>javadoc</report>
+						</reports>
+					</reportSet>
+					<reportSet>
+						<id>spi</id>
+						<configuration>
+							<doctitle>${project.name} ${project.version} SPI</doctitle>
+							<subpackages>org.gvsig.fmap.dal.serverexplorer.db.spi:org.gvsig.fmap.dal.store.db:org.gvsig.fmap.dal.store.jdbc</subpackages>
+							<name>Javadoc: SPI</name>
+							<destDir>spidoc</destDir>
+							<windowtitle>SPI and base stores documentation</windowtitle>
+							<links>
+								<link>../apidoc/</link>
+							</links>
+						</configuration>
+						<reports>
+							<report>javadoc</report>
+						</reports>
+					</reportSet>
+					<reportSet>
+						<id>impl</id>
+						<configuration>
+							<doctitle>${project.name} ${project.version} Default implementation and
+								stores</doctitle>
+							<subpackages>org.gvsig.fmap.dal.store.mysql:org.gvsig.fmap.dal.store.postgresql</subpackages>
+							<name>Javadoc: Impl and Stores</name>
+							<destDir>impldoc</destDir>
+							<windowtitle>Default implementation and Stores Documentation</windowtitle>
+							<links>
+								<link>../apidoc/</link>
+								<link>../spidoc/</link>
+							</links>
+						</configuration>
+						<reports>
+							<report>javadoc</report>
+						</reports>
+					</reportSet>
+				</reportSets>
+			</plugin>
+		</plugins>
+	</reporting>
+</project>
\ No newline at end of file
Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/jdbc/META-INF/services/org.gvsig.tools.library.Library
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/jdbc/META-INF/services/org.gvsig.tools.library.Library	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/jdbc/META-INF/services/org.gvsig.tools.library.Library	(revision 38285)
@@ -0,0 +1 @@
+org.gvsig.fmap.dal.store.jdbc.JDBCLibrary
\ No newline at end of file
Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/jdbc/org/gvsig/fmap/dal/store/jdbc/JDBCMetadata.xml
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/jdbc/org/gvsig/fmap/dal/store/jdbc/JDBCMetadata.xml	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/jdbc/org/gvsig/fmap/dal/store/jdbc/JDBCMetadata.xml	(revision 38285)
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<definitions>
+  <version>1.0.0</version>
+  <classes>
+    <class name="JDBC" namespace="Metadata">
+      <extends>
+      	<class name="SpatialProvider" namespace="Metadata"/>
+      </extends>
+      <description>Metadata of a JDBC store</description>
+      <fields>
+      </fields>
+    </class>
+
+  </classes>
+</definitions>  

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/jdbc/org/gvsig/fmap/dal/store/jdbc/JDBCMetadata.xml
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/jdbc/org/gvsig/fmap/dal/store/jdbc/JDBCParameters.xml
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/jdbc/org/gvsig/fmap/dal/store/jdbc/JDBCParameters.xml	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/jdbc/org/gvsig/fmap/dal/store/jdbc/JDBCParameters.xml	(revision 38285)
@@ -0,0 +1,61 @@
+<?xml version="1.0"?>
+<definitions>
+  <version>1.0.0</version>
+  <classes>
+    <class name="JDBCResourceParameters">
+      <description></description>
+      <extends>
+        <class>DBResourceParameters</class>
+      </extends>
+      <fields>
+        <field name="JDBCDriverClass" type="string" mandatory="true" group="Advanced">
+          <description>JDBC Driver class</description>
+        </field>
+        <field name="URL" type="string" mandatory="true" group="Connection">
+          <description>JDBC url connection</description>
+        </field>
+        <field name="Catalog" type="string" mandatory="false" group="Basic">
+          <description>Database catalog</description>
+        </field>
+        <field name="Schema" type="string" mandatory="false" group="Basic">
+          <description>Database schema</description>
+        </field>
+      </fields>
+    </class>
+
+    <class name="JDBCStoreParameters">
+      <extends>
+        <class>JDBCResourceParameters</class>
+        <class>DBStoreParameters</class>
+      </extends>
+      <fields>
+      </fields>
+    </class>
+
+    <class name="JDBCNewStoreParameters">
+      <description></description>
+      <extends>
+        <class>JDBCStoreParameters</class>
+	    <class namespace="dal" name="NewProviderParameters"/>
+      </extends>
+      <fields>
+      </fields>
+    </class>
+
+
+    <class name="JDBCServerExplorerParameters">
+      <extends>
+        <class>JDBCResourceParameters</class>
+        <class>DBServerExplorerParameters</class>
+      </extends>
+      <fields>
+        <field name="ShowInformationDBTables" type="boolean" 
+            mandatory="false" defaultValue="false" group="Basic">
+          <description>Show information tables</description>
+        </field>
+      </fields>
+    </class>
+
+
+  </classes>
+</definitions>  

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/jdbc/org/gvsig/fmap/dal/store/jdbc/JDBCParameters.xml
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/postgresql/META-INF/services/org.gvsig.tools.library.Library
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/postgresql/META-INF/services/org.gvsig.tools.library.Library	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/postgresql/META-INF/services/org.gvsig.tools.library.Library	(revision 38285)
@@ -0,0 +1 @@
+org.gvsig.fmap.dal.store.postgresql.PostgreSQLLibrary
\ No newline at end of file
Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/postgresql/org/gvsig/fmap/dal/store/postgresql/PostgreSQLMetadata.xml
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/postgresql/org/gvsig/fmap/dal/store/postgresql/PostgreSQLMetadata.xml	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/postgresql/org/gvsig/fmap/dal/store/postgresql/PostgreSQLMetadata.xml	(revision 38285)
@@ -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>  

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/postgresql/org/gvsig/fmap/dal/store/postgresql/PostgreSQLMetadata.xml
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/postgresql/org/gvsig/fmap/dal/store/postgresql/PostgreSQLParameters.xml
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/postgresql/org/gvsig/fmap/dal/store/postgresql/PostgreSQLParameters.xml	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/postgresql/org/gvsig/fmap/dal/store/postgresql/PostgreSQLParameters.xml	(revision 38285)
@@ -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>PostgreSQLStoreParameters</class>
+	    <class namespace="dal" name="NewProviderParameters"/>
+      </extends>
+      <fields/>
+    </class>
+
+
+    <class name="PostgreSQLServerExplorerParameters">
+      <extends>
+        <class>PostgreSQLResourceParameters</class>
+        <class>JDBCServerExplorerParameters</class>
+      </extends>
+      <fields/>
+    </class>
+
+
+  </classes>
+</definitions>  

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/postgresql/org/gvsig/fmap/dal/store/postgresql/PostgreSQLParameters.xml
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/mysql/META-INF/services/org.gvsig.tools.library.Library
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/mysql/META-INF/services/org.gvsig.tools.library.Library	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/mysql/META-INF/services/org.gvsig.tools.library.Library	(revision 38285)
@@ -0,0 +1 @@
+org.gvsig.fmap.dal.store.mysql.MySQLLibrary
\ No newline at end of file
Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/mysql/org/gvsig/fmap/dal/store/mysql/MySQLMetadata.xml
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/mysql/org/gvsig/fmap/dal/store/mysql/MySQLMetadata.xml	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/mysql/org/gvsig/fmap/dal/store/mysql/MySQLMetadata.xml	(revision 38285)
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<definitions>
+  <version>1.0.0</version>
+  <classes>
+    <class name="MySQL" namespace="Metadata">
+      <extends>
+      	<class name="JDBC" namespace="Metadata"/>
+      </extends>
+      <description>Metadata of a MySQL store</description>
+      <fields>
+      </fields>
+    </class>
+
+  </classes>
+</definitions>  

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/mysql/org/gvsig/fmap/dal/store/mysql/MySQLMetadata.xml
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/mysql/org/gvsig/fmap/dal/store/mysql/MySQLParameters.xml
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/mysql/org/gvsig/fmap/dal/store/mysql/MySQLParameters.xml	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/mysql/org/gvsig/fmap/dal/store/mysql/MySQLParameters.xml	(revision 38285)
@@ -0,0 +1,52 @@
+<?xml version="1.0"?>
+<definitions>
+  <version>1.0.0</version>
+  <classes>
+    <class name="MySQLResourceParameters">
+      <extends>
+        <class>JDBCResourceParameters</class>
+      </extends>
+      <fields>
+        <field name="JDBCDriverClass" type="string" mandatory="true"
+          defaultValue="com.mysql.jdbc.Driver" group="Advanced">
+          <description>JDBC Driver class</description>
+        </field>
+		<field name="port" type="integer" mandatory="false"
+          defaultValue="3306" group="Basic">
+          <description></description>
+        </field>
+        <field name="UseSSL" type="boolean" mandatory="false"
+          defaultValue="false" group="Basic">
+          <description>Use SSL connetion</description>
+        </field>
+      </fields>
+    </class>
+
+    <class name="MySQLStoreParameters">
+      <extends>
+        <class>JDBCStoreParameters</class>
+        <class>MySQLResourceParameters</class>
+      </extends>
+      <fields/>
+    </class>
+
+    <class name="MySQLNewStoreParameters">
+      <extends>
+        <class>MySQLStoreParameters</class>
+	    <class namespace="dal" name="NewProviderParameters"/>
+      </extends>
+      <fields/>
+    </class>
+
+
+    <class name="MySQLServerExplorerParameters">
+      <extends>
+        <class>MySQLResourceParameters</class>
+        <class>JDBCServerExplorerParameters</class>
+      </extends>
+      <fields/>
+    </class>
+
+
+  </classes>
+</definitions>  

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/mysql/org/gvsig/fmap/dal/store/mysql/MySQLParameters.xml
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/api/META-INF/services/org.gvsig.tools.library.Library
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/api/META-INF/services/org.gvsig.tools.library.Library	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/api/META-INF/services/org.gvsig.tools.library.Library	(revision 38285)
@@ -0,0 +1,3 @@
+org.gvsig.fmap.dal.DALDbLibrary
+org.gvsig.fmap.dal.resource.db.DBResourceLibrary
+org.gvsig.fmap.dal.store.db.DBStoreLibrary
\ No newline at end of file
Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/api/org/gvsig/fmap/dal/store/db/DBParameters.xml
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/api/org/gvsig/fmap/dal/store/db/DBParameters.xml	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/api/org/gvsig/fmap/dal/store/db/DBParameters.xml	(revision 38285)
@@ -0,0 +1,47 @@
+<?xml version="1.0"?>
+<definitions>
+  <version>1.0.0</version>
+  <classes>
+
+    <class name="DBStoreParameters">
+      <description>Store the parameters need to open a table of a database</description>
+      <extends>
+      	<class name="DBResourceParameters"/>
+      </extends>
+      <fields>
+		<!--  Basic data -->
+        <field name="Table" type="string" mandatory="true" group="Basic">
+          <description>Name of the table or view to access</description>
+        </field>
+        <field name="DefaultGeometryField" type="string" mandatory="false" 
+            group="Basic">
+          <description>Default geometry field</description>
+        </field>
+
+		<!-- Advanced  -->
+        <field name="CRS" type="crs" mandatory="false">
+          <description>CRS used to override the autodetection</description>
+        </field>
+        <field name="SQL" type="string" mandatory="false">
+          <description>SQL to use instead the table name</description>
+        </field>
+        <field name="Fields" type="string" mandatory="false">
+          <description>comma separated list of the field names that we want to use</description>
+        </field>
+        <field name="BaseFilter" type="string" mandatory="false">
+          <description>This filter is passed to BD provider on each request as a base filter.</description>
+        </field>
+        <field name="BaseOrder" type="string" mandatory="false">
+          <description>This order is used if no custom order is request in query.</description>
+        </field>
+        <field name="PKFields" type="string" mandatory="false">
+          <description>Comma separated list of the field names that compound the primary key</description>
+        </field>
+        <field name="Workingarea" type="envelope" mandatory="false">
+          <description>Envelop that define the filter by area used</description>
+        </field>
+      </fields>
+    </class>
+
+  </classes>
+</definitions>  

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/api/org/gvsig/fmap/dal/store/db/DBParameters.xml
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/api/org/gvsig/fmap/dal/resource/db/DBParameters.xml
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/api/org/gvsig/fmap/dal/resource/db/DBParameters.xml	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/api/org/gvsig/fmap/dal/resource/db/DBParameters.xml	(revision 38285)
@@ -0,0 +1,31 @@
+<?xml version= "1.0 "?>
+<definitions>
+  <version>1.0.0</version>
+  <classes>
+    <class name="DBResourceParameters">
+      <extends>
+      	<class namespace="dal" name="ProviderParameters"/>
+      </extends>
+      <description>Store the parameters need to open a table of a database</description>
+      <fields>
+        <field name="host" type="string" mandatory="true" group="Connection">
+          <description></description>
+        </field>
+        <field name="port" type="integer" mandatory="false" group="Connection">
+          <description></description>
+        </field>
+
+        <field name="dbname" type="string" mandatory="false" group="Basic">
+          <description></description>
+        </field>
+        <field name="dbuser" type="string" mandatory="false" group="Basic">
+          <description></description>
+        </field>
+        <field name="password" type="string" mandatory="false" group="Basic">
+          <description></description>
+        </field>
+      </fields>
+    </class>
+
+  </classes>
+</definitions>  

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/api/org/gvsig/fmap/dal/resource/db/DBParameters.xml
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/api/org/gvsig/fmap/dal/serverexplorer/db/DBParameters.xml
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/api/org/gvsig/fmap/dal/serverexplorer/db/DBParameters.xml	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/api/org/gvsig/fmap/dal/serverexplorer/db/DBParameters.xml	(revision 38285)
@@ -0,0 +1,16 @@
+<?xml version= "1.0 "?>
+<definitions>
+  <version>1.0.0</version>
+  <classes>
+
+    <class name="DBServerExplorerParameters">
+      <description></description>
+      <extends>
+      	<class name="DBResourceParameters"/>
+      </extends>
+      <fields>
+      </fields>
+    </class>
+
+  </classes>
+</definitions>  

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/resources/api/org/gvsig/fmap/dal/serverexplorer/db/DBParameters.xml
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src-test/org/gvsig/fmap/dal/store/jdbc/JDBCTestWrite.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src-test/org/gvsig/fmap/dal/store/jdbc/JDBCTestWrite.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src-test/org/gvsig/fmap/dal/store/jdbc/JDBCTestWrite.java	(revision 38285)
@@ -0,0 +1,224 @@
+/* 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.jdbc;
+
+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.EditableFeature;
+import org.gvsig.fmap.dal.feature.EditableFeatureType;
+import org.gvsig.fmap.dal.feature.FeatureStore;
+import org.gvsig.fmap.dal.feature.FeatureType;
+import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters;
+
+import com.mysql.jdbc.Driver;
+
+
+public class JDBCTestWrite extends BaseTestEditableFeatureStore {
+	private JDBCNewStoreParameters newParams;
+	private JDBCServerExplorer myExplorer;
+	private int newId = 50000;
+
+	public void fillPrimaryKeyInserFeature(EditableFeature feature) {
+		feature.set("id", newId);
+		newId++;
+	}
+
+	@Override
+	protected void doSetUp() throws Exception {
+		// Nothing to do	
+	}
+
+	public DataStoreParameters getDefaultDataStoreParameters()
+			throws DataException {
+		JDBCStoreParameters parameters = null;
+		parameters = (JDBCStoreParameters) dataManager
+				.createStoreParameters(JDBCStoreProvider.NAME);
+
+		parameters.setHost("localhost");
+		parameters.setPort(3306);
+		parameters.setUser("test");
+		parameters.setPassword("test");
+		parameters.setDBName("gis");
+		parameters.setTable("alfanum");
+		parameters.setUrl("jdbc:mysql://" + parameters.getHost() + ":"
+				+ parameters.getPort() + "/" + parameters.getDBName());
+		parameters.setJDBCDriverClassName(Driver.class.getName());
+
+		return parameters;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 *
+	 * @see org.gvsig.fmap.dal.feature.BaseTestFeatureStore#hasExplorer()
+	 */
+	@Override
+	public boolean hasExplorer() {
+		// TODO Auto-generated method stub
+		return true;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 *
+	 * @see org.gvsig.fmap.dal.feature.BaseTestFeatureStore#usesResources()
+	 */
+	@Override
+	public boolean usesResources() {
+		// TODO Auto-generated method stub
+		return true;
+	}
+
+	/*
+	public void testImportDB() throws Exception {
+		JDBCNewStoreParameters newParasm = (JDBCNewStoreParameters) getDefaultNewDataStoreParameters();
+		JDBCServerExplorerParameters seParams = (JDBCServerExplorerParameters) dataManager
+				.createServerExplorerParameters(JDBCServerExplorer.NAME);
+
+		assertTrue(myExplorer.add(newParasm, true));
+
+		FeatureStore store = (FeatureStore) dataManager
+				.createStore(getDefaultDataStoreParameters());
+
+		FeatureStore newstore = (FeatureStore) dataManager
+				.createStore(newParasm);
+
+
+
+		newstore.edit(FeatureStore.MODE_APPEND);
+		FeatureSet set = store.getFeatureSet();
+		DisposableIterator iter = set.iterator();
+		Feature org;
+		EditableFeature trg;
+		Iterator attrIter;
+		FeatureAttributeDescriptor attr;
+		while (iter.hasNext()) {
+			org = (Feature) iter.next();
+			trg = newstore.createNewFeature(false);
+			attrIter = trg.getType().iterator();
+			while (attrIter.hasNext()) {
+				attr = (FeatureAttributeDescriptor) attrIter.next();
+				trg.set(attr.getName(), org.get(attr.getName()));
+			}
+			newstore.insert(trg);
+		}
+		newstore.finishEditing();
+
+		iter.dispose();
+		set.dispose();
+		store.dispose();
+		newstore.dispose();
+
+
+	}
+	*/
+
+	@Override
+	public NewFeatureStoreParameters getDefaultNewDataStoreParameters()
+			throws Exception {
+
+
+		JDBCStoreParameters params = (JDBCStoreParameters) getDefaultDataStoreParameters();
+
+		if (this.myExplorer == null) {
+
+			JDBCServerExplorerParameters seParameters = null;
+			seParameters = (JDBCServerExplorerParameters) dataManager
+					.createServerExplorerParameters(JDBCServerExplorer.NAME);
+
+			seParameters.setHost("localhost");
+			seParameters.setPort(3306);
+			seParameters.setUser("test");
+			seParameters.setPassword("test");
+			seParameters.setDBName("gis");
+
+			seParameters.setUrl("jdbc:mysql://" + seParameters.getHost() + ":"
+					+ seParameters.getPort() + "/" + seParameters.getDBName());
+			seParameters.setJDBCDriverClassName(Driver.class.getName());
+
+
+			myExplorer = (JDBCServerExplorer) dataManager
+					.createServerExplorer(seParameters);
+		}
+		if (this.newParams == null) {
+			FeatureStore store = (FeatureStore) dataManager.createStore(params);
+
+			newParams = (JDBCNewStoreParameters) myExplorer
+					.getAddParameters();
+
+
+			newParams.setTable(params.getTable() + "_test");
+			FeatureType ftOrg = store.getDefaultFeatureType();
+			EditableFeatureType ftTrg = ftOrg.getEditable();
+
+//			EditableFeatureType ftTrg = (EditableFeatureType) newParams
+//					.getDefaultFeatureType();
+			newParams.setDefaultFeatureType(ftTrg);
+
+//			FeatureAttributeDescriptor org;
+//			EditableFeatureAttributeDescriptor trg;
+//			Iterator iter = ftOrg.iterator();
+//			while (iter.hasNext()) {
+//				org = (FeatureAttributeDescriptor) iter.next();
+//				trg = ftTrg.add(org.getName(), org.getDataType());
+//				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());
+//				trg.setAdditionalInfo("SQLType", org
+//						.getAdditionalInfo("SQLType"));
+//				trg.setAdditionalInfo("SQLTypeName", org
+//						.getAdditionalInfo("SQLTypeName"));
+//
+//			}
+//			ftTrg.setDefaultGeometryAttributeName(ftOrg
+//					.getDefaultGeometryAttributeName());
+//			ftTrg.setHasOID(ftOrg.hasOID());
+
+			store.dispose();
+		}
+
+		return this.newParams;
+	}
+
+	@Override
+	public boolean resourcesNotifyChanges() {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src-test/org/gvsig/fmap/dal/store/jdbc/JDBCTestWrite.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src-test/org/gvsig/fmap/dal/store/jdbc/JDBCTest.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src-test/org/gvsig/fmap/dal/store/jdbc/JDBCTest.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src-test/org/gvsig/fmap/dal/store/jdbc/JDBCTest.java	(revision 38285)
@@ -0,0 +1,88 @@
+/* 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.jdbc;
+
+import org.gvsig.fmap.dal.DataStoreParameters;
+import org.gvsig.fmap.dal.exception.DataException;
+import org.gvsig.fmap.dal.feature.BaseTestFeatureStore;
+
+import com.mysql.jdbc.Driver;
+
+/**
+ * @author jmvivo
+ *
+ */
+public class JDBCTest extends BaseTestFeatureStore {
+
+	@Override
+	protected void doSetUp() throws Exception {
+		// Nothing to do	
+	}
+
+	public DataStoreParameters getDefaultDataStoreParameters()
+			throws DataException {
+		JDBCStoreParameters parameters = null;
+		parameters = (JDBCStoreParameters) dataManager
+				.createStoreParameters(JDBCStoreProvider.NAME);
+
+
+		parameters.setHost("localhost");
+		parameters.setPort(3306);
+		parameters.setUser("test");
+		parameters.setPassword("test");
+		parameters.setDBName("gis");
+		parameters.setTable("alfanum");
+		parameters.setUrl("jdbc:mysql://" + parameters.getHost() + ":"
+				+ parameters.getPort() + "/" + parameters.getDBName());
+		parameters.setJDBCDriverClassName(Driver.class.getName());
+
+		return parameters;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.feature.BaseTestFeatureStore#hasExplorer()
+	 */
+	@Override
+	public boolean hasExplorer() {
+		// TODO Auto-generated method stub
+		return true;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.feature.BaseTestFeatureStore#usesResources()
+	 */
+	@Override
+	public boolean usesResources() {
+		// TODO Auto-generated method stub
+		return true;
+	}
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src-test/org/gvsig/fmap/dal/store/jdbc/JDBCTest.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src-test/org/gvsig/fmap/dal/store/postgresql/TestReadAndWriteGeom.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src-test/org/gvsig/fmap/dal/store/postgresql/TestReadAndWriteGeom.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src-test/org/gvsig/fmap/dal/store/postgresql/TestReadAndWriteGeom.java	(revision 38285)
@@ -0,0 +1,297 @@
+/* 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.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.impl.Point2D;
+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();
+			Point2D geom = (Point2D) 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;
+		Geometry nullGeom = geoManager.createNullGeometry(Geometry.SUBTYPES.GEOM2D);
+
+		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);
+//				if (buff != null) {
+//					opContext.setData(buff);
+//					geom = (Geometry) nullGeom.invokeOperation(FromWKB.CODE,
+//							opContext);
+//					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();
+				}
+			}
+		}
+
+	}
+
+	public void testReadWKB() throws Exception {
+		Statement st = null;
+		ResultSet rs = null;
+		long count = 0;
+		Geometry geom;
+		Geometry nullGeom = geoManager
+				.createNullGeometry(Geometry.SUBTYPES.GEOM2D);
+		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);
+//				if (buff != null) {
+//					opContext.setData(buff);
+//					geom = (Geometry) nullGeom.invokeOperation(FromWKB.CODE,
+//							opContext);
+//					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();
+				}
+			}
+		}
+	}
+
+//	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();
+	}
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src-test/org/gvsig/fmap/dal/store/postgresql/TestReadAndWriteGeom.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src-test/org/gvsig/fmap/dal/store/postgresql/TestPostgreSQL.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src-test/org/gvsig/fmap/dal/store/postgresql/TestPostgreSQL.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src-test/org/gvsig/fmap/dal/store/postgresql/TestPostgreSQL.java	(revision 38285)
@@ -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;
+	}
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src-test/org/gvsig/fmap/dal/store/postgresql/TestPostgreSQL.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src-test/org/gvsig/fmap/dal/store/postgresql/DatabaseMetadataChecks.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src-test/org/gvsig/fmap/dal/store/postgresql/DatabaseMetadataChecks.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src-test/org/gvsig/fmap/dal/store/postgresql/DatabaseMetadataChecks.java	(revision 38285)
@@ -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/v2_0_0_Build_2047/libraries/libFMap_daldb/src-test/org/gvsig/fmap/dal/store/postgresql/TestPostgreSQLWrite.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src-test/org/gvsig/fmap/dal/store/postgresql/TestPostgreSQLWrite.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src-test/org/gvsig/fmap/dal/store/postgresql/TestPostgreSQLWrite.java	(revision 38285)
@@ -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;
+	}
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src-test/org/gvsig/fmap/dal/store/postgresql/TestPostgreSQLWrite.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src-test/org/gvsig/fmap/dal/store/mysql/MySQLTestWrite.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src-test/org/gvsig/fmap/dal/store/mysql/MySQLTestWrite.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src-test/org/gvsig/fmap/dal/store/mysql/MySQLTestWrite.java	(revision 38285)
@@ -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.mysql;
+
+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.EditableFeatureType;
+import org.gvsig.fmap.dal.feature.FeatureStore;
+import org.gvsig.fmap.dal.feature.FeatureType;
+import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters;
+import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters;
+
+
+public class MySQLTestWrite extends BaseTestEditableFeatureStore {
+	private MySQLNewStoreParameters newParams;
+	private MySQLServerExplorer myExplorer;
+
+	@Override
+	protected void doSetUp() throws Exception {
+		super.doSetUp();
+	}
+
+	public DataStoreParameters getDefaultDataStoreParameters()
+			throws DataException {
+		MySQLStoreParameters parameters = null;
+		parameters = (MySQLStoreParameters) dataManager
+				.createStoreParameters(MySQLStoreProvider.NAME);
+
+		parameters.setHost("localhost");
+		parameters.setPort(3306);
+		parameters.setUser("test");
+		parameters.setPassword("test");
+		parameters.setDBName("gis");
+		// parameters.setTable("alfanum_autoid");
+		parameters.setTable("comunic_lin_300k");
+
+		return parameters;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 *
+	 * @see org.gvsig.fmap.dal.feature.BaseTestFeatureStore#hasExplorer()
+	 */
+	@Override
+	public boolean hasExplorer() {
+		// TODO Auto-generated method stub
+		return true;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 *
+	 * @see org.gvsig.fmap.dal.feature.BaseTestFeatureStore#usesResources()
+	 */
+	@Override
+	public boolean usesResources() {
+		// TODO Auto-generated method stub
+		return true;
+	}
+
+	/*
+	public void testImportDB() throws Exception {
+		JDBCNewStoreParameters newParasm = (JDBCNewStoreParameters) getDefaultNewDataStoreParameters();
+		JDBCServerExplorerParameters seParams = (JDBCServerExplorerParameters) dataManager
+				.createServerExplorerParameters(JDBCServerExplorer.NAME);
+
+		assertTrue(myExplorer.add(newParasm, true));
+
+		FeatureStore store = (FeatureStore) dataManager
+				.createStore(getDefaultDataStoreParameters());
+
+		FeatureStore newstore = (FeatureStore) dataManager
+				.createStore(newParasm);
+
+
+
+		newstore.edit(FeatureStore.MODE_APPEND);
+		FeatureSet set = store.getFeatureSet();
+		DisposableIterator iter = set.iterator();
+		Feature org;
+		EditableFeature trg;
+		Iterator attrIter;
+		FeatureAttributeDescriptor attr;
+		while (iter.hasNext()) {
+			org = (Feature) iter.next();
+			trg = newstore.createNewFeature(false);
+			attrIter = trg.getType().iterator();
+			while (attrIter.hasNext()) {
+				attr = (FeatureAttributeDescriptor) attrIter.next();
+				trg.set(attr.getName(), org.get(attr.getName()));
+			}
+			newstore.insert(trg);
+		}
+		newstore.finishEditing();
+
+		iter.dispose();
+		set.dispose();
+		store.dispose();
+		newstore.dispose();
+
+
+	}
+	*/
+
+	@Override
+	public NewFeatureStoreParameters getDefaultNewDataStoreParameters()
+			throws Exception {
+
+
+		JDBCStoreParameters params = (JDBCStoreParameters) getDefaultDataStoreParameters();
+
+		if (this.myExplorer == null) {
+
+			MySQLServerExplorerParameters seParameters = null;
+			seParameters = (MySQLServerExplorerParameters) dataManager
+					.createServerExplorerParameters(MySQLServerExplorer.NAME);
+
+			seParameters.setHost("localhost");
+			seParameters.setPort(3306);
+			seParameters.setUser("test");
+			seParameters.setPassword("test");
+			seParameters.setDBName("gis");
+
+
+			myExplorer = (MySQLServerExplorer) dataManager
+					.createServerExplorer(seParameters);
+		}
+		if (this.newParams == null) {
+			FeatureStore store = (FeatureStore) dataManager.createStore(params);
+
+			newParams = (MySQLNewStoreParameters) myExplorer
+					.getAddParameters();
+
+
+			newParams.setTable(params.getTable() + "_test");
+			FeatureType ftOrg = store.getDefaultFeatureType();
+			EditableFeatureType ftTrg = ftOrg.getEditable();
+
+//			EditableFeatureType ftTrg = (EditableFeatureType) newParams
+//					.getDefaultFeatureType();
+			newParams.setDefaultFeatureType(ftTrg);
+
+//			FeatureAttributeDescriptor org;
+//			EditableFeatureAttributeDescriptor trg;
+//			Iterator iter = ftOrg.iterator();
+//			while (iter.hasNext()) {
+//				org = (FeatureAttributeDescriptor) iter.next();
+//				trg = ftTrg.add(org.getName(), org.getDataType());
+//				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());
+//				trg.setAdditionalInfo("SQLType", org
+//						.getAdditionalInfo("SQLType"));
+//				trg.setAdditionalInfo("SQLTypeName", org
+//						.getAdditionalInfo("SQLTypeName"));
+//
+//			}
+//			ftTrg.setDefaultGeometryAttributeName(ftOrg
+//					.getDefaultGeometryAttributeName());
+//			ftTrg.setHasOID(ftOrg.hasOID());
+
+			store.dispose();
+		}
+
+		return this.newParams;
+	}
+
+	@Override
+	public boolean resourcesNotifyChanges() {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb/src-test/org/gvsig/fmap/dal/store/mysql/MySQLTestWrite.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain


Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_daldb
___________________________________________________________________
Added: svn:ignore
   + .classpath 
.project 
.settings 
maven-eclipse.xml
target
bin
hs_err_pid*
.externalToolBuilders
.settings
.classpath
.project


