svn-gvsig-desktop / trunk / applications / appCatalogYNomenclatorClient / src / es / gva / cit / catalogClient / z3950 / filters / Z3950Filter.java @ 7394
History | View | Annotate | Download (5.15 KB)
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 es.gva.cit.catalogClient.z3950.filters; |
43 |
import org.gvsig.i18n.Messages; |
44 |
|
45 |
import es.gva.cit.catalogClient.filters.AbstractFilter; |
46 |
import es.gva.cit.catalogClient.languages.BasicEncodingRules; |
47 |
import es.gva.cit.catalogClient.utils.Strings; |
48 |
|
49 |
/**
|
50 |
*
|
51 |
*
|
52 |
*
|
53 |
* @author Jorge Piera Llodra (piera_jor@gva.es)
|
54 |
*/
|
55 |
public class Z3950Filter extends AbstractFilter { |
56 |
|
57 |
/**
|
58 |
*
|
59 |
*
|
60 |
*/
|
61 |
public Z3950Filter() {
|
62 |
super();
|
63 |
} |
64 |
|
65 |
/**
|
66 |
*
|
67 |
*
|
68 |
*
|
69 |
* @param query
|
70 |
* @return
|
71 |
* @param profile
|
72 |
*/
|
73 |
public String getQuery(es.gva.cit.catalogClient.querys.Query query, String profile) { |
74 |
// Create a RemoteBooleanQuery
|
75 |
BasicEncodingRules filter = new BasicEncodingRules();
|
76 |
|
77 |
//Title (title, 4), Word List (6)
|
78 |
if (query.getTitle() != null) { |
79 |
filter.addClauses("4", "6", "3", query.getTitle(), |
80 |
query.getTitleFilter(),"and");
|
81 |
} |
82 |
|
83 |
|
84 |
if (query.isMinimized()){
|
85 |
if (query.getAbstract() != null) { |
86 |
filter.addClauses("62", "6", "3", query.getAbstract(), "E", "or"); |
87 |
} |
88 |
}else{
|
89 |
if (query.getAbstract() != null) { |
90 |
filter.addClauses("62", "6", "3", query.getAbstract(), "E", "and"); |
91 |
} |
92 |
// Theme Keyword (themekey, 2002), Word List (6)
|
93 |
if (query.getThemeKey() != null) { |
94 |
filter.addClauses("2002", "6", "3", query.getThemeKey(), "Y","and"); |
95 |
} |
96 |
// Source Scale Denominator (srcscale, 1024), Numeric String (109)
|
97 |
if (query.getScale() != null) { |
98 |
if (query.getMinScale() != null){ |
99 |
filter.addClauses("1024", "109", "4", query.getMinScale(),"E","and"); |
100 |
} |
101 |
if (query.getMaxScale() != null){ |
102 |
filter.addClauses("1024", "109", "2", query.getMaxScale(),"E","and"); |
103 |
} |
104 |
} |
105 |
|
106 |
if (query.getProvider() != null) { |
107 |
filter.addClauses("1005", "6", "3", query.getProvider(), "E","and"); |
108 |
} |
109 |
// Beginning Date (begdate, 1012), Date(210)
|
110 |
if (query.getDateFrom() != null) { |
111 |
filter.addClauses("1012", "210", "18", query.getDateFrom(), "E","and"); |
112 |
} |
113 |
// Ending Date (date, 1012 ), Date(210)
|
114 |
if (query.getDateTo() != null) { |
115 |
filter.addClauses("1012", "210", "14", query.getDateTo(), "E","and"); |
116 |
} |
117 |
} |
118 |
|
119 |
if ((query.getCoordenates() != null) && (query.isCoordinatesClicked())){ |
120 |
String sNorth = query.getCoordenates().getUly();
|
121 |
String sWest = query.getCoordenates().getUlx();
|
122 |
String sSouth = query.getCoordenates().getBry();
|
123 |
String sEast = query.getCoordenates().getBrx();
|
124 |
String sBounding = sNorth + " " + sWest + " " + sSouth + " " + |
125 |
sEast; |
126 |
String sRelation = getRelation(query.getCoordenatesFilter());
|
127 |
// Bounding Coordinates (bounding, 2060), Coordinate String (201)
|
128 |
filter.addClauses("2060", "201", sRelation, sBounding, "E","and"); |
129 |
} |
130 |
//return query
|
131 |
return filter.toString(profile);
|
132 |
} |
133 |
|
134 |
/**
|
135 |
* Return a value for the option of the 'Coordenates Filter'
|
136 |
*
|
137 |
* @param relation String in the combo. Possible values:
|
138 |
* encloses
|
139 |
* overlaps
|
140 |
* fullyOutsideOf
|
141 |
* equals
|
142 |
*
|
143 |
* @return String
|
144 |
* Possible values:
|
145 |
* 9 -> encloses
|
146 |
* 7 -> overlaps
|
147 |
* 10 -> fullyOutsideOf
|
148 |
* 3 -> equals
|
149 |
* @param translator
|
150 |
* @param relacion
|
151 |
*/
|
152 |
private String getRelation(String relacion) { |
153 |
if (relacion.equals(Messages.getText("coordinatesEqual"))) { |
154 |
return "3"; |
155 |
} |
156 |
if (relacion.equals(Messages.getText("coordinatesContains"))) { |
157 |
return "7"; |
158 |
} |
159 |
if (relacion.equals(Messages.getText("coordinatesEnclose"))) { |
160 |
return "9"; |
161 |
} else {
|
162 |
return "10"; |
163 |
} |
164 |
} |
165 |
} |