org.pentaho.di.i18n.BaseMessages Java Examples

The following examples show how to use org.pentaho.di.i18n.BaseMessages. 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: DynamicSQLRowMeta.java    From pentaho-kettle with 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 #2
Source File: DimensionLookup.java    From pentaho-kettle with 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 #3
Source File: JobEntryEvalTableContent.java    From pentaho-kettle with 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 #4
Source File: GetJobImageServletTest.java    From pentaho-kettle with 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 #5
Source File: SetVariableMeta.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 {
    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 #6
Source File: ConfigurationDialog.java    From pentaho-kettle with 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 #7
Source File: ExecuteJobServletTest.java    From pentaho-kettle with 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 #8
Source File: WebServiceAvailableDialog.java    From pentaho-kettle with 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 #9
Source File: GetPreviousRowFieldDialog.java    From pentaho-kettle with 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 #10
Source File: RssInputDialog.java    From pentaho-kettle with 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 #11
Source File: CreditCardValidatorDialog.java    From pentaho-kettle with 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 #12
Source File: SpoonPartitionsDelegate.java    From pentaho-kettle with 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 File: JobEntryWaitForFileDialog.java    From pentaho-kettle with 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 File: ConnectionPermissionsController.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
/**
 * 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 #15
Source File: ChangeFileEncodingMeta.java    From pentaho-kettle with 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 #16
Source File: EESecurityController.java    From pentaho-kettle with 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 #17
Source File: PerformanceLogTable.java    From pentaho-kettle with 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 #18
Source File: CsvInputDialog.java    From pentaho-kettle with 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 #19
Source File: GetXMLData.java    From pentaho-kettle with 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 #20
Source File: SpoonSlave.java    From pentaho-kettle with 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 #21
Source File: ProcessFilesMeta.java    From pentaho-kettle with 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 #22
Source File: DimensionLookupMeta.java    From pentaho-kettle with 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 #23
Source File: PaloCellInputDialog.java    From pentaho-kettle with 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 #24
Source File: PaloDimOutputDialog.java    From pentaho-kettle with 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 #25
Source File: CubeInputMeta.java    From pentaho-kettle with 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 #26
Source File: GetFieldsSampleDataDialog.java    From pentaho-kettle with 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 #27
Source File: MailConnection.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * Set filter on message received date.
 *
 * @param pastDate
 *          messages will be filtered on pastDate
 */
public void setReceivedDateTermGT( Date pastDate ) {
  if ( this.protocol == MailConnectionMeta.PROTOCOL_POP3 ) {
    log.logError( BaseMessages.getString( PKG, "MailConnection.Error.ReceivedDatePOP3Unsupported" ) );
  } else {
    addSearchTerm( new ReceivedDateTerm( ComparisonTerm.GT, pastDate ) );
  }
}
 
Example #28
Source File: AnalyticQueryMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void getFields( RowMetaInterface r, String origin, RowMetaInterface[] info, StepMeta nextStep,
  VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException {
  // re-assemble a new row of metadata
  //
  RowMetaInterface fields = new RowMeta();

  // Add existing values
  fields.addRowMeta( r );

  // add analytic values
  for ( int i = 0; i < number_of_fields; i++ ) {

    int index_of_subject = -1;
    index_of_subject = r.indexOfValue( subjectField[i] );

    // if we found the subjectField in the RowMetaInterface, and we should....
    if ( index_of_subject > -1 ) {
      ValueMetaInterface vmi = r.getValueMeta( index_of_subject ).clone();
      vmi.setOrigin( origin );
      vmi.setName( aggregateField[i] );
      fields.addValueMeta( r.size() + i, vmi );
    } else {
      // we have a condition where the subjectField can't be found from the rowMetaInterface
      StringBuilder sbfieldNames = new StringBuilder();
      String[] fieldNames = r.getFieldNames();
      for ( int j = 0; j < fieldNames.length; j++ ) {
        sbfieldNames.append( "[" + fieldNames[j] + "]" + ( j < fieldNames.length - 1 ? ", " : "" ) );
      }
      throw new KettleStepException( BaseMessages.getString(
        PKG, "AnalyticQueryMeta.Exception.SubjectFieldNotFound", getParentStepMeta().getName(),
        subjectField[i], sbfieldNames.toString() ) );
    }
  }

  r.clear();
  // Add back to Row Meta
  r.addRowMeta( fields );
}
 
Example #29
Source File: InsertUpdateDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void getTableName() {
  DatabaseMeta inf = null;
  // New class: SelectTableDialog
  int connr = wConnection.getSelectionIndex();
  if ( connr >= 0 ) {
    inf = transMeta.getDatabase( connr );
  }

  if ( inf != null ) {
    if ( log.isDebug() ) {
      logDebug( BaseMessages.getString( PKG, "InsertUpdateDialog.Log.LookingAtConnection" ) + inf.toString() );
    }

    DatabaseExplorerDialog std = new DatabaseExplorerDialog( shell, SWT.NONE, inf, transMeta.getDatabases() );
    std.setSelectedSchemaAndTable( wSchema.getText(), wTable.getText() );
    if ( std.open() ) {
      wSchema.setText( Const.NVL( std.getSchemaName(), "" ) );
      wTable.setText( Const.NVL( std.getTableName(), "" ) );
      setTableFieldCombo();
    }
  } else {
    MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR );
    mb.setMessage( BaseMessages.getString( PKG, "InsertUpdateDialog.InvalidConnection.DialogMessage" ) );
    mb.setText( BaseMessages.getString( PKG, "InsertUpdateDialog.InvalidConnection.DialogTitle" ) );
    mb.open();
  }
}
 
Example #30
Source File: RowGeneratorDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void getInfo( RowGeneratorMeta meta ) throws KettleException {
  meta.setRowLimit( wLimit.getText() );
  meta.setNeverEnding( wNeverEnding.getSelection() );
  meta.setIntervalInMs( wInterval.getText() );
  meta.setRowTimeField( wRowTimeField.getText() );
  meta.setLastTimeField( wLastTimeField.getText() );

  int nrfields = wFields.nrNonEmpty();

  meta.allocate( nrfields );

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

    meta.getFieldName()[i] = item.getText( 1 );

    meta.getFieldFormat()[i] = item.getText( 3 );
    String slength = item.getText( 4 );
    String sprec = item.getText( 5 );
    meta.getCurrency()[i] = item.getText( 6 );
    meta.getDecimal()[i] = item.getText( 7 );
    meta.getGroup()[i] = item.getText( 8 );
    meta.isSetEmptyString()[i] =
      BaseMessages.getString( PKG, "System.Combo.Yes" ).equalsIgnoreCase( item.getText( 10 ) );

    meta.getValue()[i] = meta.isSetEmptyString()[i] ? "" : item.getText( 9 );
    meta.getFieldType()[i] = meta.isSetEmptyString()[i] ? "String" : item.getText( 2 );
    meta.getFieldLength()[i] = Const.toInt( slength, -1 );
    meta.getFieldPrecision()[i] = Const.toInt( sprec, -1 );
  }

  // Performs checks...
  /*
   * Commented out verification : if variables are used, this check is a pain!
   *
   * long longLimit = Const.toLong(transMeta.environmentSubstitute( wLimit.getText()), -1L ); if (longLimit<0) { throw
   * new KettleException( BaseMessages.getString(PKG, "RowGeneratorDialog.Wrong.RowLimit.Number") ); }
   */
}