org.pentaho.di.core.database.Database.prepareInsert()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(19.2k)|赞(0)|评价(0)|浏览(155)

本文整理了Java中org.pentaho.di.core.database.Database.prepareInsert()方法的一些代码示例,展示了Database.prepareInsert()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Database.prepareInsert()方法的具体详情如下:
包路径:org.pentaho.di.core.database.Database
类名称:Database
方法名:prepareInsert

Database.prepareInsert介绍

[英]Prepare inserting values into a table, using the fields & values in a Row
[中]准备使用行中的字段和值将值插入表中

代码示例

代码示例来源:origin: pentaho/pentaho-kettle

  1. /**
  2. * Prepare inserting values into a table, using the fields & values in a Row
  3. *
  4. * @param rowMeta The row metadata to determine which values need to be inserted
  5. * @param table The name of the table in which we want to insert rows
  6. * @throws KettleDatabaseException if something went wrong.
  7. */
  8. public void prepareInsert( RowMetaInterface rowMeta, String tableName ) throws KettleDatabaseException {
  9. prepareInsert( rowMeta, null, tableName );
  10. }

代码示例来源:origin: pentaho/pentaho-kettle

  1. public void insertRow( String schemaName, String tableName, RowMetaInterface fields, Object[] data )
  2. throws KettleDatabaseException {
  3. prepareInsert( fields, schemaName, tableName );
  4. setValuesInsert( fields, data );
  5. insertRow();
  6. closeInsert();
  7. }

代码示例来源:origin: pentaho/pentaho-kettle

  1. public synchronized void insertTableRow( String tablename, RowMetaAndData values ) throws KettleException {
  2. database.prepareInsert( values.getRowMeta(), tablename );
  3. database.setValuesInsert( values );
  4. database.insertRow();
  5. database.closeInsert();
  6. }

代码示例来源:origin: pentaho/pentaho-kettle

  1. private void insertDatabaseAttributes( ObjectId idDatabase, Properties properties ) throws KettleException {
  2. if ( properties.isEmpty() ) {
  3. return;
  4. }
  5. Database db = repository.connectionDelegate.getDatabase();
  6. boolean firstAttribute = true;
  7. Enumeration<Object> keys = properties.keys();
  8. while ( keys.hasMoreElements() ) {
  9. String code = (String) keys.nextElement();
  10. String attribute = (String) properties.get( code );
  11. RowMetaAndData attributeData = createAttributeRow( idDatabase, code, attribute );
  12. if ( firstAttribute ) {
  13. db.prepareInsert( attributeData.getRowMeta(), KettleDatabaseRepository.TABLE_R_DATABASE_ATTRIBUTE );
  14. firstAttribute = false;
  15. }
  16. db.setValuesInsert( attributeData );
  17. db.insertRow( db.getPrepStatementInsert(), true, false );
  18. }
  19. db.executeAndClearBatch( db.getPrepStatementInsert() );
  20. db.closeInsert();
  21. }
  22. }

代码示例来源:origin: pentaho/pentaho-kettle

  1. table.addValue( new ValueMetaBoolean( KettleDatabaseRepository.FIELD_NOTE_DRAW_SHADOW ), Boolean.valueOf( drawshadow ) );
  2. repository.connectionDelegate.getDatabase().prepareInsert( table.getRowMeta(), KettleDatabaseRepository.TABLE_R_NOTE );
  3. repository.connectionDelegate.getDatabase().setValuesInsert( table );
  4. repository.connectionDelegate.getDatabase().insertRow();

