Java Code Examples for org.pentaho.di.core.xml.XMLHandler#getNodes()
The following examples show how to use
org.pentaho.di.core.xml.XMLHandler#getNodes() .
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: AttributesUtil.java From pentaho-kettle with Apache License 2.0 | 6 votes |
/** * <p>Load the attribute groups from an XML DOM Node.</p> * <p>An empty Map will be returned if a null or empty Node is given.</p> * * @param attributesNode the attributes node to read from * @return the Map with the attribute groups */ public static Map<String, Map<String, String>> loadAttributes( Node attributesNode ) { Map<String, Map<String, String>> attributesMap = new HashMap<>(); if ( attributesNode != null ) { List<Node> groupNodes = XMLHandler.getNodes( attributesNode, XML_TAG_GROUP ); for ( Node groupNode : groupNodes ) { String groupName = XMLHandler.getTagValue( groupNode, "name" ); Map<String, String> attributes = new HashMap<>(); attributesMap.put( groupName, attributes ); List<Node> attributeNodes = XMLHandler.getNodes( groupNode, XML_TAG_ATTRIBUTE ); for ( Node attributeNode : attributeNodes ) { String key = XMLHandler.getTagValue( attributeNode, "key" ); String value = XMLHandler.getTagValue( attributeNode, "value" ); if ( key != null && value != null ) { attributes.put( key, value ); } } } } return attributesMap; }
Example 2
Source File: DimensionTableDialog.java From pentaho-kettle with Apache License 2.0 | 6 votes |
private void addAttributesFromFile(String filename) throws KettleException { InputStream inputStream = getClass().getResourceAsStream(filename); Document document = XMLHandler.loadXMLFile(inputStream); Node attributesNode = XMLHandler.getSubNode(document, "attributes"); List<Node> attributeNodes = XMLHandler.getNodes(attributesNode, "attribute"); for (Node node : attributeNodes) { String name = XMLHandler.getTagValue(node, "name"); String description = XMLHandler.getTagValue(node, "description"); String phName = XMLHandler.getTagValue(node, "physicalname"); AttributeType attributeType= AttributeType.getAttributeType(XMLHandler.getTagValue(node, "attribute_type")); DataType dataType= ConceptUtil.getDataType(XMLHandler.getTagValue(node, "data_type")); int length = Const.toInt(XMLHandler.getTagValue(node, "length"), -1); int precision = Const.toInt(XMLHandler.getTagValue(node, "precision"), -1); // String sourceDb = XMLHandler.getTagValue(node, "source_db"); // String sourceTable = XMLHandler.getTagValue(node, "source_table"); // String sourceColumn = XMLHandler.getTagValue(node, "source_column"); String remarks = XMLHandler.getTagValue(node, "remarks"); addAttribute(name, description, phName, attributeType, dataType, length, precision, remarks); } }
Example 3
Source File: BeamBQInputMeta.java From kettle-beam with Apache License 2.0 | 6 votes |
@Override public void loadXML( Node stepNode, List<DatabaseMeta> databases, IMetaStore metaStore ) throws KettleXMLException { projectId = XMLHandler.getTagValue( stepNode, PROJECT_ID ); datasetId = XMLHandler.getTagValue( stepNode, DATASET_ID ); tableId = XMLHandler.getTagValue( stepNode, TABLE_ID ); query = XMLHandler.getTagValue( stepNode, QUERY ); Node fieldsNode = XMLHandler.getSubNode( stepNode, "fields" ); List<Node> fieldNodes = XMLHandler.getNodes( fieldsNode, "field" ); fields = new ArrayList<>(); for ( Node fieldNode : fieldNodes ) { String name = XMLHandler.getTagValue( fieldNode, "name" ); String newName = XMLHandler.getTagValue( fieldNode, "new_name" ); String kettleType = XMLHandler.getTagValue( fieldNode, "type" ); fields.add( new BQField( name, newName, kettleType ) ); } }
Example 4
Source File: BaseStepMeta.java From pentaho-kettle with Apache License 2.0 | 6 votes |
/** * Load step attributes. * * @throws KettleException the kettle exception */ protected void loadStepAttributes() throws KettleException { try ( InputStream inputStream = getClass().getResourceAsStream( STEP_ATTRIBUTES_FILE ) ) { if ( inputStream != null ) { Document document = XMLHandler.loadXMLFile( inputStream ); Node attrsNode = XMLHandler.getSubNode( document, "attributes" ); List<Node> nodes = XMLHandler.getNodes( attrsNode, "attribute" ); attributes = new ArrayList<KettleAttributeInterface>(); for ( Node node : nodes ) { String key = XMLHandler.getTagAttribute( node, "id" ); String xmlCode = XMLHandler.getTagValue( node, "xmlcode" ); String repCode = XMLHandler.getTagValue( node, "repcode" ); String description = XMLHandler.getTagValue( node, "description" ); String tooltip = XMLHandler.getTagValue( node, "tooltip" ); int valueType = ValueMetaFactory.getIdForValueMeta( XMLHandler.getTagValue( node, "valuetype" ) ); String parentId = XMLHandler.getTagValue( node, "parentid" ); KettleAttribute attribute = new KettleAttribute( key, xmlCode, repCode, description, tooltip, valueType, findParent( attributes, parentId ) ); attributes.add( attribute ); } } } catch ( Exception e ) { throw new KettleException( "Unable to load file " + STEP_ATTRIBUTES_FILE, e ); } }
Example 5
Source File: PentahoReportingOutputMeta.java From pentaho-kettle with Apache License 2.0 | 6 votes |
private void readData( Node stepnode ) throws KettleXMLException { try { inputFileField = XMLHandler.getTagValue( stepnode, "input_file_field" ); outputFileField = XMLHandler.getTagValue( stepnode, "output_file_field" ); createParentfolder = "Y".equals( XMLHandler.getTagValue( stepnode, "create_parent_folder" ) ); parameterFieldMap = new HashMap<String, String>(); Node parsNode = XMLHandler.getSubNode( stepnode, XML_TAG_PARAMETERS ); List<Node> nodes = XMLHandler.getNodes( parsNode, XML_TAG_PARAMETER ); for ( Node node : nodes ) { String parameter = XMLHandler.getTagValue( node, "name" ); String fieldname = XMLHandler.getTagValue( node, "field" ); if ( !Utils.isEmpty( parameter ) && !Utils.isEmpty( fieldname ) ) { parameterFieldMap.put( parameter, fieldname ); } } outputProcessorType = ProcessorType.getProcessorTypeByCode( XMLHandler.getTagValue( stepnode, "processor_type" ) ); } catch ( Exception e ) { throw new KettleXMLException( BaseMessages.getString( PKG, "PentahoReportingOutputMeta.Exception.UnableToLoadStepInfo" ), e ); } }
Example 6
Source File: ImportRules.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public void loadXML( Node rulesNode ) throws KettleException { List<Node> ruleNodes = XMLHandler.getNodes( rulesNode, BaseImportRule.XML_TAG ); for ( Node ruleNode : ruleNodes ) { String id = XMLHandler.getTagValue( ruleNode, "id" ); PluginRegistry registry = PluginRegistry.getInstance(); PluginInterface plugin = registry.findPluginWithId( ImportRulePluginType.class, id ); if ( plugin == null ) { throw new KettleException( "The import rule of type '" + id + "' could not be found in the plugin registry." ); } ImportRuleInterface rule = (ImportRuleInterface) registry.loadClass( plugin ); rule.loadXML( ruleNode ); getRules().add( rule ); } }
Example 7
Source File: GraphOutputMeta.java From knowbi-pentaho-pdi-neo4j-output with Apache License 2.0 | 6 votes |
@Override public void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ) throws KettleXMLException { connectionName = XMLHandler.getTagValue( stepnode, CONNECTION ); model = XMLHandler.getTagValue( stepnode, MODEL ); batchSize = XMLHandler.getTagValue( stepnode, BATCH_SIZE ); creatingIndexes = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, CREATE_INDEXES ) ); returningGraph = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, RETURNING_GRAPH ) ); returnGraphField = XMLHandler.getTagValue( stepnode, RETURN_GRAPH_FIELD ); validatingAgainstModel = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, VALIDATE_AGAINST_MODEL ) ); // Parse parameter mappings // Node mappingsNode = XMLHandler.getSubNode( stepnode, MAPPINGS ); List<Node> mappingNodes = XMLHandler.getNodes( mappingsNode, MAPPING ); fieldModelMappings = new ArrayList<>(); for ( Node mappingNode : mappingNodes ) { String field = XMLHandler.getTagValue( mappingNode, SOURCE_FIELD ); ModelTargetType targetType = ModelTargetType.parseCode( XMLHandler.getTagValue( mappingNode, TARGET_TYPE ) ); String targetName = XMLHandler.getTagValue( mappingNode, TARGET_NAME ); String targetProperty = XMLHandler.getTagValue( mappingNode, TARGET_PROPERTY ); fieldModelMappings.add( new FieldModelMapping( field, targetType, targetName, targetProperty ) ); } super.loadXML( stepnode, databases, metaStore ); }
Example 8
Source File: BeamConsumeMeta.java From kettle-beam with Apache License 2.0 | 6 votes |
@Override public void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ) throws KettleXMLException { bootstrapServers = XMLHandler.getTagValue( stepnode, BOOTSTRAP_SERVERS ); topics = XMLHandler.getTagValue( stepnode, TOPICS ); keyField = XMLHandler.getTagValue( stepnode, KEY_FIELD ); messageField = XMLHandler.getTagValue( stepnode, MESSAGE_FIELD ); groupId = XMLHandler.getTagValue( stepnode, GROUP_ID ); usingProcessingTime="Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, USE_PROCESSING_TIME ) ); usingLogAppendTime="Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, USE_LOG_APPEND_TIME ) ); usingCreateTime="Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, USE_CREATE_TIME ) ); restrictedToCommitted="Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, RESTRICT_TO_COMMITTED ) ); allowingCommitOnConsumedOffset="Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, ALLOW_COMMIT_ON_CONSUMED ) ); configOptions = new ArrayList<>( ); Node optionsNode = XMLHandler.getSubNode( stepnode, CONFIG_OPTIONS ); List<Node> optionNodes = XMLHandler.getNodes( optionsNode, CONFIG_OPTION ); for (Node optionNode : optionNodes) { String parameter = XMLHandler.getTagValue( optionNode, CONFIG_OPTION_PARAMETER ); String value = XMLHandler.getTagValue( optionNode, CONFIG_OPTION_VALUE ); ConfigOption.Type type = ConfigOption.Type.getTypeFromName( XMLHandler.getTagValue( optionNode, CONFIG_OPTION_TYPE ) ); configOptions.add( new ConfigOption(parameter, value, type)); } }
Example 9
Source File: StepStatus.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public StepStatus( Node node ) throws KettleException { stepname = XMLHandler.getTagValue( node, "stepname" ); copy = Integer.parseInt( XMLHandler.getTagValue( node, "copy" ) ); linesRead = Long.parseLong( XMLHandler.getTagValue( node, "linesRead" ) ); linesWritten = Long.parseLong( XMLHandler.getTagValue( node, "linesWritten" ) ); linesInput = Long.parseLong( XMLHandler.getTagValue( node, "linesInput" ) ); linesOutput = Long.parseLong( XMLHandler.getTagValue( node, "linesOutput" ) ); linesUpdated = Long.parseLong( XMLHandler.getTagValue( node, "linesUpdated" ) ); linesRejected = Long.parseLong( XMLHandler.getTagValue( node, "linesRejected" ) ); errors = Long.parseLong( XMLHandler.getTagValue( node, "errors" ) ); statusDescription = XMLHandler.getTagValue( node, "statusDescription" ); seconds = Double.parseDouble( XMLHandler.getTagValue( node, "seconds" ) ); speed = XMLHandler.getTagValue( node, "speed" ); priority = XMLHandler.getTagValue( node, "priority" ); stopped = "Y".equalsIgnoreCase( XMLHandler.getTagValue( node, "stopped" ) ); paused = "Y".equalsIgnoreCase( XMLHandler.getTagValue( node, "paused" ) ); Node samplesNode = XMLHandler.getSubNode( node, "samples" ); if ( samplesNode != null ) { Node rowMetaNode = XMLHandler.getSubNode( samplesNode, RowMeta.XML_META_TAG ); if ( rowMetaNode != null ) { sampleRowMeta = new RowMeta( rowMetaNode ); sampleRows = new ArrayList<Object[]>(); List<Node> dataNodes = XMLHandler.getNodes( samplesNode, RowMeta.XML_DATA_TAG ); for ( Node dataNode : dataNodes ) { Object[] sampleRow = sampleRowMeta.getRow( dataNode ); sampleRows.add( sampleRow ); } } } }
Example 10
Source File: CheckConnections.java From knowbi-pentaho-pdi-neo4j-output with Apache License 2.0 | 5 votes |
@Override public void loadXML( Node node, List<DatabaseMeta> databases, List<SlaveServer> slaveServers, Repository rep, IMetaStore metaStore ) throws KettleXMLException { super.loadXML( node, databases, slaveServers ); connectionNames = new ArrayList<>(); Node connectionsNode = XMLHandler.getSubNode( node, "connections" ); List<Node> connectionNodes = XMLHandler.getNodes( connectionsNode, "connection" ); for ( Node connectionNode : connectionNodes ) { String connectionName = XMLHandler.getNodeValue( connectionNode ); connectionNames.add( connectionName ); } }
Example 11
Source File: PDI_11319Test.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private Node getNullIfStep( Node doc ) { Node trans = XMLHandler.getSubNode( doc, "transformation" ); List<Node> steps = XMLHandler.getNodes( trans, "step" ); Node nullIfStep = null; for ( Node step : steps ) { if ( "IfNull".equals( XMLHandler.getNodeValue( XMLHandler.getSubNode( step, "type" ) ) ) ) { nullIfStep = step; break; } } return nullIfStep; }
Example 12
Source File: UserDefinedJavaClassCodeSnippits.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private void buildSnippitList( Document doc ) { List<Node> nodes = XMLHandler.getNodes( XMLHandler.getSubNode( doc, "codeSnippits" ), "codeSnippit" ); for ( Node node : nodes ) { Snippit snippit = new Snippit( Category.valueOf( XMLHandler.getTagValue( node, "category" ) ), XMLHandler.getTagValue( node, "name" ), XMLHandler.getTagValue( node, "sample" ), XMLHandler.getTagValue( node, "code" ) ); snippits.add( snippit ); Snippit oldSnippit = snippitsMap.put( snippit.name, snippit ); if ( oldSnippit != null ) { log.logError( "Multiple code snippits for name: " + snippit.name ); } } }
Example 13
Source File: BasePluginType.java From pentaho-kettle with Apache License 2.0 | 5 votes |
/** * This method registers plugins from the InputStream with the XML Resource * * @param inputStream * @throws KettlePluginException * @throws KettleXMLException */ protected void registerPlugins( InputStream inputStream ) throws KettlePluginException, KettleXMLException { Document document = XMLHandler.loadXMLFile( inputStream, null, true, false ); Node repsNode = XMLHandler.getSubNode( document, getMainTag() ); List<Node> repsNodes = XMLHandler.getNodes( repsNode, getSubTag() ); for ( Node repNode : repsNodes ) { registerPluginFromXmlResource( repNode, getPath(), this.getClass(), true, null ); } }
Example 14
Source File: JsonInputMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private static boolean getDefaultPathLeafToNull( Node stepnode ) { boolean result = true; List<Node> nodes = XMLHandler.getNodes( stepnode, "defaultPathLeafToNull" ); if ( nodes != null && nodes.size() > 0 ) { result = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "defaultPathLeafToNull" ) ); } return result; }
Example 15
Source File: StreamToNodeConvertersPrivateDatabasesTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private void assertDatabaseNodes( InputStream stream, String... names ) throws Exception { if ( names == null ) { names = new String[0]; } Document document = XMLHandler.loadXMLFile( stream, null, false, false ); Node metaNode = XMLHandler.getSubNode( document, metaTag ); List<Node> nodes = XMLHandler.getNodes( metaNode, DatabaseMeta.XML_TAG ); assertNodes( nodes, names ); }
Example 16
Source File: SlaveServerConfig.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public SlaveServerConfig( LogChannelInterface log, Node node ) throws KettleXMLException { this(); Node slaveNode = XMLHandler.getSubNode( node, SlaveServer.XML_TAG ); if ( slaveNode != null ) { slaveServer = new SlaveServer( slaveNode ); checkNetworkInterfaceSetting( log, slaveNode, slaveServer ); } Node mastersNode = XMLHandler.getSubNode( node, XML_TAG_MASTERS ); int nrMasters = XMLHandler.countNodes( mastersNode, SlaveServer.XML_TAG ); for ( int i = 0; i < nrMasters; i++ ) { Node masterSlaveNode = XMLHandler.getSubNodeByNr( mastersNode, SlaveServer.XML_TAG, i ); SlaveServer masterSlaveServer = new SlaveServer( masterSlaveNode ); checkNetworkInterfaceSetting( log, masterSlaveNode, masterSlaveServer ); masterSlaveServer.setSslMode( slaveServer.isSslMode() ); masters.add( masterSlaveServer ); } reportingToMasters = "Y".equalsIgnoreCase( XMLHandler.getTagValue( node, "report_to_masters" ) ); joining = "Y".equalsIgnoreCase( XMLHandler.getTagValue( node, "joining" ) ); maxLogLines = Const.toInt( XMLHandler.getTagValue( node, "max_log_lines" ), 0 ); maxLogTimeoutMinutes = Const.toInt( XMLHandler.getTagValue( node, "max_log_timeout_minutes" ), 0 ); objectTimeoutMinutes = Const.toInt( XMLHandler.getTagValue( node, "object_timeout_minutes" ), 0 ); // Read sequence information // List<Node> dbNodes = XMLHandler.getNodes( node, DatabaseMeta.XML_TAG ); for ( Node dbNode : dbNodes ) { databases.add( new DatabaseMeta( dbNode ) ); } Node sequencesNode = XMLHandler.getSubNode( node, "sequences" ); List<Node> seqNodes = XMLHandler.getNodes( sequencesNode, SlaveSequence.XML_TAG ); for ( Node seqNode : seqNodes ) { slaveSequences.add( new SlaveSequence( seqNode, databases ) ); } Node autoSequenceNode = XMLHandler.getSubNode( node, XML_TAG_AUTOSEQUENCE ); if ( autoSequenceNode != null ) { autoSequence = new SlaveSequence( autoSequenceNode, databases ); automaticCreationAllowed = "Y".equalsIgnoreCase( XMLHandler.getTagValue( autoSequenceNode, XML_TAG_AUTO_CREATE ) ); } // Set Jetty Options setUpJettyOptions( node ); Node repositoryNode = XMLHandler.getSubNode( node, XML_TAG_REPOSITORY ); repositoryId = XMLHandler.getTagValue( repositoryNode, "name" ); repositoryUsername = XMLHandler.getTagValue( repositoryNode, "username" ); repositoryPassword = XMLHandler.getTagValue( repositoryNode, "password" ); }
Example 17
Source File: DatabaseMeta.java From pentaho-kettle with Apache License 2.0 | 4 votes |
/** * Reads the information from an XML Node into this new database connection. * * @param con * The Node to read the data from * @throws KettleXMLException */ public DatabaseMeta( Node con ) throws KettleXMLException { this(); try { String type = XMLHandler.getTagValue( con, "type" ); try { databaseInterface = getDatabaseInterface( type ); } catch ( KettleDatabaseException kde ) { throw new KettleXMLException( "Unable to create new database interface", kde ); } setName( XMLHandler.getTagValue( con, "name" ) ); setDisplayName( getName() ); setHostname( XMLHandler.getTagValue( con, "server" ) ); String acc = XMLHandler.getTagValue( con, "access" ); setAccessType( getAccessType( acc ) ); setDBName( XMLHandler.getTagValue( con, "database" ) ); // The DB port is read here too for backward compatibility! getName() // setDBPort( XMLHandler.getTagValue( con, "port" ) ); setUsername( XMLHandler.getTagValue( con, "username" ) ); setPassword( Encr.decryptPasswordOptionallyEncrypted( XMLHandler.getTagValue( con, "password" ) ) ); setServername( XMLHandler.getTagValue( con, "servername" ) ); setDataTablespace( XMLHandler.getTagValue( con, "data_tablespace" ) ); setIndexTablespace( XMLHandler.getTagValue( con, "index_tablespace" ) ); setReadOnly( Boolean.valueOf( XMLHandler.getTagValue( con, "read_only" ) ) ); // Also, read the database attributes... Node attrsnode = XMLHandler.getSubNode( con, "attributes" ); if ( attrsnode != null ) { List<Node> attrnodes = XMLHandler.getNodes( attrsnode, "attribute" ); for ( Node attrnode : attrnodes ) { String code = XMLHandler.getTagValue( attrnode, "code" ); String attribute = XMLHandler.getTagValue( attrnode, "attribute" ); if ( code != null && attribute != null ) { databaseInterface.addAttribute( code, attribute ); } getDatabasePortNumberString(); } } } catch ( Exception e ) { throw new KettleXMLException( "Unable to load database connection info from XML node", e ); } }
Example 18
Source File: Result.java From pentaho-kettle with Apache License 2.0 | 4 votes |
/** * Instantiates a new Result object from a DOM node * * @param node * the DOM root node representing the desired Result * @throws KettleException * if any errors occur during instantiation */ public Result( Node node ) throws KettleException { this(); // First we read the metrics... // nrLinesInput = Const.toLong( XMLHandler.getTagValue( node, "lines_input" ), 0L ); nrLinesOutput = Const.toLong( XMLHandler.getTagValue( node, "lines_output" ), 0L ); nrLinesRead = Const.toLong( XMLHandler.getTagValue( node, "lines_read" ), 0L ); nrLinesWritten = Const.toLong( XMLHandler.getTagValue( node, "lines_written" ), 0L ); nrLinesUpdated = Const.toLong( XMLHandler.getTagValue( node, "lines_updated" ), 0L ); nrLinesRejected = Const.toLong( XMLHandler.getTagValue( node, "lines_rejected" ), 0L ); nrLinesDeleted = Const.toLong( XMLHandler.getTagValue( node, "lines_deleted" ), 0L ); nrErrors = Const.toLong( XMLHandler.getTagValue( node, "nr_errors" ), 0L ); nrFilesRetrieved = Const.toLong( XMLHandler.getTagValue( node, "nr_files_retrieved" ), 0L ); entryNr = Const.toLong( XMLHandler.getTagValue( node, "entry_nr" ), 0L ); // The high level results... // result = "Y".equalsIgnoreCase( XMLHandler.getTagValue( node, "result" ) ); exitStatus = Integer.parseInt( XMLHandler.getTagValue( node, "exit_status" ) ); stopped = "Y".equalsIgnoreCase( XMLHandler.getTagValue( node, "is_stopped" ) ); logChannelId = XMLHandler.getTagValue( node, "log_channel_id" ); logText = XMLHandler.getTagValue( node, "log_text" ); elapsedTimeMillis = Const.toLong( XMLHandler.getTagValue( node, "elapsedTimeMillis" ), 0L ); executionId = XMLHandler.getTagValue( node, "executionId" ); // Now read back the result files... // Node resultFilesNode = XMLHandler.getSubNode( node, XML_FILES_TAG ); int nrResultFiles = XMLHandler.countNodes( resultFilesNode, XML_FILE_TAG ); for ( int i = 0; i < nrResultFiles; i++ ) { try { ResultFile resultFile = new ResultFile( XMLHandler.getSubNodeByNr( resultFilesNode, XML_FILE_TAG, i ) ); resultFiles.put( resultFile.getFile().toString(), resultFile ); } catch ( KettleFileException e ) { throw new KettleException( "Unexpected error reading back a ResultFile object from XML", e ); } } // Let's also read back the result rows... // Node resultRowsNode = XMLHandler.getSubNode( node, XML_ROWS_TAG ); List<Node> resultNodes = XMLHandler.getNodes( resultRowsNode, RowMeta.XML_DATA_TAG ); if ( !resultNodes.isEmpty() ) { // OK, get the metadata first... // RowMeta rowMeta = new RowMeta( XMLHandler.getSubNode( resultRowsNode, RowMeta.XML_META_TAG ) ); for ( Node resultNode : resultNodes ) { Object[] rowData = rowMeta.getRow( resultNode ); rows.add( new RowMetaAndData( rowMeta, rowData ) ); } } }
Example 19
Source File: MetaInjectMeta.java From pentaho-kettle with Apache License 2.0 | 4 votes |
@Override public void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ) throws KettleXMLException { try { String method = XMLHandler.getTagValue( stepnode, SPECIFICATION_METHOD ); specificationMethod = ObjectLocationSpecificationMethod.getSpecificationMethodByCode( method ); String transId = XMLHandler.getTagValue( stepnode, TRANS_OBJECT_ID ); transObjectId = Utils.isEmpty( transId ) ? null : new StringObjectId( transId ); transName = XMLHandler.getTagValue( stepnode, TRANS_NAME ); fileName = XMLHandler.getTagValue( stepnode, FILENAME ); directoryPath = XMLHandler.getTagValue( stepnode, DIRECTORY_PATH ); sourceStepName = XMLHandler.getTagValue( stepnode, SOURCE_STEP ); Node outputFieldsNode = XMLHandler.getSubNode( stepnode, SOURCE_OUTPUT_FIELDS ); List<Node> outputFieldNodes = XMLHandler.getNodes( outputFieldsNode, SOURCE_OUTPUT_FIELD ); sourceOutputFields = new ArrayList<MetaInjectOutputField>(); for ( Node outputFieldNode : outputFieldNodes ) { String name = XMLHandler.getTagValue( outputFieldNode, SOURCE_OUTPUT_FIELD_NAME ); String typeName = XMLHandler.getTagValue( outputFieldNode, SOURCE_OUTPUT_FIELD_TYPE ); int length = Const.toInt( XMLHandler.getTagValue( outputFieldNode, SOURCE_OUTPUT_FIELD_LENGTH ), -1 ); int precision = Const.toInt( XMLHandler.getTagValue( outputFieldNode, SOURCE_OUTPUT_FIELD_PRECISION ), -1 ); int type = ValueMetaFactory.getIdForValueMeta( typeName ); sourceOutputFields.add( new MetaInjectOutputField( name, type, length, precision ) ); } targetFile = XMLHandler.getTagValue( stepnode, TARGET_FILE ); noExecution = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, NO_EXECUTION ) ); streamSourceStepname = XMLHandler.getTagValue( stepnode, STREAM_SOURCE_STEP ); streamTargetStepname = XMLHandler.getTagValue( stepnode, STREAM_TARGET_STEP ); Node mappingsNode = XMLHandler.getSubNode( stepnode, MAPPINGS ); int nrMappings = XMLHandler.countNodes( mappingsNode, MAPPING ); for ( int i = 0; i < nrMappings; i++ ) { Node mappingNode = XMLHandler.getSubNodeByNr( mappingsNode, MAPPING, i ); String targetStepname = XMLHandler.getTagValue( mappingNode, TARGET_STEP_NAME ); String targetAttributeKey = XMLHandler.getTagValue( mappingNode, TARGET_ATTRIBUTE_KEY ); boolean targetDetail = "Y".equalsIgnoreCase( XMLHandler.getTagValue( mappingNode, TARGET_DETAIL ) ); String sourceStepname = XMLHandler.getTagValue( mappingNode, SOURCE_STEP ); String sourceField = XMLHandler.getTagValue( mappingNode, SOURCE_FIELD ); TargetStepAttribute target = new TargetStepAttribute( targetStepname, targetAttributeKey, targetDetail ); SourceStepField source = new SourceStepField( sourceStepname, sourceField ); targetSourceMapping.put( target, source ); } MetaInjectMigration.migrateFrom70( targetSourceMapping ); } catch ( Exception e ) { throw new KettleXMLException( "Unable to load step info from XML", e ); } }