private FIDMapping buildFIDMapping( TableName table, QName ftName, FIDMappingJAXB config ) throws FeatureStoreException { String prefix = config != null ? config.getPrefix() : null; if ( prefix == null ) { prefix = ftName.getPrefix().toUpperCase() + "_" + ftName.getLocalPart().toUpperCase() + "_"; } List<Pair<SQLIdentifier, BaseType>> columns = new ArrayList<Pair<SQLIdentifier, BaseType>>(); if ( config != null && config.getColumn() != null ) { for ( ColumnJAXB configColumn : config.getColumn() ) { String column = configColumn.getName(); BaseType pt = null; if ( configColumn.getType() != null ) { pt = getPrimitiveType( configColumn.getType() ); } columns.add( new Pair<SQLIdentifier, BaseType>( new SQLIdentifier( column ), pt ) ); } } IDGenerator generator = buildGenerator( config == null ? null : config.getAbstractIDGenerator() ); if ( !( generator instanceof AutoIDGenerator ) ) { if ( columns.isEmpty() ) { throw new FeatureStoreException( "No FIDMapping column for table '" + table + "' specified. This is only possible for AutoIDGenerator." ); } } return new FIDMapping( prefix, "_", columns, generator ); }
private Mapping buildMapping( TableName currentTable, Pair<XSElementDeclaration, Boolean> elDecl, PrimitiveParticleJAXB config ) { ValueReference path = new ValueReference( config.getPath(), nsBindings ); Pair<PrimitiveType, Boolean> pt = null; try { pt = schemaWalker.getTargetType( elDecl, path ); } catch ( RuntimeException e ) { throw new RuntimeException( "Error in mapping of table '" + currentTable + "': " + e ); } if ( config.getType() != null ) { PrimitiveType forcedType = new PrimitiveType( getPrimitiveType( config.getType() ) ); LOG.debug( "Overriding schema-derived primitive type '" + pt.getFirst() + "'. Forcing '" + forcedType + "'." ); pt.first = forcedType; } MappingExpression me = parseMappingExpression( config.getMapping() ); List<TableJoin> joinedTable = buildJoinTable( currentTable, config.getJoin() ); LOG.debug( "Targeted primitive type: " + pt ); boolean escalateVoid = determineParticleVoidability( pt.second, config.getNullEscalation() ); return new PrimitiveMapping( path, escalateVoid, me, pt.first, joinedTable, config.getCustomConverter() ); }