Revision 44374
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 | ||
---|---|---|
124 | 124 |
sqlbuilder.select().column().name(attr.getName()); |
125 | 125 |
columns.add(attr); |
126 | 126 |
} |
127 |
if( query !=null && query.isGrouped() ) { |
|
128 |
sqlbuilder.select().group_by(expbuilder.column(attr.getName())); |
|
129 |
} |
|
127 | 130 |
} |
128 |
for(String attrName : forcedColumns ) { |
|
129 |
sqlbuilder.select().column().name(attrName); |
|
130 |
columns.add(setType.getAttributeDescriptor(attrName)); |
|
131 |
if( query ==null || !query.isGrouped() ) { |
|
132 |
for(String attrName : forcedColumns ) { |
|
133 |
sqlbuilder.select().column().name(attrName); |
|
134 |
columns.add(setType.getAttributeDescriptor(attrName)); |
|
135 |
} |
|
131 | 136 |
} |
132 | 137 |
|
133 | 138 |
sqlbuilder.select().from().table() |
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/SearchFieldController.java | ||
---|---|---|
31 | 31 |
import org.gvsig.fmap.dal.exception.DataException; |
32 | 32 |
import org.gvsig.fmap.dal.feature.Feature; |
33 | 33 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
34 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
|
34 | 35 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
35 | 36 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
36 | 37 |
import org.gvsig.fmap.dal.feature.FeatureType; |
... | ... | |
355 | 356 |
final long timeLimit = System.currentTimeMillis() + limit * 1000; |
356 | 357 |
final DefaultComboBoxModel model = new DefaultComboBoxModel(); |
357 | 358 |
this.setEnabled(false); |
359 |
final FeatureStore theStore = attribute.getFeatureStore(); |
|
360 |
final FeatureQuery query = theStore.createFeatureQuery(); |
|
361 |
query.addAttributeName(attribute.getDescriptor().getName()); |
|
362 |
query.setGroup(true); |
|
363 |
query.setLimit(1000); |
|
358 | 364 |
Thread th = new Thread(new Runnable() { |
359 | 365 |
@Override |
360 | 366 |
public void run() { |
361 | 367 |
try { |
362 |
FeatureSet set = attribute.getFeatureStore().getFeatureSet();
|
|
368 |
FeatureSet set = theStore.getFeatureSet(query);
|
|
363 | 369 |
set.accept(new Visitor() { |
364 | 370 |
@Override |
365 | 371 |
public void visit(Object o) throws VisitCanceledException, BaseException { |
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/feature/FeatureQuery.java | ||
---|---|---|
286 | 286 |
* the load page size |
287 | 287 |
*/ |
288 | 288 |
void setPageSize(long pageSize); |
289 |
|
|
290 |
void setGroup(boolean group); |
|
291 |
|
|
292 |
boolean isGrouped(); |
|
289 | 293 |
} |
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/DefaultFeatureType.java | ||
---|---|---|
327 | 327 |
rules.validate(feature, mode); |
328 | 328 |
} |
329 | 329 |
|
330 |
public FeatureType getSubtype() throws DataException { |
|
331 |
return new SubtypeFeatureType(this, null, null, true); |
|
332 |
} |
|
333 |
|
|
330 | 334 |
public FeatureType getSubtype(String[] names) throws DataException { |
331 |
if (names == null || names.length < 1) { |
|
332 |
return (FeatureType) this.clone(); |
|
333 |
} |
|
334 |
return new SubtypeFeatureType(this, names, null); |
|
335 |
return this.getSubtype(names, null, true); |
|
335 | 336 |
} |
336 | 337 |
|
337 | 338 |
public FeatureType getSubtype(String[] names, String[] constantsNames) throws DataException { |
339 |
return this.getSubtype(names, constantsNames, true); |
|
340 |
} |
|
341 |
|
|
342 |
public FeatureType getSubtype(String[] names, String[] constantsNames, boolean includePk) throws DataException { |
|
338 | 343 |
if (ArrayUtils.isEmpty(names) && ArrayUtils.isEmpty(constantsNames)) { |
339 | 344 |
return (FeatureType) this.clone(); |
340 | 345 |
} |
341 |
return new SubtypeFeatureType(this, names, constantsNames); |
|
346 |
return new SubtypeFeatureType(this, names, constantsNames,includePk);
|
|
342 | 347 |
} |
343 | 348 |
|
344 |
public FeatureType getSubtype() throws DataException { |
|
345 |
return new SubtypeFeatureType(this, null, null); |
|
346 |
} |
|
347 |
|
|
348 | 349 |
public boolean isSubtypeOf(FeatureType featureType) { |
349 | 350 |
return false; |
350 | 351 |
} |
... | ... | |
382 | 383 |
private static final long serialVersionUID = 6913732960073922540L; |
383 | 384 |
WeakReference parent; |
384 | 385 |
|
385 |
SubtypeFeatureType(DefaultFeatureType parent, String[] names, String[] constantsNames) |
|
386 |
SubtypeFeatureType(DefaultFeatureType parent, String[] names, String[] constantsNames, boolean includePk)
|
|
386 | 387 |
throws DataException { |
387 | 388 |
super(parent, false); |
388 | 389 |
DefaultFeatureAttributeDescriptor attrcopy; |
... | ... | |
411 | 412 |
} |
412 | 413 |
} |
413 | 414 |
// Add missing pk fiels |
414 |
if (!parent.hasOID()) { |
|
415 |
if (includePk && !parent.hasOID()) {
|
|
415 | 416 |
for (FeatureAttributeDescriptor attrdesc : parent) { |
416 | 417 |
if (attrdesc.isPrimaryKey()) { |
417 | 418 |
attrnames.add(attrdesc.getName()); |
... | ... | |
453 | 454 |
this.parent = new WeakReference(parent); |
454 | 455 |
} |
455 | 456 |
|
456 |
public FeatureType getSubtype(String[] names) throws DataException { |
|
457 |
public FeatureType getSubtype(String[] names, boolean includePk) throws DataException {
|
|
457 | 458 |
return new SubtypeFeatureType((DefaultFeatureType) this.parent |
458 |
.get(), names, null); |
|
459 |
.get(), names, null, includePk);
|
|
459 | 460 |
} |
460 | 461 |
|
461 | 462 |
public boolean isSubtypeOf(FeatureType featureType) { |
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 | ||
---|---|---|
1997 | 1997 |
|
1998 | 1998 |
@Override |
1999 | 1999 |
public Feature findFirst(FeatureQuery query) throws DataException { |
2000 |
if( query == null ) { |
|
2001 |
query = this.createFeatureQuery(); |
|
2002 |
} else { |
|
2003 |
query = query.getCopy(); |
|
2004 |
} |
|
2005 |
query.setLimit(1); |
|
2000 | 2006 |
final MutableObject<Feature> feature = new MutableObject<>(); |
2001 | 2007 |
try { |
2002 | 2008 |
this.accept(new Visitor() { |
... | ... | |
2041 | 2047 |
featureQuery.hasConstantsAttributeNames() || |
2042 | 2048 |
fType.hasRequiredFields() |
2043 | 2049 |
) { |
2044 |
return fType.getSubtype(featureQuery.getAttributeNames(), featureQuery.getConstantsAttributeNames() ); |
|
2050 |
if( featureQuery.isGrouped() ) { |
|
2051 |
return fType.getSubtype(featureQuery.getAttributeNames(), featureQuery.getConstantsAttributeNames(), false ); |
|
2052 |
} else { |
|
2053 |
return fType.getSubtype(featureQuery.getAttributeNames(), featureQuery.getConstantsAttributeNames()); |
|
2054 |
} |
|
2045 | 2055 |
} |
2046 | 2056 |
return fType; |
2047 | 2057 |
} |
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/DefaultFeatureQuery.java | ||
---|---|---|
27 | 27 |
import java.util.HashMap; |
28 | 28 |
import java.util.List; |
29 | 29 |
import java.util.Map; |
30 |
import java.util.logging.Level; |
|
31 |
import java.util.logging.Logger; |
|
32 | 30 |
import org.apache.commons.lang3.ArrayUtils; |
33 | 31 |
import org.apache.commons.lang3.StringUtils; |
34 | 32 |
import org.gvsig.expressionevaluator.Expression; |
35 | 33 |
import org.gvsig.fmap.dal.DALLocator; |
36 | 34 |
import org.gvsig.fmap.dal.DataTypes; |
37 | 35 |
import org.gvsig.fmap.dal.exception.DataException; |
38 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
39 | 36 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
40 | 37 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
41 | 38 |
import org.gvsig.fmap.dal.feature.FeatureQueryOrder; |
... | ... | |
107 | 104 |
|
108 | 105 |
private long pageSize; |
109 | 106 |
|
107 |
private boolean group = false; |
|
110 | 108 |
/** |
111 | 109 |
* Creates a FeatureQuery which will load all available Features of a type. |
112 | 110 |
* |
... | ... | |
617 | 615 |
this.constantsAttributeNames = new ArrayList(); |
618 | 616 |
} |
619 | 617 |
|
618 |
@Override |
|
619 |
public boolean isGrouped() { |
|
620 |
return this.group; |
|
621 |
} |
|
622 |
|
|
623 |
@Override |
|
624 |
public void setGroup(boolean group) { |
|
625 |
this.group = group; |
|
626 |
} |
|
627 |
|
|
620 | 628 |
} |
Also available in: Unified diff