CompoundMapping cm = (CompoundMapping) particle; for ( Mapping child : cm.getParticles() ) { deleteJoinedRows( child, joinKeyColToValue );
joinKeyToValue.put( toColumn, rs.getObject( i++ ) ); deleteJoinedRows( particle, tableJoin, joinKeyToValue ); CompoundMapping cm = (CompoundMapping) particle; for ( Mapping child : cm.getParticles() ) { deleteJoinedRows( child, keyColToValue );
private int performDeleteRelational( IdFilter filter, Lock lock ) throws FeatureStoreException { checkIfFeaturesAreNotLocked( filter, lock ); 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; }
/** * Deletes the joined rows for the specified feature id. * <p> * Deletes all joined rows and transitive join rows, but stops at joins to subfeature tables. * </p> * * @param fid * feature id, must not be <code>null</code> * @throws FeatureStoreException */ private void deleteJoinedRows( IdAnalysis fid ) throws FeatureStoreException { Map<SQLIdentifier, Object> keyColsToValues = new HashMap<SQLIdentifier, Object>(); FeatureTypeMapping ftMapping = schema.getFtMapping( fid.getFeatureType().getName() ); // add values for feature id columns int i = 0; for ( Pair<SQLIdentifier, BaseType> fidColumns : ftMapping.getFidMapping().getColumns() ) { PrimitiveType pt = new PrimitiveType( fidColumns.second ); PrimitiveValue value = new PrimitiveValue( fid.getIdKernels()[i], pt ); Object sqlValue = SQLValueMangler.internalToSQL( value ); keyColsToValues.put( fidColumns.first, sqlValue ); i++; } // traverse mapping particles for ( Mapping particle : ftMapping.getMappings() ) { deleteJoinedRows( particle, keyColsToValues ); } }