Revision 263

View differences:

tags/org.gvsig.postgresql-2.0.57/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.57/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.57/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.57/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.57/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.57/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.57/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.57/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.57/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.57/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.57/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.57/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.57/org.gvsig.postgresql.app/org.gvsig.postgresql.app.mainplugin/buildNumber.properties
1
#Fri Jul 01 12:43:19 CEST 2016
2
buildNumber=2114
tags/org.gvsig.postgresql-2.0.57/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.57/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>
tags/org.gvsig.postgresql-2.0.57/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.57</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>
0 70

  
tags/org.gvsig.postgresql-2.0.57/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.57</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.57/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.57</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.140</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.57</connection>
20
      <developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-postgresql/tags/org.gvsig.postgresql-2.0.57</developerConnection>
21
      <url>https://devel.gvsig.org/redmine/projects/gvsig-postgresql/repository/show/tags/org.gvsig.postgresql-2.0.57</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.57</version>
63
          </dependency>
64
          <dependency>
65
            <groupId>org.gvsig</groupId>
66
            <artifactId>org.gvsig.postgresql.app.mainplugin</artifactId>
67
            <version>2.0.57</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.57/org.gvsig.postgresql.provider/src/main/resources/org/gvsig/fmap/dal/store/postgresql/PostgreSQLParameters.xml
1
<?xml version="1.0"?>
2
<definitions>
3
  <version>1.0.0</version>
4
  <classes>
5
    <class name="PostgreSQLResourceParameters">
6
      <extends>
7
        <class>JDBCResourceParameters</class>
8
      </extends>
9
      <fields>
10
        <field name="JDBCDriverClass" type="string" mandatory="true"
11
          defaultValue="org.postgresql.Driver" group="Advanced">
12
          <description>JDBC Driver class</description>
13
        </field>
14
		<field name="port" type="integer" mandatory="false"
15
          defaultValue="5432" group="Connection">
16
          <description></description>
17
        </field>
18
        <field name="UseSSL" type="boolean" mandatory="false"
19
          defaultValue="false" group="Basic">
20
          <description>Use SSL connetion</description>
21
        </field>
22
      </fields>
23
    </class>
24

  
25
    <class name="PostgreSQLStoreParameters">
26
      <extends>
27
        <class>JDBCStoreParameters</class>
28
        <class>PostgreSQLResourceParameters</class>
29
      </extends>
30
      <fields/>
31
    </class>
32

  
33
    <class name="PostgreSQLNewStoreParameters">
34
      <extends>
35
        <class>JDBCNewStoreParameters</class>
36
        <class>PostgreSQLResourceParameters</class>
37
      </extends>
38
      <fields/>
39
    </class>
40

  
41

  
42
    <class name="PostgreSQLServerExplorerParameters">
43
      <extends>
44
        <class>PostgreSQLResourceParameters</class>
45
        <class>JDBCServerExplorerParameters</class>
46
      </extends>
47
      <fields/>
48
    </class>
49

  
50

  
51
  </classes>
52
</definitions>  
tags/org.gvsig.postgresql-2.0.57/org.gvsig.postgresql.provider/src/main/resources/org/gvsig/fmap/dal/store/postgresql/PostgreSQLMetadata.xml
1
<?xml version="1.0"?>
2
<definitions>
3
  <version>1.0.0</version>
4
  <classes>
5
    <class name="PostgreSQL" namespace="Metadata">
6
      <extends>
7
      	<class name="JDBC" namespace="Metadata"/>
8
      </extends>
9
      <description>Metadata of a PostgreSQL store</description>
10
      <fields>
11
      </fields>
12
    </class>
13

  
14
  </classes>
15
</definitions>  
tags/org.gvsig.postgresql-2.0.57/org.gvsig.postgresql.provider/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.fmap.dal.store.postgresql.PostgreSQLLibrary
tags/org.gvsig.postgresql-2.0.57/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/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
* 2009 IVER T.I   {{Task}}
26
*/
27

  
28
package org.gvsig.fmap.dal.store.postgresql;
29

  
30
import java.sql.SQLException;
31
import java.text.MessageFormat;
32

  
33
import javax.sql.DataSource;
34

  
35
import org.apache.commons.dbcp.BasicDataSource;
36
import org.gvsig.fmap.dal.exception.DataException;
37
import org.gvsig.fmap.dal.exception.InitializeException;
38
import org.gvsig.fmap.dal.resource.exception.AccessResourceException;
39
import org.gvsig.fmap.dal.store.jdbc.JDBCResource;
40
import org.gvsig.fmap.dal.store.jdbc.JDBCResourceParameters;
41
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCDriverClassNotFoundException;
42
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCException;
43
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCSQLException;
44
import org.slf4j.Logger;
45
import org.slf4j.LoggerFactory;
46

  
47
public class PostgreSQLResource extends JDBCResource {
48
	
49
	final static private Logger logger = LoggerFactory
50
			.getLogger(PostgreSQLResource.class);
51

  
52
	public final static String NAME = "PostgreSQLResource";
53
	public static final String DESCRIPTION = "PostgreSQL Connection";
54

  
55
	public PostgreSQLResource(PostgreSQLResourceParameters parameters)
56
			throws InitializeException {
57
		super(parameters);
58
	}
59

  
60
	public String getName() throws AccessResourceException {
61
		PostgreSQLResourceParameters params = (PostgreSQLResourceParameters) this.getParameters();
62
		return MessageFormat.format("PostgreSQLResource({0},{1})",
63
				new Object[] { params.getUrl(),params.getUser() });
64
	}
65
        
66
        public String toString() {
67
            try {
68
                return this.getName();
69
            } catch(Exception ex) {
70
                return super.toString();
71
            }
72
        }
73

  
74
	protected void connectToDB() throws DataException {
75
		if (this.dataSource != null) {
76
			return;
77
		}
78
		JDBCResourceParameters jdbcParams = (JDBCResourceParameters) this
79
				.getParameters();
80
		BasicDataSource dataSource = new BasicDataSource();
81
		dataSource.setDriverClassName(jdbcParams.getJDBCDriverClassName());
82
		dataSource.setUsername(jdbcParams.getUser());
83
		dataSource.setPassword(jdbcParams.getPassword());
84
		dataSource.setUrl(jdbcParams.getUrl());
85

  
86
		dataSource.setMaxWait(60L * 1000); // FIXME
87

  
88
		// FIXME Set Pool parameters:
89
		/*
90
		dataSource.setMaxActive(maxActive);
91
		dataSource.setMaxIdle(maxActive);
92
		dataSource.setMaxOpenPreparedStatements(maxActive);
93
		dataSource.setMaxWait(maxActive);
94
		dataSource.setInitialSize(initialSize);
95
		dataSource.setDefaultReadOnly(defaultReadOnly);
96
		dataSource.setDefaultTransactionIsolation(defaultTransactionIsolation);
97
		dataSource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
98
		dataSource.setMinIdle(minIdle);
99
		dataSource.setTestOnBorrow(testOnBorrow);
100
		dataSource.setTestOnReturn(testOnReturn);
101
		dataSource.setTestWhileIdle(testOnReturn);
102
		dataSource
103
				.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
104

  
105
		dataSource.setAccessToUnderlyingConnectionAllowed(allow);
106
		dataSource.setLoginTimeout(seconds);
107
		dataSource.setLogWriter(out);
108
		*/
109

  
110
		this.dataSource = dataSource;
111
	}	
112
	protected void registerJDBCDriver() throws InitializeException {
113
		String className = ((JDBCResourceParameters) getParameters())
114
				.getJDBCDriverClassName();
115
		if (className == null) {
116
			return;
117
		}
118

  
119
		Class theClass = null;
120
		try {
121
			theClass = Class.forName(className);
122
		} catch (Exception e){
123
			throw new InitializeException(e);
124
		}
125
		if (theClass == null) {
126
			try {
127
				throw new JDBCDriverClassNotFoundException(this.getName(),
128
						className);
129
			} catch (AccessResourceException e) {
130
				throw new InitializeException(e);
131

  
132
			}
133
		}
134
	}
135
	
136
	protected DataSource createDataSource() {
137
		PostgreSQLResourceParameters jdbcParams = (PostgreSQLResourceParameters) this
138
				.getParameters();
139
		BasicDataSource dataSource = new BasicDataSource();
140
		dataSource.setDriverClassName(jdbcParams.getJDBCDriverClassName());
141
		dataSource.setUsername(jdbcParams.getUser());
142
		dataSource.setPassword(jdbcParams.getPassword());
143
		dataSource.setUrl(jdbcParams.getUrl());
144

  
145
		dataSource.setMaxWait(60L * 1000); // FIXME
146

  
147
		// FIXME Set Pool parameters:
148
		/*
149
		dataSource.setMaxActive(maxActive);
150
		dataSource.setMaxIdle(maxActive);
151
		dataSource.setMaxOpenPreparedStatements(maxActive);
152
		dataSource.setMaxWait(maxActive);
153
		dataSource.setInitialSize(initialSize);
154
		dataSource.setDefaultReadOnly(defaultReadOnly);
155
		dataSource.setDefaultTransactionIsolation(defaultTransactionIsolation);
156
		dataSource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
157
		dataSource.setMinIdle(minIdle);
158
		dataSource.setTestOnBorrow(testOnBorrow);
159
		dataSource.setTestOnReturn(testOnReturn);
160
		dataSource.setTestWhileIdle(testOnReturn);
161
		dataSource
162
			.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
163

  
164
		dataSource.setAccessToUnderlyingConnectionAllowed(allow);
165
		dataSource.setLoginTimeout(seconds);
166
		dataSource.setLogWriter(out);
167
		 */
168
		return dataSource;
169
	}
170
	
171
	
172
	public boolean isConnected() {
173
		if (dataSource == null) {
174
			return false;
175
		}
176
		if (dataSource instanceof BasicDataSource) {
177
			return ((BasicDataSource) dataSource).getNumActive() > 0
178
					|| ((BasicDataSource) dataSource).getNumIdle() > 0;
179
		}
180
		return true;
181
	}	
182
	
183
	private void logPoolStatus(String src) {
184
		if (logger.isDebugEnabled() ) {
185
			logger.debug(src + "  " + this.getStatusInformation());
186
		}
187

  
188
	}
189
        
190
        public String getStatusInformation() {
191
		if ( !(dataSource instanceof BasicDataSource) ) {
192
                    return "Connected: " + this.isConnected();
193
                }
194
        	BasicDataSource ds = (BasicDataSource) dataSource;
195
                String s = "Connected: " + this.isConnected() + ", " +
196
                        "actives: "+ ds.getNumActive() + "/"+ ds.getMaxActive() + ", " + 
197
                        "idle: " + ds.getNumIdle() + "/"+ ds.getMaxIdle() ;
198
                return s;
199
        }
200

  
201
        
202

  
203
        private static class CanGetConnectionException extends JDBCSQLException {
204
            public CanGetConnectionException(String datasource, SQLException cause) {
205
                super("Can't get a connection to the data source (%(datasource))", cause, "_CanGetConnectionException", 0);
206
                setValue("datasource", datasource);
207
            }
208
        }
209
    
210
	protected synchronized Object getTheConnection() throws DataException {
211
		try {
212
			Object conn = this.dataSource.getConnection();
213
			logPoolStatus("getTheConnection");
214
			return conn;
215
		} catch (SQLException e) {
216
			throw new CanGetConnectionException(this.toString(),e);
217
		}
218
	}	
219

  
220
}
tags/org.gvsig.postgresql-2.0.57/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLServerExplorer.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
package org.gvsig.fmap.dal.store.postgresql;
31

  
32
import java.sql.Connection;
33
import java.sql.SQLException;
34
import java.sql.Statement;
35
import java.util.ArrayList;
36
import java.util.Iterator;
37
import java.util.List;
38
import java.util.logging.Level;
39

  
40
import org.gvsig.fmap.dal.DataStoreParameters;
41
import org.gvsig.fmap.dal.NewDataStoreParameters;
42
import org.gvsig.fmap.dal.exception.DataException;
43
import org.gvsig.fmap.dal.exception.InitializeException;
44
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
45
import org.gvsig.fmap.dal.exception.RemoveException;
46
import org.gvsig.fmap.dal.resource.exception.AccessResourceException;
47
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices;
48
import org.gvsig.fmap.dal.store.jdbc.JDBCHelper;
49
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorer;
50
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters;
51
import org.gvsig.fmap.dal.store.jdbc.TransactionalAction;
52
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCExecuteSQLException;
53
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCSQLException;
54
import org.slf4j.Logger;
55
import org.slf4j.LoggerFactory;
56

  
57
/**
58
 * @author jmvivo
59
 *
60
 */