代码示例来源:origin: pentaho/pentaho-kettle

  1. public synchronized ObjectId insertJobEntryCopy( ObjectId id_job, ObjectId id_jobentry,
  2. ObjectId id_jobentry_type, int nr, long gui_location_x, long gui_location_y, boolean gui_draw,
  3. boolean parallel ) throws KettleException {
  4. ObjectId id = repository.connectionDelegate.getNextJobEntryCopyID();
  5. RowMetaAndData table = new RowMetaAndData();
  6. //CHECKSTYLE:LineLength:OFF
  7. table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_JOBENTRY_COPY_ID_JOBENTRY_COPY ), id );
  8. table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_JOBENTRY_COPY_ID_JOBENTRY ), id_jobentry );
  9. table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_JOBENTRY_COPY_ID_JOB ), id_job );
  10. table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_JOBENTRY_COPY_ID_JOBENTRY_TYPE ), id_jobentry_type );
  11. table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_JOBENTRY_COPY_NR ), new Long( nr ) );
  12. table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_JOBENTRY_COPY_GUI_LOCATION_X ), new Long( gui_location_x ) );
  13. table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_JOBENTRY_COPY_GUI_LOCATION_Y ), new Long( gui_location_y ) );
  14. table.addValue( new ValueMetaBoolean( KettleDatabaseRepository.FIELD_JOBENTRY_COPY_GUI_DRAW ), Boolean.valueOf( gui_draw ) );
  15. table.addValue( new ValueMetaBoolean( KettleDatabaseRepository.FIELD_JOBENTRY_COPY_PARALLEL ), Boolean.valueOf( parallel ) );
  16. repository.connectionDelegate.getDatabase().prepareInsert( table.getRowMeta(), KettleDatabaseRepository.TABLE_R_JOBENTRY_COPY );
  17. repository.connectionDelegate.getDatabase().setValuesInsert( table );
  18. repository.connectionDelegate.getDatabase().insertRow();
  19. repository.connectionDelegate.getDatabase().closeInsert();
  20. return id;
  21. }

代码示例来源:origin: pentaho/pentaho-kettle

  1. public synchronized ObjectId insertStep( ObjectId id_transformation, String name, String description,
  2. String steptype, boolean distribute, long copies, long gui_location_x, long gui_location_y,
  3. boolean gui_draw, String copiesString ) throws KettleException {
  4. ObjectId id = repository.connectionDelegate.getNextStepID();
  5. ObjectId id_step_type = getStepTypeID( steptype );
  6. RowMetaAndData table = new RowMetaAndData();
  7. table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_STEP_ID_STEP ), id );
  8. table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_STEP_ID_TRANSFORMATION ), id_transformation );
  9. table.addValue( new ValueMetaString( KettleDatabaseRepository.FIELD_STEP_NAME ), name );
  10. table.addValue( new ValueMetaString( KettleDatabaseRepository.FIELD_STEP_DESCRIPTION ), description );
  11. table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_STEP_ID_STEP_TYPE ), id_step_type );
  12. table.addValue( new ValueMetaBoolean( KettleDatabaseRepository.FIELD_STEP_DISTRIBUTE ), Boolean.valueOf( distribute ) );
  13. table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_STEP_COPIES ), new Long( copies ) );
  14. table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_STEP_GUI_LOCATION_X ), new Long( gui_location_x ) );
  15. table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_STEP_GUI_LOCATION_Y ), new Long( gui_location_y ) );
  16. table.addValue( new ValueMetaBoolean( KettleDatabaseRepository.FIELD_STEP_GUI_DRAW ), Boolean.valueOf( gui_draw ) );
  17. table.addValue( new ValueMetaString( KettleDatabaseRepository.FIELD_STEP_COPIES_STRING ), copiesString );
  18. repository.connectionDelegate.getDatabase().prepareInsert( table.getRowMeta(), KettleDatabaseRepository.TABLE_R_STEP );
  19. repository.connectionDelegate.getDatabase().setValuesInsert( table );
  20. repository.connectionDelegate.getDatabase().insertRow();
  21. repository.connectionDelegate.getDatabase().closeInsert();
  22. return id;
  23. }

代码示例来源:origin: pentaho/pentaho-kettle

  1. public synchronized ObjectId insertJobEntryAttribute( ObjectId id_job, ObjectId id_jobentry, long nr,
  2. String code, double value_num, String value_str )
  3. throws KettleException {
  4. ObjectId id = getNextJobEntryAttributeID();
  5. RowMetaAndData table = new RowMetaAndData();
  6. //CHECKSTYLE:LineLength:OFF
  7. table
  8. .addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_ID_JOBENTRY_ATTRIBUTE ), id );
  9. table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_ID_JOB ), id_job );
  10. table
  11. .addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_ID_JOBENTRY ), id_jobentry );
  12. table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_NR ), new Long( nr ) );
  13. table.addValue( new ValueMetaString( KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_CODE ), code );
  14. table.addValue( new ValueMetaNumber( KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_VALUE_NUM ),
  15. new Double( value_num ) );
  16. table.addValue( new ValueMetaString( KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_VALUE_STR ), value_str );
  17. database.prepareInsert( table.getRowMeta(), KettleDatabaseRepository.TABLE_R_JOBENTRY_ATTRIBUTE );
  18. database.setValuesInsert( table );
  19. database.insertRow();
  20. database.closeInsert();
  21. return id;
  22. }

代码示例来源:origin: pentaho/pentaho-kettle

  1. .valueOf( unconditional ) );
  2. repository.connectionDelegate.getDatabase().prepareInsert(
  3. table.getRowMeta(), KettleDatabaseRepository.TABLE_R_JOB_HOP );
  4. repository.connectionDelegate.getDatabase().setValuesInsert( table );

代码示例来源:origin: pentaho/pentaho-kettle

  1. private synchronized ObjectId insertTransHop( ObjectId id_transformation, ObjectId id_step_from,
  2. ObjectId id_step_to, boolean enabled ) throws KettleException {
  3. ObjectId id = repository.connectionDelegate.getNextTransHopID();
  4. RowMetaAndData table = new RowMetaAndData();
  5. table.addValue( new ValueMetaInteger(
  6. KettleDatabaseRepository.FIELD_TRANS_HOP_ID_TRANS_HOP ), id );
  7. table
  8. .addValue(
  9. new ValueMetaInteger(
  10. KettleDatabaseRepository.FIELD_TRANS_HOP_ID_TRANSFORMATION ),
  11. id_transformation );
  12. table.addValue( new ValueMetaInteger(
  13. KettleDatabaseRepository.FIELD_TRANS_HOP_ID_STEP_FROM ), id_step_from );
  14. table.addValue( new ValueMetaInteger(
  15. KettleDatabaseRepository.FIELD_TRANS_HOP_ID_STEP_TO ), id_step_to );
  16. table.addValue( new ValueMetaBoolean(
  17. KettleDatabaseRepository.FIELD_TRANS_HOP_ENABLED ), Boolean
  18. .valueOf( enabled ) );
  19. repository.connectionDelegate.getDatabase().prepareInsert(
  20. table.getRowMeta(), KettleDatabaseRepository.TABLE_R_TRANS_HOP );
  21. repository.connectionDelegate.getDatabase().setValuesInsert( table );
  22. repository.connectionDelegate.getDatabase().insertRow();
  23. repository.connectionDelegate.getDatabase().closeInsert();
  24. return id;
  25. }

代码示例来源:origin: pentaho/pentaho-kettle

  1. public synchronized ObjectId insertPartition( ObjectId id_partition_schema, String partition_id ) throws KettleException {
  2. ObjectId id = repository.connectionDelegate.getNextPartitionID();
  3. RowMetaAndData table = new RowMetaAndData();
  4. table.addValue( new ValueMetaInteger(
  5. KettleDatabaseRepository.FIELD_PARTITION_ID_PARTITION ), id );
  6. table.addValue(
  7. new ValueMetaInteger(
  8. KettleDatabaseRepository.FIELD_PARTITION_ID_PARTITION_SCHEMA ),
  9. id_partition_schema );
  10. table.addValue( new ValueMetaString(
  11. KettleDatabaseRepository.FIELD_PARTITION_PARTITION_ID ), partition_id );
  12. repository.connectionDelegate.getDatabase().prepareInsert(
  13. table.getRowMeta(), KettleDatabaseRepository.TABLE_R_PARTITION );
  14. repository.connectionDelegate.getDatabase().setValuesInsert( table );
  15. repository.connectionDelegate.getDatabase().insertRow();
  16. repository.connectionDelegate.getDatabase().closeInsert();
  17. return id;
  18. }

代码示例来源:origin: pentaho/pentaho-kettle

  1. public synchronized ObjectId insertValue( String name, String type, String value_str, boolean isnull,
  2. ObjectId id_value_prev ) throws KettleException {
  3. ObjectId id_value = lookupValue( name, type, value_str, isnull );
  4. // if it didn't exist yet: insert it!!
  5. if ( id_value == null ) {
  6. id_value = repository.connectionDelegate.getNextValueID();
  7. // Let's see if the same value is not yet available?
  8. String tablename = KettleDatabaseRepository.TABLE_R_VALUE;
  9. RowMetaAndData table = new RowMetaAndData();
  10. table.addValue( new ValueMetaInteger(
  11. KettleDatabaseRepository.FIELD_VALUE_ID_VALUE ), id_value );
  12. table.addValue(
  13. new ValueMetaString( KettleDatabaseRepository.FIELD_VALUE_NAME ), name );
  14. table.addValue( new ValueMetaString(
  15. KettleDatabaseRepository.FIELD_VALUE_VALUE_TYPE ), type );
  16. table.addValue( new ValueMetaString(
  17. KettleDatabaseRepository.FIELD_VALUE_VALUE_STR ), value_str );
  18. table.addValue(
  19. new ValueMetaBoolean( KettleDatabaseRepository.FIELD_VALUE_IS_NULL ), Boolean
  20. .valueOf( isnull ) );
  21. repository.connectionDelegate.getDatabase().prepareInsert( table.getRowMeta(), tablename );
  22. repository.connectionDelegate.getDatabase().setValuesInsert( table );
  23. repository.connectionDelegate.getDatabase().insertRow();
  24. repository.connectionDelegate.getDatabase().closeInsert();
  25. }
  26. return id_value;
  27. }

代码示例来源:origin: pentaho/pentaho-kettle

  1. private synchronized ObjectId insertDirectory( ObjectId id_directory_parent, RepositoryDirectoryInterface dir ) throws KettleException {
  2. ObjectId id = repository.connectionDelegate.getNextDirectoryID();
  3. String tablename = KettleDatabaseRepository.TABLE_R_DIRECTORY;
  4. RowMetaAndData table = new RowMetaAndData();
  5. table.addValue( new ValueMetaInteger(
  6. KettleDatabaseRepository.FIELD_DIRECTORY_ID_DIRECTORY ), id );
  7. table.addValue(
  8. new ValueMetaInteger(
  9. KettleDatabaseRepository.FIELD_DIRECTORY_ID_DIRECTORY_PARENT ),
  10. id_directory_parent );
  11. table.addValue( new ValueMetaString(
  12. KettleDatabaseRepository.FIELD_DIRECTORY_DIRECTORY_NAME ), dir.getName() );
  13. repository.connectionDelegate.getDatabase().prepareInsert( table.getRowMeta(), tablename );
  14. repository.connectionDelegate.getDatabase().setValuesInsert( table );
  15. repository.connectionDelegate.getDatabase().insertRow();
  16. repository.connectionDelegate.getDatabase().closeInsert();
  17. return id;
  18. }

代码示例来源:origin: pentaho/pentaho-kettle

  1. public ObjectId insertNamespace( String namespace ) throws KettleException {
  2. ObjectId idNamespace =
  3. repository.connectionDelegate.getNextID(
  4. quoteTable( KettleDatabaseRepository.TABLE_R_NAMESPACE ),
  5. quote( KettleDatabaseRepository.FIELD_NAMESPACE_ID_NAMESPACE ) );
  6. RowMetaAndData table = new RowMetaAndData();
  7. table.addValue( new ValueMetaInteger(
  8. KettleDatabaseRepository.FIELD_NAMESPACE_ID_NAMESPACE ), idNamespace );
  9. table.addValue(
  10. new ValueMetaString( KettleDatabaseRepository.FIELD_NAMESPACE_NAME ), namespace );
  11. repository.connectionDelegate.getDatabase().prepareInsert(
  12. table.getRowMeta(), KettleDatabaseRepository.TABLE_R_NAMESPACE );
  13. repository.connectionDelegate.getDatabase().setValuesInsert( table );
  14. repository.connectionDelegate.getDatabase().insertRow();
  15. repository.connectionDelegate.getDatabase().closeInsert();
  16. if ( log.isDebug() ) {
  17. log.logDebug( "Saved namespace [" + namespace + "]" );
  18. }
  19. return idNamespace;
  20. }

代码示例来源:origin: pentaho/pentaho-kettle

  1. private synchronized ObjectId insertDependency( ObjectId id_transformation, ObjectId id_database,
  2. String tablename, String fieldname ) throws KettleException {
  3. ObjectId id = repository.connectionDelegate.getNextDepencencyID();
  4. RowMetaAndData table = new RowMetaAndData();
  5. table.addValue( new ValueMetaInteger(
  6. KettleDatabaseRepository.FIELD_DEPENDENCY_ID_DEPENDENCY ), id );
  7. table.addValue(
  8. new ValueMetaInteger(
  9. KettleDatabaseRepository.FIELD_DEPENDENCY_ID_TRANSFORMATION ),
  10. id_transformation );
  11. table.addValue( new ValueMetaInteger(
  12. KettleDatabaseRepository.FIELD_DEPENDENCY_ID_DATABASE ), id_database );
  13. table.addValue( new ValueMetaString(
  14. KettleDatabaseRepository.FIELD_DEPENDENCY_TABLE_NAME ), tablename );
  15. table.addValue( new ValueMetaString(
  16. KettleDatabaseRepository.FIELD_DEPENDENCY_FIELD_NAME ), fieldname );
  17. repository.connectionDelegate.getDatabase().prepareInsert(
  18. table.getRowMeta(), KettleDatabaseRepository.TABLE_R_DEPENDENCY );
  19. repository.connectionDelegate.getDatabase().setValuesInsert( table );
  20. repository.connectionDelegate.getDatabase().insertRow();
  21. repository.connectionDelegate.getDatabase().closeInsert();
  22. return id;
  23. }

代码示例来源:origin: pentaho/pentaho-kettle

  1. .getName() );
  2. repository.connectionDelegate.getDatabase().prepareInsert(
  3. table.getRowMeta(), KettleDatabaseRepository.TABLE_R_ELEMENT );
  4. repository.connectionDelegate.getDatabase().setValuesInsert( table );

代码示例来源:origin: pentaho/pentaho-kettle

  1. public synchronized ObjectId insertPartitionSchema( PartitionSchema partitionSchema ) throws KettleException {
  2. if ( getPartitionSchemaID( partitionSchema.getName() ) != null ) {
  3. // This partition schema name is already in use. Throw an exception.
  4. throw new KettleObjectExistsException( "Failed to create object in repository. Object ["
  5. + partitionSchema.getName() + "] already exists." );
  6. }
  7. ObjectId id = repository.connectionDelegate.getNextPartitionSchemaID();
  8. RowMetaAndData table = new RowMetaAndData();
  9. table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_PARTITION_SCHEMA_ID_PARTITION_SCHEMA ), id );
  10. table.addValue( new ValueMetaString( KettleDatabaseRepository.FIELD_PARTITION_SCHEMA_NAME ),
  11. partitionSchema.getName() );
  12. table.addValue( new ValueMetaBoolean( KettleDatabaseRepository.FIELD_PARTITION_SCHEMA_DYNAMIC_DEFINITION ),
  13. partitionSchema.isDynamicallyDefined() );
  14. table.addValue( new ValueMetaString( KettleDatabaseRepository.FIELD_PARTITION_SCHEMA_PARTITIONS_PER_SLAVE ),
  15. partitionSchema.getNumberOfPartitionsPerSlave() );
  16. repository.connectionDelegate.getDatabase().prepareInsert(
  17. table.getRowMeta(), KettleDatabaseRepository.TABLE_R_PARTITION_SCHEMA );
  18. repository.connectionDelegate.getDatabase().setValuesInsert( table );
  19. repository.connectionDelegate.getDatabase().insertRow();
  20. repository.connectionDelegate.getDatabase().closeInsert();
  21. return id;
  22. }

代码示例来源:origin: pentaho/pentaho-kettle

  1. public synchronized ObjectId insertJobEntry( ObjectId id_job, JobEntryBase jobEntryBase ) throws KettleException {
  2. ObjectId id = repository.connectionDelegate.getNextJobEntryID();
  3. ObjectId id_jobentry_type = getJobEntryTypeID( jobEntryBase.getPluginId() );
  4. log.logDebug( "ID_JobEntry_type = " + id_jobentry_type + " for type = [" + jobEntryBase.getPluginId() + "]" );
  5. RowMetaAndData table = new RowMetaAndData();
  6. table.addValue( new ValueMetaInteger(
  7. KettleDatabaseRepository.FIELD_JOBENTRY_ID_JOBENTRY ), id );
  8. table.addValue(
  9. new ValueMetaInteger( KettleDatabaseRepository.FIELD_JOBENTRY_ID_JOB ), id_job );
  10. table
  11. .addValue(
  12. new ValueMetaInteger(
  13. KettleDatabaseRepository.FIELD_JOBENTRY_ID_JOBENTRY_TYPE ),
  14. id_jobentry_type );
  15. table.addValue(
  16. new ValueMetaString( KettleDatabaseRepository.FIELD_JOBENTRY_NAME ),
  17. jobEntryBase.getName() );
  18. table.addValue( new ValueMetaString(
  19. KettleDatabaseRepository.FIELD_JOBENTRY_DESCRIPTION ), jobEntryBase
  20. .getDescription() );
  21. repository.connectionDelegate.getDatabase().prepareInsert(
  22. table.getRowMeta(), KettleDatabaseRepository.TABLE_R_JOBENTRY );
  23. repository.connectionDelegate.getDatabase().setValuesInsert( table );
  24. repository.connectionDelegate.getDatabase().insertRow();
  25. repository.connectionDelegate.getDatabase().closeInsert();
  26. jobEntryBase.setObjectId( id );
  27. return id;
  28. }

代码示例来源:origin: pentaho/pentaho-kettle

  1. public ObjectId insertElementType( KDBRMetaStoreElementType type ) throws KettleException {
  2. ObjectId idType =
  3. repository.connectionDelegate.getNextID(
  4. quoteTable( KettleDatabaseRepository.TABLE_R_ELEMENT_TYPE ),
  5. quote( KettleDatabaseRepository.FIELD_ELEMENT_TYPE_ID_ELEMENT_TYPE ) );
  6. RowMetaAndData table = new RowMetaAndData();
  7. table.addValue( new ValueMetaInteger(
  8. KettleDatabaseRepository.FIELD_ELEMENT_TYPE_ID_ELEMENT_TYPE ), idType );
  9. table.addValue( new ValueMetaInteger(
  10. KettleDatabaseRepository.FIELD_ELEMENT_TYPE_ID_NAMESPACE ), type
  11. .getNamespaceId() );
  12. table.addValue( new ValueMetaString(
  13. KettleDatabaseRepository.FIELD_ELEMENT_TYPE_NAME ), type.getName() );
  14. table.addValue( new ValueMetaString(
  15. KettleDatabaseRepository.FIELD_ELEMENT_TYPE_DESCRIPTION ), type
  16. .getDescription() );
  17. repository.connectionDelegate.getDatabase().prepareInsert(
  18. table.getRowMeta(), KettleDatabaseRepository.TABLE_R_ELEMENT_TYPE );
  19. repository.connectionDelegate.getDatabase().setValuesInsert( table );
  20. repository.connectionDelegate.getDatabase().insertRow();
  21. repository.connectionDelegate.getDatabase().closeInsert();
  22. type.setId( new LongObjectId( idType ) );
  23. if ( log.isDebug() ) {
  24. log.logDebug( "Saved element type [" + type.getName() + "]" );
  25. }
  26. return idType;
  27. }

代码示例来源:origin: pentaho/pentaho-kettle

  1. private void insertAttributes( List<IMetaStoreAttribute> children, LongObjectId elementId,
  2. LongObjectId parentAttributeId ) throws Exception {
  3. for ( IMetaStoreAttribute child : children ) {
  4. LongObjectId attributeId =
  5. repository.connectionDelegate.getNextID(
  6. quoteTable( KettleDatabaseRepository.TABLE_R_ELEMENT_ATTRIBUTE ),
  7. quote( KettleDatabaseRepository.FIELD_ELEMENT_ATTRIBUTE_ID_ELEMENT_ATTRIBUTE ) );
  8. RowMetaAndData table = new RowMetaAndData();
  9. table.addValue(
  10. new ValueMetaInteger(
  11. KettleDatabaseRepository.FIELD_ELEMENT_ATTRIBUTE_ID_ELEMENT_ATTRIBUTE ), attributeId.longValue() );
  12. table.addValue(
  13. new ValueMetaInteger(
  14. KettleDatabaseRepository.FIELD_ELEMENT_ATTRIBUTE_ID_ELEMENT ),
  15. elementId.longValue() );
  16. table.addValue( new ValueMetaInteger(
  17. KettleDatabaseRepository.FIELD_ELEMENT_ATTRIBUTE_ID_ELEMENT_ATTRIBUTE_PARENT ), parentAttributeId.longValue() );
  18. table.addValue( new ValueMetaString(
  19. KettleDatabaseRepository.FIELD_ELEMENT_ATTRIBUTE_KEY ), child.getId() );
  20. table.addValue(
  21. new ValueMetaString( KettleDatabaseRepository.FIELD_ELEMENT_ATTRIBUTE_VALUE ),
  22. encodeAttributeValue( child.getValue() ) );
  23. repository.connectionDelegate.getDatabase().prepareInsert(
  24. table.getRowMeta(), KettleDatabaseRepository.TABLE_R_ELEMENT_ATTRIBUTE );
  25. repository.connectionDelegate.getDatabase().setValuesInsert( table );
  26. repository.connectionDelegate.getDatabase().insertRow();
  27. repository.connectionDelegate.getDatabase().closeInsert();
  28. child.setId( attributeId.toString() );
  29. }
  30. }

相关文章