Java Code Examples for org.pentaho.di.core.exception.KettleException

The following examples show how to use org.pentaho.di.core.exception.KettleException. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: OpenKettleWebUI   Source File: KettleUtils.java    License: Apache License 2.0 6 votes vote down vote up
public static KettleDatabaseRepository initDatabaseRepository(DbRepParams params)
    throws KettleException {
  KettleDatabaseRepository repository = null;
  // 初始化
  KettleEnvironment.init();
  DatabaseMeta databaseMeta =
      new DatabaseMeta(params.getName(), params.getType(), params.getAccess(), params.getHost(),
          params.getDb(), params.getPort(), params.getUser(), params.getPass());
  KettleDatabaseRepositoryMeta repositoryMeta = new KettleDatabaseRepositoryMeta();
  repositoryMeta.setConnection(databaseMeta);
  repository = new KettleDatabaseRepository();
  repository.init(repositoryMeta);
  repository.connect(params.getUsername(), params.getPassword());

  RepositoryDirectoryInterface dir = new RepositoryDirectory();
  dir.setObjectId(repository.getRootDirectoryID());
  return repository;

}
 
Example 2
Source Project: pentaho-kettle   Source File: GPLoad.java    License: Apache License 2.0 6 votes vote down vote up
public boolean init( StepMetaInterface smi, StepDataInterface sdi ) {
  meta = (GPLoadMeta) smi;
  data = (GPLoadData) sdi;

  Trans trans = getTrans();
  preview = trans.isPreview();

  if ( super.init( smi, sdi ) ) {

    try {
      verifyDatabaseConnection();
    } catch ( KettleException ex ) {
      logError( ex.getMessage() );
      return false;
    }
    return true;
  }
  return false;
}
 
Example 3
Source Project: pentaho-kettle   Source File: FuzzyMatchDialog.java    License: Apache License 2.0 6 votes vote down vote up
private void setMainStreamField() {
  if ( !gotPreviousFields ) {
    String field = wMainStreamField.getText();
    try {
      wMainStreamField.removeAll();

      RowMetaInterface r = transMeta.getPrevStepFields( stepname );
      if ( r != null ) {
        wMainStreamField.setItems( r.getFieldNames() );
      }
    } catch ( KettleException ke ) {
      new ErrorDialog(
        shell, BaseMessages.getString( PKG, "FuzzyMatchDialog.FailedToGetFields.DialogTitle" ), BaseMessages
          .getString( PKG, "FuzzyMatchDialog.FailedToGetFields.DialogMessage" ), ke );
    }
    if ( field != null ) {
      wMainStreamField.setText( field );
    }
    gotPreviousFields = true;
  }
}
 
Example 4
Source Project: pentaho-kettle   Source File: JobEntryCheckFilesLocked.java    License: Apache License 2.0 6 votes vote down vote up
public void loadRep( Repository rep, IMetaStore metaStore, ObjectId idJobEntry, List<DatabaseMeta> databases,
  List<SlaveServer> slaveServers ) throws KettleException {
  try {
    argFromPrevious = rep.getJobEntryAttributeBoolean( idJobEntry, ARG_FROM_PREVIOUS_ATTR );
    includeSubfolders = rep.getJobEntryAttributeBoolean( idJobEntry, INCLUDE_SUBFOLDERS_ATTR );

    // How many arguments?
    int argnr = rep.countNrJobEntryAttributes( idJobEntry, NAME_ATTR );
    arguments = new String[argnr];
    filemasks = new String[argnr];

    // Read them all...
    for ( int a = 0; a < argnr; a++ ) {
      arguments[a] = rep.getJobEntryAttributeString( idJobEntry, a, NAME_ATTR );
      filemasks[a] = rep.getJobEntryAttributeString( idJobEntry, a, FILE_MASK_ATTR );
    }
  } catch ( KettleException dbe ) {
    throw new KettleException( BaseMessages.getString(
      PKG, "JobEntryCheckFilesLocked.UnableToLoadFromRepo", String.valueOf( idJobEntry ) ), dbe );
  }
}
 
