Revision 43448

View differences:

tags/org.gvsig.desktop-2.0.198/org.gvsig.desktop.library/org.gvsig.exportto/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
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
  <modelVersion>4.0.0</modelVersion>
5
  <artifactId>org.gvsig.exportto</artifactId>
6
  <packaging>pom</packaging>
7
  <name>${project.artifactId}</name>
8
  <description>Exportto project</description>
9
  
10
  <parent>
11
    <groupId>org.gvsig</groupId>
12
    <artifactId>org.gvsig.desktop.library</artifactId>
13
    <version>2.0.198</version>
14
  </parent>
15

  
16
  <dependencies>
17
    <dependency>
18
      <groupId>org.gvsig</groupId>
19
      <artifactId>org.gvsig.tools.lib</artifactId>
20
    </dependency>
21
    <dependency>
22
      <groupId>org.gvsig</groupId>
23
      <artifactId>org.gvsig.tools.lib</artifactId>
24
      <type>test-jar</type>
25
      <scope>test</scope>
26
    </dependency>
27
  </dependencies>
28
  
29
  <modules>
30
    <module>org.gvsig.exportto.lib</module>
31
    <module>org.gvsig.exportto.swing</module>
32
    <module>org.gvsig.exportto.main</module>
33
  </modules>
34
</project>
35

  
36

  
37

  
0 38

  
tags/org.gvsig.desktop-2.0.198/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.main/src/main/resources/README.txt
1
Put into this folder the resources needed by your classes.
2

  
3
This folder is added to the classpath, so you can load any resources 
4
through the ClassLoader.
5

  
6
By default, in this folder you can find an example of log4j configuration,
7
prepared to log messages through the console, so logging works when you
8
run your classes.
0 9

  
tags/org.gvsig.desktop-2.0.198/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.main/src/main/resources/log4j.xml
1
<?xml version="1.0" encoding="ISO-8859-1" ?>
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 log4j:configuration SYSTEM "log4j.dtd">
28

  
29
<!-- 
30
Log4J configuration file for unit tests execution.
31
 -->
32
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
33

  
34
	<!-- Appender configuration to show logging messages through the console -->
35
	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
36
		<layout class="org.apache.log4j.PatternLayout">
37
			<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n  %m%n" />
38
		</layout>
39
	</appender>
40

  
41
	<!-- 
42
	Activate logging messages of DEBUG level of higher only for the
43
	org.gvsig.tools packages.
44
	You can put full classes names or packages instead, to configure
45
	logging for all the classes and subpackages of the package.
46
	-->
47
	<category name="org.gvsig.tools">
48
		<priority value="DEBUG" />
49
	</category>
50
	<category name="org.gvsig.exportto">
51
		<priority value="DEBUG" />
52
	</category>
53

  
54
	<!-- 
55
	By default, show only logging messages of INFO level or higher, 
56
	through the previously configured CONSOLE appender. 
57
	-->
58
	<root>
59
		<priority value="INFO" />
60
		<appender-ref ref="CONSOLE" />
61
	</root>
62
</log4j:configuration>
0 63

  
tags/org.gvsig.desktop-2.0.198/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.main/src/main/java/org/gvsig/exportto/main/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.exportto package documentation</title>
32
</head>
33
<body>
34

  
35
	<p>Exportto library testing and demo application.</p>
36

  
37
</body>
38
</html>
0 39

  
tags/org.gvsig.desktop-2.0.198/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.main/src/main/java/org/gvsig/exportto/main/Main.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.exportto.main;
25

  
26
import java.awt.BorderLayout;
27
import java.awt.Dimension;
28
import java.awt.event.ActionEvent;
29

  
30
import javax.swing.AbstractAction;
31
import javax.swing.Action;
32
import javax.swing.JButton;
33
import javax.swing.JFrame;
34
import javax.swing.JMenu;
35
import javax.swing.JMenuBar;
36
import javax.swing.JMenuItem;
37
import javax.swing.JToolBar;
38
import javax.swing.WindowConstants;
39

  
40
import org.slf4j.Logger;
41
import org.slf4j.LoggerFactory;
42

  
43
import org.gvsig.exportto.ExporttoLocator;
44
import org.gvsig.exportto.ExporttoManager;
45
import org.gvsig.exportto.swing.ExporttoSwingLocator;
46
import org.gvsig.exportto.swing.ExporttoSwingManager;
47
import org.gvsig.exportto.swing.ExporttoWindowManager;
48
import org.gvsig.exportto.swing.JExporttoServicePanel;
49
import org.gvsig.exportto.swing.preferences.ExporttoSwingPreferencesComponent;
50
import org.gvsig.exportto.swing.spi.ExporttoSwingProviderLocator;
51
import org.gvsig.fmap.crs.CRSFactory;
52
import org.gvsig.fmap.dal.DALLocator;
53
import org.gvsig.fmap.dal.DataManager;
54
import org.gvsig.fmap.dal.DataStoreParameters;
55
import org.gvsig.fmap.dal.exception.InitializeException;
56
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
57
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
58
import org.gvsig.fmap.dal.feature.FeatureStore;
59
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer;
60

  
61
/**
62
 * Main executable class for testing the Exportto library.
63
 * 
64
 * @author gvSIG Team
65
 * @version $Id$
66
 */
