Class WritableDataStoreDataSource
java.lang.Object
com.vividsolutions.jump.io.datasource.DataSource
com.vividsolutions.jump.workbench.ui.plugin.datastore.DataStoreQueryDataSource
com.vividsolutions.jump.workbench.ui.plugin.datastore.DataStoreDataSource
org.openjump.core.ui.plugin.datastore.WritableDataStoreDataSource
- All Implemented Interfaces:
WorkbenchContextReference
- Direct Known Subclasses:
H2DataStoreDataSource, PostGISDataStoreDataSource
Extension of DataBaseDataSource adding write capabilities.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringprotected final LinkedHashMap<Integer, Evolution> static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected Stringprotected Stringstatic final Stringprotected Stringstatic final StringFields inherited from class DataStoreDataSource
CACHING_KEY, context, DATASET_NAME_KEY, GEOMETRY_ATTRIBUTE_NAME_KEY, MAX_FEATURES_KEY, WHERE_CLAUSE_KEYFields inherited from class DataStoreQueryDataSource
CONNECTION_DESCRIPTOR_KEY, PATTERN_FENCE, PATTERN_SELECTION, PATTERN_VIEW, PRIMARY_KEY_KEY, SQL_QUERY_KEYFields inherited from class DataSource
CHARSET_KEY, COMPRESSED_KEY, COORDINATE_SYSTEM_CODE, COORDINATE_SYSTEM_KEY, COORDINATE_SYSTEM_REGISTRY, FILE_KEY, URI_KEY -
Constructor Summary
ConstructorsConstructorDescriptionWritableDataStoreDataSource(ConnectionDescriptor connectionDescriptor, String datasetName, String geometryAttributeName, String externalPKName, String txManager, WorkbenchContext context) Constructor with mandatory parameters for a WritableDataStoreDataSource. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCreation(Feature feature) protected abstract voidaddDBPrimaryKey(SpatialDatabasesDSConnection conn, String primaryKey) Add an automatically named primary key constraint to the table.voidaddModification(Feature feature, Feature oldFeature) voidaddSuppression(Feature feature) protected abstract voidcreateAndPopulateTable(SpatialDatabasesDSConnection conn, FeatureCollection fc, int srid, String geometryType, boolean multi, int dim, boolean normalizedColumnNames) Create and populate a table with features from a dataset.protected abstract voidExecute a query against this connection to delete the reference to this table in the PostGIS's geometry_columns table.abstract voidDeprecated.Creates a new Connection to this DataSource.protected static intgetGeometryDimension(FeatureCollection coll, int defaultDim) Return 3 if coll contains at least one 3d geometry, 2 if coll contains only 2d geometries and defaultDim if coll is empty.protected static ClassgetGeometryType(FeatureCollection coll, boolean narrow, boolean multi) Determine database geometry type according to values present in the feature collection narrow attribute : true means that we want to use the most specific attribute type able to represent all geometries of the collection multi parameter : true means that we previously transform single geometry types into multigeometry types to be able to use the same type (multi) for geometries of same dimension (single or multi)Return a map with modified features indexed by their database id.protected abstract intgetTableSRID(Connection conn, String column) protected org.locationtech.jts.geom.Geometryprotected PreparedStatementinsertStatement(SpatialDatabasesDSConnection conn, FeatureSchema fSchema, boolean multi, boolean normalizedColumnNames) Create a statement to insert a feature into the databasebooleanvoidremoveEvolution(int fid) Remove the evolution currently recorded for feature fid.protected PreparedStatementsetAttributeValues(PreparedStatement pstmt, Feature feature, int srid, boolean multi, int dim) voidsetCoordDimension(int dbCoordDim) voidsetLimitedToView(boolean limitedToView) voidsetManageConflicts(boolean manageConflicts) voidsetMultiGeometry(boolean multi) voidsetSRID(int srid) voidsetTableAlreadyCreated(boolean tableAlreadyCreated) Add this attribute to decide if executeUpdate must write a new table or commit to an existing table.Methods inherited from class DataStoreDataSource
createFeatureCollection, getWorkbenchContext, setMaxFeature, setWhereClause, setWorkbenchContextMethods inherited from class DataStoreQueryDataSource
expandQueryMethods inherited from class DataSource
getProperties, installCoordinateSystem, isDisabled, isReadable, setDisabled, setProperties
-
Field Details
-
LIMITED_TO_VIEW
- See Also:
-
MANAGE_CONFLICTS
- See Also:
-
EXTERNAL_PK_KEY
- See Also:
-
SRID_KEY
- See Also:
-
GEOM_DIM_KEY
- See Also:
-
NAN_Z_TO_VALUE_KEY
- See Also:
-
NARROW_GEOMETRY_TYPE_KEY
- See Also:
-
CONVERT_TO_MULTIGEOMETRY_KEY
- See Also:
-
CREATE_PK
- See Also:
-
NORMALIZED_COLUMN_NAMES
- See Also:
-
TX_MANAGER_KEY
- See Also:
-
DEFAULT_PK_NAME
- See Also:
-
evolutions
-
schemaName
-
tableName
-
-
-
Constructor Details
-
WritableDataStoreDataSource
public WritableDataStoreDataSource() -
WritableDataStoreDataSource
public WritableDataStoreDataSource(ConnectionDescriptor connectionDescriptor, String datasetName, String geometryAttributeName, String externalPKName, String txManager, WorkbenchContext context) Constructor with mandatory parameters for a WritableDataStoreDataSource.- Parameters:
connectionDescriptor- descriptor of the connection this datasource is connected todatasetName- dataset namegeometryAttributeName- geometry attribute nameexternalPKName- database primary key used to manage feature updatestxManager- the transaction managercontext- global context of the application
-
-
Method Details
-
setLimitedToView
public void setLimitedToView(boolean limitedToView) -
setManageConflicts
public void setManageConflicts(boolean manageConflicts) -
setMultiGeometry
public void setMultiGeometry(boolean multi) -
setCoordDimension
public void setCoordDimension(int dbCoordDim) -
setSRID
public void setSRID(int srid) -
setTableAlreadyCreated
public void setTableAlreadyCreated(boolean tableAlreadyCreated) Add this attribute to decide if executeUpdate must write a new table or commit to an existing table. Note : I tried first to set this property in the DataSourceQuery properties, but properties are set through the "load" or "save as" dialog box and are not supposed to change (I tried to change the value at the end of an executeUpdate, but initial properties set in the dialog box are re-applied and overwrite changed value after that).- Parameters:
tableAlreadyCreated- true if the table already exists
-
isWritable
public boolean isWritable()- Overrides:
isWritablein classDataStoreDataSource
-
getConnection
Description copied from class:DataSourceCreates a new Connection to this DataSource.- Overrides:
getConnectionin classDataStoreDataSource- Returns:
- a Connection to connect to this DataSource
-
finalizeUpdate
Deprecated.With some databases, it may be useful to do some cleaning after a big update. Example : perform a vacuum analyze in PostgreSQL to compact database and to update statistics (needed by ST_EstimatedExtent function)- Parameters:
conn- the Connection to use to finalize the update- Throws:
Exception- if an Exception occurs during update finalization
-
insertStatement
protected PreparedStatement insertStatement(SpatialDatabasesDSConnection conn, FeatureSchema fSchema, boolean multi, boolean normalizedColumnNames) throws SQLException Create a statement to insert a feature into the database- Parameters:
conn- connection to the database to update.fSchema- feature schemamulti- true to force geometry to be a MultiGeometrynormalizedColumnNames- whether database column names should be normalized (lowercase) or not- Returns:
- a PreparedStatement
- Throws:
SQLException- if an exception occurs during insert
-
setAttributeValues
protected PreparedStatement setAttributeValues(PreparedStatement pstmt, Feature feature, int srid, boolean multi, int dim) throws SQLException - Throws:
SQLException
-
getTableSRID
- Throws:
SQLException
-
getViewEnvelope
protected org.locationtech.jts.geom.Geometry getViewEnvelope() -
addCreation
- Throws:
EvolutionOperationException
-
addModification
- Throws:
EvolutionOperationException
-
addSuppression
- Throws:
EvolutionOperationException
-
removeEvolution
public void removeEvolution(int fid) Remove the evolution currently recorded for feature fid. To be used cautiously : this method is used by DataStoreTransactionManager to remove an evolution when the newFeature of this evolution happens to be the same as the last version updated from the server (false conflict).- Parameters:
fid- id of the feature to be removed in the evolution stack
-
getUncommittedEvolutions
-
getIndexedEvolutions
-
deleteTableQuery
Execute a query against this connection to delete the reference to this table in the PostGIS's geometry_columns table.- Parameters:
conn- connection to use to delete the table- Throws:
SQLException- if the server returns an exception while deleting
-
createAndPopulateTable
protected abstract void createAndPopulateTable(SpatialDatabasesDSConnection conn, FeatureCollection fc, int srid, String geometryType, boolean multi, int dim, boolean normalizedColumnNames) throws SQLException Create and populate a table with features from a dataset.- Parameters:
conn- connection to the databasefc- featureCollection to upload to the databasesrid- srid of the geometrygeometryType- geometry typemulti- true to force geometry to be a MultiGeometrydim- geometry dimensionnormalizedColumnNames- whether columns names have to be normalized or not- Throws:
SQLException- if an exception occurs during table creation or inserts
-
addDBPrimaryKey
protected abstract void addDBPrimaryKey(SpatialDatabasesDSConnection conn, String primaryKey) throws SQLException Add an automatically named primary key constraint to the table.- Parameters:
conn- the Connection to use to add the Primary KeyprimaryKey- the column name for th primary key- Throws:
SQLException- if an exception occurs during primary key addition
-
getGeometryDimension
Return 3 if coll contains at least one 3d geometry, 2 if coll contains only 2d geometries and defaultDim if coll is empty.- Parameters:
coll- featureCollection to extract geometry dimension fromdefaultDim- set a default in the case coll is empty- Returns:
- the geometry dimension of collection features
-
getGeometryType
Determine database geometry type according to- values present in the feature collection
- narrow attribute : true means that we want to use the most specific attribute type able to represent all geometries of the collection
- multi parameter : true means that we previously transform single geometry types into multigeometry types to be able to use the same type (multi) for geometries of same dimension (single or multi)
- Parameters:
coll- featureCollection to extract geometry dimension fromnarrow- true to use a specific geometry type where possiblemulti- true to always use a MultiGeometry- Returns:
- the geometry class to be used
-