Revision 44346 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
DefaultFeatureStore.java | ||
---|---|---|
47 | 47 |
import org.gvsig.expressionevaluator.Expression; |
48 | 48 |
import org.gvsig.expressionevaluator.ExpressionBuilder; |
49 | 49 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator; |
50 |
import org.gvsig.expressionevaluator.ExpressionUtils; |
|
50 | 51 |
import org.gvsig.fmap.dal.BaseStoresRepository; |
51 | 52 |
|
52 | 53 |
import org.gvsig.fmap.dal.DALLocator; |
... | ... | |
1915 | 1916 |
@Override |
1916 | 1917 |
public List<Feature> getFeatures(String filter, String sortBy, boolean asc) { |
1917 | 1918 |
FeatureQuery query = this.createFeatureQuery(filter, sortBy, asc); |
1918 |
return this.getFeatures(query, 100);
|
|
1919 |
return this.getFeatures(query, 0); |
|
1919 | 1920 |
} |
1920 | 1921 |
|
1921 | 1922 |
@Override |
... | ... | |
1931 | 1932 |
@Override |
1932 | 1933 |
public List<Feature> getFeatures(Expression filter, String sortBy, boolean asc) { |
1933 | 1934 |
FeatureQuery query = this.createFeatureQuery(filter, sortBy, asc); |
1934 |
return this.getFeatures(query, 100);
|
|
1935 |
return this.getFeatures(query, 0); |
|
1935 | 1936 |
} |
1936 | 1937 |
|
1937 | 1938 |
@Override |
1938 | 1939 |
public List<Feature> getFeatures(FeatureQuery query) { |
1939 |
return this.getFeatures(query, 100);
|
|
1940 |
return this.getFeatures(query, 0); |
|
1940 | 1941 |
} |
1941 | 1942 |
|
1942 | 1943 |
@Override |
1943 | 1944 |
public List<Feature> getFeatures(FeatureQuery query, int pageSize) { |
1944 | 1945 |
try { |
1946 |
if( pageSize<=0 ) { |
|
1947 |
pageSize = 100; |
|
1948 |
} |
|
1945 | 1949 |
FeaturePagingHelper pager = this.dataManager.createFeaturePagingHelper(this, query, pageSize); |
1946 | 1950 |
return pager.asList(); |
1947 | 1951 |
} catch (BaseException ex) { |
... | ... | |
1951 | 1955 |
|
1952 | 1956 |
@Override |
1953 | 1957 |
public List<Feature> getFeatures() { |
1954 |
return this.getFeatures(null, 500);
|
|
1958 |
return this.getFeatures(null, 0); |
|
1955 | 1959 |
} |
1956 | 1960 |
|
1957 | 1961 |
@Override |
... | ... | |
2527 | 2531 |
return new DefaultFeatureQuery(); |
2528 | 2532 |
} |
2529 | 2533 |
|
2530 |
private FeatureQuery createFeatureQuery(Expression filter, String sortBy, boolean asc) {
|
|
2534 |
public FeatureQuery createFeatureQuery(Expression filter, String sortBy, boolean asc) {
|
|
2531 | 2535 |
FeatureQuery query = null; |
2532 | 2536 |
if( filter!=null ) { |
2533 | 2537 |
query = this.createFeatureQuery(); |
... | ... | |
2537 | 2541 |
if( query == null ) { |
2538 | 2542 |
query = this.createFeatureQuery(); |
2539 | 2543 |
} |
2540 |
query.getOrder().add(sortBy, asc); |
|
2544 |
String[] attrnames; |
|
2545 |
if( sortBy.contains(",") ) { |
|
2546 |
attrnames = StringUtils.split(sortBy, ","); |
|
2547 |
} else { |
|
2548 |
attrnames = new String[] { sortBy }; |
|
2549 |
} |
|
2550 |
for (String attrname : attrnames) { |
|
2551 |
attrname = attrname.trim(); |
|
2552 |
if( attrname.startsWith("-") ) { |
|
2553 |
query.getOrder().add(sortBy.substring(1).trim(), false); |
|
2554 |
} else if( attrname.endsWith("-") ) { |
|
2555 |
query.getOrder().add(sortBy.substring(0,sortBy.length()-1).trim(), false); |
|
2556 |
} else if( attrname.startsWith("+") ) { |
|
2557 |
query.getOrder().add(sortBy.substring(1).trim(), true); |
|
2558 |
} else if( attrname.endsWith("-") ) { |
|
2559 |
query.getOrder().add(sortBy.substring(0,sortBy.length()-1).trim(), true); |
|
2560 |
} else { |
|
2561 |
query.getOrder().add(sortBy, asc); |
|
2562 |
} |
|
2563 |
} |
|
2541 | 2564 |
} |
2542 | 2565 |
if( query != null ) { |
2543 | 2566 |
query.retrievesAllAttributes(); |
... | ... | |
2545 | 2568 |
return query; |
2546 | 2569 |
} |
2547 | 2570 |
|
2548 |
private FeatureQuery createFeatureQuery(String filter, String sortBy, boolean asc) { |
|
2549 |
FeatureQuery query = null; |
|
2550 |
if( !StringUtils.isEmpty(filter) ) { |
|
2551 |
query = this.createFeatureQuery(); |
|
2552 |
query.setFilter(filter); |
|
2571 |
public FeatureQuery createFeatureQuery(String filter, String sortBy, boolean asc) { |
|
2572 |
if( StringUtils.isBlank(filter) ) { |
|
2573 |
return this.createFeatureQuery( |
|
2574 |
(Expression)null, |
|
2575 |
sortBy, |
|
2576 |
asc |
|
2577 |
); |
|
2578 |
} else { |
|
2579 |
return this.createFeatureQuery( |
|
2580 |
ExpressionUtils.createExpression(filter), |
|
2581 |
sortBy, |
|
2582 |
asc |
|
2583 |
); |
|
2553 | 2584 |
} |
2554 |
if( !StringUtils.isEmpty(sortBy) ) { |
|
2555 |
if( query == null ) { |
|
2556 |
query = this.createFeatureQuery(); |
|
2557 |
} |
|
2558 |
query.getOrder().add(sortBy, asc); |
|
2559 |
} |
|
2560 |
if( query != null ) { |
|
2561 |
query.retrievesAllAttributes(); |
|
2562 |
} |
|
2563 |
return query; |
|
2564 | 2585 |
} |
2565 | 2586 |
|
2566 | 2587 |
@Override |
Also available in: Unified diff