Java Code Examples for org.pentaho.di.core.row.RowMetaInterface#isEmpty()

The following examples show how to use org.pentaho.di.core.row.RowMetaInterface#isEmpty() . 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: DimensionLookupDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
/**
 * Get the fields from the previous step and use them as "update fields". Only get the the fields which are not yet in
 * use as key, or in the field table. Also ignore technical key, version, fromdate, todate.
 */
private void getUpdate() {
  try {
    RowMetaInterface r = transMeta.getPrevStepFields( stepname );
    if ( r != null && !r.isEmpty() ) {
      BaseStepDialog.getFieldsFromPrevious(
        r, wUpIns, 2, new int[] { 1, 2 }, new int[] {}, -1, -1, new TableItemInsertListener() {
          public boolean tableItemInserted( TableItem tableItem, ValueMetaInterface v ) {
            tableItem
              .setText( 3, BaseMessages.getString( PKG, "DimensionLookupDialog.TableItem.Insert.Label" ) );

            int idx = wKey.indexOfString( v.getName(), 2 );
            return idx < 0
              && !v.getName().equalsIgnoreCase( wTk.getText() )
              && !v.getName().equalsIgnoreCase( wVersion.getText() )
              && !v.getName().equalsIgnoreCase( wFromdate.getText() )
              && !v.getName().equalsIgnoreCase( wTodate.getText() );
          }
        } );
    }
  } catch ( KettleException ke ) {
    new ErrorDialog(
      shell, BaseMessages.getString( PKG, "DimensionLookupDialog.FailedToGetFields.DialogTitle" ),
      BaseMessages.getString( PKG, "DimensionLookupDialog.FailedToGetFields.DialogMessage" ), ke );
  }
}
 
Example 2
Source File: OpenERPObjectOutputDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void getKeyFields() {
  try {
    RowMetaInterface r = transMeta.getPrevStepFields( stepname );
    if ( r != null && !r.isEmpty() ) {
      TableItemInsertListener listener = new TableItemInsertListener() {
        public boolean tableItemInserted( TableItem tableItem, ValueMetaInterface v ) {
          tableItem.setText( 2, "=" );
          return true;
        }
      };
      BaseStepDialog.getFieldsFromPrevious( r, tableViewKeyFields, 1, new int[]{ 1, 3 }, new int[]{ }, -1, -1,
        listener );
    }
  } catch ( KettleException ke ) {
    new ErrorDialog( shell, BaseMessages.getString( PKG, "OpenERPObjectOutputDialog.FailedToGetFields.Title" ),
      BaseMessages.getString( PKG, "OpenERPObjectOutputDialog.FailedToGetFields.Message" ), ke );
  }
}
 
Example 3
Source File: DatabaseLookupDialog.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 && !r.isEmpty() ) {
      TableItemInsertListener listener = new TableItemInsertListener() {
        public boolean tableItemInserted( TableItem tableItem, ValueMetaInterface v ) {
          tableItem.setText( 2, "=" );
          return true;
        }
      };
      BaseStepDialog.getFieldsFromPrevious( r, wKey, 1, new int[] { 1, 3 }, new int[] {}, -1, -1, listener );
    }
  } catch ( KettleException ke ) {
    new ErrorDialog(
      shell, BaseMessages.getString( PKG, "DatabaseLookupDialog.GetFieldsFailed.DialogTitle" ), BaseMessages
        .getString( PKG, "DatabaseLookupDialog.GetFieldsFailed.DialogMessage" ), ke );
  }

}
 
Example 4
Source File: DeleteDialog.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 && !r.isEmpty() ) {
      TableItemInsertListener listener = new TableItemInsertListener() {
        public boolean tableItemInserted( TableItem tableItem, ValueMetaInterface v ) {
          tableItem.setText( 2, "=" );
          return true;
        }
      };
      BaseStepDialog.getFieldsFromPrevious( r, wKey, 1, new int[] { 1, 3 }, new int[] {}, -1, -1, listener );
    }
  } catch ( KettleException ke ) {
    new ErrorDialog(
      shell, BaseMessages.getString( PKG, "DeleteDialog.FailedToGetFields.DialogTitle" ), BaseMessages
        .getString( PKG, "DeleteDialog.FailedToGetFields.DialogMessage" ), ke );
  }
}
 
