Revision 46104 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
JDBCHelperBase.java | ||
---|---|---|
29 | 29 |
import java.sql.Connection; |
30 | 30 |
import java.sql.ResultSet; |
31 | 31 |
import java.util.ArrayList; |
32 |
import java.util.HashMap; |
|
32 | 33 |
import java.util.HashSet; |
33 | 34 |
import java.util.List; |
35 |
import java.util.Map; |
|
34 | 36 |
import java.util.function.Predicate; |
35 | 37 |
import org.apache.commons.io.IOUtils; |
36 | 38 |
import org.apache.commons.lang3.ArrayUtils; |
... | ... | |
96 | 98 |
import org.slf4j.LoggerFactory; |
97 | 99 |
import static org.gvsig.expressionevaluator.ExpressionBuilder.FUNCTION_$CONSTANT; |
98 | 100 |
import static org.gvsig.expressionevaluator.ExpressionBuilder.FUNCTION_$IDENTIFIER; |
101 |
import org.gvsig.fmap.dal.store.jdbc2.spi.expressionbuilder.formatters.ComputedAttribute; |
|
99 | 102 |
|
100 | 103 |
@SuppressWarnings("UseSpecificCatch") |
101 | 104 |
public class JDBCHelperBase extends AbstractDisposable implements ResourceConsumer, JDBCHelper { |
... | ... | |
956 | 959 |
public String getConnectionProviderStatus() { |
957 | 960 |
return ""; |
958 | 961 |
} |
959 |
|
|
962 |
|
|
963 |
public void expandCalculedColumns(JDBCSQLBuilderBase sqlbuilder) { |
|
964 |
ComputedAttribute computedAttributeFormater = new ComputedAttribute(sqlbuilder, sqlbuilder.formatter()); |
|
965 |
Map<ExpressionBuilder.Value, ExpressionBuilder.Value> variablesToReplace = new HashMap<>(); |
|
966 |
sqlbuilder.accept(new ExpressionBuilder.Visitor() { |
|
967 |
@Override |
|
968 |
public void visit(ExpressionBuilder.Visitable value) { |
|
969 |
if (computedAttributeFormater.canApply((ExpressionBuilder.Value) value)) { |
|
970 |
ExpressionBuilder.Variable variable = (ExpressionBuilder.Variable) value; |
|
971 |
ExpressionBuilder.Value replace = computedAttributeFormater.expandedValue(variable); |
|
972 |
variablesToReplace.put(variable, replace); |
|
973 |
} |
|
974 |
} |
|
975 |
}, null); |
|
976 |
for (Map.Entry<ExpressionBuilder.Value, ExpressionBuilder.Value> entry : variablesToReplace.entrySet()) { |
|
977 |
ExpressionBuilder.Value variable = entry.getKey(); |
|
978 |
ExpressionBuilder.Value replace = entry.getValue(); |
|
979 |
sqlbuilder.select().replace(variable, replace); |
|
980 |
} |
|
981 |
} |
|
982 |
|
|
960 | 983 |
} |
Also available in: Unified diff