Revision 37617

View differences:

tags/v_2_0_0_Build_2043/applications/appGazetteer/src-test/org/gvsig/gazetteer/drivers/ExampleNewPanel.java
1
package org.gvsig.gazetteer.drivers;
2

  
3
import java.util.Properties;
4

  
5
import javax.swing.JLabel;
6
import javax.swing.JTextField;
7

  
8
import org.gvsig.catalog.ui.search.SearchAditionalPropertiesPanel;
9

  
10

  
11
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
12
 *
13
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
14
 *
15
 * This program is free software; you can redistribute it and/or
16
 * modify it under the terms of the GNU General Public License
17
 * as published by the Free Software Foundation; either version 2
18
 * of the License, or (at your option) any later version.
19
 *
20
 * This program is distributed in the hope that it will be useful,
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 * GNU General Public License for more details.
24
 *
25
 * You should have received a copy of the GNU General Public License
26
 * along with this program; if not, write to the Free Software
27
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
28
 *
29
 * For more information, contact:
30
 *
31
 *  Generalitat Valenciana
32
 *   Conselleria d'Infraestructures i Transport
33
 *   Av. Blasco Ib??ez, 50
34
 *   46010 VALENCIA
35
 *   SPAIN
36
 *
37
 *      +34 963862235
38
 *   gvsig@gva.es
39
 *      www.gvsig.gva.es
40
 *
41
 *    or
42
 *
43
 *   IVER T.I. S.A
44
 *   Salamanca 50
45
 *   46005 Valencia
46
 *   Spain
47
 *
48
 *   +34 963163400
49
 *   dac@iver.es
50
 */
51
/* CVS MESSAGES:
52
 *
53
 * $Id: ExampleNewPanel.java 537 2007-07-26 11:21:10 +0000 (Thu, 26 Jul 2007) jpiera $
54
 * $Log$
55
 * Revision 1.1.2.1  2007/07/13 12:00:35  jorpiell
56
 * Add the posibility to add a new panel
57
 *
58
 *
59
 */
60
/**
61
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
62
 */
63
public class ExampleNewPanel extends SearchAditionalPropertiesPanel{
64
	JLabel label = null;
65
	JTextField text = null;
66
	
67
	public ExampleNewPanel(){
68
		label = new JLabel();
69
		text = new JTextField();		
70
		setLayout(new java.awt.BorderLayout());
71
		label.setText("Label");
72
		add(label, java.awt.BorderLayout.WEST);		
73
		add(text, java.awt.BorderLayout.CENTER);
74
	}
75
	
76
	/*
77
	 * (non-Javadoc)
78
	 * @see es.gva.cit.gazetteer.ui.search.SearchAditionalPropertiesPanel#getProperties()
79
	 */
80
	public Properties getProperties() {
81
		Properties properties = new Properties();
82
		properties.put("PROP1", text.getText());
83
		return properties;
84
	}
85

  
86
}
0 87

  
tags/v_2_0_0_Build_2043/applications/appGazetteer/src-test/org/gvsig/gazetteer/drivers/ExampleNewDriver.java
1
package org.gvsig.gazetteer.drivers;
2

  
3
import java.awt.geom.Point2D;
4
import java.net.URI;
5

  
6
import org.gvsig.catalog.drivers.DiscoveryServiceCapabilities;
7
import org.gvsig.catalog.ui.search.SearchAditionalPropertiesPanel;
8
import org.gvsig.gazetteer.querys.Feature;
9
import org.gvsig.gazetteer.querys.GazetteerQuery;
10

  
11

  
12
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
13
 *
14
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
15
 *
16
 * This program is free software; you can redistribute it and/or
17
 * modify it under the terms of the GNU General Public License
18
 * as published by the Free Software Foundation; either version 2
19
 * of the License, or (at your option) any later version.
20
 *
21
 * This program is distributed in the hope that it will be useful,
22
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
 * GNU General Public License for more details.
25
 *
26
 * You should have received a copy of the GNU General Public License
27
 * along with this program; if not, write to the Free Software
28
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
29
 *
30
 * For more information, contact:
31
 *
32
 *  Generalitat Valenciana
33
 *   Conselleria d'Infraestructures i Transport
34
 *   Av. Blasco Ib??ez, 50
35
 *   46010 VALENCIA
36
 *   SPAIN
37
 *
38
 *      +34 963862235
39
 *   gvsig@gva.es
40
 *      www.gvsig.gva.es
41
 *
42
 *    or
43
 *
44
 *   IVER T.I. S.A
45
 *   Salamanca 50
46
 *   46005 Valencia
47
 *   Spain
48
 *
49
 *   +34 963163400
50
 *   dac@iver.es
51
 */
52
/* CVS MESSAGES:
53
 *
54
 * $Id: ExampleNewDriver.java 537 2007-07-26 11:21:10 +0000 (Thu, 26 Jul 2007) jpiera $
55
 * $Log$
56
 * Revision 1.1.2.1  2007/07/13 12:00:35  jorpiell
57
 * Add the posibility to add a new panel
58
 *
59
 *
60
 */
61
/**
62
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
63
 */
