private void process( TableName table, QName ftName, FIDMapping fidMapping, List<JAXBElement<? extends AbstractPropertyJAXB>> propDecls ) throws FeatureStoreException, SQLException { List<PropertyType> pts = new ArrayList<PropertyType>(); List<Mapping> mappings = new ArrayList<Mapping>(); for ( JAXBElement<? extends AbstractPropertyJAXB> propDeclEl : propDecls ) { AbstractPropertyJAXB propDecl = propDeclEl.getValue(); Pair<PropertyType, Mapping> pt = process( table, propDecl ); pts.add( pt.first ); mappings.add( pt.second ); } FeatureType ft = new GenericFeatureType( ftName, pts, false ); ftNameToFt.put( ftName, ft ); FeatureTypeMapping ftMapping = new FeatureTypeMapping( ftName, table, fidMapping, mappings ); ftNameToMapping.put( ftName, ftMapping ); }
/** * Creates a new {@link MappedSchemaBuilderTableOld} instance. * * @param jdbcConnId * identifier of JDBC connection, must not be <code>null</code> (used to determine columns / types) * @param ftDecls * JAXB feature type declarations, must not be <code>null</code> * @throws SQLException * @throws FeatureStoreException */ public MappedSchemaBuilderTableOld( String jdbcConnId, List<FeatureTypeJAXB> ftDecls, SQLDialect dialect, boolean deleteCascadingByDB, Workspace workspace ) throws SQLException, FeatureStoreException { this.dialect = dialect; ConnectionProvider prov = workspace.getResource( ConnectionProviderProvider.class, jdbcConnId ); conn = prov.getConnection(); try { for ( FeatureTypeJAXB ftDecl : ftDecls ) { process( ftDecl ); } } finally { JDBCUtils.close( conn ); } this.deleteCascadingByDB = deleteCascadingByDB; }
private void process( FeatureTypeJAXB ftDecl ) throws SQLException, FeatureStoreException { if ( ftDecl.getTable() == null || ftDecl.getTable().isEmpty() ) { String msg = "Feature type element without or with empty table attribute."; throw new FeatureStoreException( msg ); } TableName table = new TableName( ftDecl.getTable() ); LOG.debug( "Processing feature type mapping for table '" + table + "'." ); if ( getColumns( table ).isEmpty() ) { throw new FeatureStoreException( "No table with name '" + table + "' exists (or no columns defined)." ); } QName ftName = ftDecl.getName(); if ( ftName == null ) { LOG.debug( "Using table name for feature type." ); ftName = new QName( table.getTable() ); } ftName = makeFullyQualified( ftName, "app", "http://www.deegree.org/app" ); LOG.debug( "Feature type name: '" + ftName + "'." ); FIDMapping fidMapping = buildFIDMapping( table, ftName, ftDecl.getFIDMapping() ); List<JAXBElement<? extends AbstractPropertyJAXB>> propDecls = ftDecl.getAbstractProperty(); if ( propDecls != null && !propDecls.isEmpty() ) { process( table, ftName, fidMapping, propDecls ); } else { process( table, ftName, fidMapping ); } }