Revision 11339 trunk/extensions/extJDBC/src/com/iver/cit/gvsig/fmap/drivers/jdbc/mysql/MySqlFeatureIterator.java
MySqlFeatureIterator.java | ||
---|---|---|
51 | 51 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
52 | 52 |
import com.hardcode.gdbms.engine.values.Value; |
53 | 53 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
54 |
import com.iver.cit.gvsig.fmap.SqlDriveExceptionType; |
|
55 | 54 |
import com.iver.cit.gvsig.fmap.core.DefaultFeature; |
56 | 55 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
57 | 56 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
58 | 57 |
import com.iver.cit.gvsig.fmap.drivers.DBLayerDefinition; |
59 |
import com.iver.cit.gvsig.fmap.drivers.FeatureWithoutIdExceptionType; |
|
60 | 58 |
import com.iver.cit.gvsig.fmap.drivers.IFeatureIterator; |
61 | 59 |
import com.iver.cit.gvsig.fmap.drivers.WKBParser2; |
62 | 60 |
|
63 | 61 |
/** |
64 |
* @author FJP |
|
62 |
* Iterator over the features of a MySQL driver. |
|
63 |
* |
|
65 | 64 |
* |
66 |
* TODO To change the template for this generated type comment go to
|
|
67 |
* Window - Preferences - Java - Code Generation - Code and Comments
|
|
65 |
* |
|
66 |
* @author FJP
|
|
68 | 67 |
*/ |
69 | 68 |
public class MySqlFeatureIterator implements IFeatureIterator { |
70 | 69 |
private WKBParser2 parser = new WKBParser2(); |
... | ... | |
123 | 122 |
*/ |
124 | 123 |
public IFeature next() throws ReadDriverException { |
125 | 124 |
byte[] data; |
125 |
|
|
126 | 126 |
try { |
127 | 127 |
data = rs.getBytes(1); |
128 | 128 |
geom = parser.parse(data); |
... | ... | |
135 | 135 |
String strAux = rs.getString(fieldId); |
136 | 136 |
if (strAux == null) strAux = ""; |
137 | 137 |
val = ValueFactory.createValue(strAux); |
138 |
} |
|
139 |
if (metaData.getColumnType(fieldId) == Types.FLOAT) |
|
138 |
}else if (metaData.getColumnType(fieldId) == Types.FLOAT) |
|
140 | 139 |
val = ValueFactory.createValue(rs.getFloat(fieldId)); |
141 |
if (metaData.getColumnType(fieldId) == Types.DOUBLE) |
|
140 |
else if (metaData.getColumnType(fieldId) == Types.DOUBLE)
|
|
142 | 141 |
val = ValueFactory.createValue(rs.getDouble(fieldId)); |
143 |
if (metaData.getColumnType(fieldId) == Types.INTEGER) |
|
142 |
else if (metaData.getColumnType(fieldId) == Types.INTEGER)
|
|
144 | 143 |
val = ValueFactory.createValue(rs.getInt(fieldId)); |
145 |
if (metaData.getColumnType(fieldId) == Types.BIGINT) |
|
144 |
else if (metaData.getColumnType(fieldId) == Types.BIGINT)
|
|
146 | 145 |
val = ValueFactory.createValue(rs.getLong(fieldId)); |
147 |
if (metaData.getColumnType(fieldId) == Types.BIT) |
|
146 |
else if (metaData.getColumnType(fieldId) == Types.BIT)
|
|
148 | 147 |
val = ValueFactory.createValue(rs.getBoolean(fieldId)); |
149 |
if (metaData.getColumnType(fieldId) == Types.DATE) |
|
148 |
else if (metaData.getColumnType(fieldId) == Types.DATE)
|
|
150 | 149 |
val = ValueFactory.createValue(rs.getDate(fieldId)); |
151 | 150 |
|
152 |
// regAtt[relIds[fieldId-2]] = val; |
|
153 |
//TODO No se que hace exactamente relIds[fieldId-2], pero estaba todo a 0 |
|
154 |
//REVISAR |
|
155 |
regAtt[fieldId-2] = val; |
|
156 |
|
|
157 |
|
|
151 |
regAtt[relIds[fieldId-2]] = val; |
|
158 | 152 |
} |
159 |
|
|
160 |
// TODO: Aqu? habr?a que usar una Factor?a. |
|
161 |
|
|
162 | 153 |
IFeature feat = null; |
163 | 154 |
if (idFieldID != -1) |
164 |
{ |
|
165 |
String theID = regAtt[lyrDef.getIdFieldID()].toString(); |
|
155 |
{//TODO Review if we could find problems when the table has only geom and gid |
|
156 |
int fieldId = lyrDef.getIdFieldID(); |
|
157 |
Value idValue = regAtt[fieldId]; |
|
158 |
String theID = ""; |
|
159 |
if(idValue != null)//azabala: sometimes we found problems with gid (null pointer exceptions) |
|
160 |
theID = idValue.toString(); |
|
166 | 161 |
feat = new DefaultFeature(geom, regAtt, theID); |
167 | 162 |
} |
168 | 163 |
else |
... | ... | |
172 | 167 |
// type.setSchema(lyrDef); |
173 | 168 |
throw new ReadDriverException("MySQL Driver",null); |
174 | 169 |
} |
170 |
|
|
175 | 171 |
|
176 | 172 |
|
177 | 173 |
|
Also available in: Unified diff