Example 5
Source File: UpdateDialog.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 && !r.isEmpty() ) {
      TableItemInsertListener listener = new TableItemInsertListener() {
        public boolean tableItemInserted( TableItem tableItem, ValueMetaInterface v ) {
          tableItem.setText( 2, "=" );
          return true;
        }
      };
      BaseStepDialog.getFieldsFromPrevious( r, wKey, 1, new int[] { 1, 3 }, new int[] {}, -1, -1, listener );
    }
  } catch ( KettleException ke ) {
    new ErrorDialog(
      shell, BaseMessages.getString( PKG, "UpdateDialog.FailedToGetFields.DialogTitle" ), BaseMessages
        .getString( PKG, "UpdateDialog.FailedToGetFields.DialogMessage" ), ke );
  }
}
 
Example 6
Source File: MemoryGroupByDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void getAgg() {
  try {
    RowMetaInterface r = transMeta.getPrevStepFields( stepname );
    if ( r != null && !r.isEmpty() ) {
      BaseStepDialog.getFieldsFromPrevious( r, wAgg, 1, new int[] { 1, 2 }, new int[] {}, -1, -1, null );
    }
  } catch ( KettleException ke ) {
    new ErrorDialog(
      shell, BaseMessages.getString( PKG, "MemoryGroupByDialog.FailedToGetFields.DialogTitle" ), BaseMessages
        .getString( PKG, "MemoryGroupByDialog.FailedToGetFields.DialogMessage" ), ke );
  }
}
 
Example 7
Source File: RestDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void getHeaders() {
  try {
    RowMetaInterface r = transMeta.getPrevStepFields( stepname );
    if ( r != null && !r.isEmpty() ) {
      BaseStepDialog.getFieldsFromPrevious( r, wFields, 1, new int[] { 1, 2 }, new int[] { 3 }, -1, -1, null );
    }
  } catch ( KettleException ke ) {
    new ErrorDialog(
      shell, BaseMessages.getString( PKG, "RestDialog.FailedToGetHeaders.DialogTitle" ), BaseMessages
        .getString( PKG, "RestDialog.FailedToGetHeaders.DialogMessage" ), ke );
  }

}
 
Example 8
Source File: UniqueRowsByHashSetDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void get() {
  try {
    RowMetaInterface r = transMeta.getPrevStepFields( stepname );
    if ( r != null && !r.isEmpty() ) {
      BaseStepDialog.getFieldsFromPrevious( r, wFields, 1, new int[] { 1 }, new int[] {}, -1, -1, null );
    }
  } catch ( KettleException ke ) {
    new ErrorDialog( shell, BaseMessages.getString(
      PKG, "UniqueRowsByHashSetDialog.FailedToGetFields.DialogTitle" ), BaseMessages.getString(
      PKG, "UniqueRowsByHashSetDialog.FailedToGetFields.DialogMessage" ), ke );
  }
}
 
Example 9
Source File: BaseStepXulDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * Gets fields from previous steps and populate a ComboVar.
 *
 * @param comboVar
 *          the comboVar to populate
 * @param TransMeta
 *          the source transformation
 * @param StepMeta
 *          the source step
 */
