Revision 61

View differences:

trunk/org.gvsig.postgresql/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>
trunk/org.gvsig.postgresql/org.gvsig.postgresql.app/org.gvsig.postgresql.app.export/buildNumber.properties
1
#Tue Oct 08 20:52:46 CEST 2013
2
buildNumber=2077
trunk/org.gvsig.postgresql/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
trunk/org.gvsig.postgresql/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

  
trunk/org.gvsig.postgresql/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
}
trunk/org.gvsig.postgresql/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
}
trunk/org.gvsig.postgresql/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>
trunk/org.gvsig.postgresql/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
}
trunk/org.gvsig.postgresql/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
}
trunk/org.gvsig.postgresql/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
}
trunk/org.gvsig.postgresql/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
}
trunk/org.gvsig.postgresql/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>

Also available in: Unified diff