61
public class PostgreSQLServerExplorer extends JDBCServerExplorer {
62

  
63
    final static private Logger logger = LoggerFactory
64
            .getLogger(PostgreSQLServerExplorer.class);
65

  
66
    public static final String NAME = "PostgreSQLExplorer";
67

  
68
    public PostgreSQLServerExplorer(
69
            PostgreSQLServerExplorerParameters parameters,
70
            DataServerExplorerProviderServices services)
71
            throws InitializeException {
72
        super(parameters, services);
73
    }
74

  
75
    private PostgreSQLServerExplorerParameters getPostgreSQLParameters() {
76
        return (PostgreSQLServerExplorerParameters) getParameters();
77
    }
78

  
79
    protected JDBCHelper createHelper() throws InitializeException {
80
        return new PostgreSQLHelper(this, getPostgreSQLParameters());
81
    }
82

  
83
    public String getStoreName() {
84
        return PostgreSQLStoreProvider.NAME;
85
    }
86

  
87
    public String getProviderName() {
88
        return NAME;
89
    }
90

  
91
    protected JDBCStoreParameters createStoreParams()
92
            throws InitializeException, ProviderNotRegisteredException {
93
        PostgreSQLStoreParameters orgParams = (PostgreSQLStoreParameters) super
94
                .createStoreParams();
95

  
96
        orgParams.setUseSSL(getPostgreSQLParameters().getUseSSL());
97

  
98
        return orgParams;
99
    }
100

  
101
	// ****************************
102
    public boolean canAdd() {
103
        return true;
104
    }
105

  
106
    public DataStoreParameters getOpenParameters() throws DataException {
107
        PostgreSQLServerExplorerParameters parameters = getPostgreSQLParameters();
108
        PostgreSQLStoreParameters params = new PostgreSQLStoreParameters();
109
        params.setHost(parameters.getHost());
110
        params.setPort(parameters.getPort());
111
        params.setDBName(parameters.getDBName());
112
        params.setUser(parameters.getUser());
113
        params.setPassword(parameters.getPassword());
114
        params.setCatalog(parameters.getCatalog());
115
        params.setSchema(parameters.getSchema());
116
        params.setJDBCDriverClassName(parameters.getJDBCDriverClassName());
117
        params.setUrl(parameters.getUrl());
118
        return params;
119
    }
120

  
121
    protected void checkIsMine(DataStoreParameters dsp) {
122
        if (!(dsp instanceof PostgreSQLConnectionParameters)) {
123
            // FIXME Excpetion ???
124
            throw new IllegalArgumentException(
125
                    "not instance of PostgreSQLStoreParameters");
126
        }
127
        super.checkIsMine(dsp);
128

  
129
        PostgreSQLConnectionParameters pgp = (PostgreSQLConnectionParameters) dsp;
130
        if (pgp.getUseSSL().booleanValue() != getPostgreSQLParameters()
131
                .getUseSSL()) {
132
            throw new IllegalArgumentException("worng explorer: Host");
133
        }
134
    }
135

  
136
    public void remove(DataStoreParameters dsp) throws RemoveException {
137
        final PostgreSQLStoreParameters pgParams = (PostgreSQLStoreParameters) dsp;
138

  
139
        TransactionalAction action = new TransactionalAction() {
140
            public boolean continueTransactionAllowed() {
141
                return false;
142
            }
143

  
144
            public Object action(Connection conn) throws DataException {
145

  
146
                Statement st;
147
                try {
148
                    st = conn.createStatement();
149
                } catch (SQLException e) {
150
                    throw new JDBCSQLException(e);
151
                }
152

  
153
                String sqlDrop = "Drop table "
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff