@Test public void testCreateOutputFieldNode() throws Exception { doReturn( builder ).when( analyzer ).getMetaverseBuilder(); analyzer.setBaseStepMeta( meta ); GetXMLDataField[] fields = new GetXMLDataField[2]; GetXMLDataField field1 = new GetXMLDataField( "name" ); GetXMLDataField field2 = new GetXMLDataField( "age" ); field1.setXPath( "field1/xpath" ); field2.setElementType( 1 ); field1.setResultType( 1 ); field2.setRepeated( true ); fields[0] = field1; fields[1] = field2; when( meta.getInputFields() ).thenReturn( fields ); IAnalysisContext context = mock( IAnalysisContext.class ); doReturn( "thisStepName" ).when( analyzer ).getStepName(); when( node.getLogicalId() ).thenReturn( "logical id" ); ValueMetaInterface vmi = new ValueMeta( "name", 1 ); IMetaverseNode outputFieldNode = analyzer.createOutputFieldNode( context, vmi, ExternalResourceStepAnalyzer.RESOURCE, DictionaryConst.NODE_TYPE_TRANS_FIELD ); assertNotNull( outputFieldNode ); assertNotNull( outputFieldNode.getProperty( DictionaryConst.PROPERTY_KETTLE_TYPE ) ); assertEquals( ExternalResourceStepAnalyzer.RESOURCE, outputFieldNode.getProperty( DictionaryConst.PROPERTY_TARGET_STEP ) ); assertEquals( "field1/xpath", outputFieldNode.getProperty( "xpath" ) ); assertNotNull( outputFieldNode.getProperty( "resultType" ) ); assertNotNull( outputFieldNode.getProperty( "element" ) ); assertEquals( false, outputFieldNode.getProperty( "repeat" ) ); verify( builder ).addNode( outputFieldNode ); }
@Override protected IMetaverseNode createOutputFieldNode( IAnalysisContext context, ValueMetaInterface fieldMeta, String targetStepName, String nodeType ) { IMetaverseNode fieldNode = super.createOutputFieldNode( context, fieldMeta, targetStepName, nodeType ); GetXMLDataField[] fields = baseStepMeta.getInputFields(); for ( GetXMLDataField field : fields ) { if ( fieldMeta.getName().equals( field.getName() ) ) { fieldNode.setProperty( "xpath", Const.NVL( field.getXPath(), "" ) ); fieldNode.setProperty( "element", Const.NVL( field.getElementTypeCode(), "" ) ); fieldNode.setProperty( "resultType", Const.NVL( field.getResultTypeCode(), "" ) ); fieldNode.setProperty( "repeat", field.isRepeated() ); break; } } return fieldNode; }
GetXMLDataStepAnalyzer extends ExternalResourceStepAnalyzer<GetXMLDataMeta> { @Override protected IMetaverseNode createOutputFieldNode( IAnalysisContext context, ValueMetaInterface fieldMeta, String targetStepName, String nodeType ) { IMetaverseNode fieldNode = super.createOutputFieldNode( context, fieldMeta, targetStepName, nodeType ); GetXMLDataField[] fields = baseStepMeta.getInputFields(); for ( GetXMLDataField field : fields ) { if ( fieldMeta.getName().equals( field.getName() ) ) { fieldNode.setProperty( "xpath", Const.NVL( field.getXPath(), "" ) ); fieldNode.setProperty( "element", Const.NVL( field.getElementTypeCode(), "" ) ); fieldNode.setProperty( "resultType", Const.NVL( field.getResultTypeCode(), "" ) ); fieldNode.setProperty( "repeat", field.isRepeated() ); break; } } return fieldNode; } }
GetXMLDataStepAnalyzer extends ExternalResourceStepAnalyzer<GetXMLDataMeta> { @Override protected IMetaverseNode createOutputFieldNode( IAnalysisContext context, ValueMetaInterface fieldMeta, String targetStepName, String nodeType ) { IMetaverseNode fieldNode = super.createOutputFieldNode( context, fieldMeta, targetStepName, nodeType ); GetXMLDataField[] fields = baseStepMeta.getInputFields(); for ( GetXMLDataField field : fields ) { if ( fieldMeta.getName().equals( field.getName() ) ) { fieldNode.setProperty( "xpath", Const.NVL( field.getXPath(), "" ) ); fieldNode.setProperty( "element", Const.NVL( field.getElementTypeCode(), "" ) ); fieldNode.setProperty( "resultType", Const.NVL( field.getResultTypeCode(), "" ) ); fieldNode.setProperty( "repeat", field.isRepeated() ); break; } } return fieldNode; }  }
GetXMLDataStepAnalyzer extends ExternalResourceStepAnalyzer<GetXMLDataMeta> { @Override protected IMetaverseNode createOutputFieldNode( IAnalysisContext context, ValueMetaInterface fieldMeta, String targetStepName, String nodeType ) { IMetaverseNode fieldNode = super.createOutputFieldNode( context, fieldMeta, targetStepName, nodeType ); GetXMLDataField[] fields = baseStepMeta.getInputFields(); for ( GetXMLDataField field : fields ) { if ( fieldMeta.getName().equals( field.getName() ) ) { fieldNode.setProperty( "xpath", Const.NVL( field.getXPath(), "" ) ); fieldNode.setProperty( "element", Const.NVL( field.getElementTypeCode(), "" ) ); fieldNode.setProperty( "resultType", Const.NVL( field.getResultTypeCode(), "" ) ); fieldNode.setProperty( "repeat", field.isRepeated() ); break; } } return fieldNode; }  @Override Set<Class<? extends BaseStepMeta>> getSupportedSteps(); @Override Set<ComponentDerivationRecord> getChangeRecords( GetXMLDataMeta meta ); @Override IMetaverseNode createResourceNode( IExternalResourceInfo resource ); @Override String getResourceInputNodeType(); @Override String getResourceOutputNodeType(); @Override boolean isOutput(); @Override boolean isInput(); }
GetXMLDataStepAnalyzer extends ExternalResourceStepAnalyzer<GetXMLDataMeta> { @Override protected IMetaverseNode createOutputFieldNode( IAnalysisContext context, ValueMetaInterface fieldMeta, String targetStepName, String nodeType ) { IMetaverseNode fieldNode = super.createOutputFieldNode( context, fieldMeta, targetStepName, nodeType ); GetXMLDataField[] fields = baseStepMeta.getInputFields(); for ( GetXMLDataField field : fields ) { if ( fieldMeta.getName().equals( field.getName() ) ) { fieldNode.setProperty( "xpath", Const.NVL( field.getXPath(), "" ) ); fieldNode.setProperty( "element", Const.NVL( field.getElementTypeCode(), "" ) ); fieldNode.setProperty( "resultType", Const.NVL( field.getResultTypeCode(), "" ) ); fieldNode.setProperty( "repeat", field.isRepeated() ); break; } } return fieldNode; }  @Override Set<Class<? extends BaseStepMeta>> getSupportedSteps(); @Override Set<ComponentDerivationRecord> getChangeRecords( GetXMLDataMeta meta ); @Override IMetaverseNode createResourceNode( IExternalResourceInfo resource ); @Override String getResourceInputNodeType(); @Override String getResourceOutputNodeType(); @Override boolean isOutput(); @Override boolean isInput();  }