Example 5
Source Project: pentaho-kettle   Source File: SalesforceConnection.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Method returns names of the fields specified.<br>
 * For the type='reference' it also returns name in the
 * <code>format: objectReferenceTo:externalIdField/lookupField</code>
 *
 * @param fields
 *          fields
 * @param excludeNonUpdatableFields
 *          the flag that indicates if non-updatable fields should be excluded or not
 * @return fields' names
 * @throws KettleException
 */
public String[] getFields( Field[] fields, boolean excludeNonUpdatableFields ) throws KettleException {
  if ( fields != null ) {
    ArrayList<String> fieldsList = new ArrayList<String>( fields.length );
    for ( Field field : fields ) {
      //Add the name of the field - always
      fieldsList.add( field.getName() );
      //Get the referenced to the field object and for this object get all its field to find possible idLookup fields
      if ( isReferenceField( field ) ) {
        String referenceTo = field.getReferenceTo()[0];
        Field[] referenceObjectFields = this.getObjectFields( referenceTo, excludeNonUpdatableFields );

        for ( Field f : referenceObjectFields ) {
          if ( f.isIdLookup() && !isIdField( f ) ) {
            fieldsList.add( String.format( "%s:%s/%s", referenceTo, f.getName(), field.getRelationshipName() ) );
          }
        }
      }
    }
    return fieldsList.toArray( new String[fieldsList.size()] );
  }
  return null;
}
 
Example 6
Source Project: pentaho-kettle   Source File: SalesforceConnectionIT.java    License: Apache License 2.0 6 votes vote down vote up
private void testConnect( String password ) throws Exception {
  LogChannelInterface logInterface = mock( LogChannelInterface.class );
  String url = "http://localhost/services/Soap/u/37.0";
  String username = "MySampleUsername";
  SalesforceConnection connection;
  connection = spy( new SalesforceConnection( logInterface, url, username, password ) );
  ArgumentCaptor<ConnectorConfig> captorConfig = ArgumentCaptor.forClass( ConnectorConfig.class );

  ConnectorConfig mockConfig = mock( ConnectorConfig.class );
  doReturn( UUID.randomUUID().toString() ).when( mockConfig ).getUsername();
  doReturn( UUID.randomUUID().toString() ).when( mockConfig ).getPassword();
  doReturn( mockConfig ).when( bindingStub ).getConfig();
  doReturn( mock( LoginResult.class ) ).when( bindingStub ).login( anyString(), anyString() );

  try {
    connection.connect();
  } catch ( KettleException e ) {
    // The connection should fail
    // We just want to see the generated ConnectorConfig
  }

  verify( connection ).createBinding( captorConfig.capture() );
  assertEquals( username, captorConfig.getValue().getUsername() );
  // Password is unchanged (not decrypted) when setting in ConnectorConfig
  assertEquals( password, captorConfig.getValue().getPassword() );
}
 
Example 7
Source Project: pentaho-kettle   Source File: ScriptValuesMetaMod.java    License: Apache License 2.0 6 votes vote down vote up
public void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ) throws KettleException {
  try {
    rep.saveStepAttribute( id_transformation, id_step, 0, "compatible", compatible );
    rep.saveStepAttribute( id_transformation, id_step, 0, "optimizationLevel", optimizationLevel );

    for ( int i = 0; i < jsScripts.length; i++ ) {
      rep.saveStepAttribute( id_transformation, id_step, i, JSSCRIPT_TAG_NAME, jsScripts[i].getScriptName() );
      rep.saveStepAttribute( id_transformation, id_step, i, JSSCRIPT_TAG_SCRIPT, jsScripts[i].getScript() );
      rep.saveStepAttribute( id_transformation, id_step, i, JSSCRIPT_TAG_TYPE, jsScripts[i].getScriptType() );
    }

    for ( int i = 0; i < fieldname.length; i++ ) {
      rep.saveStepAttribute( id_transformation, id_step, i, "field_name", fieldname[i] );
      rep.saveStepAttribute( id_transformation, id_step, i, "field_rename", rename[i] );
      rep.saveStepAttribute( id_transformation, id_step, i, "field_type",
        ValueMetaFactory.getValueMetaName( type[i] ) );
      rep.saveStepAttribute( id_transformation, id_step, i, "field_length", length[i] );
      rep.saveStepAttribute( id_transformation, id_step, i, "field_precision", precision[i] );
      rep.saveStepAttribute( id_transformation, id_step, i, "field_replace", replace[i] );
    }
  } catch ( Exception e ) {
    throw new KettleException( BaseMessages
      .getString( PKG, "ScriptValuesMetaMod.Exception.UnableToSaveStepInfo" )
      + id_step, e );
  }
}
 
