Revision 257

View differences:

org.gvsig.catalog/tags/org.gvsig.catalog-2.0.39/org.gvsig.catalog.lib/src/test/java/org/gvsig/catalog/catalog/utils/URIUtilsTest.java
1
package org.gvsig.catalog.catalog.utils;
2

  
3
import java.net.URI;
4
import java.net.URISyntaxException;
5

  
6
import junit.framework.TestCase;
7

  
8
import org.gvsig.catalog.utils.URIUtils;
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: URIUtilsTest.java,v 1.1.2.1 2007/07/10 11:18:04 jorpiell Exp $
53
 * $Log: URIUtilsTest.java,v $
54
 * Revision 1.1.2.1  2007/07/10 11:18:04  jorpiell
55
 * Added the registers
56
 *
57
 *
58
 */
59
/**
60
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
61
 */
62
public class URIUtilsTest extends TestCase {
63
	
64
	public void test1() throws URISyntaxException{
65
		URI uri = URIUtils.createUri("http://www.upv.es", "http", 80);	
66
		assertEquals(uri.getHost(), "www.upv.es");
67
		assertEquals(uri.getScheme(), "http");
68
		assertEquals(uri.getPort(), 80);
69
		assertEquals(uri.getPath(), "");
70
	}
71
	
72
	public void test2() throws URISyntaxException{
73
		URI uri = URIUtils.createUri("www.upv.es", "http", 80);	
74
		assertEquals(uri.getHost(), "www.upv.es");
75
		assertEquals(uri.getScheme(), "http");
76
		assertEquals(uri.getPort(), 80);
77
		assertEquals(uri.getPath(), "");
78
	}
79
	
80
	public void test3() throws URISyntaxException{
81
		URI uri = URIUtils.createUri("www.upv.es", "z3950", 2100);	
82
		assertEquals(uri.getHost(), "www.upv.es");
83
		assertEquals(uri.getScheme(), "z3950");
84
		assertEquals(uri.getPort(), 2100);
85
		assertEquals(uri.getPath(), "");
86
	}
87
	
88
	public void test4() throws URISyntaxException{
89
		URI uri = URIUtils.createUri("http://193.144.250.29/webservices/services/IDEC_GeoServeisPort", "http", 80);	
90
		assertEquals(uri.getHost(), "193.144.250.29");
91
		assertEquals(uri.getScheme(), "http");
92
		assertEquals(uri.getPort(), 80);
93
		assertEquals(uri.getPath(), "/webservices/services/IDEC_GeoServeisPort");
94
	}
95
}
0 96

  
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.39/org.gvsig.catalog.lib/src/test/java/org/gvsig/catalog/catalog/drivers/ExampleNewDriver.java
1
package org.gvsig.catalog.catalog.drivers;
2

  
3
import java.net.URI;
4

  
5
import org.gvsig.catalog.CatalogLocator;
6
import org.gvsig.catalog.CatalogManager;
7
import org.gvsig.catalog.drivers.AbstractCatalogServiceDriver;
8
import org.gvsig.catalog.drivers.CatalogCapabilities;
9
import org.gvsig.catalog.drivers.DiscoveryServiceCapabilities;
10
import org.gvsig.catalog.drivers.GetRecordsReply;
11
import org.gvsig.catalog.querys.CatalogQuery;
12
import org.gvsig.catalog.schemas.Record;
13
import org.gvsig.catalog.ui.search.SearchAditionalPropertiesPanel;
14

  
15

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

  
79
	/*
80
	 * (non-Javadoc)
81
	 * @see es.gva.cit.catalog.drivers.ICatalogServiceDriver#getRecords(java.net.URI, es.gva.cit.catalog.querys.CatalogQuery, int)
82
	 */
83
	public GetRecordsReply getRecords(URI uri, CatalogQuery query,
84
			int firstRecord) {
85
		GetRecordsReply reply = new GetRecordsReply(1);
86
		Record record = catalogManager.createRecord(uri, null);
87
		record.setTitle("Record example");
88
		record.setAbstract_("Just for testing");
89
		reply.addRecord(record);
90
		return reply;
91
	}
92

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

  
101
	/*
102
	 * (non-Javadoc)
103
	 * @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#getAditionalSearchPanel()
104
	 */
105
	public SearchAditionalPropertiesPanel getAditionalSearchPanel(){
106
		return new ExampleNewPanel();
107
	}
108

  
109

  
110

  
111

  
112
}
0 113

  
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.39/org.gvsig.catalog.lib/src/test/java/org/gvsig/catalog/catalog/drivers/ExampleNewDriverTest.java
1
package org.gvsig.catalog.catalog.drivers;
2

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

  
6
import org.gvsig.catalog.CatalogLocator;
7
import org.gvsig.catalog.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:43Z 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
//		DefaultCatalogLibrary library = new DefaultCatalogLibrary();
74
//		library.initialize();
75
//		library.postInitialize();
76

  
77
		CatalogLocator.getCatalogManager().register("My catalog service", ExampleNewDriver.class);
78
		//Get the currently installed look and feel
