Revision 28676 branches/v2_0_0_prep/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLStoreProviderWriter.java

View differences:

PostgreSQLStoreProviderWriter.java
40 40
import org.gvsig.fmap.dal.DataTypes;
41 41
import org.gvsig.fmap.dal.exception.DataException;
42 42
import org.gvsig.fmap.dal.exception.InitializeException;
43
import org.gvsig.fmap.dal.exception.OpenException;
44 43
import org.gvsig.fmap.dal.feature.Feature;
45 44
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
46 45
import org.gvsig.fmap.dal.feature.FeatureType;
47 46
import org.gvsig.fmap.dal.feature.exception.PerformEditingException;
48 47
import org.gvsig.fmap.dal.feature.spi.FeatureData;
49 48
import org.gvsig.fmap.dal.feature.spi.FeatureReferenceProviderServices;
50
import org.gvsig.fmap.dal.resource.exception.ResourceBeginException;
51 49
import org.gvsig.fmap.dal.store.jdbc.JDBCExecutePreparedSQLException;
52 50
import org.gvsig.fmap.dal.store.jdbc.JDBCExecuteSQLException;
53 51
import org.gvsig.fmap.dal.store.jdbc.JDBCPreparingSQLException;
......
62 60

  
63 61
	final static private Logger logger = LoggerFactory
64 62
			.getLogger(PostgreSQLStoreProvider.class);
63
	private String sqlForAppend;
64
	private List attrsForAppendMode;
65 65

  
66 66

  
67 67
	public PostgreSQLStoreProviderWriter() {
......
149 149

  
150 150
		boolean countChanged = deleteds.hasNext() || inserteds.hasNext();
151 151

  
152
		try {
153
			this.open();
154
		} catch (OpenException e2) {
155
			throw new PerformEditingException(this.getName(), e2);
156
		}
157
		try {
158
			this.resourceBegin();
159
		} catch (ResourceBeginException e2) {
160
			throw new PerformEditingException(this.getName(), e2);
161
		}
162 152

  
163 153
		TransactionalAction action = new TransactionalAction() {
164 154

  
......
208 198

  
209 199
		} catch (Exception e) {
210 200
			throw new PerformEditingException(this.getName(), e);
211
		} finally {
212
			this.resourceEnd();
213 201
		}
214 202
	}
215 203

  
......
797 785
		return strb.toString();
798 786
	}
799 787

  
788
	public boolean supportsAppendMode() {
789
		return true;
790
	}
791

  
792
	public void endAppend() throws DataException {
793
		this.loadMetadata();
794
	}
795

  
796
	public void append(final FeatureData featureData) throws DataException {
797
		TransactionalAction action = new TransactionalAction() {
798
			public Object action(Connection conn) throws DataException {
799

  
800
				PreparedStatement st;
801
				try {
802
					st = conn.prepareStatement(sqlForAppend);
803
				} catch (SQLException e) {
804
					throw new JDBCPreparingSQLException(sqlForAppend, e);
805
				}
806
				try {
807
//					perfomInsert(conn, st, sqlForAppend, featureData, attrsForAppendMode);
808
				} finally {
809
					try {st.close();} catch (SQLException e) {	};
810
				}
811
				return null;
812
			}
813

  
814
			public boolean continueTransactionAllowed() {
815
				return false;
816
			}
817
		};
818
		try {
819
			this.helper.doConnectionAction(action);
820

  
821
			resetCount();
822

  
823
		} catch (Exception e) {
824
			throw new PerformEditingException(this.getName(), e);
825
		}
826
	}
827

  
828
	public void beginAppend() throws DataException {
829
		StringBuilder sqlb = new StringBuilder();
830
		List attrs = new ArrayList();
831

  
832
		prepareSQLAndAttributeListForInser(sqlb, attrs);
833

  
834
		sqlForAppend = sqlb.toString();
835
		attrsForAppendMode = attrs;
836
	}
837

  
800 838
}

Also available in: Unified diff