Java Code Examples for org.pentaho.di.core.row.value.ValueMetaBase#getType()

The following examples show how to use org.pentaho.di.core.row.value.ValueMetaBase#getType() . 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: SwitchCaseMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void readData( Node stepnode ) throws KettleXMLException {
  try {
    fieldname = XMLHandler.getTagValue( stepnode, "fieldname" );
    isContains = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "use_contains" ) );
    caseValueType = ValueMetaBase.getType( XMLHandler.getTagValue( stepnode, "case_value_type" ) );
    caseValueFormat = XMLHandler.getTagValue( stepnode, "case_value_format" );
    caseValueDecimal = XMLHandler.getTagValue( stepnode, "case_value_decimal" );
    caseValueGroup = XMLHandler.getTagValue( stepnode, "case_value_group" );

    defaultTargetStepname = XMLHandler.getTagValue( stepnode, "default_target_step" );

    Node casesNode = XMLHandler.getSubNode( stepnode, XML_TAG_CASE_VALUES );
    int nrCases = XMLHandler.countNodes( casesNode, XML_TAG_CASE_VALUE );
    allocate();
    for ( int i = 0; i < nrCases; i++ ) {
      Node caseNode = XMLHandler.getSubNodeByNr( casesNode, XML_TAG_CASE_VALUE, i );
      SwitchCaseTarget target = new SwitchCaseTarget();
      target.caseValue = XMLHandler.getTagValue( caseNode, "value" );
      target.caseTargetStepname = XMLHandler.getTagValue( caseNode, "target_step" );
      caseTargets.add( target );
    }
  } catch ( Exception e ) {
    throw new KettleXMLException( BaseMessages.getString(
      PKG, "SwitchCaseMeta.Exception..UnableToLoadStepInfoFromXML" ), e );
  }
}
 
Example 2
Source File: SwitchCaseMeta.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 {
    fieldname = rep.getStepAttributeString( id_step, "fieldname" );
    isContains = rep.getStepAttributeBoolean( id_step, "use_contains" );
    caseValueType = ValueMetaBase.getType( rep.getStepAttributeString( id_step, "case_value_type" ) );
    caseValueFormat = rep.getStepAttributeString( id_step, "case_value_format" );
    caseValueDecimal = rep.getStepAttributeString( id_step, "case_value_decimal" );
    caseValueGroup = rep.getStepAttributeString( id_step, "case_value_group" );

    defaultTargetStepname = rep.getStepAttributeString( id_step, "default_target_step" );

    int nrCases = rep.countNrStepAttributes( id_step, "case_value" );
    allocate();
    for ( int i = 0; i < nrCases; i++ ) {
      SwitchCaseTarget target = new SwitchCaseTarget();
      target.caseValue = rep.getStepAttributeString( id_step, i, "case_value" );
      target.caseTargetStepname = rep.getStepAttributeString( id_step, i, "case_target_step" );
      caseTargets.add( target );
    }
  } catch ( Exception e ) {
    throw new KettleException( BaseMessages.getString(
      PKG, "SwitchCaseMeta.Exception.UnexpectedErrorInReadingStepInfoFromRepository" ), e );
  }
}
 
Example 3
Source File: BaseMetadataInjectionTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public static int[] getTypeCodes( String[] typeNames ) {
  int[] typeCodes = new int[typeNames.length];
  for ( int i = 0; i < typeNames.length; i++ ) {
    typeCodes[i] = ValueMetaBase.getType( typeNames[i] );
  }
  return typeCodes;
}
 
Example 4
Source File: ValueMetaAndData.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
/**
 * Read the data for this Value from an XML Node
 *
 * @param valnode
 *          The XML Node to read from
 * @return true if all went well, false if something went wrong.
 */
public boolean loadXML( Node valnode ) {
  valueMeta = null;

  try {
    String valname = XMLHandler.getTagValue( valnode, "name" );
    int valtype = ValueMetaBase.getType( XMLHandler.getTagValue( valnode, "type" ) );
    String text = XMLHandler.getTagValue( valnode, "text" );
    boolean isnull = "Y".equalsIgnoreCase( XMLHandler.getTagValue( valnode, "isnull" ) );
    int len = Const.toInt( XMLHandler.getTagValue( valnode, "length" ), -1 );
    int prec = Const.toInt( XMLHandler.getTagValue( valnode, "precision" ), -1 );
    String mask = XMLHandler.getTagValue( valnode, "mask" );

    valueMeta = new ValueMeta( valname, valtype );
    valueData = text;
    valueMeta.setLength( len );
    valueMeta.setPrecision( prec );
    if ( mask != null ) {
      valueMeta.setConversionMask( mask );
    }

    if ( valtype != ValueMetaInterface.TYPE_STRING ) {
      ValueMetaInterface originMeta = new ValueMetaString( valname );
      if ( valueMeta.isNumeric() ) {
        originMeta.setDecimalSymbol( "." );
        originMeta.setGroupingSymbol( null );
        originMeta.setCurrencySymbol( null );
      }
      if ( valtype == ValueMetaInterface.TYPE_DATE ) {
        originMeta.setConversionMask( ValueMetaBase.COMPATIBLE_DATE_FORMAT_PATTERN );
      }
      valueData = Const.trim( text );
      valueData = valueMeta.convertData( originMeta, valueData );
    }

    if ( isnull ) {
      valueData = null;
    }
  } catch ( Exception e ) {
    valueData = null;
    return false;
  }

  return true;
}
 
Example 5
Source File: GaInputStepDialog.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private void getInfo( GaInputStepMeta meta ) {

    stepname = wStepname.getText(); // return value

    meta.setGaProfileName( wGaProfile.getText() );
    meta.setGaAppName( wGaAppName.getText() );
    meta.setOauthServiceAccount( wOauthAccount.getText() );
    meta.setOAuthKeyFile( keyFilename.getText() );

    if ( !Utils.isEmpty( wGaProfile.getText() ) ) {
      meta.setGaProfileTableId( profileTableIds.get( wGaProfile.getText() ) );
    } else {
      meta.setGaProfileTableId( null );
    }

    meta.setUseCustomTableId( wCustomProfileEnabled.getSelection() );
    meta.setGaCustomTableId( wGaCustomProfile.getText() );

    meta.setSegmentName( Utils.isEmpty( wQuSegment.getText() ) ? "All Visits" : wQuSegment.getText() );
    if ( !Utils.isEmpty( wQuSegment.getText() ) ) {
      meta.setSegmentId( segmentIds.get( wQuSegment.getText() ) );
    } else {
      // all visits is default
      meta.setSegmentId( "gaid::-1" );
    }

    meta.setStartDate( wQuStartDate.getText() );
    meta.setEndDate( wQuEndDate.getText() );

    meta.setDimensions( wQuDimensions.getText() );
    meta.setMetrics( wQuMetrics.getText() );
    meta.setFilters( wQuFilters.getText() );
    meta.setSort( wQuSort.getText() );

    meta.setUseSegment( wUseSegmentEnabled.getSelection() );
    meta.setUseCustomSegment( wCustomSegmentEnabled.getSelection() );
    meta.setCustomSegment( wQuCustomSegment.getText() );
    meta.setSamplingLevel( wQuSamplingLevel.getText() );

    int nrFields = getTableView().nrNonEmpty();

    meta.allocate( nrFields );

    for ( int i = 0; i < nrFields; i++ ) {
      TableItem item = getTableView().getNonEmpty( i );
      meta.getFeedFieldType()[ i ] = item.getText( 1 );
      meta.getFeedField()[ i ] = item.getText( 2 );
      meta.getOutputField()[ i ] = item.getText( 3 );

      meta.getOutputType()[ i ] = ValueMetaBase.getType( item.getText( 4 ) );
      meta.getConversionMask()[ i ] = item.getText( 5 );

      // fix unknowns
      if ( meta.getOutputType()[ i ] < 0 ) {
        meta.getOutputType()[ i ] = ValueMetaInterface.TYPE_STRING;
      }
    }
    meta.setRowLimit( Const.toInt( wLimit.getText(), 0 ) );
  }
 
Example 6
Source File: MetaInjectOutputField.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@Override
public int string2intPrimitive( String v ) throws KettleValueException {
  return ValueMetaBase.getType( v );
}