Revision 3510
trunk/applications/appCatalogYNomenclatorClient/src/es/gva/cit/catalogClient/filters/AbstractFilter.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
/* |
|
42 |
* CVS MESSAGES: |
|
43 |
* |
|
44 |
* $Id$ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.1 2005-12-22 08:31:43 jorpiell |
|
47 |
* 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. |
|
48 |
* |
|
49 |
* |
|
50 |
*/ |
|
51 |
|
|
52 |
|
|
53 |
package es.gva.cit.catalogClient.filters; |
|
54 |
|
|
55 |
import es.gva.cit.catalogClient.querys.Query; |
|
56 |
|
|
57 |
|
|
58 |
public abstract class AbstractFilter implements IFilter{ |
|
59 |
protected Query query = null; |
|
60 |
/** |
|
61 |
* This class containt all the common methods for the |
|
62 |
* filters.It have to be implemented by all of them |
|
63 |
* @param args |
|
64 |
*/ |
|
65 |
public AbstractFilter(Query query) { |
|
66 |
this.query = query; |
|
67 |
} |
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
} |
|
0 | 72 |
trunk/applications/appCatalogYNomenclatorClient/src/es/gva/cit/catalogClient/srw/filters/SRWFilter.java | ||
---|---|---|
40 | 40 |
*/ |
41 | 41 |
package es.gva.cit.catalogClient.srw.filters; |
42 | 42 |
|
43 |
import es.gva.cit.catalogClient.filters.IFilter;
|
|
43 |
import es.gva.cit.catalogClient.filters.AbstractFilter;
|
|
44 | 44 |
import es.gva.cit.catalogClient.languages.CommonQueryLanguage; |
45 | 45 |
import es.gva.cit.catalogClient.querys.Query; |
46 | 46 |
|
... | ... | |
50 | 50 |
* |
51 | 51 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
52 | 52 |
*/ |
53 |
public class SRWFilter extends Query implements IFilter {
|
|
53 |
public class SRWFilter extends AbstractFilter {
|
|
54 | 54 |
public SRWFilter(Query query) { |
55 |
super(query.getTitle(), query.getTitleFilter(), query.getAbstract(), |
|
56 |
query.getThemeKey(), query.getTopic(), query.getScale(), |
|
57 |
query.getProvider(), query.getDateFrom(), query.getDateTo(), |
|
58 |
query.getCoordenates(), query.getCoordenatesFilter(),query.getTranslator()); |
|
59 |
setMinimized(query.isMinimized()); |
|
60 |
setCoordinatesClicked(query.isCoordinatesClicked()); |
|
55 |
super(query); |
|
61 | 56 |
} |
62 | 57 |
|
63 | 58 |
/** |
... | ... | |
69 | 64 |
String pregunta = null; |
70 | 65 |
|
71 | 66 |
// Construimos una RemoteBooleanQuery |
72 |
CommonQueryLanguage query = new CommonQueryLanguage();
|
|
67 |
CommonQueryLanguage filter = new CommonQueryLanguage();
|
|
73 | 68 |
|
74 |
if (this.getTitle() != null) {
|
|
75 |
query.addClauses("dc.title", this.getTitle(), this.getTitleFilter());
|
|
69 |
if (query.getTitle() != null) {
|
|
70 |
filter.addClauses("dc.title", query.getTitle(), query.getTitleFilter());
|
|
76 | 71 |
} |
77 | 72 |
|
78 |
if (this.getAbstract() != null) {
|
|
79 |
query.addClauses("dc.subject", this.getAbstract(), "E");
|
|
73 |
if (query.getAbstract() != null) {
|
|
74 |
filter.addClauses("dc.subject", query.getAbstract(), "E");
|
|
80 | 75 |
} |
81 | 76 |
|
82 | 77 |
//if (this.getThemeKey() != null) |
83 | 78 |
//query.addClauses("", this.getThemeKey(),"Y"); |
84 | 79 |
//if (this.getScale() != null) |
85 | 80 |
//query.addClauses("map_scale", this.getScale(),"E"); |
86 |
if (this.getProvider() != null) {
|
|
87 |
query.addClauses("dc.creator", this.getProvider(), "E");
|
|
81 |
if (query.getProvider() != null) {
|
|
82 |
filter.addClauses("dc.creator", query.getProvider(), "E");
|
|
88 | 83 |
} |
89 | 84 |
|
90 | 85 |
//if (this.getDateFrom() != null) |
91 | 86 |
//query.addClauses("2072", "210", "4",this.getDateFrom(),"E"); |
92 | 87 |
//if (this.getDateTo() != null) |
93 | 88 |
//query.addClauses("2073", "210", "2",this.getDateTo(),"E"); |
94 |
pregunta = query.toString();
|
|
89 |
pregunta = filter.toString();
|
|
95 | 90 |
|
96 | 91 |
System.out.println(pregunta); |
97 | 92 |
|
trunk/applications/appCatalogYNomenclatorClient/src/es/gva/cit/catalogClient/srw/drivers/SRWCatalogServiceDriver.java | ||
---|---|---|
47 | 47 |
import es.gva.cit.catalogClient.protocols.HTTPGetProtocol; |
48 | 48 |
import es.gva.cit.catalogClient.protocols.SOAPProtocol; |
49 | 49 |
import es.gva.cit.catalogClient.querys.Query; |
50 |
import es.gva.cit.catalogClient.srw.filters.SRWFilter; |
|
51 | 50 |
import es.gva.cit.catalogClient.srw.parsers.SrwCapabilitiesParser; |
52 | 51 |
|
53 |
import org.apache.commons.httpclient.NameValuePair; |
|
54 |
|
|
55 | 52 |
import java.net.URL; |
56 | 53 |
|
57 | 54 |
import java.util.StringTokenizer; |
... | ... | |
70 | 67 |
* @see ICatalogServerDriver#GetCapabilities(java.lang.String, java.lang.String) |
71 | 68 |
*/ |
72 | 69 |
public XMLNode[] getCapabilities(URL url) { |
70 |
SRWMessages messages = new SRWMessages(this); |
|
71 |
|
|
73 | 72 |
XMLNode[] nodos = new HTTPGetProtocol().doQuery(url, |
74 |
getMessageCapabilities(), 0);
|
|
73 |
messages.getHTTPGETCapabilities(true), 0);
|
|
75 | 74 |
|
76 | 75 |
if (nodos != null) { |
77 | 76 |
setCommunicationProtocol("GET"); |
... | ... | |
79 | 78 |
return nodos; |
80 | 79 |
} |
81 | 80 |
|
82 |
nodos = new SOAPProtocol().doQuery(url, getSOAPMessageCapabilities(), 0);
|
|
81 |
nodos = new SOAPProtocol().doQuery(url, messages.getSOAPCapabilities(), 0);
|
|
83 | 82 |
|
84 | 83 |
if (nodos != null) { |
85 | 84 |
setCommunicationProtocol("SOAP"); |
... | ... | |
93 | 92 |
*/ |
94 | 93 |
public XMLNode[] getRecords(URL url, Query query, int firstRecord) { |
95 | 94 |
setQuery(query); |
95 |
SRWMessages messages = new SRWMessages(this); |
|
96 | 96 |
|
97 | 97 |
XMLNode[] answerNodes = null; |
98 | 98 |
XMLNode[] nodes = null; |
99 | 99 |
|
100 | 100 |
if (getCommunicationProtocol().equals("GET")) { |
101 | 101 |
nodes = new HTTPGetProtocol().doQuery(url, |
102 |
getMessageRecords(getQuery(), firstRecord), firstRecord);
|
|
102 |
messages.getHTTPGETRecords(getQuery(), firstRecord), firstRecord);
|
|
103 | 103 |
} |
104 | 104 |
|
105 | 105 |
if (getCommunicationProtocol().equals("POST") || |
106 | 106 |
getCommunicationProtocol().equals("SOAP")){ |
107 | 107 |
nodes = new SOAPProtocol().doQuery(url, |
108 |
getMessageRecords(getQuery(), firstRecord), firstRecord);
|
|
108 |
messages.getSOAPRecords(getQuery(), firstRecord), firstRecord);
|
|
109 | 109 |
} |
110 | 110 |
|
111 | 111 |
String prefix = new StringTokenizer(nodes[0].getName(), ":").nextToken(); |
... | ... | |
149 | 149 |
public XMLNode[] createAnswerTree(int numberOfRecords, int firstRecord, |
150 | 150 |
XMLNode node, URL url,String prefix) { |
151 | 151 |
XMLNode[] answerNodes = null; |
152 |
|
|
152 |
|
|
153 | 153 |
if (numberOfRecords > 10) { |
154 | 154 |
answerNodes = new XMLNode[11]; |
155 | 155 |
} else { |
... | ... | |
168 | 168 |
answerNodes[i] = auxNodes[i - 1]; |
169 | 169 |
|
170 | 170 |
return answerNodes; |
171 |
} |
|
172 |
|
|
173 |
/** |
|
174 |
* It creates the name-value pairs for the getCapabilities request |
|
175 |
* @return |
|
176 |
* Name-Value pair array |
|
177 |
*/ |
|
178 |
public NameValuePair[] getMessageCapabilities() { |
|
179 |
NameValuePair nvp1 = new NameValuePair("OPERATION", "explain"); |
|
180 |
NameValuePair nvp2 = new NameValuePair("VERSION", this.version); |
|
171 |
} |
|
172 |
|
|
181 | 173 |
|
182 |
return new NameValuePair[] { nvp1, nvp2 }; |
|
183 |
} |
|
184 |
|
|
185 | 174 |
/** |
186 |
* It creates the name-value pairs for the getRecords request |
|
187 |
* @return |
|
188 |
* Name-Value pair array |
|
189 |
*/ |
|
190 |
public NameValuePair[] getMessageRecords(Query query, int firstRecord) { |
|
191 |
SRWFilter qsrwd = new SRWFilter(query); |
|
192 |
|
|
193 |
NameValuePair nvp1 = new NameValuePair("operation", "searchRetrieve"); |
|
194 |
NameValuePair nvp2 = new NameValuePair("version", this.version); |
|
195 |
NameValuePair nvp3 = new NameValuePair("query", qsrwd.getQuery(null)); |
|
196 |
NameValuePair nvp4 = new NameValuePair("maximumRecords", "10"); |
|
197 |
NameValuePair nvp5 = new NameValuePair("recordPacking", |
|
198 |
getOutputFormat()); |
|
199 |
NameValuePair nvp6 = new NameValuePair("startRecord", |
|
200 |
new String(new Integer(firstRecord).toString())); |
|
201 |
|
|
202 |
return new NameValuePair[] { nvp1, nvp2, nvp3, nvp4, nvp5, nvp6 }; |
|
203 |
} |
|
204 |
|
|
205 |
/** |
|
206 |
* It creates the SOAP message for the getCapabilities request |
|
207 |
* |
|
208 |
* @return |
|
209 |
* String with the SOAP message |
|
210 |
*/ |
|
211 |
public String getSOAPMessageCapabilities() { |
|
212 |
String soapMessage = |
|
213 |
"<SRW:explainRequest xmlns:SRW=\"http://www.loc.gov/zing/srw/\">" + |
|
214 |
"<SRW:version>" + version + "</SRW:version>" + |
|
215 |
"</SRW:explainRequest>"; |
|
216 |
|
|
217 |
return SOAPProtocol.setSOAPMessage(soapMessage,null); |
|
218 |
} |
|
219 |
|
|
220 |
/** |
|
221 |
* It creates the SOAP message for the getRecords request |
|
222 |
* |
|
223 |
* @return |
|
224 |
* String with the SOAP message |
|
225 |
*/ |
|
226 |
public String getSOAPMessageRecords(Query query) { |
|
227 |
SRWFilter qsrwd = new SRWFilter(query); |
|
228 |
|
|
229 |
String soapMessage = |
|
230 |
"<srw:searchRetrieveRequest xmlns:srw=\"http://www.loc.gov/zing/srw/\">" + |
|
231 |
"<srw:query><![CDATA[" + qsrwd.getQuery(null) + "]]></srw:query>" + |
|
232 |
"<srw:sortKeys xsi:nil=\"true\"/>" + "<srw:startRecord>" + |
|
233 |
getStartPosition() + "</srw:startRecord>" + "<srw:maximumRecords>" + |
|
234 |
getMaxRecords() + "</srw:maximumRecords>" + "<srw:recordPacking>" + |
|
235 |
getOutputFormat() + "</srw:recordPacking>" + "<srw:recordSchema>" + |
|
236 |
getOutputSchema()[0] + "</srw:recordSchema>" + |
|
237 |
"<srw:resultSetTTL>" + getResultSetTTL() + "</srw:resultSetTTL>" + |
|
238 |
"</srw:searchRetrieveRequest>"; |
|
239 |
|
|
240 |
return SOAPProtocol.setSOAPMessage(soapMessage,null); |
|
241 |
} |
|
242 |
|
|
243 |
/** |
|
244 | 175 |
* @return Returns the recordXPath. |
245 | 176 |
*/ |
246 | 177 |
public String getRecordXPath() { |
trunk/applications/appCatalogYNomenclatorClient/src/es/gva/cit/catalogClient/srw/drivers/SRWMessages.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
/* |
|
42 |
* CVS MESSAGES: |
|
43 |
* |
|
44 |
* $Id$ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.1 2005-12-22 08:31:43 jorpiell |
|
47 |
* 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. |
|
48 |
* |
|
49 |
* |
|
50 |
*/ |
|
51 |
|
|
52 |
|
|
53 |
package es.gva.cit.catalogClient.srw.drivers; |
|
54 |
|
|
55 |
import org.apache.commons.httpclient.NameValuePair; |
|
56 |
|
|
57 |
import es.gva.cit.catalogClient.drivers.IProtocolMessages; |
|
58 |
import es.gva.cit.catalogClient.protocols.SOAPProtocol; |
|
59 |
import es.gva.cit.catalogClient.querys.Query; |
|
60 |
import es.gva.cit.catalogClient.srw.filters.SRWFilter; |
|
61 |
|
|
62 |
/** |
|
63 |
* This class create the SRW protocol messages |
|
64 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
65 |
*/ |
|
66 |
public class SRWMessages implements IProtocolMessages{ |
|
67 |
private SRWCatalogServiceDriver driver; |
|
68 |
|
|
69 |
public SRWMessages(SRWCatalogServiceDriver driver){ |
|
70 |
this.driver = driver; |
|
71 |
} |
|
72 |
|
|
73 |
public NameValuePair[] getHTTPGETCapabilities(boolean upper) { |
|
74 |
NameValuePair nvp1 = new NameValuePair("OPERATION", "explain"); |
|
75 |
NameValuePair nvp2 = new NameValuePair("VERSION", driver.getVersion()); |
|
76 |
|
|
77 |
return new NameValuePair[] { nvp1, nvp2 }; |
|
78 |
} |
|
79 |
|
|
80 |
public NameValuePair[] getHTTPGETDescribeRecords() { |
|
81 |
// TODO Auto-generated method stub |
|
82 |
return null; |
|
83 |
} |
|
84 |
|
|
85 |
public NameValuePair[] getHTTPGETRecords(Query query, int firstRecord) { |
|
86 |
SRWFilter qsrwd = new SRWFilter(query); |
|
87 |
|
|
88 |
NameValuePair nvp1 = new NameValuePair("operation", "searchRetrieve"); |
|
89 |
NameValuePair nvp2 = new NameValuePair("version", driver.getVersion()); |
|
90 |
NameValuePair nvp3 = new NameValuePair("query", qsrwd.getQuery(null)); |
|
91 |
NameValuePair nvp4 = new NameValuePair("maximumRecords", "10"); |
|
92 |
NameValuePair nvp5 = new NameValuePair("recordPacking", |
|
93 |
driver.getOutputFormat()); |
|
94 |
NameValuePair nvp6 = new NameValuePair("startRecord", |
|
95 |
new String(new Integer(firstRecord).toString())); |
|
96 |
|
|
97 |
return new NameValuePair[] { nvp1, nvp2, nvp3, nvp4, nvp5, nvp6 }; |
|
98 |
} |
|
99 |
|
|
100 |
public String getHTTPPOSTCapabilities() { |
|
101 |
// TODO Auto-generated method stub |
|
102 |
return null; |
|
103 |
} |
|
104 |
|
|
105 |
public String getHTTPPOSTDescribeRecords() { |
|
106 |
// TODO Auto-generated method stub |
|
107 |
return null; |
|
108 |
} |
|
109 |
|
|
110 |
public String getHTTPPOSTRecords(Query query, int firstRecord) { |
|
111 |
// TODO Auto-generated method stub |
|
112 |
return null; |
|
113 |
} |
|
114 |
|
|
115 |
public String getSOAPCapabilities() { |
|
116 |
String soapMessage = |
|
117 |
"<SRW:explainRequest xmlns:SRW=\"http://www.loc.gov/zing/srw/\">" + |
|
118 |
"<SRW:version>" + driver.getVersion() + "</SRW:version>" + |
|
119 |
"</SRW:explainRequest>"; |
|
120 |
|
|
121 |
return SOAPProtocol.setSOAPMessage(soapMessage,null); |
|
122 |
} |
|
123 |
|
|
124 |
public String getSOAPDescribeRecords() { |
|
125 |
// TODO Auto-generated method stub |
|
126 |
return null; |
|
127 |
} |
|
128 |
|
|
129 |
public String getSOAPRecords(Query query, int firstRecord) { |
|
130 |
SRWFilter qsrwd = new SRWFilter(query); |
|
131 |
|
|
132 |
String soapMessage = |
|
133 |
"<srw:searchRetrieveRequest xmlns:srw=\"http://www.loc.gov/zing/srw/\">" + |
|
134 |
"<srw:query><![CDATA[" + qsrwd.getQuery(null) + "]]></srw:query>" + |
|
135 |
"<srw:sortKeys xsi:nil=\"true\"/>" + "<srw:startRecord>" + |
|
136 |
driver.getStartPosition() + "</srw:startRecord>" + "<srw:maximumRecords>" + |
|
137 |
driver.getMaxRecords() + "</srw:maximumRecords>" + "<srw:recordPacking>" + |
|
138 |
driver.getOutputFormat() + "</srw:recordPacking>" + "<srw:recordSchema>" + |
|
139 |
driver.getOutputSchema()[0] + "</srw:recordSchema>" + |
|
140 |
"<srw:resultSetTTL>" + driver.getResultSetTTL() + "</srw:resultSetTTL>" + |
|
141 |
"</srw:searchRetrieveRequest>"; |
|
142 |
|
|
143 |
return SOAPProtocol.setSOAPMessage(soapMessage,null); |
|
144 |
} |
|
145 |
|
|
146 |
|
|
147 |
|
|
148 |
} |
|
0 | 149 |
trunk/applications/appCatalogYNomenclatorClient/src/es/gva/cit/catalogClient/ui/serverConnect/ServerConnectDialogPanel.java | ||
---|---|---|
82 | 82 |
private JButton search = null; |
83 | 83 |
|
84 | 84 |
//Others |
85 |
CatalogClient client = null; |
|
86 |
private String serversFile = "servers/CatalogServers.txt";
|
|
87 |
private String currentServer = "";
|
|
85 |
private CatalogClient client = null;
|
|
86 |
private String serversFile = "servers/CatalogServers.txt"; |
|
87 |
private String currentServer = ""; |
|
88 | 88 |
private ITranslator translator = null; |
89 | 89 |
|
90 | 90 |
|
... | ... | |
282 | 282 |
* Search Button action |
283 | 283 |
*/ |
284 | 284 |
public void searchButtonActionPerformed() { |
285 |
this.setEnabled(false);
|
|
286 |
SearchDialog frame = new SearchDialog(client,true,"");
|
|
285 |
setEnabled(false); |
|
286 |
new SearchDialog(client,true,""); |
|
287 | 287 |
} |
288 | 288 |
|
289 | 289 |
/** |
... | ... | |
296 | 296 |
client = new CatalogClient(controlsPanel.getServerAddress(), |
297 | 297 |
controlsPanel.getProtocol(), controlsPanel.getDatabase()); |
298 | 298 |
|
299 |
String msg = ""; |
|
300 |
|
|
301 |
//try to connect |
|
302 |
if (!client.serverReady()) { |
|
303 |
msg = translator.getText("errorServerNotFound"); |
|
304 |
} else if (!client.getLnkICatalogServerDriver().isProtocolSupported(client.getUrl())) { |
|
305 |
msg = translator.getText("errorNotSupportedProtocol"); |
|
306 |
} else { |
|
307 |
//getCapabilities |
|
308 |
XMLNode[] nodesCapabilities = client.getLnkICatalogServerDriver() |
|
309 |
.getCapabilities(client.getUrl()); |
|
310 |
|
|
311 |
if (nodesCapabilities == null) { |
|
312 |
msg = translator.getText("errorNotSupportedCapabilities"); |
|
313 |
} else { |
|
314 |
//Configure the client |
|
315 |
if (!client.getLnkICatalogServerDriver().setParameters(nodesCapabilities,client.getUrl())) { |
|
316 |
if (!(client.getLnkICatalogServerDriver() |
|
317 |
.getServerAnswerReady().equals(""))) { |
|
318 |
msg = translator.getText(client.getLnkICatalogServerDriver() |
|
319 |
.getServerAnswerReady()); |
|
320 |
} else { |
|
321 |
msg = translator.getText("errorNotParsedReply"); |
|
322 |
} |
|
323 |
} else { |
|
324 |
//Show the answer |
|
325 |
msg = client.getLnkICatalogServerDriver() |
|
326 |
.getServerAnswerReady(); |
|
327 |
|
|
328 |
search.setEnabled(true); |
|
329 |
currentServer = controlsPanel.getServerAddress(); |
|
330 |
} |
|
331 |
} |
|
299 |
|
|
300 |
if (client.getCapabilities()){ |
|
301 |
search.setEnabled(true); |
|
302 |
currentServer = controlsPanel.getServerAddress(); |
|
332 | 303 |
} |
304 |
|
|
305 |
controlsPanel.setRespuesta(translator.getText(client.getServerStatus())); |
|
306 |
} |
|
333 | 307 |
|
334 |
controlsPanel.setRespuesta(msg); |
|
335 |
} |
|
336 |
|
|
337 | 308 |
/** |
338 | 309 |
* @return Returns the serversFile. |
339 | 310 |
*/ |
trunk/applications/appCatalogYNomenclatorClient/src/es/gva/cit/catalogClient/schemas/ISchemas.java | ||
---|---|---|
42 | 42 |
|
43 | 43 |
import es.gva.cit.catalogClient.filters.AdditionalClauses; |
44 | 44 |
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 | 45 |
/** |
46 |
* This interface caontains all the fields that can |
|
47 |
* be used to do a search. Each "schema class" have to |
|
48 |
* implement it. |
|
50 | 49 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
51 | 50 |
*/ |
52 | 51 |
public interface ISchemas { |
trunk/applications/appCatalogYNomenclatorClient/src/es/gva/cit/catalogClient/CatalogClient.java | ||
---|---|---|
42 | 42 |
|
43 | 43 |
import es.gva.cit.catalogClient.csw.drivers.CSWCatalogServiceDriver; |
44 | 44 |
import es.gva.cit.catalogClient.drivers.ICatalogServiceDriver; |
45 |
import es.gva.cit.catalogClient.metadataXML.XMLNode; |
|
45 | 46 |
import es.gva.cit.catalogClient.srw.drivers.SRWCatalogServiceDriver; |
46 | 47 |
import es.gva.cit.catalogClient.utils.comboServer.ServerData; |
47 | 48 |
import es.gva.cit.catalogClient.z3950.drivers.Z3950CatalogServiceDriver; |
... | ... | |
63 | 64 |
private String sURL = null; |
64 | 65 |
private String protocol = null; |
65 | 66 |
private ICatalogServiceDriver lnkICatalogServerDriver; |
67 |
private String serverStatus = null; |
|
66 | 68 |
|
67 | 69 |
/** |
68 | 70 |
* Constructor |
... | ... | |
116 | 118 |
lnkICatalogServerDriver = new Z3950CatalogServiceDriver(); |
117 | 119 |
} |
118 | 120 |
} |
121 |
|
|
122 |
/** |
|
123 |
* This function is a link between the user interface and |
|
124 |
* the driver. It tryes if the server exists, if the server |
|
125 |
* supports the protocolo and finally it sents a getCapabilities |
|
126 |
* request. |
|
127 |
* @return |
|
128 |
* True if all is OK. |
|
129 |
*/ |
|
130 |
public boolean getCapabilities(){ |
|
131 |
//try to connect |
|
132 |
if (!serverReady()) { |
|
133 |
serverStatus = ("errorServerNotFound"); |
|
134 |
} else if (!getLnkICatalogServerDriver().isProtocolSupported(getUrl())) { |
|
135 |
serverStatus = "errorNotSupportedProtocol"; |
|
136 |
} else { |
|
137 |
//getCapabilities |
|
138 |
XMLNode[] nodesCapabilities = getLnkICatalogServerDriver() |
|
139 |
.getCapabilities(getUrl()); |
|
119 | 140 |
|
141 |
if (nodesCapabilities == null) { |
|
142 |
serverStatus = "errorNotSupportedCapabilities"; |
|
143 |
} else { |
|
144 |
//Configure the client |
|
145 |
if (!getLnkICatalogServerDriver().setParameters(nodesCapabilities,getUrl())) { |
|
146 |
if (!(getLnkICatalogServerDriver() |
|
147 |
.getServerAnswerReady().equals(""))) { |
|
148 |
serverStatus = getLnkICatalogServerDriver().getServerAnswerReady(); |
|
149 |
} else { |
|
150 |
serverStatus = "errorNotParsedReply"; |
|
151 |
} |
|
152 |
} else { |
|
153 |
//Show the answer |
|
154 |
serverStatus = getLnkICatalogServerDriver().getServerAnswerReady(); |
|
155 |
return true; |
|
156 |
} |
|
157 |
} |
|
158 |
} |
|
159 |
|
|
160 |
return false; |
|
161 |
} |
|
162 |
|
|
120 | 163 |
/** |
121 | 164 |
* @return Returns the lnkICatalogServerDriver. |
122 | 165 |
*/ |
... | ... | |
175 | 218 |
* true --> server is ready |
176 | 219 |
* false --> server is not ready |
177 | 220 |
*/ |
178 |
public boolean serverReady() {
|
|
221 |
private boolean serverReady() {
|
|
179 | 222 |
try { |
180 | 223 |
new Socket(this.getUrl().getHost(),this.getUrl().getPort()); |
181 | 224 |
} catch (UnknownHostException e) { |
... | ... | |
200 | 243 |
public void setSURL(String surl) { |
201 | 244 |
sURL = surl; |
202 | 245 |
} |
246 |
|
|
247 |
/** |
|
248 |
* @return Returns the serverStatus. |
|
249 |
*/ |
|
250 |
public String getServerStatus() { |
|
251 |
return serverStatus; |
|
252 |
} |
|
203 | 253 |
} |
trunk/applications/appCatalogYNomenclatorClient/src/es/gva/cit/catalogClient/z3950/drivers/Z3950CatalogServiceDriver.java | ||
---|---|---|
45 | 45 |
import es.gva.cit.catalogClient.metadataXML.XMLTree; |
46 | 46 |
import es.gva.cit.catalogClient.protocols.Z3950Protocol; |
47 | 47 |
import es.gva.cit.catalogClient.querys.Query; |
48 |
import es.gva.cit.catalogClient.z3950.filters.Z3950Filter; |
|
49 | 48 |
|
50 | 49 |
|
51 | 50 |
import java.io.ByteArrayInputStream; |
... | ... | |
64 | 63 |
*/ |
65 | 64 |
public XMLNode[] getCapabilities(URL url) { |
66 | 65 |
XMLNode[] nodos = new XMLNode[1]; |
66 |
Z3950Messages messages = new Z3950Messages(this); |
|
67 | 67 |
|
68 |
String message = getMessageCapabilities(new Z3950Protocol().openConnection(
|
|
68 |
String message = messages.getCapabilities(new Z3950Protocol().openConnection(
|
|
69 | 69 |
url)); |
70 | 70 |
ByteArrayInputStream buffer = new ByteArrayInputStream(message.getBytes()); |
71 | 71 |
|
... | ... | |
79 | 79 |
*/ |
80 | 80 |
public XMLNode[] getRecords(URL url, Query query, int firstRecord) { |
81 | 81 |
setQuery(query); |
82 |
Z3950Messages messages = new Z3950Messages(this); |
|
83 |
|
|
84 |
String message = messages.getRecords(getQuery()); |
|
82 | 85 |
|
83 |
String message = getMessageRecords(getQuery()); |
|
84 |
|
|
85 | 86 |
System.out.println(message); |
86 | 87 |
|
87 | 88 |
XMLNode[] nodos = new Z3950Protocol().doQuery(url, message, firstRecord); |
88 | 89 |
|
89 | 90 |
return nodos; |
90 |
} |
|
91 |
|
|
92 |
/** |
|
93 |
* It creates the String for the getCapabilities request |
|
94 |
* @return |
|
95 |
* String with the query |
|
96 |
*/ |
|
97 |
public String getMessageCapabilities(String message) { |
|
98 |
return "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" + "<Z3950> " + |
|
99 |
"<Servidor>" + message + "</Servidor>" + "</Z3950>"; |
|
100 |
} |
|
101 |
|
|
102 |
|
|
103 |
/** |
|
104 |
* It creates the String for the getRecords request |
|
105 |
* @return |
|
106 |
* String with the query |
|
107 |
*/ |
|
108 |
public String getMessageRecords(Query query) { |
|
109 |
Z3950Filter qz3950 = new Z3950Filter(query); |
|
91 |
} |
|
92 |
|
|
110 | 93 |
|
111 |
return qz3950.getQuery(null); |
|
112 |
} |
|
113 |
|
|
114 | 94 |
/* (non-Javadoc) |
115 | 95 |
* @see catalogClient.ICatalogServerDriver#setParameters(java.util.Properties) |
116 | 96 |
*/ |
trunk/applications/appCatalogYNomenclatorClient/src/es/gva/cit/catalogClient/z3950/drivers/Z3950Messages.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
/* |
|
42 |
* CVS MESSAGES: |
|
43 |
* |
|
44 |
* $Id$ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.1 2005-12-22 08:31:43 jorpiell |
|
47 |
* 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. |
|
48 |
* |
|
49 |
* |
|
50 |
*/ |
|
51 |
|
|
52 |
|
|
53 |
package es.gva.cit.catalogClient.z3950.drivers; |
|
54 |
|
|
55 |
import es.gva.cit.catalogClient.querys.Query; |
|
56 |
import es.gva.cit.catalogClient.z3950.filters.Z3950Filter; |
|
57 |
|
|
58 |
/** |
|
59 |
* This class is used to create all the Z3950 protocol |
|
60 |
* messages |
|
61 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
62 |
*/ |
|
63 |
public class Z3950Messages { |
|
64 |
private Z3950CatalogServiceDriver driver = null;; |
|
65 |
|
|
66 |
public Z3950Messages(Z3950CatalogServiceDriver driver){ |
|
67 |
this.driver = driver; |
|
68 |
} |
|
69 |
|
|
70 |
public String getCapabilities(String message) { |
|
71 |
return "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" + "<Z3950> " + |
|
72 |
"<Servidor>" + message + "</Servidor>" + "</Z3950>"; |
|
73 |
|
|
74 |
} |
|
75 |
|
|
76 |
public String getRecords(Query query) { |
|
77 |
Z3950Filter qz3950 = new Z3950Filter(query); |
|
78 |
|
|
79 |
return qz3950.getQuery(null); |
|
80 |
} |
|
81 |
|
|
82 |
} |
|
0 | 83 |
trunk/applications/appCatalogYNomenclatorClient/src/es/gva/cit/catalogClient/z3950/filters/Z3950Filter.java | ||
---|---|---|
40 | 40 |
*/ |
41 | 41 |
package es.gva.cit.catalogClient.z3950.filters; |
42 | 42 |
|
43 |
import es.gva.cit.catalogClient.filters.IFilter;
|
|
43 |
import es.gva.cit.catalogClient.filters.AbstractFilter;
|
|
44 | 44 |
import es.gva.cit.catalogClient.languages.BasicEncodingRules; |
45 | 45 |
import es.gva.cit.catalogClient.querys.Query; |
46 | 46 |
|
... | ... | |
48 | 48 |
/** |
49 | 49 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
50 | 50 |
*/ |
51 |
public class Z3950Filter extends Query implements IFilter {
|
|
51 |
public class Z3950Filter extends AbstractFilter {
|
|
52 | 52 |
public Z3950Filter(Query query) { |
53 |
super(query.getTitle(), query.getTitleFilter(), query.getAbstract(), |
|
54 |
query.getThemeKey(), query.getTopic(), query.getScale(), |
|
55 |
query.getProvider(), query.getDateFrom(), query.getDateTo(), |
|
56 |
query.getCoordenates(), query.getCoordenatesFilter(),query.getTranslator()); |
|
57 |
setMinimized(query.isMinimized()); |
|
58 |
setCoordinatesClicked(query.isCoordinatesClicked()); |
|
53 |
super(query); |
|
59 | 54 |
} |
60 | 55 |
|
61 | 56 |
public String getQuery(String profile) { |
62 | 57 |
// Create a RemoteBooleanQuery |
63 |
BasicEncodingRules query = new BasicEncodingRules();
|
|
58 |
BasicEncodingRules filter = new BasicEncodingRules();
|
|
64 | 59 |
|
65 | 60 |
//Title (title, 4), Word List (6) |
66 |
if (getTitle() != null) { |
|
67 |
query.addClauses("4", "6", "3", this.getTitle(),
|
|
68 |
this.getTitleFilter(),"and");
|
|
61 |
if (query.getTitle() != null) {
|
|
62 |
filter.addClauses("4", "6", "3", query.getTitle(),
|
|
63 |
query.getTitleFilter(),"and");
|
|
69 | 64 |
} |
70 | 65 |
|
71 | 66 |
String operator = "and"; |
72 |
if (isMinimized()) |
|
67 |
if (query.isMinimized())
|
|
73 | 68 |
operator = "or"; |
74 | 69 |
|
75 | 70 |
//Abstract (abstract, 62), Word List (6) |
76 |
if (getAbstract() != null) { |
|
77 |
query.addClauses("62", "6", "3", this.getAbstract(), "E", operator);
|
|
71 |
if (query.getAbstract() != null) {
|
|
72 |
filter.addClauses("62", "6", "3", query.getAbstract(), "E", operator);
|
|
78 | 73 |
} |
79 | 74 |
|
80 | 75 |
//Theme Keyword (themekey, 2002), Word List (6) |
81 |
if (getThemeKey() != null) { |
|
82 |
query.addClauses("2002", "6", "3", this.getThemeKey(), "Y","and");
|
|
76 |
if (query.getThemeKey() != null) {
|
|
77 |
filter.addClauses("2002", "6", "3", query.getThemeKey(), "Y","and");
|
|
83 | 78 |
} |
84 | 79 |
|
85 | 80 |
//Source Scale Denominator (srcscale, 1024), Numeric String (109) |
86 |
if (getScale() != null) { |
|
87 |
if (getMinScale() != null){ |
|
88 |
query.addClauses("1024", "109", "4", getMinScale(),"E","and");
|
|
81 |
if (query.getScale() != null) {
|
|
82 |
if (query.getMinScale() != null){
|
|
83 |
filter.addClauses("1024", "109", "4", query.getMinScale(),"E","and");
|
|
89 | 84 |
} |
90 |
if (getMaxScale() != null){ |
|
91 |
query.addClauses("1024", "109", "2", getMaxScale(),"E","and");
|
|
85 |
if (query.getMaxScale() != null){
|
|
86 |
filter.addClauses("1024", "109", "2", query.getMaxScale(),"E","and");
|
|
92 | 87 |
} |
93 | 88 |
} |
94 | 89 |
|
95 |
if (getProvider() != null) { |
|
96 |
query.addClauses("1005", "6", "3", this.getProvider(), "E","and");
|
|
90 |
if (query.getProvider() != null) {
|
|
91 |
filter.addClauses("1005", "6", "3", query.getProvider(), "E","and");
|
|
97 | 92 |
} |
98 | 93 |
|
99 | 94 |
//Beginning Date (begdate, 2072), Date(210) |
100 |
if (getDateFrom() != null) { |
|
101 |
query.addClauses("2072", "210", "4", this.getDateFrom(), "E","and");
|
|
95 |
if (query.getDateFrom() != null) {
|
|
96 |
filter.addClauses("2072", "210", "4", query.getDateFrom(), "E","and");
|
|
102 | 97 |
} |
103 | 98 |
|
104 | 99 |
//Ending Date (enddate, 2073), Date(210) |
105 |
if (getDateTo() != null) { |
|
106 |
query.addClauses("2073", "210", "2", this.getDateTo(), "E","and");
|
|
100 |
if (query.getDateTo() != null) {
|
|
101 |
filter.addClauses("2073", "210", "2", query.getDateTo(), "E","and");
|
|
107 | 102 |
} |
108 | 103 |
|
109 |
if ((getCoordenates() != null) && (isCoordinatesClicked())){
|
|
110 |
String sNorth = this.getCoordenates().getUly();
|
|
111 |
String sWest = this.getCoordenates().getUlx();
|
|
112 |
String sSouth = this.getCoordenates().getBry();
|
|
113 |
String sEast = this.getCoordenates().getBrx();
|
|
104 |
if ((query.getCoordenates() != null) && (query.isCoordinatesClicked())){
|
|
105 |
String sNorth = query.getCoordenates().getUly();
|
|
106 |
String sWest = query.getCoordenates().getUlx();
|
|
107 |
String sSouth = query.getCoordenates().getBry();
|
|
108 |
String sEast = query.getCoordenates().getBrx();
|
|
114 | 109 |
String sBounding = sNorth + " " + sWest + " " + sSouth + " " + |
115 | 110 |
sEast; |
116 |
String sRelation = getRelation(this.getCoordenatesFilter());
|
|
111 |
String sRelation = getRelation(query.getCoordenatesFilter());
|
|
117 | 112 |
|
118 | 113 |
// Bounding Coordinates (bounding, 2060), Coordinate String (201) |
119 |
query.addClauses("2060", "201", sRelation, sBounding, "E","and");
|
|
114 |
filter.addClauses("2060", "201", sRelation, sBounding, "E","and");
|
|
120 | 115 |
} |
121 | 116 |
|
122 | 117 |
//return query |
123 |
return query.toString();
|
|
118 |
return filter.toString();
|
|
124 | 119 |
} |
125 | 120 |
|
126 | 121 |
/** |
... | ... | |
140 | 135 |
* 3 -> equals |
141 | 136 |
*/ |
142 | 137 |
private String getRelation(String relacion) { |
143 |
if (relacion.equals(getTranslator().getText("coordinatesEqual"))) { |
|
138 |
if (relacion.equals(query.getTranslator().getText("coordinatesEqual"))) {
|
|
144 | 139 |
return "3"; |
145 | 140 |
} |
146 |
if (relacion.equals(getTranslator().getText("coordinatesContains"))) { |
|
141 |
if (relacion.equals(query.getTranslator().getText("coordinatesContains"))) {
|
|
147 | 142 |
return "7"; |
148 | 143 |
} |
149 |
if (relacion.equals(getTranslator().getText("coordinatesEnclose"))) { |
|
144 |
if (relacion.equals(query.getTranslator().getText("coordinatesEnclose"))) {
|
|
150 | 145 |
return "9"; |
151 | 146 |
} else { |
152 | 147 |
return "10"; |
trunk/applications/appCatalogYNomenclatorClient/src/es/gva/cit/catalogClient/csw/drivers/CSWCatalogServiceDriver.java | ||
---|---|---|
71 | 71 |
private String[] typeNames = null; |
72 | 72 |
private String[] resultType = null; |
73 | 73 |
private String[] NAMESPACE = null; |
74 |
private String version = "2.0.0";
|
|
74 |
private String version = "2.0.0"; |
|
75 | 75 |
private CswSupportedProtocolOperations operations = null; |
76 | 76 |
|
77 | 77 |
/* |
trunk/applications/appCatalogYNomenclatorClient/src/es/gva/cit/catalogClient/csw/filters/CSWFilter.java | ||
---|---|---|
40 | 40 |
*/ |
41 | 41 |
package es.gva.cit.catalogClient.csw.filters; |
42 | 42 |
|
43 |
import es.gva.cit.catalogClient.filters.AbstractFilter; |
|
43 | 44 |
import es.gva.cit.catalogClient.filters.AdditionalClauses; |
44 |
import es.gva.cit.catalogClient.filters.IFilter; |
|
45 | 45 |
import es.gva.cit.catalogClient.languages.FilterEncoding; |
46 | 46 |
import es.gva.cit.catalogClient.querys.Query; |
47 | 47 |
import es.gva.cit.catalogClient.schemas.DublinCoreSchema; |
... | ... | |
58 | 58 |
* |
59 | 59 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
60 | 60 |
*/ |
61 |
public class CSWFilter extends Query implements IFilter {
|
|
62 |
ISchemas equiv = null; |
|
63 |
|
|
61 |
public class CSWFilter extends AbstractFilter {
|
|
62 |
private ISchemas equiv = null;
|
|
63 |
|
|
64 | 64 |
public CSWFilter(Query query) { |
65 |
super(query.getTitle(), query.getTitleFilter(), query.getAbstract(), |
|
66 |
query.getThemeKey(), query.getTopic(), query.getScale(), |
|
67 |
query.getProvider(), query.getDateFrom(), query.getDateTo(), |
|
68 |
query.getCoordenates(), query.getCoordenatesFilter(),query.getTranslator()); |
|
69 |
setMinimized(query.isMinimized()); |
|
70 |
setCoordinatesClicked(query.isCoordinatesClicked()); |
|
71 |
} |
|
72 |
|
|
65 |
super(query); |
|
66 |
} |
|
73 | 67 |
|
74 | 68 |
/** |
75 | 69 |
* Return a CQL-Text query |
... | ... | |
81 | 75 |
|
82 | 76 |
setProfile(profile); |
83 | 77 |
|
84 |
FilterEncoding query = new FilterEncoding("ogc:", "*", "?", "\\",
|
|
78 |
FilterEncoding filter = new FilterEncoding("ogc:", "*", "?", "\\",
|
|
85 | 79 |
"xmlns:ogc=\"http://www.opengis.net/ogc\""); |
80 |
|
|
81 |
addAdditionalClauses(filter); |
|
86 | 82 |
|
87 |
addAdditionalClauses(query); |
|
88 |
|
|
89 |
if (getTitle() != null) { |
|
90 |
query.addClauses(equiv.getTitle(), equiv.getTitleValue(getTitle(),getTitleFilter()), getTitleFilter(), |
|
83 |
if (query.getTitle() != null) { |
|
84 |
filter.addClauses(equiv.getTitle(), equiv.getTitleValue(query.getTitle(),query.getTitleFilter()), query.getTitleFilter(), |
|
91 | 85 |
"PropertyIsLike", "L", "And"); |
92 | 86 |
} |
93 | 87 |
|
94 | 88 |
String operator = "And"; |
95 |
if (isMinimized()) |
|
89 |
|
|
90 |
if (query.isMinimized()) |
|
96 | 91 |
operator = "Or"; |
97 | 92 |
|
98 | 93 |
|
99 |
if (getAbstract() != null) { |
|
100 |
query.addClauses(equiv.getAbstract(), Strings.addAsteriscsFromAnArray(getAbstract()),
|
|
94 |
if (query.getAbstract() != null) {
|
|
95 |
filter.addClauses(equiv.getAbstract(), Strings.addAsteriscsFromAnArray(query.getAbstract()),
|
|
101 | 96 |
"Y", "PropertyIsLike", "L", operator); |
102 | 97 |
} |
103 | 98 |
|
104 |
if (getThemeKey() != null) { |
|
105 |
query.addClauses(equiv.getThemeKey(), getThemeKey(), "Y",
|
|
99 |
if (query.getThemeKey() != null) {
|
|
100 |
filter.addClauses(equiv.getThemeKey(), query.getThemeKey(), "Y",
|
|
106 | 101 |
"PropertyIsLike", "L", "And"); |
107 | 102 |
} |
108 | 103 |
|
109 |
if ((getTopic() != null) && (!getTopic().equals(this.getTranslator().getText("cathegoryAny")))) {
|
|
110 |
query.addClauses(equiv.getTopic(), equiv.getTopicValue(getTopic()),
|
|
104 |
if ((query.getTopic() != null) && (!query.getTopic().equals(query.getTranslator().getText("cathegoryAny")))) {
|
|
105 |
filter.addClauses(equiv.getTopic(), equiv.getTopicValue(query.getTopic()),
|
|
111 | 106 |
"E", "PropertyIsEqualTo", "L", "And"); |
112 | 107 |
} |
113 | 108 |
|
... | ... | |
117 | 112 |
} |
118 | 113 |
*/ |
119 | 114 |
|
120 |
if (getProvider() != null) { |
|
121 |
query.addClauses(equiv.getProvider(), equiv.getProviderValue(getProvider()),
|
|
115 |
if (query.getProvider() != null) {
|
|
116 |
filter.addClauses(equiv.getProvider(), equiv.getProviderValue(query.getProvider()),
|
|
122 | 117 |
"E", "PropertyIsEqualTo" , "L", "And"); |
123 | 118 |
} |
124 | 119 |
|
125 |
if (this.getDateFrom() != null) {
|
|
126 |
query.addClauses(equiv.getDateFrom(), this.getDateFrom(), "E", "PropertyIsGeaterThan" ,"L", "And");
|
|
120 |
if (query.getDateFrom() != null) {
|
|
121 |
filter.addClauses(equiv.getDateFrom(), query.getDateFrom(), "E", "PropertyIsGeaterThan" ,"L", "And");
|
|
127 | 122 |
} |
128 | 123 |
|
129 |
if (this.getDateTo() != null) {
|
|
130 |
query.addClauses(equiv.getDateTo(), this.getDateTo(), "E", "PropertyIsLessThan", "L", "And");
|
|
124 |
if (query.getDateTo() != null) {
|
|
125 |
filter.addClauses(equiv.getDateTo(), query.getDateTo(), "E", "PropertyIsLessThan", "L", "And");
|
|
131 | 126 |
} |
132 | 127 |
|
133 |
if ((getCoordenates() != null) && (isCoordinatesClicked())){
|
|
134 |
query.addBoundingBox(getCoordenates(), equiv.getCoordinates(), getCoordinatesOption(getCoordenatesFilter()));
|
|
128 |
if ((query.getCoordenates() != null) && (query.isCoordinatesClicked())){
|
|
129 |
filter.addBoundingBox(query.getCoordenates(), equiv.getCoordinates(), getCoordinatesOption(query.getCoordenatesFilter()));
|
|
135 | 130 |
} |
136 | 131 |
|
137 |
pregunta = query.toString();
|
|
132 |
pregunta = filter.toString();
|
|
138 | 133 |
|
139 | 134 |
return pregunta; |
140 | 135 |
} |
... | ... | |
146 | 141 |
* @return |
147 | 142 |
*/ |
148 | 143 |
public boolean getCoordinatesOption(String coordinatesOption){ |
149 |
if ((coordinatesOption.equals(getTranslator().getText("coordinatesEqual"))) || |
|
150 |
(coordinatesOption.equals(getTranslator().getText("coordinatesContains"))) || |
|
151 |
(coordinatesOption.equals(getTranslator().getText("coordinatesEnclose")))) |
|
144 |
if ((coordinatesOption.equals(query.getTranslator().getText("coordinatesEqual"))) ||
|
|
145 |
(coordinatesOption.equals(query.getTranslator().getText("coordinatesContains"))) ||
|
|
146 |
(coordinatesOption.equals(query.getTranslator().getText("coordinatesEnclose"))))
|
|
152 | 147 |
return false; |
153 | 148 |
|
154 | 149 |
return true; |
... | ... | |
172 | 167 |
* It adds the aditional clauses (for each profile) |
173 | 168 |
* @param query |
174 | 169 |
*/ |
175 |
public void addAdditionalClauses(FilterEncoding query) {
|
|
170 |
public void addAdditionalClauses(FilterEncoding filter) {
|
|
176 | 171 |
AdditionalClauses[] ac = equiv.getAdditionalClauses(null); |
177 | 172 |
|
178 | 173 |
for (int i = 0; i < ac.length; i++) |
179 |
query.addClauses(ac[i].getProperty(), ac[i].getValue(),
|
|
174 |
filter.addClauses(ac[i].getProperty(), ac[i].getValue(),
|
|
180 | 175 |
ac[i].getConcorancia(), ac[i].getRelationship(), ac[i].getType(),"And"); |
181 | 176 |
} |
182 | 177 |
|
Also available in: Unified diff