@Test public void testGetXmlWorksIfWeUpdateOnlyPartOfInputFilesInformation() throws Exception { inputMeta.inputFiles = new FormatInputFile(); inputMeta.inputFiles.fileName = new String[] { FILE_NAME_VALID_PATH }; inputMeta.getXML(); assertEquals( inputMeta.inputFiles.fileName.length, inputMeta.inputFiles.fileMask.length ); assertEquals( inputMeta.inputFiles.fileName.length, inputMeta.inputFiles.excludeFileMask.length ); assertEquals( inputMeta.inputFiles.fileName.length, inputMeta.inputFiles.fileRequired.length ); assertEquals( inputMeta.inputFiles.fileName.length, inputMeta.inputFiles.includeSubFolders.length ); assertEquals( inputMeta.inputFiles.fileName.length, inputMeta.inputFiles.environment.length ); }
@Override public String getXML() { StringBuilder retval = new StringBuilder( 1500 ); retval.append( " " ).append( XMLHandler.addTagValue( "passing_through_fields", inputFiles.passingThruFields ) ); retval.append( " <file>" ).append( Const.CR ); inputFiles.normalizeAllocation( inputFiles.fileName.length ); for ( int i = 0; i < inputFiles.fileName.length; i++ ) { retval.append( " " ).append( XMLHandler.addTagValue( "environment", inputFiles.environment[i] ) ); if ( parentStepMeta != null && parentStepMeta.getParentTransMeta() != null ) { parentStepMeta.getParentTransMeta().getNamedClusterEmbedManager().registerUrl( inputFiles.fileName[i] ); } retval.append( " " ).append( XMLHandler.addTagValue( "name", inputFiles.fileName[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "filemask", inputFiles.fileMask[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "exclude_filemask", inputFiles.excludeFileMask[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "file_required", inputFiles.fileRequired[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "include_subfolders", inputFiles.includeSubFolders[i] ) ); } retval.append( " </file>" ).append( Const.CR ); retval.append( " <fields>" ).append( Const.CR ); for ( int i = 0; i < inputFields.length; i++ ) { OrcInputField field = inputFields[ i ]; retval.append( " <field>" ).append( Const.CR ); retval.append( " " ).append( XMLHandler.addTagValue( "path", field.getFormatFieldName() ) ); retval.append( " " ).append( XMLHandler.addTagValue( "name", field.getPentahoFieldName() ) ); retval.append( " " ).append( XMLHandler.addTagValue( "type", field.getTypeDesc() ) ); OrcSpec.DataType orcDataType = field.getOrcType(); if ( orcDataType != null && orcDataType.getName() != null && !orcDataType.getName().equalsIgnoreCase( OrcSpec.DataType.NULL.getName() ) ) { retval.append( " " ).append( XMLHandler.addTagValue( "orc_type", orcDataType.getName() ) ); } else { retval.append( " " ).append( XMLHandler.addTagValue( "orc_type", OrcTypeConverter.convertToOrcType( field.getTypeDesc() ) ) ); } if ( field.getStringFormat() != null ) { retval.append( " " ).append( XMLHandler.addTagValue( "format", field.getStringFormat() ) ); } retval.append( " </field>" ).append( Const.CR ); } retval.append( " </fields>" ).append( Const.CR ); return retval.toString(); }
OrcInputMetaBase extends
    BaseFileInputMeta<BaseFileInputAdditionalField, FormatInputFile, OrcInputField> implements ResolvableResource { @Override public String getXML() { StringBuilder retval = new StringBuilder( 1500 ); retval.append( " " ).append( XMLHandler.addTagValue( "passing_through_fields", inputFiles.passingThruFields ) ); retval.append( " <file>" ).append( Const.CR ); inputFiles.normalizeAllocation( inputFiles.fileName.length ); for ( int i = 0; i < inputFiles.fileName.length; i++ ) { retval.append( " " ).append( XMLHandler.addTagValue( "environment", inputFiles.environment[i] ) ); if ( parentStepMeta != null && parentStepMeta.getParentTransMeta() != null ) { parentStepMeta.getParentTransMeta().getNamedClusterEmbedManager().registerUrl( inputFiles.fileName[i] ); } retval.append( " " ).append( XMLHandler.addTagValue( "name", inputFiles.fileName[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "filemask", inputFiles.fileMask[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "exclude_filemask", inputFiles.excludeFileMask[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "file_required", inputFiles.fileRequired[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "include_subfolders", inputFiles.includeSubFolders[i] ) ); } retval.append( " </file>" ).append( Const.CR ); retval.append( " <fields>" ).append( Const.CR ); for ( int i = 0; i < inputFields.length; i++ ) { OrcInputField field = inputFields[ i ]; retval.append( " <field>" ).append( Const.CR ); retval.append( " " ).append( XMLHandler.addTagValue( "path", field.getFormatFieldName() ) ); retval.append( " " ).append( XMLHandler.addTagValue( "name", field.getPentahoFieldName() ) ); retval.append( " " ).append( XMLHandler.addTagValue( "type", field.getTypeDesc() ) ); OrcSpec.DataType orcDataType = field.getOrcType(); if ( orcDataType != null && orcDataType.getName() != null && !orcDataType.getName().equalsIgnoreCase( OrcSpec.DataType.NULL.getName() ) ) { retval.append( " " ).append( XMLHandler.addTagValue( "orc_type", orcDataType.getName() ) ); } else { retval.append( " " ).append( XMLHandler.addTagValue( "orc_type", OrcTypeConverter.convertToOrcType( field.getTypeDesc() ) ) ); } if ( field.getStringFormat() != null ) { retval.append( " " ).append( XMLHandler.addTagValue( "format", field.getStringFormat() ) ); } retval.append( " </field>" ).append( Const.CR ); } retval.append( " </fields>" ).append( Const.CR ); return retval.toString(); } }
OrcInputMetaBase extends
    BaseFileInputMeta<BaseFileInputAdditionalField, FormatInputFile, OrcInputField> implements ResolvableResource { @Override public String getXML() { StringBuilder retval = new StringBuilder( 1500 ); retval.append( " " ).append( XMLHandler.addTagValue( "passing_through_fields", inputFiles.passingThruFields ) ); retval.append( " <file>" ).append( Const.CR ); inputFiles.normalizeAllocation( inputFiles.fileName.length ); for ( int i = 0; i < inputFiles.fileName.length; i++ ) { retval.append( " " ).append( XMLHandler.addTagValue( "environment", inputFiles.environment[i] ) ); if ( parentStepMeta != null && parentStepMeta.getParentTransMeta() != null ) { parentStepMeta.getParentTransMeta().getNamedClusterEmbedManager().registerUrl( inputFiles.fileName[i] ); } retval.append( " " ).append( XMLHandler.addTagValue( "name", inputFiles.fileName[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "filemask", inputFiles.fileMask[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "exclude_filemask", inputFiles.excludeFileMask[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "file_required", inputFiles.fileRequired[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "include_subfolders", inputFiles.includeSubFolders[i] ) ); } retval.append( " </file>" ).append( Const.CR ); retval.append( " <fields>" ).append( Const.CR ); for ( int i = 0; i < inputFields.length; i++ ) { OrcInputField field = inputFields[ i ]; retval.append( " <field>" ).append( Const.CR ); retval.append( " " ).append( XMLHandler.addTagValue( "path", field.getFormatFieldName() ) ); retval.append( " " ).append( XMLHandler.addTagValue( "name", field.getPentahoFieldName() ) ); retval.append( " " ).append( XMLHandler.addTagValue( "type", field.getTypeDesc() ) ); OrcSpec.DataType orcDataType = field.getOrcType(); if ( orcDataType != null && orcDataType.getName() != null && !orcDataType.getName().equalsIgnoreCase( OrcSpec.DataType.NULL.getName() ) ) { retval.append( " " ).append( XMLHandler.addTagValue( "orc_type", orcDataType.getName() ) ); } else { retval.append( " " ).append( XMLHandler.addTagValue( "orc_type", OrcTypeConverter.convertToOrcType( field.getTypeDesc() ) ) ); } if ( field.getStringFormat() != null ) { retval.append( " " ).append( XMLHandler.addTagValue( "format", field.getStringFormat() ) ); } retval.append( " </field>" ).append( Const.CR ); } retval.append( " </fields>" ).append( Const.CR ); return retval.toString(); } OrcInputMetaBase(); }
OrcInputMetaBase extends
    BaseFileInputMeta<BaseFileInputAdditionalField, FormatInputFile, OrcInputField> implements ResolvableResource { @Override public String getXML() { StringBuilder retval = new StringBuilder( 1500 ); retval.append( " " ).append( XMLHandler.addTagValue( "passing_through_fields", inputFiles.passingThruFields ) ); retval.append( " <file>" ).append( Const.CR ); inputFiles.normalizeAllocation( inputFiles.fileName.length ); for ( int i = 0; i < inputFiles.fileName.length; i++ ) { retval.append( " " ).append( XMLHandler.addTagValue( "environment", inputFiles.environment[i] ) ); if ( parentStepMeta != null && parentStepMeta.getParentTransMeta() != null ) { parentStepMeta.getParentTransMeta().getNamedClusterEmbedManager().registerUrl( inputFiles.fileName[i] ); } retval.append( " " ).append( XMLHandler.addTagValue( "name", inputFiles.fileName[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "filemask", inputFiles.fileMask[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "exclude_filemask", inputFiles.excludeFileMask[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "file_required", inputFiles.fileRequired[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "include_subfolders", inputFiles.includeSubFolders[i] ) ); } retval.append( " </file>" ).append( Const.CR ); retval.append( " <fields>" ).append( Const.CR ); for ( int i = 0; i < inputFields.length; i++ ) { OrcInputField field = inputFields[ i ]; retval.append( " <field>" ).append( Const.CR ); retval.append( " " ).append( XMLHandler.addTagValue( "path", field.getFormatFieldName() ) ); retval.append( " " ).append( XMLHandler.addTagValue( "name", field.getPentahoFieldName() ) ); retval.append( " " ).append( XMLHandler.addTagValue( "type", field.getTypeDesc() ) ); OrcSpec.DataType orcDataType = field.getOrcType(); if ( orcDataType != null && orcDataType.getName() != null && !orcDataType.getName().equalsIgnoreCase( OrcSpec.DataType.NULL.getName() ) ) { retval.append( " " ).append( XMLHandler.addTagValue( "orc_type", orcDataType.getName() ) ); } else { retval.append( " " ).append( XMLHandler.addTagValue( "orc_type", OrcTypeConverter.convertToOrcType( field.getTypeDesc() ) ) ); } if ( field.getStringFormat() != null ) { retval.append( " " ).append( XMLHandler.addTagValue( "format", field.getStringFormat() ) ); } retval.append( " </field>" ).append( Const.CR ); } retval.append( " </fields>" ).append( Const.CR ); return retval.toString(); } OrcInputMetaBase(); String getFilename(); void setFilename( String filename ); OrcInputField[] getInputFields(); void setInputFields( OrcInputField[] inputFields ); void setInputFields( List<OrcInputField> inputFields ); @Override String getXML(); @Override void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); @Override void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); @Override void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); void allocateFiles( int nrFiles ); @Override String getEncoding(); @Override void setDefault(); @Override void resolve(); @Override void getFields( RowMetaInterface rowMeta, String origin, RowMetaInterface[] info, StepMeta nextStep,
                         VariableSpace space, Repository repository, IMetaStore metaStore ); }
OrcInputMetaBase extends
    BaseFileInputMeta<BaseFileInputAdditionalField, FormatInputFile, OrcInputField> implements ResolvableResource { @Override public String getXML() { StringBuilder retval = new StringBuilder( 1500 ); retval.append( " " ).append( XMLHandler.addTagValue( "passing_through_fields", inputFiles.passingThruFields ) ); retval.append( " <file>" ).append( Const.CR ); inputFiles.normalizeAllocation( inputFiles.fileName.length ); for ( int i = 0; i < inputFiles.fileName.length; i++ ) { retval.append( " " ).append( XMLHandler.addTagValue( "environment", inputFiles.environment[i] ) ); if ( parentStepMeta != null && parentStepMeta.getParentTransMeta() != null ) { parentStepMeta.getParentTransMeta().getNamedClusterEmbedManager().registerUrl( inputFiles.fileName[i] ); } retval.append( " " ).append( XMLHandler.addTagValue( "name", inputFiles.fileName[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "filemask", inputFiles.fileMask[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "exclude_filemask", inputFiles.excludeFileMask[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "file_required", inputFiles.fileRequired[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "include_subfolders", inputFiles.includeSubFolders[i] ) ); } retval.append( " </file>" ).append( Const.CR ); retval.append( " <fields>" ).append( Const.CR ); for ( int i = 0; i < inputFields.length; i++ ) { OrcInputField field = inputFields[ i ]; retval.append( " <field>" ).append( Const.CR ); retval.append( " " ).append( XMLHandler.addTagValue( "path", field.getFormatFieldName() ) ); retval.append( " " ).append( XMLHandler.addTagValue( "name", field.getPentahoFieldName() ) ); retval.append( " " ).append( XMLHandler.addTagValue( "type", field.getTypeDesc() ) ); OrcSpec.DataType orcDataType = field.getOrcType(); if ( orcDataType != null && orcDataType.getName() != null && !orcDataType.getName().equalsIgnoreCase( OrcSpec.DataType.NULL.getName() ) ) { retval.append( " " ).append( XMLHandler.addTagValue( "orc_type", orcDataType.getName() ) ); } else { retval.append( " " ).append( XMLHandler.addTagValue( "orc_type", OrcTypeConverter.convertToOrcType( field.getTypeDesc() ) ) ); } if ( field.getStringFormat() != null ) { retval.append( " " ).append( XMLHandler.addTagValue( "format", field.getStringFormat() ) ); } retval.append( " </field>" ).append( Const.CR ); } retval.append( " </fields>" ).append( Const.CR ); return retval.toString(); } OrcInputMetaBase(); String getFilename(); void setFilename( String filename ); OrcInputField[] getInputFields(); void setInputFields( OrcInputField[] inputFields ); void setInputFields( List<OrcInputField> inputFields ); @Override String getXML(); @Override void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); @Override void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); @Override void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); void allocateFiles( int nrFiles ); @Override String getEncoding(); @Override void setDefault(); @Override void resolve(); @Override void getFields( RowMetaInterface rowMeta, String origin, RowMetaInterface[] info, StepMeta nextStep,
                         VariableSpace space, Repository repository, IMetaStore metaStore );  }