private List<String> performUpdateRelational( QName ftName, List<ParsedPropertyReplacement> replacementProps, Filter filter) throws FeatureStoreException { IdFilter idFilter = null; try { if (filter instanceof IdFilter) { idFilter = (IdFilter) filter; } else { idFilter = getIdFilter(ftName, (OperatorFilter) filter); } } catch (Exception e) { LOG.debug(e.getMessage(), e); } List<String> updated = null; if (blobMapping != null) { throw new FeatureStoreException( "Updates in SQLFeatureStore (BLOB mode) are currently not implemented."); } else { try { updated = performUpdateRelational(ftName, replacementProps, idFilter); if (fs.getCache() != null) { for (ResourceId id : idFilter.getSelectedIds()) { fs.getCache().remove(id.getRid()); } } } catch (Exception e) { LOG.debug(e.getMessage(), e); throw new FeatureStoreException(e.getMessage(), e); } } return updated; }
private int performDeleteBlob(IdFilter filter, Lock lock) throws FeatureStoreException { int deleted = 0; PreparedStatement stmt = null; try { stmt = conn.prepareStatement( "DELETE FROM " + blobMapping.getTable() + " WHERE " + blobMapping.getGMLIdColumn() + "=?"); for (ResourceId id : filter.getSelectedIds()) { stmt.setString(1, id.getRid()); stmt.addBatch(); if (fs.getCache() != null) { fs.getCache().remove(id.getRid()); } } int[] deletes = stmt.executeBatch(); for (int noDeleted : deletes) { deleted += noDeleted; } } catch (SQLException e) { LOG.debug(e.getMessage(), e); throw new FeatureStoreException(e.getMessage(), e); } finally { JDBCUtils.close(stmt); } LOG.debug("Deleted " + deleted + " features."); return deleted; }
private void addRelationallyMappedMultiProperty( ParsedPropertyReplacement replacement, Mapping mapping, FeatureTypeMapping ftMapping, List<ResourceId> list) throws FilterEvaluationException, FeatureStoreException, SQLException { UpdateAction action = replacement.getUpdateAction(); if (action == null) { action = UpdateAction.INSERT_AFTER; } switch (action) { case INSERT_BEFORE: case REMOVE: case REPLACE: LOG.warn( "Updating of multi properties is currently only supported for 'insertAfter' update action. Omitting."); break; case INSERT_AFTER: break; default: break; } InsertRowManager mgr = new InsertRowManager(fs, conn, null); List<Property> props = Collections.singletonList(replacement.getNewValue()); for (ResourceId id : list) { IdAnalysis analysis = schema.analyzeId(id.getRid()); FeatureType featureType = schema.getFeatureType(ftMapping.getFeatureType()); Feature f = featureType.newFeature(id.getRid(), props, null); mgr.updateFeature(f, ftMapping, analysis.getIdKernels(), mapping, replacement); } }
private int performDeleteRelational(IdFilter filter, Lock lock) throws FeatureStoreException { int deleted = 0; for (ResourceId id : filter.getSelectedIds()) { LOG.debug("Analyzing id: " + id.getRid()); IdAnalysis analysis = null; try { analysis = schema.analyzeId(id.getRid()); LOG.debug("Analysis: " + analysis); if (!schema.getKeyDependencies().getDeleteCascadingByDB()) { LOG.debug("Deleting joined rows manually."); deleteJoinedRows(analysis); } else { LOG.debug("Depending on database to delete joined rows automatically."); } deleted += deleteFeatureRow(analysis); } catch (IllegalArgumentException e) { throw new FeatureStoreException("Unable to determine feature type for id '" + id + "'."); } } return deleted; }