Revision 44854
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/test/resources/org/gvsig/fmap/dal/store/h2/resultSetForSetProvider.sql | ||
---|---|---|
51 | 51 |
("countries"."LASTCENSUS" < 0)) LIMIT 1)),TRUE,FALSE) |
52 | 52 |
GROUP BY "Long"; |
53 | 53 |
|
54 |
-- Simple |
|
55 |
SELECT |
|
56 |
"Byte", "Bool1", "Long", "Timestamp", "Date", "Time", |
|
57 |
"Bool2", "String", "Bool3", "Double", "Bool4", "Float", "Bool5", "Decimal", |
|
58 |
NVL2("Geometry",ST_AsBinary("Geometry"),NULL), "ID" |
|
59 |
FROM "PUBLIC"."test"; |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/test/java/org/gvsig/fmap/dal/store/h2/operations/sql/TestResultSetForSetProvider.java | ||
---|---|---|
201 | 201 |
|
202 | 202 |
|
203 | 203 |
|
204 |
public void testConstantColumnPrimaryKey() throws Exception { |
|
205 |
JDBCHelper helper = TestUtils.getJDBCHelper(); |
|
206 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
|
207 |
OperationsFactory operations = helper.getOperations(); |
|
208 |
|
|
209 |
List<String> expectedSQLs = TestUtils.getSQLs("resultSetForSetProvider.sql"); |
|
210 |
|
|
211 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
|
212 |
|
|
213 |
TableReference table = operations.createTableReference( |
|
214 |
"dbtest", |
|
215 |
sqlbuilder.default_schema(), |
|
216 |
"test", |
|
217 |
null |
|
218 |
); |
|
219 |
// meterle como constantCOlumn ID |
|
220 |
|
|
221 |
FeatureType featureType = sourceStore.getDefaultFeatureType(); |
|
222 |
FeatureQuery query = sourceStore.createFeatureQuery(); |
|
223 |
|
|
224 |
query.setConstantsAttributeNames(new String[]{"ID"}); |
|
225 |
|
|
226 |
ResultSetForSetProviderOperation resultSetForSetProvider = operations.createResultSetForSetProvider( |
|
227 |
table, |
|
228 |
null, |
|
229 |
null, |
|
230 |
query, |
|
231 |
featureType, |
|
232 |
featureType, |
|
233 |
0, |
|
234 |
0, |
|
235 |
0 |
|
236 |
); |
|
237 |
String sql = resultSetForSetProvider.getSQL(); |
|
238 |
System.out.println("###### SQL:"+sql); |
|
239 |
System.out.println("###### EXP:"+expectedSQLs.get(4)); |
|
240 |
|
|
241 |
assertEquals("ResultSetForSetProvider SQL", expectedSQLs.get(4), sql); |
|
242 |
} |
|
243 |
|
|
244 |
|
|
204 | 245 |
// TODO: a?adir un test con where, group y order. |
205 | 246 |
} |
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 | ||
---|---|---|
139 | 139 |
for(String attrName : query.getGroupByColumns() ) { |
140 | 140 |
select.group_by(expbuilder.column(attrName)); |
141 | 141 |
} |
142 |
} else { |
|
143 |
for(String attrName : forcedColumns ) { |
|
144 |
select.column().name(attrName); |
|
145 |
columns.add(setType.getAttributeDescriptor(attrName)); |
|
146 |
} |
|
142 | 147 |
} |
143 | 148 |
|
144 | 149 |
select.from().table() |
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 | ||
---|---|---|
32 | 32 |
import org.gvsig.fmap.dal.exception.DataException; |
33 | 33 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
34 | 34 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
35 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
36 | 35 |
import org.gvsig.fmap.dal.feature.Feature; |
37 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
38 | 36 |
import org.gvsig.fmap.dal.feature.FeatureIndexes; |
39 | 37 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
40 | 38 |
import org.gvsig.fmap.dal.feature.FeatureQueryOrder; |
... | ... | |
149 | 147 |
transformsToUse.getSourceFeatureTypeFrom(this.defaultFeatureType); |
150 | 148 |
theQueryForProvider.setFeatureTypeId(ftype.getId()); |
151 | 149 |
this.defatulFeatureTypeForProvider = ftype; |
152 |
|
|
150 |
|
|
153 | 151 |
if (transformsToUse.isTransformsOriginalValues()) { |
154 | 152 |
theQueryForProvider.clearFilter(); |
155 | 153 |
FeatureQueryOrder fqo = theQueryForProvider.getOrder(); |
... | ... | |
222 | 220 |
return true; |
223 | 221 |
} |
224 | 222 |
|
223 |
@Override |
|
225 | 224 |
public FeatureType getDefaultFeatureType() { |
226 | 225 |
return this.defaultFeatureType; |
227 | 226 |
} |
228 | 227 |
|
228 |
@Override |
|
229 | 229 |
public List getFeatureTypes() { |
230 | 230 |
return Collections.unmodifiableList(this.featureTypes); |
231 | 231 |
} |
232 | 232 |
|
233 |
@Override |
|
233 | 234 |
public long getSize() throws DataException { |
234 | 235 |
this.checkSourceStoreModified(); |
235 | 236 |
if (size < 0) { |
... | ... | |
590 | 591 |
|
591 | 592 |
} |
592 | 593 |
|
594 |
@Override |
|
593 | 595 |
public void delete(Feature feature) throws DataException { |
594 | 596 |
this.featureToIgnoreNotification = feature; |
595 | 597 |
this.store.delete(feature); |
... | ... | |
600 | 602 |
this.ownFeaturesModified = true; |
601 | 603 |
} |
602 | 604 |
|
605 |
@Override |
|
603 | 606 |
public void insert(EditableFeature feature) throws DataException { |
604 | 607 |
this.featureToIgnoreNotification = feature; |
605 | 608 |
this.store.insert(feature); |
... | ... | |
610 | 613 |
this.ownFeaturesModified = true; |
611 | 614 |
} |
612 | 615 |
|
616 |
@Override |
|
613 | 617 |
public void update(EditableFeature feature) throws DataException { |
614 | 618 |
this.featureToIgnoreNotification = feature; |
615 | 619 |
this.store.update(feature); |
... | ... | |
617 | 621 |
this.ownFeaturesModified = true; |
618 | 622 |
} |
619 | 623 |
|
624 |
@Override |
|
620 | 625 |
public void commitChanges() throws DataException { |
621 | 626 |
this.ignoreChanges = true; |
622 | 627 |
this.store.commitChanges(); |
... | ... | |
624 | 629 |
|
625 | 630 |
} |
626 | 631 |
|
632 |
@Override |
|
627 | 633 |
public FeatureStore getFeatureStore() { |
628 | 634 |
return store; |
629 | 635 |
} |
Also available in: Unified diff