public static final void getFieldsFromPrevious( ComboVar comboVar, TransMeta transMeta, StepMeta stepMeta ) {
  String selectedField = null;
  int indexField = -1;
  try {
    RowMetaInterface r = transMeta.getPrevStepFields( stepMeta );
    selectedField = comboVar.getText();
    comboVar.removeAll();

    if ( r != null && !r.isEmpty() ) {
      r.getFieldNames();
      comboVar.setItems( r.getFieldNames() );
      indexField = r.indexOfValue( selectedField );
    }
    // Select value if possible...
    if ( indexField > -1 ) {
      comboVar.select( indexField );
    } else {
      if ( selectedField != null ) {
        comboVar.setText( selectedField );
      }
    }

  } catch ( KettleException ke ) {
    new ErrorDialog( comboVar.getShell(),
      BaseMessages.getString( PKG, "BaseStepDialog.FailedToGetFieldsPrevious.DialogTitle" ),
      BaseMessages.getString( PKG, "BaseStepDialog.FailedToGetFieldsPrevious.DialogMessage" ), ke );
  }
}
 
Example 10
Source File: GroupByDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void getAgg() {
  try {
    RowMetaInterface r = transMeta.getPrevStepFields( stepname );
    if ( r != null && !r.isEmpty() ) {
      BaseStepDialog.getFieldsFromPrevious( r, wAgg, 1, new int[] { 1, 2 }, new int[] {}, -1, -1, null );
    }
  } catch ( KettleException ke ) {
    new ErrorDialog(
      shell, BaseMessages.getString( PKG, "GroupByDialog.FailedToGetFields.DialogTitle" ), BaseMessages
        .getString( PKG, "GroupByDialog.FailedToGetFields.DialogMessage" ), ke );
  }
}
 
Example 11
Source File: BaseStepDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * Gets fields from previous steps and populate a ComboVar.
 *
 * @param comboVar  the Combo Box (with Variables) to populate
 * @param transMeta the transformation metadata
 * @param stepMeta  the step metadata
 */
public static final void getFieldsFromPrevious( ComboVar comboVar, TransMeta transMeta, StepMeta stepMeta ) {
  String selectedField = null;
  int indexField = -1;
  try {
    RowMetaInterface r = transMeta.getPrevStepFields( stepMeta );
    selectedField = comboVar.getText();
    comboVar.removeAll();

    if ( r != null && !r.isEmpty() ) {
      r.getFieldNames();
      comboVar.setItems( r.getFieldNames() );
      indexField = r.indexOfValue( selectedField );
    }
    // Select value if possible...
    if ( indexField > -1 ) {
      comboVar.select( indexField );
    } else {
      if ( selectedField != null ) {
        comboVar.setText( selectedField );
      }
    }
  } catch ( KettleException ke ) {
    new ErrorDialog( comboVar.getShell(),
      BaseMessages.getString( PKG, "BaseStepDialog.FailedToGetFieldsPrevious.DialogTitle" ),
      BaseMessages.getString( PKG, "BaseStepDialog.FailedToGetFieldsPrevious.DialogMessage" ), ke );
  }
}
 
Example 12
Source File: HTTPDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void getHeadersFields() {
  try {
    RowMetaInterface r = transMeta.getPrevStepFields( stepname );
    if ( r != null && !r.isEmpty() ) {
      BaseStepDialog.getFieldsFromPrevious( r, wHeaders, 1, new int[] { 1, 2 }, new int[] { 3 }, -1, -1, null );
    }
  } catch ( KettleException ke ) {
    new ErrorDialog(
      shell, BaseMessages.getString( PKG, "HTTPDialog.FailedToGetFields.DialogTitle" ), BaseMessages
        .getString( PKG, "HTTPDialog.FailedToGetFields.DialogMessage" ), ke );
  }

}
 
Example 13
Source File: HTTPDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void get() {
  try {
    RowMetaInterface r = transMeta.getPrevStepFields( stepname );
    if ( r != null && !r.isEmpty() ) {
      BaseStepDialog.getFieldsFromPrevious( r, wFields, 1, new int[] { 1, 2 }, new int[] { 3 }, -1, -1, null );
    }
  } catch ( KettleException ke ) {
    new ErrorDialog(
      shell, BaseMessages.getString( PKG, "HTTPDialog.FailedToGetFields.DialogTitle" ), BaseMessages
        .getString( PKG, "HTTPDialog.FailedToGetFields.DialogMessage" ), ke );
  }
}
 
Example 14
Source File: DenormaliserDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void get() {
  try {
    RowMetaInterface r = transMeta.getPrevStepFields( stepname );
    if ( r != null && !r.isEmpty() ) {
      BaseStepDialog.getFieldsFromPrevious( r, wGroup, 1, new int[] { 1 }, new int[] {}, -1, -1, null );
    }
  } catch ( KettleException ke ) {
    new ErrorDialog(
      shell, BaseMessages.getString( PKG, "DenormaliserDialog.FailedToGetFields.DialogTitle" ), BaseMessages
        .getString( PKG, "DenormaliserDialog.FailedToGetFields.DialogMessage" ), ke );
  }
}
 
Example 15
Source File: UniqueRowsDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void get() {
  try {
    RowMetaInterface r = transMeta.getPrevStepFields( stepname );
    if ( r != null && !r.isEmpty() ) {
      BaseStepDialog.getFieldsFromPrevious( r, wFields, 1, new int[] { 1 }, new int[] {}, -1, -1, null );
    }
  } catch ( KettleException ke ) {
    new ErrorDialog(
      shell, BaseMessages.getString( PKG, "UniqueRowsDialog.FailedToGetFields.DialogTitle" ), BaseMessages
        .getString( PKG, "UniqueRowsDialog.FailedToGetFields.DialogMessage" ), ke );
  }
}
 
Example 16
Source File: NullIfDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void get() {
  try {
    RowMetaInterface r = transMeta.getPrevStepFields( stepname );
    if ( r != null && !r.isEmpty() ) {
      BaseStepDialog.getFieldsFromPrevious( r, wFields, 1, new int[] { 1 }, null, -1, -1, null );
    }
  } catch ( KettleException ke ) {
    new ErrorDialog( shell, BaseMessages.getString( PKG, "System.Dialog.GetFieldsFailed.Title" ), BaseMessages
      .getString( PKG, "System.Dialog.GetFieldsFailed.Message" ), ke );
  }
}
 
Example 17
Source File: DenormaliserDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void getAgg() {
  // The grouping fields: ignore those.
  wGroup.removeEmptyRows();
  final String[] groupingFields = wGroup.getItems( 0 );
  try {
    RowMetaInterface r = transMeta.getPrevStepFields( stepname );
    if ( r != null && !r.isEmpty() ) {
      BaseStepDialog.getFieldsFromPrevious(
        r, wTarget, 2, new int[] {}, new int[] {}, -1, -1, new TableItemInsertListener() {
          @Override
          public boolean tableItemInserted( TableItem tableItem, ValueMetaInterface v ) {
            if ( Const.indexOfString( v.getName(), groupingFields ) < 0 ) { // Not a grouping field
              if ( !wKeyField.getText().equalsIgnoreCase( v.getName() ) ) { // Not the key field
                int nr = tableItem.getParent().indexOf( tableItem ) + 1;
                tableItem.setText( 1, BaseMessages.getString( PKG, "DenormaliserDialog.TargetFieldname.Label" )
                  + nr ); // the target fieldname
                tableItem.setText( 2, v.getName() );
                tableItem.setText( 4, v.getTypeDesc() );
                if ( v.getLength() >= 0 ) {
                  tableItem.setText( 6, "" + v.getLength() );
                }
                if ( v.getPrecision() >= 0 ) {
                  tableItem.setText( 7, "" + v.getPrecision() );
                }
              }
            }
            return true;
          }
        } );
    }
  } catch ( KettleException ke ) {
    new ErrorDialog(
      shell, BaseMessages.getString( PKG, "DenormaliserDialog.FailedToGetFields.DialogTitle" ), BaseMessages
        .getString( PKG, "DenormaliserDialog.FailedToGetFields.DialogMessage" ), ke );
  }
}
 
Example 18
Source File: XMLOutputDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void get() {
  try {
    RowMetaInterface r = transMeta.getPrevStepFields( stepname );
    if ( r != null && !r.isEmpty() ) {
      TableItemInsertListener listener = new TableItemInsertListener() {
        public boolean tableItemInserted( TableItem tableItem, ValueMetaInterface v ) {
          tableItem.setText( 3, ContentType.Element.name() );
          if ( v.isNumber() ) {
            if ( v.getLength() > 0 ) {
              int le = v.getLength();
              int pr = v.getPrecision();

              if ( v.getPrecision() <= 0 ) {
                pr = 0;
              }

              String mask = " ";
              for ( int m = 0; m < le - pr; m++ ) {
                mask += "0";
              }
              if ( pr > 0 ) {
                mask += ".";
              }
              for ( int m = 0; m < pr; m++ ) {
                mask += "0";
              }
              tableItem.setText( 4, mask );
            }
          }
          return true;
        }
      };
      BaseStepDialog.getFieldsFromPrevious( r, wFields, 1, new int[] { 1 }, new int[] { 4 }, 6, 7, listener );
    }
  } catch ( KettleException ke ) {
    new ErrorDialog( shell, BaseMessages.getString( PKG, "System.Dialog.GetFieldsFailed.Title" ), BaseMessages
        .getString( PKG, "System.Dialog.GetFieldsFailed.Message" ), ke );
  }

}
 
Example 19
Source File: AnalyticQueryDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void get() {
  try {
    RowMetaInterface r = transMeta.getPrevStepFields( stepname );
    if ( r != null && !r.isEmpty() ) {
      BaseStepDialog.getFieldsFromPrevious( r, wGroup, 1, new int[] { 1 }, new int[] {}, -1, -1, null );
    }
  } catch ( KettleException ke ) {
    new ErrorDialog(
      shell, BaseMessages.getString( PKG, "AnalyticQueryDialog.FailedToGetFields.DialogTitle" ), BaseMessages
        .getString( PKG, "AnalyticQueryDialog.FailedToGetFields.DialogMessage" ), ke );
  }
}
 
Example 20
Source File: TableInput.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private boolean doQuery( RowMetaInterface parametersMeta, Object[] parameters ) throws KettleDatabaseException {
  boolean success = true;

  // Open the query with the optional parameters received from the source steps.
  String sql = null;
  if ( meta.isVariableReplacementActive() ) {
    sql = environmentSubstitute( meta.getSQL() );
  } else {
    sql = meta.getSQL();
  }

  if ( log.isDetailed() ) {
    logDetailed( "SQL query : " + sql );
  }
  if ( parametersMeta.isEmpty() ) {
    data.rs = data.db.openQuery( sql, null, null, ResultSet.FETCH_FORWARD, meta.isLazyConversionActive() );
  } else {
    data.rs =
      data.db.openQuery( sql, parametersMeta, parameters, ResultSet.FETCH_FORWARD, meta
        .isLazyConversionActive() );
  }
  if ( data.rs == null ) {
    logError( "Couldn't open Query [" + sql + "]" );
    setErrors( 1 );
    stopAll();
    success = false;
  } else {
    // Keep the metadata
    data.rowMeta = data.db.getReturnRowMeta();

    // Set the origin on the row metadata...
    if ( data.rowMeta != null ) {
      for ( ValueMetaInterface valueMeta : data.rowMeta.getValueMetaList() ) {
        valueMeta.setOrigin( getStepname() );
      }
    }

    // Get the first row...
    data.thisrow = data.db.getRow( data.rs );
    if ( data.thisrow != null ) {
      incrementLinesInput();
      data.nextrow = data.db.getRow( data.rs );
      if ( data.nextrow != null ) {
        incrementLinesInput();
      }
    }
  }
  return success;
}