Java Code Examples for org.pentaho.di.i18n.BaseMessages

The following examples show how to use org.pentaho.di.i18n.BaseMessages. 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: pentaho-kettle   Source File: JobEntryEvalTableContent.java    License: Apache License 2.0 6 votes vote down vote up
public void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_job ) throws KettleException {
  try {
    rep.saveDatabaseMetaJobEntryAttribute( id_job, getObjectId(), "connection", "id_database", connection );

    rep.saveJobEntryAttribute( id_job, getObjectId(), "schemaname", schemaname );
    rep.saveJobEntryAttribute( id_job, getObjectId(), "tablename", tablename );
    rep.saveJobEntryAttribute(
      id_job, getObjectId(), "success_condition", getSuccessConditionCode( successCondition ) );
    rep.saveJobEntryAttribute( id_job, getObjectId(), "limit", limit );
    rep.saveJobEntryAttribute( id_job, getObjectId(), "custom_sql", customSQL );
    rep.saveJobEntryAttribute( id_job, getObjectId(), "is_custom_sql", useCustomSQL );
    rep.saveJobEntryAttribute( id_job, getObjectId(), "is_usevars", useVars );
    rep.saveJobEntryAttribute( id_job, getObjectId(), "add_rows_result", addRowsResult );
    rep.saveJobEntryAttribute( id_job, getObjectId(), "clear_result_rows", clearResultList );
  } catch ( KettleDatabaseException dbe ) {
    throw new KettleException( BaseMessages.getString( PKG, "JobEntryEvalTableContent.UnableSaveRep", ""
      + id_job ), dbe );
  }
}
 
Example 2
Source Project: pentaho-kettle   Source File: GetJobImageServletTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testGetJobImageServletByWrongJobName() throws Exception {
  Job job = buildJob();

  doReturn( GetJobImageServlet.CONTEXT_PATH ).when( mockHttpServletRequest ).getContextPath( );
  doReturn( "wrong" ).when( mockHttpServletRequest ).getParameter( "name" );
  doReturn( USE_XML ).when( mockHttpServletRequest ).getParameter( "xml" );

  jobMap.addJob( JOB_NAME, JOB_ID, job, null );

  StringWriter out = mockWriter();

  spyGetJobImageServlet.doGet( mockHttpServletRequest, spyHttpServletResponse );

  String message = BaseMessages.getString( PKG, "GetJobImageServlet.Error.CoundNotFindJob", "wrong", "null" );
  assertTrue( out.toString().contains( Encode.forHtml( message ) ) );
}
 
Example 3
Source Project: pentaho-kettle   Source File: ConfigurationDialog.java    License: Apache License 2.0 6 votes vote down vote up
protected void mainLayout( Class<?> PKG, String prefix, Image img ) {
  display = parent.getDisplay();
  shell = new Shell( parent, SWT.DIALOG_TRIM | SWT.MIN | SWT.APPLICATION_MODAL | SWT.RESIZE | SWT.MAX );
  props.setLook( shell );
  shell.setImage( img );
  shell.setLayout( new FormLayout() );
  shell.setText( BaseMessages.getString( PKG, prefix + ".Shell.Title" ) );

  scContainer = new ScrolledComposite( shell, SWT.NONE | SWT.H_SCROLL | SWT.V_SCROLL );
  scContainer.setLayout( new FormLayout() );
  FormData fd = new FormData();
  fd.top = new FormAttachment( 0, Const.FORM_MARGIN );
  fd.bottom = new FormAttachment( 100, -Const.FORM_MARGIN );
  fd.left = new FormAttachment( 0, Const.FORM_MARGIN );
  fd.right = new FormAttachment( 100, -Const.FORM_MARGIN );
  scContainer.setLayoutData( fd );
  scContainer.setExpandHorizontal( true );
  scContainer.setExpandVertical( true );
  cContainer = new Composite( scContainer, SWT.NONE );
  scContainer.setContent( cContainer );
  cContainer.setLayout( new FormLayout() );
  cContainer.setBackground( shell.getBackground() );
  cContainer.setParent( scContainer );
}
 
Example 4
Source Project: pentaho-kettle   Source File: SetVariableMeta.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 {
    for ( int i = 0; i < fieldName.length; i++ ) {
      rep.saveStepAttribute( id_transformation, id_step, i, "field_name", Utils.isEmpty( fieldName[i] )
        ? "" : fieldName[i] );
      rep.saveStepAttribute( id_transformation, id_step, i, "variable_name", variableName[i] );
      rep.saveStepAttribute(
        id_transformation, id_step, i, "variable_type", getVariableTypeCode( variableType[i] ) );
      rep.saveStepAttribute( id_transformation, id_step, i, "default_value", defaultValue[i] );
    }

    rep.saveStepAttribute( id_transformation, id_step, 0, "use_formatting", usingFormatting );
  } catch ( Exception e ) {
    throw new KettleException( BaseMessages.getString(
      PKG, "SetVariableMeta.RuntimeError.UnableToSaveRepository.SETVARIABLE0006", "" + id_step ), e );
  }

}
 