Example 8
Source Project: pentaho-kettle   Source File: DialogHelper.java    License: Apache License 2.0 6 votes vote down vote up
public static RepositoryObject selectRepositoryObject( String filter, LogChannel log ) {
  try {
    FileDialogOperation fileDialogOperation =
      new FileDialogOperation( FileDialogOperation.OPEN, FileDialogOperation.ORIGIN_OTHER );
    if ( !Utils.isEmpty( filter ) ) {
      fileDialogOperation.setFilter( filter );
    }
    ExtensionPointHandler.callExtensionPoint( log, KettleExtensionPoint.SpoonOpenSaveRepository.id,
      fileDialogOperation );
    return (RepositoryObject) fileDialogOperation.getRepositoryObject();
  } catch ( KettleException ke ) {
    // Ignore
  }

  return null;
}
 
Example 9
Source Project: pentaho-kettle   Source File: BlockingStepMetaTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testRoundTrip() throws KettleException {
  List<String> attributes = Arrays.asList( "pass_all_rows", "directory", "prefix", "cache_size", "compress" );

  Map<String, String> getterMap = new HashMap<String, String>();
  getterMap.put( "pass_all_rows", "isPassAllRows" );
  getterMap.put( "directory", "getDirectory" );
  getterMap.put( "prefix", "getPrefix" );
  getterMap.put( "cache_size", "getCacheSize" );
  getterMap.put( "compress", "getCompress" );

  Map<String, String> setterMap = new HashMap<String, String>();
  setterMap.put( "pass_all_rows", "setPassAllRows" );
  setterMap.put( "directory", "setDirectory" );
  setterMap.put( "prefix", "setPrefix" );
  setterMap.put( "cache_size", "setCacheSize" );
  setterMap.put( "compress", "setCompress" );

  LoadSaveTester loadSaveTester = new LoadSaveTester( BlockingStepMeta.class, attributes, getterMap, setterMap );
  loadSaveTester.testSerialization();
}
 
Example 10
Source Project: pentaho-kettle   Source File: PDI5436Test.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testCacheAllTable() throws KettleException {
  DatabaseLookup stepSpy =
      spy( new DatabaseLookup( smh.stepMeta, smh.stepDataInterface, 0, smh.transMeta, smh.trans ) );

  Database database = mockDatabase();
  doReturn( database ).when( stepSpy ).getDatabase( any( DatabaseMeta.class ) );

  stepSpy.addRowSetToInputRowSets( mockInputRowSet() );
  stepSpy.setInputRowMeta( mockInputRowMeta() );
  RowSet outputRowSet = new QueueRowSet();
  stepSpy.addRowSetToOutputRowSets( outputRowSet );

  StepMetaInterface meta = mockStepMeta();
  StepDataInterface data = smh.initStepDataInterface;

  Assert.assertTrue( "Step init failed", stepSpy.init( meta, data ) );
  Assert.assertTrue( "Error processing row", stepSpy.processRow( meta, data ) );
  Assert.assertEquals( "Cache lookup failed", "value", outputRowSet.getRow()[2] );
}
 
Example 11
Source Project: pentaho-kettle   Source File: KettleFileRepository.java    License: Apache License 2.0 6 votes vote down vote up
private ObjectId renameObject( ObjectId id, RepositoryDirectoryInterface newDirectory, String newName,
  String extension ) throws KettleException {
  try {
    // In case of a root object, the ID is the same as the relative filename...
    //
    FileObject fileObject = KettleVFS.getFileObject( calcDirectoryName( null ) + id.getId() );

    // Same name, different folder?
    if ( Utils.isEmpty( newName ) ) {
      newName = calcObjectName( id );
    }
    // The new filename can be anywhere so we re-calculate a new ID...
    //
    String newFilename = calcDirectoryName( newDirectory ) + newName + extension;

    FileObject newObject = KettleVFS.getFileObject( newFilename );
    fileObject.moveTo( newObject );

    return new StringObjectId( calcObjectId( newDirectory, newName, extension ) );
  } catch ( Exception e ) {
    throw new KettleException( "Unable to rename object with ID [" + id + "] to [" + newName + "]", e );
  }

}
 
Example 12
Source Project: pentaho-kettle   Source File: MissingPluginTransIT.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Given a transformation having a step which's plugin is missing in current Kettle installation.
 * When this transformation is executed, then execution should fail.
 */
@Test
public void testForPluginMissingStep() throws Exception {
  InputStream is = new FileInputStream(
      new File( this.getClass().getResource( "missing_plugin_trans.ktr" ).getFile() ) );
  TransMeta transMeta = new TransMeta( is, null, false, null, null );
  Trans trans = new Trans( transMeta );
  LogChannelInterface log = mock( LogChannelInterface.class );
  trans.setLog( log );

  try {
    trans.prepareExecution( null );
    fail();
  } catch ( KettleException e ) {
    verify( log, times( 1 ) ).logError( "Step [JSON Input.0] failed to initialize!" );
  }
}
 
Example 13
Source Project: pentaho-kettle   Source File: KettleDatabaseRepository.java    License: Apache License 2.0 6 votes vote down vote up
public synchronized void insertJobEntryDatabase( ObjectId id_job, ObjectId id_jobentry, ObjectId id_database ) throws KettleException {
  // First check if the relationship is already there.
  // There is no need to store it twice!
  RowMetaAndData check = getJobEntryDatabase( id_jobentry );

  if ( check.getInteger( 0 ) == null ) {
    RowMetaAndData table = new RowMetaAndData();

    table.addValue( new ValueMetaInteger(
      KettleDatabaseRepository.FIELD_JOBENTRY_DATABASE_ID_JOB ), id_job );
    table.addValue(
      new ValueMetaInteger(
        KettleDatabaseRepository.FIELD_JOBENTRY_DATABASE_ID_JOBENTRY ),
      id_jobentry );
    table.addValue(
      new ValueMetaInteger(
        KettleDatabaseRepository.FIELD_JOBENTRY_DATABASE_ID_DATABASE ),
      id_database );

    connectionDelegate.insertTableRow( KettleDatabaseRepository.TABLE_R_JOBENTRY_DATABASE, table );
  }
}
 
Example 14
Source Project: pentaho-kettle   Source File: GetVariableDialog.java    License: Apache License 2.0 6 votes vote down vote up
private void getInfo( GetVariableMeta input ) throws KettleException {

    stepname = wStepname.getText(); // return value
    // Table table = wFields.table;

    int count = wFields.nrNonEmpty();
    input.allocate( count );

    //CHECKSTYLE:Indentation:OFF
    for ( int i = 0; i < count; i++ ) {
      TableItem item = wFields.getNonEmpty( i );

      FieldDefinition currentField = input.getFieldDefinitions()[i];
      int index = 1;
      currentField.setFieldName( item.getText( index++ ) );
      currentField.setVariableString( item.getText( index++ ) );
      currentField.setFieldType( ValueMetaFactory.getIdForValueMeta( item.getText( index++ ) ) );
      currentField.setFieldFormat( item.getText( index++ ) );
      currentField.setFieldLength( Const.toInt( item.getText( index++ ), -1 ) );
      currentField.setFieldPrecision( Const.toInt( item.getText( index++ ), -1 ) );
      currentField.setCurrency( item.getText( index++ ) );
      currentField.setDecimal( item.getText( index++ ) );
      currentField.setGroup( item.getText( index++ ) );
      currentField.setTrimType( ValueMetaString.getTrimTypeByDesc( item.getText( index++ ) ) );
    }
  }
 