64
public class ExampleNewDriver extends AbstractGazetteerServiceDriver {
65

  
66
	/*
67
	 * (non-Javadoc)
68
	 * @see es.gva.cit.catalogClient.drivers.IDiscoveryServiceDriver#getCapabilities(java.net.URI)
69
	 */
70
	public DiscoveryServiceCapabilities getCapabilities(URI uri) {
71
		return new GazetteerCapabilities();
72
	}
73

  
74
	/*
75
	 * (non-Javadoc)
76
	 * @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#getFeature(java.net.URI, es.gva.cit.gazetteer.querys.Query)
77
	 */
78
	public Feature[] getFeature(URI uri, GazetteerQuery query) throws Exception {
79
		String prop = (String)query.getProperty("PROP1");
80
		Feature[] features = new Feature[1];
81
		features[0] = new Feature("1","Result 1","description 1",new Point2D.Double(0,0));
82
		return features;
83
	}
84

  
85
	/*
86
	 * (non-Javadoc)
87
	 * @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#getServiceName()
88
	 */
89
	public String getServiceName() {
90
		return "My service";
91
	}
92
	
93
	/*
94
	 * (non-Javadoc)
95
	 * @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#getAditionalSearchPanel()
96
	 */
97
	public SearchAditionalPropertiesPanel getAditionalSearchPanel(){
98
		return new ExampleNewPanel();
99
	}
100

  
101
}
0 102

  
tags/v_2_0_0_Build_2043/applications/appGazetteer/src-test/org/gvsig/gazetteer/drivers/ExampleNewDriverTest.java
1
package org.gvsig.gazetteer.drivers;
2

  
3
import javax.swing.UIManager;
4
import javax.swing.UnsupportedLookAndFeelException;
5

  
6
import org.gvsig.gazetteer.GazetteerLocator;
7
import org.gvsig.gazetteer.ui.serverconnect.ServerConnectDialog;
8
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer;
9

  
10

  
11
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
12
 *
13
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
14
 *
15
 * This program is free software; you can redistribute it and/or
16
 * modify it under the terms of the GNU General Public License
17
 * as published by the Free Software Foundation; either version 2
18
 * of the License, or (at your option) any later version.
19
 *
20
 * This program is distributed in the hope that it will be useful,
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 * GNU General Public License for more details.
24
 *
25
 * You should have received a copy of the GNU General Public License
26
 * along with this program; if not, write to the Free Software
27
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
28
 *
29
 * For more information, contact:
30
 *
31
 *  Generalitat Valenciana
32
 *   Conselleria d'Infraestructures i Transport
33
 *   Av. Blasco Ib??ez, 50
34
 *   46010 VALENCIA
35
 *   SPAIN
36
 *
37
 *      +34 963862235
38
 *   gvsig@gva.es
39
 *      www.gvsig.gva.es
40
 *
41
 *    or
42
 *
43
 *   IVER T.I. S.A
44
 *   Salamanca 50
45
 *   46005 Valencia
46
 *   Spain
47
 *
48
 *   +34 963163400
49
 *   dac@iver.es
50
 */
51
/* CVS MESSAGES:
52
 *
53
 * $Id: ExampleNewDriverTest.java 512 2007-07-24 11:25:43 +0000 (Tue, 24 Jul 2007) jorpiell $
54
 * $Log$
55
 * Revision 1.1.2.2  2007/07/24 11:25:42  jorpiell
56
 * The registers has been refactorized
57
 *
58
 * Revision 1.1.2.1  2007/07/13 12:00:35  jorpiell
59
 * Add the posibility to add a new panel
60
 *
61
 *
62
 */
63
/**
64
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
65
 */
66
public class ExampleNewDriverTest {
67

  
68
	/**
69
	 * @param args
70
	 */
71
	public static void main(String[] args) {
72
		new DefaultLibrariesInitializer().fullInitialize();
73
		
74
		GazetteerLocator.getGazetteerManager().register("example", ExampleNewDriver.class);
75
		//Get the currently installed look and feel
76
		UIManager.getLookAndFeel();
77
		// Install a different look and feel; specifically, the Windows look and feel
78
		try {
79
			UIManager.setLookAndFeel(
80
					"com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
81
		} catch (InstantiationException e) {
82
		} catch (ClassNotFoundException e) {
83
		} catch (UnsupportedLookAndFeelException e) {
84
		} catch (IllegalAccessException e) {
85
		}
86

  
87
		new ServerConnectDialog();
88
	}
89

  
90
}
0 91

  
tags/v_2_0_0_Build_2043/applications/appGazetteer/src-test/org/gvsig/gazetteer/URIs.java
1
package org.gvsig.gazetteer;
2

  
3
import java.net.URISyntaxException;
4

  
5

  
6
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
7
 *
8
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
9
 *
10
 * This program is free software; you can redistribute it and/or
11
 * modify it under the terms of the GNU General Public License
12
 * as published by the Free Software Foundation; either version 2
13
 * of the License, or (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program; if not, write to the Free Software
22
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
23
 *
24
 * For more information, contact:
25
 *
26
 *  Generalitat Valenciana
27
 *   Conselleria d'Infraestructures i Transport
28
 *   Av. Blasco Ib??ez, 50
29
 *   46010 VALENCIA
30
 *   SPAIN
31
 *
32
 *      +34 963862235
33
 *   gvsig@gva.es
34
 *      www.gvsig.gva.es
35
 *
36
 *    or
37
 *
38
 *   IVER T.I. S.A
39
 *   Salamanca 50
40
 *   46005 Valencia
41
 *   Spain
42
 *
43
 *   +34 963163400
44
 *   dac@iver.es
45
 */
46
/* CVS MESSAGES:
47
 *
48
 * $Id: URIs.java 499 2007-07-10 11:18:10 +0000 (Tue, 10 Jul 2007) jorpiell $
49
 * $Log$
50
 * Revision 1.1.2.1  2007/07/10 11:18:03  jorpiell
51
 * Added the registers
52
 *
53
 *
54
 */
55
/**
56
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
57
 */
58
public class URIs {
59

  
60
	/**
61
	 * @param args
62
	 * @throws URISyntaxException 
63
	 */
64
	public static void main(String[] args) throws URISyntaxException {
65
		java.net.URI uri = new java.net.URI("www.upv.es");
66
		System.out.println(uri.getHost());
67
		System.out.println(uri.getPort());
68
		System.out.println(uri.getScheme());
69
		java.net.URI uri1 = new java.net.URI("z3950://www.upv.es");
70
		System.out.println(uri1.getHost());
71
		System.out.println(uri1.getPort());
72
		System.out.println(uri1.getScheme());
73
	}
74

  
75
}
0 76

  
tags/v_2_0_0_Build_2043/applications/appGazetteer/src/org/gvsig/gazetteer/GazetteerLocator.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.gazetteer;
29

  
30
import org.gvsig.tools.locator.AbstractLocator;
31
import org.gvsig.tools.locator.Locator;
32
import org.gvsig.tools.locator.LocatorException;
33

  
34
/**
35
 * This Locator provides the entry point for the gvSIG 
36
 * {@link GazetteerManager}
37
 * @see Locator
38
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
39
 */
40
public class GazetteerLocator extends AbstractLocator {
41
	private static final String LOCATOR_NAME = "GazetteerLocator";
42
	
43
	/**
44
	 * GazetteerManager name used by the locator to access the instance
45
	 */
46
	public static final String GAZETTEER_MANAGER_NAME = "GazetteerManager";
47
	private static final String GAZETTEER_MANAGER_DESCRIPTION = "GazetteerManager of gvSIG";
48

  
49
	/**
50
	 * Unique instance.
51
	 */
52
	private static final GazetteerLocator instance = new GazetteerLocator();
53
	
54
	/* (non-Javadoc)
55
	 * @see org.gvsig.tools.locator.Locator#getLocatorName()
56
	 */
57
	public String getLocatorName() {
58
		return LOCATOR_NAME;
59
	}
60
	
61
	/**
62
	 * Return a reference to {@link GazetteerManager}.
63
	 *
64
	 * @return a reference to GazetteerManager
65
	 * @throws LocatorException
66
	 *             if there is no access to the class or the class cannot be
67
	 *             instantiated
68
	 * @see Locator#get(String)
69
	 */
70
	public static GazetteerManager getGazetteerManager() throws LocatorException {
71
		return (GazetteerManager) getInstance().get(GAZETTEER_MANAGER_NAME);
72
	}
73
	
74
	/**
75
	 * Return the singleton instance.
76
	 *
77
	 * @return the singleton instance
78
	 */
79
	public static GazetteerLocator getInstance() {
80
		return instance;
81
	}
82
	
83
	/**
84
	 * Registers the Class implementing the {@link GazetteerManager} interface.
85
	 *
86
	 * @param clazz
87
	 *            implementing the IGazetteerServiceDriver interface
88
	 */
89
	public static void registerGazetteerManager(Class clazz) {
90
		getInstance().register(GAZETTEER_MANAGER_NAME, 
91
				GAZETTEER_MANAGER_DESCRIPTION,
92
				clazz);
93
	}
94
}
95

  
0 96

  
tags/v_2_0_0_Build_2043/applications/appGazetteer/src/org/gvsig/gazetteer/geonames/GeonamesServiceDriver.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.gazetteer.geonames;
29

  
30
import java.awt.geom.Point2D;
31
import java.net.URI;
32
import java.util.List;
33

  
34
import org.geonames.Toponym;
35
import org.geonames.ToponymSearchCriteria;
36
import org.geonames.ToponymSearchResult;
37
import org.geonames.WebService;
38
import org.gvsig.catalog.drivers.DiscoveryServiceCapabilities;
39
import org.gvsig.catalog.exceptions.NotSupportedVersionException;
40
import org.gvsig.gazetteer.drivers.AbstractGazetteerServiceDriver;
41
import org.gvsig.gazetteer.drivers.GazetteerCapabilities;
42
import org.gvsig.gazetteer.querys.Feature;
43
import org.gvsig.gazetteer.querys.GazetteerQuery;
44
import org.gvsig.utils.swing.jcomboServer.ServerData;
45

  
46

  
47

  
48
public class GeonamesServiceDriver extends AbstractGazetteerServiceDriver {
49
	
50
	
51
	public GeonamesServiceDriver() {
52
		super();
53
		setProjection("EPSG:4326");		
54
	}
55

  
56
	/*
57
	 * (non-Javadoc)
58
	 * @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#getFeature(java.net.URI, es.gva.cit.gazetteer.querys.GazetteerQuery)
59
	 */
60
	public Feature[] getFeature(URI uri, GazetteerQuery query) throws Exception {
61
		ToponymSearchCriteria searchCriteria = new ToponymSearchCriteria();
62
		searchCriteria.setQ(query.getName());
63
		ToponymSearchResult searchResult = WebService.search(searchCriteria);
64
		List toponims = searchResult.getToponyms();
65
		Feature[] features = new Feature[toponims.size()];
66
		for (int i=0 ; i<toponims.size() ; i++){
67
			features[i] = converToponym((Toponym)toponims.get(i));
68
		}
69
		return features;
70
	}
71

  
72
	private Feature converToponym(Toponym toponym) {
73
		Feature feature = new Feature(toponym.getFeatureCode(), 
74
				toponym.getName(),
75
				toponym.getName(),
76
				new Point2D.Double(toponym.getLongitude(), toponym.getLatitude()));
77
		
78
		return feature;
79
	}
80

  
81
	/*
82
	 * (non-Javadoc)
83
	 * @see es.gva.cit.catalog.drivers.IDiscoveryServiceDriver#getCapabilities(java.net.URI)
84
	 */
85
	public DiscoveryServiceCapabilities getCapabilities(URI uri)
86
	throws NotSupportedVersionException {
87
		GazetteerCapabilities capabilities = new GazetteerCapabilities();
88
		return capabilities;
89
	}
90

  
91
	/*
92
	 * (non-Javadoc)
93
	 * @see es.gva.cit.catalog.drivers.IDiscoveryServiceDriver#getServiceName()
94
	 */
95
	public String getServiceName() {
96
		return "Geonames";
97
	}
98

  
99
	/*
100
	 * (non-Javadoc)
101
	 * @see es.gva.cit.catalog.drivers.AbstractDiscoveryServiceDriver#getOneServer()
102
	 */
103
	public ServerData getOneServer() {
104
		return new ServerData("www.geonames.org", "GEONAMES");
105
	}
106
	
107
	
108
}
0 109

  
tags/v_2_0_0_Build_2043/applications/appGazetteer/src/org/gvsig/gazetteer/GazetteerLibrary.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.gazetteer;
29

  
30
import org.gvsig.tools.library.AbstractLibrary;
31
import org.gvsig.tools.library.LibraryException;
32
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
33

  
34
/**
35
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
36
 */
37
public class GazetteerLibrary extends AbstractLibrary  {
38

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

  
44
	@Override
45
	protected void doInitialize() throws LibraryException {
46
	}
47

  
48
	@Override
49
	protected void doPostInitialize() throws LibraryException {
50
		// Validate there is any implementation registered of CatalogManager.
51
		GazetteerManager gazetteerManager = GazetteerLocator.getGazetteerManager();
52
		if (gazetteerManager == null) {
53
			throw new ReferenceNotRegisteredException(
54
					GazetteerLocator.GAZETTEER_MANAGER_NAME, 
55
					GazetteerLocator.getInstance());
56
		}		
57
	}
58
}
0 59

  
tags/v_2_0_0_Build_2043/applications/appGazetteer/src/org/gvsig/gazetteer/wfs/drivers/WFSGPEErrorHandler.java
1
package org.gvsig.gazetteer.wfs.drivers;
2

  
3
import org.gvsig.gpe.lib.impl.parser.GPEErrorHandler;
4

  
5
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
6
 *
7
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
8
 *
9
 * This program is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU General Public License
11
 * as published by the Free Software Foundation; either version 2
12
 * of the License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program; if not, write to the Free Software
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
22
 *
23
 * For more information, contact:
24
 *
25
 *  Generalitat Valenciana
26
 *   Conselleria d'Infraestructures i Transport
27
 *   Av. Blasco Ib??ez, 50
28
 *   46010 VALENCIA
29
 *   SPAIN
30
 *
31
 *      +34 963862235
32
 *   gvsig@gva.es
33
 *      www.gvsig.gva.es
34
 *
35
 *    or
36
 *
37
 *   IVER T.I. S.A
38
 *   Salamanca 50
39
 *   46005 Valencia
40
 *   Spain
41
 *
42
 *   +34 963163400
43
 *   dac@iver.es
44
 */
45
/* CVS MESSAGES:
46
 *
47
 * $Id$
48
 * $Log$
49
 *
50
 */
51
/**
52
 * @author Jorge Piera Llodr? (jorge.piera@iver.es)
53
 */
54
public class WFSGPEErrorHandler extends GPEErrorHandler{
55

  
56
}
0 57

  
tags/v_2_0_0_Build_2043/applications/appGazetteer/src/org/gvsig/gazetteer/wfs/drivers/WFSGPEContentHandler.java
1
package org.gvsig.gazetteer.wfs.drivers;
2

  
3
import java.awt.geom.Point2D;
4
import java.util.ArrayList;
5

  
6
import org.gvsig.gazetteer.querys.Feature;
7
import org.gvsig.gpe.lib.impl.parser.GPEContentHandler;
8

  
9

  
10
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
11
 *
12
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
13
 *
14
 * This program is free software; you can redistribute it and/or
15
 * modify it under the terms of the GNU General Public License
16
 * as published by the Free Software Foundation; either version 2
17
 * of the License, or (at your option) any later version.
18
 *
19
 * This program is distributed in the hope that it will be useful,
20
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 * GNU General Public License for more details.
23
 *
24
 * You should have received a copy of the GNU General Public License
25
 * along with this program; if not, write to the Free Software
26
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
27
 *
28
 * For more information, contact:
29
 *
30
 *  Generalitat Valenciana
31
 *   Conselleria d'Infraestructures i Transport
32
 *   Av. Blasco Ib??ez, 50
33
 *   46010 VALENCIA
34
 *   SPAIN
35
 *
36
 *      +34 963862235
37
 *   gvsig@gva.es
38
 *      www.gvsig.gva.es
39
 *
40
 *    or
41
 *
42
 *   IVER T.I. S.A
43
 *   Salamanca 50
44
 *   46005 Valencia
45
 *   Spain
46
 *
47
 *   +34 963163400
48
 *   dac@iver.es
49
 */
50
/* CVS MESSAGES:
51
 *
52
 * $Id$
53
 * $Log$
54
 *
55
 */
56
/**
57
 * ContentHandler for the WFS
58
 * @author Jorge Piera Llodr? (jorge.piera@iver.es)
59
 */
60
public class WFSGPEContentHandler extends GPEContentHandler{
61
	private ArrayList features  = null;	
62
	private String searchField = null;
63

  
64
	public WFSGPEContentHandler(String searchField) {
65
		super();
66
		this.searchField = searchField;
67
		features = new ArrayList();
68
	}
69

  
70
	/*
71
	 * (non-Javadoc)
72
	 * @see org.gvsig.gpe.GPEContentHandler#addElementToFeature(java.lang.Object, java.lang.Object)
73
	 */
74
	public void addElementToFeature(Object element, Object feature) {
75
		if ((element != null) && (((Element)element).getName().equals(searchField))){
76
			((Feature)feature).setName(String.valueOf(((Element)element).getValue()));
77
			((Feature)feature).setDescription(String.valueOf(((Element)element).getValue()));
78
		}
79
	}
80

  
81
	/*
82
	 * (non-Javadoc)
83
	 * @see org.gvsig.gpe.GPEContentHandler#addGeometryToFeature(java.lang.Object, java.lang.Object)
84
	 */
85
	public void addGeometryToFeature(Object geometry, Object feature) {
86
		((Feature)feature).setCoordinates((Point2D)geometry);
87
	}
88

  
89
	/*
90
	 * (non-Javadoc)
91
	 * @see org.gvsig.gpe.GPEContentHandler#endFeature(java.lang.Object)
92
	 */
93
	public void endFeature(Object feature) {
94
		features.add(feature);
95
	}
96

  
97
	/*
98
	 * (non-Javadoc)
99
	 * @see org.gvsig.gpe.GPEContentHandler#startElement(java.lang.String, java.lang.Object, java.lang.String, java.lang.Object)
100
	 */
101
	public Object startElement(String name, Object value, String xsElementName,
102
			Object parentElement) {
103
		return new Element(name, value);
104
	}
105

  
106
	/*
107
	 * (non-Javadoc)
108
	 * @see org.gvsig.gpe.GPEContentHandler#startFeature(java.lang.String, java.lang.String, java.lang.String, java.lang.Object)
109
	 */
110
	public Object startFeature(String id, String name, String xsElementName,
111
			Object layer) {
112
		return new Feature(id, name, name, null);		
113
	}
114

  
115
	/*
116
	 * (non-Javadoc)
117
	 * @see org.gvsig.gpe.GPEContentHandler#startPoint(java.lang.String, double, double, double, java.lang.String)
118
	 */
119
	public Object startPoint(String id, double x, double y, double z, String srs) {
120
		return new Point2D.Double(x, y);
121
	}	
122

  
123
	/* (non-Javadoc)
124
	 * @see org.gvsig.gpe.GPEContentHandler#startLineString(java.lang.String, double[], double[], double[], java.lang.String)
125
	 */
126
	public Object startLineString(String id, double[] x, double[] y,
127
			double[] z, String srs) {
128
		return getPoint(x, y);
129
	}
130

  
131
	/* (non-Javadoc)
132
	 * @see org.gvsig.gpe.GPEContentHandler#startPolygon(java.lang.String, double[], double[], double[], java.lang.String)
133
	 */
134
	public Object startPolygon(String id, double[] x, double[] y, double[] z,
135
			String srs) {
136
		return getPoint(x, y);
137
	}
138
	
139
	private Point2D getPoint(double[] x, double y[]) {        
140
		double xs = 0.0;
141
		double ys = 0.0;
142
		for (int i=0 ; i<x.length ; i++){
143
			xs = xs + x[i];
144
			ys = ys + y[i];
145
		}
146
		if (x.length == 0){
147
			return new Point2D.Double(xs,ys);
148
		}else{
149
			return new Point2D.Double(xs/x.length,ys/x.length);
150
		}
151
	} 
152
	
153
	/**
154
	 * @author Jorge Piera Llodr? (jorge.piera@iver.es)
155
	 */
156
	private class Element{
157
		private String name = null;
158
		private Object value = null;
159
				
160
		public Element(String name, Object value) {
161
			super();
162
			this.name = name;
163
			this.value = value;
164
		}
165
		
166
		/**
167
		 * @return the name
168
		 */
169
		public String getName() {
170
			return name;
171
		}
172
		
173
		/**
174
		 * @param name the name to set
175
		 */
176
		public void setName(String name) {
177
			this.name = name;
178
		}
179
		
180
		/**
181
		 * @return the value
182
		 */
183
		public Object getValue() {
184
			return value;
185
		}
186
		
187
		/**
188
		 * @param value the value to set
189
		 */
190
		public void setValue(Object value) {
191
			this.value = value;
192
		}		
193
	}
194

  
195
	/**
196
	 * @return the features
197
	 */
198
	public ArrayList getFeatures() {
199
		return features;
200
	}
201

  
202
}
0 203

  
tags/v_2_0_0_Build_2043/applications/appGazetteer/src/org/gvsig/gazetteer/wfs/drivers/WFSServiceDriver.java
1

  
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 *  Generalitat Valenciana
23
 *   Conselleria d'Infraestructures i Transport
24
 *   Av. Blasco Ib??ez, 50
25
 *   46010 VALENCIA
26
 *   SPAIN
27
 *
28
 *      +34 963862235
29
 *   gvsig@gva.es
30
 *      www.gvsig.gva.es
31
 *
32
 *    or
33
 *
34
 *   IVER T.I. S.A
35
 *   Salamanca 50
36
 *   46005 Valencia
37
 *   Spain
38
 *
39
 *   +34 963163400
40
 *   dac@iver.es
41
 */
42
package org.gvsig.gazetteer.wfs.drivers;
43
import java.io.File;
44
import java.net.MalformedURLException;
45
import java.net.URI;
46
import java.net.URISyntaxException;
47
import java.util.ArrayList;
48
import java.util.Hashtable;
49
import java.util.Iterator;
50

  
51
import org.gvsig.catalog.drivers.DiscoveryServiceCapabilities;
52
import org.gvsig.catalog.utils.CatalogConstants;
53
import org.gvsig.gazetteer.drivers.AbstractGazetteerServiceDriver;
54
import org.gvsig.gazetteer.drivers.GazetteerCapabilities;
55
import org.gvsig.gazetteer.querys.Feature;
56
import org.gvsig.gazetteer.querys.FeatureType;
57
import org.gvsig.gazetteer.querys.FeatureTypeAttribute;
58
import org.gvsig.gazetteer.querys.GazetteerQuery;
59
import org.gvsig.gazetteer.utils.GazetteerFormatter;
60
import org.gvsig.gpe.lib.api.GPELocator;
61
import org.gvsig.gpe.lib.api.GPEManager;
62
import org.gvsig.i18n.Messages;
63
import org.gvsig.remoteclient.wfs.WFSClient;
64
import org.gvsig.remoteclient.wfs.WFSFeature;
65
import org.gvsig.remoteclient.wfs.WFSFeatureField;
66
import org.gvsig.remoteclient.wfs.WFSStatus;
67
import org.gvsig.remoteclient.wfs.filters.filterencoding.FilterEncoding;
68
import org.gvsig.utils.swing.jcomboServer.ServerData;
69

  
70

  
71

  
72
/**
73
 * Driver for the WFS protocol
74
 * @author Jorge Piera Llodra (piera_jor@gva.es)
75
 */
76
public class WFSServiceDriver extends AbstractGazetteerServiceDriver {
77
	protected WFSClient client = null;
78
	protected WFSStatus status = null;
79
	private static GPEManager gpeManager = GPELocator.getGPEManager();
80

  
81
	/*
82
	 * (non-Javadoc)
83
	 * @see es.gva.cit.catalogClient.drivers.IDiscoveryServiceDriver#getCapabilities(java.net.URI)
84
	 */
85
	public DiscoveryServiceCapabilities getCapabilities(URI uri) {
86
		GazetteerCapabilities capabilities = new GazetteerCapabilities();
87
		String sURL = null;
88
		try {
89
			sURL = uri.toURL().toString();
90
		} catch (MalformedURLException e) {
91
			setServerAnswerReady("errorServerNotFound");
92
			return null;
93
		}
94
		status = new WFSStatus(sURL);
95
		try {
96
			client = new WFSClient(sURL);
97
			client.getCapabilities(status, true, null);
98
		} catch (Exception e) {
99
			capabilities.setServerMessage(Messages.getText("errorNotParsedReply"));
100
			capabilities.setAvailable(false);
101
			return capabilities;
102
		}
103
		setServerAnswerReady(client.getServiceInformation().name);
104
		Hashtable features = client.getFeatures();
105
		setFeatureTypes(convertFeatureNames(features));
106
		capabilities.setServerMessage(client.getServiceInformation().name +
107
				client.getServiceInformation().abstr);
108
		capabilities.setFeatureTypes(getFeatureTypes());
109
		return capabilities;
110
	}
111

  
112
	/**
113
	 * Convert the features from the remote services format to
114
	 * the gazetteer format
115
	 * @param features
116
	 * @return
117
	 */
118
	private FeatureType[] convertFeatureNames(Hashtable features) {
119
		Iterator it = features.keySet().iterator();
120
		FeatureType[] featureTypes = new FeatureType[features.size()];
121
		int i = 0;
122
		while (it.hasNext()){
123
			String featureName = (String)it.next();
124
			WFSFeature feature = (WFSFeature)features.get(featureName);
125
			featureTypes[i] = new FeatureType(featureName);
126
			featureTypes[i].setTitle(feature.getTitle());
127
			i++;
128
		}
129
		return featureTypes;
130
	}
131

  
132
	/*
133
	 * (non-Javadoc)
134
	 * @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#describeFeatureType(java.net.URI, java.lang.String)
135
	 */
136
	public FeatureTypeAttribute[] describeFeatureType(URI uri, String feature) {
137
		status.setFeatureName(feature);
138
		try{
139
			client.describeFeatureType(status, false, null);
140
		}catch (Exception e){
141
			//Impossible to retrieve the attributes
142
			return new FeatureTypeAttribute[0];
143
		}
144
		WFSFeature wfsFeature = (WFSFeature)client.getFeatures().get(feature);
145
		if ((wfsFeature.getSrs() != null) && (wfsFeature.getSrs().size() > 0)){
146
			this.setProjection((String)wfsFeature.getSrs().get(0));
147
		}
148
		return covertFeatuteAttributes(wfsFeature);
149
	}
150

  
151
	/*
152
	 * (non-Javadoc)
153
	 * @see es.gva.cit.gazetteer.drivers.AsbtractGazetteerServiceDriver#isDescribeFeatureTypeNeeded()
154
	 */
155
	public boolean isDescribeFeatureTypeNeeded(){
156
		return true;
157
	}
158

  
159
	/**
160
	 * Convert the feature attributes
161
	 * @param feature
162
	 * a Remote clients feature
163
	 * @return
164
	 * A list of attributes
165
	 */
166
	private FeatureTypeAttribute[] covertFeatuteAttributes(WFSFeature feature) {
167
		FeatureTypeAttribute[] attributes = new FeatureTypeAttribute[feature.getFieldSize()];
168
		for (int i=0 ; i<feature.getFieldSize(); i++){
169
			WFSFeatureField child = feature.getFieldAt(i);
170
			attributes[i] = new FeatureTypeAttribute(child.getName(),0,false,child.getType());
171
		}
172
		return attributes;
173
	}
174

  
175
	/*
176
	 * (non-Javadoc)
177
	 * @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#getFeature(java.net.URI, es.gva.cit.gazetteer.querys.Query)
178
	 */
179
	public Feature[] getFeature(URI uri, GazetteerQuery query) throws Exception {
180
		//Set the filter
181
		String sQuery = getFilterSQL(query);
182
		if (sQuery != null){
183
			status.setFilterByAttribute(sQuery);
184
		}
185
		status.setFields(new String[0]);
186
		try{
187
			File file = client.getFeature(status, false, null);
188
			return parseOutputFile(file,query.getFieldAttribute());
189
		}catch(Exception e){
190
			e.printStackTrace();
191
			return new Feature[0];
192
		}
193
	}
194

  
195
	/**
196
	 * Parses the GML file
197
	 * @param file
198
	 * @return
199
	 * @throws GPEParserCreationException 
200
	 * @throws URISyntaxException 
201
	 */
202
	protected Feature[] parseOutputFile(File file, String fieldAttribute) throws Exception {
203
		URI uri = file.toURI();	
204
		WFSGPEErrorHandler errorHandler = new WFSGPEErrorHandler();
205
		WFSGPEContentHandler contentHandler = new WFSGPEContentHandler(fieldAttribute);
206
		gpeManager.parse(contentHandler, errorHandler, uri);
207
		ArrayList features = contentHandler.getFeatures();
208
		Feature[] auxFeatures = new Feature[features.size()];
209
		for (int i=0 ; i<features.size() ; i++){
210
			auxFeatures[i] = (Feature)features.get(i);
211
		}
212
		return auxFeatures;
213
	}
214

  
215
	/**
216
	 * Creates a SQL filter to do the search
217
	 * @return
218
	 * A standard SQL query
219
	 */
220
	protected String getFilterSQL(GazetteerQuery query){
221
		StringBuffer buffer = new StringBuffer();
222
		if ((query.getName() == null) || (query.getName().equals(""))){
223
			return null;
224
		}
225
		if (query.getNameFilter().equals(CatalogConstants.EXACT_WORDS)){
226
			buffer.append("(" + query.getFieldAttribute() + " = " + query.getName() + ")");
227
		}else{
228
			String conector = null;
229
			if (query.getNameFilter().equals(CatalogConstants.ALL_WORDS)){
230
				conector = "AND";
231
			}else if (query.getNameFilter().equals(CatalogConstants.ANY_WORD)){
232
				conector = "OR";
233
			}
234
			String[] words = query.getName().split(" ");
235
			for (int i=0 ; i<words.length ; i++){
236
				buffer.append("(" + query.getFieldAttribute() + " = " + words[i] + ")");
237
				if (i  < words.length - 1){
238
					buffer.append(" " + conector + " ");
239
				}
240
			}
241
		}
242
		FilterEncoding fe = GazetteerFormatter.createFilter();
243
		fe.setQueryByAttribute(buffer.toString());
244
		return fe.toString();
245
	}
246

  
247
	/*
248
	 * (non-Javadoc)
249
	 * @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#isProtocolSupported(java.net.URI)
250
	 */
251
	public boolean isProtocolSupported(URI uri) {
252
		return true;
253
	}
254

  
255
	/*
256
	 * (non-Javadoc)
257
	 * @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#getDefaultPort()
258
	 */
259
	public int getDefaultPort() {
260
		return 80;
261
	}
262

  
263
	/*
264
	 * (non-Javadoc)
265
	 * @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#getDefaultSchema()
266
	 */
267
	public String getDefaultSchema() {
268
		return "http";
269
	}
270

  
271
	/*
272
	 * (non-Javadoc)
273
	 * @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#getServiceName()
274
	 */
275
	public String getServiceName() {
276
		return ServerData.SERVER_SUBTYPE_GAZETTEER_WFS;
277
	}
278
}
0 279

  
tags/v_2_0_0_Build_2043/applications/appGazetteer/src/org/gvsig/gazetteer/adl/protocols/ADLThesaurus.java
1

  
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 *  Generalitat Valenciana
23
 *   Conselleria d'Infraestructures i Transport
24
 *   Av. Blasco Ib??ez, 50
25
 *   46010 VALENCIA
26
 *   SPAIN
27
 *
28
 *      +34 963862235
29
 *   gvsig@gva.es
30
 *      www.gvsig.gva.es
31
 *
32
 *    or
33
 *
34
 *   IVER T.I. S.A
35
 *   Salamanca 50
36
 *   46005 Valencia
37
 *   Spain
38
 *
39
 *   +34 963163400
40
 *   dac@iver.es
41
 */
42
package org.gvsig.gazetteer.adl.protocols;
43
import java.net.MalformedURLException;
44
import java.net.URL;
45
import java.util.Collection;
46

  
47
import org.apache.commons.httpclient.NameValuePair;
48
import org.gvsig.catalog.metadataxml.XMLNode;
49
import org.gvsig.catalog.metadataxml.XMLTree;
50
import org.gvsig.catalog.protocols.HTTPGetProtocol;
51
import org.gvsig.gazetteer.querys.FeatureType;
52

  
53

  
54
/**
55
 * This class implemets an ADL thesaurus client
56
 * @author Jorge Piera Llodra (piera_jor@gva.es)
57
 * @see http://middleware.alexandria.ucsb.edu:8080/thes/FTT/index.html
58
 */
59
public class ADLThesaurus {
60
	private URL url;
61
	private FeatureType[] features;
62

  
63
	public  ADLThesaurus(URL url) {        
64
		setUrl(url);
65
		getNarrower();
66
	} 
67

  
68
	/**
69
	 * It implements the getNarrower ADL thesaurus operation
70
	 * 
71
	 */
72
	private void getNarrower() {        
73
		URL urlNarrower;
74
		try {
75
			urlNarrower = new URL ("http", getUrl().getHost(), getUrl().getPort(),getUrl().getFile() + "/get-narrower");
76
		} catch (MalformedURLException e) {
77
			// TODO Auto-generated catch block
78
			e.printStackTrace();
79
			return;
80
		}
81
		Collection nodes = new HTTPGetProtocol().doQuery(urlNarrower, getNarrowerParams(), 0);
82
		parseGetNarrowAnswer((XMLNode)nodes.toArray()[0]);       
83
	} 
84

  
85
	/**
86
	 * It returns the name-value pair for the getNarrower opertaion
87
	 * @return Name-value pair
88
	 */
89
	private NameValuePair[] getNarrowerParams() {        
90
		String message = "";
91
		System.out.println(message);
92
		NameValuePair nvp1 = new NameValuePair("starting-term", "");
93
		NameValuePair nvp2 = new NameValuePair("max-levels", "-1");
94
		NameValuePair nvp3 = new NameValuePair("format", "term");
95

  
96
		return new NameValuePair[] { nvp1, nvp2, nvp3 };
97
	} 
98

  
99
	/**
100
	 * It parses the getNarrow answer into a Feature arrray
101
	 * @param node 
102
	 */
103
	private void parseGetNarrowAnswer(XMLNode node) {        
104
		XMLNode[] rootNodes = XMLTree.searchMultipleNode(node,"hierarchy->node->node");
105
		FeatureType[] features = new FeatureType[rootNodes.length];
106
		for (int i=0 ; i<rootNodes.length ; i++){
107
			FeatureType thesaurus = new FeatureType(XMLTree.searchNodeValue(rootNodes[i],"term"));
108
			thesaurus.setFeatures(parseRecursiveFeatures(rootNodes[i],thesaurus));
109
			thesaurus.setTitle(thesaurus.getName());
110
			features[i] = (thesaurus);
111
		}
112
		setFeatures(features);
113
	} 
114

  
115
	/**
116
	 * It is used to parse a feature using recursivity.
117
	 * @return 
118
	 * @param node Feature tree
119
	 * @param thesaurus Feature to add the child Features
120
	 */
121
	private FeatureType[] parseRecursiveFeatures(XMLNode node, FeatureType thesaurus) {        
122
		XMLNode[] rootNodes = XMLTree.searchMultipleNode(node,"node");
123

  
124
		if ((rootNodes == null) || (rootNodes.length == 0)){
125
			return null;
126
		}
127

  
128
		FeatureType[] features = new FeatureType[rootNodes.length];
129
		for (int i=0 ; i<rootNodes.length ; i++){
130
			FeatureType f = new FeatureType(XMLTree.searchNodeValue(rootNodes[i],"term"));
131
			f.setTitle(f.getName());
132
			f.setFeatures(parseRecursiveFeatures(rootNodes[i],f));
133
			features[i] = f;
134
		}        
135
		return features;
136
	} 
137

  
138
	/**
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff