public void addPreparedArgument( String column, Object value ) { addPreparedArgument( new SQLIdentifier( column ), value, "?" ); }
public void addPreparedArgument( String column, Object value, String literal ) { addPreparedArgument( new SQLIdentifier( column ), value, literal ); }
this.fromColumns = new ArrayList<SQLIdentifier>( fromColumns.size() ); for ( String fromColumn : fromColumns ) { this.fromColumns.add( new SQLIdentifier( fromColumn ) ); this.toColumns = new ArrayList<SQLIdentifier>( toColumns.size() ); for ( String toColumn : toColumns ) { this.toColumns.add( new SQLIdentifier( toColumn ) ); this.orderColumns = new ArrayList<SQLIdentifier>( orderColumns.size() ); for ( String orderColumn : orderColumns ) { this.orderColumns.add( new SQLIdentifier( orderColumn ) );
public <T extends TypedObjectNode> void addPreparedArgument( String columnName, T particle, ParticleConverter<T> converter ) { SQLIdentifier column = new SQLIdentifier( columnName ); columnToLiteral.put( column, converter.getSetSnippet( particle ) ); columnToObject.put( column, new ParticleConversion<T>( converter, particle ) ); }
private ColumnMetadata getUnescapedColumnMetadata( TableName qTable, SQLIdentifier columnName ) throws SQLException { String name = columnName.getName(); char leadingEscapeChar = dialect.getLeadingEscapeChar(); char tailingEscapeChar = dialect.getTailingEscapeChar(); if ( leadingEscapeChar == name.charAt( 0 ) && tailingEscapeChar == name.charAt( name.length() - 1 ) ) { SQLIdentifier unescapedColumnName = new SQLIdentifier( name.substring( 1, name.length() - 1 ) ); return getColumnMetadataFromDb( qTable ).get( unescapedColumnName ); } return null; }
private void addRegistryObject( InsertRow ir, RegistryObject ro ) { ir.addPreparedArgument( new SQLIdentifier( "id" ), ro.getId() ); ir.addPreparedArgument( new SQLIdentifier( "objectType" ), ro.getObjectType() ); ir.addPreparedArgument( new SQLIdentifier( "home" ), ro.getHome() ); ir.addPreparedArgument( new SQLIdentifier( "lid" ), ro.getLid() ); ir.addPreparedArgument( new SQLIdentifier( "status" ), ro.getStatus() ); ir.addPreparedArgument( new SQLIdentifier( "externalId" ), ro.getExtId() ); ir.addPreparedArgument( new SQLIdentifier( "name" ), ro.getName() ); ir.addPreparedArgument( new SQLIdentifier( "description" ), ro.getDesc() ); ir.addPreparedArgument( new SQLIdentifier( "versionInfo" ), ro.getVersionInfo() ); }
private List<TableJoin> generateJoinChain( MappingContext from, MappingContext to ) { TableName fromTable = new TableName( from.getTable() ); TableName toTable = new TableName( to.getTable() ); List<String> fromColumns = Collections.singletonList( from.getIdColumn() ); List<String> toColumns = Collections.singletonList( "parentfk" ); List<String> orderColumns = Collections.singletonList( "num" ); Map<SQLIdentifier, IDGenerator> keyColumnToIdGenerator = new HashMap<SQLIdentifier, IDGenerator>(); keyColumnToIdGenerator.put( new SQLIdentifier( "id" ), new AutoIDGenerator() ); TableJoin join = new TableJoin( fromTable, toTable, fromColumns, toColumns, orderColumns, true, keyColumnToIdGenerator ); return Collections.singletonList( join ); }
private void insertAssociation( Association association, int regPackId, Connection conn ) throws SQLException { InsertRow ir = new InsertRow( new TableName( Table.idxtb_association.name() ), null ); addRegistryObject( ir, association ); ir.addPreparedArgument( new SQLIdentifier( "sourceObject" ), association.getSourceObject() ); ir.addPreparedArgument( new SQLIdentifier( "targetObject" ), association.getTargetObject() ); ir.addPreparedArgument( new SQLIdentifier( "associationType" ), association.getAssociationType() ); ir.addPreparedArgument( new SQLIdentifier( "data" ), getAsByteArray( association.getElement() ) ); ir.addPreparedArgument( new SQLIdentifier( "fk_registrypackage" ), regPackId ); ir.performInsert( conn ); }
private void insertClassification( Classification classification, int regPackId, Connection conn ) throws SQLException { InsertRow ir = new InsertRow( new TableName( Table.idxtb_classification.name() ), null ); addRegistryObject( ir, classification ); ir.addPreparedArgument( new SQLIdentifier( "classificationNode" ), classification.getClassificationNode() ); ir.addPreparedArgument( new SQLIdentifier( "classifiedObject" ), classification.getClassifiedObject() ); ir.addPreparedArgument( new SQLIdentifier( "classificationScheme" ), classification.getClassificationScheme() ); ir.addPreparedArgument( new SQLIdentifier( "data" ), getAsByteArray( classification.getElement() ) ); ir.addPreparedArgument( new SQLIdentifier( "fk_registrypackage" ), regPackId ); ir.performInsert( conn ); }
private void insertClassificationNode( ClassificationNode classificationNode, int regPackId, Connection conn ) throws SQLException { InsertRow ir = new InsertRow( new TableName( Table.idxtb_classificationNode.name() ), null ); addRegistryObject( ir, classificationNode ); ir.addPreparedArgument( new SQLIdentifier( "parent" ), classificationNode.getParent() ); ir.addPreparedArgument( new SQLIdentifier( "code" ), classificationNode.getCode() ); ir.addPreparedArgument( new SQLIdentifier( "path" ), classificationNode.getPath() ); ir.addPreparedArgument( new SQLIdentifier( "data" ), getAsByteArray( classificationNode.getElement() ) ); ir.addPreparedArgument( new SQLIdentifier( "fk_registrypackage" ), regPackId ); ir.performInsert( conn ); }
private TableJoin generateFtJoin( MappingContext from, FeatureType valueFt ) { if ( valueFt != null && valueFt.getSchema().getSubtypes( valueFt ).length == 1 ) { LOG.warn( "Ambigous feature join." ); } TableName fromTable = new TableName( from.getTable() ); TableName toTable = new TableName( "?" ); List<String> fromColumns = Collections.singletonList( from.getColumn() ); List<String> toColumns = Collections.singletonList( detectPrimaryKeyColumnName() ); Map<SQLIdentifier, IDGenerator> keyColumnToIdGenerator = new HashMap<SQLIdentifier, IDGenerator>(); keyColumnToIdGenerator.put( new SQLIdentifier( "id" ), new AutoIDGenerator() ); return new TableJoin( fromTable, toTable, fromColumns, toColumns, Collections.EMPTY_LIST, false, keyColumnToIdGenerator ); }
if ( fidColumnNames.contains( new SQLIdentifier( md.column.toLowerCase() ) ) ) { LOG.debug( "Omitting column '" + md.column + "' from properties. Used in FIDMapping." ); continue;
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 ); }
protected List<TableJoin> buildJoinTable( TableName from, org.deegree.feature.persistence.sql.jaxb.Join join ) { if ( join != null ) { TableName target = createFromQualifiedName( join.getTable() ); if ( join.getFromColumns().size() != join.getToColumns().size() ) { throw new UnsupportedOperationException( "Joins must use same number of from and to columns." ); } if ( join.getFromColumns().isEmpty() ) { throw new UnsupportedOperationException( "Joins must use at least a single column." ); } boolean isNumbered = join.isNumbered() == null ? false : join.isNumbered(); Map<SQLIdentifier, IDGenerator> keyColumnToGenerator = new HashMap<SQLIdentifier, IDGenerator>(); for ( AutoKeyColumn keyColumn : join.getAutoKeyColumn() ) { SQLIdentifier columnName = new SQLIdentifier( keyColumn.getName() ); IDGenerator idGenerator = buildGenerator( keyColumn.getAbstractIDGenerator() ); keyColumnToGenerator.put( columnName, idGenerator ); } if ( keyColumnToGenerator.isEmpty() ) { // defaulting keyColumnToGenerator.put( new SQLIdentifier( "id" ), new AutoIDGenerator() ); } TableJoin tj = new TableJoin( from, target, join.getFromColumns(), join.getToColumns(), join.getOrderColumns(), isNumbered, keyColumnToGenerator ); return Collections.singletonList( tj ); } return null; }
if ( useIntegerFids ) { IDGenerator generator = new AutoIDGenerator(); Pair<SQLIdentifier, BaseType> fidColumn = new Pair<SQLIdentifier, BaseType>( new SQLIdentifier( "gid" ), BaseType.INTEGER ); fidMapping = new FIDMapping( prefix, "_", Collections.singletonList( fidColumn ), generator ); IDGenerator generator = new UUIDGenerator(); Pair<SQLIdentifier, BaseType> fidColumn = new Pair<SQLIdentifier, BaseType>( new SQLIdentifier( "attr_gml_id" ), STRING );
if ( config != null && config.getColumn() != null ) { for ( ColumnJAXB configColumn : config.getColumn() ) { SQLIdentifier columnName = new SQLIdentifier( configColumn.getName() ); BaseType columnType = configColumn.getType() != null ? getPrimitiveType( configColumn.getType() ) : null; if ( md.isAutoincrement ) { BaseType columnType = BaseType.valueOf( md.sqlType ); columns.add( new Pair<SQLIdentifier, BaseType>( new SQLIdentifier( md.column ), columnType ) ); break;
if ( config != null && config.getColumn() != null ) { for ( ColumnJAXB configColumn : config.getColumn() ) { SQLIdentifier columnName = new SQLIdentifier( configColumn.getName() ); BaseType columnType = configColumn.getType() != null ? getPrimitiveType( configColumn.getType() ) : null; if ( md.isAutoincrement ) { BaseType columnType = BaseType.valueOf( md.sqlType ); columns.add( new Pair<SQLIdentifier, BaseType>( new SQLIdentifier( md.column ), columnType ) ); break;
addRegistryObject( ir, eo ); ir.addPreparedArgument( new SQLIdentifier( "resource" ), eo.getResource() ); ir.addPreparedArgument( new SQLIdentifier( "isopaque" ), eo.isOpaque() ); ir.addPreparedArgument( new SQLIdentifier( "data" ), getAsByteArray( eo.getElement() ) ); ir.addPreparedArgument( new SQLIdentifier( "fk_registrypackage" ), regPackId ); slots = PRODUCT.getSlots(); } else if ( ACQUPLATFORM.getType().equals( eo.getObjectType() ) ) { ir.addPreparedArgument( new SQLIdentifier( "ap_shortName" ), eo.getName() ); slots = ACQUPLATFORM.getSlots(); } else if ( MASKINFO.getType().equals( eo.getObjectType() ) ) { ir.addPreparedArgument( new SQLIdentifier( "mi_type" ), eo.getName() ); slots = MASKINFO.getSlots(); } else if ( ARCHIVINGINFO.getType().equals( eo.getObjectType() ) ) { ir.addPreparedArgument( new SQLIdentifier( "ai_archivingCenter" ), eo.getName() ); slots = ARCHIVINGINFO.getSlots(); } else if ( PRODUCTINFO.getType().equals( eo.getObjectType() ) ) { slots = PRODUCTINFO.getSlots(); } else if ( DATALAYER.getType().equals( eo.getObjectType() ) ) { ir.addPreparedArgument( new SQLIdentifier( "dl_specy" ), eo.getName() ); slots = DATALAYER.getSlots(); } else if ( BROWSEINFO.getType().equals( eo.getObjectType() ) ) { ir.addPreparedArgument( new SQLIdentifier( "bi_type" ), eo.getName() ); slots = BROWSEINFO.getSlots();
try { int id = getNewId( conn ); ir.addPreparedArgument( new SQLIdentifier( "internalId" ), id ); ir.addPreparedArgument( new SQLIdentifier( "id" ), registryPackage.getId() ); ir.addPreparedArgument( new SQLIdentifier( "externalId" ), registryPackage.getExtId() ); ir.addPreparedArgument( new SQLIdentifier( "name" ), registryPackage.getName() ); ir.addPreparedArgument( new SQLIdentifier( "description" ), registryPackage.getDesc() ); ir.addPreparedArgument( new SQLIdentifier( "data" ), getAsByteArray( registryPackage.getElement() ) );
hrefColumn = new SQLIdentifier( fm.getHrefMapping().toString() );