Example 5
Source Project: pentaho-kettle   Source File: ExecuteJobServletTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testExecuteJobServletTestCantFindRepository() throws ServletException, IOException {
  doReturn( ExecuteJobServlet.CONTEXT_PATH ).when( mockHttpServletRequest ).getContextPath();
  doReturn( "Unknown" ).when( mockHttpServletRequest ).getParameter( "rep" );
  doReturn( AUTHORIZED_USER ).when( mockHttpServletRequest ).getParameter( "user" );
  doReturn( PASSWORD ).when( mockHttpServletRequest ).getParameter( "pass" );
  doReturn( JOB_NAME ).when( mockHttpServletRequest ).getParameter( "job" );
  doReturn( LEVEL ).when( mockHttpServletRequest ).getParameter( "level" );

  PowerMockito.mockStatic( Encr.class );
  when( Encr.decryptPasswordOptionallyEncrypted( PASSWORD ) ).thenReturn( PASSWORD );

  KettleLogStore.init();

  StringWriter out = mockWriter();
  spyExecuteJobServlet.doGet( mockHttpServletRequest, spyHttpServletResponse );

  String message = BaseMessages.getString( PKG, "ExecuteJobServlet.Error.UnableToFindRepository", "Unknown" );
  assertTrue( out.toString().contains( message ) );
}
 
Example 6
Source Project: pentaho-kettle   Source File: DimensionLookup.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void dispose( StepMetaInterface smi, StepDataInterface sdi ) {
  meta = (DimensionLookupMeta) smi;
  data = (DimensionLookupData) sdi;
  if ( data.db != null ) {
    try {
      if ( !data.db.isAutoCommit() ) {
        if ( getErrors() == 0 ) {
          data.db.commit();
        } else {
          data.db.rollback();
        }
      }
    } catch ( KettleDatabaseException e ) {
      logError( BaseMessages.getString( PKG, "DimensionLookup.Log.ErrorOccurredInProcessing" ) + e.getMessage() );
    } finally {
      data.db.disconnect();
    }
  }
  super.dispose( smi, sdi );
}
 
Example 7
Source Project: pentaho-kettle   Source File: WebServiceAvailableDialog.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Copy information from the meta-data input to the dialog fields.
 */
public void getData() {
  if ( isDebug() ) {
    logDebug( BaseMessages.getString( PKG, "WebServiceAvailableDialog.Log.GettingKeyInfo" ) );
  }

  if ( input.getURLField() != null ) {
    wURL.setText( input.getURLField() );
  }
  if ( input.getConnectTimeOut() != null ) {
    wConnectTimeOut.setText( input.getConnectTimeOut() );
  }
  if ( input.getReadTimeOut() != null ) {
    wReadTimeOut.setText( input.getReadTimeOut() );
  }
  if ( input.getResultFieldName() != null ) {
    wResult.setText( input.getResultFieldName() );
  }

  wStepname.selectAll();
  wStepname.setFocus();
}
 
Example 8
Source Project: pentaho-kettle   Source File: GetPreviousRowFieldDialog.java    License: Apache License 2.0 6 votes vote down vote up
private void get() {
  try {
    RowMetaInterface r = transMeta.getPrevStepFields( stepname );
    if ( r != null ) {
      TableItemInsertListener listener = new TableItemInsertListener() {
        public boolean tableItemInserted( TableItem tableItem, ValueMetaInterface v ) {
          return true;
        }
      };

      BaseStepDialog.getFieldsFromPrevious( r, wFields, 1, new int[] { 1 }, new int[] {}, -1, -1, listener );

    }
  } catch ( KettleException ke ) {
    new ErrorDialog( shell, BaseMessages.getString(
      PKG, "GetPreviousRowFieldDialog.FailedToGetFields.DialogTitle" ), BaseMessages.getString(
      PKG, "GetPreviousRowFieldDialog.FailedToGetFields.DialogMessage" ), ke );
  }
}
 
Example 9
Source Project: pentaho-kettle   Source File: RssInputDialog.java    License: Apache License 2.0 6 votes vote down vote up
private void setURLPreviousField() {
  try {

    wUrlField.removeAll();

    RowMetaInterface r = transMeta.getPrevStepFields( stepname );
    if ( r != null ) {
      r.getFieldNames();

      for ( int i = 0; i < r.getFieldNames().length; i++ ) {
        wUrlField.add( r.getFieldNames()[i] );

      }
    }

  } catch ( KettleException ke ) {
    new ErrorDialog(
      shell, BaseMessages.getString( PKG, "RssInputDialog.FailedToGetFields.DialogTitle" ), BaseMessages
        .getString( PKG, "RssInputDialog.FailedToGetFields.DialogMessage" ), ke );
  }
}
 
Example 10
Source Project: pentaho-kettle   Source File: CreditCardValidatorDialog.java    License: Apache License 2.0 6 votes vote down vote up
private void get() {
  if ( !gotPreviousFields ) {
    try {
      String columnName = wFieldName.getText();
      wFieldName.removeAll();
      RowMetaInterface r = transMeta.getPrevStepFields( stepname );
      if ( r != null ) {
        r.getFieldNames();

        for ( int i = 0; i < r.getFieldNames().length; i++ ) {
          wFieldName.add( r.getFieldNames()[i] );
        }
      }
      wFieldName.setText( columnName );
      gotPreviousFields = true;
    } catch ( KettleException ke ) {
      new ErrorDialog( shell,
        BaseMessages.getString( PKG, "CreditCardValidatorDialog.FailedToGetFields.DialogTitle" ),
        BaseMessages.getString( PKG, "CreditCardValidatorDialog.FailedToGetFields.DialogMessage" ), ke );
    }
  }
}
 
Example 11
Source Project: pentaho-kettle   Source File: ChangeFileEncodingMeta.java    License: Apache License 2.0 6 votes vote down vote up
public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases )
  throws KettleException {
  try {
    filenamefield = rep.getStepAttributeString( id_step, "filenamefield" );
    targetfilenamefield = rep.getStepAttributeString( id_step, "targetfilenamefield" );
    sourceencoding = rep.getStepAttributeString( id_step, "sourceencoding" );
    targetencoding = rep.getStepAttributeString( id_step, "targetencoding" );

    addsourceresultfilenames = rep.getStepAttributeBoolean( id_step, "addsourceresultfilenames" );
    addtargetresultfilenames = rep.getStepAttributeBoolean( id_step, "addtargetresultfilenames" );
    createparentfolder = rep.getStepAttributeBoolean( id_step, "createparentfolder" );

  } catch ( Exception e ) {
    throw new KettleException(
        BaseMessages.getString( PKG, "ChangeFileEncodingMeta.Exception.UnexpectedErrorReadingStepInfo" ), e );
  }
}
 
Example 12
Source Project: pentaho-kettle   Source File: SpoonPartitionsDelegate.java    License: Apache License 2.0 6 votes vote down vote up
public void delPartitionSchema( TransMeta transMeta, PartitionSchema partitionSchema ) {
  try {
    int idx = transMeta.getPartitionSchemas().indexOf( partitionSchema );
    transMeta.getPartitionSchemas().remove( idx );

    if ( spoon.rep != null && partitionSchema.getObjectId() != null ) {
      // remove the partition schema from the repository too...
      spoon.rep.deletePartitionSchema( partitionSchema.getObjectId() );
      if ( sharedObjectSyncUtil != null ) {
        sharedObjectSyncUtil.deletePartitionSchema( partitionSchema );
      }
    }
    refreshTree();
  } catch ( KettleException e ) {
    new ErrorDialog(
      spoon.getShell(), BaseMessages.getString( PKG, "Spoon.Dialog.ErrorDeletingClusterSchema.Title" ), BaseMessages
        .getString( PKG, "Spoon.Dialog.ErrorDeletingClusterSchema.Message" ), e );
  }
}
 
Example 13
Source Project: pentaho-kettle   Source File: JobEntryWaitForFileDialog.java    License: Apache License 2.0 6 votes vote down vote up
private void ok() {
  if ( Utils.isEmpty( wName.getText() ) ) {
    MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR );
    mb.setText( BaseMessages.getString( PKG, "System.StepJobEntryNameMissing.Title" ) );
    mb.setMessage( BaseMessages.getString( PKG, "System.JobEntryNameMissing.Msg" ) );
    mb.open();
    return;
  }
  jobEntry.setName( wName.getText() );
  jobEntry.setFilename( wFilename.getText() );
  jobEntry.setMaximumTimeout( wMaximumTimeout.getText() );
  jobEntry.setCheckCycleTime( wCheckCycleTime.getText() );
  jobEntry.setSuccessOnTimeout( wSuccesOnTimeout.getSelection() );
  jobEntry.setFileSizeCheck( wFileSizeCheck.getSelection() );
  jobEntry.setAddFilenameToResult( wAddFilenameResult.getSelection() );
  dispose();
}
 
Example 14
Source Project: pentaho-kettle   Source File: GetFieldsSampleDataDialog.java    License: Apache License 2.0 6 votes vote down vote up
protected void handleOk( final int samples ) {
  if ( samples >= 0 ) {
    String message = parentDialog.loadFields( parentDialog.getPopulatedMeta(), samples, reloadAllFields );
    if ( wCheckbox != null && wCheckbox.getSelection() ) {
      if ( StringUtils.isNotBlank( message ) ) {
        final EnterTextDialog etd =
          new EnterTextDialog( parentDialog.getShell(),
            BaseMessages.getString( PKG, "System.GetFields.ScanResults.DialogTitle" ),
            BaseMessages.getString( PKG, "System.GetFields.ScanResults.DialogMessage" ), message, true );
        etd.setReadOnly();
        etd.setModal();
        etd.open();
      } else {
        final Dialog errorDlg = new SimpleMessageDialog( parentDialog.getShell(),
          BaseMessages.getString( PKG, "System.Dialog.Error.Title" ),
          BaseMessages.getString( PKG, "System.GetFields.ScanResults.Error.Message" ), MessageDialog.ERROR );
        errorDlg.open();
      }
    }
  }
}
 
Example 15
/**
 * applyOnObjectOnly is called to save acl for a file object only
 * 
 * @param roList
 * @param hideDialog
 */
private void applyOnObjectOnly( List<UIDatabaseConnection> roList, boolean hideDialog ) {
  try {
    UIDatabaseConnection rd = roList.get( 0 );
    if ( rd instanceof IAclObject ) {
      ( (IAclObject) rd ).setAcls( viewAclsModel );
    } else {
      throw new IllegalStateException( BaseMessages.getString( PKG, "PermissionsController.NoAclSupport" ) ); //$NON-NLS-1$
    }
    viewAclsModel.setModelDirty( false );
    messageBox.setTitle( BaseMessages.getString( PKG, "Dialog.Success" ) ); //$NON-NLS-1$
    messageBox.setAcceptLabel( BaseMessages.getString( PKG, "Dialog.Ok" ) ); //$NON-NLS-1$
    messageBox.setMessage( BaseMessages.getString( PKG, "PermissionsController.PermissionAppliedSuccessfully" ) ); //$NON-NLS-1$
    messageBox.open();
  } catch ( AccessDeniedException ade ) {
    if ( mainController == null || !mainController.handleLostRepository( ade ) ) {
      messageBox.setTitle( BaseMessages.getString( PKG, "Dialog.Error" ) ); //$NON-NLS-1$
      messageBox.setAcceptLabel( BaseMessages.getString( PKG, "Dialog.Ok" ) ); //$NON-NLS-1$
      messageBox.setMessage( ade.getLocalizedMessage() );
      messageBox.open();
    }
  }
}
 
Example 16
Source Project: pentaho-kettle   Source File: CubeInputMeta.java    License: Apache License 2.0 6 votes vote down vote up
@Override public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases )
  throws KettleException {
  try {
    filename = rep.getStepAttributeString( id_step, "file_name" );
    try {
      rowLimit = rep.getStepAttributeString( id_step, "limit" );
    } catch ( KettleException readOldAttributeType ) {
      // PDI-12897
      rowLimit = String.valueOf( rep.getStepAttributeInteger( id_step, "limit" ) );
    }
    addfilenameresult = rep.getStepAttributeBoolean( id_step, "addfilenameresult" );

  } catch ( Exception e ) {
    throw new KettleException( BaseMessages.getString(
      PKG, "CubeInputMeta.Exception.UnexpectedErrorWhileReadingStepInfo" ), e );
  }
}
 
Example 17
Source Project: pentaho-kettle   Source File: PaloDimOutputDialog.java    License: Apache License 2.0 6 votes vote down vote up
private void fillPreviousFieldTableViewColumn() throws KettleException {
  RowMetaInterface r = transMeta.getPrevStepFields( stepname );
  if ( r != null ) {
    String[] fieldNames = r.getFieldNames();
    colinf[2] = new ColumnInfo( getLocalizedColumn( 2 ), ColumnInfo.COLUMN_TYPE_CCOMBO, fieldNames, true );

    /* Get all number fields to include in the consolidation factor column */
    String[] fieldTypes = r.getFieldNamesAndTypes( 0 );
    ArrayList<String> intFields = new ArrayList<String>();
    intFields.add( BaseMessages.getString( PKG, "PaloDimOutputDialog.ConsolidationFactorDefault" ) );
    for ( int i = 0; i < fieldNames.length; i++ ) {
      if ( fieldTypes[i].toLowerCase().indexOf( "integer" ) >= 0
        || fieldTypes[i].toLowerCase().indexOf( "number" ) > 0 ) {
        intFields.add( fieldNames[i] );
      }
    }

    String[] fieldNamesDefault = intFields.toArray( new String[intFields.size()] );
    colinf[3] = new ColumnInfo( getLocalizedColumn( 3 ), ColumnInfo.COLUMN_TYPE_CCOMBO, fieldNamesDefault, true );
  }
}
 
