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 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 void insertInOperatesOnTable( Connection conn, int operatesOnId, QueryableProperties qp ) throws MetadataStoreException { List<OperatesOnData> opOns = qp.getOperatesOnData(); if ( opOns != null && opOns.size() > 0 ) { for ( OperatesOnData opOn : opOns ) { InsertRow ir = new InsertRow( new TableName( opOnTable ), null ); try { int localId = getNewIdentifier( conn, opOnTable ); ir.addPreparedArgument( idColumn, localId ); ir.addPreparedArgument( fk_main, operatesOnId ); ir.addPreparedArgument( "operateson", opOn.getOperatesOnId() ); ir.addPreparedArgument( "operatesonid", opOn.getOperatesOnIdentifier() ); ir.addPreparedArgument( "operatesonname", opOn.getOperatesOnName() ); LOG.debug( ir.getSql() ); ir.performInsert( conn ); } catch ( SQLException e ) { String msg = Messages.getMessage( "ERROR_SQL", ir.getSql(), e.getMessage() ); LOG.debug( msg ); throw new MetadataStoreException( msg ); } } } }
private void insertInKeywordTable( Connection conn, int operatesOnId, QueryableProperties qp ) throws MetadataStoreException { List<Keyword> keywords = qp.getKeywords(); if ( keywords != null && keywords.size() > 0 ) { for ( Keyword keyword : keywords ) { InsertRow ir = new InsertRow( new TableName( keywordTable ), null ); try { int localId = getNewIdentifier( conn, keywordTable ); ir.addPreparedArgument( idColumn, localId ); ir.addPreparedArgument( fk_main, operatesOnId ); ir.addPreparedArgument( "keywordtype", keyword.getKeywordType() ); ir.addPreparedArgument( "keywords", concatenate( keyword.getKeywords() ) ); LOG.debug( ir.getSql() ); ir.performInsert( conn ); } catch ( SQLException e ) { String msg = Messages.getMessage( "ERROR_SQL", ir.getSql(), e.getMessage() ); LOG.debug( msg ); throw new MetadataStoreException( msg ); } } } }
@Override public synchronized int executeInsert( Connection conn, ISORecord rec ) throws MetadataStoreException, XMLStreamException { int internalId = 0; InsertRow ir = new InsertRow( new TableName( mainTable ), null ); try { internalId = getLastDatasetId( conn, mainTable ); internalId++; ir.addPreparedArgument( idColumn, internalId ); ir.addPreparedArgument( recordColumn, rec.getAsByteArray() ); ir.addPreparedArgument( "fileidentifier", rec.getIdentifier() ); ir.addPreparedArgument( "version", null ); ir.addPreparedArgument( "status", null ); appendValues( rec, ir ); LOG.debug( ir.getSql() ); ir.performInsert( conn ); QueryableProperties qp = rec.getParsedElement().getQueryableProperties(); insertNewValues( conn, internalId, qp ); } catch ( SQLException e ) { String msg = Messages.getMessage( "ERROR_SQL", ir.getSql(), e.getMessage() ); LOG.debug( msg ); throw new MetadataStoreException( msg ); } return internalId; }
private void insertInCRSTable( Connection conn, int operatesOnId, QueryableProperties qp ) throws MetadataStoreException { List<CRS> crss = qp.getCrs(); if ( crss != null && crss.size() > 0 ) { for ( CRS crs : crss ) { InsertRow ir = new InsertRow( new TableName( crsTable ), null ); try { int localId = getNewIdentifier( conn, crsTable ); ir.addPreparedArgument( idColumn, localId ); ir.addPreparedArgument( fk_main, operatesOnId ); ir.addPreparedArgument( "authority", ( crs.getAuthority() != null && crs.getAuthority().length() > 0 ) ? crs.getAuthority() : null ); ir.addPreparedArgument( "crsid", ( crs.getCrsId() != null && crs.getCrsId().length() > 0 ) ? crs.getCrsId() : null ); ir.addPreparedArgument( "version", ( crs.getVersion() != null && crs.getVersion().length() > 0 ) ? crs.getVersion() : null ); LOG.debug( ir.getSql() ); ir.performInsert( conn ); } catch ( SQLException e ) { String msg = Messages.getMessage( "ERROR_SQL", ir.getSql(), e.getMessage() ); LOG.debug( msg ); throw new MetadataStoreException( msg ); } } } }
ir.addPreparedArgument( new SQLIdentifier( slot.getColumn() ), wkt, sb.toString() ); } catch ( ParseException e ) { String msg = "Could not write as WKB " + geom + ": " + e.getMessage(); ir.addPreparedArgument( new SQLIdentifier( slot.getColumn() ), concatenate( slotValue ) ); case _date: try { ir.addPreparedArgument( new SQLIdentifier( slot.getColumn() ), new Timestamp( ( parseDateTime( slotValue ).getTimeInMilliseconds() ) ) ); case _double: try { ir.addPreparedArgument( new SQLIdentifier( slot.getColumn() ), Double.parseDouble( slotValue ) ); } catch ( NumberFormatException e ) { String msg = "Could not parse as double:" + slotValue; case _int: try { ir.addPreparedArgument( new SQLIdentifier( slot.getColumn() ), Integer.parseInt( slotValue ) ); } catch ( NumberFormatException e ) { String msg = "Could not parse as integer:" + slotValue; ir.addPreparedArgument( new SQLIdentifier( slot.getColumn() ), slotValue ); break;
ir.addPreparedArgument( new SQLIdentifier( "key" ), "REGISTRYPACKAGE_ID" ); ir.addPreparedArgument( new SQLIdentifier( "value" ), insertedId ); ir.performInsert( conn ); ir.addPreparedArgument( new SQLIdentifier( "key" ), "LAST_INSERTED" ); ir.addPreparedArgument( new SQLIdentifier( "value" ), ISO8601Converter.formatDateTime( new Date() ) ); ir.performInsert( conn );
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() ) );
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();