Revision 10626 trunk/extensions/extCAD/src/com/iver/cit/gvsig/writers/WriterGT2.java

View differences:

WriterGT2.java
11 11
import org.geotools.data.FeatureReader;
12 12
import org.geotools.data.FeatureStore;
13 13
import org.geotools.data.Transaction;
14
import org.geotools.factory.FactoryConfigurationError;
15 14
import org.geotools.feature.AttributeType;
16 15
import org.geotools.feature.AttributeTypeFactory;
17 16
import org.geotools.feature.Feature;
18 17
import org.geotools.feature.FeatureType;
19
import org.geotools.feature.FeatureTypeBuilder;
18
import org.geotools.feature.FeatureTypes;
20 19
import org.geotools.feature.IllegalAttributeException;
21 20
import org.geotools.feature.SchemaException;
22 21
import org.geotools.filter.Filter;
23 22
import org.geotools.filter.FilterFactory;
24 23

  
25
import com.hardcode.gdbms.engine.data.driver.DriverException;
24
import com.hardcode.gdbms.driver.exceptions.InitializeWriterException;
25
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
26 26
import com.hardcode.gdbms.engine.values.NullValue;
27
import com.iver.cit.gvsig.exceptions.visitors.ProcessWriterVisitorException;
28
import com.iver.cit.gvsig.exceptions.visitors.StartWriterVisitorException;
29
import com.iver.cit.gvsig.exceptions.visitors.StopWriterVisitorException;
27 30
import com.iver.cit.gvsig.fmap.core.FShape;
28 31
import com.iver.cit.gvsig.fmap.core.IFeature;
29 32
import com.iver.cit.gvsig.fmap.drivers.ITableDefinition;
30
import com.iver.cit.gvsig.fmap.edition.EditionException;
31 33
import com.iver.cit.gvsig.fmap.edition.IRowEdited;
32 34
import com.iver.cit.gvsig.fmap.edition.writers.AbstractWriter;
33 35
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
......
80 82
        return NullValue.class;
81 83
    }
82 84

  
83
	public static FeatureType getFeatureType(FLyrVect layer, String geomField, String featName) throws DriverException, com.iver.cit.gvsig.fmap.DriverException, FactoryConfigurationError, SchemaException {
85
	public static FeatureType getFeatureType(FLyrVect layer, String geomField, String featName) throws SchemaException, ReadDriverException {
84 86

  
85 87
		Class geomType = findBestGeometryClass(layer.getShapeType());
86 88
		// geomType = Geometry.class;
......
94 96
					layer.getRecordset().getFieldName(i-1),
95 97
					getClassBySqlTYPE(layer.getRecordset().getFieldType(i-1)));
96 98
		}
97
		FeatureType featType = FeatureTypeBuilder.newFeatureType(att,featName);
99
		FeatureType featType = FeatureTypes.newFeatureType(att,featName);
98 100
		return featType;
99 101
	}
100 102

  
......
124 126
		  }
125 127

  
126 128

  
127
	public WriterGT2(FeatureStore featureStore, boolean writeAllFeatures) throws IOException
129
	public WriterGT2(FeatureStore featureStore, boolean writeAllFeatures)
128 130
	{
129 131
		this.featStore = featureStore;
130 132
		this.bWriteAll = writeAllFeatures;
......
133 135
	/* (non-Javadoc)
134 136
	 * @see com.iver.cit.gvsig.fmap.edition.IWriter#preProcess()
135 137
	 */
136
	public void preProcess() throws EditionException {
138
	public void preProcess() throws StartWriterVisitorException{
137 139
		try {
138 140
			types = featStore.getSchema().getAttributeTypes();
139 141
			t = new DefaultTransaction("handle");
......
142 144
			t.addAuthorization("handle");  // provide authoriztion
143 145

  
144 146

  
145
		} catch (Exception e) {
146
			e.printStackTrace();
147
			throw new EditionException(e);
147
		} catch (IOException e) {
148
			throw new StartWriterVisitorException(getName(),e);
148 149
		}
149 150

  
150 151

  
......
153 154
	/* (non-Javadoc)
154 155
	 * @see com.iver.cit.gvsig.fmap.edition.IWriter#process(com.iver.cit.gvsig.fmap.edition.IRowEdited)
155 156
	 */
156
	public void process(IRowEdited row) throws EditionException {
157
	public void process(IRowEdited row) throws ProcessWriterVisitorException {
157 158

  
158 159
		IFeature feat = (IFeature) row.getLinkedRow();
159 160
		// FeatureType featType = featStore.getSchema();
......
194 195

  
195 196
			numReg++;
196 197
		} catch (IOException e) {
197
			e.printStackTrace();
198
			throw new EditionException(e);
198
			throw new ProcessWriterVisitorException(getName(),e);
199 199
		} catch (IllegalAttributeException e) {
200
			e.printStackTrace();
201
			throw new EditionException(e);
200
			throw new ProcessWriterVisitorException(getName(),e);
202 201
		}
203 202

  
204 203

  
......
209 208
	/* (non-Javadoc)
210 209
	 * @see com.iver.cit.gvsig.fmap.edition.IWriter#postProcess()
211 210
	 */
212
	public void postProcess() throws EditionException {
211
	public void postProcess() throws StopWriterVisitorException  {
213 212
		try
214 213
		{
215 214
			t.commit(); // commit opperations
......
218 217
			try {
219 218
				t.rollback();
220 219
			} catch (IOException e) {
221
				e.printStackTrace();
222
				throw new EditionException(e);
220
				throw new StopWriterVisitorException(getName(),e);
223 221
			} // cancel opperations
224 222
		}
225 223
		finally {
226 224
			try {
227 225
				t.close();
228 226
			} catch (IOException e) {
229
				e.printStackTrace();
230
				throw new EditionException(e);
227
				throw new StopWriterVisitorException(getName(),e);
231 228
			} // free resources
232 229
		}
233 230

  
......
286 283

  
287 284
	}
288 285

  
289
	public void initialize(ITableDefinition tableDefinition) throws EditionException {
286
	public void initialize(ITableDefinition tableDefinition) throws InitializeWriterException {
290 287
		super.initialize(tableDefinition);
291
		
288

  
292 289
	}
293 290

  
294 291
	public boolean canAlterTable() {

Also available in: Unified diff