Example 15
Source Project: pentaho-kettle   Source File: KettleDatabaseRepository.java    License: Apache License 2.0 5 votes vote down vote up
public synchronized String[] getClusterNames( boolean includeDeleted ) throws KettleException {
  String nameField = quote( KettleDatabaseRepository.FIELD_CLUSTER_NAME );
  return connectionDelegate
    .getStrings( "SELECT "
      + nameField + " FROM " + quoteTable( KettleDatabaseRepository.TABLE_R_CLUSTER ) + " ORDER BY "
      + nameField );
}
 
Example 16
Source Project: pentaho-kettle   Source File: AddSequenceMeta.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ) throws KettleException {
  try {
    valuename = rep.getStepAttributeString( id_step, "valuename" );

    useDatabase = rep.getStepAttributeBoolean( id_step, "use_database" );

    database = rep.loadDatabaseMetaFromStepAttribute( id_step, "id_connection", databases );

    schemaName = rep.getStepAttributeString( id_step, "schema" );
    sequenceName = rep.getStepAttributeString( id_step, "seqname" );

    useCounter = rep.getStepAttributeBoolean( id_step, "use_counter" );
    counterName = rep.getStepAttributeString( id_step, "counter_name" );

    startAt = rep.getStepAttributeString( id_step, "start_at" );
    incrementBy = rep.getStepAttributeString( id_step, "increment_by" );
    maxValue = rep.getStepAttributeString( id_step, "max_value" );

    // Fix for backwards compatibility, only to be used from previous versions (TO DO Sven Boden: remove in later
    // versions)
    if ( startAt == null ) {
      long start = rep.getStepAttributeInteger( id_step, "start_at" );
      startAt = Long.toString( start );
    }

    if ( incrementBy == null ) {
      long increment = rep.getStepAttributeInteger( id_step, "increment_by" );
      incrementBy = Long.toString( increment );
    }

    if ( maxValue == null ) {
      long max = rep.getStepAttributeInteger( id_step, "max_value" );
      maxValue = Long.toString( max );
    }
  } catch ( Exception e ) {
    throw new KettleException( BaseMessages.getString( PKG, "AddSequenceMeta.Exception.UnableToReadStepInfo" )
      + id_step, e );
  }
}
 
Example 17
Source Project: pentaho-kettle   Source File: JobEntryEval.java    License: Apache License 2.0 5 votes vote down vote up
public void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_job ) throws KettleException {
  try {
    rep.saveJobEntryAttribute( id_job, getObjectId(), "script", script );
  } catch ( KettleDatabaseException dbe ) {
    throw new KettleException( BaseMessages.getString( PKG, "JobEntryEval.UnableToSaveToRepo", String
      .valueOf( id_job ) ), dbe );
  }
}
 
Example 18
Source Project: pentaho-kettle   Source File: KettleDatabaseRepository.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Load a condition from the repository with the Object ID stored in a step attribute.
 *
 * @param id_step
 * @param code
 * @return
 * @throws KettleException
 */
public Condition loadConditionFromStepAttribute( ObjectId id_step, String code ) throws KettleException {
  long id_condition = getStepAttributeInteger( id_step, code );
  if ( id_condition > 0 ) {
    return loadCondition( new LongObjectId( id_condition ) ); // this repository
                                                              // uses longs
  } else {
    return null;
  }

}
 
Example 19
Source Project: pentaho-kettle   Source File: BaseSerializingMeta.java    License: Apache License 2.0 5 votes vote down vote up
@Override public void saveRep( Repository rep, IMetaStore metaStore, ObjectId transId, ObjectId stepId )
  throws KettleException {
  RepoSerializer.builder()
    .stepMeta( this )
    .repo( rep )
    .stepId( stepId )
    .transId( transId )
    .serialize();
}
 
Example 20
Source Project: pentaho-kettle   Source File: SalesforceUpsertTest.java    License: Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws KettleException {
  PluginRegistry.addPluginType( TwoWayPasswordEncoderPluginType.getInstance() );
  PluginRegistry.init();
  String passwordEncoderPluginID =
      Const.NVL( EnvUtil.getSystemProperty( Const.KETTLE_PASSWORD_ENCODER_PLUGIN ), "Kettle" );
  Encr.init( passwordEncoderPluginID );
}
 
Example 21
Source Project: pentaho-kettle   Source File: SalesforceInsertDialog.java    License: Apache License 2.0 5 votes vote down vote up
private void ok() {
  try {
    getInfo( input );
  } catch ( KettleException e ) {
    new ErrorDialog(
      shell, BaseMessages.getString( PKG, "SalesforceInsertDialog.ErrorValidateData.DialogTitle" ),
      BaseMessages.getString( PKG, "SalesforceInsertDialog.ErrorValidateData.DialogMessage" ), e );
  }

  dispose();
}
 
Example 22
Source Project: pentaho-kettle   Source File: SlaveServerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test( expected = KettleException.class )
public void testSendXML() throws Exception {
  slaveServer.setHostname( "hostNameStub" );
  slaveServer.setUsername( "userNAmeStub" );
  HttpPost httpPostMock = mock( HttpPost.class );
  URI uriMock = new URI( "fake" );
  doReturn( uriMock ).when( httpPostMock ).getURI();
  doReturn( httpPostMock ).when( slaveServer ).buildSendXMLMethod( any( byte[].class ), anyString() );
  slaveServer.sendXML( "", "" );
  fail( "Incorrect connection details had been used, but no exception was thrown" );
}
 
Example 23
Source Project: pentaho-kettle   Source File: KettleDatabaseRepository.java    License: Apache License 2.0 5 votes vote down vote up
public synchronized String[] getTransformationsUsingCluster( ObjectId id_cluster ) throws KettleException {
  ObjectId[] transIds =
    connectionDelegate.getIDs( "SELECT DISTINCT "
      + quote( FIELD_TRANS_CLUSTER_ID_TRANSFORMATION ) + " FROM " + quoteTable( TABLE_R_TRANS_CLUSTER )
      + " WHERE " + quote( FIELD_TRANS_CLUSTER_ID_CLUSTER ) + " = ?", id_cluster );
  return transDelegate.getTransformationsWithIDList( transIds );
}
 
Example 24
Source Project: pentaho-kettle   Source File: JsonInputDialog.java    License: Apache License 2.0 5 votes vote down vote up
private void ok() {
  try {
    getInfo( input );
  } catch ( KettleException e ) {
    new ErrorDialog( shell, BaseMessages.getString( PKG, "JsonInputDialog.ErrorParsingData.DialogTitle" ),
        BaseMessages.getString( PKG, "JsonInputDialog.ErrorParsingData.DialogMessage" ), e );
  }
  dispose();
}
 
Example 25
Source Project: pentaho-kettle   Source File: DatabaseLookupUTest.java    License: Apache License 2.0 5 votes vote down vote up
private DatabaseLookup createSpiedStep( Database db,
                                        StepMockHelper<DatabaseLookupMeta, DatabaseLookupData> mockHelper,
                                        DatabaseLookupMeta meta ) throws KettleException {
  DatabaseLookup step = spyLookup( mockHelper, db, meta.getDatabaseMeta() );
  doNothing().when( step ).determineFieldsTypesQueryingDb();
  doReturn( null ).when( step ).lookupValues( any( RowMetaInterface.class ), any( Object[].class ) );

  RowMeta input = new RowMeta();
  input.addValueMeta( new ValueMetaInteger( "Test" ) );
  step.setInputRowMeta( input );
  return step;
}
 
Example 26
Source Project: kettle-beam   Source File: BeamProduce.java    License: Apache License 2.0 5 votes vote down vote up
@Override public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException {

    // Outside of a Beam Runner this step doesn't actually do anything, it's just metadata
    // This step gets converted into Beam API calls in a pipeline
    //
    return false;
  }
 
