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

The following examples show how to use org.pentaho.di.core.exception.KettleException. 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 File: BlockingStepMetaTest.java    From pentaho-kettle with 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 #2
Source File: MissingPluginTransIT.java    From pentaho-kettle with 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 #3
Source File: KettleFileRepository.java    From pentaho-kettle with 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 #4
Source File: DialogHelper.java    From pentaho-kettle with 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 #5
Source File: FuzzyMatchDialog.java    From pentaho-kettle with 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 #6
Source File: GPLoad.java    From pentaho-kettle with 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 #7
Source File: KettleUtils.java    From OpenKettleWebUI with 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 #8
Source File: SalesforceConnection.java    From pentaho-kettle with 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 #9
Source File: SalesforceConnectionIT.java    From pentaho-kettle with 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 #10
Source File: JobEntryCheckFilesLocked.java    From pentaho-kettle with 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 #11
Source File: KettleDatabaseRepository.java    From pentaho-kettle with 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 #12
Source File: PDI5436Test.java    From pentaho-kettle with 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 #13
Source File: GetVariableDialog.java    From pentaho-kettle with 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 #14
Source File: ScriptValuesMetaMod.java    From pentaho-kettle with 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 #15
Source File: SlaveServerTest.java    From pentaho-kettle with 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 #16
Source File: XMLInputSax.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException {
  if ( first ) {
    first = false;

    data.outputRowMeta = new RowMeta();
    meta.getFields( data.outputRowMeta, getStepname(), null, null, this, repository, metaStore );

    // For String to <type> conversions, we allocate a conversion meta data row as well...
    //
    data.convertRowMeta = data.outputRowMeta.cloneToType( ValueMetaInterface.TYPE_STRING );
  }

  Object[] outputRowData = getRowFromXML();
  if ( outputRowData == null ) {
    setOutputDone(); // signal end to receiver(s)
    return false; // This is the end of this step.
  }

  if ( log.isRowLevel() ) {
    logRowlevel( "Read row: " + data.outputRowMeta.getString( outputRowData ) );
  }

  putRow( data.outputRowMeta, outputRowData );

  // limit has been reached: stop now.
  //
  if ( meta.getRowLimit() > 0 && data.rownr >= meta.getRowLimit() ) {
    setOutputDone();
    return false;
  }

  return true;
}
 
Example #17
Source File: DatabaseLookupUTest.java    From pentaho-kettle with 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 #18
Source File: MemoryRepository.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Override
public void saveDatabaseMetaStepAttribute( ObjectId id_transformation, ObjectId id_step, String code,
    DatabaseMeta database ) throws KettleException {
  ObjectId id = null;
  if ( database != null ) {
    id = database.getObjectId();
    Long id_database = id == null ? Long.valueOf( -1L ) : new LongObjectId( id ).longValue();
    saveStepAttribute( id_transformation, id_step, code, id_database );
  }
}
 
Example #19
Source File: KettleDatabaseRepository.java    From pentaho-kettle with 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 #20
Source File: Trans.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
protected ExecutorService startHeartbeat( final long intervalInSeconds ) {

    ScheduledExecutorService heartbeat = Executors.newSingleThreadScheduledExecutor( new ThreadFactory() {

      @Override
      public Thread newThread( Runnable r ) {
        Thread thread = new Thread( r, "Transformation Heartbeat Thread for: " + getName() );
        thread.setDaemon( true );
        return thread;
      }
    } );

    heartbeat.scheduleAtFixedRate( new Runnable() {
      @Override
      public void run() {
        try {

          if ( Trans.this.isFinished() ) {
            log.logBasic( "Shutting down heartbeat signal for " + getName() );
            shutdownHeartbeat( Trans.this.heartbeat );
            return;
          }

          log.logDebug( "Triggering heartbeat signal for " + getName() + " at every " + intervalInSeconds
            + " seconds" );
          ExtensionPointHandler.callExtensionPoint( log, KettleExtensionPoint.TransformationHeartbeat.id, Trans.this );

        } catch ( KettleException e ) {
          log.logError( e.getMessage(), e );
        }
      }
    }, intervalInSeconds /* initial delay */, intervalInSeconds /* interval delay */, TimeUnit.SECONDS );

    return heartbeat;
  }
 
Example #21
Source File: AbsSecurityManager.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public Map<String, String> getAllLogicalRoles( String locale ) throws KettleException {
  if ( authorizationPolicyRoleBindingService != null ) {
    return roleBindingStruct.logicalRoleNameMap;
  } else {
    throw new KettleException( BaseMessages.getString( AbsSecurityManager.class,
        "AbsSecurityManager.ERROR_0005_INSUFFICIENT_PRIVELEGES" ) ); //$NON-NLS-1$
  }
}
 
Example #22
Source File: KettleDatabaseRepository.java    From pentaho-kettle with 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 #23
Source File: JsonInputDialog.java    From pentaho-kettle with 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 #24
Source File: KettleDatabaseRepository.java    From pentaho-kettle with 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 #25
Source File: RepositoryProxy.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public String getStepAttributeString( ObjectId idStep, int nr, String code ) throws KettleException {
  String propName = code + PROP_CODE_NR_SEPARATOR + nr;
  if ( node.hasProperty( propName ) ) {
    return node.getProperty( propName ).getString();
  } else if ( nr == 0 && node.hasProperty( code ) ) {
    // Old pur stored elements with no nr when not specified
    return node.getProperty( code ).getString();
  } else {
    return null;
  }
}
 
Example #26
Source File: BeamProduce.java    From kettle-beam with 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 File: SalesforceInputDialog.java    From pentaho-kettle with 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();
}
 
Example #28
Source File: StarModelerPerspective.java    From pentaho-kettle with 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 #29
Source File: BeamOutputMeta.java    From kettle-beam with 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 #30
Source File: KettleDatabaseRepositoryDatabaseDelegate.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
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 );
  }
}