Revision 45155 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/ResultSetForSetProviderOperation.java
ResultSetForSetProviderOperation.java | ||
---|---|---|
28 | 28 |
import java.util.List; |
29 | 29 |
import org.apache.commons.lang3.ArrayUtils; |
30 | 30 |
import org.apache.commons.lang3.StringUtils; |
31 |
import org.gvsig.expressionevaluator.Code; |
|
31 | 32 |
import org.gvsig.expressionevaluator.ExpressionBuilder; |
33 |
import static org.gvsig.expressionevaluator.ExpressionBuilder.FUNCTION_LET; |
|
32 | 34 |
import org.gvsig.expressionevaluator.ExpressionUtils; |
33 | 35 |
import org.gvsig.fmap.dal.SQLBuilder.SelectBuilder; |
34 | 36 |
import org.gvsig.fmap.dal.exception.DataException; |
... | ... | |
158 | 160 |
} |
159 | 161 |
columns.add(attr); |
160 | 162 |
} |
161 |
if( query !=null && query.hasGroupByColumns() ) { |
|
163 |
|
|
164 |
if( query !=null && query.hasGroupByColumns() ) { |
|
162 | 165 |
for(String attrName : query.getGroupByColumns() ) { |
163 |
select.group_by(expbuilder.column(attrName)); |
|
164 |
} |
|
166 |
if( setType.get(attrName)==null ) { |
|
167 |
try { |
|
168 |
Code code = ExpressionUtils.compile(attrName); |
|
169 |
if( code.code()==Code.CALLABLE ) { |
|
170 |
Code.Callable callable = (Code.Callable) code; |
|
171 |
if( callable.name().equalsIgnoreCase(FUNCTION_LET) ) { |
|
172 |
code = callable.parameters().get(1); |
|
173 |
Code name = callable.parameters().get(0); |
|
174 |
select.column().value(callable.parameters().get(1).toValue()) |
|
175 |
.as((String) ((Code.Constant)name).value()); |
|
176 |
extraColumnNames.add((String) ((Code.Constant)name).value()); |
|
177 |
} |
|
178 |
} |
|
179 |
select.group_by(code.toValue()); |
|
180 |
} catch (Exception ex) { |
|
181 |
throw new RuntimeException("Not able to create column by expression in groupby query", ex); |
|
182 |
} |
|
183 |
} else { |
|
184 |
select.group_by(expbuilder.column(attrName)); |
|
185 |
} |
|
186 |
} |
|
165 | 187 |
} else { |
166 | 188 |
for(String attrName : forcedColumns ) { |
167 | 189 |
select.column().name(attrName); |
168 | 190 |
columns.add(setType.getAttributeDescriptor(attrName)); |
169 | 191 |
} |
170 | 192 |
} |
171 |
|
|
193 |
|
|
172 | 194 |
select.from().table() |
173 | 195 |
.database(this.table.getDatabase()) |
174 | 196 |
.schema(this.table.getSchema()) |
... | ... | |
262 | 284 |
); |
263 | 285 |
return resultSetEntry; |
264 | 286 |
} |
265 |
|
|
287 |
|
|
266 | 288 |
} |
Also available in: Unified diff