Example 27
Source Project: pentaho-kettle   Source File: StarModelerPerspective.java    License: Apache License 2.0 5 votes vote down vote up
protected void testMetaStore() {
  try {
    // Force repository meta store
    IMetaStore metaStore = Spoon.getInstance().getRepository().getMetaStore();

    LogChannel.GENERAL.logBasic("Active metastore: "+metaStore.getName());

    StarDomainMetaStoreUtil.verifyNamespaceCreated(metaStore, "pentaho");
    IMetaStoreElementType elementType = StarDomainMetaStoreUtil.getStarDomainElementType(metaStore);
    if (elementType==null) {
      throw new KettleException("Unable to find star domain element type");
    }
    LogChannel.GENERAL.logBasic("Found star domain element type: "+elementType.getName()+" : "+elementType.getDescription());

    elementType = metaStore.getElementTypeByName(PentahoDefaults.NAMESPACE, elementType.getName());
    if (elementType==null) {
      throw new KettleException("Unable to find star domain element type by name");
    }

    LogChannel.GENERAL.logBasic("Found element type by name");

    List<IdNameDescription> list = new ArrayList<IdNameDescription>();
    for (IMetaStoreElement element : metaStore.getElements(PentahoDefaults.NAMESPACE, elementType)) {
      IdNameDescription nameDescription = new IdNameDescription(element.getId(), element.getName(), null);
      list.add(nameDescription);
    }
    LogChannel.GENERAL.logBasic("Found "+list.size()+" star domain elements.");

    StarDomainMetaStoreUtil.getStarDomainList(metaStore);

  } catch(Exception e) {
    new ErrorDialog(Spoon.getInstance().getShell(), "ERROR", "Error testing meta store: ", e);
  }
}
 
Example 28
Source Project: kettle-beam   Source File: BeamOutputMeta.java    License: Apache License 2.0 5 votes vote down vote up
@Override public String getXML() throws KettleException {
  StringBuffer xml = new StringBuffer(  );

  xml.append( XMLHandler.addTagValue( OUTPUT_LOCATION, outputLocation ) );
  xml.append( XMLHandler.addTagValue( FILE_DESCRIPTION_NAME, fileDescriptionName) );
  xml.append( XMLHandler.addTagValue( FILE_PREFIX, filePrefix) );
  xml.append( XMLHandler.addTagValue( FILE_SUFFIX, fileSuffix) );
  xml.append( XMLHandler.addTagValue( WINDOWED, windowed) );

  return xml.toString();
}
 
Example 29
public synchronized void delDatabase( ObjectId id_database ) throws KettleException {
  repository.getSecurityProvider().validateAction( RepositoryOperation.DELETE_DATABASE );

  // First, see if the database connection is still used by other connections...
  // If so, generate an error!!
  // We look in table R_STEP_DATABASE to see if there are any steps using this database.
  //
  String[] transList = repository.getTransformationsUsingDatabase( id_database );
  String[] jobList = repository.getJobsUsingDatabase( id_database );

  if ( jobList.length == 0 && transList.length == 0 ) {
    repository.connectionDelegate.performDelete( "DELETE FROM "
      + quoteTable( KettleDatabaseRepository.TABLE_R_DATABASE ) + " WHERE "
      + quote( KettleDatabaseRepository.FIELD_DATABASE_ID_DATABASE ) + " = ? ", id_database );
  } else {
    String message = " Database used by the following " + Const.CR;
    if ( jobList.length > 0 ) {
      message = "jobs :" + Const.CR;
      for ( String job : jobList ) {
        message += "\t " + job + Const.CR;
      }
    }

    message += "transformations:" + Const.CR;
    for ( String trans : transList ) {
      message += "\t " + trans + Const.CR;
    }
    KettleDependencyException e = new KettleDependencyException( message );
    throw new KettleDependencyException( "This database is still in use by "
      + jobList.length + " jobs and " + transList.length + " transformations references", e );
  }
}
 
Example 30
Source Project: pentaho-kettle   Source File: SalesforceInputDialog.java    License: Apache License 2.0 5 votes vote down vote up
private void ok() {
  if ( Utils.isEmpty( wStepname.getText() ) ) {
    return;
  }

  stepname = wStepname.getText();
  try {
    getInfo( input );
  } catch ( KettleException e ) {
    new ErrorDialog(
      shell, BaseMessages.getString( PKG, "SalesforceInputDialog.ErrorValidateData.DialogTitle" ),
      BaseMessages.getString( PKG, "SalesforceInputDialog.ErrorValidateData.DialogMessage" ), e );
  }
  dispose();
}