Revision 23680
branches/v2_0_0_prep/libraries/libFMap_dataDB/src/org/gvsig/fmap/data/feature/db/DBDataFeatureCollectionWithFeatureID.java | ||
---|---|---|
1 | 1 |
package org.gvsig.fmap.data.feature.db; |
2 | 2 |
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.Collection; |
|
5 |
import java.util.Comparator; |
|
6 |
import java.util.Iterator; |
|
7 |
import java.util.TreeSet; |
|
3 |
import java.util.*; |
|
8 | 4 |
|
9 | 5 |
import org.gvsig.fmap.data.DataManager; |
10 | 6 |
import org.gvsig.fmap.data.DataStore; |
11 | 7 |
import org.gvsig.fmap.data.ReadException; |
12 |
import org.gvsig.fmap.data.feature.AbstractFeatureIDIterator; |
|
13 |
import org.gvsig.fmap.data.feature.Feature; |
|
14 |
import org.gvsig.fmap.data.feature.FeatureCollection; |
|
15 |
import org.gvsig.fmap.data.feature.FeatureManager; |
|
16 |
import org.gvsig.fmap.data.feature.FeatureType; |
|
8 |
import org.gvsig.fmap.data.feature.*; |
|
17 | 9 |
import org.gvsig.fmap.data.feature.expressionevaluator.Filter; |
18 | 10 |
|
19 | 11 |
public abstract class DBDataFeatureCollectionWithFeatureID extends |
... | ... | |
103 | 95 |
this.featureType); |
104 | 96 |
return dbfIter; |
105 | 97 |
} |
98 |
|
|
99 |
protected Iterator internalIterator(int index) { |
|
100 |
checkModified(); |
|
101 |
FIDIterator dbfIter; |
|
106 | 102 |
|
103 |
|
|
104 |
if (featureIDs instanceof List) { |
|
105 |
dbfIter = new FIDIterator(((List) featureIDs).listIterator(index), |
|
106 |
featureType); |
|
107 |
} else { |
|
108 |
// TODO: If featureIDs is not a Collection of type List (actually, |
|
109 |
// only when ordering is applied), we are not able |
|
110 |
// to get a listIterator with an index, so we have to move the |
|
111 |
// iterator to the required position. This option will be probably |
|
112 |
// a lot slower, so an option would be to order with a List |
|
113 |
// instead of a TreeSet. |
|
114 |
Iterator iter = featureIDs.iterator(); |
|
115 |
for (int i = 0; i < index; i++) { |
|
116 |
iter.next(); |
|
117 |
} |
|
118 |
|
|
119 |
dbfIter = new FIDIterator(iter, featureType); |
|
120 |
} |
|
121 |
|
|
122 |
return dbfIter; |
|
123 |
} |
|
124 |
|
|
107 | 125 |
public class FIDIterator extends AbstractFeatureIDIterator { |
108 | 126 |
|
109 | 127 |
public FIDIterator(Iterator iter, FeatureType featureType) { |
branches/v2_0_0_prep/libraries/libFMap_dataDB/src/org/gvsig/fmap/data/feature/db/jdbc/postgresql/AbstractPostgresqlDBIterator.java | ||
---|---|---|
40 | 40 |
|
41 | 41 |
public AbstractPostgresqlDBIterator(PostgresqlStore store, |
42 | 42 |
DBFeatureType featureType, String sql, int fetchSize, |
43 |
FeatureManager featureManager, Filter featureFilter) |
|
43 |
FeatureManager featureManager, Filter featureFilter, |
|
44 |
int initialPosition) |
|
44 | 45 |
throws ReadException { |
45 |
super(store, featureType, sql, fetchSize, featureManager, featureFilter); |
|
46 |
super(store, featureType, sql, fetchSize, featureManager, |
|
47 |
featureFilter, initialPosition); |
|
46 | 48 |
} |
47 | 49 |
|
48 | 50 |
protected String getFinalResulsetSQL() { |
branches/v2_0_0_prep/libraries/libFMap_dataDB/src/org/gvsig/fmap/data/feature/db/jdbc/postgresql/PostgresqlFeatureCollectionEditingFiltered.java | ||
---|---|---|
5 | 5 |
import java.util.Iterator; |
6 | 6 |
import java.util.NoSuchElementException; |
7 | 7 |
|
8 |
import org.gvsig.tools.exception.BaseException; |
|
9 | 8 |
import org.gvsig.fmap.data.DataManager; |
10 | 9 |
import org.gvsig.fmap.data.DataStore; |
11 | 10 |
import org.gvsig.fmap.data.ReadException; |
... | ... | |
14 | 13 |
import org.gvsig.fmap.data.feature.db.DBDataFeatureCollection; |
15 | 14 |
import org.gvsig.fmap.data.feature.db.DBFeatureType; |
16 | 15 |
import org.gvsig.fmap.data.feature.expressionevaluator.Filter; |
16 |
import org.gvsig.tools.exception.BaseException; |
|
17 | 17 |
|
18 | 18 |
public class PostgresqlFeatureCollectionEditingFiltered extends DBDataFeatureCollection { |
19 | 19 |
protected DBFeatureType featureType; |
... | ... | |
85 | 85 |
} |
86 | 86 |
|
87 | 87 |
|
88 |
public Iterator iterator() {
|
|
89 |
checkModified();
|
|
90 |
try{
|
|
91 |
PostgresIterator dbIter = new PostgresIterator(this.store,
|
|
92 |
this.featureType, this.sql, this.fetchSize,
|
|
93 |
this.featureManager, this.parser);
|
|
94 |
return dbIter;
|
|
95 |
} catch (BaseException e){
|
|
96 |
throw new RuntimeException(e);
|
|
97 |
}
|
|
98 |
}
|
|
88 |
protected Iterator internalIterator(int index) {
|
|
89 |
checkModified();
|
|
90 |
try {
|
|
91 |
PostgresIterator dbIter = new PostgresIterator(this.store,
|
|
92 |
this.featureType, this.sql, this.fetchSize,
|
|
93 |
this.featureManager, this.parser, index + 1);
|
|
94 |
return dbIter;
|
|
95 |
} catch (BaseException e) {
|
|
96 |
throw new RuntimeException(e);
|
|
97 |
}
|
|
98 |
}
|
|
99 | 99 |
|
100 |
|
|
101 | 100 |
protected class PostgresIterator extends AbstractPostgresqlDBIterator { |
102 | 101 |
public PostgresIterator(PostgresqlStore store, |
103 | 102 |
DBFeatureType featureType, String sql, int fetchSize, |
104 |
FeatureManager featureManager, Filter featureFilter) |
|
103 |
FeatureManager featureManager, Filter featureFilter, |
|
104 |
int initialPosition) |
|
105 | 105 |
throws ReadException { |
106 | 106 |
super(store, featureType, sql, fetchSize, featureManager, |
107 |
featureFilter); |
|
107 |
featureFilter, initialPosition);
|
|
108 | 108 |
} |
109 | 109 |
|
110 | 110 |
protected void checkModified() { |
branches/v2_0_0_prep/libraries/libFMap_dataDB/src/org/gvsig/fmap/data/feature/db/jdbc/postgresql/PostgresqlFeatureCollection.java | ||
---|---|---|
6 | 6 |
import java.util.ConcurrentModificationException; |
7 | 7 |
import java.util.Iterator; |
8 | 8 |
|
9 |
import org.gvsig.tools.exception.BaseException; |
|
10 | 9 |
import org.gvsig.fmap.data.DataStore; |
11 | 10 |
import org.gvsig.fmap.data.ReadException; |
12 | 11 |
import org.gvsig.fmap.data.feature.Feature; |
... | ... | |
17 | 16 |
import org.gvsig.fmap.data.feature.db.DBStore; |
18 | 17 |
import org.gvsig.fmap.data.feature.db.jdbc.JDBCStore; |
19 | 18 |
import org.gvsig.fmap.data.feature.db.jdbc.SQLException; |
19 |
import org.gvsig.tools.exception.BaseException; |
|
20 | 20 |
|
21 | 21 |
public class PostgresqlFeatureCollection extends DBDataFeatureCollection { |
22 | 22 |
protected DBFeatureType featureType; |
... | ... | |
123 | 123 |
} |
124 | 124 |
|
125 | 125 |
} |
126 |
|
|
127 |
protected Iterator internalIterator(int index) { |
|
128 |
checkModified(); |
|
129 |
PostgresqlIterator dbIter; |
|
130 |
try { |
|
131 |
dbIter = new PostgresqlIterator((PostgresqlStore) this.store, |
|
132 |
this.featureType, this.sql, this.fetchSize, index + 1); |
|
133 |
} catch (ReadException e) { |
|
134 |
throw new RuntimeException(e); |
|
135 |
} |
|
126 | 136 |
|
127 |
public Iterator iterator() { |
|
128 |
checkModified(); |
|
129 |
PostgresqlIterator dbIter; |
|
130 |
try { |
|
131 |
dbIter=new PostgresqlIterator((PostgresqlStore)this.store,this.featureType,this.sql,this.fetchSize); |
|
132 |
} catch (ReadException e) { |
|
133 |
throw new RuntimeException(e); |
|
134 |
} |
|
137 |
return dbIter; |
|
138 |
} |
|
135 | 139 |
|
136 |
return dbIter; |
|
137 |
} |
|
138 |
|
|
139 | 140 |
protected class PostgresqlIterator extends AbstractPostgresqlDBIterator { |
140 |
public PostgresqlIterator(PostgresqlStore store,DBFeatureType featureType ,String sql,int fetchSize) throws ReadException{ |
|
141 |
super(store, featureType, sql, fetchSize, null, null); |
|
141 |
public PostgresqlIterator(PostgresqlStore store, |
|
142 |
DBFeatureType featureType, String sql, int fetchSize, |
|
143 |
int initialPosition) throws ReadException { |
|
144 |
super(store, featureType, sql, fetchSize, null, null, |
|
145 |
initialPosition); |
|
142 | 146 |
} |
143 | 147 |
|
144 | 148 |
protected void createResulset() throws ReadException{ |
branches/v2_0_0_prep/libraries/libFMap_dataDB/src/org/gvsig/fmap/data/feature/db/jdbc/postgresql/PostgresqlFeatureCollectionEditing.java | ||
---|---|---|
6 | 6 |
import java.util.ConcurrentModificationException; |
7 | 7 |
import java.util.Iterator; |
8 | 8 |
|
9 |
import org.gvsig.tools.exception.BaseException; |
|
10 | 9 |
import org.gvsig.fmap.data.DataStore; |
11 | 10 |
import org.gvsig.fmap.data.ReadException; |
12 | 11 |
import org.gvsig.fmap.data.feature.FeatureManager; |
... | ... | |
14 | 13 |
import org.gvsig.fmap.data.feature.db.DBDataFeatureCollection; |
15 | 14 |
import org.gvsig.fmap.data.feature.db.DBFeatureType; |
16 | 15 |
import org.gvsig.fmap.data.feature.db.jdbc.SQLException; |
16 |
import org.gvsig.tools.exception.BaseException; |
|
17 | 17 |
|
18 | 18 |
public class PostgresqlFeatureCollectionEditing extends DBDataFeatureCollection { |
19 | 19 |
protected DBFeatureType featureType; |
... | ... | |
89 | 89 |
|
90 | 90 |
} |
91 | 91 |
|
92 |
|
|
93 |
public Iterator iterator() { |
|
94 |
checkModified(); |
|
95 |
try{ |
|
96 |
ResultSet r=null; |
|
97 |
r = this.getNewResulset(this.sql); |
|
98 |
PostgresIterator dbIter = new PostgresIterator(this.store, |
|
99 |
this.featureType, this.sql, this.fetchSize, |
|
100 |
this.featureManager); |
|
101 |
return dbIter; |
|
102 |
} catch (BaseException e){ |
|
103 |
throw new RuntimeException(e); |
|
104 |
} |
|
105 |
} |
|
106 |
|
|
92 |
protected Iterator internalIterator(int index) { |
|
93 |
checkModified(); |
|
94 |
try { |
|
95 |
ResultSet r = null; |
|
96 |
r = this.getNewResulset(this.sql); |
|
97 |
PostgresIterator dbIter = new PostgresIterator(this.store, |
|
98 |
this.featureType, this.sql, this.fetchSize, |
|
99 |
this.featureManager, index + 1); |
|
100 |
return dbIter; |
|
101 |
} catch (BaseException e) { |
|
102 |
throw new RuntimeException(e); |
|
103 |
} |
|
104 |
} |
|
105 |
|
|
107 | 106 |
protected class PostgresIterator extends AbstractPostgresqlDBIterator { |
108 | 107 |
|
109 | 108 |
public PostgresIterator(PostgresqlStore store, |
110 | 109 |
DBFeatureType featureType, String sql, int fetchSize, |
111 |
FeatureManager featureManager) throws ReadException { |
|
112 |
super(store, featureType, sql, fetchSize, featureManager, null); |
|
110 |
FeatureManager featureManager, int initialPosition) |
|
111 |
throws ReadException { |
|
112 |
super(store, featureType, sql, fetchSize, featureManager, null, |
|
113 |
initialPosition); |
|
113 | 114 |
} |
114 | 115 |
|
115 | 116 |
protected void checkModified() { |
branches/v2_0_0_prep/libraries/libFMap_dataDB/src/org/gvsig/fmap/data/feature/db/jdbc/h2/H2FeatureCollectionEditingFiltered.java | ||
---|---|---|
5 | 5 |
import java.util.Iterator; |
6 | 6 |
import java.util.NoSuchElementException; |
7 | 7 |
|
8 |
import org.gvsig.tools.exception.BaseException; |
|
9 | 8 |
import org.gvsig.fmap.data.DataManager; |
10 | 9 |
import org.gvsig.fmap.data.DataStore; |
11 | 10 |
import org.gvsig.fmap.data.ReadException; |
... | ... | |
15 | 14 |
import org.gvsig.fmap.data.feature.db.DBDataFeatureCollection; |
16 | 15 |
import org.gvsig.fmap.data.feature.db.DBFeatureType; |
17 | 16 |
import org.gvsig.fmap.data.feature.expressionevaluator.Filter; |
17 |
import org.gvsig.tools.exception.BaseException; |
|
18 | 18 |
|
19 | 19 |
public class H2FeatureCollectionEditingFiltered extends DBDataFeatureCollection { |
20 | 20 |
protected DBFeatureType featureType; |
... | ... | |
85 | 85 |
|
86 | 86 |
} |
87 | 87 |
|
88 |
|
|
89 |
public Iterator iterator() { |
|
88 |
protected Iterator internalIterator(int index) { |
|
90 | 89 |
checkModified(); |
91 | 90 |
try{ |
92 | 91 |
H2Iterator dbIter = new H2Iterator(this.store, this.featureType, |
93 |
this.sql, this.fetchSize, this.featureManager, this.parser); |
|
92 |
this.sql, this.fetchSize, this.featureManager, this.parser, |
|
93 |
index + 1); |
|
94 | 94 |
return dbIter; |
95 | 95 |
} catch (BaseException e){ |
96 | 96 |
throw new RuntimeException(e); |
... | ... | |
102 | 102 |
public H2Iterator(H2Store store, DBFeatureType featureType, |
103 | 103 |
String sql, |
104 | 104 |
int fetchSize, FeatureManager featureManager, |
105 |
Filter featureFilter) |
|
105 |
Filter featureFilter, int initialPosition)
|
|
106 | 106 |
throws ReadException { |
107 | 107 |
super(store, featureType, sql, fetchSize, featureManager, |
108 |
featureFilter); |
|
108 |
featureFilter, initialPosition);
|
|
109 | 109 |
} |
110 | 110 |
|
111 | 111 |
protected Feature createFeatureFromTheResulset() throws ReadException { |
branches/v2_0_0_prep/libraries/libFMap_dataDB/src/org/gvsig/fmap/data/feature/db/jdbc/h2/H2FeatureCollection.java | ||
---|---|---|
6 | 6 |
import java.util.ConcurrentModificationException; |
7 | 7 |
import java.util.Iterator; |
8 | 8 |
|
9 |
import org.gvsig.tools.exception.BaseException; |
|
10 | 9 |
import org.gvsig.fmap.data.DataStore; |
11 | 10 |
import org.gvsig.fmap.data.ReadException; |
12 | 11 |
import org.gvsig.fmap.data.feature.Feature; |
... | ... | |
15 | 14 |
import org.gvsig.fmap.data.feature.db.DBFeatureType; |
16 | 15 |
import org.gvsig.fmap.data.feature.db.jdbc.AbstractJDBCIterator; |
17 | 16 |
import org.gvsig.fmap.data.feature.db.jdbc.SQLException; |
17 |
import org.gvsig.tools.exception.BaseException; |
|
18 | 18 |
|
19 | 19 |
public class H2FeatureCollection extends DBDataFeatureCollection { |
20 | 20 |
protected DBFeatureType featureType; |
... | ... | |
120 | 120 |
} |
121 | 121 |
|
122 | 122 |
} |
123 |
|
|
124 |
protected Iterator internalIterator(int index) { |
|
125 |
checkModified(); |
|
126 |
AbstractJDBCIterator dbfIter = null; |
|
127 |
try { |
|
128 |
dbfIter = new H2Iterator(this.store, this.featureType, this.sql, |
|
129 |
this.fetchSize, index + 1); |
|
130 |
} catch (ReadException e) { |
|
131 |
throw new RuntimeException(e); |
|
132 |
} |
|
133 |
return dbfIter; |
|
134 |
} |
|
123 | 135 |
|
124 |
public Iterator iterator() { |
|
125 |
checkModified(); |
|
126 |
AbstractJDBCIterator dbfIter = null; |
|
127 |
try { |
|
128 |
dbfIter = new H2Iterator(this.store, this.featureType, this.sql, |
|
129 |
this.fetchSize); |
|
130 |
} catch (ReadException e) { |
|
131 |
throw new RuntimeException(e); |
|
132 |
} |
|
133 |
return dbfIter; |
|
134 |
} |
|
135 |
|
|
136 | 136 |
public class H2Iterator extends AbstractH2DBIterator { |
137 |
public H2Iterator(H2Store store, |
|
138 |
DBFeatureType featureType, String sql, |
|
139 |
int fetchSize) throws ReadException { |
|
140 |
super(store, featureType, sql, fetchSize, null, null); |
|
141 |
} |
|
142 | 137 |
|
138 |
public H2Iterator(H2Store store, DBFeatureType featureType, String sql, |
|
139 |
int fetchSize, int initialPosition) throws ReadException { |
|
140 |
super(store, featureType, sql, fetchSize, null, null, |
|
141 |
initialPosition); |
|
142 |
} |
|
143 |
|
|
143 | 144 |
protected void checkModified() { |
144 | 145 |
if (modified) { |
145 | 146 |
throw new ConcurrentModificationException( |
branches/v2_0_0_prep/libraries/libFMap_dataDB/src/org/gvsig/fmap/data/feature/db/jdbc/h2/H2FeatureCollectionEditing.java | ||
---|---|---|
6 | 6 |
import java.util.ConcurrentModificationException; |
7 | 7 |
import java.util.Iterator; |
8 | 8 |
|
9 |
import org.gvsig.tools.exception.BaseException; |
|
10 | 9 |
import org.gvsig.fmap.data.DataStore; |
11 | 10 |
import org.gvsig.fmap.data.ReadException; |
12 | 11 |
import org.gvsig.fmap.data.feature.Feature; |
... | ... | |
15 | 14 |
import org.gvsig.fmap.data.feature.db.DBDataFeatureCollection; |
16 | 15 |
import org.gvsig.fmap.data.feature.db.DBFeatureType; |
17 | 16 |
import org.gvsig.fmap.data.feature.db.jdbc.SQLException; |
17 |
import org.gvsig.tools.exception.BaseException; |
|
18 | 18 |
|
19 | 19 |
public class H2FeatureCollectionEditing extends DBDataFeatureCollection { |
20 | 20 |
protected DBFeatureType featureType; |
... | ... | |
94 | 94 |
} |
95 | 95 |
|
96 | 96 |
|
97 |
public Iterator iterator() {
|
|
98 |
checkModified();
|
|
99 |
try{
|
|
100 |
H2Iterator dbfIter = new H2Iterator(this.store, this.featureType,
|
|
101 |
this.sql, this.fetchSize, this.featureManager);
|
|
102 |
return dbfIter;
|
|
103 |
} catch (BaseException e){
|
|
104 |
throw new RuntimeException(e);
|
|
105 |
}
|
|
97 |
protected Iterator internalIterator(int index) {
|
|
98 |
checkModified();
|
|
99 |
try {
|
|
100 |
H2Iterator dbfIter = new H2Iterator(this.store, this.featureType,
|
|
101 |
this.sql, this.fetchSize, this.featureManager, index + 1);
|
|
102 |
return dbfIter;
|
|
103 |
} catch (BaseException e) {
|
|
104 |
throw new RuntimeException(e);
|
|
105 |
}
|
|
106 | 106 |
} |
107 |
|
|
108 |
protected class H2Iterator extends AbstractH2DBIterator { |
|
107 | 109 |
|
108 |
protected class H2Iterator extends AbstractH2DBIterator { |
|
109 | 110 |
public H2Iterator(H2Store store, DBFeatureType featureType, String sql, |
110 |
int fetchSize, FeatureManager featureManager) |
|
111 |
throws ReadException { |
|
112 |
super(store, featureType, sql, fetchSize, featureManager, null); |
|
113 |
} |
|
111 |
int fetchSize, FeatureManager featureManager, |
|
112 |
int initialPosition) throws ReadException { |
|
113 |
super(store, featureType, sql, fetchSize, featureManager, null, |
|
114 |
initialPosition); |
|
115 |
} |
|
114 | 116 |
|
115 | 117 |
protected Feature createFeatureFromTheResulset() throws ReadException { |
116 | 118 |
return ((H2Store) this.store).createFeatureFromResulset(this.rs, |
branches/v2_0_0_prep/libraries/libFMap_dataDB/src/org/gvsig/fmap/data/feature/db/jdbc/h2/AbstractH2DBIterator.java | ||
---|---|---|
40 | 40 |
|
41 | 41 |
|
42 | 42 |
public AbstractH2DBIterator(H2Store store, DBFeatureType featureType, |
43 |
String sql, int fetchSize, FeatureManager featureManager,
|
|
44 |
Filter featureFilter) throws ReadException {
|
|
45 |
super(store, featureType, sql, fetchSize, featureManager, featureFilter);
|
|
46 |
}
|
|
43 |
String sql, int fetchSize, FeatureManager featureManager,
|
|
44 |
Filter featureFilter) throws ReadException {
|
|
45 |
super(store, featureType, sql, fetchSize, featureManager, featureFilter);
|
|
46 |
}
|
|
47 | 47 |
|
48 |
public AbstractH2DBIterator(H2Store store, DBFeatureType featureType, |
|
49 |
String sql, int fetchSize, FeatureManager featureManager, |
|
50 |
Filter featureFilter, int initialPosition) throws ReadException { |
|
51 |
super(store, featureType, sql, fetchSize, featureManager, |
|
52 |
featureFilter, initialPosition); |
|
53 |
} |
|
54 |
|
|
48 | 55 |
protected String getFinalResulsetSQL() { |
49 | 56 |
return H2Utils.addLimitsToSQL(this.sql, this.fetchSize, |
50 | 57 |
this.page); |
branches/v2_0_0_prep/libraries/libFMap_dataDB/src/org/gvsig/fmap/data/feature/db/jdbc/AbstractJDBCIterator.java | ||
---|---|---|
41 | 41 |
|
42 | 42 |
public abstract class AbstractJDBCIterator implements Iterator { |
43 | 43 |
|
44 |
public AbstractJDBCIterator(JDBCStore store, DBFeatureType featureType, |
|
45 |
String sql, int fetchSize, FeatureManager featureManager, |
|
46 |
Filter featureFilter) throws ReadException { |
|
47 |
this.store = store; |
|
48 |
this.featureType = featureType; |
|
49 |
this.fetchSize = fetchSize; |
|
50 |
this.sql = sql; |
|
51 |
this.page = 0; |
|
52 |
this.index = 0; |
|
53 |
this.featureManager = featureManager; |
|
54 |
this.featureFilter = featureFilter; |
|
55 |
this.createResulset(); |
|
56 |
} |
|
57 | 44 |
protected boolean nextChecked = false; |
58 | 45 |
protected Feature feature; |
59 | 46 |
protected ResultSet rs; |
... | ... | |
68 | 55 |
protected int index; |
69 | 56 |
protected FeatureManager featureManager = null; |
70 | 57 |
protected Filter featureFilter = null; |
58 |
|
|
59 |
private int initialPosition = 1; |
|
71 | 60 |
|
61 |
public AbstractJDBCIterator(JDBCStore store, DBFeatureType featureType, |
|
62 |
String sql, int fetchSize, FeatureManager featureManager, |
|
63 |
Filter featureFilter, int initialPosition) throws ReadException { |
|
64 |
this.store = store; |
|
65 |
this.featureType = featureType; |
|
66 |
this.fetchSize = fetchSize; |
|
67 |
this.sql = sql; |
|
68 |
this.page = 0; |
|
69 |
this.index = 0; |
|
70 |
this.featureManager = featureManager; |
|
71 |
this.featureFilter = featureFilter; |
|
72 |
this.initialPosition = initialPosition; |
|
73 |
this.createResulset(); |
|
74 |
} |
|
75 |
|
|
76 |
public AbstractJDBCIterator(JDBCStore store, DBFeatureType featureType, |
|
77 |
String sql, int fetchSize, FeatureManager featureManager, |
|
78 |
Filter featureFilter) throws ReadException { |
|
79 |
this(store, featureType, sql, fetchSize, featureManager, featureFilter, |
|
80 |
1); |
|
81 |
} |
|
82 |
|
|
72 | 83 |
protected Feature nextDBFeature() { |
73 | 84 |
Feature feature = null; |
74 | 85 |
while (true) { |
... | ... | |
143 | 154 |
Statement st = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, |
144 | 155 |
ResultSet.CONCUR_READ_ONLY); |
145 | 156 |
this.rs = st.executeQuery(mSql); |
157 |
|
|
158 |
if (initialPosition > 1) { |
|
159 |
rs.absolute(initialPosition); |
|
160 |
} |
|
146 | 161 |
|
147 | 162 |
} catch (java.sql.SQLException e) { |
148 | 163 |
throw new SQLException(mSql, this.store.getName(), e); |
branches/v2_0_0_prep/libraries/libFMap_dataDB/src/org/gvsig/fmap/data/feature/db/jdbc/postgresqlbin/PostgresqlBinFeatureCollection.java | ||
---|---|---|
6 | 6 |
import java.util.ConcurrentModificationException; |
7 | 7 |
import java.util.Iterator; |
8 | 8 |
|
9 |
import org.gvsig.tools.exception.BaseException; |
|
10 | 9 |
import org.gvsig.fmap.data.DataStore; |
11 | 10 |
import org.gvsig.fmap.data.ReadException; |
12 | 11 |
import org.gvsig.fmap.data.feature.Feature; |
... | ... | |
15 | 14 |
import org.gvsig.fmap.data.feature.db.DBFeatureType; |
16 | 15 |
import org.gvsig.fmap.data.feature.db.jdbc.AbstractJDBCIterator; |
17 | 16 |
import org.gvsig.fmap.data.feature.db.jdbc.SQLException; |
17 |
import org.gvsig.tools.exception.BaseException; |
|
18 | 18 |
|
19 | 19 |
public class PostgresqlBinFeatureCollection extends DBDataFeatureCollection { |
20 | 20 |
protected DBFeatureType featureType; |
... | ... | |
121 | 121 |
|
122 | 122 |
} |
123 | 123 |
|
124 |
public Iterator iterator() { |
|
124 |
protected Iterator internalIterator(int index) { |
|
125 |
PostgresqlIterator dbfIter; |
|
126 |
try { |
|
127 |
dbfIter = new PostgresqlIterator(this.store, this.featureType, |
|
128 |
this.sql, this.fetchSize, index + 1); |
|
129 |
} catch (ReadException e) { |
|
130 |
throw new RuntimeException(e); |
|
131 |
} |
|
125 | 132 |
|
126 |
PostgresqlIterator dbfIter; |
|
127 |
try { |
|
128 |
dbfIter = new PostgresqlIterator(this.store, this.featureType, |
|
129 |
this.sql, this.fetchSize); |
|
130 |
} catch (ReadException e) { |
|
131 |
throw new RuntimeException(e); |
|
132 |
} |
|
133 |
return dbfIter; |
|
134 |
} |
|
133 | 135 |
|
134 |
return dbfIter; |
|
135 |
} |
|
136 |
|
|
137 | 136 |
protected class PostgresqlIterator extends AbstractJDBCIterator { |
138 | 137 |
private String cursorName = null; |
139 | 138 |
public PostgresqlIterator(PostgresqlBinStore store, |
140 |
DBFeatureType featureType, String sql, int fetchSize) |
|
139 |
DBFeatureType featureType, String sql, int fetchSize, |
|
140 |
int initialPosition) |
|
141 | 141 |
throws ReadException { |
142 |
super(store, featureType, sql, fetchSize, null, null); |
|
142 |
super(store, featureType, sql, fetchSize, null, null, |
|
143 |
initialPosition); |
|
143 | 144 |
|
144 | 145 |
} |
145 | 146 |
protected void createResulset() throws ReadException { |
branches/v2_0_0_prep/libraries/libFMap_dataDB/pom.xml | ||
---|---|---|
16 | 16 |
<dependencies> |
17 | 17 |
<dependency> |
18 | 18 |
<groupId>org.gvsig</groupId> |
19 |
<artifactId>libFMap_data</artifactId> |
|
20 |
<version>2.0-SNAPSHOT</version> |
|
21 |
</dependency> |
|
22 |
<dependency> |
|
23 |
<groupId>org.gvsig</groupId> |
|
24 |
<artifactId>libFMap_data</artifactId> |
|
25 |
<version>2.0-SNAPSHOT</version> |
|
26 |
<classifier>tests</classifier> |
|
27 |
<scope>test</scope> |
|
28 |
</dependency> |
|
29 |
<dependency> |
|
30 |
<groupId>org.gvsig</groupId> |
|
19 | 31 |
<artifactId>libFMap_dataFile</artifactId> |
20 | 32 |
<version>2.0-SNAPSHOT</version> |
21 | 33 |
</dependency> |
Also available in: Unified diff