79
		UIManager.getLookAndFeel();
80
		// Install a different look and feel; specifically, the Windows look and feel
81
		try {
82
			UIManager.setLookAndFeel(
83
					"com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
84
		} catch (InstantiationException e) {
85
		} catch (ClassNotFoundException e) {
86
		} catch (UnsupportedLookAndFeelException e) {
87
		} catch (IllegalAccessException e) {
88
		}
89

  
90
		new ServerConnectDialog();
91
	}
92

  
93
}
0 94

  
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.39/org.gvsig.catalog.lib/src/test/java/org/gvsig/catalog/catalog/drivers/ExampleNewPanel.java
1
package org.gvsig.catalog.catalog.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:10Z 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

  
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.39/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/csw/messages/CSWMessages0_9_0.java
1
package org.gvsig.catalog.csw.messages;
2

  
3
import org.gvsig.catalog.csw.drivers.profiles.CSWAbstractProfile;
4
import org.gvsig.catalog.csw.parsers.CSWConstants;
5
import org.gvsig.catalog.languages.FilterEncoding;
6

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

  
64
	/*
65
	 * (non-Javadoc)
66
	 * @see es.gva.cit.catalog.csw.messages.CSWAbstractMessages#getContraintVersion()
67
	 */
68
	protected String getContraintVersion() {
69
		return CSWConstants.CONSTRAINT_VERSION_0_9_0;
70
	}
71
	
72
	/*
73
	 * (non-Javadoc)
74
	 * @see es.gva.cit.catalog.csw.messages.CSWAbstractMessages#createGetRecordsQuery()
75
	 */
76
	protected String createGetRecordsQuery(){
77
		StringBuffer buffer = new StringBuffer();
78
		buffer.append("<" + CSWConstants.CSW_NAMESPACE + ":" + CSWConstants.QUERY + " ");
79
		buffer.append(CSWConstants.TYPENAMES + "=\"" + TYPENAMES + "\"");
80
		buffer.append(">");
81
		buffer.append("<" + CSWConstants.CSW_NAMESPACE + ":" + CSWConstants.ELEMENTSETNAME + " ");
82
		buffer.append(CSWConstants.TYPENAMES + "=\"" + TYPENAMES + "\"");
83
		buffer.append(">");
84
		buffer.append(CSWConstants.FULL);
85
		buffer.append("</" + CSWConstants.CSW_NAMESPACE + ":" + CSWConstants.ELEMENTSETNAME + ">");
86
		buffer.append(createGetRecordsConstraint());
87
		buffer.append("</" + CSWConstants.CSW_NAMESPACE + ":" + CSWConstants.QUERY + ">");
88
		return buffer.toString();
89
	}
90
	
91
	/*
92
	 * (non-Javadoc)
93
	 * @see es.gva.cit.catalog.csw.messages.CSWAbstractMessages#getFilterEncoding()
94
	 */
95
	protected FilterEncoding getFilterEncoding(){
96
		FilterEncoding filter = super.getFilterEncoding();
97
		filter.setEscapeCharLabel(ESCAPECHAR);
98
		return filter;
99
	}
100

  
101
}
0 102

  
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.39/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/csw/messages/CSWMessagesFactory.java
1
package org.gvsig.catalog.csw.messages;
2

  
3
import java.util.HashMap;
4

  
5
import org.gvsig.catalog.csw.drivers.profiles.CSWAbstractProfile;
6
import org.gvsig.catalog.csw.parsers.CSWConstants;
7
import org.gvsig.catalog.exceptions.NotSupportedVersionException;
8
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
9
 *
10
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
11
 *
12
 * This program is free software; you can redistribute it and/or
13
 * modify it under the terms of the GNU General Public License
14
 * as published by the Free Software Foundation; either version 2
15
 * of the License, or (at your option) any later version.
16
 *
17
 * This program is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 * GNU General Public License for more details.
21
 *
22
 * You should have received a copy of the GNU General Public License
23
 * along with this program; if not, write to the Free Software
24
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
25
 *
26
 * For more information, contact:
27
 *
28
 *  Generalitat Valenciana
29
 *   Conselleria d'Infraestructures i Transport
30
 *   Av. Blasco Ib??ez, 50
31
 *   46010 VALENCIA
32
 *   SPAIN
33
 *
34
 *      +34 963862235
35
 *   gvsig@gva.es
36
 *      www.gvsig.gva.es
37
 *
38
 *    or
39
 *
40
 *   IVER T.I. S.A
41
 *   Salamanca 50
42
 *   46005 Valencia
43
 *   Spain
44
 *
45
 *   +34 963163400
46
 *   dac@iver.es
47
 */
48
/* CVS MESSAGES:
49
 *
50
 * $Id$
51
 * $Log$
52
 *
53
 */
54
/**
55
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
56
 */