67
public class Main {
68

  
69
    private static final Logger LOG = LoggerFactory.getLogger(Main.class);
70

  
71
    private ExporttoManager manager;
72
    private ExporttoSwingManager swingManager;
73
    private DataManager dataManager;
74

  
75
    public static void main(String args[]) {
76
        new DefaultLibrariesInitializer().fullInitialize();
77
        Main main = new Main();
78
        main.show();
79
    }
80

  
81
    @SuppressWarnings("serial")
82
    public void show() {
83
        manager = ExporttoLocator.getManager();
84
        swingManager = ExporttoSwingLocator.getSwingManager();
85
        dataManager = DALLocator.getDataManager();
86

  
87
        Action showCookie = new AbstractAction("Get a Exportto") {
88

  
89
            public void actionPerformed(ActionEvent e) {
90
                showExportto(manager);
91
            }
92
        };
93

  
94
        Action preferences = new AbstractAction("Exportto preferences") {
95

  
96
            public void actionPerformed(ActionEvent e) {
97
                showExporttoPreferences();
98
            }
99

  
100
        };
101

  
102
        Action exit = new AbstractAction("Exit") {
103

  
104
            public void actionPerformed(ActionEvent e) {
105
                System.exit(0);
106
            }
107
        };
108

  
109
        JFrame frame = new JFrame("Exportto example app");
110
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
111

  
112
        // Create the menu bar.
113
        JMenuBar menuBar = new JMenuBar();
114

  
115
        // Build the menu.
116
        JMenu menuFile = new JMenu("File");
117
        menuFile.add(new JMenuItem(showCookie));
118
        menuFile.add(new JMenuItem(preferences));
119
        menuFile.add(new JMenuItem(exit));
120

  
121
        menuBar.add(menuFile);
122

  
123
        JToolBar toolBar = new JToolBar();
124
        toolBar.add(new JButton(showCookie));
125
        toolBar.add(new JButton(exit));
126

  
127
        frame.setPreferredSize(new Dimension(200, 100));
128
        frame.setJMenuBar(menuBar);
129
        frame.add(toolBar, BorderLayout.PAGE_START);
130

  
131
        // Display the window.
132
        frame.pack();
133
        frame.setVisible(true);
134
    }
135

  
136
    private void showExporttoPreferences() {
137
        ExporttoSwingPreferencesComponent preferences =
138
            ExporttoSwingProviderLocator.getManager()
139
                .createExporttoSwingProvidersPreferences();
140

  
141
        JFrame preferencesFrame = new JFrame("Export to preferences");
142
        preferencesFrame.add(preferences.asJComponent());
143

  
144
        preferencesFrame.pack();
145
        preferencesFrame.setVisible(true);
146
    }
147

  
148
    public void showExportto(ExporttoManager manager) {
149
        try {
150
            JExporttoServicePanel panel =
151
                swingManager.createExportto(createFeatureStore(),
152
                    CRSFactory.getCRS("EPSG:23030"));
153
            panel.setPreferredSize(new Dimension(800, 400));
154
            swingManager.getWindowManager().showWindow(panel, "Exportto",
155
                ExporttoWindowManager.MODE_WINDOW);
156
        } catch (ValidateDataParametersException e) {
157
            LOG.error("Error showing a Exportto", e);
158
        } catch (InitializeException e) {
159
            LOG.error("Error showing a Exportto", e);
160
        } catch (ProviderNotRegisteredException e) {
161
            LOG.error("Error showing a Exportto", e);
162
        }
163
    }
164

  
165
    private FeatureStore createFeatureStore() throws InitializeException,
166
        ProviderNotRegisteredException, ValidateDataParametersException {
167
        String sourceFileName =
168
            getClass().getClassLoader()
169
                .getResource("org/gvsig/exportto/data/andalucia.shp").getFile();
170
        DataStoreParameters sourceParameters =
171
            dataManager.createStoreParameters("Shape");
172
        sourceParameters.setDynValue("shpfile", sourceFileName);
173
        sourceParameters.setDynValue("crs", CRSFactory.getCRS("EPSG:23030"));
174
        return (FeatureStore) dataManager.openStore("Shape", sourceParameters);
175
    }
176
}
0 177

  
tags/org.gvsig.desktop-2.0.198/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.main/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
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/maven-v4_0_0.xsd">
4
    <modelVersion>4.0.0</modelVersion>
5
    <artifactId>org.gvsig.exportto.main</artifactId>
6
    <packaging>jar</packaging>
7
    <name>${project.artifactId}</name>
8
    <parent>
9
        <groupId>org.gvsig</groupId>
10
        <artifactId>org.gvsig.exportto</artifactId>
11
        <version>2.0.198</version>
12
    </parent>
13
    <dependencies>
14
        <dependency>
15
            <groupId>org.gvsig</groupId>
16
            <artifactId>org.gvsig.exportto.lib.api</artifactId>
17
        </dependency>
18
        <dependency>
19
            <groupId>org.gvsig</groupId>
20
            <artifactId>org.gvsig.exportto.lib.impl</artifactId>
21
            <scope>runtime</scope>
22
        </dependency>
23
        <dependency>
24
            <groupId>org.gvsig</groupId>
25
            <artifactId>org.gvsig.exportto.swing.api</artifactId>
26
        </dependency>
27
        <dependency>
28
            <groupId>org.gvsig</groupId>
29
            <artifactId>org.gvsig.exportto.swing.spi</artifactId>
30
        </dependency>
31
        <dependency>
32
            <groupId>org.gvsig</groupId>
33
            <artifactId>org.gvsig.tools.lib</artifactId>
34
            <scope>compile</scope>
35
        </dependency>
36
        <dependency>
37
            <groupId>org.gvsig</groupId>
38
            <artifactId>org.gvsig.projection.api</artifactId>
39
            <scope>compile</scope>
40
        </dependency>
41
        <dependency>
42
            <groupId>org.gvsig</groupId>
43
            <artifactId>org.gvsig.fmap.dal.api</artifactId>
44
            <scope>compile</scope>
45
        </dependency>
46
        <dependency>
47
            <groupId>org.gvsig</groupId>
48
            <artifactId>org.gvsig.tools.swing.api</artifactId>
49
            <scope>compile</scope>
50
        </dependency>
51
<!--
52
        <dependency>
53
            <groupId>org.gvsig</groupId>
54
            <artifactId>org.gvsig.tools.swing.serv.field</artifactId>
55
            <scope>compile</scope>
56
        </dependency>
57
-->
58
        <dependency>
59
            <groupId>org.gvsig</groupId>
60
            <artifactId>org.gvsig.metadata.lib.basic.api</artifactId>
61
            <scope>compile</scope>
62
        </dependency>
63
        <dependency>
64
            <groupId>org.gvsig</groupId>
65
            <artifactId>org.gvsig.i18n</artifactId>
66
            <scope>runtime</scope>
67
        </dependency>
68
    </dependencies>
69
</project>
70

  
0 71

  
tags/org.gvsig.desktop-2.0.198/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.impl/src/main/resources/org/gvsig/exportto/lib/impl/exporttofilters.properties
1
#point_geometries_only=
2
#curve_geometries_only=
3
#surface_geometries_only=
4
prov_demo=PROV < '10'
0 5

  
tags/org.gvsig.desktop-2.0.198/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.exportto.impl.ExporttoDefaultImplLibrary
tags/org.gvsig.desktop-2.0.198/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.impl/src/main/java/org/gvsig/exportto/impl/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.exportto package documentation</title>
32
</head>
33
<body>
34

  
35
	<p>Exportto library API default implementation.</p>
36

  
37
</body>
38
</html>
0 39

  
tags/org.gvsig.desktop-2.0.198/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.impl/src/main/java/org/gvsig/exportto/impl/ExporttoDefaultImplLibrary.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.exportto.impl;
25

  
26
import org.gvsig.exportto.ExporttoLibrary;
27
import org.gvsig.exportto.ExporttoLocator;
28
import org.gvsig.tools.library.AbstractLibrary;
29
import org.gvsig.tools.library.LibraryException;
30

  
31
/**
32
 * Library for default implementation initialization and configuration.
33
 * 
34
 * @author gvSIG team
35
 * @version $Id$
36
 */
37
public class ExporttoDefaultImplLibrary extends AbstractLibrary {
38

  
39
    @Override
40
    public void doRegistration() {
41
        registerAsImplementationOf(ExporttoLibrary.class);
42
    }
43

  
44
    @Override
45
    protected void doInitialize() throws LibraryException {
46
        ExporttoLocator.registerManager(DefaultExporttoManager.class);
47
    }
48

  
49
    @Override
50
    protected void doPostInitialize() throws LibraryException {
51
        // Do nothing
52
    }
53

  
54
}
0 55

  
tags/org.gvsig.desktop-2.0.198/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.impl/src/main/java/org/gvsig/exportto/impl/DefaultExporttoManager.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.exportto.impl;
24

  
25
import java.io.File;
26
import java.io.FileInputStream;
27
import java.io.FileOutputStream;
28
import java.io.IOException;
29
import java.util.HashMap;
30
import java.util.Iterator;
31
import java.util.Map;
32
import java.util.Properties;
33

  
34
import org.slf4j.Logger;
35
import org.slf4j.LoggerFactory;
36

  
37
import org.gvsig.exportto.ExporttoManager;
38
import org.gvsig.exportto.ExporttoService;
39
import org.gvsig.fmap.dal.DataServerExplorer;
40
import org.gvsig.fmap.dal.NewDataStoreParameters;
41
import org.gvsig.fmap.dal.OpenDataStoreParameters;
42

  
43
/**
44
 * Default {@link ExporttoManager} implementation.
45
 *
46
 * @author gvSIG Team
47
 * @version $Id$
48
 */
49
public class DefaultExporttoManager implements ExporttoManager {
50

  
51
    private static final Logger LOG = LoggerFactory
52
            .getLogger(DefaultExporttoManager.class);
53

  
54
    private Map<String, String> filters = null;
55
    private File homeFolder = null;
56

  
57
    public DefaultExporttoManager() {
58
        super();
59
        filters = new HashMap<>();
60
    }
61

  
62
    @Override
63
    public ExporttoService getExporttoService(
64
            DataServerExplorer dataServerExplorer,
65
            NewDataStoreParameters newDataStoreParameters,
66
            OpenDataStoreParameters openDataStoreParameters
67
        ) {
68
        return new DefaultExporttoService(
69
            dataServerExplorer,
70
            newDataStoreParameters, 
71
            openDataStoreParameters
72
        );
73
    }
74

  
75
    @Override
76
    public Iterator getPredefinedFilters() {
77
        if (this.filters == null) {
78
            if (this.homeFolder != null) {
79
                Properties properties = new Properties();
80
                File filtersFile = new File(this.homeFolder, "filters");
81
                if (filtersFile.exists()) {
82
                    try {
83
                        properties.load(new FileInputStream(filtersFile));
84
                        Iterator it = properties.keySet().iterator();
85
                        while (it.hasNext()) {
86
                            String key = (String) it.next();
87
                            filters.put(key, (String) properties.get(key));
88
                        }
89
                    } catch (IOException ex) {
90
                        LOG.warn("Can't load filters file '" + filtersFile.getAbsolutePath() + "'.", ex);
91
                    }
92
                }
93
            }
94
        }
95
        return filters.keySet().iterator();
96
    }
97

  
98
    @Override
99
    public String getFilter(String filterName) {
100
        if (filters.containsKey(filterName)) {
101
            return (String) filters.get(filterName);
102
        }
103
        return null;
104
    }
105

  
106
    @Override
107
    public void addFilter(String name, String filter) {
108
        this.filters.put(name, filter);
109
        if (this.homeFolder != null) {
110
            Properties properties = new Properties();
111
            Iterator<Map.Entry<String, String>> it = this.filters.entrySet().iterator();
112
            while (it.hasNext()) {
113
                Map.Entry<String, String> entry = it.next();
114
                properties.setProperty(entry.getKey(), entry.getValue());
115
            }
116
            File filtersFile = new File(this.homeFolder, "filters");
117
            try {
118
                properties.store(new FileOutputStream(filtersFile), "");
119
            } catch (IOException ex) {
120
                LOG.warn("Can't load filters file '" + filtersFile.getAbsolutePath() + "'.", ex);
121
            }
122
        }
123
    }
124

  
125
    @Override
126
    public void setHomeFolder(File homeFolder) {
127
        this.homeFolder = homeFolder;
128
    }
129

  
130
}
0 131

  
tags/org.gvsig.desktop-2.0.198/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.impl/src/main/java/org/gvsig/exportto/impl/DefaultExporttoService.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.exportto.impl;
24

  
25
import org.cresques.cts.ICoordTrans;
26
import org.cresques.cts.IProjection;
27

  
28
import org.gvsig.exportto.ExporttoService;
29
import org.gvsig.exportto.ExporttoServiceException;
30
import org.gvsig.exportto.ExporttoServiceFinishAction;
31
import org.gvsig.fmap.dal.DALLocator;
32
import org.gvsig.fmap.dal.DataManager;
33
import org.gvsig.fmap.dal.DataServerExplorer;
34
import org.gvsig.fmap.dal.NewDataStoreParameters;
35
import org.gvsig.fmap.dal.OpenDataStoreParameters;
36
import org.gvsig.fmap.dal.feature.EditableFeature;
37
import org.gvsig.fmap.dal.feature.Feature;
38
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
39
import org.gvsig.fmap.dal.feature.FeatureSet;
40
import org.gvsig.fmap.dal.feature.FeatureStore;
41
import org.gvsig.fmap.dal.feature.FeatureType;
42
import org.gvsig.fmap.geom.Geometry;
43
import org.gvsig.tools.ToolsLocator;
44
import org.gvsig.tools.dispose.DisposableIterator;
45
import org.gvsig.tools.dispose.DisposeUtils;
46
import org.gvsig.tools.task.AbstractMonitorableTask;
47

  
48
/**
49
 * Default {@link ExporttoService} implementation.
50
 *
51
 * @author gvSIG Team
52
 * @version $Id$
53
 */
