Java Code Examples for org.pentaho.di.core.exception.KettleException#printStackTrace()

The following examples show how to use org.pentaho.di.core.exception.KettleException#printStackTrace() . 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: AvroNestedRecordReader.java    From pentaho-hadoop-shims with Apache License 2.0 6 votes vote down vote up
private RowMetaAndData getNextRowMetaAndData() {
  if ( hasExpandedRows() == false ) {
    try {
      nextExpandedRow = 0;
      expandedRows = null;
      expandedRows = avroNestedReader.avroObjectToKettle( incomingFields, avroInputStep );
      if ( expandedRows != null ) {
        nextRow = objectToRowMetaAndData( expandedRows[ nextExpandedRow ] );
      } else {
        return null;
      }
    } catch ( KettleException e ) {
      e.printStackTrace();
    }
  }

  nextRow = objectToRowMetaAndData( expandedRows[ nextExpandedRow ] );
  nextExpandedRow++;
  return nextRow;
}
 
Example 2
Source File: UserRoleHelper.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public static Set<IRole> getRolesForUser( String name, List<UserToRoleAssignment> assignments,
    IRoleSupportSecurityManager rsm ) {
  if ( assignments == null || assignments.isEmpty() ) {
    return Collections.emptySet();
  }

  Set<IRole> roles = new HashSet<IRole>( assignments.size() );
  for ( UserToRoleAssignment assignment : assignments ) {
    if ( name.equals( assignment.getUserId() ) ) {
      IRole role = null;
      try {
        role = rsm.constructRole();
      } catch ( KettleException e ) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      if ( role != null ) {
        role.setName( assignment.getRoleId() );
        roles.add( role );
      }
    }
  }
  return roles;
}
 
Example 3
Source File: KettleEnvironmentIT.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void lifecycleListenerEnvironmentInitCallback_throwable_thrown() throws Exception {
  resetKettleEnvironmentInitializationFlag();
  assertFalse( "This test only works if the Kettle Environment is not yet initialized", KettleEnvironment
      .isInitialized() );
  System.setProperty( Const.KETTLE_PLUGIN_CLASSES, ThrowableFailingMockLifecycleListener.class.getName() );
  try {
    KettleEnvironment.init();
    fail( "Expected exception" );
  } catch ( KettleException ex ) {
    assertEquals( AbstractMethodError.class, ex.getCause().getClass() );
    ex.printStackTrace();
  }

  assertFalse( KettleEnvironment.isInitialized() );
}
 
Example 4
Source File: UserRoleHelper.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public static IUser convertToUserInfo( ProxyPentahoUser user, ProxyPentahoRole[] roles,
    IRoleSupportSecurityManager rsm ) {
  IUser userInfo = null;
  try {
    userInfo = rsm.constructUser();
    userInfo.setDescription( user.getDescription() );
    userInfo.setPassword( user.getPassword() );
    userInfo.setLogin( user.getName() );
    userInfo.setName( user.getName() );
    if ( userInfo instanceof IEEUser ) {
      ( (IEEUser) userInfo ).setRoles( convertToSetFromProxyPentahoRoles( roles, rsm ) );
    }
  } catch ( KettleException ke ) {
    ke.printStackTrace();
  }
  return userInfo;
}
 
Example 5
Source File: TransformationResource.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@GET
@Path( "/start/{id : .+}" )
@Produces( { MediaType.APPLICATION_JSON } )
public TransformationStatus startTransformation( @PathParam( "id" ) String id ) {
  Trans trans = CarteResource.getTransformation( id );
  try {
    // Discard old log lines from old transformation runs
    //
    KettleLogStore.discardLines( trans.getLogChannelId(), true );

    String carteObjectId = UUID.randomUUID().toString();
    SimpleLoggingObject servletLoggingObject =
      new SimpleLoggingObject( getClass().getName(), LoggingObjectType.CARTE, null );
    servletLoggingObject.setContainerObjectId( carteObjectId );
    servletLoggingObject.setLogLevel( trans.getLogLevel() );
    trans.setParent( servletLoggingObject );
    trans.execute( null );
  } catch ( KettleException e ) {
    e.printStackTrace();
  }
  return getTransformationStatus( id );
}
 
Example 6
Source File: TransformationResource.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@GET
@Path( "/prepare/{id : .+}" )
@Produces( { MediaType.APPLICATION_JSON } )
public TransformationStatus prepareTransformation( @PathParam( "id" ) String id ) {
  Trans trans = CarteResource.getTransformation( id );
  try {

    CarteObjectEntry entry = CarteResource.getCarteObjectEntry( id );
    TransConfiguration transConfiguration =
      CarteSingleton.getInstance().getTransformationMap().getConfiguration( entry );
    TransExecutionConfiguration executionConfiguration = transConfiguration.getTransExecutionConfiguration();
    // Set the appropriate logging, variables, arguments, replay date, ...
    // etc.
    trans.setArguments( executionConfiguration.getArgumentStrings() );
    trans.setReplayDate( executionConfiguration.getReplayDate() );
    trans.setSafeModeEnabled( executionConfiguration.isSafeModeEnabled() );
    trans.setGatheringMetrics( executionConfiguration.isGatheringMetrics() );
    trans.injectVariables( executionConfiguration.getVariables() );
    trans.setPreviousResult( executionConfiguration.getPreviousResult() );

    trans.prepareExecution( null );
  } catch ( KettleException e ) {
    e.printStackTrace();
  }
  return getTransformationStatus( id );
}
 