57
public class CSWMessagesFactory {
58
	private static HashMap messages = null;
59
	
60
	static{
61
		messages = new HashMap();
62
		messages.put(CSWConstants.VERSION_0_9_0, CSWMessages0_9_0.class);
63
		messages.put(CSWConstants.VERSION_2_0_0, CSWMessages2_0_0.class);
64
		messages.put(CSWConstants.VERSION_2_0_1, CSWMessages2_0_1.class);
65
		messages.put(CSWConstants.VERSION_2_0_2, CSWMessages2_0_2.class);
66
	}
67
	
68
	/**
69
	 * Gets a messages class
70
	 * @param version
71
	 * The CSW version
72
	 * @param profile
73
	 * The CSW profile
74
	 * @return
75
	 * A CSWAbstractMessages class
76
	 * @throws NotSupportedVersionException 
77
	 */
78
	public static CSWAbstractMessages getMessages(String version, CSWAbstractProfile profile) throws NotSupportedVersionException{
79
		if ((version != null) && (messages.containsKey(version))){
80
			Class clazz = (Class)messages.get(version);
81
			Class[] parameters = {CSWAbstractProfile.class};
82
			Object[] args = {profile};
83
			try {
84
				return (CSWAbstractMessages)clazz.getConstructor(parameters).newInstance(args);
85
			} catch (Exception e) {
86
				throw new NotSupportedVersionException(e);
87
			} 
88
		}
89
		throw new NotSupportedVersionException();
90
	}
91
}
0 92

  
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.39/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/csw/messages/CSWMessages2_0_0.java
1
package org.gvsig.catalog.csw.messages;
2

  
3
import org.gvsig.catalog.csw.drivers.profiles.CSWAbstractProfile;
4
import org.gvsig.catalog.csw.parsers.CSWConstants;
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$
49
 * $Log$
50
 *
51
 */
52
/**
53
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
54
 */
55
public class CSWMessages2_0_0 extends CSWAbstractMessages {
56

  
57
	public CSWMessages2_0_0(CSWAbstractProfile profile) {
58
		super(profile);		
59
	}
60

  
61
	/*
62
	 * (non-Javadoc)
63
	 * @see es.gva.cit.catalog.csw.messages.CSWAbstractMessages#getContraintVersion()
64
	 */
65
	protected String getContraintVersion() {
66
		return CSWConstants.CONSTRAINT_VERSION_2_0_0;
67
	}
68

  
69
}
0 70

  
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.39/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/csw/messages/CSWMessages2_0_1.java
1
package org.gvsig.catalog.csw.messages;
2

  
3
import org.gvsig.catalog.csw.drivers.profiles.CSWAbstractProfile;
4
import org.gvsig.catalog.csw.parsers.CSWConstants;
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$
49
 * $Log$
50
 *
51
 */
52
/**
53
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
54
 */
55
public class CSWMessages2_0_1 extends CSWAbstractMessages{
56

  
57
	public CSWMessages2_0_1(CSWAbstractProfile profile) {
58
		super(profile);		
59
	}
60

  
61
	/*
62
	 * (non-Javadoc)
63
	 * @see es.gva.cit.catalog.csw.messages.CSWAbstractMessages#getContraintVersion()
64
	 */
65
	protected String getContraintVersion() {
66
		return CSWConstants.CONSTRAINT_VERSION_2_0_1;
67
	}
68

  
69

  
70
}
0 71

  
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.39/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/csw/messages/CSWMessages2_0_2.java
1
package org.gvsig.catalog.csw.messages;
2

  
3
import org.gvsig.catalog.csw.drivers.profiles.CSWAbstractProfile;
4
import org.gvsig.catalog.csw.parsers.CSWConstants;
5
import org.gvsig.catalog.languages.FilterEncoding;
6
import org.gvsig.catalog.utils.CatalogConstants;
7
import org.gvsig.catalog.utils.Strings;
8
import org.gvsig.i18n.Messages;
9
import org.gvsig.utils.swing.jcomboServer.ServerData;
10

  
11

  
12
/**
13
 * @author jvhigon
14
 */