54
public class DefaultExporttoService extends AbstractMonitorableTask implements
55
        ExporttoService {
56

  
57
    private DataServerExplorer dataServerExplorer;
58
    private NewDataStoreParameters newDataStoreParameters;
59
    private OpenDataStoreParameters openDataStoreParameters;
60

  
61
    private ExporttoServiceFinishAction exporttoServiceFinishAction;
62

  
63
    /**
64
     * {@link DefaultExporttoService} constructor
65
     * @param dataServerExplorer
66
     * @param newDataStoreParameters
67
     * @param openDataStoreParameters
68
     */
69
    public DefaultExporttoService(DataServerExplorer dataServerExplorer,
70
            NewDataStoreParameters newDataStoreParameters,
71
            OpenDataStoreParameters openDataStoreParameters
72
            ) {
73
        super(ToolsLocator.getI18nManager().getTranslation("Exportto"));
74
        this.dataServerExplorer = dataServerExplorer;
75
        this.newDataStoreParameters = newDataStoreParameters;
76
        this.openDataStoreParameters = openDataStoreParameters;
77
    }
78

  
79
    public void export(FeatureStore featureStore, IProjection projection,
80
            FeatureSet featureSet) throws ExporttoServiceException {
81
        // TODO Auto-generated method stub
82

  
83
    }
84

  
85
    public void export(FeatureSet featureSet) throws ExporttoServiceException {
86

  
87
        String providerName = newDataStoreParameters.getDataStoreName();
88
        String explorerName = dataServerExplorer.getProviderName();
89

  
90
        DisposableIterator it = null;
91
        FeatureStore target = null;
92
        EditableFeature newfeature = null;
93
        try {
94
            taskStatus.setRangeOfValues(0, featureSet.getSize());
95

  
96
            DataManager dataManager = DALLocator.getDataManager();
97

  
98
            dataManager.newStore(explorerName, providerName, newDataStoreParameters, true);
99
            target = (FeatureStore) dataManager.openStore(providerName, openDataStoreParameters);
100

  
101
            FeatureType targetType = target.getDefaultFeatureType();
102

  
103
            target.edit(FeatureStore.MODE_APPEND);
104
            it = featureSet.fastIterator();
105

  
106
            IProjection targetProjection;
107
            FeatureAttributeDescriptor defaultGeom = target.getDefaultFeatureType().getDefaultGeometryAttribute();
108
            if (defaultGeom!=null) {
109
            	targetProjection = defaultGeom.getSRS();
110
            }
111
            else {
112
            	targetProjection = null;
113
            }
114

  
115
            long featureCount = 0;
116
            while (it.hasNext()) {
117
                Feature feature = (Feature) it.next();
118
                newfeature = target.createNewFeature(targetType, feature);
119
                // ================================================
120
                // Reprojection stuff
121
                Geometry reproj_geom = null;
122
                IProjection sourceProjection = feature.getDefaultSRS();
123

  
124
                ICoordTrans coord_trans = null;
125
                // this comparison is perhaps too preventive
126
                // we could  have two instances of same projection
127
                // so we would do more computations than needed
128
                if (sourceProjection != null
129
                        && targetProjection != null
130
                        && sourceProjection != targetProjection) {
131

  
132
                    coord_trans = sourceProjection.getCT(targetProjection);
133
                    reproj_geom = feature.getDefaultGeometry();
134
                    reproj_geom = reproj_geom.cloneGeometry();
135
                    reproj_geom.reProject(coord_trans);
136
                    newfeature.setDefaultGeometry(reproj_geom);
137
                }
138
                // ================================================
139

  
140
                target.insert(newfeature);
141

  
142
                featureCount++;
143
                this.taskStatus.setCurValue(featureCount);
144

  
145
                if (this.taskStatus.isCancellationRequested()) {
146
                    return;
147
                }
148
            }
149
            target.finishEditing();
150

  
151
            this.taskStatus.terminate();
152
            this.taskStatus.remove();
153
        } catch (Exception e) {
154
            throw new ExporttoServiceException(e, newfeature);
155
        } finally {
156
            if (target != null) {
157
                target.dispose();
158
            }
159
            if (it != null) {
160
                it.dispose();
161
            }
162
            if (featureSet != null) {
163
                featureSet.dispose();
164
            }
165
            DisposeUtils.dispose(it);
166
        }
167

  
168
        if (exporttoServiceFinishAction != null) {
169
            exporttoServiceFinishAction.finished(
170
                    newDataStoreParameters.getDataStoreName(),
171
                    newDataStoreParameters);
172
        }
173
    }
174

  
175
    public void setFinishAction(
176
            ExporttoServiceFinishAction exporttoServiceFinishAction) {
177
        this.exporttoServiceFinishAction = exporttoServiceFinishAction;
178
    }
179

  
180
}
0 181

  
tags/org.gvsig.desktop-2.0.198/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.impl/src/test/java/org/gvsig/exportto/impl/DefaultExporttoManagerTest.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.exportto.impl;
25

  
26
import org.gvsig.exportto.ExporttoManager;
27
import org.gvsig.exportto.ExporttoManagerTest;
28

  
29
/**
30
 * {@link ExporttoManager} API compatibility tests for the
31
 * {@link DefaultExporttoManager} implementation.
32
 * 
33
 * @author gvSIG Team
34
 * @version $Id$
35
 */
36
public class DefaultExporttoManagerTest extends ExporttoManagerTest {
37

  
38
    // Nothing to add
39
}
0 40

  
tags/org.gvsig.desktop-2.0.198/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.impl/src/test/resources/README.txt
1
Put into this folder the resources needed by your test classes.
2

  
3
This folder is added to the Tests classpath, so you can load any resources 
4
through the ClassLoader.
5

  
6
By default, in this folder you can find an example of log4j configuration,
7
prepared to log messages through the console, so logging works when you
8
run your tests classes.
0 9

  
tags/org.gvsig.desktop-2.0.198/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.impl/src/test/resources/log4j.xml
1
<?xml version="1.0" encoding="ISO-8859-1" ?>
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 log4j:configuration SYSTEM "log4j.dtd">
28

  
29
<!-- 
30
Log4J configuration file for unit tests execution.
31
 -->
32
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
33

  
34
	<!-- Appender configuration to show logging messages through the console -->
35
	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
36
		<layout class="org.apache.log4j.PatternLayout">
37
			<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n  %m%n" />
38
		</layout>
39
	</appender>
40

  
41
	<!-- 
42
	Activate logging messages of DEBUG level of higher only for the
43
	org.gvsig.tools packages.
44
	You can put full classes names or packages instead, to configure
45
	logging for all the classes and subpackages of the package.
46
	-->
47
	<category name="org.gvsig.tools">
48
		<priority value="DEBUG" />
49
	</category>
50
	<category name="org.gvsig.exportto">
51
		<priority value="DEBUG" />
52
	</category>
53

  
54
	<!-- 
55
	By default, show only logging messages of INFO level or higher, 
56
	through the previously configured CONSOLE appender. 
57
	-->
58
	<root>
59
		<priority value="INFO" />
60
		<appender-ref ref="CONSOLE" />
61
	</root>
62
</log4j:configuration>
0 63

  
tags/org.gvsig.desktop-2.0.198/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.impl/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
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/maven-v4_0_0.xsd">
4
  <modelVersion>4.0.0</modelVersion>
5
  <artifactId>org.gvsig.exportto.lib.impl</artifactId>
6
  <packaging>jar</packaging>
7
  <name>${project.artifactId}</name>
8
  <parent>
9
    <groupId>org.gvsig</groupId>
10
    <artifactId>org.gvsig.exportto.lib</artifactId>
11
    <version>2.0.198</version>
12
  </parent>
13
  <dependencies>
14
    <dependency>
15
      <groupId>org.gvsig</groupId>
16
      <artifactId>org.gvsig.exportto.lib.api</artifactId>
17
    </dependency>    
18
    <dependency>
19
      <groupId>org.gvsig</groupId>
20
      <artifactId>org.gvsig.exportto.lib.api</artifactId>
21
      <type>test-jar</type>
22
      <scope>test</scope> 
23
    </dependency>
24
    <dependency>
25
        <groupId>org.gvsig</groupId>
26
        <artifactId>org.gvsig.tools.lib</artifactId>
27
        <scope>compile</scope>
28
    </dependency>
29
    <dependency>
30
        <groupId>org.gvsig</groupId>
31
        <artifactId>org.gvsig.metadata.lib.basic.api</artifactId>
32
        <scope>compile</scope>
33
    </dependency>
34
    <dependency>
35
        <groupId>org.gvsig</groupId>
36
        <artifactId>org.gvsig.fmap.dal.api</artifactId>    
37
        <scope>compile</scope>        
38
    </dependency>
39
    <dependency>
40
        <groupId>org.gvsig</groupId>
41
        <artifactId>org.gvsig.projection.api</artifactId>
42
        <scope>compile</scope>
43
    </dependency>
44
  </dependencies>
45

  
46
  <build>
47
    <plugins>
48
        <plugin>
49
          <!-- Skip test execution -->
50
          <groupId>org.apache.maven.plugins</groupId>
51
          <artifactId>maven-surefire-plugin</artifactId>
52
          <configuration>
53
            <skipTests>true</skipTests>
54
          </configuration>
55
        </plugin>
56

  
57
        <plugin>
58
          <!-- Skip compilation tests -->
59
          <groupId>org.apache.maven.plugins</groupId>
60
          <artifactId>maven-compiler-plugin</artifactId>
61
          <executions>
62
            <execution>
63
              <id>default-testCompile</id>
64
              <phase>process-test-sources</phase>
65
              <goals>
66
                <goal>testCompile</goal>
67
              </goals>
68
              <configuration>
69
                <skip>true</skip>
70
              </configuration>
71
            </execution>
72
          </executions>
73
        </plugin>
74

  
75
    </plugins>
76
  </build>
77
</project>
78

  
0 79

  
tags/org.gvsig.desktop-2.0.198/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.api/src/test/java/org/gvsig/exportto/ExporttoManagerTest.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.exportto;
25

  
26
import org.gvsig.fmap.dal.DALLocator;
27
import org.gvsig.fmap.dal.DataManager;
28
import org.gvsig.fmap.dal.DataServerExplorer;
29
import org.gvsig.fmap.dal.DataServerExplorerParameters;
30
import org.gvsig.fmap.dal.NewDataStoreParameters;
31
import org.gvsig.fmap.dal.exception.DataException;
32
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
33
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
34

  
35
/**
36
 * API compatibility tests for {@link ExporttoManager} implementations.
37
 * 
38
 * @author gvSIG Team
39
 * @version $Id$
40
 */
41
public abstract class ExporttoManagerTest extends
42
    AbstractLibraryAutoInitTestCase {
43

  
44
    protected ExporttoManager manager;
45
    protected DataManager dataManager = null;
46

  
47
    @Override
48
    protected void doSetUp() throws Exception {
49
        manager = ExporttoLocator.getManager();
50
        dataManager = DALLocator.getDataManager();
51
    }
52

  
53
    /**
54
     * Test for the {@link ExporttoManager#getExporttoService()} method.
55
     * 
56
     * @throws Exception
57
     *             if there is any error in the tests
58
     */
59
    public void testGetExporttoService() throws Exception {
60
        ExporttoService exportService;
61
        try {
62
            exportService = createService();
63
            assertNotNull(exportService);
64
        } catch (ValidateDataParametersException e) {
65
            assertNull(e);
66
        } catch (DataException e) {
67
            assertNull(e);
68
        }
69
    }
70

  
71
    protected ExporttoService createService()
72
        throws ValidateDataParametersException, DataException {
73
        DataServerExplorerParameters dataServerExplorerParameters =
74
            dataManager.createServerExplorerParameters("FilesystemExplorer");
75
        DataServerExplorer dataServerExplorer =
76
            dataManager.openServerExplorer("FilesystemExplorer",
77
                dataServerExplorerParameters);
78
        NewDataStoreParameters newDataStoreParameters =
79
            dataServerExplorer.getAddParameters("Shape");
80
        return manager.getExporttoService(dataServerExplorer, 
81
            newDataStoreParameters, null);
82
    }
83

  
84
}
0 85

  
tags/org.gvsig.desktop-2.0.198/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.api/src/test/java/org/gvsig/exportto/ExporttoServiceTest.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.exportto;
25

  
26
import org.gvsig.fmap.dal.DALLocator;
27
import org.gvsig.fmap.dal.DataManager;
28
import org.gvsig.fmap.dal.DataServerExplorer;
29
import org.gvsig.fmap.dal.DataServerExplorerParameters;
30
import org.gvsig.fmap.dal.DataStoreParameters;
31
import org.gvsig.fmap.dal.NewDataStoreParameters;
32
import org.gvsig.fmap.dal.exception.DataException;
33
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
34
import org.gvsig.fmap.dal.feature.FeatureStore;
35
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
36

  
37
/**
38
 * API compatibility tests for {@link ExporttoService} implementations.
39
 * 
40
 * @author gvSIG Team
41
 * @version $Id$
42
 */
43
public abstract class ExporttoServiceTest extends
44
    AbstractLibraryAutoInitTestCase {
45

  
46
    protected ExporttoManager manager;
47
    protected DataManager dataManager = null;
48

  
49
    @Override
50
    protected void doSetUp() throws Exception {
51
        manager = ExporttoLocator.getManager();
52
        dataManager = DALLocator.getDataManager();
53
    }
54

  
55
    /**
56
     * Returns an instance of the {@link ExporttoService}.
57
     * 
58
     * @return a {@link ExporttoService} instance
59
     * @throws ValidateDataParametersException
60
     * @throws DataException
61
     * @throws Exception
62
     *             if there is any error creating the instance
63
     */
64
    protected ExporttoService createService()
65
        throws ValidateDataParametersException, DataException {
66
        DataServerExplorerParameters dataServerExplorerParameters =
67
            dataManager.createServerExplorerParameters("FilesystemExplorer");
68
        DataServerExplorer dataServerExplorer =
69
            dataManager.openServerExplorer("FilesystemExplorer",
70
                dataServerExplorerParameters);
71
        NewDataStoreParameters newDataStoreParameters =
72
            dataServerExplorer.getAddParameters("Shape");
73
        return manager.getExporttoService(dataServerExplorer,
74
            newDataStoreParameters, null);
75
    }
76

  
77
    /**
78
     * Test for the
79
     * {@link ExporttoService#export(org.gvsig.fmap.dal.feature.FeatureSet)}
80
     * method.
81
     */
82
    public void testExporttoServiceCreation() {
83
        ExporttoService exportService;
84
        try {
85
            exportService = createService();
86
            assertNotNull(exportService);
87
            // TODO a test for the export service
88
            // exportService.export(featureSet);
89

  
90
        } catch (ValidateDataParametersException e) {
91
            assertNull(e);
92
        } catch (DataException e) {
93
            assertNull(e);
94
        }
95
    }
96

  
97
    @SuppressWarnings("unused")
98
    private FeatureStore createMemoryFeatureStore()
99
        throws ValidateDataParametersException, DataException {
100
        DataStoreParameters memoryParameters =
101
            dataManager.createStoreParameters("Memory");
102
        FeatureStore featureStore =
103
            (FeatureStore) dataManager.openStore("Memory", memoryParameters);
104
        return (FeatureStore) featureStore.getFeatureSet();
105
    }
106
}
0 107

  
tags/org.gvsig.desktop-2.0.198/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.api/src/main/java/org/gvsig/exportto/ExporttoLibrary.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.exportto;
25

  
26
import org.gvsig.tools.library.AbstractLibrary;
27
import org.gvsig.tools.library.LibraryException;
28
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
29

  
30
/**
31
 * Library for API initialization and configuration.
32
 * 
33
 * @author gvSIG team
34
 * @version $Id$
35
 */
36
public class ExporttoLibrary extends AbstractLibrary {
37

  
38
    @Override
39
    public void doRegistration() {
40
        registerAsAPI(ExporttoLibrary.class);
41
    }
42

  
43
    @Override
44
    protected void doInitialize() throws LibraryException {
45
        // Do nothing
46
    }
47

  
48
    @Override
49
    protected void doPostInitialize() throws LibraryException {
50
        // Validate there is any implementation registered.
51
        ExporttoManager manager = ExporttoLocator.getManager();
52
        if (manager == null) {
53
            throw new ReferenceNotRegisteredException(
54
                ExporttoLocator.MANAGER_NAME, ExporttoLocator.getInstance());
55
        }
56
    }
57

  
58
}
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff