Revision 20798

View differences:

trunk/libraries/libFMap_dataDB/src/org/gvsig/data/datastores/vectorial/db/jdbc/postgresqlbin/PostgresqlResource.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
* MA  02110-1301, USA.
20
*
21
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2008 IVER T.I   {{Task}}
26
*/
27

  
28
/**
29
 *
30
 */
31
package org.gvsig.data.datastores.vectorial.db.jdbc.postgresqlbin;
32

  
33
import java.sql.Connection;
34
import java.sql.DriverManager;
35

  
36
import org.gvsig.data.datastores.vectorial.db.jdbc.JDBCExplorerParameter;
37
import org.gvsig.data.datastores.vectorial.db.jdbc.JDBCResource;
38
import org.gvsig.data.datastores.vectorial.db.jdbc.JDBCStoreParameters;
39
import org.gvsig.data.datastores.vectorial.db.jdbc.exception.JDBCDriverNotFoundException;
40
import org.gvsig.data.exception.DataException;
41
import org.gvsig.data.exception.InitializeException;
42
import org.gvsig.data.exception.OpenException;
43
import org.gvsig.data.exception.ReadException;
44
import org.gvsig.data.exception.ResourceChangedException;
45

  
46
/**
47
 * @author jmvivo
48
 *
49
 */
50
public class PostgresqlResource extends JDBCResource {
51

  
52
	/* (non-Javadoc)
53
	 * @see org.gvsig.data.datastores.vectorial.db.jdbc.JDBCResource#getConnection()
54
	 */
55
	protected Connection getConnection() throws ReadException {
56
		return super.getConnection();
57
	}
58

  
59
	/**
60
	 * @param params
61
	 */
62
	PostgresqlResource(JDBCStoreParameters params) {
63
		super(params);
64
	}
65

  
66
	/**
67
	 * @param params
68
	 */
69
	PostgresqlResource(JDBCExplorerParameter params) {
70
		super(params);
71
	}
72

  
73
	/* (non-Javadoc)
74
	 * @see org.gvsig.data.datastores.vectorial.db.jdbc.JDBCResource#createConnection()
75
	 */
76
	protected Connection createConnection() throws ReadException {
77
		Connection conn = null;
78

  
79
		try {
80
			Class.forName("org.postgresql.Driver");
81
		} catch (ClassNotFoundException e) {
82
			throw new JDBCDriverNotFoundException("org.postgresql.Driver",e);
83
		}
84
		try {
85
			conn = DriverManager.getConnection(this.getUrl(), this.getUser(), this.getPassword());
86

  
87
		} catch (java.sql.SQLException e1) {
88
			throw new InitializeException(this.getName(),e1);
89
		}
90
		return conn;
91
	}
92

  
93
	/* (non-Javadoc)
94
	 * @see org.gvsig.data.Resource#generateKey()
95
	 */
96
	protected String generateKey() {
97
		return this.getName()+";"+this.getUrl()+";"+this.getUser();
98
	}
99

  
100
	/* (non-Javadoc)
101
	 * @see org.gvsig.data.Resource#getName()
102
	 */
103
	public String getName() {
104
		return "Postgresql";
105
	}
106

  
107
}
108

  
0 109

  
trunk/libraries/libFMap_dataDB/src/org/gvsig/data/datastores/vectorial/db/jdbc/JDBCStore.java
215 215
				}
216 216
			}
217 217
			selectiveWriter.postProcess();
218
			this.resource.changed(this);
218 219

  
219 220
		}catch (ReadException e) {
220 221
			selectiveWriter.cancelProcess();
trunk/libraries/libFMap_dataDB/src/org/gvsig/data/datastores/vectorial/db/jdbc/postgresql/PostgresqlStore.java
3 3
import java.lang.ref.WeakReference;
4 4
import java.sql.Connection;
5 5
import java.sql.ResultSet;
6
import java.util.Locale;
7 6

  
8 7
import org.gvsig.data.IDataCollection;
9 8
import org.gvsig.data.IDataExplorer;
......
12 11
import org.gvsig.data.datastores.vectorial.db.DBFeatureType;
13 12
import org.gvsig.data.datastores.vectorial.db.jdbc.JDBCFeaturesWriter;
14 13
import org.gvsig.data.datastores.vectorial.db.jdbc.JDBCStore;
15
import org.gvsig.data.datastores.vectorial.db.jdbc.h2.H2Resource;
16
import org.gvsig.data.datastores.vectorial.db.jdbc.h2.H2StoreParameters;
17 14
import org.gvsig.data.exception.CloseException;
18 15
import org.gvsig.data.exception.DataException;
19 16
import org.gvsig.data.exception.InitializeException;
......
29 26
public class PostgresqlStore extends JDBCStore{
30 27
	public static final String CONNECTION_STRING = "postgresql";
31 28
	public static String DATASTORE_NAME = "PostgresqlStore";
32
	protected static Locale ukLocale = new Locale("en", "UK"); // English, UK version
33 29
    PostgresqlStoreParameters getParametersPostgresql(){
34 30
		return (PostgresqlStoreParameters)this.parameters;
35 31
	}
36 32

  
37 33

  
38 34
	public void init(IDataStoreParameters parameters) throws InitializeException {
39
//		super.init(parameters);
40
//
41
//
42
//
43
//		this.initConnection();
44
//		this.initFeatureType();
45
//		this.initSqlProperties();
46 35

  
47

  
48 36
		PostgresqlResource tmpResource = new PostgresqlResource((PostgresqlStoreParameters)parameters);
49 37
		PostgresqlResource theResource;
50 38
		ResourceManager resMan = ResourceManager.getResourceManager();
trunk/libraries/libFMap_dataDB/src/org/gvsig/data/datastores/vectorial/db/DBDataFeatureCollectionWithFeatureID.java
89 89
	}
90 90

  
91 91
	public int size() {
92
		checkModified();
92 93
		return featureIDs.size();
93 94
	}
94 95

  
95 96
	public Iterator iterator() {
97
		checkModified();
96 98
		FIDIterator dbfIter=new FIDIterator(featureIDs.iterator());
97 99
		return dbfIter;
98 100
	}
trunk/libraries/libFMap_dataDB/src-test/org/gvsig/data/datastores/vectorial/db/jdbc/h2/H2Test.java
11 11
import org.gvsig.data.IDataStoreParameters;
12 12
import org.gvsig.data.datastores.vectorial.db.DBAttributeDescriptor;
13 13
import org.gvsig.data.datastores.vectorial.db.DBFeatureType;
14
import org.gvsig.data.datastores.vectorial.db.DBTest;
15 14
import org.gvsig.data.datastores.vectorial.db.jdbc.JDBCTest;
16 15
import org.gvsig.data.datastores.vectorial.file.shp.SHPStore;
17 16
import org.gvsig.data.datastores.vectorial.file.shp.SHPStoreParameters;
......
33 32
import org.h2.tools.Server;
34 33

  
35 34

  
36
public class H2Test extends DBTest {
35
public class H2Test extends JDBCTest {
37 36

  
38 37
	private Server h2Server = null;
39 38
	private Server h2WebServer = null;
......
226 225
		}
227 226

  
228 227

  
229
		Iterator it;
230 228
		IFeatureCollection fc =null;
231 229

  
232 230
		try {
......
800 798
		}
801 799

  
802 800
		// TODO FALTA Notificaci?n de edici?n
803
//		JDBCTest.doFileResourceTest(dp);
804
		JDBCTest.doFileResourceTest(dp,false);
801
		JDBCTest.doFileResourceTest(dp);
802
//		JDBCTest.doFileResourceTest(dp,false);
805 803

  
806 804
		deleteTable(dp);
807 805

  
......
845 843
		Iterator iter = null;
846 844
		DBAttributeDescriptor attr= null;
847 845

  
848
		int i,j;
846
		int i;
849 847
		for (i=0;i<list.length;i++){
850 848
			h2param = (H2StoreParameters)list[i];
851 849
			System.out.println("Table: "+h2param.tableID());

Also available in: Unified diff