Example 7
Source File: CapabilityManagerDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public static void main( String[] args ) {

    Display display = new Display(  );
    try {
      KettleEnvironment.init();

      PropsUI.init( display, Props.TYPE_PROPERTIES_SPOON );

      KettleLogStore
          .init( PropsUI.getInstance().getMaxNrLinesInLog(), PropsUI.getInstance().getMaxLogLineTimeoutMinutes() );

    } catch ( KettleException e ) {
      e.printStackTrace();
    }

    KettleClientEnvironment.getInstance().setClient( KettleClientEnvironment.ClientType.SPOON );
    Shell shell = new Shell( display, SWT.DIALOG_TRIM );
    shell.open();
    CapabilityManagerDialog capabilityManagerDialog = new CapabilityManagerDialog( shell );
    capabilityManagerDialog.open();
    while ( !shell.isDisposed() ) {
      if ( !display.readAndDispatch() ) {
        display.sleep();
      }
    }
  }
 
Example 8
Source File: UserRoleHelper.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public static IUser convertFromProxyPentahoUser( ProxyPentahoUser user, List<UserToRoleAssignment> assignments,
    IRoleSupportSecurityManager rsm ) {
  IUser userInfo = null;
  try {
    userInfo = rsm.constructUser();
    userInfo.setDescription( user.getDescription() );
    userInfo.setPassword( user.getPassword() );
    userInfo.setLogin( user.getName() );
    userInfo.setName( user.getName() );
    if ( userInfo instanceof IEEUser ) {
      ( (IEEUser) userInfo ).setRoles( getRolesForUser( user.getName(), assignments, rsm ) );
    }
  } catch ( KettleException e ) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  }
  return userInfo;
}
 
Example 9
Source File: RepositoryFileProvider.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Override
public List<RepositoryFile> getFiles( RepositoryFile file, String filters ) {
  RepositoryDirectoryInterface repositoryDirectoryInterface =
    findDirectory( file.getType().equalsIgnoreCase( RepositoryDirectory.DIRECTORY ) ? file.getPath() : file.getParent() );

  RepositoryDirectory repositoryDirectory = RepositoryDirectory.build( null, repositoryDirectoryInterface );
  populateFolders( repositoryDirectory, repositoryDirectoryInterface );
  try {
    populateFiles( repositoryDirectory, repositoryDirectoryInterface, FILTER );
  } catch ( KettleException ke ) {
    ke.printStackTrace();
  }
  return repositoryDirectory.getChildren();
}
 
Example 10
Source File: KettleUtilsTest.java    From OpenKettleWebUI with Apache License 2.0 5 votes vote down vote up
@Before
public void testInitFileRepository() {
  String dir = "D:/kettle/data";
  try {
    rep = KettleUtils.initFileRepository(dir);
  } catch (KettleException e) {
    e.printStackTrace();
  }
}
 
Example 11
Source File: RepositoryBrowserController.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public RepositoryDirectory loadFilesAndFolders( String path ) {
  RepositoryDirectoryInterface repositoryDirectoryInterface = findDirectory( path );
  RepositoryDirectory repositoryDirectory = RepositoryDirectory.build( null, repositoryDirectoryInterface );
  populateFolders( repositoryDirectory, repositoryDirectoryInterface );
  try {
    populateFiles( repositoryDirectory, repositoryDirectoryInterface, FILTER );
  } catch ( KettleException ke ) {
    ke.printStackTrace();
  }
  return repositoryDirectory;
}
 
Example 12
Source File: UISecurityRole.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public IRole getRole( IRoleSupportSecurityManager rsm ) {
  IRole roleInfo = null;
  try {
    roleInfo = rsm.constructRole();
  } catch ( KettleException e ) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  }
  roleInfo.setDescription( description );
  roleInfo.setName( name );
  for ( IUIUser user : getAssignedUsers() ) {
    roleInfo.addUser( user.getUserInfo() );
  }
  return roleInfo;
}
 
Example 13
Source File: UserRoleLookupCache.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private IRole createRoleInfo( String role ) {
  IRole roleInfo = null;
  try {
    roleInfo = rsm.constructRole();
  } catch ( KettleException e ) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  }
  roleInfo.setName( role );
  return roleInfo;
}
 
Example 14
Source File: PurRepository.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
protected void saveSlaveServer( final RepositoryElementInterface element, final String versionComment,
                                Calendar versionDate ) throws KettleException {
  try {
    // Even if the object id is null, we still have to check if the element is not present in the PUR
    // For example, if we import data from an XML file and there is a element with the same name in it.
    //
    if ( element.getObjectId() == null ) {
      element.setObjectId( getSlaveID( element.getName() ) );
    }

    saveRepositoryElement( element, versionComment, slaveTransformer, getSlaveServerParentFolderId() );
  } catch ( KettleException ke ) {
    ke.printStackTrace();
  }
}
 
Example 15
Source File: CalculatorBackwardCompatibilityUnitTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void assertRound( final double expectedResult, final double value ) throws KettleException {
  RowMeta inputRowMeta = new RowMeta();
  ValueMetaNumber valueMeta = new ValueMetaNumber( "Value" );
  inputRowMeta.addValueMeta( valueMeta );

  RowSet inputRowSet = smh.getMockInputRowSet( new Object[] { value } );
  inputRowSet.setRowMeta( inputRowMeta );

  Calculator calculator = new Calculator( smh.stepMeta, smh.stepDataInterface, 0, smh.transMeta, smh.trans );
  calculator.addRowSetToInputRowSets( inputRowSet );
  calculator.setInputRowMeta( inputRowMeta );
  calculator.init( smh.initStepMetaInterface, smh.initStepDataInterface );

  CalculatorMeta meta = new CalculatorMeta();
  meta.setCalculation( new CalculatorMetaFunction[] { new CalculatorMetaFunction( "test",
      CalculatorMetaFunction.CALC_ROUND_1, "Value", null, null, ValueMetaInterface.TYPE_NUMBER, 2, 0, false, "", "",
      "", "" ) } );

  // Verify output
  try {
    calculator.addRowListener( new RowAdapter() {
      @Override
      public void rowWrittenEvent( RowMetaInterface rowMeta, Object[] row ) throws KettleStepException {
        assertEquals( expectedResult, row[1] );
      }
    } );
    calculator.processRow( meta, new CalculatorData() );
  } catch ( KettleException ke ) {
    ke.printStackTrace();
    fail();
  }

}
 
Example 16
Source File: CalculatorUnitTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testReturnDigitsOnly() throws KettleException {
  RowMeta inputRowMeta = new RowMeta();
  ValueMetaString nameMeta = new ValueMetaString( "Name" );
  inputRowMeta.addValueMeta( nameMeta );
  ValueMetaString valueMeta = new ValueMetaString( "Value" );
  inputRowMeta.addValueMeta( valueMeta );

  RowSet inputRowSet = smh.getMockInputRowSet( new Object[][] { { "name1", "qwe123asd456zxc" }, { "name2", null } } );
  inputRowSet.setRowMeta( inputRowMeta );

  Calculator calculator = new Calculator( smh.stepMeta, smh.stepDataInterface, 0, smh.transMeta, smh.trans );
  calculator.addRowSetToInputRowSets( inputRowSet );
  calculator.setInputRowMeta( inputRowMeta );
  calculator.init( smh.initStepMetaInterface, smh.initStepDataInterface );

  CalculatorMeta meta = new CalculatorMeta();
  meta.setCalculation( new CalculatorMetaFunction[] {
    new CalculatorMetaFunction( "digits", CalculatorMetaFunction.CALC_GET_ONLY_DIGITS, "Value", null, null,
      ValueMetaInterface.TYPE_STRING, 0, 0, false, "", "", "", "" ) } );

  // Verify output
  try {
    calculator.addRowListener( new RowAdapter() {
      @Override public void rowWrittenEvent( RowMetaInterface rowMeta, Object[] row ) throws KettleStepException {
        assertEquals( "123456", row[ 2 ] );
      }
    } );
    calculator.processRow( meta, new CalculatorData() );
  } catch ( KettleException ke ) {
    ke.printStackTrace();
    fail();
  }
}
 
Example 17
Source File: RepositoryFileProvider.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private List<RepositoryElementMetaInterface> getRepositoryElements(
  RepositoryDirectoryInterface repositoryDirectoryInterface ) {
  List<RepositoryElementMetaInterface> elements = repositoryDirectoryInterface.getRepositoryObjects();
  if ( elements == null ) {
    try {
      return getRepository().getJobAndTransformationObjects( repositoryDirectoryInterface.getObjectId(), false );
    } catch ( KettleException ke ) {
      ke.printStackTrace();
    }
  } else {
    return elements;
  }
  return Collections.emptyList();
}
 
Example 18
Source File: DatabaseDialogHarness.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public static void main( String[] args ) {

    try {
      KettleEnvironment.init();
    } catch ( KettleException e ) {
      e.printStackTrace();
      System.exit( 1 );
    }
    DatabaseDialogHarness harness = new DatabaseDialogHarness();
    harness.showDialog();
  }
 
Example 19
Source File: UserRoleLookupCache.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private IUser createUserInfo( String user ) {
  IUser userInfo = null;
  try {
    userInfo = this.rsm.constructUser();
    userInfo.setName( user );
  } catch ( KettleException e ) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  }
  return userInfo;
}
 
Example 20
Source File: PurRepositorySecurityProvider.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public boolean allowsVersionComments( String fullPath ) {
  FileVersioningConfiguration versioningConfiguration;
  try {
    versioningConfiguration = callVersioningService( fullPath );
  } catch ( KettleException e ) {
    e.printStackTrace();
    return false;
  }
  return versioningConfiguration.isVersionCommentEnabled();
}