Revision 879

View differences:

org.gvsig.catalog/tags/org.gvsig.catalog-2.0.162/org.gvsig.catalog.lib/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.catalog.CatalogLibrary
2
org.gvsig.catalog.impl.DefaultCatalogLibrary
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.162/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/z3950/filters/Z3950Filter.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.catalog.z3950.filters;
43
import org.gvsig.catalog.filters.AbstractFilter;
44
import org.gvsig.catalog.languages.BasicEncodingRules;
45
import org.gvsig.i18n.Messages;
46

  
47
/**
48
 * 
49
 * 
50
 * 
51
 * @author Jorge Piera Llodra (piera_jor@gva.es)
52
 */
53
public class Z3950Filter extends AbstractFilter {
54
	private String database = null; 
55
	
56
    public  Z3950Filter(String database) {        
57
        super();
58
        this.database = database;
59
    } 
60

  
61

  
62
    /*
63
     * (non-Javadoc)
64
     * @see es.gva.cit.catalog.filters.IFilter#getQuery(es.gva.cit.catalog.querys.CatalogQuery)
65
     */
66
    public String getQuery(org.gvsig.catalog.querys.CatalogQuery query) {        
67
        // Create a RemoteBooleanQuery
68
        BasicEncodingRules filter = new BasicEncodingRules();
69
       
70
        //Title (title, 4), Word List (6)
71
        if (query.getTitle() != null) {
72
            filter.addClauses("4", "6", "3", query.getTitle(),
73
                    query.getTitleFilter(),"and");
74
        }
75
        
76
             
77
        if (query.isMinimized()){
78
            if (query.getAbstract() != null) {
79
                filter.addClauses("62", "6", "3", query.getAbstract(), "E", "or");
80
            }
81
        }else{
82
            if (query.getAbstract() != null) {
83
                filter.addClauses("62", "6", "3", query.getAbstract(), "E", "and");
84
            }         
85
                //  Theme Keyword (themekey, 2002), Word List (6)
86
            if (query.getThemeKey() != null) {
87
                filter.addClauses("2002", "6", "3", query.getThemeKey(), "Y","and");
88
            }
89
            //  Source Scale Denominator (srcscale, 1024), Numeric String (109)
90
            if (query.getScale() != null) {
91
                if (query.getMinScale() != null){
92
                    filter.addClauses("1024", "109", "4", query.getMinScale(),"E","and"); 
93
                }
94
                if (query.getMaxScale() != null){
95
                    filter.addClauses("1024", "109", "2", query.getMaxScale(),"E","and"); 
96
                }           
97
            }
98
        
99
            if (query.getProvider() != null) {
100
                filter.addClauses("1005", "6", "3", query.getProvider(), "E","and");
101
            }
102
        //     Beginning Date  (begdate, 1012), Date(210)
103
            if (query.getDateFrom() != null) {
104
                filter.addClauses("1012", "210", "18", query.getDateFrom(), "E","and");
105
            }
106
            //  Ending Date (date, 1012 ), Date(210)		
107
            if (query.getDateTo() != null) {
108
                filter.addClauses("1012", "210", "14", query.getDateTo(), "E","and");
109
            }
110
        }
111
        
112
        if ((query.getCoordenates() != null) && (query.isCoordinatesClicked())){
113
                String sNorth = query.getCoordenates().getUly();
114
                String sWest = query.getCoordenates().getUlx();
115
                String sSouth = query.getCoordenates().getBry();
116
                String sEast = query.getCoordenates().getBrx();
117
                String sBounding = sNorth + " " + sWest + " " + sSouth + " " +
118
                    sEast;
119
                String sRelation = getRelation(query.getCoordenatesFilter());
120
            //  Bounding Coordinates (bounding, 2060), Coordinate String (201)
121
            filter.addClauses("2060", "201", sRelation, sBounding, "E","and");
122
        }
123
        //return query
124
        return filter.toString(database);
125
    } 
126

  
127
/**
128
 * Return a value for the option of the 'Coordenates Filter'
129
 * 
130
 * @param relation String in the combo. Possible values:
131
 * encloses
132
 * overlaps
133
 * fullyOutsideOf
134
 * equals
135
 * 
136
 * @return String
137
 * Possible values:
138
 * 9 -> encloses
139
 * 7 -> overlaps
140
 * 10 -> fullyOutsideOf
141
 * 3 -> equals
142
 * @param translator 
143
 * @param relacion 
144
 */
145
    private String getRelation(String relacion) {        
146
        if (relacion.equals(Messages.getText("coordinatesEqual"))) {
147
            return "3";
148
        }
149
        if (relacion.equals(Messages.getText("coordinatesContains"))) {
150
            return "7";
151
        }
152
        if (relacion.equals(Messages.getText("coordinatesEnclose"))) {
153
            return "9";            
154
        } else {
155
            return "10";
156
        }
157
    } 
158
 }
