Revision 44191
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/Expression.java | ||
---|---|---|
36 | 36 |
|
37 | 37 |
public Object execute(SymbolTable symbolTable); |
38 | 38 |
|
39 |
public void link(SymbolTable symbolTable); |
|
40 |
|
|
39 | 41 |
public Code getCode(); |
40 | 42 |
|
41 | 43 |
public String toJSON(); |
... | ... | |
47 | 49 |
public boolean isPhraseEmpty(); |
48 | 50 |
|
49 | 51 |
public boolean isEmpty(); |
52 |
|
|
53 |
public void setSQLCompatible(boolean sqlCompatible); |
|
54 |
|
|
55 |
public boolean isSQLCompatible(); |
|
50 | 56 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/Interpreter.java | ||
---|---|---|
34 | 34 |
@Override |
35 | 35 |
public Interpreter clone() throws CloneNotSupportedException; |
36 | 36 |
|
37 |
public void setSQLCompatible(boolean sqlCompatible); |
|
37 | 38 |
|
39 |
public boolean isSQLCompatible(); |
|
40 |
|
|
38 | 41 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/main/java/org/gvsig/expressionevaluator/impl/DefaultExpression.java | ||
---|---|---|
153 | 153 |
} |
154 | 154 |
|
155 | 155 |
@Override |
156 |
public void setSQLCompatible(boolean sqlCompatible) { |
|
157 |
this.getInterpreter().setSQLCompatible(sqlCompatible); |
|
158 |
} |
|
159 |
|
|
160 |
@Override |
|
161 |
public boolean isSQLCompatible() { |
|
162 |
return this.getInterpreter().isSQLCompatible(); |
|
163 |
} |
|
164 |
|
|
165 |
private Interpreter getInterpreter() { |
|
166 |
if (this.interpreter == null) { |
|
167 |
ExpressionEvaluatorManager manager = ExpressionEvaluatorLocator.getManager(); |
|
168 |
this.interpreter = manager.createInterpreter(); |
|
169 |
} |
|
170 |
return this.interpreter; |
|
171 |
} |
|
172 |
|
|
173 |
@Override |
|
156 | 174 |
public Object execute(SymbolTable symbolTable) { |
157 | 175 |
if (this.interpreter == null) { |
158 | 176 |
ExpressionEvaluatorManager manager = ExpressionEvaluatorLocator.getManager(); |
... | ... | |
169 | 187 |
} |
170 | 188 |
|
171 | 189 |
@Override |
190 |
public void link(SymbolTable symbolTable) { |
|
191 |
if (this.interpreter == null) { |
|
192 |
ExpressionEvaluatorManager manager = ExpressionEvaluatorLocator.getManager(); |
|
193 |
this.interpreter = manager.createInterpreter(); |
|
194 |
} |
|
195 |
this.interpreter.setSymbolTable(symbolTable); |
|
196 |
if( this.hasNotBeenOptimized ) { |
|
197 |
Optimizer optimizer = new DefaultOptimizer(symbolTable); |
|
198 |
this.code = optimizer.optimize(this.getCode()); |
|
199 |
this.hasNotBeenOptimized = false; |
|
200 |
} |
|
201 |
this.interpreter.link(this.getCode()); |
|
202 |
} |
|
203 |
|
|
204 |
@Override |
|
172 | 205 |
public void saveToState(PersistentState state) throws PersistenceException { |
173 | 206 |
state.set("phrase", this.phrase); |
174 | 207 |
if (this.userScript == null) { |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/main/java/org/gvsig/expressionevaluator/impl/function/operator/AddOperator.java | ||
---|---|---|
1 | 1 |
package org.gvsig.expressionevaluator.impl.function.operator; |
2 | 2 |
|
3 |
import java.util.Objects; |
|
3 | 4 |
import org.gvsig.expressionevaluator.Code; |
4 | 5 |
import org.gvsig.expressionevaluator.Code.Caller; |
5 | 6 |
import org.gvsig.expressionevaluator.Code.Constant; |
7 |
import org.gvsig.expressionevaluator.ExpressionRuntimeException; |
|
6 | 8 |
import org.gvsig.expressionevaluator.Function; |
7 | 9 |
import org.gvsig.expressionevaluator.Interpreter; |
8 | 10 |
import org.gvsig.expressionevaluator.Optimizer; |
9 | 11 |
import org.gvsig.expressionevaluator.Optimizer.FunctionOptimizer; |
12 |
import org.gvsig.expressionevaluator.impl.I18N; |
|
10 | 13 |
|
11 | 14 |
public class AddOperator |
12 | 15 |
extends AbstractBinaryOperator |
... | ... | |
43 | 46 |
int value = ((Number) op1).intValue()+ ((Number) op2).intValue(); |
44 | 47 |
return value; |
45 | 48 |
} |
49 |
if( (type & TYPE_STRING) == TYPE_STRING ) { |
|
50 |
if( interpreter.isSQLCompatible() ) { |
|
51 |
throw new ExpressionRuntimeException( |
|
52 |
null, |
|
53 |
"The '"+name()+"' operator can not be used with string operands", |
|
54 |
I18N.Use_the_operator_CONCAT_to_concatenate_strings() |
|
55 |
); |
|
56 |
} |
|
57 |
return Objects.toString(op1, "")+Objects.toString(op2, ""); |
|
58 |
} |
|
46 | 59 |
throw new IllegalArgumentException("Types not allowed in '"+name()+"' operand."); |
47 | 60 |
} |
48 | 61 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/main/java/org/gvsig/expressionevaluator/impl/DefaultInterpreter.java | ||
---|---|---|
6 | 6 |
import java.util.HashMap; |
7 | 7 |
import java.util.List; |
8 | 8 |
import java.util.Map; |
9 |
import java.util.Objects; |
|
9 | 10 |
import org.apache.commons.lang3.tuple.Pair; |
10 | 11 |
import org.gvsig.expressionevaluator.SymbolTable; |
11 | 12 |
import org.gvsig.expressionevaluator.Interpreter; |
... | ... | |
87 | 88 |
private Code currentCode; |
88 | 89 |
private Cache cache; |
89 | 90 |
private int maxRecursionLimit; |
91 |
private boolean sqlCompatible = false; |
|
90 | 92 |
|
91 | 93 |
public DefaultInterpreter() { |
92 | 94 |
this.cache = new DefaultCache(); |
... | ... | |
139 | 141 |
} |
140 | 142 |
|
141 | 143 |
@Override |
144 |
public void setSQLCompatible(boolean sqlCompatible) { |
|
145 |
this.sqlCompatible = sqlCompatible; |
|
146 |
} |
|
147 |
|
|
148 |
@Override |
|
149 |
public boolean isSQLCompatible() { |
|
150 |
return sqlCompatible; |
|
151 |
} |
|
152 |
|
|
153 |
@Override |
|
142 | 154 |
public Object run(Code code) { |
143 | 155 |
try { |
144 | 156 |
return this.runCode(code); |
... | ... | |
220 | 232 |
} |
221 | 233 |
caller.function(function); |
222 | 234 |
} |
235 |
if( !function.isSQLCompatible() && this.sqlCompatible ) { |
|
236 |
throw new ExpressionRuntimeException(code, I18N.Cant_use_non_SQL_compatible_functions(function.name())); |
|
237 |
} |
|
223 | 238 |
Codes args = caller.args(); |
224 | 239 |
try { |
225 | 240 |
switch( caller.type() ) { |
... | ... | |
260 | 275 |
} catch (Exception ex) { |
261 | 276 |
String argsstr = "???"; |
262 | 277 |
try { |
263 |
argsstr = args.toString();
|
|
278 |
argsstr = Objects.toString(args);
|
|
264 | 279 |
} catch(Exception ex2) { |
265 | 280 |
// Ignore. |
266 | 281 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/main/java/org/gvsig/expressionevaluator/impl/I18N.java | ||
---|---|---|
152 | 152 |
return "Maximum recursion limit exceeded."; |
153 | 153 |
} |
154 | 154 |
|
155 |
static String Cant_use_non_SQL_compatible_functions(String name) { |
|
156 |
return String.format("Can't use non-SQL compatible functions (%s)", name); |
|
157 |
} |
|
155 | 158 |
|
159 |
public static String Use_the_operator_CONCAT_to_concatenate_strings() { |
|
160 |
return "Use the operator '||' to concatenate strings."; |
|
161 |
} |
|
162 |
|
|
156 | 163 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.swing/org.gvsig.expressionevaluator.swing.api/src/main/java/org/gvsig/expressionevaluator/swing/ExpressionEvaluatorSwingManager.java | ||
---|---|---|
16 | 16 |
public interface ExpressionEvaluatorSwingManager { |
17 | 17 |
|
18 | 18 |
|
19 |
public List<Element> createElements(Collection<SymbolTable> symbolTables); |
|
19 |
// public List<Element> createElements(Collection<SymbolTable> symbolTables);
|
|
20 | 20 |
|
21 |
public List<Element> createElements(ExpressionBuilderConfig config, Collection<SymbolTable> symbolTables); |
|
22 |
|
|
21 | 23 |
public JExpressionBuilder createJExpressionBuilder(); |
22 | 24 |
|
23 | 25 |
public JExpressionPicker createJExpressionPicker(); |
... | ... | |
34 | 36 |
|
35 | 37 |
public Element createElement(String name, Object... parameters); |
36 | 38 |
|
37 |
public GroupElement createGroupElement(String name); |
|
39 |
// public GroupElement createGroupElement(String name); |
|
40 |
// |
|
41 |
// public GroupElement createGroupElement(String name, List<Element> elements); |
|
42 |
// |
|
43 |
// public FunctionElement createFunctionElement(Function function); |
|
44 |
// |
|
45 |
// public ConstantElement createConstantElement(Object value); |
|
46 |
// |
|
47 |
// public ConstantElement createConstantElement(Object value, String description); |
|
48 |
// |
|
49 |
// public VariableElement createVariableElement(String label, String source, String name, String typeName, String description); |
|
50 |
|
|
51 |
public GroupElement createGroupElement(ExpressionBuilderConfig config, String name); |
|
38 | 52 |
|
39 |
public GroupElement createGroupElement(String name, List<Element> elements); |
|
53 |
public GroupElement createGroupElement(ExpressionBuilderConfig config, String name, List<Element> elements);
|
|
40 | 54 |
|
41 |
public FunctionElement createFunctionElement(Function function); |
|
55 |
public FunctionElement createFunctionElement(ExpressionBuilderConfig config, Function function);
|
|
42 | 56 |
|
43 |
public ConstantElement createConstantElement(Object value); |
|
57 |
public ConstantElement createConstantElement(ExpressionBuilderConfig config, Object value);
|
|
44 | 58 |
|
45 |
public ConstantElement createConstantElement(Object value, String description); |
|
59 |
public ConstantElement createConstantElement(ExpressionBuilderConfig config, Object value, String description);
|
|
46 | 60 |
|
47 |
public VariableElement createVariableElement(String label, String source, String name, String typeName, String description); |
|
61 |
public VariableElement createVariableElement(ExpressionBuilderConfig config, String label, String source, String name, String typeName, String description);
|
|
48 | 62 |
|
49 | 63 |
public ExpressionPickerController createExpressionPickerController(JTextComponent text, JButton button); |
50 | 64 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.swing/org.gvsig.expressionevaluator.swing.api/src/main/java/org/gvsig/expressionevaluator/swing/ExpressionBuilderConfig.java | ||
---|---|---|
45 | 45 |
|
46 | 46 |
public void setPreviewSymbolTable(SymbolTable symbolTable); |
47 | 47 |
|
48 |
public void setSQLCompatible(boolean sqlCompatible); |
|
49 |
|
|
50 |
public boolean isSQLCompatible(); |
|
48 | 51 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.swing/org.gvsig.expressionevaluator.swing.impl/src/main/java/org/gvsig/expressionevaluator/swing/impl/AbstractAutomaticExpressionChecker.java | ||
---|---|---|
41 | 41 |
|
42 | 42 |
private static final Color COLOR_ERROR = new Color(255,225,232); |
43 | 43 |
|
44 |
private JTextComponent text; |
|
45 |
private ExpressionBuilderConfig config; |
|
44 |
private final JTextComponent text;
|
|
45 |
private final ExpressionBuilderConfig config;
|
|
46 | 46 |
|
47 | 47 |
private Color color_ok; |
48 | 48 |
private Timer timerExpression; |
... | ... | |
173 | 173 |
this.setMessage(JOptionPane.ERROR_MESSAGE, "Syntax error in expression"); |
174 | 174 |
return; |
175 | 175 |
} |
176 |
expression.setSQLCompatible(this.config.isSQLCompatible()); |
|
176 | 177 |
if (this.config.getPreviewSymbolTable() == null) { |
177 | 178 |
try { |
178 | 179 |
ExpressionEvaluatorManager theManager = ExpressionEvaluatorLocator.getManager(); |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.swing/org.gvsig.expressionevaluator.swing.impl/src/main/java/org/gvsig/expressionevaluator/swing/impl/DefaultExpressionBuilderConfig.java | ||
---|---|---|
26 | 26 |
private final ExpressionEvaluatorSwingManager manager; |
27 | 27 |
private boolean scriptsEnabled = true; |
28 | 28 |
private SymbolTable previewSymbolTable; |
29 |
private boolean SQLCompatible; |
|
29 | 30 |
|
30 | 31 |
public DefaultExpressionBuilderConfig(ExpressionEvaluatorSwingManager manager) { |
31 | 32 |
this.manager = manager; |
32 | 33 |
this.limit = 6; |
34 |
this.SQLCompatible = false; |
|
33 | 35 |
initSymbolTables(); |
34 | 36 |
} |
35 | 37 |
|
... | ... | |
45 | 47 |
@Override |
46 | 48 |
public List<Element> getElements() { |
47 | 49 |
if (this.elements == null) { |
48 |
this.elements = manager.createElements(this.getSymbolTables()); |
|
50 |
this.elements = manager.createElements(this, this.getSymbolTables());
|
|
49 | 51 |
for (ElementFactory factory : manager.getElementFactories()) { |
50 | 52 |
if (factory.isAutoload()) { |
51 | 53 |
Element e = factory.createElement(); |
... | ... | |
139 | 141 |
this.previewSymbolTable = symbolTable; |
140 | 142 |
} |
141 | 143 |
|
144 |
@Override |
|
145 |
public void setSQLCompatible(boolean SQLCompatible) { |
|
146 |
this.SQLCompatible = SQLCompatible; |
|
147 |
} |
|
148 |
|
|
149 |
@Override |
|
150 |
public boolean isSQLCompatible() { |
|
151 |
return SQLCompatible; |
|
152 |
} |
|
142 | 153 |
|
143 | 154 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.swing/org.gvsig.expressionevaluator.swing.impl/src/main/java/org/gvsig/expressionevaluator/swing/impl/DefaultJExpressionBuilder.java | ||
---|---|---|
665 | 665 |
} |
666 | 666 |
|
667 | 667 |
private void doSelectElement(SimpleElement element) { |
668 |
if( !element.isEnabled() ) { |
|
669 |
this.infoPanel.clean(); |
|
670 |
} else { |
|
668 |
// if( !element.isEnabled() ) {
|
|
669 |
// this.infoPanel.clean();
|
|
670 |
// } else {
|
|
671 | 671 |
this.infoPanel.setDescription(removeCursorMark(element.getDescription())); |
672 | 672 |
this.infoPanel.setAdditionalPanel(element.getAditionalPanel(this)); |
673 | 673 |
this.infoPanel.repaint(); |
674 |
} |
|
674 |
// }
|
|
675 | 675 |
} |
676 | 676 |
|
677 | 677 |
private void updateSimpleElementsList(GroupElement group) { |
... | ... | |
833 | 833 |
public boolean getScriptsEnabled() { |
834 | 834 |
return this.config.getScriptsEnabled(); |
835 | 835 |
} |
836 |
|
|
837 |
@Override |
|
838 |
public void setSQLCompatible(boolean sqlCompatible) { |
|
839 |
this.config.setSQLCompatible(sqlCompatible); |
|
840 |
} |
|
841 |
|
|
842 |
@Override |
|
843 |
public boolean isSQLCompatible() { |
|
844 |
return this.config.isSQLCompatible(); |
|
845 |
} |
|
836 | 846 |
|
837 | 847 |
@Override |
838 | 848 |
public JComponent asJComponent() { |
... | ... | |
840 | 850 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
841 | 851 |
this.treeModel = new ElementsTreeModel( |
842 | 852 |
this.manager.createGroupElement( |
853 |
this.config, |
|
843 | 854 |
i18n.getTranslation("_Elements"), |
844 | 855 |
this.getElements() |
845 | 856 |
) |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.swing/org.gvsig.expressionevaluator.swing.impl/src/main/java/org/gvsig/expressionevaluator/swing/impl/DefaultExpressionPickerController.java | ||
---|---|---|
243 | 243 |
this.config.setPreviewSymbolTable(symbolTable); |
244 | 244 |
} |
245 | 245 |
|
246 |
|
|
246 |
@Override |
|
247 |
public void setSQLCompatible(boolean sqlCompatible) { |
|
248 |
this.config.setSQLCompatible(sqlCompatible); |
|
249 |
} |
|
250 |
|
|
251 |
@Override |
|
252 |
public boolean isSQLCompatible() { |
|
253 |
return this.config.isSQLCompatible(); |
|
254 |
} |
|
255 |
|
|
247 | 256 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.swing/org.gvsig.expressionevaluator.swing.impl/src/main/java/org/gvsig/expressionevaluator/swing/impl/DefaultExpressionEvaluatorSwingManager.java | ||
---|---|---|
21 | 21 |
import org.gvsig.expressionevaluator.swing.Element.GroupElement; |
22 | 22 |
import org.gvsig.expressionevaluator.swing.Element.VariableElement; |
23 | 23 |
import org.gvsig.expressionevaluator.swing.ElementFactory; |
24 |
import org.gvsig.expressionevaluator.swing.ExpressionBuilderConfig; |
|
24 | 25 |
import org.gvsig.expressionevaluator.swing.ExpressionPickerController; |
25 | 26 |
import org.gvsig.expressionevaluator.swing.FunctionAdditionalPanelFactory; |
26 | 27 |
import org.gvsig.expressionevaluator.swing.JExpressionPicker; |
... | ... | |
34 | 35 |
public class DefaultExpressionEvaluatorSwingManager |
35 | 36 |
implements ExpressionEvaluatorSwingManager { |
36 | 37 |
|
37 |
private Map<String, ElementFactory> elementsFactories; |
|
38 |
private Map<String, FunctionAdditionalPanelFactory> functionAdditionalPanelFactories; |
|
38 |
private final Map<String, ElementFactory> elementsFactories;
|
|
39 |
private final Map<String, FunctionAdditionalPanelFactory> functionAdditionalPanelFactories;
|
|
39 | 40 |
|
40 | 41 |
public DefaultExpressionEvaluatorSwingManager() { |
41 | 42 |
this.elementsFactories = new HashMap<>(); |
... | ... | |
43 | 44 |
} |
44 | 45 |
|
45 | 46 |
@Override |
46 |
public List<Element> createElements(Collection<SymbolTable> symbolTables) { |
|
47 |
public List<Element> createElements(ExpressionBuilderConfig config, Collection<SymbolTable> symbolTables) {
|
|
47 | 48 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
48 | 49 |
Map<String, Function> functions = new HashMap<>(); |
49 | 50 |
|
... | ... | |
60 | 61 |
String groupName = function.group(); |
61 | 62 |
GroupElement group = operatorGroups.get(groupName); |
62 | 63 |
if (group == null) { |
63 |
group = new DefaultGroupElement(groupName); |
|
64 |
group = new DefaultGroupElement(config, groupName);
|
|
64 | 65 |
operatorGroups.put(groupName, group); |
65 | 66 |
} |
66 |
group.addElement(new DefaultFunctionElement(function)); |
|
67 |
group.addElement(new DefaultFunctionElement(config, function));
|
|
67 | 68 |
} else { |
68 | 69 |
String groupName = function.group(); |
69 | 70 |
GroupElement group = functionGroups.get(groupName); |
70 | 71 |
if (group == null) { |
71 |
group = new DefaultGroupElement(groupName); |
|
72 |
group = new DefaultGroupElement(config, groupName);
|
|
72 | 73 |
functionGroups.put(groupName, group); |
73 | 74 |
} |
74 |
group.addElement(new DefaultFunctionElement(function)); |
|
75 |
group.addElement(new DefaultFunctionElement(config, function));
|
|
75 | 76 |
} |
76 | 77 |
} |
77 |
GroupElement builtinFunctions = this.createGroupElement(i18n.getTranslation("_Functions")); |
|
78 |
GroupElement builtinFunctions = this.createGroupElement(config, i18n.getTranslation("_Functions"));
|
|
78 | 79 |
for (GroupElement group : functionGroups.values()) { |
79 | 80 |
builtinFunctions.addElement(group); |
80 | 81 |
} |
81 |
GroupElement operatorFunctions = this.createGroupElement(i18n.getTranslation("_Operators")); |
|
82 |
GroupElement operatorFunctions = this.createGroupElement(config, i18n.getTranslation("_Operators"));
|
|
82 | 83 |
for (GroupElement group : operatorGroups.values()) { |
83 | 84 |
operatorFunctions.addElement(group); |
84 | 85 |
} |
... | ... | |
90 | 91 |
|
91 | 92 |
@Override |
92 | 93 |
public void registerElement(ElementFactory factory) { |
93 |
if (this.elementsFactories == null) { |
|
94 |
this.elementsFactories = new HashMap<>(); |
|
95 |
} |
|
96 | 94 |
this.elementsFactories.put(factory.getName().toLowerCase(), factory); |
97 | 95 |
} |
98 | 96 |
|
99 | 97 |
@Override |
100 | 98 |
public Collection<ElementFactory> getElementFactories() { |
101 |
if (this.elementsFactories == null) { |
|
102 |
this.elementsFactories = new HashMap<>(); |
|
103 |
} |
|
104 | 99 |
List<ElementFactory> factories = new ArrayList<>(); |
105 | 100 |
factories.addAll(this.elementsFactories.values()); |
106 | 101 |
Collections.sort(factories, new Comparator<ElementFactory>() { |
... | ... | |
131 | 126 |
} |
132 | 127 |
|
133 | 128 |
@Override |
134 |
public GroupElement createGroupElement(String name) { |
|
135 |
GroupElement e = new DefaultGroupElement(name); |
|
129 |
public GroupElement createGroupElement(ExpressionBuilderConfig config, String name) {
|
|
130 |
GroupElement e = new DefaultGroupElement(config, name);
|
|
136 | 131 |
return e; |
137 | 132 |
} |
138 | 133 |
|
139 | 134 |
@Override |
140 |
public GroupElement createGroupElement(String name, List<Element> elements) { |
|
141 |
GroupElement e = new DefaultGroupElement(this, name, elements); |
|
135 |
public GroupElement createGroupElement(ExpressionBuilderConfig config, String name, List<Element> elements) {
|
|
136 |
GroupElement e = new DefaultGroupElement(this, config, name, elements);
|
|
142 | 137 |
return e; |
143 | 138 |
} |
144 | 139 |
|
145 | 140 |
@Override |
146 |
public FunctionElement createFunctionElement(Function function) { |
|
147 |
FunctionElement e = new DefaultFunctionElement(function); |
|
141 |
public FunctionElement createFunctionElement(ExpressionBuilderConfig config, Function function) {
|
|
142 |
FunctionElement e = new DefaultFunctionElement(config, function);
|
|
148 | 143 |
return e; |
149 | 144 |
} |
150 | 145 |
|
151 | 146 |
@Override |
152 |
public ConstantElement createConstantElement(Object value) { |
|
153 |
ConstantElement e = new DefaultConstantValueElement(value, null); |
|
147 |
public ConstantElement createConstantElement(ExpressionBuilderConfig config, Object value) {
|
|
148 |
ConstantElement e = new DefaultConstantValueElement(config, value, null);
|
|
154 | 149 |
return e; |
155 | 150 |
} |
156 | 151 |
|
157 | 152 |
@Override |
158 |
public ConstantElement createConstantElement(Object value, String description) { |
|
159 |
ConstantElement e = new DefaultConstantValueElement(value, description); |
|
153 |
public ConstantElement createConstantElement(ExpressionBuilderConfig config, Object value, String description) {
|
|
154 |
ConstantElement e = new DefaultConstantValueElement(config, value, description);
|
|
160 | 155 |
return e; |
161 | 156 |
} |
162 | 157 |
|
163 | 158 |
@Override |
164 |
public VariableElement createVariableElement(String label, String source, String name, String typeName, String description) { |
|
165 |
VariableElement e = new DefaultVariableElement(label, source, name, typeName, description); |
|
159 |
public VariableElement createVariableElement(ExpressionBuilderConfig config, String label, String source, String name, String typeName, String description) {
|
|
160 |
VariableElement e = new DefaultVariableElement(config, label, source, name, typeName, description);
|
|
166 | 161 |
return e; |
167 | 162 |
} |
168 | 163 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.swing/org.gvsig.expressionevaluator.swing.impl/src/main/java/org/gvsig/expressionevaluator/swing/impl/DefaultJExpressionPicker.java | ||
---|---|---|
126 | 126 |
public void setPreviewSymbolTable(SymbolTable symbolTable) { |
127 | 127 |
this.controller.setPreviewSymbolTable(symbolTable); |
128 | 128 |
} |
129 |
|
|
129 |
|
|
130 |
@Override |
|
131 |
public void setSQLCompatible(boolean sqlCompatible) { |
|
132 |
this.controller.setSQLCompatible(sqlCompatible); |
|
133 |
} |
|
134 |
|
|
135 |
@Override |
|
136 |
public boolean isSQLCompatible() { |
|
137 |
return this.controller.isSQLCompatible(); |
|
138 |
} |
|
130 | 139 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.swing/org.gvsig.expressionevaluator.swing.impl/src/main/java/org/gvsig/expressionevaluator/swing/impl/elements/DefaultGroupElement.java | ||
---|---|---|
11 | 11 |
import org.gvsig.expressionevaluator.Function; |
12 | 12 |
import org.gvsig.expressionevaluator.swing.Element; |
13 | 13 |
import org.gvsig.expressionevaluator.swing.Element.GroupElement; |
14 |
import org.gvsig.expressionevaluator.swing.ExpressionBuilderConfig; |
|
14 | 15 |
import org.gvsig.expressionevaluator.swing.spi.AbstractElement; |
15 | 16 |
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingManager; |
16 |
import org.gvsig.tools.ToolsLocator; |
|
17 |
import org.gvsig.tools.i18n.I18nManager; |
|
18 | 17 |
|
19 | 18 |
/** |
20 | 19 |
* |
... | ... | |
25 | 24 |
implements GroupElement |
26 | 25 |
{ |
27 | 26 |
|
28 |
final List<Element> elements; |
|
29 |
ExpressionEvaluatorSwingManager manager; |
|
27 |
final private List<Element> elements; |
|
28 |
final private ExpressionBuilderConfig config; |
|
29 |
private ExpressionEvaluatorSwingManager manager; |
|
30 | 30 |
|
31 |
public DefaultGroupElement(ExpressionEvaluatorSwingManager manager, String name, List<Element> elements) { |
|
31 |
public DefaultGroupElement(ExpressionEvaluatorSwingManager manager, ExpressionBuilderConfig config, String name, List<Element> elements) {
|
|
32 | 32 |
super(name, "expressionbuilder-element-group"); |
33 | 33 |
this.manager = manager; |
34 | 34 |
this.elements = elements; |
35 |
this.config = config; |
|
35 | 36 |
} |
36 | 37 |
|
37 |
public DefaultGroupElement(String name) { |
|
38 |
public DefaultGroupElement(ExpressionBuilderConfig config, String name) {
|
|
38 | 39 |
super(name, "expressionbuilder-element-group"); |
40 |
this.config = config; |
|
39 | 41 |
this.elements = new ArrayList<>(); |
40 | 42 |
} |
41 | 43 |
|
... | ... | |
66 | 68 |
|
67 | 69 |
@Override |
68 | 70 |
public void addElement(Function function) { |
69 |
Element item = this.manager.createConstantElement(function); |
|
71 |
Element item = this.manager.createConstantElement(this.config, function);
|
|
70 | 72 |
this.addElement(item); |
71 | 73 |
} |
72 | 74 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.swing/org.gvsig.expressionevaluator.swing.impl/src/main/java/org/gvsig/expressionevaluator/swing/impl/elements/DefaultFunctionElement.java | ||
---|---|---|
9 | 9 |
import org.apache.commons.lang3.StringUtils; |
10 | 10 |
import org.gvsig.expressionevaluator.Function; |
11 | 11 |
import org.gvsig.expressionevaluator.swing.Element.FunctionElement; |
12 |
import org.gvsig.expressionevaluator.swing.ExpressionBuilderConfig; |
|
12 | 13 |
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingLocator; |
13 | 14 |
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingManager; |
14 | 15 |
import org.gvsig.expressionevaluator.swing.FunctionAdditionalPanelFactory; |
... | ... | |
27 | 28 |
implements FunctionElement { |
28 | 29 |
|
29 | 30 |
private final Function function; |
31 |
private final ExpressionBuilderConfig config; |
|
30 | 32 |
|
31 |
public DefaultFunctionElement(Function function) { |
|
33 |
public DefaultFunctionElement(ExpressionBuilderConfig config, Function function) {
|
|
32 | 34 |
super( |
33 | 35 |
function.name(), |
34 | 36 |
function.isSQLCompatible() |
... | ... | |
36 | 38 |
: "expressionbuilder-element-function" |
37 | 39 |
); |
38 | 40 |
this.function = function; |
41 |
this.config = config; |
|
39 | 42 |
} |
40 | 43 |
|
41 | 44 |
@Override |
... | ... | |
44 | 47 |
} |
45 | 48 |
|
46 | 49 |
@Override |
50 |
public boolean isEnabled() { |
|
51 |
if( this.config.isSQLCompatible() ) { |
|
52 |
return this.function.isSQLCompatible(); |
|
53 |
} |
|
54 |
return true; |
|
55 |
} |
|
56 |
|
|
57 |
@Override |
|
47 | 58 |
public Component getAditionalPanel(JExpressionBuilder expressionBuilder) { |
48 | 59 |
ExpressionEvaluatorSwingManager manager = ExpressionEvaluatorSwingLocator.getManager(); |
49 | 60 |
FunctionAdditionalPanelFactory factory = manager.getFunctionAdditionalPanelFactory(this.function.name()); |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.swing/org.gvsig.expressionevaluator.swing.impl/src/main/java/org/gvsig/expressionevaluator/swing/impl/elements/DefaultVariableElement.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import org.apache.commons.lang3.StringUtils; |
4 | 4 |
import org.gvsig.expressionevaluator.swing.Element.VariableElement; |
5 |
import org.gvsig.expressionevaluator.swing.ExpressionBuilderConfig; |
|
5 | 6 |
import org.gvsig.expressionevaluator.swing.spi.AbstractElement; |
6 | 7 |
import org.gvsig.tools.ToolsLocator; |
7 | 8 |
import org.gvsig.tools.i18n.I18nManager; |
... | ... | |
18 | 19 |
private final String source; |
19 | 20 |
private final String typeName; |
20 | 21 |
private final String description; |
22 |
private final ExpressionBuilderConfig config; |
|
21 | 23 |
|
22 |
public DefaultVariableElement(String label, String source, String name, String typeName, String description) { |
|
24 |
public DefaultVariableElement(ExpressionBuilderConfig config, String label, String source, String name, String typeName, String description) {
|
|
23 | 25 |
super(name, "expressionbuilder-element"); |
24 | 26 |
this.description = description; |
25 | 27 |
this.label = label; |
26 | 28 |
this.source = source; |
27 | 29 |
this.typeName = typeName; |
30 |
this.config = config; |
|
28 | 31 |
} |
29 | 32 |
|
30 | 33 |
@Override |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.swing/org.gvsig.expressionevaluator.swing.impl/src/main/java/org/gvsig/expressionevaluator/swing/impl/elements/DefaultConstantValueElement.java | ||
---|---|---|
7 | 7 |
|
8 | 8 |
import java.util.Objects; |
9 | 9 |
import org.gvsig.expressionevaluator.swing.Element.ConstantElement; |
10 |
import org.gvsig.expressionevaluator.swing.ExpressionBuilderConfig; |
|
10 | 11 |
import org.gvsig.expressionevaluator.swing.impl.Utils; |
11 | 12 |
import org.gvsig.expressionevaluator.swing.spi.AbstractElement; |
12 | 13 |
import org.gvsig.tools.ToolsLocator; |
... | ... | |
21 | 22 |
implements ConstantElement { |
22 | 23 |
|
23 | 24 |
private final Object value; |
25 |
private final ExpressionBuilderConfig config; |
|
24 | 26 |
|
25 |
public DefaultConstantValueElement(Object value, String description) { |
|
27 |
public DefaultConstantValueElement(ExpressionBuilderConfig config, Object value, String description) {
|
|
26 | 28 |
super(Objects.toString(value, ""), "expressionbuilder-element-constant"); |
27 | 29 |
this.value = value; |
30 |
this.config = config; |
|
28 | 31 |
} |
29 | 32 |
|
30 | 33 |
@Override |
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/featuretype/DefaultFeatureTypeAttributePanel.java | ||
---|---|---|
626 | 626 |
this.cboFieldType.setEnabled(editable); |
627 | 627 |
this.cboGeometryType.setEnabled(editable); |
628 | 628 |
this.cboGeometrySubtype.setEnabled(editable); |
629 |
this.pickerCRS.setEditable(editable); |
|
629 | 630 |
|
630 | 631 |
} |
631 | 632 |
|
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/DefaultDataSwingManager.java | ||
---|---|---|
38 | 38 |
import org.gvsig.featureform.swing.impl.DefaultJFeaturesForm; |
39 | 39 |
import org.gvsig.fmap.dal.DALLocator; |
40 | 40 |
import org.gvsig.fmap.dal.DataManager; |
41 |
import org.gvsig.fmap.dal.DataStoreProvider; |
|
42 |
import org.gvsig.fmap.dal.DataStoreProviderFactory; |
|
41 | 43 |
import org.gvsig.fmap.dal.exception.DataException; |
42 | 44 |
import org.gvsig.fmap.dal.expressionevaluator.FeatureSymbolTable; |
43 | 45 |
import org.gvsig.fmap.dal.feature.Feature; |
... | ... | |
122 | 124 |
featureSymbolTable.setFeature(sampleFeature); |
123 | 125 |
builder.setPreviewSymbolTable(featureSymbolTable.createParent()); |
124 | 126 |
} |
125 |
builder.addElement( |
|
126 |
swingManager.createElement( |
|
127 |
DataSwingManager.FEATURE_STORE_EXPRESSION_ELEMENT, |
|
128 |
builder, |
|
129 |
store |
|
130 |
) |
|
131 |
); |
|
127 |
builder.addElement(new DefaultFeatureStoreElement(builder, store)); |
|
128 |
if( store.getProviderFactory().hasSQLSupport()==DataStoreProviderFactory.YES ) { |
|
129 |
builder.setSQLCompatible(true); |
|
130 |
} |
|
132 | 131 |
return builder; |
133 | 132 |
} |
134 | 133 |
|
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/expressionevaluator/DefaultFeatureStoreElement.java | ||
---|---|---|
29 | 29 |
private FeatureStore store; |
30 | 30 |
private FeatureType type; |
31 | 31 |
private List<Element> elements; |
32 |
final ExpressionBuilderConfig configPanel;
|
|
32 |
private final ExpressionBuilderConfig config;
|
|
33 | 33 |
private String myName; |
34 | 34 |
|
35 | 35 |
@SuppressWarnings("OverridableMethodCallInConstructor") |
36 |
public DefaultFeatureStoreElement(ExpressionBuilderConfig configPanel, FeatureStore store) {
|
|
36 |
public DefaultFeatureStoreElement(ExpressionBuilderConfig config, FeatureStore store) { |
|
37 | 37 |
super("store", "expressionbuilder-element-table"); |
38 |
this.configPanel = configPanel;
|
|
38 |
this.config = config;
|
|
39 | 39 |
if( store!=null ) { |
40 | 40 |
this.setFeatureStore(store); |
41 | 41 |
} |
... | ... | |
61 | 61 |
} |
62 | 62 |
return this.store.getName(); |
63 | 63 |
} |
64 |
|
|
65 |
|
|
66 | 64 |
|
67 | 65 |
@Override |
68 | 66 |
public int size() { |
... | ... | |
110 | 108 |
this.elements = new ArrayList<>(); |
111 | 109 |
for (FeatureAttributeDescriptor attrdesc : type) { |
112 | 110 |
this.elements.add(new FeatureAttributeElement( |
113 |
this.configPanel,
|
|
111 |
this.config, |
|
114 | 112 |
this.store, |
115 | 113 |
attrdesc |
116 | 114 |
) |
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/expressionevaluator/FeatureAttributeElement.java | ||
---|---|---|
116 | 116 |
} |
117 | 117 |
this.elements = new ArrayList<>(); |
118 | 118 |
for (Object value : values) { |
119 |
this.elements.add(manager.createConstantElement(value)); |
|
119 |
this.elements.add(manager.createConstantElement(this.configPanel, value));
|
|
120 | 120 |
} |
121 | 121 |
} |
122 | 122 |
return this.elements; |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/expressionevaluator/ExpressionEvaluator.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.expressionevaluator; |
|
2 |
|
|
3 |
import org.gvsig.expressionevaluator.Expression; |
|
4 |
import org.gvsig.expressionevaluator.SymbolTable; |
|
5 |
import org.gvsig.tools.evaluator.EvaluatorWithDescriptions; |
|
6 |
|
|
7 |
/** |
|
8 |
* |
|
9 |
* @author jjdelcerro |
|
10 |
*/ |
|
11 |
public interface ExpressionEvaluator extends EvaluatorWithDescriptions { |
|
12 |
|
|
13 |
/** |
|
14 |
* Get a SQL representation of the evaluator. |
|
15 |
* |
|
16 |
* This funcion can return a non-sql compatible expression. |
|
17 |
* |
|
18 |
* @return the SQL string. |
|
19 |
*/ |
|
20 |
@Override |
|
21 |
public String getSQL(); |
|
22 |
|
|
23 |
public Expression getExpression(); |
|
24 |
|
|
25 |
public SymbolTable getSymbolTable(); |
|
26 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/DataStoreProviderFactory.java | ||
---|---|---|
89 | 89 |
*/ |
90 | 90 |
public int hasRasterSupport(); |
91 | 91 |
|
92 |
public int hasSQLSupport(); |
|
93 |
|
|
92 | 94 |
/** |
93 | 95 |
* Builds a specific provider |
94 | 96 |
* |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.spi/src/main/java/org/gvsig/fmap/dal/spi/AbstractDataStoreProviderFactory.java | ||
---|---|---|
85 | 85 |
} |
86 | 86 |
|
87 | 87 |
@Override |
88 |
public int hasSQLSupport() { |
|
89 |
return UNKNOWN; |
|
90 |
} |
|
91 |
|
|
92 |
@Override |
|
88 | 93 |
public int worksBestTiled() { |
89 | 94 |
return UNKNOWN; |
90 | 95 |
} |
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/DefaultFeatureStore.java | ||
---|---|---|
647 | 647 |
); |
648 | 648 |
setProvider(prov); |
649 | 649 |
} catch(Throwable th) { |
650 |
LOG.warn("Can't load store from state.", th); |
|
650 | 651 |
state.setBreakingsCause(th); |
651 | 652 |
} |
652 | 653 |
try { |
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/featureset/DefaultFeatureSet.java | ||
---|---|---|
550 | 550 |
|
551 | 551 |
if (useMyOrder) { |
552 | 552 |
if (useMyFilter) { |
553 |
return ORDERED_FILTERED;// ORDERED_FILTERED;
|
|
553 |
return ORDERED_FILTERED; |
|
554 | 554 |
} else { |
555 |
return ORDERED;// ORDERED;
|
|
555 |
return ORDERED; |
|
556 | 556 |
} |
557 | 557 |
} else { |
558 | 558 |
if (useMyFilter) { |
559 |
return FILTERED;// FILTERED;
|
|
559 |
return FILTERED; |
|
560 | 560 |
} else { |
561 |
return DEFAULT;// DEFAULT;
|
|
561 |
return DEFAULT; |
|
562 | 562 |
} |
563 | 563 |
} |
564 | 564 |
} |
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/impl/expressionevaluator/DefaultExpressionEvaluator.java | ||
---|---|---|
10 | 10 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator; |
11 | 11 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorManager; |
12 | 12 |
import org.gvsig.expressionevaluator.Function; |
13 |
import org.gvsig.fmap.dal.expressionevaluator.ExpressionEvaluator; |
|
13 | 14 |
import org.gvsig.fmap.dal.expressionevaluator.FeatureSymbolTable; |
14 | 15 |
import org.gvsig.fmap.dal.feature.Feature; |
15 | 16 |
import org.gvsig.tools.evaluator.AbstractEvaluator; |
... | ... | |
17 | 18 |
import org.gvsig.tools.evaluator.EvaluatorData; |
18 | 19 |
import org.gvsig.tools.evaluator.EvaluatorException; |
19 | 20 |
import org.gvsig.tools.evaluator.EvaluatorFieldsInfo; |
20 |
import org.gvsig.tools.evaluator.EvaluatorWithDescriptions; |
|
21 | 21 |
import org.gvsig.tools.exception.BaseException; |
22 | 22 |
import org.gvsig.tools.visitor.VisitCanceledException; |
23 | 23 |
import org.gvsig.tools.visitor.Visitor; |
24 | 24 |
import org.gvsig.tools.lang.Cloneable; |
25 |
import org.slf4j.Logger; |
|
26 |
import org.slf4j.LoggerFactory; |
|
25 | 27 |
|
28 |
@SuppressWarnings("UseSpecificCatch") |
|
26 | 29 |
public class DefaultExpressionEvaluator |
27 | 30 |
extends AbstractEvaluator |
28 |
implements EvaluatorWithDescriptions, Cloneable
|
|
31 |
implements ExpressionEvaluator, Cloneable
|
|
29 | 32 |
{ |
30 | 33 |
|
34 |
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultExpressionEvaluator.class); |
|
35 |
|
|
31 | 36 |
private static class DescriptionAdapter implements Description { |
32 | 37 |
|
33 | 38 |
Function function; |
... | ... | |
100 | 105 |
} |
101 | 106 |
|
102 | 107 |
@Override |
108 |
public String getName() { |
|
109 |
return "Genereric expression"; |
|
110 |
} |
|
111 |
|
|
112 |
@Override |
|
113 |
public String getDescription() { |
|
114 |
return this.expression.getPhrase(); |
|
115 |
} |
|
116 |
|
|
117 |
@Override |
|
118 |
public String getSQL() { |
|
119 |
return this.expression.getPhrase(); |
|
120 |
} |
|
121 |
|
|
122 |
@Override |
|
123 |
public Expression getExpression() { |
|
124 |
return expression; |
|
125 |
} |
|
126 |
|
|
127 |
@Override |
|
128 |
public SymbolTable getSymbolTable() { |
|
129 |
return this.symbolTable; |
|
130 |
} |
|
131 |
|
|
132 |
@Override |
|
103 | 133 |
public Object evaluate(EvaluatorData data) throws EvaluatorException { |
104 | 134 |
this.featureSymbolTable.setFeature((Feature) data); |
105 | 135 |
Object v = this.expression.execute(this.symbolTable); |
... | ... | |
107 | 137 |
} |
108 | 138 |
|
109 | 139 |
@Override |
110 |
public String getName() { |
|
111 |
return "Genereric expression"; |
|
112 |
} |
|
113 |
|
|
114 |
@Override |
|
115 | 140 |
public EvaluatorFieldsInfo getFieldsInfo() { |
116 | 141 |
final Set<String> names = new HashSet<>(); |
117 | 142 |
try { |
... | ... | |
162 | 187 |
return availableFunctions; |
163 | 188 |
} |
164 | 189 |
|
165 |
private SymbolTable getSymbolTable() { |
|
166 |
return this.symbolTable; |
|
167 |
} |
|
168 |
|
|
169 | 190 |
@Override |
170 | 191 |
public Evaluator clone() throws CloneNotSupportedException { |
171 | 192 |
DefaultExpressionEvaluator other = (DefaultExpressionEvaluator) super.clone(); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/impl/JDBCStoreProviderFactory.java | ||
---|---|---|
51 | 51 |
public int hasTabularSupport() { |
52 | 52 |
return YES; |
53 | 53 |
} |
54 |
|
|
55 |
@Override |
|
56 |
public int hasSQLSupport() { |
|
57 |
return YES; |
|
58 |
} |
|
54 | 59 |
|
55 | 60 |
protected JDBCStoreProviderFactory(String name, String description) { |
56 | 61 |
super(name, description); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/impl/JDBCSetProvider.java | ||
---|---|---|
27 | 27 |
import java.util.NoSuchElementException; |
28 | 28 |
import org.apache.commons.collections.CollectionUtils; |
29 | 29 |
import org.apache.commons.lang3.BooleanUtils; |
30 |
import org.apache.commons.lang3.StringUtils; |
|
31 |
|
|
32 |
import org.gvsig.fmap.dal.DataTypes; |
|
33 | 30 |
import org.gvsig.fmap.dal.exception.DataException; |
34 | 31 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
35 |
import org.gvsig.fmap.dal.feature.FeatureQueryOrder.FeatureQueryOrderMember; |
|
36 | 32 |
import org.gvsig.fmap.dal.feature.FeatureType; |
37 | 33 |
|
38 | 34 |
import org.gvsig.fmap.dal.feature.spi.AbstractFeatureSetProvider; |
... | ... | |
48 | 44 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.ResultSetForSetProviderOperation; |
49 | 45 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.CountOperation; |
50 | 46 |
import org.gvsig.tools.evaluator.Evaluator; |
51 |
import org.gvsig.tools.evaluator.EvaluatorFieldsInfo; |
|
52 | 47 |
import org.gvsig.tools.exception.BaseException; |
53 | 48 |
import org.slf4j.Logger; |
54 | 49 |
import org.slf4j.LoggerFactory; |
... | ... | |
138 | 133 |
|
139 | 134 |
@Override |
140 | 135 |
public boolean canFilter() { |
141 |
// No podemos filtrar si: |
|
142 |
// - Hay una subquery especificada en los parametros |
|
143 |
// - Si no soportamos geometrias y hay un filtro espacial. |
|
144 |
// |
|
145 |
if (this.getHelper().useSubquery()) { |
|
146 |
return false; |
|
147 |
} |
|
148 |
if( this.getHelper().hasSpatialFunctions() ) { |
|
149 |
// Como soportamos filtros espaciales, podremos hacer cualquier |
|
150 |
// filtro que se especifique, sea alfanumerico o espacial. |
|
151 |
return true; |
|
152 |
} |
|
153 |
|
|
154 |
// No se soportan filtros espaciales. |
|
155 |
// Si se esta filtrando por un campo Geometria, retornamos false |
|
156 |
|
|
157 |
Evaluator filter = getQuery().getFilter(); |
|
158 |
if (filter == null) { |
|
159 |
return true; |
|
160 |
} |
|
161 |
|
|
162 |
String sql = filter.getSQL(); |
|
163 |
if (StringUtils.isEmpty(sql)) { |
|
164 |
return true; |
|
165 |
} |
|
166 |
|
|
167 |
EvaluatorFieldsInfo fInfo = filter.getFieldsInfo(); |
|
168 |
if (fInfo == null ) { |
|
169 |
return true; |
|
170 |
} |
|
171 |
String[] names = fInfo.getFieldNames(); |
|
172 |
if ( names == null) { |
|
173 |
return true; |
|
174 |
} |
|
175 |
|
|
176 |
for (String name : names) { |
|
177 |
int type = this.getFeatureType() |
|
178 |
.getAttributeDescriptor(name) |
|
179 |
.getType(); |
|
180 |
if( type == DataTypes.GEOMETRY ) { |
|
181 |
return false; |
|
182 |
} |
|
183 |
} |
|
184 |
return true; |
|
136 |
return this.getHelper().supportFilter(getQuery().getFilter()); |
|
185 | 137 |
} |
186 | 138 |
|
187 | 139 |
@Override |
188 | 140 |
public boolean canOrder() { |
189 |
// No podemos ordenar si: |
|
190 |
// - Hay una subquery especificada en los parametros |
|
191 |
// - Si no soportamos geometrias y hay un filtro espacial. |
|
192 |
// |
|
193 |
if (this.getHelper().useSubquery()) { |
|
194 |
return false; |
|
195 |
} |
|
196 |
if( this.getHelper().hasSpatialFunctions() ) { |
|
197 |
// Como soportamos filtros espaciales, podremos hacer cualquier |
|
198 |
// filtro que se especifique, sea alfanumerico o espacial. |
|
199 |
return true; |
|
200 |
} |
|
201 |
|
|
202 |
FeatureQuery query = getQuery(); |
|
203 |
if (!query.hasOrder()) { |
|
204 |
return true; |
|
205 |
} |
|
206 |
for( FeatureQueryOrderMember member : query.getOrder().members() ) { |
|
207 |
if (member.hasEvaluator()) { |
|
208 |
String sql = member.getEvaluator().getSQL(); |
|
209 |
if ( StringUtils.isEmpty(sql) ) { |
|
210 |
return false; |
|
211 |
} |
|
212 |
} |
|
213 |
} |
|
214 |
return true; |
|
141 |
return this.getHelper().supportOrder(getQuery().getOrder()); |
|
215 | 142 |
} |
216 | 143 |
|
217 | 144 |
public ResulSetControler getResulSetControler() { |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/impl/ResulSetControlerBase.java | ||
---|---|---|
202 | 202 |
} catch (SQLException e) { |
203 | 203 |
JDBCUtils.closeQuietly(rs); |
204 | 204 |
JDBCUtils.closeQuietly(st); |
205 |
JDBCUtils.closeQuietly(conn);
|
|
205 |
this.helper.closeConnectionQuietly(conn);
|
|
206 | 206 |
throw new JDBCExecutePreparedSQLException(sql, values, e); |
207 | 207 |
} finally { |
208 | 208 |
DisposeUtils.disposeQuietly(paramsDisposer); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/JDBCHelper.java | ||
---|---|---|
7 | 7 |
import org.gvsig.fmap.dal.exception.DataException; |
8 | 8 |
import org.gvsig.fmap.dal.exception.InitializeException; |
9 | 9 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
10 |
import org.gvsig.fmap.dal.feature.FeatureQueryOrder; |
|
10 | 11 |
import org.gvsig.fmap.dal.feature.FeatureType; |
11 | 12 |
import org.gvsig.fmap.dal.feature.spi.FeatureProvider; |
12 | 13 |
import org.gvsig.fmap.dal.resource.exception.AccessResourceException; |
... | ... | |
21 | 22 |
import org.gvsig.fmap.geom.Geometry; |
22 | 23 |
import org.gvsig.fmap.geom.GeometryManager; |
23 | 24 |
import org.gvsig.fmap.dal.store.jdbc2.spi.SRSSolver; |
25 |
import org.gvsig.tools.evaluator.Evaluator; |
|
24 | 26 |
|
25 | 27 |
public interface JDBCHelper extends AutoCloseable { |
26 | 28 |
|
... | ... | |
91 | 93 |
*/ |
92 | 94 |
public boolean hasSpatialFunctions(); |
93 | 95 |
|
96 |
public boolean supportFilter(Evaluator evaluator); |
|
97 |
|
|
98 |
public boolean supportOrder(FeatureQueryOrder order); |
|
99 |
|
|
100 |
public boolean allowNestedOperations(); |
|
94 | 101 |
/** |
95 | 102 |
* Indica si podemos escribir el tipo de geometria indicado. |
96 | 103 |
* |
... | ... | |
111 | 118 |
|
112 | 119 |
public JDBCConnectionParameters getConnectionParameters(); |
113 | 120 |
|
114 |
public void closeConnection( |
|
115 |
Connection connection |
|
116 |
); |
|
121 |
public void closeConnection(Connection connection); |
|
117 | 122 |
|
123 |
public void closeConnectionQuietly(Connection connection); |
|
124 |
|
|
118 | 125 |
public GeometryManager getGeometryManager(); |
119 | 126 |
|
120 | 127 |
public ResulSetControler getResulSetControler(); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/JDBCUtils.java | ||
---|---|---|
7 | 7 |
import java.sql.Statement; |
8 | 8 |
import java.util.Iterator; |
9 | 9 |
import java.util.List; |
10 |
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCSQLException; |
|
11 | 10 |
import org.slf4j.Logger; |
12 | 11 |
import org.slf4j.LoggerFactory; |
13 | 12 |
|
13 |
@SuppressWarnings("UseSpecificCatch") |
|
14 | 14 |
public class JDBCUtils { |
15 | 15 |
|
16 |
private static final Logger logger = LoggerFactory.getLogger(JDBCUtils.class);
|
|
16 |
private static final Logger LOGGER = LoggerFactory.getLogger(JDBCUtils.class);
|
|
17 | 17 |
|
18 | 18 |
private JDBCUtils() { |
19 | 19 |
|
20 | 20 |
} |
21 | 21 |
|
22 | 22 |
public static ResultSet executeQuery(Statement st, String sql) throws SQLException { |
23 |
logger.debug("execute query SQL: " + sql);
|
|
23 |
LOGGER.debug("execute query SQL: " + sql);
|
|
24 | 24 |
try { |
25 | 25 |
ResultSet rs = st.executeQuery(sql); |
26 | 26 |
return rs; |
27 | 27 |
} catch(Exception ex) { |
28 |
logger.warn("execute SQL: " + sql, ex);
|
|
28 |
LOGGER.warn("execute SQL: " + sql, ex);
|
|
29 | 29 |
throw ex; |
30 | 30 |
} |
31 | 31 |
} |
32 | 32 |
|
33 | 33 |
public static void execute(Statement st, String sql) throws SQLException { |
34 |
logger.debug("execute SQL: " + sql);
|
|
34 |
LOGGER.debug("execute SQL: " + sql);
|
|
35 | 35 |
try { |
36 | 36 |
st.execute(sql); |
37 | 37 |
} catch(Exception ex) { |
38 |
logger.warn("execute SQL: " + sql, ex);
|
|
38 |
LOGGER.warn("execute SQL: " + sql, ex);
|
|
39 | 39 |
throw ex; |
40 | 40 |
} |
41 | 41 |
} |
42 | 42 |
|
43 | 43 |
public static void execute(Connection connection, String sql) throws SQLException { |
44 |
logger.debug("execute SQL: " + sql);
|
|
44 |
LOGGER.debug("execute SQL: " + sql);
|
|
45 | 45 |
Statement st = connection.createStatement(); |
46 | 46 |
try { |
47 | 47 |
st.execute(sql); |
48 | 48 |
} catch(Exception ex) { |
49 |
logger.warn("execute SQL: " + sql, ex);
|
|
49 |
LOGGER.warn("execute SQL: " + sql, ex);
|
|
50 | 50 |
throw ex; |
51 | 51 |
} |
52 | 52 |
} |
... | ... | |
59 | 59 |
Iterator<String> it = sqls.iterator(); |
60 | 60 |
while( it.hasNext() ) { |
61 | 61 |
sql = it.next(); |
62 |
logger.debug("execute SQL: " + sql);
|
|
62 |
LOGGER.debug("execute SQL: " + sql);
|
|
63 | 63 |
st.execute(sql); |
64 | 64 |
} |
65 | 65 |
} catch (SQLException ex) { |
66 |
logger.warn("execute SQL: " + sql, ex);
|
|
66 |
LOGGER.warn("execute SQL: " + sql, ex);
|
|
67 | 67 |
throw ex; |
68 | 68 |
} finally { |
69 | 69 |
JDBCUtils.closeQuietly(st); |
... | ... | |
71 | 71 |
} |
72 | 72 |
|
73 | 73 |
public static ResultSet executeQuery(PreparedStatement st, String sql) throws SQLException { |
74 |
logger.debug("execute query SQL: " + sql);
|
|
74 |
LOGGER.debug("execute query SQL: " + sql);
|
|
75 | 75 |
try { |
76 | 76 |
ResultSet rs = st.executeQuery(); |
77 | 77 |
return rs; |
78 | 78 |
} catch(Exception ex) { |
79 |
logger.warn("execute SQL: " + sql, ex);
|
|
79 |
LOGGER.warn("execute SQL: " + sql, ex);
|
|
80 | 80 |
throw ex; |
81 | 81 |
} |
82 | 82 |
} |
83 | 83 |
|
84 | 84 |
public static void execute(PreparedStatement st, String sql) throws SQLException { |
85 |
logger.debug("execute SQL: " + sql);
|
|
85 |
LOGGER.debug("execute SQL: " + sql);
|
|
86 | 86 |
try { |
87 | 87 |
st.execute(); |
88 | 88 |
} catch(Exception ex) { |
89 |
logger.warn("execute SQL: " + sql, ex);
|
|
89 |
LOGGER.warn("execute SQL: " + sql, ex);
|
|
90 | 90 |
throw ex; |
91 | 91 |
} |
92 | 92 |
} |
93 | 93 |
|
94 | 94 |
public static int executeUpdate(PreparedStatement st, String sql) throws SQLException { |
95 |
logger.debug("execute update SQL: "+ sql);
|
|
95 |
LOGGER.debug("execute update SQL: "+ sql);
|
|
96 | 96 |
try { |
97 | 97 |
return st.executeUpdate(); |
98 | 98 |
} catch(Exception ex) { |
99 |
logger.warn("execute SQL: " + sql, ex);
|
|
99 |
LOGGER.warn("execute SQL: " + sql, ex);
|
|
100 | 100 |
throw ex; |
101 | 101 |
} |
102 | 102 |
} |
... | ... | |
108 | 108 |
try { |
109 | 109 |
obj.close(); |
110 | 110 |
} catch (Exception e) { |
111 |
logger.warn("Problems closing " + obj.getClass().getSimpleName() + " '" + obj.toString() + "'.", e);
|
|
111 |
LOGGER.warn("Problems closing " + obj.getClass().getSimpleName() + " '" + obj.toString() + "'.", e);
|
|
112 | 112 |
} |
113 | 113 |
} |
114 | 114 |
|
... | ... | |
119 | 119 |
try { |
120 | 120 |
obj.close(); |
121 | 121 |
} catch (Exception e) { |
122 |
logger.warn("Problems closing " + obj.getClass().getSimpleName() + " '" + obj.toString() + "'.", e);
|
|
122 |
LOGGER.warn("Problems closing " + obj.getClass().getSimpleName() + " '" + obj.toString() + "'.", e);
|
|
123 | 123 |
} |
124 | 124 |
} |
125 | 125 |
|
126 |
public static void closeQuietly(Connection obj) {
|
|
127 |
if (obj == null) {
|
|
126 |
public static void closeQuietly(Connection conn) {
|
|
127 |
if (conn == null) {
|
|
128 | 128 |
return; |
129 | 129 |
} |
130 |
LOGGER.debug("Closing connection "+ conn.hashCode() + " ("+conn.toString()+")"); |
|
130 | 131 |
try { |
131 |
obj.close();
|
|
132 |
conn.close();
|
|
132 | 133 |
} catch (Exception e) { |
133 |
logger.warn("Problems closing " + obj.getClass().getSimpleName() + " '" + obj.toString() + "'.", e);
|
|
134 |
LOGGER.warn("Problems closing " + conn.getClass().getSimpleName() + " '" + conn.toString() + "'.", e);
|
|
134 | 135 |
} |
135 | 136 |
} |
136 | 137 |
|
... | ... | |
139 | 140 |
return; |
140 | 141 |
} |
141 | 142 |
try { |
143 |
LOGGER.debug("Closing " + obj.getClass().getSimpleName() + " "+ obj.hashCode() + " ("+obj.toString()+")"); |
|
142 | 144 |
obj.close(); |
143 | 145 |
} catch (Exception e) { |
144 |
logger.warn("Problems closing " + obj.getClass().getSimpleName() + " '" + obj.toString() + "'.", e);
|
|
146 |
LOGGER.warn("Problems closing " + obj.getClass().getSimpleName() + " '" + obj.toString() + "'.", e);
|
|
145 | 147 |
} |
146 | 148 |
} |
147 | 149 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/AbstractConnectionOperation.java | ||
---|---|---|
9 | 9 |
import org.slf4j.Logger; |
10 | 10 |
import org.slf4j.LoggerFactory; |
11 | 11 |
|
12 |
@SuppressWarnings("UseSpecificCatch") |
|
12 | 13 |
public abstract class AbstractConnectionOperation implements ConnectionOperation { |
13 | 14 |
|
14 | 15 |
final static protected Logger LOGGER = LoggerFactory.getLogger(AbstractConnectionOperation.class); |
... | ... | |
58 | 59 |
LOGGER.debug("preparing execution of "+this.getClass().getSimpleName()+"."); |
59 | 60 |
if( needTransaction() ) { |
60 | 61 |
try { |
61 |
// XXX OJO esta condicion NO ES FIABLE |
|
62 |
if (!this.getConnection().getAutoCommit()) { |
|
63 |
if (!continueTransactionAllowed()) { |
|
64 |
throw new SQLException("nested operations not allowed."); |
|
62 |
if( this.helper.allowNestedOperations() ) { |
|
63 |
boolean commitOnFinish = true; |
|
64 |
if (!this.getConnection().getAutoCommit()) { |
|
65 |
// Casi seguro que es una operacion anidada, asi que no |
|
66 |
// terminamos la transaccion. |
|
67 |
commitOnFinish = false; |
|
68 |
} |
|
69 |
this.getConnection().setAutoCommit(false); |
|
70 |
try { |
|
71 |
LOGGER.debug("Excuting operation {}.", this.getClass().getSimpleName()); |
|
72 |
result = perform(this.getConnection()); |
|
73 |
} catch (Exception ex) { |
|
74 |
try { |
|
75 |
this.getConnection().rollback(); |
|
76 |
} catch (Exception e1) { |
|
77 |
throw new JDBCTransactionRollbackException(e1, ex); |
|
78 |
} |
|
79 |
throw new RuntimeException("Can't perform operation '"+this.getClass().getSimpleName()+"'.",ex); |
|
65 | 80 |
} |
66 |
} |
|
67 |
this.getConnection().setAutoCommit(false); |
|
68 |
try { |
|
69 |
LOGGER.debug("Excuting operation {}.", this.getClass().getSimpleName()); |
|
70 |
result = perform(this.getConnection()); |
|
71 |
} catch (Exception ex) { |
|
81 |
if( commitOnFinish ) { |
|
82 |
this.getConnection().commit(); |
|
83 |
this.getConnection().setAutoCommit(true); |
|
84 |
} |
|
85 |
} else { |
|
86 |
if (!this.getConnection().getAutoCommit()) { |
|
87 |
// Casi seguro que es una transaccion anidada, si no |
|
88 |
// esta permitido, petamos. |
|
89 |
if (!continueTransactionAllowed()) { |
|
90 |
throw new SQLException("nested operations not allowed."); |
|
91 |
} |
|
92 |
} |
|
93 |
this.getConnection().setAutoCommit(false); |
|
72 | 94 |
try { |
73 |
this.getConnection().rollback(); |
|
74 |
} catch (Exception e1) { |
|
75 |
throw new JDBCTransactionRollbackException(e1, ex); |
|
95 |
LOGGER.debug("Excuting operation {}.", this.getClass().getSimpleName()); |
|
96 |
result = perform(this.getConnection()); |
|
97 |
} catch (Exception ex) { |
|
98 |
try { |
|
99 |
this.getConnection().rollback(); |
|
100 |
} catch (Exception e1) { |
|
101 |
throw new JDBCTransactionRollbackException(e1, ex); |
|
102 |
} |
|
103 |
throw new RuntimeException("Can't perform operation '"+this.getClass().getSimpleName()+"'.",ex); |
|
76 | 104 |
} |
77 |
throw new RuntimeException("Can't perform operation '"+this.getClass().getSimpleName()+"'.",ex);
|
|
105 |
this.getConnection().commit();
|
|
78 | 106 |
} |
79 |
this.getConnection().commit(); |
|
80 | 107 |
} finally { |
81 | 108 |
helper.closeConnection(this.getConnection()); |
82 | 109 |
conn = null; |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/JDBCSQLBuilderBase.java | ||
---|---|---|
13 | 13 |
import org.gvsig.fmap.dal.feature.spi.FeatureProvider; |
14 | 14 |
import org.gvsig.fmap.dal.feature.spi.FeatureReferenceProviderServices; |
15 | 15 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
16 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils; |
|
17 | 16 |
import org.gvsig.fmap.geom.DataTypes; |
18 | 17 |
import org.gvsig.fmap.geom.Geometry; |
19 | 18 |
import org.gvsig.fmap.geom.GeometryLocator; |
... | ... | |
65 | 64 |
} catch (Exception ex) { |
66 | 65 |
throw new RuntimeException("Can't locate database code for SRS '"+projection.getAbrev()+"'."); |
67 | 66 |
} finally { |
68 |
JDBCUtils.closeQuietly(conn);
|
|
67 |
this.helper.closeConnectionQuietly(conn);
|
|
69 | 68 |
} |
70 | 69 |
} |
71 | 70 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/JDBCHelperBase.java | ||
---|---|---|
5 | 5 |
import java.sql.Connection; |
6 | 6 |
import java.sql.ResultSet; |
7 | 7 |
import org.apache.commons.lang3.StringUtils; |
8 |
import org.apache.commons.lang3.mutable.MutableBoolean; |
|
9 |
import org.gvsig.expressionevaluator.Code; |
|
8 | 10 |
import org.gvsig.expressionevaluator.ExpressionBuilder.GeometrySupportType; |
9 | 11 |
import static org.gvsig.expressionevaluator.ExpressionBuilder.GeometrySupportType.EWKB; |
10 | 12 |
import static org.gvsig.expressionevaluator.ExpressionBuilder.GeometrySupportType.NATIVE; |
11 | 13 |
import static org.gvsig.expressionevaluator.ExpressionBuilder.GeometrySupportType.WKB; |
12 | 14 |
import static org.gvsig.expressionevaluator.ExpressionBuilder.GeometrySupportType.WKT; |
15 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator; |
|
16 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorManager; |
|
17 |
import org.gvsig.expressionevaluator.Function; |
|
13 | 18 |
import org.gvsig.fmap.dal.DataTypes; |
14 | 19 |
import org.gvsig.fmap.dal.exception.DataException; |
15 | 20 |
import org.gvsig.fmap.dal.exception.InitializeException; |
16 | 21 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
22 |
import org.gvsig.fmap.dal.feature.FeatureQueryOrder; |
|
17 | 23 |
import org.gvsig.fmap.dal.feature.FeatureType; |
18 | 24 |
|
19 | 25 |
import org.gvsig.fmap.dal.feature.spi.FeatureProvider; |
... | ... | |
41 | 47 |
import org.gvsig.fmap.geom.GeometryLocator; |
42 | 48 |
import org.gvsig.fmap.geom.GeometryManager; |
43 | 49 |
import org.gvsig.tools.dispose.impl.AbstractDisposable; |
50 |
import org.gvsig.tools.evaluator.Evaluator; |
|
44 | 51 |
import org.gvsig.tools.exception.BaseException; |
45 | 52 |
import org.gvsig.tools.exception.NotYetImplemented; |
53 |
import org.gvsig.tools.visitor.VisitCanceledException; |
|
54 |
import org.gvsig.tools.visitor.Visitor; |
|
46 | 55 |
import org.slf4j.Logger; |
47 | 56 |
import org.slf4j.LoggerFactory; |
48 | 57 |
|
58 |
@SuppressWarnings("UseSpecificCatch") |
|
49 | 59 |
public class JDBCHelperBase extends AbstractDisposable implements ResourceConsumer, JDBCHelper { |
50 | 60 |
|
51 | 61 |
private static final boolean ALLOW_AUTOMATIC_VALUES = true; |
52 | 62 |
private static final String QUOTE_FOR_USE_IN_IDENTIFIERS = "\""; |
53 | 63 |
private static final String QUOTE_FOR_USE_IN_STRINGS = "'"; |
54 | 64 |
|
55 |
private static final Logger logger = LoggerFactory.getLogger(JDBCHelperBase.class);
|
|
65 |
private static final Logger LOGGER = LoggerFactory.getLogger(JDBCHelperBase.class);
|
|
56 | 66 |
|
57 | 67 |
private ResulSetControler resulSetControler = null; |
58 | 68 |
|
... | ... | |
112 | 122 |
} |
113 | 123 |
|
114 | 124 |
@Override |
125 |
public boolean allowNestedOperations() { |
|
126 |
return false; |
|
127 |
} |
|
128 |
|
|
129 |
@Override |
|
115 | 130 |
public boolean canWriteGeometry(int geometryType, int geometrySubtype) { |
116 | 131 |
// Como va a guardar las geometrias en WKT, puede escribirlas todas. |
117 | 132 |
return true; |
... | ... | |
142 | 157 |
public String getQuoteForStrings() { |
143 | 158 |
return QUOTE_FOR_USE_IN_STRINGS; |
144 | 159 |
} |
160 |
|
|
161 |
@Override |
|
162 |
public boolean supportFilter(Evaluator filter) { |
|
163 |
// No podemos filtrar cuando: |
|
164 |
// - Hay una subquery especificada en los parametros |
|
165 |
// - Si hay un filtro y el getSQL devuelbe null. |
|
166 |
// - Si se esta usando alguna funcion no-sql en el getSQL |
|
167 |
// - Si se estan usando funciones OGC y no soportamos funciones espaciales |
|
168 |
// |
|
169 |
// Un proveedor especifico podria sobreescribir el metodo, |
|
170 |
// para hilar mas fino al comprobar si soporta el filtro o no. |
|
171 |
// |
|
172 |
|
|
173 |
if (this.useSubquery()) { |
|
174 |
// Se esta usando una subquery en los parametros de acceso a la |
|
175 |
// BBDD, asi que no podemos filtrar. |
|
176 |
return false; |
Also available in: Unified diff