15
public class CSWMessages2_0_2 extends CSWAbstractMessages{
16
	//private CSWCapabilities capabilities = null;
17
	//private static final String TYPENAMES = "Dataset";
18
	
19
	public CSWMessages2_0_2(CSWAbstractProfile profile) {
20
		super(profile);		
21
	}
22

  
23
	/*
24
	 * (non-Javadoc)
25
	 * @see es.gva.cit.catalog.csw.messages.CSWAbstractMessages#getContraintVersion()
26
	 */
27
	protected String getContraintVersion() {
28
		return CSWConstants.CONSTRAINT_VERSION_2_0_2;
29
	}
30
	/**
31
	 * Create the GetRecords header. 
32
	 * @param firstRecord
33
	 * @return
34
	 */
35
	protected String createGetRecordsHeader(int firstRecord){
36
		StringBuffer buffer = new StringBuffer();
37
		buffer.append(CatalogConstants.XML_HEADER_ENCODING); 
38
		buffer.append("<" + CSWConstants.CSW_NAMESPACE + 
39
				":" + CSWConstants.CSW_GET_RECORDS);
40
		buffer.append(" " + CSWConstants.CSW_SERVICE + "=\"" + ServerData.SERVER_SUBTYPE_CATALOG_CSW + "\" ");
41
		buffer.append(CSWConstants.CSW_VERSION + "=\"" + capabilities.getVersion() + "\" ");
42
		buffer.append(CatalogConstants.XML_NS + "=\"" +CSWConstants.CSW_NAMESPACE_URI + "/2.0.2"+ "\" ");
43
		buffer.append(CatalogConstants.XML_NS + ":" + CSWConstants.CSW_NAMESPACE + 
44
				"=\"" + CSWConstants.CSW_NAMESPACE_URI + "/2.0.2"+ "\" ");
45
		buffer.append(CatalogConstants.XML_NS + ":" + CSWConstants.OGC_NAMESPACE + 
46
				"=\"" + CSWConstants.OGC_NAMESPACE_URI + "\" ");
47
		buffer.append(CatalogConstants.XML_NS + ":" + CSWConstants.GML_NAMESPACE + 
48
				"=\"" + CSWConstants.GML_NAMESPACE_URI + "\" ");
49
		buffer.append(CSWConstants.CSW_START_POSITION + "='" +	firstRecord  + "' ");
50
		buffer.append(CSWConstants.CSW_MAX_RECORDS + "='10' ");
51
		if ( capabilities.getOutputFormat() != null){
52
			buffer.append(CSWConstants.CSW_OUTPUTFORMAT + "=\"" + capabilities.getOutputFormat() + "\" ");
53
		}
54
		if (getOutputSchema(capabilities.getOutputSchema()) != null){
55
			buffer.append(CSWConstants.CSW_OUTPUTSCHEMA + "=\"" + getOutputSchema(capabilities.getOutputSchema()) + "\" ");
56
		}else{
57
			buffer.append(CSWConstants.CSW_OUTPUTSCHEMA + "=\"csw:IsoRecord\" ");
58
		}
59
		buffer.append("resultType=\"" +
60
				getResultType(capabilities.getResultType()) + "\">");
61
		buffer.append(createGetRecordsQuery());
62
		buffer.append("</" + CSWConstants.CSW_NAMESPACE + ":" + CSWConstants.OPERATION_GETRECORDS + ">");
63
		return buffer.toString();
64
	}
65
	
66
	
67
	/**
68
	 * @return the Query xml sub tree of the GetRecords
69
	 * operation
70
	 */
71
	protected String createGetRecordsQuery(){
72
		StringBuffer buffer = new StringBuffer();
73
		buffer.append("<" + CSWConstants.CSW_NAMESPACE + ":" + CSWConstants.QUERY + " ");
74
		if (capabilities.getTypeNames() != null && capabilities.getTypeNames().length > 0){
75
			String[] auxTypeNames = new String[capabilities.getTypeNames().length - 1];
76
			for (int i=1; i<capabilities.getTypeNames().length; i++){
77
				auxTypeNames[i-1] = capabilities.getTypeNames()[i];
78
			}
79
			buffer.append(CSWConstants.TYPENAMES + "=\"" +
80
					Strings.getBlankSeparated(auxTypeNames) + "\"");
81
		}
82
		buffer.append(">");
83
		buffer.append(getElementSetNameLabel(query.getService()));
84
		buffer.append(createGetRecordsConstraint());
85
		buffer.append("</" + CSWConstants.CSW_NAMESPACE + ":" + CSWConstants.QUERY + ">");
86
		return buffer.toString();
87
	}
88
	
89
	/**
90
	 * Creates the filter encoding query
91
	 * @param query
92
	 * @return
93
	 */
94
	protected String createFilterEncoding(){		
95
		FilterEncoding filter = getFilterEncoding();
96
		if (query.getTitle() != null){
97
			filter.addClauses(profile.getTitle(),
98
					query.getTitle(),
99
					query.getTitleFilter(),					
100
					FilterEncoding.PROPERTY_IS_LIKE, 
101
					FilterEncoding.TYPE_LITERAL,
102
					FilterEncoding.AND);
103
		}
104
		if (query.isMinimized()){
105
			if (query.getAbstract() != null) {
106
				filter.addClauses(profile.getAbstract(), 
107
						query.getAbstract(),
108
						FilterEncoding.ANY_WORDS,
109
						FilterEncoding.PROPERTY_IS_LIKE,
110
						FilterEncoding.TYPE_LITERAL,
111
						FilterEncoding.OR);
112
			}
113
		}else{
114
			if (query.getAbstract() != null) {
115
				filter.addClauses(profile.getAbstract(), 
116
						query.getAbstract(),
117
						FilterEncoding.ANY_WORDS);
118
			}
119
			if (query.getThemeKey() != null) {
120
				filter.addClauses(profile.getKeywords(), query.getThemeKey(),
121
						FilterEncoding.ANY_WORDS);
122

  
123
			}
124
			if ((query.getTopic() != null) && (!query.getTopic().equals(Messages.getText("cathegoryAny")))) {
125
				filter.addClauses(profile.getTopic(), profile.getTopicValue(query.getTopic()),
126
						FilterEncoding.EXACT_WORDS);
127
			}
128
			if (query.getScale() != null) {
129
				filter.addClauses(profile.getScale(), query.getScale(),
130
						FilterEncoding.EXACT_WORDS);
131
			}
132
			if (query.getProvider() != null) {
133
				filter.addClauses(profile.getProvider(), 
134
						filter.getWildCard() + query.getProvider() + filter.getWildCard(),
135
						FilterEncoding.EXACT_WORDS,
136
						FilterEncoding.PROPERTY_IS_EQUALS_TO,
137
						FilterEncoding.TYPE_LITERAL,
138
						FilterEncoding.AND);						
139
			}
140

  
141
			if (query.getDateFrom() != null) {
142
				filter.addClauses(profile.getDateFrom(), query.getDateFrom(), 
143
						FilterEncoding.EXACT_WORDS,
144
						FilterEncoding.PROPERTY_IS_GREATER_THAN,
145
						FilterEncoding.TYPE_LITERAL,
146
						FilterEncoding.AND);								
147
			}
148
			if (query.getDateTo() != null) {
149
				filter.addClauses(profile.getDateTo(), query.getDateTo(),
150
						FilterEncoding.EXACT_WORDS,
151
						FilterEncoding.PROPERTY_IS_LESS_THAN,
152
						FilterEncoding.TYPE_LITERAL,
153
						FilterEncoding.AND);					
154
			}
155
		}
156
		if ((query.getCoordenates() != null) && (query.isCoordinatesClicked())){
157
			filter.addBoundingBox(query.getCoordenates(), profile.getCoordinates(),
158
					getCoordinatesOption(query.getCoordenatesFilter()));
159

  
160
		}	
161
		return filter.toString();
162
	}
163

  
164
	/**
165
	 * Returns a common reslut type if the getCapabilities doesn't have
166
	 * one. Sometimes it works.
167
	 * 
168
	 * 
169
	 * @return Just one String
170
	 * @param resultType The array of result types parsed.
171
	 */
172
	protected String getResultType(String[] resultType) {        		
173
		return "results";
174
	} 
175
}
0 176

  
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.39/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/csw/messages/CSWAbstractMessages.java
1
package org.gvsig.catalog.csw.messages;
2

  
3
import org.apache.commons.httpclient.NameValuePair;
4
import org.gvsig.catalog.csw.drivers.CSWCapabilities;
5
import org.gvsig.catalog.csw.drivers.profiles.CSWAbstractProfile;
6
import org.gvsig.catalog.csw.parsers.CSWConstants;
7
import org.gvsig.catalog.languages.FilterEncoding;
8
import org.gvsig.catalog.querys.CatalogQuery;
9
import org.gvsig.catalog.querys.Search;
10
import org.gvsig.catalog.utils.CatalogConstants;
11
import org.gvsig.catalog.utils.Strings;
12
import org.gvsig.i18n.Messages;
13
import org.gvsig.utils.swing.jcomboServer.ServerData;
14

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

  
78
	public static NameValuePair[] getHTTPGETCapabilities() {        
79
		NameValuePair nvp1 = new NameValuePair("request", CSWConstants.OPERATION_GETCAPABILITIES);
80
		NameValuePair nvp2 = new NameValuePair("service", ServerData.SERVER_SUBTYPE_CATALOG_CSW);
81
		NameValuePair nvp3 = new NameValuePair("acceptFormats","text/xml");
82
		return new NameValuePair[] { nvp1, nvp2, nvp3 };
83
	} 
84
	
85
	/**
86
	 * The get capabilities operation started with lower case.
87
	 * There are some servers that has this bug 
88
	 * @return
89
	 */
90
	public static NameValuePair[] getHTTPGETCapabilitiesLower() {        
91
		NameValuePair nvp1 = new NameValuePair("request", CSWConstants.OPERATION_GETCAPABILITIESToLOWER);
92
		NameValuePair nvp2 = new NameValuePair("service", ServerData.SERVER_SUBTYPE_CATALOG_CSW);
93
		NameValuePair nvp3 = new NameValuePair("acceptFormats","text/xml");
94
		return new NameValuePair[] { nvp1, nvp2, nvp3 };
95
	}
96

  
97
	public static NameValuePair[] getHTTPGETDescribeRecord(String version) {        
98
		NameValuePair nvp1 = new NameValuePair("request", CSWConstants.OPERATION_DESCRIBERECORD);
99
		NameValuePair nvp2 = new NameValuePair("service", ServerData.SERVER_SUBTYPE_CATALOG_CSW);
100
		NameValuePair nvp3 = new NameValuePair("version", version);
101
		return new NameValuePair[] { nvp1, nvp2, nvp3 };
102
	} 	
103

  
104
	/**
105
	 * Creates and returns the GetRecords request
106
	 * @param query
107
	 * @param firstRecord
108
	 * @return
109
	 */	 
110
	public String getHTTPPostGetRecordsMessage(CSWCapabilities capabilities, CatalogQuery query, ServerData serverData, int firstRecord) {
111
		this.capabilities = capabilities;
112
		this.query = query;		
113
		profile.setServerData(serverData);
114
		StringBuffer buffer = new StringBuffer();
115
		buffer.append(createGetRecordsHeader(firstRecord));
116
		return buffer.toString();
117
	}
118

  
119
	/**
120
	 * Create the GetRecords header. 
121
	 * @param firstRecord
122
	 * @return
123
	 */
124
	protected String createGetRecordsHeader(int firstRecord){
125
		StringBuffer buffer = new StringBuffer();
126
		buffer.append(CatalogConstants.XML_HEADER_ENCODING); 
127
		buffer.append("<" + CSWConstants.CSW_NAMESPACE + 
128
				":" + CSWConstants.CSW_GET_RECORDS);
129
		buffer.append(" " + CSWConstants.CSW_SERVICE + "=\"" + ServerData.SERVER_SUBTYPE_CATALOG_CSW + "\" ");
130
		buffer.append(CSWConstants.CSW_VERSION + "=\"" + capabilities.getVersion() + "\" ");
131
		buffer.append(CatalogConstants.XML_NS + "=\"" +CSWConstants.CSW_NAMESPACE_URI + "\" ");
132
		buffer.append(CatalogConstants.XML_NS + ":" + CSWConstants.CSW_NAMESPACE + 
133
				"=\"" + CSWConstants.CSW_NAMESPACE_URI + "\" ");
134
		buffer.append(CatalogConstants.XML_NS + ":" + CSWConstants.OGC_NAMESPACE + 
135
				"=\"" + CSWConstants.OGC_NAMESPACE_URI + "\" ");
136
		buffer.append(CatalogConstants.XML_NS + ":" + CSWConstants.GML_NAMESPACE + 
137
				"=\"" + CSWConstants.GML_NAMESPACE_URI + "\" ");
138
		buffer.append(CSWConstants.CSW_START_POSITION + "='" +	firstRecord  + "' ");
139
		buffer.append(CSWConstants.CSW_MAX_RECORDS + "='10' ");
140
		if (capabilities.getOutputFormat() != null){
141
			buffer.append(CSWConstants.CSW_OUTPUTFORMAT + "=\"" + capabilities.getOutputFormat() + "\" ");
142
		}
143
		if (getOutputSchema(capabilities.getOutputSchema()) != null){
144
			buffer.append(CSWConstants.CSW_OUTPUTSCHEMA + "=\"" + getOutputSchema(capabilities.getOutputSchema()) + "\" ");
145
		}else{
146
			buffer.append(CSWConstants.CSW_OUTPUTSCHEMA + "=\"csw:IsoRecord\" ");
147
		}
148
		buffer.append("resultType=\"" +
149
				getResultType(capabilities.getResultType()) + "\">");
150
		buffer.append(createGetRecordsQuery());
151
		buffer.append("</" + CSWConstants.CSW_NAMESPACE + ":" + CSWConstants.OPERATION_GETRECORDS + ">");
152
		return buffer.toString();
153
	}
154

  
155
	/**
156
	 * Returns a common reslut type if the getCapabilities doesn't have
157
	 * one. Sometimes it works.
158
	 * 
159
	 * 
160
	 * @return Just one String
161
	 * @param resultType The array of result types parsed.
162
	 */
163
	protected String getResultType(String[] resultType) {        
164
		if (resultType == null)
165
			return "results";
166

  
167
		for (int i=0 ; i<resultType.length ; i++){
168

  
169
		}
170
		return resultType[0];
171
	} 
172

  
173
	/**
174
	 * Returns the OutputSchema. If the ISO19115 is supported,
175
	 * we prefer this
176
	 * @param OutputFormat The array of outputFormats parsed.
177
	 * @return Just one String
178
	 * @param outputSchemas 
179
	 */
180
	protected String getOutputSchema(String[] outputSchemas) {        
181
		if (outputSchemas == null){
182
			return null;
183
		}		    
184
		return outputSchemas[0];
185
	} 
186

  
187
	/**
188
	 * @return the Query xml sub tree of the GetRecords
189
	 * operation
190
	 */
191
	protected String createGetRecordsQuery(){
192
		StringBuffer buffer = new StringBuffer();
193
		buffer.append("<" + CSWConstants.CSW_NAMESPACE + ":" + CSWConstants.QUERY + " ");
194
		if (capabilities.getTypeNames() != null){
195
			buffer.append(CSWConstants.TYPENAMES + "=\"" +
196
					Strings.getBlankSeparated(capabilities.getTypeNames()) + "\"");
197
		}
198
		buffer.append(">");
199
		buffer.append(getElementSetNameLabel(query.getService()));
200
		buffer.append(createGetRecordsConstraint());
201
		buffer.append("</" + CSWConstants.CSW_NAMESPACE + ":" + CSWConstants.QUERY + ">");
202
		return buffer.toString();
203
	}
204

  
205
	/**
206
	 * Create and return the ElementName and the ElementSetName tags
207
	 * @param searchType
208
	 * @return
209
	 */
210
	protected String getElementSetNameLabel(Search searchType) {        
211
		StringBuffer buffer = new StringBuffer();
212
		buffer.append("<" + CSWConstants.CSW_NAMESPACE + ":" + CSWConstants.ELEMENTSETNAME + ">");
213
		buffer.append(CSWConstants.FULL);
214
		buffer.append("</" + CSWConstants.CSW_NAMESPACE + ":" + CSWConstants.ELEMENTSETNAME + ">");
215
		if (profile.getElementName() != null){
216
			buffer.append("<" + CSWConstants.CSW_NAMESPACE + ":" + CSWConstants.ELEMENTNAME + ">");
217
			buffer.append(profile.getElementName());
218
			buffer.append("</" + CSWConstants.CSW_NAMESPACE + ":" + CSWConstants.ELEMENTNAME + ">");
219
		}
220
		return buffer.toString();        
221
	} 	
222

  
223
	/**
224
	 * @return the Constarint xml sub tree of the GetRecords
225
	 * operation
226
	 */
227
	protected String createGetRecordsConstraint(){
228
		StringBuffer buffer = new StringBuffer();
229
		buffer.append("<" + CSWConstants.CSW_NAMESPACE + ":" + CSWConstants.CONSTRAINT);
230
		buffer.append(" " + CSWConstants.VERSION + "='" + getContraintVersion() + "'>");
231
		buffer.append(createFilterEncoding());
232
		buffer.append("</" + CSWConstants.CSW_NAMESPACE + ":" + CSWConstants.CONSTRAINT + ">");
233
		return buffer.toString();
234
	}	
235

  
236
	/**
237
	 * @return the constraint version
238
	 */
239
	protected abstract String getContraintVersion();
240

  
241
	/**
242
	 * Creates the filter encoding. It can be
243
	 * overridden by the children classes. 
244
	 * @return
245
	 * The filter encoding to use
246
	 */
247
	protected FilterEncoding getFilterEncoding(){
248
		return new FilterEncoding();
249
	}
250
	
251
	/**
252
	 * Creates the filter encoding query
253
	 * @param query
254
	 * @return
255
	 */
256
	protected String createFilterEncoding(){		
257
		FilterEncoding filter = getFilterEncoding();
258
		if (query.getTitle() != null){
259
			filter.addClauses(profile.getTitle(),
260
					query.getTitle(),
261
					query.getTitleFilter(),					
262
					FilterEncoding.PROPERTY_IS_LIKE, 
263
					FilterEncoding.TYPE_LITERAL,
264
					FilterEncoding.AND);
265
		}
266
		if (query.isMinimized()){
267
			if (query.getAbstract() != null) {
268
				filter.addClauses(profile.getAbstract(), 
269
						query.getAbstract(),
270
						FilterEncoding.ANY_WORDS,
271
						FilterEncoding.PROPERTY_IS_LIKE,
272
						FilterEncoding.TYPE_LITERAL,
273
						FilterEncoding.OR);
274
			}
275
		}else{
276
			if (query.getAbstract() != null) {
277
				filter.addClauses(profile.getAbstract(), 
278
						query.getAbstract(),
279
						FilterEncoding.ANY_WORDS);
280
			}
281
			if (query.getThemeKey() != null) {
282
				filter.addClauses(profile.getKeywords(), query.getThemeKey(),
283
						FilterEncoding.ANY_WORDS);
284

  
285
			}
286
			if ((query.getTopic() != null) && (!query.getTopic().equals(Messages.getText("cathegoryAny")))) {
287
				filter.addClauses(profile.getTopic(), profile.getTopicValue(query.getTopic()),
288
						FilterEncoding.EXACT_WORDS);
289
			}
290
			if (query.getScale() != null) {
291
				filter.addClauses(profile.getScale(), query.getScale(),
292
						FilterEncoding.EXACT_WORDS);
293
			}
294
			if (query.getProvider() != null) {
295
				filter.addClauses(profile.getProvider(), 
296
						filter.getWildCard() + query.getProvider() + filter.getWildCard(),
297
						FilterEncoding.EXACT_WORDS,
298
						FilterEncoding.PROPERTY_IS_EQUALS_TO,
299
						FilterEncoding.TYPE_LITERAL,
300
						FilterEncoding.AND);						
301
			}
302

  
303
			if (query.getDateFrom() != null) {
304
				filter.addClauses(profile.getDateFrom(), query.getDateFrom(), 
305
						FilterEncoding.EXACT_WORDS,
306
						FilterEncoding.PROPERTY_IS_GREATER_THAN,
307
						FilterEncoding.TYPE_LITERAL,
308
						FilterEncoding.AND);								
309
			}
310
			if (query.getDateTo() != null) {
311
				filter.addClauses(profile.getDateTo(), query.getDateTo(),
312
						FilterEncoding.EXACT_WORDS,
313
						FilterEncoding.PROPERTY_IS_LESS_THAN,
314
						FilterEncoding.TYPE_LITERAL,
315
						FilterEncoding.AND);					
316
			}
317
		}
318
		if ((query.getCoordenates() != null) && (query.isCoordinatesClicked())){
319
			filter.addBoundingBox(query.getCoordenates(), profile.getCoordinates(),
320
					getCoordinatesOption(query.getCoordenatesFilter()));
321

  
322
		}	
323
		return filter.toString();
324
	}
325

  
326
	/**
327
	 * This function returns true only when the user has choosen the
328
	 * "Fully Outside Of" of the coordinates option.
329
	 * @param coordinatesOption 
330
	 * @return
331
	 */
332
	protected boolean getCoordinatesOption(String coordinatesOption) {        
333
		if ((coordinatesOption.equals(Messages.getText("coordinatesEqual"))) ||
334
				(coordinatesOption.equals(Messages.getText("coordinatesContains"))) ||
335
				(coordinatesOption.equals(Messages.getText("coordinatesEnclose"))))
336
			return false;
337

  
338
		return true; 
339
	} 
340
}
0 341

  
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.39/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/csw/drivers/CSWebRIMCatalogServiceDriver.java
1
package org.gvsig.catalog.csw.drivers;
2

  
3
import java.net.URL;
4

  
5
import org.apache.commons.httpclient.NameValuePair;
6
import org.gvsig.catalog.csw.drivers.profiles.CSWebRIMProfile;
7
import org.gvsig.catalog.csw.parsers.CSWConstants;
8
import org.gvsig.catalog.drivers.profiles.IProfile;
9
import org.gvsig.catalog.metadataxml.XMLNode;
10
import org.gvsig.catalog.protocols.HTTPGetProtocol;
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$
55
 * $Log$
56
 *
57
 */
58
/**
59
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
60
 */
61
public class CSWebRIMCatalogServiceDriver extends CSWCatalogServiceDriver{
62
	public static String SERVICE_NAME = "CSW/ebRIM";
63
	
64
	/*
65
	 * (non-Javadoc)
66
	 * @see es.gva.cit.catalogClient.drivers.ICatalogServiceDriver#getServiceName()
67
	 */
68
	public String getServiceName() {
69
		return SERVICE_NAME;
70
	}
71

  
72
	/*
73
	 * (non-Javadoc)
74
	 * @see es.gva.cit.catalog.drivers.AbstractCatalogServiceDriver#getProfile()
75
	 */
76
	public IProfile getProfile() {
77
		return new CSWebRIMProfile();
78
	}
79

  
80
	/*
81
	 * (non-Javadoc)
82
	 * @see es.gva.cit.catalog.csw.drivers.CSWCatalogServiceDriver#retrieveResults(es.gva.cit.catalog.metadataxml.XMLNode)
83
	 */
84
	protected XMLNode[] retrieveResults(XMLNode root) {
85
		XMLNode resultNode = root.searchNode(CSWConstants.SEARCH_RESULTS);
86
		if (resultNode == null){
87
			return new XMLNode[0];
88
		}
89
		XMLNode[] results = new XMLNode[resultNode.getNumSubNodes()];
90
		for (int i=0 ; i<resultNode.getNumSubNodes() ; i++){
91
			results[i] = resultNode.getSubNode(i);
92
		}
93
		return getEbRIMNodes(results);
94
	}
95
	
96
	/**
97
	 * This function retrieve the nodes for one ebRIM answer
98
	 * @return Medatada Nodes.
99
	 * @param nodes Server URL
100
	 * @param url 
101
	 */
102
	private XMLNode[] getEbRIMNodes(XMLNode[] nodes) {        
103
		//if the getExtrinsincContentOperation is not supported
104
		if (capabilities.getOperations().getGetExtrinsicContent().size() == 0){
105
			return nodes;			
106
		}
107
		XMLNode[] auxNodes = new XMLNode[nodes.length];
108
		for (int i = 0; i < nodes.length; i++) {
109
			String id = nodes[i].searchAtribute(CSWConstants.ID);
110
			URL url = (URL)capabilities.getOperations().getGetExtrinsicContent().get(CSWConstants.GET);
111
			auxNodes[i] = (XMLNode)new HTTPGetProtocol().doQuery(url,
112
				getEbRIMRequestParameters(id), 0).toArray()[0];						
113
		}
114
		return auxNodes;
115
	} 
116
	
117
	/**
118
	 * It Returns the parameters needed by getExtrinsicContent
119
	 * @return 
120
	 * @param id Record id
121
	 */
122
	private NameValuePair[] getEbRIMRequestParameters(String id) {        
123
		NameValuePair nvp1 = new NameValuePair(CSWConstants.REQUEST, CSWConstants.EXTRISIC_CONTENT);
124
		NameValuePair nvp2 = new NameValuePair(CSWConstants.ID, id);
125
		return new NameValuePair[] { nvp1, nvp2 };
126
	} 
127
}
0 128

  
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.39/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/csw/drivers/profiles/CSWISO19115Profile.java
1
package org.gvsig.catalog.csw.drivers.profiles;
2

  
3

  
4
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
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 2
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.
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff