Java Code Examples for org.pentaho.di.trans.steps.textfileinput.TextFileInputField#setName()

The following examples show how to use org.pentaho.di.trans.steps.textfileinput.TextFileInputField#setName() . 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: ParGzipCsvInputMetaTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public TextFileInputField getTestObject() {
  TextFileInputField rtn = new TextFileInputField();
  rtn.setCurrencySymbol( UUID.randomUUID().toString() );
  rtn.setDecimalSymbol( UUID.randomUUID().toString() );
  rtn.setFormat( UUID.randomUUID().toString() );
  rtn.setGroupSymbol( UUID.randomUUID().toString() );
  rtn.setName( UUID.randomUUID().toString() );
  rtn.setTrimType( rand.nextInt( 4 ) );
  rtn.setPrecision( rand.nextInt( 9 ) );
  rtn.setLength( rand.nextInt( 50 ) );
  rtn.setType( rand.nextInt( 7 ) );
  // Note - these fields aren't serialized by the meta class ... cannot test for them
  // rtn.setRepeated( rand.nextBoolean() );
  // rtn.setSamples( new String[] { UUID.randomUUID().toString(), UUID.randomUUID().toString(),
  // UUID.randomUUID().toString() } );
  // rtn.setNullString( UUID.randomUUID().toString() );
  // rtn.setIfNullValue( UUID.randomUUID().toString() );
  // rtn.setIgnored( rand.nextBoolean() );
  // rtn.setPosition( rand.nextInt( 10 ) );
  return rtn;
}
 
Example 2
Source File: CsvInputMetaTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void testClone() {
  final CsvInputMeta original = new CsvInputMeta();
  original.setDelimiter( ";" );
  original.setEnclosure( "'" );
  final TextFileInputField[] originalFields = new TextFileInputField[ 1 ];
  final TextFileInputField originalField = new TextFileInputField();
  originalField.setName( "field" );
  originalFields[ 0 ] = originalField;
  original.setInputFields( originalFields );

  final CsvInputMeta clone = (CsvInputMeta) original.clone();
  // verify that the clone and its input fields are "equal" to the originals, but not the same objects
  Assert.assertNotSame( original, clone );
  Assert.assertEquals( original.getDelimiter(), clone.getDelimiter() );
  Assert.assertEquals( original.getEnclosure(), clone.getEnclosure() );

  Assert.assertNotSame( original.getInputFields(), clone.getInputFields() );
  Assert.assertNotSame( original.getInputFields()[ 0 ], clone.getInputFields()[ 0 ] );
  Assert.assertEquals( original.getInputFields()[ 0 ].getName(), clone.getInputFields()[ 0 ].getName() );
}
 
Example 3
Source File: GoogleSpreadsheetInputMeta.java    From pdi-google-spreadsheet-plugin with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void setDefault() {
    this.serviceEmail = "";
    this.spreadsheetKey = "";
    this.worksheetId = "od6";
    this.privateKeyStore = null;

    TextFileInputField field = new TextFileInputField();
    field.setName("field");
    field.setType(ValueMetaInterface.TYPE_STRING);

    inputFields = new TextFileInputField[]{
            field,
    };
}
 
Example 4
Source File: CsvInputMeta.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@Override
public void injectStepMetadataEntries( List<StepInjectionMetaEntry> metadata ) {
  for ( StepInjectionMetaEntry entry : metadata ) {
    KettleAttributeInterface attr = findAttribute( entry.getKey() );

    // Set top level attributes...
    //
    if ( entry.getValueType() != ValueMetaInterface.TYPE_NONE ) {
      if ( attr.getKey().equals( "FILENAME" ) ) {
        filename = (String) entry.getValue();
      } else if ( attr.getKey().equals( "FILENAME_FIELD" ) ) {
        filenameField = (String) entry.getValue();
      } else if ( attr.getKey().equals( "ROW_NUM_FIELD" ) ) {
        rowNumField = (String) entry.getValue();
      } else if ( attr.getKey().equals( "HEADER_PRESENT" ) ) {
        headerPresent = (Boolean) entry.getValue();
      } else if ( attr.getKey().equals( "DELIMITER" ) ) {
        delimiter = (String) entry.getValue();
      } else if ( attr.getKey().equals( "ENCLOSURE" ) ) {
        enclosure = (String) entry.getValue();
      } else if ( attr.getKey().equals( "BUFFERSIZE" ) ) {
        bufferSize = (String) entry.getValue();
      } else if ( attr.getKey().equals( "LAZY_CONVERSION" ) ) {
        lazyConversionActive = (Boolean) entry.getValue();
      } else if ( attr.getKey().equals( "PARALLEL" ) ) {
        runningInParallel = (Boolean) entry.getValue();
      } else if ( attr.getKey().equals( "NEWLINE_POSSIBLE" ) ) {
        newlinePossibleInFields = (Boolean) entry.getValue();
      } else if ( attr.getKey().equals( "ADD_FILENAME_RESULT" ) ) {
        isaddresult = (Boolean) entry.getValue();
      } else if ( attr.getKey().equals( "FORMAT" ) ) {
        fileFormat = (String) entry.getValue();
      } else if ( attr.getKey().equals( "ENCODING" ) ) {
        encoding = (String) entry.getValue();
      } else {
        throw new RuntimeException( "Unhandled metadata injection of attribute: "
          + attr.toString() + " - " + attr.getDescription() );
      }
    } else {
      if ( attr.getKey().equals( "FIELDS" ) ) {
        // This entry contains a list of lists...
        // Each list contains a single CSV input field definition (one line in the dialog)
        //
        List<StepInjectionMetaEntry> inputFieldEntries = entry.getDetails();
        inputFields = new TextFileInputField[inputFieldEntries.size()];
        for ( int row = 0; row < inputFieldEntries.size(); row++ ) {
          StepInjectionMetaEntry inputFieldEntry = inputFieldEntries.get( row );
          TextFileInputField inputField = new TextFileInputField();

          List<StepInjectionMetaEntry> fieldAttributes = inputFieldEntry.getDetails();
          for ( int i = 0; i < fieldAttributes.size(); i++ ) {
            StepInjectionMetaEntry fieldAttribute = fieldAttributes.get( i );
            KettleAttributeInterface fieldAttr = findAttribute( fieldAttribute.getKey() );

            String attributeValue = (String) fieldAttribute.getValue();
            if ( fieldAttr.getKey().equals( "FIELD_NAME" ) ) {
              inputField.setName( attributeValue );
            } else if ( fieldAttr.getKey().equals( "FIELD_TYPE" ) ) {
              inputField.setType( ValueMetaFactory.getIdForValueMeta( attributeValue ) );
            } else if ( fieldAttr.getKey().equals( "FIELD_FORMAT" ) ) {
              inputField.setFormat( attributeValue );
            } else if ( fieldAttr.getKey().equals( "FIELD_LENGTH" ) ) {
              inputField.setLength( attributeValue == null ? -1 : Integer.parseInt( attributeValue ) );
            } else if ( fieldAttr.getKey().equals( "FIELD_PRECISION" ) ) {
              inputField.setPrecision( attributeValue == null ? -1 : Integer.parseInt( attributeValue ) );
            } else if ( fieldAttr.getKey().equals( "FIELD_CURRENCY" ) ) {
              inputField.setCurrencySymbol( attributeValue );
            } else if ( fieldAttr.getKey().equals( "FIELD_DECIMAL" ) ) {
              inputField.setDecimalSymbol( attributeValue );
            } else if ( fieldAttr.getKey().equals( "FIELD_GROUP" ) ) {
              inputField.setGroupSymbol( attributeValue );
            } else if ( fieldAttr.getKey().equals( "FIELD_TRIM_TYPE" ) ) {
              inputField.setTrimType( ValueMetaString.getTrimTypeByCode( attributeValue ) );
            } else {
              throw new RuntimeException( "Unhandled metadata injection of attribute: "
                + fieldAttr.toString() + " - " + fieldAttr.getDescription() );
            }
          }

          inputFields[row] = inputField;
        }
      }
    }
  }
}
 
Example 5
Source File: CsvInputUnitTestBase.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
TextFileInputField createField( String name ) {
  TextFileInputField field = new TextFileInputField();
  field.setName( name );
  field.setType( ValueMetaInterface.TYPE_STRING );
  return field;
}
 
Example 6
Source File: TextFileInputCSVImportProgressDialogTest.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private TextFileInputField createField( String name ) {
  TextFileInputField field = new TextFileInputField();
  field.setName( name );
  field.setType( ValueMetaInterface.TYPE_NONE );
  return field;
}