Revision 47420

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.csv/src/main/java/org/gvsig/fmap/dal/store/csv/FieldTypeParser.java
8 8
import java.util.HashMap;
9 9
import java.util.Map;
10 10
import org.apache.commons.lang3.StringUtils;
11
import org.apache.commons.text.StringEscapeUtils;
11 12
import org.gvsig.fmap.dal.DataTypes;
12 13
import org.gvsig.fmap.geom.Geometry;
13 14
import org.gvsig.fmap.geom.GeometryUtils;
......
127 128
        }
128 129
        this.size = 0;
129 130
        while (n < args.length) {
131
            String escMode = null;
130 132
            String option = StringUtils.trim(args[n++].toLowerCase());
131 133
            switch (option) {
132 134
                case "size":
......
136 138
                        LOGGER.warn("Ignore incorrect field size for field " + value + " in '" + getProviderName() + "' file '" + getFullFileName() + "'.", ex);
137 139
                    }
138 140
                    break;
141
                case "tagesc":
142
                    escMode = StringUtils.trim(args[n++]);
139 143
                case "tag":
140 144
                    {
141 145
                        String x = StringUtils.trim(args[n++]);
......
143 147
                        if (pos < 0) {
144 148
                            this.tags.put(x, null);
145 149
                        } else {
146
                            this.tags.put(StringUtils.trim(StringUtils.substring(x, 0, pos)), StringUtils.trim(StringUtils.substring(x, pos + 1)));
150
                            String v = StringUtils.trim(StringUtils.substring(x, pos + 1));
151
                            if(escMode != null) {
152
                                if(StringUtils.equalsIgnoreCase(escMode,"html")){
153
                                    v = StringEscapeUtils.unescapeHtml3(v);
154
                                } else {
155
                                    LOGGER.warn("Illegal escape mode for argument '" + option + "' for field '" + this.name + "' in '" + getProviderName() + "' file '" + getFullFileName() + "' (" + value + ").");
156
                                }
157
                            }
158
                            this.tags.put(StringUtils.trim(StringUtils.substring(x, 0, pos)), v);
147 159
                        }
148 160
                        break;
149 161
                    }
162
                case "typetagesc":
163
                    escMode = StringUtils.trim(args[n++]);
150 164
                case "typetag":
151 165
                    {
152 166
                        String x = StringUtils.trim(args[n++]);
......
154 168
                        if (pos < 0) {
155 169
                            this.typetags.put(x, null);
156 170
                        } else {
157
                            this.typetags.put(StringUtils.trim(StringUtils.substring(x, 0, pos)), StringUtils.trim(StringUtils.substring(x, pos + 1)));
171
                            String v = StringUtils.trim(StringUtils.substring(x, pos + 1));
172
                            if(escMode != null) {
173
                                if(StringUtils.equalsIgnoreCase(escMode,"html")){
174
                                    v = StringEscapeUtils.unescapeHtml3(v);
175
                                } else {
176
                                    LOGGER.warn("Illegal escape mode for argument '" + option + "' for field '" + this.name + "' in '" + getProviderName() + "' file '" + getFullFileName() + "' (" + value + ").");
177
                                }
178
                            }
179
                            this.typetags.put(StringUtils.trim(StringUtils.substring(x, 0, pos)), v);
158 180
                        }
159 181
                        break;
160 182
                    }
183
                case "setesc":
184
                        escMode = StringUtils.trim(args[n++]);
161 185
                case "set":
162 186
                    {
163 187
                        String x = StringUtils.trim(args[n++]);
......
165 189
                        if (pos < 0) {
166 190
                            this.assignments.put(x, null);
167 191
                        } else {
168
                            this.assignments.put(StringUtils.trim(StringUtils.substring(x, 0, pos)), StringUtils.trim(StringUtils.substring(x, pos + 1)));
192
                            String v = StringUtils.trim(StringUtils.substring(x, pos + 1));
193
                            if(escMode != null) {
194
                                if(StringUtils.equalsIgnoreCase(escMode,"html")){
195
                                    v = StringEscapeUtils.unescapeHtml3(v);
196
                                } else {
197
                                    LOGGER.warn("Illegal escape mode for argument '" + option + "' for field '" + this.name + "' in '" + getProviderName() + "' file '" + getFullFileName() + "' (" + value + ").");
198
                                }
199
                            }
200
                            this.assignments.put(StringUtils.trim(StringUtils.substring(x, 0, pos)), v);
169 201
                        }
170 202
                        break;
171 203
                    }
204
                case "typesetesc":
205
                        escMode = StringUtils.trim(args[n++]);
172 206
                case "typeset":
173 207
                    {
174 208
                        String x = StringUtils.trim(args[n++]);
......
176 210
                        if (pos < 0) {
177 211
                            this.typeAssignments.put(x, null);
178 212
                        } else {
179
                            this.typeAssignments.put(StringUtils.trim(StringUtils.substring(x, 0, pos)), StringUtils.trim(StringUtils.substring(x, pos + 1)));
213
                            String v = StringUtils.trim(StringUtils.substring(x, pos + 1));
214
                            if(escMode != null) {
215
                                if(StringUtils.equalsIgnoreCase(escMode,"html")){
216
                                    v = StringEscapeUtils.unescapeHtml3(v);
217
                                } else {
218
                                    LOGGER.warn("Illegal escape mode for argument '" + option + "' for field '" + this.name + "' in '" + getProviderName() + "' file '" + getFullFileName() + "' (" + value + ").");
219
                                }
220
                            }
221
                            this.typeAssignments.put(StringUtils.trim(StringUtils.substring(x, 0, pos)), v);
180 222
                        }
181 223
                        break;
182 224
                    }
......
189 231
                        }
190 232
                        break;
191 233
                    }
192
                    LOGGER.warn("Illegal argumente '" + option + "' for field '" + this.name + "' in '" + getProviderName() + "' file '" + getFullFileName() + "' (" + value + ").");
234
                    LOGGER.warn("Illegal argument '" + option + "' for field '" + this.name + "' in '" + getProviderName() + "' file '" + getFullFileName() + "' (" + value + ").");
193 235
            }
194 236
        }
195 237
        return true;
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.csv/src/main/java/org/gvsig/fmap/dal/store/csv/CSVFeatureWriter.java
14 14
import java.util.Locale;
15 15
import org.apache.commons.lang3.ArrayUtils;
16 16
import org.apache.commons.lang3.StringUtils;
17
import org.apache.commons.text.StringEscapeUtils;
17 18
import org.gvsig.fmap.dal.DataTypes;
18 19
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
19 20
import org.gvsig.fmap.dal.feature.FeatureType;
......
174 175
            for (String tagName : tags) {
175 176
                String value = tags.getString(tagName, null);
176 177
                if( value!=null ) {
177
                  s += "/typetag/"+tagName+"="+value;
178
                    String sep = "/";
179
                    if(value.contains(sep)){
180
                        value = StringEscapeUtils.escapeHtml3(value);
181
                        value = StringUtils.replace(value, sep, "&#"+((int)(sep.charAt(0)))+";");
182
                        s += sep+"typetagesc"+sep+"html"+sep+tagName+"="+value;
183
                    } else {
184
                        s += sep+"typetag"+sep+tagName+"="+value;
185
                    }
178 186
                }
179 187
            }
180 188
            header[0] = s;
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeatureAttributeDescriptor.java
40 40
import org.apache.commons.lang3.ArrayUtils;
41 41
import org.apache.commons.lang3.StringUtils;
42 42
import org.apache.commons.lang3.tuple.Pair;
43
import org.apache.commons.text.StringEscapeUtils;
43 44
import org.cresques.cts.IProjection;
44 45
import org.gvsig.expressionevaluator.Expression;
45 46
import org.gvsig.expressionevaluator.ExpressionUtils;
......
2088 2089
            builder.append(this.type.getName());
2089 2090
            for (String key : this.sets.keySet()) {
2090 2091
                builder.append(sep);
2091
                builder.append("set");
2092
                builder.append(sep);
2093
                builder.append(key);
2094
                builder.append("=");
2095
                builder.append(this.sets.get(key));
2096
            }
2097
            if( this.tags!=null ) {
2098
                for (String key : this.tags.keySet()) {
2092
                String s = this.sets.get(key);
2093
                if(s.contains(sep)){
2094
                    builder.append("setesc");
2099 2095
                    builder.append(sep);
2100
                    builder.append("tag");
2096
                    builder.append("html");
2101 2097
                    builder.append(sep);
2102 2098
                    builder.append(key);
2103 2099
                    builder.append("=");
2104
                    builder.append(this.tags.get(key));
2100
                    s = StringEscapeUtils.escapeHtml3(s);
2101
                    s = StringUtils.replace(s, sep, "&#"+((int)(sep.charAt(0)))+";");
2102
                    builder.append(s);
2103
                } else {
2104
                    builder.append("set");
2105
                    builder.append(sep);
2106
                    builder.append(key);
2107
                    builder.append("=");
2108
                    builder.append(s);
2105 2109
                }
2110
                
2106 2111
            }
2112
            if( this.tags!=null ) {
2113
                for (String key : this.tags.keySet()) {
2114
                    builder.append(sep);
2115
                    String s = this.tags.get(key);
2116
                    if(s.contains(sep)){
2117
                        builder.append("tagesc");
2118
                        builder.append(sep);
2119
                        builder.append("html");
2120
                        builder.append(sep);
2121
                        builder.append(key);
2122
                        builder.append("=");
2123
                        s = StringEscapeUtils.escapeHtml3(s);
2124
                        s = StringUtils.replace(s, sep, "&#"+((int)(sep.charAt(0)))+";");
2125
                        builder.append(s);
2126
                    } else {
2127
                        builder.append("tag");
2128
                        builder.append(sep);
2129
                        builder.append(key);
2130
                        builder.append("=");
2131
                        builder.append(s);
2132
                    }
2133
                }
2134
            }
2107 2135
            return builder.toString();
2108 2136
        }
2109 2137
    }
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/searchpanel/DefaultSearchPanel.java
1336 1336
                if( selectedRows.length > maxfeatures ) {
1337 1337
                    this.taskStatusController.message("Too many items selecteds");
1338 1338
                }
1339
		if (this.tabResults.getSelectedIndex() == 0) {
1340
                    try {
1341
                            FeatureType ftype = this.store.getDefaultFeatureType();
1342
                            ExpressionBuilder builder = ExpressionUtils.createExpressionBuilder();
1343
                            List<Feature> features = ((SimpleFeaturesTableModelImpl) this.tblResults.getModel()).getFeatures();
1344
                            for (int i = 0; i < selectedRows.length && i<maxfeatures ; i++) {
1345
                                Feature feature = features.get(selectedRows[i]);
1346
                                for (FeatureAttributeDescriptor attrdesc : ftype.getPrimaryKey()) {
1347
                                        builder.or(
1348
                                                builder.eq(
1349
                                                        builder.column(attrdesc.getName()),
1350
                                                        builder.constant(feature.get(attrdesc.getName()))
1351
                                                )
1352
                                        );
1353
                                }
1354
                            }
1355
                            Expression filter = ExpressionUtils.createExpression(builder.toString());                            
1356
                            return filter;
1357
                    } catch (Exception ex) {
1358
                            LOGGER.warn("Can't build search for the selected feature.", ex);
1359
                            return null;
1360
                    }
1361
		} else {
1339
		if (this.tabResults.getSelectedIndex() == 1) {
1362 1340
			if (this.currentPostProcess == null) {
1363 1341
				return null;
1364 1342
			}
......
1383 1361
				LOGGER.warn("Can't build search for the selected feature.", ex);
1384 1362
				return null;
1385 1363
			}
1386
		}
1364
		} else {
1365
                    try {
1366
                            FeatureType ftype = this.store.getDefaultFeatureType();
1367
                            ExpressionBuilder builder = ExpressionUtils.createExpressionBuilder();
1368
                            List<Feature> features = ((SimpleFeaturesTableModelImpl) this.tblResults.getModel()).getFeatures();
1369
                            for (int i = 0; i < selectedRows.length && i<maxfeatures ; i++) {
1370
                                Feature feature = features.get(selectedRows[i]);
1371
                                for (FeatureAttributeDescriptor attrdesc : ftype.getPrimaryKey()) {
1372
                                        builder.or(
1373
                                                builder.eq(
1374
                                                        builder.column(attrdesc.getName()),
1375
                                                        builder.constant(feature.get(attrdesc.getName()))
1376
                                                )
1377
                                        );
1378
                                }
1379
                            }
1380
                            Expression filter = ExpressionUtils.createExpression(builder.toString());                            
1381
                            return filter;
1382
                    } catch (Exception ex) {
1383
                            LOGGER.warn("Can't build search for the selected feature.", ex);
1384
                            return null;
1385
                    }
1386
                }
1387 1387
        }
1388 1388
        
1389 1389
	@Override

Also available in: Unified diff