Revision 314
tags/org.gvsig.postgresql-2.0.67/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
|
|
3 |
<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"> |
|
4 |
|
|
5 |
<modelVersion>4.0.0</modelVersion> |
|
6 |
<artifactId>org.gvsig.postgresql.app.export</artifactId> |
|
7 |
<packaging>jar</packaging> |
|
8 |
<name>Export: PostgreSQL support</name> |
|
9 |
<description>Export support for PostgreSQL</description> |
|
10 |
|
|
11 |
<parent> |
|
12 |
<groupId>org.gvsig</groupId> |
|
13 |
<artifactId>org.gvsig.postgresql.app</artifactId> |
|
14 |
<version>2.0.21-SNAPSHOT</version> |
|
15 |
</parent> |
|
16 |
|
|
17 |
<dependencies> |
|
18 |
<dependency> |
|
19 |
<groupId>org.gvsig</groupId> |
|
20 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
21 |
<scope>compile</scope> |
|
22 |
</dependency> |
|
23 |
<dependency> |
|
24 |
<groupId>org.gvsig</groupId> |
|
25 |
<artifactId>org.gvsig.andami</artifactId> |
|
26 |
<scope>compile</scope> |
|
27 |
</dependency> |
|
28 |
<dependency> |
|
29 |
<groupId>org.gvsig</groupId> |
|
30 |
<artifactId>org.gvsig.exportto.lib.api</artifactId> |
|
31 |
<scope>compile</scope> |
|
32 |
</dependency> |
|
33 |
<dependency> |
|
34 |
<groupId>org.gvsig</groupId> |
|
35 |
<artifactId>org.gvsig.exportto.swing.api</artifactId> |
|
36 |
<scope>compile</scope> |
|
37 |
</dependency> |
|
38 |
<dependency> |
|
39 |
<groupId>org.gvsig</groupId> |
|
40 |
<artifactId>org.gvsig.exportto.swing.spi</artifactId> |
|
41 |
<scope>compile</scope> |
|
42 |
</dependency> |
|
43 |
<dependency> |
|
44 |
<groupId>org.gvsig</groupId> |
|
45 |
<artifactId>org.gvsig.exportto.swing.prov.jdbc</artifactId> |
|
46 |
<scope>compile</scope> |
|
47 |
</dependency> |
|
48 |
<dependency> |
|
49 |
<groupId>org.gvsig</groupId> |
|
50 |
<artifactId>org.gvsig.geodb.app.mainplugin</artifactId> |
|
51 |
<scope>compile</scope> |
|
52 |
</dependency> |
|
53 |
|
|
54 |
|
|
55 |
<dependency> |
|
56 |
<groupId>postgresql</groupId> |
|
57 |
<artifactId>postgresql</artifactId> |
|
58 |
<scope>runtime</scope> |
|
59 |
</dependency> |
|
60 |
<dependency> |
|
61 |
<groupId>commons-dbcp</groupId> |
|
62 |
<artifactId>commons-dbcp</artifactId> |
|
63 |
<scope>runtime</scope> |
|
64 |
</dependency> |
|
65 |
<dependency> |
|
66 |
<groupId>commons-collections</groupId> |
|
67 |
<artifactId>commons-collections</artifactId> |
|
68 |
<scope>runtime</scope> |
|
69 |
</dependency> |
|
70 |
<dependency> |
|
71 |
<groupId>commons-pool</groupId> |
|
72 |
<artifactId>commons-pool</artifactId> |
|
73 |
<scope>runtime</scope> |
|
74 |
</dependency> |
|
75 |
|
|
76 |
</dependencies> |
|
77 |
|
|
78 |
<properties> |
|
79 |
<!-- Package info property values --> |
|
80 |
<!-- Default values in org.gvsig.desktop --> |
|
81 |
<gvsig.package.info.state>testing</gvsig.package.info.state> |
|
82 |
<gvsig.package.info.official>true</gvsig.package.info.official> |
|
83 |
<gvsig.package.info.dependencies>required: org.gvsig.app.mainplugin -ge 2.0.1</gvsig.package.info.dependencies> |
|
84 |
<gvsig.package.info.categories>Formats,Vector,Database</gvsig.package.info.categories> |
|
85 |
<gvsig.package.info.poolURL>http://devel.gvsig.org/download/projects/gvsig-postgresql/pool/</gvsig.package.info.poolURL> |
|
86 |
</properties> |
|
87 |
|
|
88 |
|
|
89 |
</project> |
tags/org.gvsig.postgresql-2.0.67/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/buildNumber.properties | ||
---|---|---|
1 |
#Tue Oct 08 20:52:46 CEST 2013 |
|
2 |
buildNumber=2077 |
tags/org.gvsig.postgresql-2.0.67/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/resources-plugin/config.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<plugin-config> |
|
3 |
<libraries library-dir="lib/"/> |
|
4 |
<depends plugin-name="org.gvsig.app.mainplugin"/> |
|
5 |
<resourceBundle name="text"/> |
|
6 |
<extensions> |
|
7 |
<extension class-name="org.gvsig.andami.LibraryExtension" active="false"/> |
|
8 |
</extensions> |
|
9 |
</plugin-config> |
tags/org.gvsig.postgresql-2.0.67/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.exportto.swing.prov.postgresql.ExporttoV2PostgreSQLProviderLibrary |
tags/org.gvsig.postgresql-2.0.67/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
1 |
<assembly> |
|
2 |
<id>gvsig-plugin-package</id> |
|
3 |
<formats> |
|
4 |
<format>zip</format> |
|
5 |
</formats> |
|
6 |
<baseDirectory>${project.artifactId}</baseDirectory> |
|
7 |
<includeBaseDirectory>true</includeBaseDirectory> |
|
8 |
<files> |
|
9 |
<file> |
|
10 |
<source>target/${project.artifactId}-${project.version}.jar</source> |
|
11 |
<outputDirectory>lib</outputDirectory> |
|
12 |
</file> |
|
13 |
<file> |
|
14 |
<source>target/package.info</source> |
|
15 |
</file> |
|
16 |
<file> |
|
17 |
<source>src/main/resources-plugin/config.xml</source> |
|
18 |
</file> |
|
19 |
</files> |
|
20 |
|
|
21 |
<dependencySets> |
|
22 |
|
|
23 |
<dependencySet> |
|
24 |
<useProjectArtifact>false</useProjectArtifact> |
|
25 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
26 |
<outputDirectory>lib</outputDirectory> |
|
27 |
<includes> |
|
28 |
<include>org.gvsig:org.gvsig.postgresql.provider</include> |
|
29 |
</includes> |
|
30 |
</dependencySet> |
|
31 |
|
|
32 |
<dependencySet> |
|
33 |
<useProjectArtifact>false</useProjectArtifact> |
|
34 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
35 |
<outputDirectory>lib</outputDirectory> |
|
36 |
<includes> |
|
37 |
<include>postgresql:postgresql</include> |
|
38 |
<include>commons-dbcp:commons-dbcp</include> |
|
39 |
<include>commons-collections:commons-collections</include> |
|
40 |
<include>commons-pool:commons-pool</include> |
|
41 |
</includes> |
|
42 |
</dependencySet> |
|
43 |
|
|
44 |
</dependencySets> |
|
45 |
|
|
46 |
</assembly> |
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
tags/org.gvsig.postgresql-2.0.67/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/java/org/gvsig/postgresql/exportto/ExporttoPostgreSQLProviderLibrary.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.postgresql.exportto; |
|
25 |
|
|
26 |
import org.gvsig.tools.library.AbstractLibrary; |
|
27 |
import org.gvsig.tools.library.LibraryException; |
|
28 |
import org.gvsig.tools.service.spi.ProviderManager; |
|
29 |
import org.gvsig.exportto.swing.ExporttoSwingLibrary; |
|
30 |
import org.gvsig.exportto.swing.spi.ExporttoSwingProviderLocator; |
|
31 |
|
|
32 |
/** |
|
33 |
* Library to initialize and register the file Exporto provider |
|
34 |
* implementation. |
|
35 |
* |
|
36 |
* @author gvSIG Team |
|
37 |
* @version $Id$ |
|
38 |
*/ |
|
39 |
public class ExporttoPostgreSQLProviderLibrary extends AbstractLibrary { |
|
40 |
|
|
41 |
@Override |
|
42 |
public void doRegistration() { |
|
43 |
registerAsServiceOf(ExporttoSwingLibrary.class); |
|
44 |
} |
|
45 |
|
|
46 |
@Override |
|
47 |
protected void doInitialize() throws LibraryException { |
|
48 |
// Nothing to do |
|
49 |
} |
|
50 |
|
|
51 |
@Override |
|
52 |
protected void doPostInitialize() throws LibraryException { |
|
53 |
ProviderManager providerManager = |
|
54 |
ExporttoSwingProviderLocator.getManager(); |
|
55 |
providerManager |
|
56 |
.addProviderFactory(new ExporttoPostgreSQLProviderFactory()); |
|
57 |
} |
|
58 |
|
|
59 |
} |
tags/org.gvsig.postgresql-2.0.67/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/java/org/gvsig/postgresql/exportto/ExporttoPostgreSQLProviderFactory.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.postgresql.exportto; |
|
25 |
|
|
26 |
import org.cresques.cts.IProjection; |
|
27 |
|
|
28 |
import org.gvsig.exportto.swing.ExporttoSwingManager; |
|
29 |
import org.gvsig.exportto.swing.spi.AbstractExporttoProviderFactory; |
|
30 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
31 |
import org.gvsig.tools.dynobject.DynObject; |
|
32 |
import org.gvsig.tools.service.ServiceException; |
|
33 |
import org.gvsig.tools.service.spi.Provider; |
|
34 |
import org.gvsig.tools.service.spi.ProviderServices; |
|
35 |
|
|
36 |
/** |
|
37 |
* Factory of file {@link ExportoProvider} objects. |
|
38 |
* |
|
39 |
* @author gvSIG Team |
|
40 |
* @version $Id$ |
|
41 |
*/ |
|
42 |
public class ExporttoPostgreSQLProviderFactory extends |
|
43 |
AbstractExporttoProviderFactory { |
|
44 |
|
|
45 |
private static final String PROVIDER_NAME = "PostgreSQLv2"; |
|
46 |
|
|
47 |
public ExporttoPostgreSQLProviderFactory() { |
|
48 |
super(new int[] { |
|
49 |
ExporttoSwingManager.VECTORIAL_TABLE_WITHOUT_GEOMETRY, |
|
50 |
ExporttoSwingManager.VECTORIAL_TABLE_WITH_GEOMETRY }); |
|
51 |
} |
|
52 |
|
|
53 |
public Provider create(DynObject parameters, ProviderServices services) |
|
54 |
throws ServiceException { |
|
55 |
return new ExporttoPostgreSQLProvider(services, |
|
56 |
(FeatureStore) parameters.getDynValue(PARAMETER_FEATURESTORE), |
|
57 |
(IProjection) parameters.getDynValue(PARAMETER_PROJECTION)); |
|
58 |
} |
|
59 |
|
|
60 |
public String getName() { |
|
61 |
return PROVIDER_NAME; |
|
62 |
} |
|
63 |
} |
tags/org.gvsig.postgresql-2.0.67/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/java/org/gvsig/postgresql/exportto/package.html | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8" ?> |
|
2 |
<!-- |
|
3 |
|
|
4 |
gvSIG. Desktop Geographic Information System. |
|
5 |
|
|
6 |
Copyright (C) 2007-2013 gvSIG Association. |
|
7 |
|
|
8 |
This program is free software; you can redistribute it and/or |
|
9 |
modify it under the terms of the GNU General Public License |
|
10 |
as published by the Free Software Foundation; either version 3 |
|
11 |
of the License, or (at your option) any later version. |
|
12 |
|
|
13 |
This program is distributed in the hope that it will be useful, |
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
GNU General Public License for more details. |
|
17 |
|
|
18 |
You should have received a copy of the GNU General Public License |
|
19 |
along with this program; if not, write to the Free Software |
|
20 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
21 |
MA 02110-1301, USA. |
|
22 |
|
|
23 |
For any additional information, do not hesitate to contact us |
|
24 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
|
25 |
|
|
26 |
--> |
|
27 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
28 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
|
29 |
<head> |
|
30 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
|
31 |
<title>org.gvsig.exporto package documentation</title> |
|
32 |
</head> |
|
33 |
<body> |
|
34 |
|
|
35 |
<p>Exporto provider which gets Exporto from a file.</p> |
|
36 |
|
|
37 |
</body> |
|
38 |
</html> |
tags/org.gvsig.postgresql-2.0.67/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/java/org/gvsig/postgresql/exportto/panel/SelectTableNamePanel.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.postgresql.exportto.panel; |
|
25 |
|
|
26 |
import java.awt.BorderLayout; |
|
27 |
import javax.swing.JTextField; |
|
28 |
import org.gvsig.exportto.swing.ExporttoSwingLocator; |
|
29 |
import org.gvsig.exportto.swing.ExporttoSwingManager; |
|
30 |
import org.gvsig.exportto.swing.spi.ExporttoPanelValidationException; |
|
31 |
import org.gvsig.exportto.swing.spi.ExporttoSwingProviderPanel; |
|
32 |
|
|
33 |
/** |
|
34 |
* @author gvSIG Team |
|
35 |
* @version $Id$ |
|
36 |
* |
|
37 |
*/ |
|
38 |
public class SelectTableNamePanel extends ExporttoSwingProviderPanel { |
|
39 |
|
|
40 |
private static final long serialVersionUID = 6269512983586358017L; |
|
41 |
|
|
42 |
private static final ExporttoSwingManager EXPORTTO_SWING_MANAGER = |
|
43 |
ExporttoSwingLocator.getSwingManager(); |
|
44 |
|
|
45 |
protected JTextField textField = null; |
|
46 |
|
|
47 |
protected void initializeComponents() { |
|
48 |
this.setLayout(new BorderLayout()); |
|
49 |
textField = new JTextField(); |
|
50 |
add(textField, BorderLayout.NORTH); |
|
51 |
} |
|
52 |
|
|
53 |
public String getText() { |
|
54 |
String field = textField.getText(); |
|
55 |
if ((field == null) || (field.equals(""))) { |
|
56 |
return null; |
|
57 |
} |
|
58 |
return field; |
|
59 |
} |
|
60 |
|
|
61 |
public String getPanelTitle() { |
|
62 |
return EXPORTTO_SWING_MANAGER.getTranslation("intro_tablename"); |
|
63 |
} |
|
64 |
|
|
65 |
public boolean isValidPanel() throws ExporttoPanelValidationException { |
|
66 |
if (getText() == null || getText().equals("")) { |
|
67 |
throw new ExporttoPanelValidationException( |
|
68 |
"The table cannot be empty"); |
|
69 |
} |
|
70 |
return true; |
|
71 |
} |
|
72 |
} |
tags/org.gvsig.postgresql-2.0.67/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/java/org/gvsig/postgresql/exportto/panel/SelectPkPanel.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or modify it under |
|
7 |
* the terms of the GNU General Public License as published by the Free Software |
|
8 |
* Foundation; either version 3 of the License, or (at your option) any later |
|
9 |
* version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
13 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
|
14 |
* details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License along with |
|
17 |
* this program; if not, write to the Free Software Foundation, Inc., 51 |
|
18 |
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us at info AT |
|
21 |
* gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.postgresql.exportto.panel; |
|
24 |
|
|
25 |
import java.awt.BorderLayout; |
|
26 |
|
|
27 |
import javax.swing.JLabel; |
|
28 |
import javax.swing.JPanel; |
|
29 |
import javax.swing.JTextField; |
|
30 |
|
|
31 |
import org.gvsig.exportto.swing.ExporttoSwingLocator; |
|
32 |
import org.gvsig.exportto.swing.ExporttoSwingManager; |
|
33 |
import org.gvsig.exportto.swing.spi.ExporttoPanelValidationException; |
|
34 |
import org.gvsig.exportto.swing.spi.ExporttoSwingProviderPanel; |
|
35 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
36 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
37 |
|
|
38 |
/** |
|
39 |
* @author gvSIG Team |
|
40 |
* @version $Id$ |
|
41 |
* |
|
42 |
*/ |
|
43 |
public class SelectPkPanel extends ExporttoSwingProviderPanel { |
|
44 |
|
|
45 |
private static final long serialVersionUID = 2652404227373508779L; |
|
46 |
|
|
47 |
private static final ExporttoSwingManager EXPORTTO_SWING_MANAGER |
|
48 |
= ExporttoSwingLocator.getSwingManager(); |
|
49 |
|
|
50 |
private FeatureType featType = null; |
|
51 |
protected JTextField textField = null; |
|
52 |
|
|
53 |
public SelectPkPanel() { |
|
54 |
super(); |
|
55 |
} |
|
56 |
|
|
57 |
public SelectPkPanel(FeatureType ft) { |
|
58 |
super(); |
|
59 |
featType = ft; |
|
60 |
} |
|
61 |
|
|
62 |
protected void initializeComponents() { |
|
63 |
this.setLayout(new BorderLayout()); |
|
64 |
|
|
65 |
JPanel topPanel = new JPanel(new BorderLayout()); |
|
66 |
textField = new JTextField(); |
|
67 |
|
|
68 |
String msg = EXPORTTO_SWING_MANAGER.getTranslation( |
|
69 |
"_Enter_new_field_name_for_primary_key_or_blank_to_not_add_primary_key"); |
|
70 |
topPanel.add(new JLabel(msg + ":"), BorderLayout.NORTH); |
|
71 |
topPanel.add(textField, BorderLayout.CENTER); |
|
72 |
// ============================================== |
|
73 |
add(topPanel, BorderLayout.NORTH); |
|
74 |
} |
|
75 |
|
|
76 |
public String getText() { |
|
77 |
String field = textField.getText(); |
|
78 |
if ((field == null) || (field.trim().equals(""))) { |
|
79 |
return null; |
|
80 |
} |
|
81 |
return field; |
|
82 |
} |
|
83 |
|
|
84 |
@Override |
|
85 |
public String getPanelTitle() { |
|
86 |
return EXPORTTO_SWING_MANAGER.getTranslation("_Primary_key"); |
|
87 |
} |
|
88 |
|
|
89 |
@Override |
|
90 |
public boolean isValidPanel() throws ExporttoPanelValidationException { |
|
91 |
String txt = this.getText(); |
|
92 |
if (isFieldName(txt, featType)) { |
|
93 |
throw new ExporttoPanelValidationException( |
|
94 |
EXPORTTO_SWING_MANAGER.getTranslation( |
|
95 |
"_Field_name_already_exists")); |
|
96 |
} |
|
97 |
return true; |
|
98 |
} |
|
99 |
|
|
100 |
private boolean isFieldName(String txt, FeatureType ft) { |
|
101 |
|
|
102 |
if (ft == null || txt == null) { |
|
103 |
return false; |
|
104 |
} |
|
105 |
|
|
106 |
FeatureAttributeDescriptor[] atts = ft.getAttributeDescriptors(); |
|
107 |
for (int i = 0; i < atts.length; i++) { |
|
108 |
if (atts[i].getName().equals(txt)) { |
|
109 |
return true; |
|
110 |
} |
|
111 |
} |
|
112 |
return false; |
|
113 |
} |
|
114 |
|
|
115 |
} |
tags/org.gvsig.postgresql-2.0.67/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/java/org/gvsig/postgresql/exportto/panel/DefaultConnectionPanel.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
|
|
7 |
package org.gvsig.postgresql.exportto.panel; |
|
8 |
|
|
9 |
import java.util.HashMap; |
|
10 |
import java.util.Iterator; |
|
11 |
import java.util.Map; |
|
12 |
import javax.swing.JComponent; |
|
13 |
import javax.swing.JPanel; |
|
14 |
import org.gvsig.andami.PluginsLocator; |
|
15 |
import org.gvsig.andami.PluginsManager; |
|
16 |
import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorerParameters; |
|
17 |
import org.gvsig.tools.swing.api.Component; |
|
18 |
import org.gvsig.geodb.ExtDB_Spatial; |
|
19 |
|
|
20 |
/** |
|
21 |
* |
|
22 |
* @author jjdelcerro |
|
23 |
*/ |
|
24 |
public class DefaultConnectionPanel extends JPanel implements Component { |
|
25 |
|
|
26 |
private String name = null; |
|
27 |
private DBServerExplorerParameters explorerParameters = null; |
|
28 |
private String explorerNameFilter = null; |
|
29 |
|
|
30 |
|
|
31 |
public DefaultConnectionPanel() { |
|
32 |
|
|
33 |
} |
|
34 |
|
|
35 |
public void setFilterByExplorerName(String explorerNameFilter) { |
|
36 |
this.explorerNameFilter = explorerNameFilter; |
|
37 |
} |
|
38 |
|
|
39 |
public JComponent asJComponent() { |
|
40 |
return this; |
|
41 |
} |
|
42 |
|
|
43 |
protected Map<String,DBServerExplorerParameters> getUserConections() { |
|
44 |
PluginsManager pluginsManager = PluginsLocator.getManager(); |
|
45 |
ExtDB_Spatial geodbExtension = pluginsManager.getExtension(ExtDB_Spatial.class); |
|
46 |
Map<String, DBServerExplorerParameters> connections = geodbExtension.getUserConnections(); |
|
47 |
if( this.explorerNameFilter == null ) { |
|
48 |
return connections; |
|
49 |
} |
|
50 |
Map<String,DBServerExplorerParameters> filteredConnections = new HashMap<String,DBServerExplorerParameters>(); |
|
51 |
|
|
52 |
Iterator<Map.Entry<String,DBServerExplorerParameters>> it = connections.entrySet().iterator(); |
|
53 |
while( it.hasNext() ) { |
|
54 |
Map.Entry<String,DBServerExplorerParameters> entry = it.next(); |
|
55 |
if( this.explorerNameFilter.equalsIgnoreCase(entry.getValue().getExplorerName()) ) { |
|
56 |
filteredConnections.put(entry.getKey(), entry.getValue()); |
|
57 |
} |
|
58 |
} |
|
59 |
return filteredConnections; |
|
60 |
} |
|
61 |
|
|
62 |
protected void initComponents() { |
|
63 |
|
|
64 |
} |
|
65 |
|
|
66 |
|
|
67 |
} |
tags/org.gvsig.postgresql-2.0.67/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/src/main/java/org/gvsig/postgresql/exportto/ExporttoPostgreSQLProvider.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or modify it under |
|
7 |
* the terms of the GNU General Public License as published by the Free Software |
|
8 |
* Foundation; either version 3 of the License, or (at your option) any later |
|
9 |
* version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
13 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
|
14 |
* details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License along with |
|
17 |
* this program; if not, write to the Free Software Foundation, Inc., 51 |
|
18 |
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us at info AT |
|
21 |
* gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.postgresql.exportto; |
|
24 |
|
|
25 |
import org.cresques.cts.IProjection; |
|
26 |
import org.gvsig.exportto.ExporttoService; |
|
27 |
import org.gvsig.exportto.swing.prov.jdbc.ExporrtoJDBCService; |
|
28 |
import org.gvsig.exportto.swing.prov.jdbc.panel.JDBCConnectionPanel; |
|
29 |
import org.gvsig.exportto.swing.spi.ExporttoSwingProvider; |
|
30 |
import org.gvsig.exportto.swing.spi.ExporttoSwingProviderPanel; |
|
31 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
32 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
33 |
import org.gvsig.tools.service.spi.AbstractProvider; |
|
34 |
import org.gvsig.tools.service.spi.ProviderServices; |
|
35 |
import org.slf4j.Logger; |
|
36 |
import org.slf4j.LoggerFactory; |
|
37 |
import org.gvsig.postgresql.exportto.panel.SelectPkPanel; |
|
38 |
import org.gvsig.postgresql.exportto.panel.SelectTableNamePanel; |
|
39 |
|
|
40 |
|
|
41 |
/** |
|
42 |
* Exporto provider which gets Exporto from a file. |
|
43 |
* |
|
44 |
* @author gvSIG Team |
|
45 |
* @version $Id$ |
|
46 |
*/ |
|
47 |
public class ExporttoPostgreSQLProvider extends AbstractProvider |
|
48 |
implements ExporttoSwingProvider { |
|
49 |
|
|
50 |
private static Logger logger = LoggerFactory.getLogger( |
|
51 |
ExporttoPostgreSQLProvider.class); |
|
52 |
|
|
53 |
protected SelectTableNamePanel selectTableNamePanel = null; |
|
54 |
protected SelectPkPanel selectPkPanel = null; |
|
55 |
protected JDBCConnectionPanel jdbcConnectionPanel = null; |
|
56 |
|
|
57 |
protected FeatureStore featureStore; |
|
58 |
protected IProjection projection; |
|
59 |
|
|
60 |
/** |
|
61 |
* Constructor. |
|
62 |
* |
|
63 |
* @param providerServices the services for the provider |
|
64 |
* @param file to get the Exporto from |
|
65 |
*/ |
|
66 |
public ExporttoPostgreSQLProvider(ProviderServices providerServices, |
|
67 |
FeatureStore featureStore, IProjection projection) { |
|
68 |
super(providerServices); |
|
69 |
this.featureStore = featureStore; |
|
70 |
this.projection = projection; |
|
71 |
|
|
72 |
selectTableNamePanel = new SelectTableNamePanel(); |
|
73 |
|
|
74 |
FeatureType ftype = null; |
|
75 |
try { |
|
76 |
ftype = featureStore.getDefaultFeatureType(); |
|
77 |
} catch (Exception exc) { |
|
78 |
logger.error("While getting feature type.", exc); |
|
79 |
} |
|
80 |
selectPkPanel = new SelectPkPanel(ftype); |
|
81 |
jdbcConnectionPanel = new JDBCConnectionPanel(); |
|
82 |
} |
|
83 |
|
|
84 |
public String getStoreName() { |
|
85 |
return "PostgreSQL"; |
|
86 |
} |
|
87 |
|
|
88 |
public String getExplorerName() { |
|
89 |
return "PostgreSQLExplorer"; |
|
90 |
} |
|
91 |
|
|
92 |
public int getPanelCount() { |
|
93 |
return 3; |
|
94 |
} |
|
95 |
|
|
96 |
public ExporttoSwingProviderPanel getPanelAt(int index) { |
|
97 |
switch (index) { |
|
98 |
case 0: |
|
99 |
return selectTableNamePanel; |
|
100 |
case 1: |
|
101 |
return selectPkPanel; |
|
102 |
case 2: |
|
103 |
return jdbcConnectionPanel; |
|
104 |
} |
|
105 |
return null; |
|
106 |
} |
|
107 |
|
|
108 |
public ExporttoService createExporttoService() { |
|
109 |
ConnectionSettings connectionSettings |
|
110 |
= jdbcConnectionPanel.getConnectionSettings(); |
|
111 |
|
|
112 |
int port = -1; |
|
113 |
if (connectionSettings.getPort() != null |
|
114 |
&& connectionSettings.getPort().length() > 0) { |
|
115 |
port = Integer.valueOf(connectionSettings.getPort()); |
|
116 |
} |
|
117 |
|
|
118 |
String schema = null; |
|
119 |
if (connectionSettings.getSchema() != null |
|
120 |
&& connectionSettings.getSchema().length() > 0) { |
|
121 |
schema = connectionSettings.getSchema(); |
|
122 |
} |
|
123 |
|
|
124 |
return new ExporrtoJDBCService(featureStore, |
|
125 |
connectionSettings.getDb(), schema, selectTableNamePanel.getText(), |
|
126 |
selectPkPanel.getText(), connectionSettings.getUser(), |
|
127 |
connectionSettings.getPassw(), connectionSettings.getHost(), port, |
|
128 |
getExplorerName(), getStoreName(), this.projection); |
|
129 |
} |
|
130 |
} |
tags/org.gvsig.postgresql-2.0.67/org.gvsig.postgresql.app/org.gvsig.postgresql.app.mainplugin/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
|
|
3 |
<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"> |
|
4 |
|
|
5 |
<modelVersion>4.0.0</modelVersion> |
|
6 |
<artifactId>org.gvsig.postgresql.app.mainplugin</artifactId> |
|
7 |
<packaging>jar</packaging> |
|
8 |
<name>${project.artifactId}</name> |
|
9 |
<description>PostgreSQL file format support</description> |
|
10 |
|
|
11 |
<parent> |
|
12 |
<groupId>org.gvsig</groupId> |
|
13 |
<artifactId>org.gvsig.postgresql.app</artifactId> |
|
14 |
<version>2.0.67</version> |
|
15 |
</parent> |
|
16 |
|
|
17 |
<dependencies> |
|
18 |
<dependency> |
|
19 |
<groupId>org.gvsig</groupId> |
|
20 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
21 |
<scope>compile</scope> |
|
22 |
</dependency> |
|
23 |
<dependency> |
|
24 |
<groupId>org.gvsig</groupId> |
|
25 |
<artifactId>org.gvsig.andami</artifactId> |
|
26 |
<scope>compile</scope> |
|
27 |
</dependency> |
|
28 |
<dependency> |
|
29 |
<groupId>org.gvsig</groupId> |
|
30 |
<artifactId>org.gvsig.postgresql.provider</artifactId> |
|
31 |
<scope>compile</scope> |
|
32 |
</dependency> |
|
33 |
|
|
34 |
<dependency> |
|
35 |
<groupId>postgresql</groupId> |
|
36 |
<artifactId>postgresql</artifactId> |
|
37 |
<scope>runtime</scope> |
|
38 |
</dependency> |
|
39 |
<dependency> |
|
40 |
<groupId>commons-dbcp</groupId> |
|
41 |
<artifactId>commons-dbcp</artifactId> |
|
42 |
<scope>runtime</scope> |
|
43 |
</dependency> |
|
44 |
<dependency> |
|
45 |
<groupId>commons-collections</groupId> |
|
46 |
<artifactId>commons-collections</artifactId> |
|
47 |
<scope>runtime</scope> |
|
48 |
</dependency> |
|
49 |
<dependency> |
|
50 |
<groupId>commons-pool</groupId> |
|
51 |
<artifactId>commons-pool</artifactId> |
|
52 |
<scope>runtime</scope> |
|
53 |
</dependency> |
|
54 |
|
|
55 |
</dependencies> |
|
56 |
|
|
57 |
<properties> |
|
58 |
<!-- Package info property values --> |
|
59 |
<!-- Default values in org.gvsig.desktop --> |
|
60 |
<gvsig.package.info.name>Formats: PostgreSQL support</gvsig.package.info.name> |
|
61 |
<gvsig.package.info.state>testing</gvsig.package.info.state> |
|
62 |
<gvsig.package.info.official>true</gvsig.package.info.official> |
|
63 |
<gvsig.package.info.dependencies>required: org.gvsig.app.mainplugin -ge 2.0.1</gvsig.package.info.dependencies> |
|
64 |
<gvsig.package.info.categories>Formats,Vector,Database</gvsig.package.info.categories> |
|
65 |
<gvsig.package.info.poolURL>https://devel.gvsig.org/download/projects/gvsig-postgresql/pool/</gvsig.package.info.poolURL> |
|
66 |
</properties> |
|
67 |
|
|
68 |
|
|
69 |
</project> |
tags/org.gvsig.postgresql-2.0.67/org.gvsig.postgresql.app/org.gvsig.postgresql.app.mainplugin/buildNumber.properties | ||
---|---|---|
1 |
#Tue Feb 14 18:06:31 CET 2017 |
|
2 |
buildNumber=2124 |
tags/org.gvsig.postgresql-2.0.67/org.gvsig.postgresql.app/org.gvsig.postgresql.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
1 |
<assembly> |
|
2 |
<id>gvsig-plugin-package</id> |
|
3 |
<formats> |
|
4 |
<format>zip</format> |
|
5 |
</formats> |
|
6 |
<baseDirectory>${project.artifactId}</baseDirectory> |
|
7 |
<includeBaseDirectory>true</includeBaseDirectory> |
|
8 |
<files> |
|
9 |
<file> |
|
10 |
<source>target/${project.artifactId}-${project.version}.jar</source> |
|
11 |
<outputDirectory>lib</outputDirectory> |
|
12 |
</file> |
|
13 |
<file> |
|
14 |
<source>target/package.info</source> |
|
15 |
</file> |
|
16 |
<file> |
|
17 |
<source>src/main/resources-plugin/config.xml</source> |
|
18 |
</file> |
|
19 |
</files> |
|
20 |
|
|
21 |
<dependencySets> |
|
22 |
|
|
23 |
<dependencySet> |
|
24 |
<useProjectArtifact>false</useProjectArtifact> |
|
25 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
26 |
<outputDirectory>lib</outputDirectory> |
|
27 |
<includes> |
|
28 |
<include>org.gvsig:org.gvsig.postgresql.provider</include> |
|
29 |
</includes> |
|
30 |
</dependencySet> |
|
31 |
|
|
32 |
<dependencySet> |
|
33 |
<useProjectArtifact>false</useProjectArtifact> |
|
34 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
35 |
<outputDirectory>lib</outputDirectory> |
|
36 |
<includes> |
|
37 |
<include>postgresql:postgresql</include> |
|
38 |
<include>commons-dbcp:commons-dbcp</include> |
|
39 |
<include>commons-collections:commons-collections</include> |
|
40 |
<include>commons-pool:commons-pool</include> |
|
41 |
</includes> |
|
42 |
</dependencySet> |
|
43 |
|
|
44 |
</dependencySets> |
|
45 |
|
|
46 |
</assembly> |
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
tags/org.gvsig.postgresql-2.0.67/org.gvsig.postgresql.app/org.gvsig.postgresql.app.mainplugin/src/main/resources-plugin/config.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<plugin-config> |
|
3 |
<libraries library-dir="lib/"/> |
|
4 |
<depends plugin-name="org.gvsig.app.mainplugin"/> |
|
5 |
<resourceBundle name="text"/> |
|
6 |
<extensions> |
|
7 |
<extension class-name="org.gvsig.andami.LibraryExtension" active="false"/> |
|
8 |
</extensions> |
|
9 |
</plugin-config> |
|
0 | 10 |
tags/org.gvsig.postgresql-2.0.67/org.gvsig.postgresql.app/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
|
|
3 |
<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"> |
|
4 |
|
|
5 |
<modelVersion>4.0.0</modelVersion> |
|
6 |
<artifactId>org.gvsig.postgresql.app</artifactId> |
|
7 |
<packaging>pom</packaging> |
|
8 |
<name>${project.artifactId}</name> |
|
9 |
<parent> |
|
10 |
<groupId>org.gvsig</groupId> |
|
11 |
<artifactId>org.gvsig.postgresql</artifactId> |
|
12 |
<version>2.0.67</version> |
|
13 |
</parent> |
|
14 |
|
|
15 |
<modules> |
|
16 |
<module>org.gvsig.postgresql.app.mainplugin</module> |
|
17 |
<!-- |
|
18 |
<module>org.gvsig.postgresql.app.export</module> |
|
19 |
--> |
|
20 |
</modules> |
|
21 |
|
|
22 |
</project> |
tags/org.gvsig.postgresql-2.0.67/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
|
|
3 |
<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"> |
|
4 |
|
|
5 |
<modelVersion>4.0.0</modelVersion> |
|
6 |
<artifactId>org.gvsig.postgresql</artifactId> |
|
7 |
<version>2.0.67</version> |
|
8 |
<packaging>pom</packaging> |
|
9 |
<name>${project.artifactId}</name> |
|
10 |
<description>PostgreSQL support fort DAL and gvSIG</description> |
|
11 |
<parent> |
|
12 |
<groupId>org.gvsig</groupId> |
|
13 |
<artifactId>org.gvsig.desktop</artifactId> |
|
14 |
<version>2.0.169</version> |
|
15 |
</parent> |
|
16 |
|
|
17 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-postgresql</url> |
|
18 |
<scm> |
|
19 |
<connection>scm:svn:https://devel.gvsig.org/svn/gvsig-postgresql/tags/org.gvsig.postgresql-2.0.67</connection> |
|
20 |
<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-postgresql/tags/org.gvsig.postgresql-2.0.67</developerConnection> |
|
21 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-postgresql/repository/show/tags/org.gvsig.postgresql-2.0.67</url> |
|
22 |
</scm> |
|
23 |
|
|
24 |
<repositories> |
|
25 |
<repository> |
|
26 |
<id>gvsig-public-http-repository</id> |
|
27 |
<name>gvSIG maven public HTTP repository</name> |
|
28 |
<url>http://devel.gvsig.org/m2repo/j2se</url> |
|
29 |
<releases> |
|
30 |
<enabled>true</enabled> |
|
31 |
<updatePolicy>daily</updatePolicy> |
|
32 |
<checksumPolicy>warn</checksumPolicy> |
|
33 |
</releases> |
|
34 |
<snapshots> |
|
35 |
<enabled>true</enabled> |
|
36 |
<updatePolicy>daily</updatePolicy> |
|
37 |
<checksumPolicy>warn</checksumPolicy> |
|
38 |
</snapshots> |
|
39 |
</repository> |
|
40 |
</repositories> |
|
41 |
|
|
42 |
|
|
43 |
<build> |
|
44 |
<plugins> |
|
45 |
<plugin> |
|
46 |
<groupId>org.apache.maven.plugins</groupId> |
|
47 |
<artifactId>maven-release-plugin</artifactId> |
|
48 |
<configuration> |
|
49 |
<tagBase>https://devel.gvsig.org/svn/gvsig-postgresql/tags/</tagBase> |
|
50 |
<goals>deploy</goals> |
|
51 |
</configuration> |
|
52 |
</plugin> |
|
53 |
</plugins> |
|
54 |
</build> |
|
55 |
|
|
56 |
|
|
57 |
<dependencyManagement> |
|
58 |
<dependencies> |
|
59 |
<dependency> |
|
60 |
<groupId>org.gvsig</groupId> |
|
61 |
<artifactId>org.gvsig.postgresql.provider</artifactId> |
|
62 |
<version>2.0.67</version> |
|
63 |
</dependency> |
|
64 |
<dependency> |
|
65 |
<groupId>org.gvsig</groupId> |
|
66 |
<artifactId>org.gvsig.postgresql.app.mainplugin</artifactId> |
|
67 |
<version>2.0.67</version> |
|
68 |
</dependency> |
|
69 |
</dependencies> |
|
70 |
</dependencyManagement> |
|
71 |
|
|
72 |
<dependencies> |
|
73 |
<dependency> |
|
74 |
<groupId>org.slf4j</groupId> |
|
75 |
<artifactId>slf4j-api</artifactId> |
|
76 |
<scope>compile</scope> |
|
77 |
</dependency> |
|
78 |
</dependencies> |
|
79 |
|
|
80 |
|
|
81 |
<modules> |
|
82 |
<module>org.gvsig.postgresql.app</module> |
|
83 |
<module>org.gvsig.postgresql.provider</module> |
|
84 |
</modules> |
|
85 |
|
|
86 |
|
|
87 |
</project> |
tags/org.gvsig.postgresql-2.0.67/org.gvsig.postgresql.provider/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
|
|
3 |
<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"> |
|
4 |
|
|
5 |
<modelVersion>4.0.0</modelVersion> |
|
6 |
<artifactId>org.gvsig.postgresql.provider</artifactId> |
|
7 |
<packaging>jar</packaging> |
|
8 |
<name>${project.artifactId}</name> |
|
9 |
<description>DAL provider for PostgeSQL files</description> |
|
10 |
<parent> |
|
11 |
<groupId>org.gvsig</groupId> |
|
12 |
<artifactId>org.gvsig.postgresql</artifactId> |
|
13 |
<version>2.0.67</version> |
|
14 |
</parent> |
|
15 |
|
|
16 |
<dependencies> |
|
17 |
<dependency> |
|
18 |
<groupId>com.googlecode.log4jdbc</groupId> |
|
19 |
<artifactId>log4jdbc</artifactId> |
|
20 |
<scope>compile</scope> |
|
21 |
</dependency> |
|
22 |
<dependency> |
|
23 |
<groupId>org.gvsig</groupId> |
|
24 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
25 |
<scope>compile</scope> |
|
26 |
</dependency> |
|
27 |
<dependency> |
|
28 |
<groupId>org.gvsig</groupId> |
|
29 |
<artifactId>org.gvsig.projection.api</artifactId> |
|
30 |
<scope>compile</scope> |
|
31 |
</dependency> |
|
32 |
<dependency> |
|
33 |
<groupId>org.gvsig</groupId> |
|
34 |
<artifactId>org.gvsig.fmap.dal.api</artifactId> |
|
35 |
<scope>compile</scope> |
|
36 |
</dependency> |
|
37 |
|
|
38 |
<dependency> |
|
39 |
<groupId>org.gvsig</groupId> |
|
40 |
<artifactId>org.gvsig.fmap.dal.db.jdbc</artifactId> |
|
41 |
<scope>compile</scope> |
|
42 |
</dependency> |
|
43 |
|
|
44 |
<dependency> |
|
45 |
<groupId>org.gvsig</groupId> |
|
46 |
<artifactId>org.gvsig.fmap.dal.db.lib</artifactId> |
|
47 |
<scope>compile</scope> |
|
48 |
</dependency> |
|
49 |
|
|
50 |
<dependency> |
|
51 |
<groupId>org.gvsig</groupId> |
|
52 |
<artifactId>org.gvsig.fmap.dal.spi</artifactId> |
|
53 |
<scope>compile</scope> |
|
54 |
</dependency> |
|
55 |
<dependency> |
|
56 |
<groupId>org.gvsig</groupId> |
|
57 |
<artifactId>org.gvsig.metadata.lib.basic.api</artifactId> |
|
58 |
<scope>compile</scope> |
|
59 |
</dependency> |
|
60 |
<dependency> |
|
61 |
<groupId>org.gvsig</groupId> |
|
62 |
<artifactId>org.gvsig.fmap.geometry.api</artifactId> |
|
63 |
<scope>compile</scope> |
|
64 |
</dependency> |
|
65 |
<!-- |
|
66 |
<dependency> |
|
67 |
<groupId>org.gvsig</groupId> |
|
68 |
<artifactId>org.gvsig.fmap.geometry.operation</artifactId> |
|
69 |
<scope>compile</scope> |
|
70 |
</dependency> |
|
71 |
--> |
|
72 |
<dependency> |
|
73 |
<groupId>org.gvsig</groupId> |
|
74 |
<artifactId>org.gvsig.timesupport.lib.api</artifactId> |
|
75 |
<scope>compile</scope> |
|
76 |
</dependency> |
|
77 |
<dependency> |
|
78 |
<groupId>org.gvsig</groupId> |
|
79 |
<artifactId>org.gvsig.utils</artifactId> |
|
80 |
<scope>compile</scope> |
|
81 |
</dependency> |
|
82 |
<dependency> |
|
83 |
<groupId>postgresql</groupId> |
|
84 |
<artifactId>postgresql</artifactId> |
|
85 |
<scope>compile</scope> |
|
86 |
</dependency> |
|
87 |
<dependency> |
|
88 |
<groupId>commons-dbcp</groupId> |
|
89 |
<artifactId>commons-dbcp</artifactId> |
|
90 |
<scope>compile</scope> |
|
91 |
</dependency> |
|
92 |
<dependency> |
|
93 |
<groupId>commons-collections</groupId> |
|
94 |
<artifactId>commons-collections</artifactId> |
|
95 |
<scope>compile</scope> |
|
96 |
</dependency> |
|
97 |
|
|
98 |
|
|
99 |
<!-- TESTS --> |
|
100 |
<dependency> |
|
101 |
<groupId>org.gvsig</groupId> |
|
102 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
103 |
<type>test-jar</type> |
|
104 |
<scope>test</scope> |
|
105 |
</dependency> |
|
106 |
<dependency> |
|
107 |
<groupId>org.gvsig</groupId> |
|
108 |
<artifactId>org.gvsig.compat.se</artifactId> |
|
109 |
<scope>test</scope> |
|
110 |
</dependency> |
|
111 |
<dependency> |
|
112 |
<groupId>org.gvsig</groupId> |
|
113 |
<artifactId>org.gvsig.fmap.dal.impl</artifactId> |
|
114 |
<type>test-jar</type> |
|
115 |
<scope>test</scope> |
|
116 |
</dependency> |
|
117 |
|
|
118 |
<!-- |
|
119 |
<dependency> |
|
120 |
<groupId>org.gvsig</groupId> |
|
121 |
<artifactId>org.gvsig.fmap.dal.index.spatial.jts</artifactId> |
|
122 |
<scope>test</scope> |
|
123 |
</dependency> |
|
124 |
|
|
125 |
<dependency> |
|
126 |
<groupId>org.gvsig</groupId> |
|
127 |
<artifactId>org.gvsig.fmap.geometry.generalpath</artifactId> |
|
128 |
<scope>test</scope> |
|
129 |
</dependency> |
|
130 |
--> |
|
131 |
<dependency> |
|
132 |
<groupId>org.gvsig</groupId> |
|
133 |
<artifactId>org.gvsig.projection.cresques.impl</artifactId> |
|
134 |
<scope>test</scope> |
|
135 |
</dependency> |
|
136 |
<dependency> |
|
137 |
<groupId>org.gvsig</groupId> |
|
138 |
<artifactId>org.gvsig.timesupport.lib.impl</artifactId> |
|
139 |
<scope>test</scope> |
|
140 |
</dependency> |
|
141 |
|
|
142 |
|
|
143 |
</dependencies> |
|
144 |
|
|
145 |
</project> |
tags/org.gvsig.postgresql-2.0.67/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLHelper.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 |
* 2009 IVER T.I {{Task}} |
|
26 |
*/ |
|
27 |
|
|
28 |
/** |
|
29 |
* |
|
30 |
*/ |
|
31 |
package org.gvsig.fmap.dal.store.postgresql; |
|
32 |
|
|
33 |
import java.sql.Connection; |
|
34 |
import java.sql.DatabaseMetaData; |
|
35 |
import java.sql.PreparedStatement; |
|
36 |
import java.sql.ResultSet; |
|
37 |
import java.sql.ResultSetMetaData; |
|
38 |
import java.sql.SQLException; |
|
39 |
import java.sql.Statement; |
|
40 |
import java.util.ArrayList; |
|
41 |
import java.util.Comparator; |
|
42 |
import java.util.Date; |
|
43 |
import java.util.Iterator; |
|
44 |
import java.util.List; |
|
45 |
import java.util.Map; |
|
46 |
import java.util.Properties; |
|
47 |
import java.util.TreeMap; |
|
48 |
import java.util.TreeSet; |
|
49 |
|
|
50 |
import org.apache.commons.lang3.StringUtils; |
|
51 |
import org.cresques.cts.IProjection; |
|
52 |
import org.gvsig.fmap.crs.CRSFactory; |
|
53 |
import org.gvsig.fmap.dal.DALLocator; |
|
54 |
import org.gvsig.fmap.dal.DataTypes; |
|
55 |
import org.gvsig.fmap.dal.NewDataStoreParameters; |
|
56 |
import org.gvsig.fmap.dal.exception.DataException; |
|
57 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
58 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
59 |
import org.gvsig.fmap.dal.exception.WriteException; |
|
60 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
|
61 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
62 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
63 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
64 |
import org.gvsig.fmap.dal.feature.exception.CreateGeometryException; |
|
65 |
import org.gvsig.fmap.dal.feature.exception.UnsupportedDataTypeException; |
|
66 |
import org.gvsig.fmap.dal.resource.ResourceAction; |
|
67 |
import org.gvsig.fmap.dal.resource.spi.ResourceManagerProviderServices; |
|
68 |
import org.gvsig.fmap.dal.store.jdbc.ConnectionAction; |
|
69 |
import org.gvsig.fmap.dal.store.jdbc.JDBCHelper; |
|
70 |
import org.gvsig.fmap.dal.store.jdbc.JDBCHelperUser; |
|
71 |
import org.gvsig.fmap.dal.store.jdbc.JDBCNewStoreParameters; |
|
72 |
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
|
73 |
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCException; |
|
74 |
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCExecutePreparedSQLException; |
|
75 |
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCExecuteSQLException; |
|
76 |
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCPreparingSQLException; |
|
77 |
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCSQLException; |
|
78 |
import org.gvsig.fmap.geom.Geometry; |
|
79 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
80 |
import org.gvsig.tools.ToolsLocator; |
|
81 |
import org.gvsig.tools.exception.BaseException; |
|
82 |
import org.postgresql.PGResultSetMetaData; |
|
83 |
import org.slf4j.Logger; |
|
84 |
import org.slf4j.LoggerFactory; |
|
85 |
|
|
86 |
/** |
|
87 |
* @author jmvivo |
|
88 |
* |
|
89 |
*/ |
|
90 |
public class PostgreSQLHelper extends JDBCHelper { |
|
91 |
|
|
92 |
private static Logger logger = LoggerFactory |
|
93 |
.getLogger(PostgreSQLHelper.class); |
|
94 |
|
|
95 |
private Map pgSR2SRSID = new TreeMap(); |
|
96 |
private Map srsID2pgSR = new TreeMap(); |
|
97 |
|
|
98 |
private static Properties beforePostgis13 = null; |
|
99 |
private int[] postGISVersion = { 0,0,0 }; |
|
100 |
private boolean versionSet = false; |
|
101 |
|
|
102 |
PostgreSQLHelper(JDBCHelperUser consumer, |
|
103 |
PostgreSQLConnectionParameters params) |
|
104 |
throws InitializeException { |
|
105 |
|
|
106 |
super(consumer, params); |
|
107 |
} |
|
108 |
|
|
109 |
protected void initializeResource() throws InitializeException { |
|
110 |
ResourceManagerProviderServices manager = (ResourceManagerProviderServices) DALLocator |
|
111 |
.getResourceManager(); |
|
112 |
PostgreSQLResource resource = (PostgreSQLResource) manager |
|
113 |
.createAddResource( |
|
114 |
PostgreSQLResource.NAME, new Object[] { |
|
115 |
params.getUrl(), params.getHost(), |
|
116 |
params.getPort(), params.getDBName(), params.getUser(), |
|
117 |
params.getPassword(), |
|
118 |
params.getJDBCDriverClassName(), |
|
119 |
((PostgreSQLConnectionParameters) params).getUseSSL() }); |
|
120 |
this.setResource(resource); |
|
121 |
} |
|
122 |
|
|
123 |
|
|
124 |
protected String getDefaultSchema(Connection conn) |
|
125 |
throws JDBCException { |
|
126 |
if (defaultSchema == null) { |
|
127 |
String sql = "Select current_schema()"; |
|
128 |
ResultSet rs = null; |
|
129 |
Statement st = null; |
|
130 |
String schema = null; |
|
131 |
try { |
|
132 |
st = conn.createStatement(); |
|
133 |
try { |
|
134 |
rs = JDBCHelper.executeQuery(st, sql); |
|
135 |
} catch (java.sql.SQLException e) { |
|
136 |
throw new JDBCExecuteSQLException(sql, e); |
|
137 |
} |
|
138 |
rs.next(); |
|
139 |
schema = rs.getString(1); |
|
140 |
} catch (java.sql.SQLException e) { |
|
141 |
throw new JDBCSQLException(e); |
|
142 |
} finally { |
|
143 |
try {rs.close();} catch (Exception e) {logger.error("Exception clossing resulset", e);}; |
|
144 |
try {st.close();} catch (Exception e) {logger.error("Exception clossing statement", e);}; |
|
145 |
rs = null; |
|
146 |
st = null; |
|
147 |
} |
|
148 |
defaultSchema = schema; |
|
149 |
} |
|
150 |
|
|
151 |
return defaultSchema; |
|
152 |
} |
|
153 |
|
|
154 |
public Envelope getFullEnvelopeOfField( |
|
155 |
JDBCStoreParameters storeParams, |
|
156 |
String geometryAttrName, Envelope limit) |
|
157 |
throws DataException { |
|
158 |
|
|
159 |
StringBuilder strb = new StringBuilder(); |
|
160 |
strb.append("Select " + getFunctionName("ST_AsEWKB") + "(" |
|
161 |
+ getFunctionName("ST_Extent") + "("); |
|
162 |
strb.append(escapeFieldName(geometryAttrName)); |
|
163 |
strb.append(")) from "); |
|
164 |
|
|
165 |
if (storeParams.getSQL() != null |
|
166 |
&& storeParams.getSQL().trim().length() > 0) { |
|
167 |
strb.append('('); |
|
168 |
strb.append(storeParams.getSQL()); |
|
169 |
strb.append(") as _subquery_alias_ "); |
|
170 |
} else { |
|
171 |
strb.append(storeParams.tableID()); |
|
172 |
} |
|
173 |
|
|
174 |
if (limit != null || (storeParams.getBaseFilter() != null |
|
175 |
&& storeParams.getBaseFilter().trim().length() > 0)) { |
|
176 |
strb.append(" where "); |
|
177 |
|
|
178 |
if (limit != null) { |
|
179 |
strb.append(" ( " + getFunctionName("ST_Intersects") + "(" |
|
180 |
+ getFunctionName("ST_GeomFromText") + "('"); |
|
181 |
String workAreaWkt = null; |
|
182 |
try { |
|
183 |
workAreaWkt = limit.getGeometry().convertToWKT(); |
|
184 |
} catch (Exception e) { |
|
185 |
throw new CreateGeometryException(e); |
|
186 |
} |
|
187 |
strb.append(workAreaWkt); |
|
188 |
strb.append("', "); |
|
189 |
|
|
190 |
IProjection proj = storeParams.getCRS(); |
|
191 |
int sridInt = this.getProviderSRID(proj); |
|
192 |
if (sridInt == -1) { |
|
193 |
throw new CreateGeometryException( |
|
194 |
new Exception("CRS is null or unknown.")); |
|
195 |
} else { |
|
196 |
strb.append(Integer.toString(sridInt)); |
|
197 |
} |
|
198 |
strb.append("), " + getFunctionName("ST_Envelope") + "("); |
|
199 |
strb.append(escapeFieldName(geometryAttrName)); |
|
200 |
strb.append(")) ) "); |
|
201 |
|
|
202 |
} |
|
203 |
if (storeParams.getBaseFilter() != null && storeParams.getBaseFilter().trim().length() > 0) { |
|
204 |
if (limit != null) { |
|
205 |
strb.append(" and "); |
|
206 |
} |
|
207 |
strb.append(" ( "); |
|
208 |
strb.append(storeParams.getBaseFilter()); |
|
209 |
strb.append(" ) "); |
|
210 |
} |
|
211 |
|
|
212 |
} |
|
213 |
|
|
214 |
final String sql = strb.toString(); |
|
215 |
|
|
216 |
this.open(); |
|
217 |
|
|
218 |
return (Envelope) getResource().execute(new ResourceAction() { |
|
219 |
public String toString() { |
|
220 |
return "getEnvelope"; |
|
221 |
} |
|
222 |
|
|
223 |
public Object run() throws Exception { |
|
224 |
ResultSet rs = null; |
|
225 |
Statement st = null; |
|
226 |
Connection conn = null; |
|
227 |
Envelope fullEnvelope = null; |
|
228 |
|
|
229 |
Envelope emptyEnv |
|
230 |
= geomManager.createEnvelope(Geometry.SUBTYPES.GEOM2D); |
|
231 |
|
|
232 |
try { |
|
233 |
|
|
234 |
conn = getConnection(); |
|
235 |
st = conn.createStatement(); |
|
236 |
try { |
|
237 |
rs = JDBCHelper.executeQuery(st, sql); |
|
238 |
} catch (java.sql.SQLException e) { |
|
239 |
throw new JDBCExecuteSQLException(sql, e); |
|
240 |
} |
|
241 |
if (!rs.next()) { |
|
242 |
return emptyEnv; |
|
243 |
} |
|
244 |
|
|
245 |
byte[] data = rs.getBytes(1); |
|
246 |
if (data == null) { |
|
247 |
return emptyEnv; |
|
248 |
} |
|
249 |
|
|
250 |
Geometry geom = geomManager.createFrom(data); |
|
251 |
|
|
252 |
fullEnvelope = geom.getEnvelope(); |
|
253 |
|
|
254 |
return fullEnvelope; |
|
255 |
} catch (java.sql.SQLException e) { |
|
256 |
throw new JDBCSQLException(e); |
|
257 |
} catch (BaseException e) { |
|
258 |
throw new ReadException(user.getProviderName(), e); |
|
259 |
} finally { |
|
260 |
try { |
|
261 |
rs.close(); |
|
262 |
} catch (Exception e) { |
|
263 |
} |
|
264 |
try { |
|
265 |
st.close(); |
|
266 |
} catch (Exception e) { |
|
267 |
} |
|
268 |
try { |
|
269 |
conn.close(); |
|
270 |
} catch (Exception e) { |
|
271 |
} |
|
272 |
rs = null; |
|
273 |
st = null; |
|
274 |
conn = null; |
|
275 |
} |
|
276 |
} |
|
277 |
}); |
|
278 |
} |
|
279 |
|
|
280 |
@Override |
|
281 |
public Object dalValueToJDBC(FeatureAttributeDescriptor attributeDescriptor, Object value) |
|
282 |
throws WriteException { |
|
283 |
|
|
284 |
try { |
|
285 |
if (value == null) { |
|
286 |
return null; |
|
287 |
} |
|
288 |
Date jdate = null; |
|
289 |
switch (attributeDescriptor.getType()) { |
|
290 |
case DataTypes.DATE: |
|
291 |
jdate = (Date)value; |
|
292 |
java.sql.Date sqldate = new java.sql.Date(jdate.getTime()); |
|
293 |
return sqldate; |
|
294 |
|
|
295 |
case DataTypes.TIME: |
|
296 |
jdate = (Date)value; |
|
297 |
java.sql.Time sqltime = new java.sql.Time(jdate.getTime()); |
|
298 |
return sqltime; |
|
299 |
|
|
300 |
case DataTypes.GEOMETRY: |
|
301 |
IProjection srs = null; |
|
302 |
byte[] wkb = null; |
|
303 |
Geometry geom = null; |
|
304 |
try { |
|
305 |
geom = (Geometry)value; |
|
306 |
Geometry geom1 = coerce(attributeDescriptor.getGeomType(), geom); |
|
307 |
srs = attributeDescriptor.getSRS(); |
|
308 |
if (srs != null) { |
|
309 |
wkb = geom1.convertToEWKBForcingType(getProviderSRID(srs), attributeDescriptor.getGeomType().getType()); |
|
310 |
} else { |
|
311 |
wkb = geom1.convertToEWKB(); |
|
312 |
} |
Also available in: Unified diff