Example 18
Source Project: pentaho-kettle   Source File: PaloCellInputDialog.java    License: Apache License 2.0 6 votes vote down vote up
private void doSelectConnection( boolean clearCurrentData ) {
  try {
    if ( clearCurrentData ) {
      tableViewFields.table.removeAll();
      comboCube.removeAll();
    }
    if ( addConnectionLine.getText() != null ) {
      DatabaseMeta dbMeta = transMeta.findDatabase( addConnectionLine.getText() );
      if ( dbMeta != null ) {
        PaloCellInputData data = new PaloCellInputData( dbMeta );
        data.helper.connect();
        List<String> cubes = data.helper.getCubesNames();
        Collections.sort( cubes, new PaloNameComparator() );
        for ( String cubeName : cubes ) {
          if ( comboCube.indexOf( cubeName ) == -1 ) {
            comboCube.add( cubeName );
          }
        }
        data.helper.disconnect();
      }
    }
  } catch ( Exception ex ) {
    new ErrorDialog( shell, BaseMessages.getString( PKG, "PaloCellInputDialog.RetreiveCubesErrorTitle" ),
      BaseMessages.getString( PKG, "PaloCellInputDialog.RetreiveCubesError" ), ex );
  }
}
 
Example 19
Source Project: pentaho-kettle   Source File: DimensionLookupMeta.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public RowMetaInterface getTableFields() {
  RowMetaInterface fields = null;
  if ( databaseMeta != null ) {
    Database db = createDatabaseObject();
    try {
      db.connect();
      fields = db.getTableFieldsMeta( schemaName, tableName );
    } catch ( KettleDatabaseException dbe ) {
      logError( BaseMessages.getString( PKG, "DimensionLookupMeta.Log.DatabaseErrorOccurred" ) + dbe.getMessage() );
    } finally {
      db.disconnect();
    }
  }
  return fields;
}
 
Example 20
Source Project: pentaho-kettle   Source File: ProcessFilesMeta.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ) throws KettleException {
  try {
    rep.saveStepAttribute( id_transformation, id_step, "sourcefilenamefield", sourcefilenamefield );
    rep.saveStepAttribute( id_transformation, id_step, "targetfilenamefield", targetfilenamefield );
    rep.saveStepAttribute( id_transformation, id_step, "operation_type", getOperationTypeCode( operationType ) );
    rep.saveStepAttribute( id_transformation, id_step, "addresultfilenames", addresultfilenames );
    rep.saveStepAttribute( id_transformation, id_step, "overwritetargetfile", overwritetargetfile );
    rep.saveStepAttribute( id_transformation, id_step, "createparentfolder", createparentfolder );
    rep.saveStepAttribute( id_transformation, id_step, "simulate", simulate );

  } catch ( Exception e ) {
    throw new KettleException( BaseMessages.getString( PKG, "ProcessFilesMeta.Exception.UnableToSaveStepInfo" )
      + id_step, e );
  }
}
 
Example 21
Source Project: pentaho-kettle   Source File: SpoonSlave.java    License: Apache License 2.0 6 votes vote down vote up
protected void pause() {
  TreeEntry treeEntry = getTreeEntry();
  if ( treeEntry == null ) {
    return;
  }

  if ( treeEntry.isTransformation() ) {
    // Transformation
    try {
      WebResult webResult = slaveServer.pauseResumeTransformation( treeEntry.name, treeEntry.id );
      if ( !WebResult.STRING_OK.equalsIgnoreCase( webResult.getResult() ) ) {
        EnterTextDialog dialog =
          new EnterTextDialog( shell,
            BaseMessages.getString( PKG, "SpoonSlave.ErrorPausingOrResumingTrans.Title" ),
            BaseMessages.getString( PKG, "SpoonSlave.ErrorPausingOrResumingTrans.Message" ),
            webResult.getMessage() );
        dialog.setReadOnly();
        dialog.open();
      }
    } catch ( Exception e ) {
      new ErrorDialog( shell,
        BaseMessages.getString( PKG, "SpoonSlave.ErrorPausingOrResumingTrans.Title" ),
        BaseMessages.getString( PKG, "SpoonSlave.ErrorPausingOrResumingTrans.Message" ), e );
    }
  }
}
 
