/** * Returns the relational mapping for the given feature type name. * * @param ftName * name of the feature type, must not be <code>null</code> * @return relational mapping for the feature type, may be <code>null</code> (no relational mapping) */ public FeatureTypeMapping getMapping( QName ftName ) { return schema.getFtMapping( ftName ); }
FeatureTypeMapping ftMapping = getSchema().getFtMapping( ftName ); ftTable = ftMapping.getFtTable(); } else if ( !join.getToTable().getName().equals( "?" ) ) {
@Override public boolean isMapped( QName ftName ) { if ( schema.getFtMapping( ftName ) != null ) { return true; } if ( schema.getBBoxMapping() != null ) { return true; } return false; }
private List<StringBuffer> getRelationalCreates() { List<StringBuffer> ddl = new ArrayList<StringBuffer>(); for ( short ftId = 0; ftId < schema.getFts(); ftId++ ) { QName ftName = schema.getFtName( ftId ); FeatureTypeMapping ftMapping = schema.getFtMapping( ftName ); if ( ftMapping != null ) { ddl.addAll( process( ftMapping ) ); } } return ddl; }
public FeatureParticleConverter( SQLIdentifier fkColumn, SQLIdentifier hrefColumn, GMLReferenceResolver resolver, FeatureType valueFt, MappedAppSchema schema ) { this.fkColumn = fkColumn; this.hrefColumn = hrefColumn; this.resolver = resolver; this.valueFt = valueFt; this.schema = schema; if ( valueFt != null && schema.getSubtypes( valueFt ).length == 0 && schema.getFtMapping( valueFt.getName() ) != null ) { fidPrefix = schema.getFtMapping( valueFt.getName() ).getFidMapping().getPrefix(); } else { fidPrefix = null; } }
/** * @param featureOrGeomId feature or geometry ID * @return never <code>null</code> * @throws IllegalArgumentException if given ID not found */ public IdAnalysis analyze( String featureOrGeomId ) { FeatureType ft = getFeatureType( featureOrGeomId ); FIDMapping fidMapping = schema.getFtMapping( ft.getName() ).getFidMapping(); String idRemainder = featureOrGeomId.substring( fidMapping.getPrefix().length() ); return new IdAnalysis( ft, idRemainder, fidMapping ); }
Envelope calcEnvelope( QName ftName, Connection conn ) throws FeatureStoreException { Envelope env = null; FeatureType ft = schema.getFeatureType( ftName ); if ( ft != null ) { // TODO what should be favored for hybrid mappings? if ( blobMapping != null ) { env = calcEnvelope( ftName, blobMapping, conn ); } else if ( schema.getFtMapping( ft.getName() ) != null ) { FeatureTypeMapping ftMapping = schema.getFtMapping( ft.getName() ); env = calcEnvelope( ftMapping, conn ); } } bboxCache.set( ftName, env ); return env; }
private int deleteFeatureRow( IdAnalysis analysis ) throws FeatureStoreException { int deleted = 0; FeatureTypeMapping ftMapping = schema.getFtMapping( analysis.getFeatureType().getName() ); FIDMapping fidMapping = ftMapping.getFidMapping(); PreparedStatement stmt = null;
private void initConverters() { for ( FeatureType ft : schema.getFeatureTypes() ) { FeatureTypeMapping ftMapping = schema.getFtMapping( ft.getName() ); if ( ftMapping != null ) { for ( Mapping particleMapping : ftMapping.getMappings() ) { initConverter( particleMapping ); } } } }
private List<String> performUpdateRelational( QName ftName, List<ParsedPropertyReplacement> replacementProps, IdFilter filter ) throws FeatureStoreException, FilterEvaluationException { FeatureTypeMapping ftMapping = schema.getFtMapping( ftName ); FIDMapping fidMapping = ftMapping.getFidMapping(); int updated = 0; PreparedStatement stmt = null; try { String sql = createRelationalUpdateStatement( ftMapping, fidMapping, replacementProps, filter.getSelectedIds() ); if ( sql != null ) { LOG.debug( "Update: " + sql ); stmt = conn.prepareStatement( sql.toString() ); setRelationalUpdateValues( replacementProps, ftMapping, stmt, filter, fidMapping ); int[] updates = stmt.executeBatch(); for ( int noUpdated : updates ) { updated += noUpdated; } } } catch ( SQLException e ) { JDBCUtils.log( e, LOG ); throw new FeatureStoreException( JDBCUtils.getMessage( e ), e ); } finally { JDBCUtils.close( stmt ); } LOG.debug( "Updated {} features.", updated ); return new ArrayList<String>( filter.getMatchingIds() ); }
/** * Creates a new {@link IdAnalyzer} instance for the given {@link MappedAppSchema}. * * @param schema application schema with mapping information, must not be <code>null</code> */ public IdAnalyzer( MappedAppSchema schema ) { this.schema = schema; for ( FeatureType ft : schema.getFeatureTypes() ) { if ( !ft.isAbstract() ) { FeatureTypeMapping ftMapping = schema.getFtMapping( ft.getName() ); if ( ftMapping != null ) { FIDMapping fidMapping = ftMapping.getFidMapping(); if ( fidMapping != null ) { LOG.debug( fidMapping.getPrefix() + " -> " + ft.getName() ); prefixToFt.put( fidMapping.getPrefix(), ft ); } } } } prefixKeysSortedByLengthDesc = prefixToFt.keySet().toArray( new String[0] ); sortByLengthDescending( prefixKeysSortedByLengthDesc ); }
FeatureTypeMapping ftMapping = schema.getFtMapping( ft.getName() );
QName ftName = QName.valueOf( qName ); FeatureType ft = schema.getFeatureType( ftName ); if ( schema.getFtMapping( ft.getName() ) != null ) { writeFeatureTypeMapping( writer, ft );
FeatureType ft = getSchema().getFeatureType( ftName ); checkIfFeatureTypIsRequested( typeNames, ft ); FeatureTypeMapping ftMapping = getSchema().getFtMapping( ftName ); FIDMapping fidMapping = ftMapping.getFidMapping(); List<IdAnalysis> idKernels = ftNameToIdAnalysis.get( ftName );
private void map( FeatureMapping mapping, List<MappableStep> remaining ) throws UnmappableException { // followJoins( mapping.getJoinedTable() ); if ( remaining.size() < 2 ) { throw new UnmappableException( "Not enough steps." ); } MappableStep ftStep = remaining.get( 0 ); if ( !( ftStep instanceof ElementStep ) ) { throw new UnmappableException( "Must provide a feature type name." ); } QName ftName = ( (ElementStep) ftStep ).getNodeName(); FeatureTypeMapping ftMapping = schema.getFtMapping( ftName ); if ( ftMapping == null ) { throw new UnmappableException( "Feature type '" + ftName + " is not mapped to a table." ); } String fromTable = currentTable; String fromTableAlias = currentTableAlias; // TODO what do do with Href mappings here? Needs proper reference resolving code for mapping here... String fromColumn = mapping.getJoinedTable().get( 0 ).getFromColumns().get( 0 ).toString(); String toTable = ftMapping.getFtTable().toString(); String toTableAlias = aliasManager.generateNew(); String toColumn = ftMapping.getFidMapping().getColumn(); Join appliedJoin = new Join( fromTable, fromTableAlias, Collections.singletonList( fromColumn ), toTable, toTableAlias, Collections.singletonList( toColumn ) ); joins.add( appliedJoin ); currentTable = toTable; currentTableAlias = toTableAlias; map( ftMapping.getMappings(), remaining.subList( 1, remaining.size() ) ); }
void assign( Feature feature ) throws FeatureStoreException { FeatureTypeMapping ftMapping = mgr.getSchema().getFtMapping( feature.getName() ); this.table = ftMapping.getFtTable(); this.fidMapping = ftMapping.getFidMapping(); switch ( mgr.getIdGenMode() ) { case GENERATE_NEW: { Map<SQLIdentifier, IDGenerator> keyColumnToGenerator = new HashMap<SQLIdentifier, IDGenerator>(); for ( Pair<SQLIdentifier, BaseType> columnAndType : ftMapping.getFidMapping().getColumns() ) { SQLIdentifier fidColumn = columnAndType.first; keyColumnToGenerator.put( fidColumn, ftMapping.getFidMapping().getIdGenerator() ); generateImmediateKeys( keyColumnToGenerator ); } break; } case USE_EXISTING: { preInsertUseExisting( ftMapping ); break; } case REPLACE_DUPLICATE: { throw new UnsupportedOperationException( "REPLACE_DUPLICATE id generation mode is not implemented yet." ); } } newId = buildNewFid(); }
/** * 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 ); } }