Java Code Examples for org.pentaho.di.core.xml.XMLHandler#getNodeValue()
The following examples show how to use
org.pentaho.di.core.xml.XMLHandler#getNodeValue() .
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: XMLInputSaxField.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public XMLInputSaxField( Node fnode ) throws KettleValueException { setName( XMLHandler.getTagValue( fnode, "name" ) ); setType( ValueMeta.getType( XMLHandler.getTagValue( fnode, "type" ) ) ); setFormat( XMLHandler.getTagValue( fnode, "format" ) ); setCurrencySymbol( XMLHandler.getTagValue( fnode, "currency" ) ); setDecimalSymbol( XMLHandler.getTagValue( fnode, "decimal" ) ); setGroupSymbol( XMLHandler.getTagValue( fnode, "group" ) ); setLength( Const.toInt( XMLHandler.getTagValue( fnode, "length" ), -1 ) ); setPrecision( Const.toInt( XMLHandler.getTagValue( fnode, "precision" ), -1 ) ); setTrimType( getTrimType( XMLHandler.getTagValue( fnode, "trim_type" ) ) ); setRepeated( !"N".equalsIgnoreCase( XMLHandler.getTagValue( fnode, "repeat" ) ) ); Node positions = XMLHandler.getSubNode( fnode, "positions" ); int nrPositions = XMLHandler.countNodes( positions, "position" ); fieldPosition = new XMLInputSaxFieldPosition[nrPositions]; for ( int i = 0; i < nrPositions; i++ ) { Node positionnode = XMLHandler.getSubNodeByNr( positions, "position", i ); String encoded = XMLHandler.getNodeValue( positionnode ); fieldPosition[i] = new XMLInputSaxFieldPosition( encoded ); } }
Example 2
Source File: ClusterSchema.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public ClusterSchema( Node clusterSchemaNode, List<SlaveServer> referenceSlaveServers ) { this(); name = XMLHandler.getTagValue( clusterSchemaNode, "name" ); basePort = XMLHandler.getTagValue( clusterSchemaNode, "base_port" ); socketsBufferSize = XMLHandler.getTagValue( clusterSchemaNode, "sockets_buffer_size" ); socketsFlushInterval = XMLHandler.getTagValue( clusterSchemaNode, "sockets_flush_interval" ); socketsCompressed = "Y".equalsIgnoreCase( XMLHandler.getTagValue( clusterSchemaNode, "sockets_compressed" ) ); dynamic = "Y".equalsIgnoreCase( XMLHandler.getTagValue( clusterSchemaNode, "dynamic" ) ); Node slavesNode = XMLHandler.getSubNode( clusterSchemaNode, "slaveservers" ); int nrSlaves = XMLHandler.countNodes( slavesNode, "name" ); for ( int i = 0; i < nrSlaves; i++ ) { Node serverNode = XMLHandler.getSubNodeByNr( slavesNode, "name", i ); String serverName = XMLHandler.getNodeValue( serverNode ); SlaveServer slaveServer = SlaveServer.findSlaveServer( referenceSlaveServers, serverName ); if ( slaveServer != null ) { slaveServers.add( slaveServer ); } } }
Example 3
Source File: RssInputMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private void readData( Node stepnode ) throws KettleXMLException { try { urlInField = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "url_in_field" ) ); urlFieldname = XMLHandler.getTagValue( stepnode, "url_field_name" ); includeRowNumber = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "rownum" ) ); rowNumberField = XMLHandler.getTagValue( stepnode, "rownum_field" ); includeUrl = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "include_url" ) ); urlField = XMLHandler.getTagValue( stepnode, "url_Field" ); readfrom = XMLHandler.getTagValue( stepnode, "read_from" ); Node fields = XMLHandler.getSubNode( stepnode, "fields" ); int nrFields = XMLHandler.countNodes( fields, "field" ); Node urlnode = XMLHandler.getSubNode( stepnode, "urls" ); int nrUrls = XMLHandler.countNodes( urlnode, "url" ); allocate( nrUrls, nrFields ); for ( int i = 0; i < nrUrls; i++ ) { Node urlnamenode = XMLHandler.getSubNodeByNr( urlnode, "url", i ); url[i] = XMLHandler.getNodeValue( urlnamenode ); } for ( int i = 0; i < nrFields; i++ ) { Node fnode = XMLHandler.getSubNodeByNr( fields, "field", i ); RssInputField field = new RssInputField( fnode ); inputFields[i] = field; } // Is there a limit on the number of rows we process? rowLimit = Const.toLong( XMLHandler.getTagValue( stepnode, "limit" ), 0L ); } catch ( Exception e ) { throw new KettleXMLException( "Unable to load step info from XML", e ); } }
Example 4
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 5
Source File: MQLQueryImpl.java From pentaho-metadata with GNU Lesser General Public License v2.1 | 5 votes |
protected void addOrderByFromXmlNode( Element orderElement ) throws PentahoMetadataException { boolean ascending = true; String view_id = null; String column_id = null; String aggregation = null; NodeList nodes = orderElement.getElementsByTagName( "direction" ); //$NON-NLS-1$ if ( nodes.getLength() > 0 ) { ascending = XMLHandler.getNodeValue( nodes.item( 0 ) ).equals( "asc" ); //$NON-NLS-1$ } nodes = orderElement.getElementsByTagName( "view_id" ); //$NON-NLS-1$ if ( nodes.getLength() > 0 ) { view_id = XMLHandler.getNodeValue( nodes.item( 0 ) ); } nodes = orderElement.getElementsByTagName( "column_id" ); //$NON-NLS-1$ if ( nodes.getLength() > 0 ) { column_id = XMLHandler.getNodeValue( nodes.item( 0 ) ); } nodes = orderElement.getElementsByTagName( "aggregation" ); //$NON-NLS-1$ if ( nodes.getLength() > 0 ) { aggregation = XMLHandler.getNodeValue( nodes.item( 0 ) ); } if ( ( view_id != null ) && ( column_id != null ) ) { addOrderBy( view_id, column_id, aggregation, ascending ); } }
Example 6
Source File: GetRepositoryNamesMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ) throws KettleXMLException { try { String objectTypeString = XMLHandler.getTagValue( stepnode, "object_type" ); if ( objectTypeString != null ) { objectTypeSelection = ObjectTypeSelection.valueOf( objectTypeString ); } if ( objectTypeSelection == null ) { objectTypeSelection = ObjectTypeSelection.All; } includeRowNumber = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "rownum" ) ); rowNumberField = XMLHandler.getTagValue( stepnode, "rownum_field" ); Node filenode = XMLHandler.getSubNode( stepnode, "file" ); int nrfiles = XMLHandler.countNodes( filenode, "directory" ); allocate( nrfiles ); for ( int i = 0; i < nrfiles; i++ ) { Node filenamenode = XMLHandler.getSubNodeByNr( filenode, "directory", i ); Node filemasknode = XMLHandler.getSubNodeByNr( filenode, "name_mask", i ); Node excludefilemasknode = XMLHandler.getSubNodeByNr( filenode, "exclude_name_mask", i ); Node includeSubFoldersnode = XMLHandler.getSubNodeByNr( filenode, "include_subfolders", i ); directory[i] = XMLHandler.getNodeValue( filenamenode ); nameMask[i] = XMLHandler.getNodeValue( filemasknode ); excludeNameMask[i] = XMLHandler.getNodeValue( excludefilemasknode ); includeSubFolders[i] = "Y".equalsIgnoreCase( XMLHandler.getNodeValue( includeSubFoldersnode ) ); } } catch ( Exception e ) { throw new KettleXMLException( "Unable to load step info from XML", e ); } }
Example 7
Source File: SecurityService.java From pentaho-metadata with GNU Lesser General Public License v2.1 | 5 votes |
public List<String> getUsers() { List<String> users = new ArrayList<String>(); if ( hasService() || hasFile() ) { try { if ( getDetailServiceType() == SecurityService.SERVICE_TYPE_USERS || getDetailServiceType() == SERVICE_TYPE_ALL ) { String url = getURL( serviceTypeCodes[SERVICE_TYPE_USERS] ); Node contentNode = getContent( url ); String usersNode = "users"; if ( serviceURL.endsWith( "ServiceAction" ) ) { contentNode = XMLHandler.getSubNode( contentNode, usersNode ); //$NON-NLS-1$ usersNode = "user"; } // Load the users int nrUsers = XMLHandler.countNodes( contentNode, usersNode ); //$NON-NLS-1$ for ( int i = 0; i < nrUsers; i++ ) { Node userNode = XMLHandler.getSubNodeByNr( contentNode, usersNode, i ); //$NON-NLS-1$ String username = XMLHandler.getNodeValue( userNode ); if ( username != null ) { users.add( username ); } } } } catch ( PentahoMetadataException ex ) { log.logError( Messages.getString( "SecurityReference.ERROR_0001_CANT_CREATE_REFERENCE_FROM_XML" ), ex ); //$NON-NLS-1$ } catch ( Exception e ) { log.logError( Messages.getString( "SecurityReference.ERROR_0001_CANT_CREATE_REFERENCE_FROM_XML" ), e ); //$NON-NLS-1$ } } return users; }
Example 8
Source File: GetFileNamesMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private void readData( Node stepnode ) throws KettleXMLException { try { Node filternode = XMLHandler.getSubNode( stepnode, "filter" ); Node filterfiletypenode = XMLHandler.getSubNode( filternode, "filterfiletype" ); fileTypeFilter = FileInputList.FileTypeFilter.getByName( XMLHandler.getNodeValue( filterfiletypenode ) ); doNotFailIfNoFile = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "doNotFailIfNoFile" ) ); includeRowNumber = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "rownum" ) ); isaddresult = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "isaddresult" ) ); filefield = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "filefield" ) ); rowNumberField = XMLHandler.getTagValue( stepnode, "rownum_field" ); dynamicFilenameField = XMLHandler.getTagValue( stepnode, "filename_Field" ); dynamicWildcardField = XMLHandler.getTagValue( stepnode, "wildcard_Field" ); dynamicExcludeWildcardField = XMLHandler.getTagValue( stepnode, "exclude_wildcard_Field" ); dynamicIncludeSubFolders = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "dynamic_include_subfolders" ) ); // Is there a limit on the number of rows we process? rowLimit = Const.toLong( XMLHandler.getTagValue( stepnode, "limit" ), 0L ); Node filenode = XMLHandler.getSubNode( stepnode, "file" ); int nrfiles = XMLHandler.countNodes( filenode, "name" ); allocate( nrfiles ); for ( int i = 0; i < nrfiles; i++ ) { Node filenamenode = XMLHandler.getSubNodeByNr( filenode, "name", i ); Node filemasknode = XMLHandler.getSubNodeByNr( filenode, "filemask", i ); Node excludefilemasknode = XMLHandler.getSubNodeByNr( filenode, "exclude_filemask", i ); Node fileRequirednode = XMLHandler.getSubNodeByNr( filenode, "file_required", i ); Node includeSubFoldersnode = XMLHandler.getSubNodeByNr( filenode, "include_subfolders", i ); fileName[i] = XMLHandler.getNodeValue( filenamenode ); fileMask[i] = XMLHandler.getNodeValue( filemasknode ); excludeFileMask[i] = XMLHandler.getNodeValue( excludefilemasknode ); fileRequired[i] = XMLHandler.getNodeValue( fileRequirednode ); includeSubFolders[i] = XMLHandler.getNodeValue( includeSubFoldersnode ); } } catch ( Exception e ) { throw new KettleXMLException( "Unable to load step info from XML", e ); } }
Example 9
Source File: MergeRowsMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private void readData( Node stepnode ) throws KettleXMLException { try { Node keysnode = XMLHandler.getSubNode( stepnode, "keys" ); Node valuesnode = XMLHandler.getSubNode( stepnode, "values" ); int nrKeys = XMLHandler.countNodes( keysnode, "key" ); int nrValues = XMLHandler.countNodes( valuesnode, "value" ); allocate( nrKeys, nrValues ); for ( int i = 0; i < nrKeys; i++ ) { Node keynode = XMLHandler.getSubNodeByNr( keysnode, "key", i ); keyFields[i] = XMLHandler.getNodeValue( keynode ); } for ( int i = 0; i < nrValues; i++ ) { Node valuenode = XMLHandler.getSubNodeByNr( valuesnode, "value", i ); valueFields[i] = XMLHandler.getNodeValue( valuenode ); } flagField = XMLHandler.getTagValue( stepnode, "flag_field" ); List<StreamInterface> infoStreams = getStepIOMeta().getInfoStreams(); StreamInterface referenceStream = infoStreams.get( 0 ); StreamInterface compareStream = infoStreams.get( 1 ); compareStream.setSubject( XMLHandler.getTagValue( stepnode, "compare" ) ); referenceStream.setSubject( XMLHandler.getTagValue( stepnode, "reference" ) ); } catch ( Exception e ) { throw new KettleXMLException( BaseMessages.getString( PKG, "MergeRowsMeta.Exception.UnableToLoadStepInfo" ), e ); } }
Example 10
Source File: QueryXmlHelper.java From pentaho-metadata with GNU Lesser General Public License v2.1 | 5 votes |
protected void addOrderByFromXmlNode( Query query, Element orderElement ) throws PentahoMetadataException { String view_id = null; String column_id = null; String aggregation = null; Order.Type orderType = Order.Type.ASC; NodeList nodes = orderElement.getElementsByTagName( "direction" ); //$NON-NLS-1$ if ( nodes.getLength() > 0 ) { String orderTypeStr = XMLHandler.getNodeValue( nodes.item( 0 ) ); if ( orderTypeStr != null ) { orderType = Order.Type.valueOf( orderTypeStr.toUpperCase() ); } } nodes = orderElement.getElementsByTagName( "view_id" ); //$NON-NLS-1$ if ( nodes.getLength() > 0 ) { view_id = XMLHandler.getNodeValue( nodes.item( 0 ) ); } nodes = orderElement.getElementsByTagName( "column_id" ); //$NON-NLS-1$ if ( nodes.getLength() > 0 ) { column_id = XMLHandler.getNodeValue( nodes.item( 0 ) ); } nodes = orderElement.getElementsByTagName( "aggregation" ); //$NON-NLS-1$ if ( nodes.getLength() > 0 ) { aggregation = XMLHandler.getNodeValue( nodes.item( 0 ) ); } if ( ( view_id != null ) && ( column_id != null ) ) { addOrderBy( query, view_id, column_id, aggregation, orderType ); } }
Example 11
Source File: DataGridMeta.java From pentaho-kettle with Apache License 2.0 | 4 votes |
private void readData( Node stepnode ) throws KettleXMLException { try { Node fields = XMLHandler.getSubNode( stepnode, "fields" ); int nrfields = XMLHandler.countNodes( fields, FIELD ); allocate( nrfields ); String slength; String sprecision; for ( int i = 0; i < nrfields; i++ ) { Node fnode = XMLHandler.getSubNodeByNr( fields, FIELD, i ); fieldName[i] = XMLHandler.getTagValue( fnode, "name" ); fieldType[i] = XMLHandler.getTagValue( fnode, "type" ); fieldFormat[i] = XMLHandler.getTagValue( fnode, "format" ); currency[i] = XMLHandler.getTagValue( fnode, "currency" ); decimal[i] = XMLHandler.getTagValue( fnode, "decimal" ); group[i] = XMLHandler.getTagValue( fnode, "group" ); slength = XMLHandler.getTagValue( fnode, "length" ); sprecision = XMLHandler.getTagValue( fnode, "precision" ); fieldLength[i] = Const.toInt( slength, -1 ); fieldPrecision[i] = Const.toInt( sprecision, -1 ); String emptyString = XMLHandler.getTagValue( fnode, "set_empty_string" ); setEmptyString[i] = !Utils.isEmpty( emptyString ) && "Y".equalsIgnoreCase( emptyString ); fieldNullIf[i] = XMLHandler.getTagValue( fnode, FIELD_NULL_IF ); } Node datanode = XMLHandler.getSubNode( stepnode, "data" ); dataLines = new ArrayList<>(); Node lineNode = datanode.getFirstChild(); while ( lineNode != null ) { if ( "line".equals( lineNode.getNodeName() ) ) { List<String> line = new ArrayList<>(); Node itemNode = lineNode.getFirstChild(); while ( itemNode != null ) { if ( "item".equals( itemNode.getNodeName() ) ) { String itemNodeValue = XMLHandler.getNodeValue( itemNode ); line.add( itemNodeValue ); } itemNode = itemNode.getNextSibling(); } dataLines.add( line ); } lineNode = lineNode.getNextSibling(); } } catch ( Exception e ) { throw new KettleXMLException( "Unable to load step info from XML", e ); } }
Example 12
Source File: LoadFileInputMeta.java From pentaho-kettle with Apache License 2.0 | 4 votes |
private void readData( Node stepnode ) throws KettleXMLException { try { includeFilename = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, INCLUDE ) ); filenameField = XMLHandler.getTagValue( stepnode, INCLUDE_FIELD ); addresultfile = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, ADDRESULTFILE ) ); IsIgnoreEmptyFile = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, IS_IGNORE_EMPTY_FILE ) ); IsIgnoreMissingPath = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, IS_IGNORE_MISSING_PATH ) ); includeRowNumber = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, ROWNUM ) ); rowNumberField = XMLHandler.getTagValue( stepnode, ROWNUM_FIELD ); encoding = XMLHandler.getTagValue( stepnode, ENCODING ); Node filenode = XMLHandler.getSubNode( stepnode, FILE ); Node fields = XMLHandler.getSubNode( stepnode, FIELDS ); int nrFiles = XMLHandler.countNodes( filenode, NAME ); int nrFields = XMLHandler.countNodes( fields, "field" ); allocate( nrFiles, nrFields ); for ( int i = 0; i < nrFiles; i++ ) { Node filenamenode = XMLHandler.getSubNodeByNr( filenode, NAME, i ); Node filemasknode = XMLHandler.getSubNodeByNr( filenode, FILEMASK, i ); Node excludefilemasknode = XMLHandler.getSubNodeByNr( filenode, EXCLUDE_FILEMASK, i ); Node fileRequirednode = XMLHandler.getSubNodeByNr( filenode, FILE_REQUIRED, i ); Node includeSubFoldersnode = XMLHandler.getSubNodeByNr( filenode, INCLUDE_SUBFOLDERS, i ); fileName[i] = XMLHandler.getNodeValue( filenamenode ); fileMask[i] = XMLHandler.getNodeValue( filemasknode ); excludeFileMask[i] = XMLHandler.getNodeValue( excludefilemasknode ); fileRequired[i] = XMLHandler.getNodeValue( fileRequirednode ); includeSubFolders[i] = XMLHandler.getNodeValue( includeSubFoldersnode ); } for ( int i = 0; i < nrFields; i++ ) { Node fnode = XMLHandler.getSubNodeByNr( fields, "field", i ); LoadFileInputField field = new LoadFileInputField( fnode ); inputFields[i] = field; } // Is there a limit on the number of rows we process? rowLimit = Const.toLong( XMLHandler.getTagValue( stepnode, LIMIT ), 0L ); fileinfield = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, IS_IN_FIELDS ) ); DynamicFilenameField = XMLHandler.getTagValue( stepnode, DYNAMIC_FILENAME_FIELD ); shortFileFieldName = XMLHandler.getTagValue( stepnode, SHORT_FILE_FIELD_NAME ); pathFieldName = XMLHandler.getTagValue( stepnode, PATH_FIELD_NAME ); hiddenFieldName = XMLHandler.getTagValue( stepnode, HIDDEN_FIELD_NAME ); lastModificationTimeFieldName = XMLHandler.getTagValue( stepnode, LAST_MODIFICATION_TIME_FIELD_NAME ); uriNameFieldName = XMLHandler.getTagValue( stepnode, URI_NAME_FIELD_NAME ); rootUriNameFieldName = XMLHandler.getTagValue( stepnode, ROOT_URI_NAME_FIELD_NAME ); extensionFieldName = XMLHandler.getTagValue( stepnode, EXTENSION_FIELD_NAME ); } catch ( Exception e ) { throw new KettleXMLException( BaseMessages.getString( PKG, "LoadFileInputMeta.Exception.ErrorLoadingXML", e .toString() ) ); } }
Example 13
Source File: ValueMetaBase.java From pentaho-kettle with Apache License 2.0 | 4 votes |
/** * Convert a data XML node to an Object that corresponds to the metadata. This is basically String to Object * conversion that is being done. * * @param node * the node to retrieve the data value from * @return the converted data value * @throws IOException * thrown in case there is a problem with the XML to object conversion */ @Override public Object getValue( Node node ) throws KettleException { switch ( storageType ) { case STORAGE_TYPE_NORMAL: String valueString = XMLHandler.getNodeValue( node ); if ( Utils.isEmpty( valueString ) ) { return null; } // Handle Content -- only when not NULL // switch ( getType() ) { case TYPE_STRING: return valueString; case TYPE_NUMBER: return Double.parseDouble( valueString ); case TYPE_INTEGER: return Long.parseLong( valueString ); case TYPE_DATE: return XMLHandler.stringToDate( valueString ); case TYPE_TIMESTAMP: return XMLHandler.stringToTimestamp( valueString ); case TYPE_BIGNUMBER: return new BigDecimal( valueString ); case TYPE_BOOLEAN: return "Y".equalsIgnoreCase( valueString ); case TYPE_BINARY: return XMLHandler.stringToBinary( XMLHandler.getTagValue( node, "binary-value" ) ); default: throw new KettleException( toString() + " : Unable to de-serialize '" + valueString + "' from XML for data type " + getType() ); } case STORAGE_TYPE_BINARY_STRING: // Handle binary string content -- only when not NULL // In this case, we opt not to convert anything at all for speed. // That way, we can save on CPU power. // Since the streams can be compressed, volume shouldn't be an issue at // all. // String binaryString = XMLHandler.getTagValue( node, "binary-string" ); if ( Utils.isEmpty( binaryString ) ) { return null; } return XMLHandler.stringToBinary( binaryString ); case STORAGE_TYPE_INDEXED: String indexString = XMLHandler.getTagValue( node, "index-value" ); if ( Utils.isEmpty( indexString ) ) { return null; } return Integer.parseInt( indexString ); default: throw new KettleException( toString() + " : Unknown storage type " + getStorageType() ); } }
Example 14
Source File: Validation.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public Validation( Node calcnode ) throws KettleXMLException { this(); fieldName = XMLHandler.getTagValue( calcnode, "name" ); name = XMLHandler.getTagValue( calcnode, "validation_name" ); if ( Utils.isEmpty( name ) ) { name = fieldName; // remain backward compatible } maximumLength = XMLHandler.getTagValue( calcnode, "max_length" ); minimumLength = XMLHandler.getTagValue( calcnode, "min_length" ); nullAllowed = "Y".equalsIgnoreCase( XMLHandler.getTagValue( calcnode, "null_allowed" ) ); onlyNullAllowed = "Y".equalsIgnoreCase( XMLHandler.getTagValue( calcnode, "only_null_allowed" ) ); onlyNumericAllowed = "Y".equalsIgnoreCase( XMLHandler.getTagValue( calcnode, "only_numeric_allowed" ) ); dataType = ValueMetaFactory.getIdForValueMeta( XMLHandler.getTagValue( calcnode, "data_type" ) ); dataTypeVerified = "Y".equalsIgnoreCase( XMLHandler.getTagValue( calcnode, "data_type_verified" ) ); conversionMask = XMLHandler.getTagValue( calcnode, "conversion_mask" ); decimalSymbol = XMLHandler.getTagValue( calcnode, "decimal_symbol" ); groupingSymbol = XMLHandler.getTagValue( calcnode, "grouping_symbol" ); minimumValue = XMLHandler.getTagValue( calcnode, "min_value" ); maximumValue = XMLHandler.getTagValue( calcnode, "max_value" ); startString = XMLHandler.getTagValue( calcnode, "start_string" ); endString = XMLHandler.getTagValue( calcnode, "end_string" ); startStringNotAllowed = XMLHandler.getTagValue( calcnode, "start_string_not_allowed" ); endStringNotAllowed = XMLHandler.getTagValue( calcnode, "end_string_not_allowed" ); regularExpression = XMLHandler.getTagValue( calcnode, "regular_expression" ); regularExpressionNotAllowed = XMLHandler.getTagValue( calcnode, "regular_expression_not_allowed" ); errorCode = XMLHandler.getTagValue( calcnode, "error_code" ); errorDescription = XMLHandler.getTagValue( calcnode, "error_description" ); sourcingValues = "Y".equalsIgnoreCase( XMLHandler.getTagValue( calcnode, "is_sourcing_values" ) ); sourcingStepName = XMLHandler.getTagValue( calcnode, "sourcing_step" ); sourcingField = XMLHandler.getTagValue( calcnode, "sourcing_field" ); Node allowedValuesNode = XMLHandler.getSubNode( calcnode, XML_TAG_ALLOWED ); int nrValues = XMLHandler.countNodes( allowedValuesNode, "value" ); allowedValues = new String[nrValues]; for ( int i = 0; i < nrValues; i++ ) { Node allowedNode = XMLHandler.getSubNodeByNr( allowedValuesNode, "value", i ); allowedValues[i] = XMLHandler.getNodeValue( allowedNode ); } }
Example 15
Source File: QueryXmlHelper.java From pentaho-metadata with GNU Lesser General Public License v2.1 | 4 votes |
protected void addSelectionFromXmlNode( Query query, Element selectionElement ) { NodeList viewnodes = selectionElement.getElementsByTagName( "view" ); //$NON-NLS-1$ NodeList nodes = selectionElement.getElementsByTagName( "column" ); //$NON-NLS-1$ if ( nodes.getLength() == 0 ) { // should throw exception here return; } String columnId = XMLHandler.getNodeValue( nodes.item( 0 ) ); String viewId = null; Category category = null; if ( viewnodes.getLength() != 0 ) { // this is due to legacy reasons, the query doesn't really need the category. viewId = XMLHandler.getNodeValue( viewnodes.item( 0 ) ); category = query.getLogicalModel().findCategory( viewId ); } LogicalColumn column = null; if ( category != null ) { column = category.findLogicalColumn( columnId ); } else { column = query.getLogicalModel().findLogicalColumnInCategories( columnId ); } if ( column != null ) { AggregationType aggsetting = null; NodeList aggnodes = selectionElement.getElementsByTagName( "aggregation" ); //$NON-NLS-1$ if ( aggnodes.getLength() > 0 ) { String aggvalue = XMLHandler.getNodeValue( aggnodes.item( 0 ) ); AggregationType setting = AggregationType.valueOf( aggvalue.toUpperCase() ); if ( setting == null ) { Messages.getErrorString( "QueryXmlHelper.ERROR_0011_AGG_NOT_RECOGNIZED", columnId, aggvalue ); //$NON-NLS-1$ } else { // verify that the setting is one of the options for this business column if ( ( column.getAggregationType() == setting ) || column.getAggregationList() != null && column.getAggregationList().contains( setting ) ) { aggsetting = setting; } else { Messages.getErrorString( "QueryXmlHelper.ERROR_0012_INVALID_AGG_FOR_BUSINESS_COL", columnId, aggvalue ); //$NON-NLS-1$ } } } query.getSelections().add( new Selection( category, column, aggsetting ) ); } else { // print a warning message Messages.getErrorString( "QueryXmlHelper.ERROR_0013_BUSINESS_COL_NOT_FOUND", viewId, columnId ); //$NON-NLS-1$ } }
Example 16
Source File: AdvancedQueryXmlHelper.java From pentaho-metadata with GNU Lesser General Public License v2.1 | 4 votes |
@Override protected void addOrderByFromXmlNode( Query query, Element orderElement ) throws PentahoMetadataException { boolean ascending = true; String view = null; String column = null; String formula = null; String alias = null; NodeList nodes = orderElement.getElementsByTagName( "direction" ); //$NON-NLS-1$ if ( nodes.getLength() > 0 ) { ascending = XMLHandler.getNodeValue( nodes.item( 0 ) ).equals( "asc" ); //$NON-NLS-1$ } nodes = orderElement.getElementsByTagName( "view" ); //$NON-NLS-1$ if ( nodes.getLength() > 0 ) { view = XMLHandler.getNodeValue( nodes.item( 0 ) ); } nodes = orderElement.getElementsByTagName( "column" ); //$NON-NLS-1$ if ( nodes.getLength() > 0 ) { column = XMLHandler.getNodeValue( nodes.item( 0 ) ); } nodes = orderElement.getElementsByTagName( "alias" ); //$NON-NLS-1$ if ( nodes.getLength() > 0 ) { alias = XMLHandler.getNodeValue( nodes.item( 0 ) ); } nodes = orderElement.getElementsByTagName( "formula" ); //$NON-NLS-1$ if ( nodes.getLength() > 0 ) { formula = XMLHandler.getNodeValue( nodes.item( 0 ) ); } if ( view != null && column != null ) { Category category = query.getLogicalModel().findCategory( view ); if ( category == null ) { throw new PentahoMetadataException( Messages.getErrorString( "QueryXmlHelper.ERROR_0015_BUSINESS_CATEGORY_NOT_FOUND", view ) ); //$NON-NLS-1$ } LogicalColumn businessColumn = category.findLogicalColumn( column ); if ( businessColumn == null ) { throw new PentahoMetadataException( Messages.getErrorString( "QueryXmlHelper.ERROR_0013_BUSINESS_COL_NOT_FOUND", category.getId(), column ) ); //$NON-NLS-1$ } query.getOrders().add( new Order( new AliasedSelection( category, businessColumn, null, alias ), ascending ? Type.ASC : Type.DESC ) ); } else if ( formula != null ) { query.getOrders().add( new Order( new AliasedSelection( formula ), ascending ? Type.ASC : Type.DESC ) ); } else { throw new PentahoMetadataException( "no column or formula specified" ); //$NON-NLS-1$ } }
Example 17
Source File: AdvancedQueryXmlHelper.java From pentaho-metadata with GNU Lesser General Public License v2.1 | 4 votes |
/** * overridden method allowing more advanced selection functionality */ @Override protected void addSelectionFromXmlNode( Query query, Element selectionElement ) { String view = null; String column = null; String alias = null; String formula = null; NodeList viewnodes = selectionElement.getElementsByTagName( "view" ); //$NON-NLS-1$ if ( viewnodes.getLength() > 0 ) { view = XMLHandler.getNodeValue( viewnodes.item( 0 ) ); if ( ( view != null ) && ( view.trim().length() == 0 ) ) { view = null; } } NodeList nodes = selectionElement.getElementsByTagName( "column" ); //$NON-NLS-1$ if ( nodes.getLength() > 0 ) { column = XMLHandler.getNodeValue( nodes.item( 0 ) ); if ( ( column != null ) && ( column.trim().length() == 0 ) ) { column = null; } } nodes = selectionElement.getElementsByTagName( "alias" ); //$NON-NLS-1$ if ( nodes.getLength() > 0 ) { alias = XMLHandler.getNodeValue( nodes.item( 0 ) ); if ( ( alias != null ) && ( alias.trim().length() == 0 ) ) { alias = null; } } nodes = selectionElement.getElementsByTagName( "formula" ); //$NON-NLS-1$ if ( nodes.getLength() > 0 ) { formula = XMLHandler.getNodeValue( nodes.item( 0 ) ); if ( ( formula != null ) && ( formula.trim().length() == 0 ) ) { formula = null; } } if ( view != null && column != null ) { Category category = query.getLogicalModel().findCategory( view ); LogicalColumn businessColumn = category.findLogicalColumn( column ); if ( businessColumn != null ) { query.getSelections().add( new AliasedSelection( category, businessColumn, null, alias ) ); } else { throw new RuntimeException( "Failed to find business column '" + column + "' in model." ); } } else if ( formula != null ) { try { query.getSelections().add( new AliasedSelection( formula ) ); } catch ( PentahoMetadataException e ) { throw new RuntimeException( e ); } } else { throw new RuntimeException( "Failed to parse selection, no column or formula provided" ); } }
Example 18
Source File: GPLoadMeta.java From pentaho-kettle with Apache License 2.0 | 4 votes |
private void readData( Node stepnode, List<? extends SharedObjectInterface> databases ) throws KettleXMLException { try { String con = XMLHandler.getTagValue( stepnode, "connection" ); databaseMeta = DatabaseMeta.findDatabase( databases, con ); maxErrors = XMLHandler.getTagValue( stepnode, "errors" ); schemaName = XMLHandler.getTagValue( stepnode, "schema" ); tableName = XMLHandler.getTagValue( stepnode, "table" ); errorTableName = XMLHandler.getTagValue( stepnode, "error_table" ); loadMethod = XMLHandler.getTagValue( stepnode, "load_method" ); loadAction = XMLHandler.getTagValue( stepnode, "load_action" ); gploadPath = XMLHandler.getTagValue( stepnode, "gpload_path" ); controlFile = XMLHandler.getTagValue( stepnode, "control_file" ); dataFile = XMLHandler.getTagValue( stepnode, "data_file" ); delimiter = XMLHandler.getTagValue( stepnode, "delimiter" ); logFile = XMLHandler.getTagValue( stepnode, "log_file" ); nullAs = XMLHandler.getTagValue( stepnode, "null_as" ); eraseFiles = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "erase_files" ) ); encoding = XMLHandler.getTagValue( stepnode, "encoding" ); updateCondition = XMLHandler.getTagValue( stepnode, "update_condition" ); Node localHostsNode = XMLHandler.getSubNode( stepnode, "local_hosts" ); int nLocalHosts = XMLHandler.countNodes( localHostsNode, "local_host" ); allocateLocalHosts( nLocalHosts ); for ( int i = 0; i < nLocalHosts; i++ ) { Node localHostNode = XMLHandler.getSubNodeByNr( localHostsNode, "local_host", i ); localHosts[i] = XMLHandler.getNodeValue( localHostNode ); } localhostPort = XMLHandler.getTagValue( stepnode, "localhost_port" ); encloseNumbers = XMLHandler.getTagValue( stepnode, "enclose_numbers" ).equalsIgnoreCase( "Y" ); int nrvalues = XMLHandler.countNodes( stepnode, "mapping" ); allocate( nrvalues ); for ( int i = 0; i < nrvalues; i++ ) { Node vnode = XMLHandler.getSubNodeByNr( stepnode, "mapping", i ); fieldTable[i] = XMLHandler.getTagValue( vnode, "stream_name" ); fieldStream[i] = XMLHandler.getTagValue( vnode, "field_name" ); if ( fieldStream[i] == null ) { fieldStream[i] = fieldTable[i]; // default: the same name! } String locDateMask = XMLHandler.getTagValue( vnode, "date_mask" ); if ( locDateMask == null ) { dateMask[i] = ""; } else { if ( GPLoadMeta.DATE_MASK_DATE.equals( locDateMask ) || GPLoadMeta.DATE_MASK_DATETIME.equals( locDateMask ) ) { dateMask[i] = locDateMask; } else { dateMask[i] = ""; } } matchColumn[i] = ( "Y".equalsIgnoreCase( XMLHandler.getTagValue( vnode, "match_column" ) ) ); updateColumn[i] = ( "Y".equalsIgnoreCase( XMLHandler.getTagValue( vnode, "update_column" ) ) ); } } catch ( Exception e ) { throw new KettleXMLException( BaseMessages.getString( PKG, "GPLoadMeta.Exception.UnableToReadStepInfoFromXML" ), e ); } }
Example 19
Source File: XMLInputMeta.java From pentaho-kettle with Apache License 2.0 | 4 votes |
private void readData( Node stepnode ) throws KettleXMLException { try { includeFilename = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "include" ) ); filenameField = XMLHandler.getTagValue( stepnode, "include_field" ); includeRowNumber = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "rownum" ) ); rowNumberField = XMLHandler.getTagValue( stepnode, "rownum_field" ); fileBaseURI = XMLHandler.getTagValue( stepnode, "file_base_uri" ); ignoreEntities = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "ignore_entities" ) ); namespaceAware = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "namespace_aware" ) ); Node filenode = XMLHandler.getSubNode( stepnode, "file" ); Node fields = XMLHandler.getSubNode( stepnode, "fields" ); Node positions = XMLHandler.getSubNode( stepnode, "positions" ); int nrFiles = XMLHandler.countNodes( filenode, "name" ); int nrFields = XMLHandler.countNodes( fields, "field" ); int nrPositions = XMLHandler.countNodes( positions, "position" ); allocate( nrFiles, nrFields, nrPositions ); for ( int i = 0; i < nrFiles; i++ ) { Node filenamenode = XMLHandler.getSubNodeByNr( filenode, "name", i ); Node filemasknode = XMLHandler.getSubNodeByNr( filenode, "filemask", i ); fileName[i] = XMLHandler.getNodeValue( filenamenode ); fileMask[i] = XMLHandler.getNodeValue( filemasknode ); } for ( int i = 0; i < nrFields; i++ ) { Node fnode = XMLHandler.getSubNodeByNr( fields, "field", i ); XMLInputField field = new XMLInputField( fnode ); inputFields[i] = field; } for ( int i = 0; i < nrPositions; i++ ) { Node positionnode = XMLHandler.getSubNodeByNr( positions, "position", i ); inputPosition[i] = XMLHandler.getNodeValue( positionnode ); } // Is there a limit on the number of rows we process? rowLimit = Const.toLong( XMLHandler.getTagValue( stepnode, "limit" ), 0L ); // Do we skip rows before starting to read nrRowsToSkip = Const.toInt( XMLHandler.getTagValue( stepnode, "skip" ), 0 ); } catch ( Exception e ) { throw new KettleXMLException( "Unable to load step info from XML", e ); } }
Example 20
Source File: ValueMetaBase.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public ValueMetaBase( Node node ) throws KettleException { this(); type = getType( XMLHandler.getTagValue( node, "type" ) ); storageType = getStorageType( XMLHandler.getTagValue( node, "storagetype" ) ); switch ( storageType ) { case STORAGE_TYPE_INDEXED: Node indexNode = XMLHandler.getSubNode( node, "index" ); int nrIndexes = XMLHandler.countNodes( indexNode, "value" ); index = new Object[nrIndexes]; for ( int i = 0; i < index.length; i++ ) { Node valueNode = XMLHandler.getSubNodeByNr( indexNode, "value", i ); String valueString = XMLHandler.getNodeValue( valueNode ); if ( Utils.isEmpty( valueString ) ) { index[i] = null; } else { switch ( type ) { case TYPE_STRING: index[i] = valueString; break; case TYPE_NUMBER: index[i] = Double.parseDouble( valueString ); break; case TYPE_INTEGER: index[i] = Long.parseLong( valueString ); break; case TYPE_DATE: index[i] = XMLHandler.stringToDate( valueString ); break; case TYPE_BIGNUMBER: index[i] = new BigDecimal( valueString ); break; case TYPE_BOOLEAN: index[i] = Boolean.valueOf( "Y".equalsIgnoreCase( valueString ) ); break; case TYPE_BINARY: index[i] = XMLHandler.stringToBinary( valueString ); break; default: throw new KettleException( toString() + " : Unable to de-serialize index storage type from XML for data type " + getType() ); } } } break; case STORAGE_TYPE_BINARY_STRING: // Load the storage meta data... // Node storageMetaNode = XMLHandler.getSubNode( node, "storage-meta" ); Node storageValueMetaNode = XMLHandler.getSubNode( storageMetaNode, XML_META_TAG ); if ( storageValueMetaNode != null ) { storageMetadata = new ValueMetaBase( storageValueMetaNode ); } break; default: break; } name = XMLHandler.getTagValue( node, "name" ); length = Integer.parseInt( XMLHandler.getTagValue( node, "length" ) ); precision = Integer.parseInt( XMLHandler.getTagValue( node, "precision" ) ); origin = XMLHandler.getTagValue( node, "origin" ); comments = XMLHandler.getTagValue( node, "comments" ); conversionMask = XMLHandler.getTagValue( node, "conversion_Mask" ); decimalSymbol = XMLHandler.getTagValue( node, "decimal_symbol" ); groupingSymbol = XMLHandler.getTagValue( node, "grouping_symbol" ); currencySymbol = XMLHandler.getTagValue( node, "currency_symbol" ); trimType = getTrimTypeByCode( XMLHandler.getTagValue( node, "trim_type" ) ); caseInsensitive = "Y".equalsIgnoreCase( XMLHandler.getTagValue( node, "case_insensitive" ) ); collatorDisabled = "Y".equalsIgnoreCase( XMLHandler.getTagValue( node, "collator_disabled" ) ); if ( XMLHandler.getTagValue( node, "collator_strength" ) != null ) { collatorStrength = Integer.parseInt( XMLHandler.getTagValue( node, "collator_strength" ) ); } sortedDescending = "Y".equalsIgnoreCase( XMLHandler.getTagValue( node, "sort_descending" ) ); outputPaddingEnabled = "Y".equalsIgnoreCase( XMLHandler.getTagValue( node, "output_padding" ) ); dateFormatLenient = "Y".equalsIgnoreCase( XMLHandler.getTagValue( node, "date_format_lenient" ) ); String dateFormatLocaleString = XMLHandler.getTagValue( node, "date_format_locale" ); if ( !Utils.isEmpty( dateFormatLocaleString ) ) { dateFormatLocale = EnvUtil.createLocale( dateFormatLocaleString ); } String dateTimeZoneString = XMLHandler.getTagValue( node, "date_format_timezone" ); if ( !Utils.isEmpty( dateTimeZoneString ) ) { dateFormatTimeZone = EnvUtil.createTimeZone( dateTimeZoneString ); } else { dateFormatTimeZone = TimeZone.getDefault(); } lenientStringToNumber = "Y".equalsIgnoreCase( XMLHandler.getTagValue( node, "lenient_string_to_number" ) ); }