Example 22
Source Project: pentaho-kettle   Source File: GetXMLData.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressWarnings( "unchecked" )
private boolean applyXPath() {
  try {
    XPath xpath = data.document.createXPath( data.PathValue );
    if ( meta.isNamespaceAware() ) {
      xpath = data.document.createXPath( addNSPrefix( data.PathValue, data.PathValue ) );
      xpath.setNamespaceURIs( data.NAMESPACE );
    }
    // get nodes list
    data.an = xpath.selectNodes( data.document );
    data.nodesize = data.an.size();
    data.nodenr = 0;
  } catch ( Exception e ) {
    logError( BaseMessages.getString( PKG, "GetXMLData.Log.ErrorApplyXPath", e.getMessage() ) );
    return false;
  }
  return true;
}
 
Example 23
Source Project: pentaho-kettle   Source File: CsvInputDialog.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public InputStream getInputStream( final CsvInputAwareMeta meta ) {
  InputStream inputStream = null;
  try {
    FileObject fileObject = meta.getHeaderFileObject( getTransMeta() );
    if ( !( fileObject instanceof LocalFile ) ) {
      // We can only use NIO on local files at the moment, so that's what we limit ourselves to.
      throw new KettleException( BaseMessages.getString( "FileInputDialog.Log.OnlyLocalFilesAreSupported" ) );
    }

    inputStream = KettleVFS.getInputStream( fileObject );
  } catch ( final Exception e ) {
    logError( BaseMessages.getString( "FileInputDialog.ErrorGettingFileDesc.DialogMessage" ), e );
  }
  return inputStream;
}
 
Example 24
Source Project: pentaho-kettle   Source File: PerformanceLogTable.java    License: Apache License 2.0 6 votes vote down vote up
public static PerformanceLogTable getDefault( VariableSpace space, HasDatabasesInterface databasesInterface ) {
  PerformanceLogTable table = new PerformanceLogTable( space, databasesInterface );

  //CHECKSTYLE:LineLength:OFF
  table.fields.add( new LogTableField( ID.ID_BATCH.id, true, false, "ID_BATCH", BaseMessages.getString( PKG, "PerformanceLogTable.FieldName.BatchID" ), BaseMessages.getString( PKG, "PerformanceLogTable.FieldDescription.BatchID" ), ValueMetaInterface.TYPE_INTEGER, 8 ) );
  table.fields.add( new LogTableField( ID.SEQ_NR.id, true, false, "SEQ_NR", BaseMessages.getString( PKG, "PerformanceLogTable.FieldName.SeqNr" ), BaseMessages.getString( PKG, "PerformanceLogTable.FieldDescription.SeqNr" ), ValueMetaInterface.TYPE_INTEGER, 8 ) );
  table.fields.add( new LogTableField( ID.LOGDATE.id, true, false, "LOGDATE", BaseMessages.getString( PKG, "PerformanceLogTable.FieldName.LogDate" ), BaseMessages.getString( PKG, "PerformanceLogTable.FieldDescription.LogDate" ), ValueMetaInterface.TYPE_DATE, -1 ) );
  table.fields.add( new LogTableField( ID.TRANSNAME.id, true, false, "TRANSNAME", BaseMessages.getString( PKG, "PerformanceLogTable.FieldName.TransName" ), BaseMessages.getString( PKG, "PerformanceLogTable.FieldDescription.TransName" ), ValueMetaInterface.TYPE_STRING, 255 ) );
  table.fields.add( new LogTableField( ID.STEPNAME.id, true, false, "STEPNAME", BaseMessages.getString( PKG, "PerformanceLogTable.FieldName.StepName" ), BaseMessages.getString( PKG, "PerformanceLogTable.FieldDescription.StepName" ), ValueMetaInterface.TYPE_STRING, 255 ) );
  table.fields.add( new LogTableField( ID.STEP_COPY.id, true, false, "STEP_COPY", BaseMessages.getString( PKG, "PerformanceLogTable.FieldName.StepCopy" ), BaseMessages.getString( PKG, "PerformanceLogTable.FieldDescription.StepCopy" ), ValueMetaInterface.TYPE_INTEGER, 8 ) );
  table.fields.add( new LogTableField( ID.LINES_READ.id, true, false, "LINES_READ", BaseMessages.getString( PKG, "PerformanceLogTable.FieldName.LinesRead" ), BaseMessages.getString( PKG, "PerformanceLogTable.FieldDescription.LinesRead" ), ValueMetaInterface.TYPE_INTEGER, 18 ) );
  table.fields.add( new LogTableField( ID.LINES_WRITTEN.id, true, false, "LINES_WRITTEN", BaseMessages.getString( PKG, "PerformanceLogTable.FieldName.LinesWritten" ), BaseMessages.getString( PKG, "PerformanceLogTable.FieldDescription.LinesWritten" ), ValueMetaInterface.TYPE_INTEGER, 18 ) );
  table.fields.add( new LogTableField( ID.LINES_UPDATED.id, true, false, "LINES_UPDATED", BaseMessages.getString( PKG, "PerformanceLogTable.FieldName.LinesUpdated" ), BaseMessages.getString( PKG, "PerformanceLogTable.FieldDescription.LinesUpdated" ), ValueMetaInterface.TYPE_INTEGER, 18 ) );
  table.fields.add( new LogTableField( ID.LINES_INPUT.id, true, false, "LINES_INPUT", BaseMessages.getString( PKG, "PerformanceLogTable.FieldName.LinesInput" ), BaseMessages.getString( PKG, "PerformanceLogTable.FieldDescription.LinesInput" ), ValueMetaInterface.TYPE_INTEGER, 18 ) );
  table.fields.add( new LogTableField( ID.LINES_OUTPUT.id, true, false, "LINES_OUTPUT", BaseMessages.getString( PKG, "PerformanceLogTable.FieldName.LinesOutput" ), BaseMessages.getString( PKG, "PerformanceLogTable.FieldDescription.LinesOutput" ), ValueMetaInterface.TYPE_INTEGER, 18 ) );
  table.fields.add( new LogTableField( ID.LINES_REJECTED.id, true, false, "LINES_REJECTED", BaseMessages.getString( PKG, "PerformanceLogTable.FieldName.LinesRejected" ), BaseMessages.getString( PKG, "PerformanceLogTable.FieldDescription.LinesRejected" ), ValueMetaInterface.TYPE_INTEGER, 18 ) );
  table.fields.add( new LogTableField( ID.ERRORS.id, true, false, "ERRORS", BaseMessages.getString( PKG, "PerformanceLogTable.FieldName.Errors" ), BaseMessages.getString( PKG, "PerformanceLogTable.FieldDescription.Errors" ), ValueMetaInterface.TYPE_INTEGER, 18 ) );
  table.fields.add( new LogTableField( ID.INPUT_BUFFER_ROWS.id, true, false, "INPUT_BUFFER_ROWS", BaseMessages.getString( PKG, "PerformanceLogTable.FieldName.InputBufferRows" ), BaseMessages.getString( PKG, "PerformanceLogTable.FieldDescription.InputBufferRows" ), ValueMetaInterface.TYPE_INTEGER, 18 ) );
  table.fields.add( new LogTableField( ID.OUTPUT_BUFFER_ROWS.id, true, false, "OUTPUT_BUFFER_ROWS", BaseMessages.getString( PKG, "PerformanceLogTable.FieldName.OutputBufferRows" ), BaseMessages.getString( PKG, "PerformanceLogTable.FieldDescription.OutputBufferRows" ), ValueMetaInterface.TYPE_INTEGER, 18 ) );

  table.findField( ID.ID_BATCH.id ).setKey( true );
  table.findField( ID.LOGDATE.id ).setLogDateField( true );
  table.findField( ID.TRANSNAME.id ).setNameField( true );

  return table;
}
 
Example 25
Source Project: pentaho-kettle   Source File: EESecurityController.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * addRole method is called when user has click ok on a add role dialog. The method add the role
 * 
 * @throws Exception
 */

private void addRole() {
  if ( service != null ) {
    try {
      if ( securityRole.getName().isEmpty() ) {
        throw new Exception( BaseMessages.getString( PKG, "CantCreateRoleDialog.RoleNameIsMandatory" ) );
      }
      IRole role = securityRole.getRole( (IRoleSupportSecurityManager) service );
      ( (IRoleSupportSecurityManager) service ).createRole( role );
      eeSecurity.addRole( UIEEObjectRegistery.getInstance().constructUIRepositoryRole( role ) );
      roleDialog.hide();
    } catch ( Throwable th ) {
      if ( mainController == null || !mainController.handleLostRepository( th ) ) {
        messageBox.setTitle( BaseMessages.getString( PKG, "CantCreateRoleDialog.Title" ) );
        messageBox.setAcceptLabel( BaseMessages.getString( PKG, "Dialog.Close" ) );
        messageBox
            .setMessage( BaseMessages.getString( PKG, "CantCreateRoleDialog.Message", th.getLocalizedMessage() ) );
        messageBox.open();
      }
    }
  }
}
 
Example 26
Source Project: pentaho-kettle   Source File: DynamicSQLRowMeta.java    License: Apache License 2.0 6 votes vote down vote up
public void analyseImpact( List<DatabaseImpact> impact, TransMeta transMeta, StepMeta stepMeta,
  RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, Repository repository,
  IMetaStore metaStore ) throws KettleStepException {

  RowMetaInterface out = prev.clone();
  getFields( out, stepMeta.getName(), new RowMetaInterface[] { info, }, null, transMeta, repository, metaStore );
  if ( out != null ) {
    for ( int i = 0; i < out.size(); i++ ) {
      ValueMetaInterface outvalue = out.getValueMeta( i );
      DatabaseImpact di =
        new DatabaseImpact(
          DatabaseImpact.TYPE_IMPACT_READ, transMeta.getName(), stepMeta.getName(), databaseMeta
            .getDatabaseName(), "", outvalue.getName(), outvalue.getName(), stepMeta.getName(), sql,
          BaseMessages.getString( PKG, "DynamicSQLRowMeta.DatabaseImpact.Title" ) );
      impact.add( di );

    }
  }
}
 
Example 27
Source Project: pentaho-kettle   Source File: SalesforceInputDialog.java    License: Apache License 2.0 5 votes vote down vote up
void addFieldToTable( String fieldLabel, String fieldName, boolean fieldIdIsLookup, String fieldType,
                      String fieldLength, String fieldPrecision ) {
  TableItem item = new TableItem( wFields.table, SWT.NONE );
  item.setText( 1, fieldLabel );
  item.setText( 2, fieldName );
  item.setText( 3, fieldIdIsLookup ? BaseMessages.getString( PKG, "System.Combo.Yes" ) : BaseMessages.getString(
    PKG, "System.Combo.No" ) );

  // Try to get the Type
  if ( fieldType.equals( "boolean" ) ) {
    item.setText( 4, "Boolean" );
  } else if ( fieldType.equals( "date" ) ) {
    item.setText( 4, "Date" );
    item.setText( 5, DEFAULT_DATE_FORMAT );
  } else if ( fieldType.equals( "datetime" ) ) {
    item.setText( 4, "Date" );
    item.setText( 5, DEFAULT_DATE_TIME_FORMAT );
  } else if ( fieldType.equals( "double" ) ) {
    item.setText( 4, "Number" );
  } else if ( fieldType.equals( "int" ) ) {
    item.setText( 4, "Integer" );
  } else if ( fieldType.equals( "base64" ) ) {
    item.setText( 4, "Binary" );
  } else {
    item.setText( 4, "String" );
  }

  if ( fieldLength != null ) {
    item.setText( 6, fieldLength );
  }
  // Get precision
  if ( fieldPrecision != null ) {
    item.setText( 7, fieldPrecision );
  }
}
 
Example 28
Source Project: pentaho-kettle   Source File: CloneRowMeta.java    License: Apache License 2.0 5 votes vote down vote up
private void readData( Node stepnode ) throws KettleXMLException {
  try {
    nrclones = XMLHandler.getTagValue( stepnode, "nrclones" );
    addcloneflag = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "addcloneflag" ) );
    cloneflagfield = XMLHandler.getTagValue( stepnode, "cloneflagfield" );
    nrcloneinfield = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "nrcloneinfield" ) );
    nrclonefield = XMLHandler.getTagValue( stepnode, "nrclonefield" );
    addclonenum = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "addclonenum" ) );
    clonenumfield = XMLHandler.getTagValue( stepnode, "clonenumfield" );

  } catch ( Exception e ) {
    throw new KettleXMLException(
      BaseMessages.getString( PKG, "CloneRowMeta.Exception.UnableToReadStepInfo" ), e );
  }
}
 
Example 29
Source Project: pentaho-kettle   Source File: TeraFastDialog.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @param factory
 *          factory to use.
 */
protected void buildSessionsLine( final PluginWidgetFactory factory ) {
  final Control topControl = this.wDataFile;

  this.wlSessions = factory.createRightLabel( BaseMessages.getString( PKG, "TeraFastDialog.Sessions.Label" ) );
  this.props.setLook( this.wlSessions );
  this.wlSessions.setLayoutData( factory.createLabelLayoutData( topControl ) );

  this.wSessions = factory.createSingleTextVarLeft();
  this.props.setLook( this.wSessions );
  this.wSessions.setLayoutData( factory.createControlLayoutData( topControl ) );
}
 
Example 30
Source Project: pentaho-kettle   Source File: JobEntrySuccessDialog.java    License: Apache License 2.0 5 votes vote down vote up
private void ok() {
  if ( Utils.isEmpty( wName.getText() ) ) {
    MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR );
    mb.setText( BaseMessages.getString( PKG, "System.StepJobEntryNameMissing.Title" ) );
    mb.setMessage( BaseMessages.getString( PKG, "System.JobEntryNameMissing.Msg" ) );
    mb.open();
    return;
  }
  jobEntry.setName( wName.getText() );
  dispose();
}