0 159

  
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.162/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/z3950/drivers/Z3950CatalogServiceDriver.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.catalog.z3950.drivers;
43
import java.io.ByteArrayInputStream;
44
import java.net.URI;
45
import java.util.ArrayList;
46
import java.util.Collection;
47

  
48
import org.gvsig.catalog.drivers.AbstractCatalogServiceDriver;
49
import org.gvsig.catalog.drivers.CatalogCapabilities;
50
import org.gvsig.catalog.drivers.DiscoveryServiceCapabilities;
51
import org.gvsig.catalog.drivers.GetRecordsReply;
52
import org.gvsig.catalog.metadataxml.XMLNode;
53
import org.gvsig.catalog.metadataxml.XMLTree;
54
import org.gvsig.catalog.protocols.Z3950Protocol;
55
import org.gvsig.catalog.querys.CatalogQuery;
56
import org.gvsig.utils.swing.jcomboServer.ServerData;
57

  
58
/**
59
 * This class implements the Z39.50 protocol.
60
 * 
61
 * 
62
 * @author Jorge Piera Llodra (piera_jor@gva.es)
63
 * @see http://www.loc.gov/z3950/agency/
64
 */
65
public class Z3950CatalogServiceDriver extends AbstractCatalogServiceDriver {
66

  
67
	/*
68
	 * (non-Javadoc)
69
	 * @see es.gva.cit.catalogClient.drivers.IDiscoveryServiceDriver#getCapabilities(java.net.URI)
70
	 */
71
	public DiscoveryServiceCapabilities getCapabilities(URI uri) {        
72
		Collection nodes = new ArrayList();;
73
		Z3950Messages messages = new Z3950Messages(this);
74
		String message = messages.getCapabilities(new Z3950Protocol().openConnection(
75
				uri));
76
		ByteArrayInputStream buffer = new ByteArrayInputStream(message.getBytes());
77
		nodes.add(XMLTree.xmlToTree(buffer));
78

  
79
		setServerAnswerReady(XMLTree.searchNodeValue((XMLNode)nodes.toArray()[0], "Servidor"));
80
		CatalogCapabilities capabilities = new CatalogCapabilities();
81
		capabilities.setVersion("3.0");
82
		return capabilities;
83
	} 
84

  
85
	/*
86
	 * (non-Javadoc)
87
	 * @see es.gva.cit.catalogClient.drivers.ICatalogServiceDriver#getRecords(java.net.URI, es.gva.cit.catalogClient.querys.Query, int)
88
	 */
89
	public GetRecordsReply getRecords(URI uri, CatalogQuery query, int firstRecord) {        
90
		setQuery(query);
91
		Z3950Messages messages = new Z3950Messages(this);
92
		String message = messages.getRecords(getQuery(),Z3950Protocol.getDatabase(uri));
93
		System.out.println(message);
94
		new Z3950Protocol().doQuery(getRecordsReply(), uri, message, firstRecord);		
95
		return getRecordsReply();
96
	} 
97

  
98
	/*
99
	 * (non-Javadoc)
100
	 * @see es.gva.cit.catalogClient.drivers.ICatalogServiceDriver#isProtocolSupported(java.net.URI)
101
	 */
102
	public boolean isProtocolSupported(URI uri) {        
103
		return new Z3950Protocol().isProtocolSupported(uri);
104
	} 
105

  
106
	/**
107
	 * @return 
108
	 */
109
	public String getQueryProfile() {        
110
		return "Z3950";
111
	}
112

  
113
	/*
114
	 * (non-Javadoc)
115
	 * @see es.gva.cit.catalogClient.drivers.ICatalogServiceDriver#getServiceName()
116
	 */
117
	public String getServiceName() {
118
		return ServerData.SERVER_SUBTYPE_CATALOG_Z3950;
119
	}
120

  
121
	/*
122
	 * (non-Javadoc)
123
	 * @see es.gva.cit.catalogClient.drivers.ICatalogServiceDriver#getDefaultPort()
124
	 */
125
	public int getDefaultPort() {
126
		return 2100;
127
	}
128

  
129
	/*
130
	 * (non-Javadoc)
131
	 * @see es.gva.cit.catalogClient.drivers.ICatalogServiceDriver#getDefaultSchema()
132
	 */
133
	public String getDefaultSchema() {
134
		return "z3950";
135
	} 
136
}
0 137

  
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.162/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/z3950/drivers/Z3950Messages.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
/*
43
* CVS MESSAGES:
44
*
45
* $Id: Z3950Messages.java 585 2007-09-03 10:21:55 +0000 (Mon, 03 Sep 2007) jpiera $
46
* $Log$
47
* Revision 1.4.10.2  2006/11/15 00:08:08  jjdelcerro
48
* *** empty log message ***
49
*
50
* Revision 1.6  2006/10/02 08:29:07  jorpiell
51
* Modificados los cambios del Branch 10 al head
52
*
53
* Revision 1.4.10.1  2006/09/20 12:01:18  jorpiell
54
* Se ha cambiado la versi?n de la jzkit, se ha incorporado la funcionalidad de cargar arcims
55
*
56
* Revision 1.5  2006/09/20 11:22:43  jorpiell
57
* Se ha cambiado la versi?n de la librer?a jzkit de la 1 a la 2.0
58
*
59
* Revision 1.4  2006/01/12 13:52:24  jorpiell
60
* Se ha a?adido un boton close en las dos pantallas de connect. Adem?s se ha cambiado el comportamiento de las ventanas para adaptarlo a la nueva forma de buscar multihilo
61
*
62
* Revision 1.3  2006/01/10 17:23:23  jorpiell
63
* Se ha hecho una peque?a modificaci?n en el gazeteer: ahora funcionan las b?squedas restringiendo el ?rea en el WFSG. Hay muchos cambios porque se ha hecho un CONTROL+SHIFT+O sobre todo el proyecto para eliminar los imports y para ordenarlos
64
*
65
* Revision 1.2  2006/01/10 09:32:49  jorpiell
66
* Se ha echo un commit de las versiones modificadas del catalogo y del gazetteer usando el Poseidon. Se han renombrado algunas clases por considerar que tenian un nombre confuso y se han cambiado algunas relaciones entre clases (con la intenci?n de separar GUI de la parte de control). Han habido clases que no han sido tocadas, pero como han sido formateadas usando el Poseidon TODAS las CLASES del proyecto han cambiado de versi?n.
67
*
68
* Revision 1.1  2005/12/22 08:31:43  jorpiell
69
* Aqui tambien se han producido muchos cambis, porque hemos acabado de cambiar la estructura del cat?logo: Se han creado todas las clases "XXXMessages", que sacan toda la parte de los mensajes de los drivers. Ademas se ha incluido en "CatalogClient" la operaci?n "getCapabilities", que libera a la interfaz de algunas operaciones que hac?a anteriormente.
70
*
71
*
72
*/
73
package org.gvsig.catalog.z3950.drivers;
74
import org.gvsig.catalog.querys.CatalogQuery;
75
import org.gvsig.catalog.z3950.filters.Z3950Filter;
76

  
77
/**
78
 * This class is used to create all the Z3950 protocol
79
 * messages
80
 * 
81
 * 
82
 * @author Jorge Piera Llodra (piera_jor@gva.es)
83
 */
84
public class Z3950Messages {
85
/**
86
 * 
87
 * 
88
 */
89
    private Z3950CatalogServiceDriver driver = null;
90

  
91
/**
92
 * 
93
 * 
94
 * 
95
 * @param driver 
96
 */
97
    public  Z3950Messages(Z3950CatalogServiceDriver driver) {        
98
        this.driver = driver;
99
    } 
100

  
101
/**
102
 * 
103
 * 
104
 * 
105
 * @return 
106
 * @param message 
107
 */
108
    public String getCapabilities(String message) {        
109
        return "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" + "<Z3950> " +
110
        "<Servidor>" + message + "</Servidor>" + "</Z3950>";
111
       
112
    } 
113

  
114
/**
115
 * 
116
 * 
117
 * 
118
 * @return 
119
 * @param query 
120
 */
121
    public String getRecords(CatalogQuery query,String database) {        
122
        return new Z3950Filter(database).getQuery(query);
123
    } 
124
 }
0 125

  
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.162/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.162/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.162/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.162/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.162/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.162/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.162/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/csw/drivers/CSWISO19115CatalogServiceDriver.java
1
package org.gvsig.catalog.csw.drivers;
2

  
3
import org.gvsig.catalog.csw.drivers.profiles.CSWISO19115Profile;
4
import org.gvsig.catalog.csw.parsers.CSWConstants;
5
import org.gvsig.catalog.drivers.profiles.IProfile;
6
import org.gvsig.catalog.metadataxml.XMLNode;
7
import org.gvsig.catalog.metadataxml.XMLTree;
8

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

  
61
	/*
62
	 * (non-Javadoc)
63
	 * @see es.gva.cit.catalogClient.drivers.ICatalogServiceDriver#getServiceName()
64
	 */
65
	public String getServiceName() {
66
		return SERVICE_NAME;
67
	}	
68
	
69
	/*
70
	 * (non-Javadoc)
71
	 * @see es.gva.cit.catalog.csw.drivers.CSWCatalogServiceDriver#retrieveResults(es.gva.cit.catalog.metadataxml.XMLNode)
72
	 */
73
	protected XMLNode[] retrieveResults(XMLNode root){
74
		XMLNode resultNode = XMLTree.searchNode(root, CSWConstants.SEARCH_RESULTS);
75
		if (resultNode == null){
76
			return new XMLNode[0];
77
		}
78
		XMLNode[] results = new XMLNode[resultNode.getNumSubNodes()];
79
		for (int i=0 ; i<resultNode.getNumSubNodes() ; i++){
80
			results[i] = resultNode.getSubNode(i);
81
		}
82
		return results;
83
	}
84
	
85
	/*
86
	 * (non-Javadoc)
87
	 * @see es.gva.cit.catalog.drivers.AbstractCatalogServiceDriver#getProfile()
88
	 */
89
	public IProfile getProfile() {
90
		return new CSWISO19115Profile();
91
	}
92

  
93
}
0 94

  
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.162/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,
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff