private void readData(Node stepnode, List<? extends SharedObjectInterface> databases) throws KettleXMLException { try { databaseMeta = DatabaseMeta.findDatabase(databases, XMLHandler.getTagValue(stepnode, "connection")); String functionName = XMLHandler.getTagValue(stepnode, XML_TAG_FUNCTION, "name"); String functionDescription = XMLHandler.getTagValue(stepnode, XML_TAG_FUNCTION, "description"); String functionGroup = XMLHandler.getTagValue(stepnode, XML_TAG_FUNCTION, "group"); String functionApplication = XMLHandler.getTagValue(stepnode, XML_TAG_FUNCTION, "application"); String functionHost = XMLHandler.getTagValue(stepnode, XML_TAG_FUNCTION, "host"); if (!Const.isEmpty(functionName)) { function = new SAPFunction( functionName, functionDescription, functionGroup, functionApplication, functionHost); } else { function = null; } Node paramsNode = XMLHandler.getSubNode(stepnode, XML_TAG_PARAMETERS); int nrParameters = XMLHandler.countNodes(paramsNode, XML_TAG_PARAMETER); for (int i = 0; i < nrParameters; i++) { Node paramNode = XMLHandler.getSubNodeByNr(paramsNode, XML_TAG_PARAMETER, i); String fieldName = XMLHandler.getTagValue(paramNode, "field_name"); SapType sapType = SapType.findTypeForCode(XMLHandler.getTagValue(paramNode, "sap_type")); String tableName = XMLHandler.getTagValue(paramNode, "table_name"); int targetType = ValueMeta.getType(XMLHandler.getTagValue(paramNode, "target_type")); String parameterName = XMLHandler.getTagValue(paramNode, "parameter_name"); parameters.add(new SapParameter(fieldName, sapType, tableName, parameterName, targetType)); } Node fieldsNode = XMLHandler.getSubNode(stepnode, XML_TAG_FIELDS); int nrFields = XMLHandler.countNodes(fieldsNode, XML_TAG_FIELD); for (int i = 0; i < nrFields; i++) { Node fieldNode = XMLHandler.getSubNodeByNr(fieldsNode, XML_TAG_FIELD, i); String sapFieldName = XMLHandler.getTagValue(fieldNode, "field_name"); SapType sapType = SapType.findTypeForCode(XMLHandler.getTagValue(fieldNode, "sap_type")); String tableName = XMLHandler.getTagValue(fieldNode, "table_name"); int targetType = ValueMeta.getType(XMLHandler.getTagValue(fieldNode, "target_type")); String newName = XMLHandler.getTagValue(fieldNode, "new_name"); outputFields.add(new SapOutputField(sapFieldName, sapType, tableName, newName, targetType)); } } catch (Exception e) { throw new KettleXMLException("Unable to load step info from XML", e); } }
public void readRep( Repository rep, ObjectId id_step, List<DatabaseMeta> databases, Map<String, Counter> counters) throws KettleException { try { databaseMeta = rep.loadDatabaseMetaFromStepAttribute(id_step, "id_connection", databases); // $NON-NLS-1$ String functionName = rep.getStepAttributeString(id_step, "function_name"); String functionDescription = rep.getStepAttributeString(id_step, "function_description"); String functionGroup = rep.getStepAttributeString(id_step, "function_group"); String functionApplication = rep.getStepAttributeString(id_step, "function_application"); String functionHost = rep.getStepAttributeString(id_step, "function_host"); if (!Const.isEmpty(functionName)) { function = new SAPFunction( functionName, functionDescription, functionGroup, functionApplication, functionHost); } else { function = null; } int nrParameters = rep.countNrStepAttributes(id_step, "parameter_field_name"); for (int i = 0; i < nrParameters; i++) { String fieldName = rep.getStepAttributeString(id_step, i, "parameter_field_name"); SapType sapType = SapType.findTypeForCode(rep.getStepAttributeString(id_step, i, "parameter_sap_type")); String tableName = rep.getStepAttributeString(id_step, i, "parameter_table_name"); int targetType = ValueMeta.getType(rep.getStepAttributeString(id_step, i, "parameter_target_type")); String parameterName = rep.getStepAttributeString(id_step, i, "parameter_name"); parameters.add(new SapParameter(fieldName, sapType, tableName, parameterName, targetType)); } int nrFields = rep.countNrStepAttributes(id_step, "field_sap_field_name"); for (int i = 0; i < nrFields; i++) { String sapFieldName = rep.getStepAttributeString(id_step, i, "field_sap_field_name"); SapType sapType = SapType.findTypeForCode(rep.getStepAttributeString(id_step, i, "field_sap_type")); String tableName = rep.getStepAttributeString(id_step, i, "field_table_name"); int targetType = ValueMeta.getType(rep.getStepAttributeString(id_step, i, "field_target_type")); String newName = rep.getStepAttributeString(id_step, i, "field_new_name"); outputFields.add(new SapOutputField(sapFieldName, sapType, tableName, newName, targetType)); } } catch (Exception e) { throw new KettleException("Unexpected error reading step information from the repository", e); } }
public void readRep( Repository rep, ObjectId id_step, List<DatabaseMeta> databases, Map<String, Counter> counters) throws KettleException { try { int nrfields = rep.countNrStepAttributes(id_step, "field_name"); // $NON-NLS-1$ allocate(nrfields); for (int i = 0; i < nrfields; i++) { fieldName[i] = rep.getStepAttributeString(id_step, i, "field_name"); // $NON-NLS-1$ fieldType[i] = ValueMeta.getType(rep.getStepAttributeString(id_step, i, "field_type")); // $NON-NLS-1$ fieldLength[i] = (int) rep.getStepAttributeInteger(id_step, i, "field_length"); // $NON-NLS-1$ fieldPrecision[i] = (int) rep.getStepAttributeInteger(id_step, i, "field_precision"); // $NON-NLS-1$ } selectingAndSortingUnspecifiedFields = rep.getStepAttributeBoolean(id_step, "select_unspecified"); } catch (Exception e) { throw new KettleException( BaseMessages.getString( PKG, "MappingInputMeta.Exception.UnexpectedErrorInReadingStepInfo"), e); //$NON-NLS-1$ } }
/** * 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 = ValueMeta.getType(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); } }
public void getInfo(SasInputMeta meta) throws KettleStepException { // copy info to Meta class (input) meta.setAcceptingField(wAccField.getText()); int nrNonEmptyFields = wFields.nrNonEmpty(); meta.getOutputFields().clear(); for (int i = 0; i < nrNonEmptyFields; i++) { TableItem item = wFields.getNonEmpty(i); int colnr = 1; SasInputField field = new SasInputField(); field.setName(item.getText(colnr++)); field.setRename(item.getText(colnr++)); if (Const.isEmpty(field.getRename())) { field.setRename(field.getName()); } field.setType(ValueMeta.getType(item.getText(colnr++))); field.setConversionMask(item.getText(colnr++)); field.setLength(Const.toInt(item.getText(colnr++), -1)); field.setPrecision(Const.toInt(item.getText(colnr++), -1)); field.setDecimalSymbol(item.getText(colnr++)); field.setGroupingSymbol(item.getText(colnr++)); field.setTrimType(ValueMeta.getTrimTypeByDesc(item.getText(colnr++))); meta.getOutputFields().add(field); } wFields.removeEmptyRows(); wFields.setRowNums(); wFields.optWidth(true); }
private void readData(Node stepnode) throws KettleXMLException { try { Node fields = XMLHandler.getSubNode(stepnode, "fields"); // $NON-NLS-1$ int nrfields = XMLHandler.countNodes(fields, "field"); // $NON-NLS-1$ allocate(nrfields); for (int i = 0; i < nrfields; i++) { Node fnode = XMLHandler.getSubNodeByNr(fields, "field", i); // $NON-NLS-1$ fieldName[i] = XMLHandler.getTagValue(fnode, "name"); // $NON-NLS-1$ fieldType[i] = ValueMeta.getType(XMLHandler.getTagValue(fnode, "type")); // $NON-NLS-1$ String slength = XMLHandler.getTagValue(fnode, "length"); // $NON-NLS-1$ String sprecision = XMLHandler.getTagValue(fnode, "precision"); // $NON-NLS-1$ fieldLength[i] = Const.toInt(slength, -1); fieldPrecision[i] = Const.toInt(sprecision, -1); } selectingAndSortingUnspecifiedFields = "Y".equalsIgnoreCase(XMLHandler.getTagValue(fields, "select_unspecified")); } catch (Exception e) { throw new KettleXMLException( BaseMessages.getString(PKG, "MappingInputMeta.Exception.UnableToLoadStepInfoFromXML"), e); //$NON-NLS-1$ } }
public CalculatorMetaFunction(Repository rep, long id_step, int nr) throws KettleException { fieldName = rep.getStepAttributeString(id_step, nr, "field_name"); calcType = getCalcFunctionType(rep.getStepAttributeString(id_step, nr, "calc_type")); fieldA = rep.getStepAttributeString(id_step, nr, "field_a"); fieldB = rep.getStepAttributeString(id_step, nr, "field_b"); fieldC = rep.getStepAttributeString(id_step, nr, "field_c"); fieldD = rep.getStepAttributeString(id_step, nr, "field_d"); fieldE = rep.getStepAttributeString(id_step, nr, "field_e"); valueType = ValueMeta.getType(rep.getStepAttributeString(id_step, nr, "value_type")); valueLength = (int) rep.getStepAttributeInteger(id_step, nr, "value_length"); valuePrecision = (int) rep.getStepAttributeInteger(id_step, nr, "value_precision"); removedFromResult = rep.getStepAttributeBoolean(id_step, nr, "remove"); conversionMask = rep.getStepAttributeString(id_step, nr, "conversion_mask"); decimalSymbol = rep.getStepAttributeString(id_step, nr, "decimal_symbol"); groupingSymbol = rep.getStepAttributeString(id_step, nr, "grouping_symbol"); currencySymbol = rep.getStepAttributeString(id_step, nr, "currency_symbol"); // Fix 2.x backward compatibility // The conversion mask was added in a certain revision. // Anything that we load from before then should get masks set to retain backward compatibility // if (rep.findStepAttributeID(id_step, nr, "conversion_mask") < 0) { fixBackwardCompatibility(); } }
public CalculatorMetaFunction(Node calcnode) { fieldName = XMLHandler.getTagValue(calcnode, "field_name"); calcType = getCalcFunctionType(XMLHandler.getTagValue(calcnode, "calc_type")); fieldA = XMLHandler.getTagValue(calcnode, "field_a"); fieldB = XMLHandler.getTagValue(calcnode, "field_b"); fieldC = XMLHandler.getTagValue(calcnode, "field_c"); fieldD = XMLHandler.getTagValue(calcnode, "field_d"); fieldE = XMLHandler.getTagValue(calcnode, "field_e"); valueType = ValueMeta.getType(XMLHandler.getTagValue(calcnode, "value_type")); valueLength = Const.toInt(XMLHandler.getTagValue(calcnode, "value_length"), -1); valuePrecision = Const.toInt(XMLHandler.getTagValue(calcnode, "value_precision"), -1); removedFromResult = "Y".equalsIgnoreCase(XMLHandler.getTagValue(calcnode, "remove")); conversionMask = XMLHandler.getTagValue(calcnode, "conversion_mask"); decimalSymbol = XMLHandler.getTagValue(calcnode, "decimal_symbol"); groupingSymbol = XMLHandler.getTagValue(calcnode, "grouping_symbol"); currencySymbol = XMLHandler.getTagValue(calcnode, "currency_symbol"); // Fix 2.x backward compatibility // The conversion mask was added in a certain revision. // Anything that we load from before then should get masks set to retain backward compatibility // if (XMLHandler.getSubNode(calcnode, "conversion_mask") == null) { fixBackwardCompatibility(); } }
public Validation(Repository rep, ObjectId id_step, int i) throws KettleException { fieldName = rep.getStepAttributeString(id_step, i, "validator_field_name"); name = rep.getStepAttributeString(id_step, i, "validator_field_validation_name"); if (Const.isEmpty(name)) { name = fieldName; // remain backward compatible } maximumLength = rep.getStepAttributeString(id_step, i, "validator_field_max_length"); minimumLength = rep.getStepAttributeString(id_step, i, "validator_field_min_length"); nullAllowed = rep.getStepAttributeBoolean(id_step, i, "validator_field_null_allowed"); onlyNullAllowed = rep.getStepAttributeBoolean(id_step, i, "validator_field_only_null_allowed"); onlyNumericAllowed = rep.getStepAttributeBoolean(id_step, i, "validator_field_only_numeric_allowed"); dataType = ValueMeta.getType(rep.getStepAttributeString(id_step, i, "validator_field_data_type")); dataTypeVerified = rep.getStepAttributeBoolean(id_step, i, "validator_field_data_type_verified"); conversionMask = rep.getStepAttributeString(id_step, i, "validator_field_conversion_mask"); decimalSymbol = rep.getStepAttributeString(id_step, i, "validator_field_decimal_symbol"); groupingSymbol = rep.getStepAttributeString(id_step, i, "validator_field_grouping_symbol"); minimumValue = rep.getStepAttributeString(id_step, i, "validator_field_min_value"); maximumValue = rep.getStepAttributeString(id_step, i, "validator_field_max_value"); startString = rep.getStepAttributeString(id_step, i, "validator_field_start_string"); endString = rep.getStepAttributeString(id_step, i, "validator_field_end_string"); startStringNotAllowed = rep.getStepAttributeString(id_step, i, "validator_field_start_string_not_allowed"); endStringNotAllowed = rep.getStepAttributeString(id_step, i, "validator_field_end_string_not_allowed"); regularExpression = rep.getStepAttributeString(id_step, i, "validator_field_regular_expression"); regularExpressionNotAllowed = rep.getStepAttributeString(id_step, i, "validator_field_regular_expression_not_allowed"); errorCode = rep.getStepAttributeString(id_step, i, "validator_field_error_code"); errorDescription = rep.getStepAttributeString(id_step, i, "validator_field_error_description"); sourcingValues = rep.getStepAttributeBoolean(id_step, i, "validator_field_is_sourcing_values"); sourcingStepName = rep.getStepAttributeString(id_step, i, "validator_field_sourcing_step"); sourcingField = rep.getStepAttributeString(id_step, i, "validator_field_sourcing_field"); List<String> allowed = new ArrayList<String>(); int nr = 1; String value = rep.getStepAttributeString(id_step, i, "validator_field_value_" + nr); while (value != null) { allowed.add(value); nr++; value = rep.getStepAttributeString(id_step, i, "validator_field_value_" + nr); } allowedValues = allowed.toArray(new String[allowed.size()]); }
private void ok() { if (Const.isEmpty(wStepname.getText())) return; int i; int nrargs = wFields.nrNonEmpty(); input.allocate(nrargs); logDebug( BaseMessages.getString( PKG, "DBProcDialog.Log.FoundArguments", String.valueOf(nrargs))); // $NON-NLS-1$ //$NON-NLS-2$ for (i = 0; i < nrargs; i++) { TableItem item = wFields.getNonEmpty(i); input.getArgument()[i] = item.getText(1); input.getArgumentDirection()[i] = item.getText(2); input.getArgumentType()[i] = ValueMeta.getType(item.getText(3)); } input.setDatabase(transMeta.findDatabase(wConnection.getText())); input.setProcedure(wProcName.getText()); input.setResultName(wResult.getText()); input.setResultType(ValueMeta.getType(wResultType.getText())); input.setAutoCommit(wAutoCommit.getSelection()); stepname = wStepname.getText(); // return value if (input.getDatabase() == null) { MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR); mb.setMessage( BaseMessages.getString( PKG, "DBProcDialog.InvalidConnection.DialogMessage")); // $NON-NLS-1$ mb.setText( BaseMessages.getString(PKG, "DBProcDialog.InvalidConnection.DialogTitle")); // $NON-NLS-1$ mb.open(); } dispose(); }
public YamlInputField(Node fnode) throws KettleValueException { setName(XMLHandler.getTagValue(fnode, "name")); setPath(XMLHandler.getTagValue(fnode, "path")); 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(getTrimTypeByCode(XMLHandler.getTagValue(fnode, "trim_type"))); }
public void readRep( Repository rep, long id_step, List<DatabaseMeta> databases, Map<String, Counter> counters) throws KettleException { try { long id_connection = rep.getStepAttributeInteger(id_step, "id_connection"); // $NON-NLS-1$ databaseMeta = DatabaseMeta.findDatabase(databases, id_connection); cached = rep.getStepAttributeBoolean(id_step, "cache"); // $NON-NLS-1$ loadingAllDataInCache = rep.getStepAttributeBoolean(id_step, "cache_load_all"); // $NON-NLS-1$ cacheSize = (int) rep.getStepAttributeInteger(id_step, "cache_size"); // $NON-NLS-1$ schemaName = rep.getStepAttributeString(id_step, "lookup_schema"); // $NON-NLS-1$ tablename = rep.getStepAttributeString(id_step, "lookup_table"); // $NON-NLS-1$ orderByClause = rep.getStepAttributeString(id_step, "lookup_orderby"); // $NON-NLS-1$ failingOnMultipleResults = rep.getStepAttributeBoolean(id_step, "fail_on_multiple"); // $NON-NLS-1$ eatingRowOnLookupFailure = rep.getStepAttributeBoolean(id_step, "eat_row_on_failure"); // $NON-NLS-1$ int nrkeys = rep.countNrStepAttributes(id_step, "lookup_key_name"); // $NON-NLS-1$ int nrvalues = rep.countNrStepAttributes(id_step, "return_value_name"); // $NON-NLS-1$ allocate(nrkeys, nrvalues); for (int i = 0; i < nrkeys; i++) { streamKeyField1[i] = rep.getStepAttributeString(id_step, i, "lookup_key_name"); // $NON-NLS-1$ tableKeyField[i] = rep.getStepAttributeString(id_step, i, "lookup_key_field"); // $NON-NLS-1$ keyCondition[i] = rep.getStepAttributeString(id_step, i, "lookup_key_condition"); // $NON-NLS-1$ streamKeyField2[i] = rep.getStepAttributeString(id_step, i, "lookup_key_name2"); // $NON-NLS-1$ } for (int i = 0; i < nrvalues; i++) { returnValueField[i] = rep.getStepAttributeString(id_step, i, "return_value_name"); // $NON-NLS-1$ returnValueNewName[i] = rep.getStepAttributeString(id_step, i, "return_value_rename"); // $NON-NLS-1$ returnValueDefault[i] = rep.getStepAttributeString(id_step, i, "return_value_default"); // $NON-NLS-1$ returnValueDefaultType[i] = ValueMeta.getType( rep.getStepAttributeString(id_step, i, "return_value_type")); // $NON-NLS-1$ } } catch (Exception e) { throw new KettleException( Messages.getString( "DatabaseLookupMeta.ERROR0002.UnexpectedErrorReadingFromTheRepository"), e); //$NON-NLS-1$ } }
public Validation(Node calcnode) throws KettleXMLException { this(); fieldName = XMLHandler.getTagValue(calcnode, "name"); name = XMLHandler.getTagValue(calcnode, "validation_name"); if (Const.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 = ValueMeta.getType(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); } }
private void getInfo(SapInputMeta meta) { meta.setDatabaseMeta(transMeta.findDatabase(wConnection.getText())); meta.setFunction(function); // Grab the parameters... // meta.getParameters().clear(); int nrParameters = wInput.nrNonEmpty(); for (int i = 0; i < nrParameters; i++) { TableItem item = wInput.getNonEmpty(i); int colnr = 1; String fieldName = item.getText(colnr++); SapType sapType = SapType.findTypeForDescription(item.getText(colnr++)); String tableName = item.getText(colnr++); String parameterName = item.getText(colnr++); int targetType = ValueMeta.getType(item.getText(colnr++)); meta.getParameters() .add(new SapParameter(fieldName, sapType, tableName, parameterName, targetType)); } // and the output fields. // meta.getOutputFields().clear(); int nrFields = wOutput.nrNonEmpty(); for (int i = 0; i < nrFields; i++) { TableItem item = wOutput.getNonEmpty(i); int colnr = 1; String sapFieldName = item.getText(colnr++); SapType sapType = SapType.findTypeForDescription(item.getText(colnr++)); String tableName = item.getText(colnr++); String newName = item.getText(colnr++); int targetType = ValueMeta.getType(item.getText(colnr++)); meta.getOutputFields() .add(new SapOutputField(sapFieldName, sapType, tableName, newName, targetType)); } }
public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases) throws KettleException { try { urlInField = rep.getStepAttributeBoolean(id_step, "url_in_field"); urlFieldname = rep.getStepAttributeString(id_step, "url_field_name"); includeRowNumber = rep.getStepAttributeBoolean(id_step, "rownum"); rowNumberField = rep.getStepAttributeString(id_step, "rownum_field"); includeUrl = rep.getStepAttributeBoolean(id_step, "include_url"); urlField = rep.getStepAttributeString(id_step, "url_Field"); readfrom = rep.getStepAttributeString(id_step, "read_from"); rowLimit = rep.getStepAttributeInteger(id_step, "limit"); int nrFields = rep.countNrStepAttributes(id_step, "field_name"); int nrUrls = rep.countNrStepAttributes(id_step, "url_name"); allocate(nrUrls, nrFields); for (int i = 0; i < nrUrls; i++) { url[i] = rep.getStepAttributeString(id_step, i, "url_name"); } for (int i = 0; i < nrFields; i++) { RssInputField field = new RssInputField(); field.setName(rep.getStepAttributeString(id_step, i, "field_name")); field.setColumn( RssInputField.getColumnByCode(rep.getStepAttributeString(id_step, i, "field_column"))); field.setType(ValueMeta.getType(rep.getStepAttributeString(id_step, i, "field_type"))); field.setFormat(rep.getStepAttributeString(id_step, i, "field_format")); field.setCurrencySymbol(rep.getStepAttributeString(id_step, i, "field_currency")); field.setDecimalSymbol(rep.getStepAttributeString(id_step, i, "field_decimal")); field.setGroupSymbol(rep.getStepAttributeString(id_step, i, "field_group")); field.setLength((int) rep.getStepAttributeInteger(id_step, i, "field_length")); field.setPrecision((int) rep.getStepAttributeInteger(id_step, i, "field_precision")); field.setTrimType( RssInputField.getTrimTypeByCode( rep.getStepAttributeString(id_step, i, "field_trim_type"))); field.setRepeated(rep.getStepAttributeBoolean(id_step, i, "field_repeat")); inputFields[i] = field; } } catch (Exception e) { throw new KettleException( BaseMessages.getString(PKG, "RssInputMeta.Exception.ErrorReadingRepository"), e); } }
private void readData(Node stepnode) throws KettleXMLException { try { filename = XMLHandler.getTagValue(stepnode, "filename"); filenameField = XMLHandler.getTagValue(stepnode, "filename_field"); rowNumField = XMLHandler.getTagValue(stepnode, "rownum_field"); includingFilename = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "include_filename")); delimiter = XMLHandler.getTagValue(stepnode, "separator"); enclosure = XMLHandler.getTagValue(stepnode, "enclosure"); bufferSize = XMLHandler.getTagValue(stepnode, "buffer_size"); headerPresent = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "header")); lazyConversionActive = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "lazy_conversion")); isaddresult = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "add_filename_result")); runningInParallel = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "parallel")); encoding = XMLHandler.getTagValue(stepnode, "encoding"); Node fields = XMLHandler.getSubNode(stepnode, "fields"); int nrfields = XMLHandler.countNodes(fields, "field"); allocate(nrfields); for (int i = 0; i < nrfields; i++) { inputFields[i] = new TextFileInputField(); Node fnode = XMLHandler.getSubNodeByNr(fields, "field", i); inputFields[i].setName(XMLHandler.getTagValue(fnode, "name")); inputFields[i].setType(ValueMeta.getType(XMLHandler.getTagValue(fnode, "type"))); inputFields[i].setFormat(XMLHandler.getTagValue(fnode, "format")); inputFields[i].setCurrencySymbol(XMLHandler.getTagValue(fnode, "currency")); inputFields[i].setDecimalSymbol(XMLHandler.getTagValue(fnode, "decimal")); inputFields[i].setGroupSymbol(XMLHandler.getTagValue(fnode, "group")); inputFields[i].setLength(Const.toInt(XMLHandler.getTagValue(fnode, "length"), -1)); inputFields[i].setPrecision(Const.toInt(XMLHandler.getTagValue(fnode, "precision"), -1)); inputFields[i].setTrimType( ValueMeta.getTrimTypeByCode(XMLHandler.getTagValue(fnode, "trim_type"))); } } catch (Exception e) { throw new KettleXMLException("Unable to load step info from XML", e); } }
public void readRep( Repository rep, long id_step, List<DatabaseMeta> databases, Map<String, Counter> counters) throws KettleException { try { filename = rep.getStepAttributeString(id_step, "filename"); filenameField = rep.getStepAttributeString(id_step, "filename_field"); rowNumField = rep.getStepAttributeString(id_step, "rownum_field"); includingFilename = rep.getStepAttributeBoolean(id_step, "include_filename"); delimiter = rep.getStepAttributeString(id_step, "separator"); enclosure = rep.getStepAttributeString(id_step, "enclosure"); headerPresent = rep.getStepAttributeBoolean(id_step, "header"); bufferSize = rep.getStepAttributeString(id_step, "buffer_size"); lazyConversionActive = rep.getStepAttributeBoolean(id_step, "lazy_conversion"); isaddresult = rep.getStepAttributeBoolean(id_step, "add_filename_result"); runningInParallel = rep.getStepAttributeBoolean(id_step, "parallel"); encoding = rep.getStepAttributeString(id_step, "encoding"); int nrfields = rep.countNrStepAttributes(id_step, "field_name"); allocate(nrfields); for (int i = 0; i < nrfields; i++) { inputFields[i] = new TextFileInputField(); inputFields[i].setName(rep.getStepAttributeString(id_step, i, "field_name")); inputFields[i].setType( ValueMeta.getType(rep.getStepAttributeString(id_step, i, "field_type"))); inputFields[i].setFormat(rep.getStepAttributeString(id_step, i, "field_format")); inputFields[i].setCurrencySymbol(rep.getStepAttributeString(id_step, i, "field_currency")); inputFields[i].setDecimalSymbol(rep.getStepAttributeString(id_step, i, "field_decimal")); inputFields[i].setGroupSymbol(rep.getStepAttributeString(id_step, i, "field_group")); inputFields[i].setLength((int) rep.getStepAttributeInteger(id_step, i, "field_length")); inputFields[i].setPrecision( (int) rep.getStepAttributeInteger(id_step, i, "field_precision")); inputFields[i].setTrimType( ValueMeta.getTrimTypeByCode(rep.getStepAttributeString(id_step, i, "field_trim_type"))); } } catch (Exception e) { throw new KettleException("Unexpected error reading step information from the repository", e); } }
private void readData(Node stepnode) throws KettleXMLException { try { splitField = XMLHandler.getTagValue(stepnode, "splitfield"); // $NON-NLS-1$ delimiter = XMLHandler.getTagValue(stepnode, "delimiter"); // $NON-NLS-1$ final Node fields = XMLHandler.getSubNode(stepnode, "fields"); // $NON-NLS-1$ final int nrfields = XMLHandler.countNodes(fields, "field"); // $NON-NLS-1$ allocate(nrfields); for (int i = 0; i < nrfields; i++) { final Node fnode = XMLHandler.getSubNodeByNr(fields, "field", i); // $NON-NLS-1$ fieldName[i] = XMLHandler.getTagValue(fnode, "name"); // $NON-NLS-1$ fieldID[i] = XMLHandler.getTagValue(fnode, "id"); // $NON-NLS-1$ final String sidrem = XMLHandler.getTagValue(fnode, "idrem"); // $NON-NLS-1$ final String stype = XMLHandler.getTagValue(fnode, "type"); // $NON-NLS-1$ fieldFormat[i] = XMLHandler.getTagValue(fnode, "format"); // $NON-NLS-1$ fieldGroup[i] = XMLHandler.getTagValue(fnode, "group"); // $NON-NLS-1$ fieldDecimal[i] = XMLHandler.getTagValue(fnode, "decimal"); // $NON-NLS-1$ fieldCurrency[i] = XMLHandler.getTagValue(fnode, "currency"); // $NON-NLS-1$ final String slen = XMLHandler.getTagValue(fnode, "length"); // $NON-NLS-1$ final String sprc = XMLHandler.getTagValue(fnode, "precision"); // $NON-NLS-1$ fieldNullIf[i] = XMLHandler.getTagValue(fnode, "nullif"); // $NON-NLS-1$ fieldIfNull[i] = XMLHandler.getTagValue(fnode, "ifnull"); // $NON-NLS-1$ final String trim = XMLHandler.getTagValue(fnode, "trimtype"); // $NON-NLS-1$ fieldRemoveID[i] = "Y".equalsIgnoreCase(sidrem); // $NON-NLS-1$ fieldType[i] = ValueMeta.getType(stype); fieldLength[i] = Const.toInt(slen, -1); fieldPrecision[i] = Const.toInt(sprc, -1); fieldTrimType[i] = ValueMeta.getTrimTypeByCode(trim); } } catch (Exception e) { throw new KettleXMLException( BaseMessages.getString(PKG, "FieldSplitterMeta.Exception.UnableToLoadStepInfoFromXML"), e); //$NON-NLS-1$ } }
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); } }
public void readRep( Repository rep, ObjectId id_step, List<DatabaseMeta> databases, Map<String, Counter> counters) throws KettleException { try { splitField = rep.getStepAttributeString(id_step, "splitfield"); // $NON-NLS-1$ delimiter = rep.getStepAttributeString(id_step, "delimiter"); // $NON-NLS-1$ int nrfields = rep.countNrStepAttributes(id_step, "field_name"); // $NON-NLS-1$ allocate(nrfields); for (int i = 0; i < nrfields; i++) { fieldName[i] = rep.getStepAttributeString(id_step, i, "field_name"); // $NON-NLS-1$ fieldID[i] = rep.getStepAttributeString(id_step, i, "field_id"); // $NON-NLS-1$ fieldRemoveID[i] = rep.getStepAttributeBoolean(id_step, i, "field_idrem"); // $NON-NLS-1$ fieldType[i] = ValueMeta.getType(rep.getStepAttributeString(id_step, i, "field_type")); // $NON-NLS-1$ fieldFormat[i] = rep.getStepAttributeString(id_step, i, "field_format"); // $NON-NLS-1$ fieldGroup[i] = rep.getStepAttributeString(id_step, i, "field_group"); // $NON-NLS-1$ fieldDecimal[i] = rep.getStepAttributeString(id_step, i, "field_decimal"); // $NON-NLS-1$ fieldLength[i] = (int) rep.getStepAttributeInteger(id_step, i, "field_length"); // $NON-NLS-1$ fieldPrecision[i] = (int) rep.getStepAttributeInteger(id_step, i, "field_precision"); // $NON-NLS-1$ fieldNullIf[i] = rep.getStepAttributeString(id_step, i, "field_nullif"); // $NON-NLS-1$ fieldIfNull[i] = rep.getStepAttributeString(id_step, i, "field_ifnull"); // $NON-NLS-1$ fieldTrimType[i] = ValueMeta.getTrimTypeByCode( rep.getStepAttributeString(id_step, i, "field_trimtype")); // $NON-NLS-1$ } } catch (Exception e) { throw new KettleException( BaseMessages.getString( PKG, "FieldSplitterMeta.Exception.UnexpectedErrorInReadingStepInfo"), e); //$NON-NLS-1$ } }
@Override public int string2intPrimitive(String v) throws KettleValueException { return ValueMeta.getType(v); }
public void init(int index) throws KettlePluginException { m_tmpValueMeta = ValueMetaFactory.createValueMeta(ValueMeta.getType(m_kettleType)); m_outputIndex = index; }
public static final RowMetaAndData buildRow( RowGeneratorMeta meta, List<CheckResultInterface> remarks, String origin) { RowMetaInterface rowMeta = new RowMeta(); Object[] rowData = RowDataUtil.allocateRowData(meta.getFieldName().length); for (int i = 0; i < meta.getFieldName().length; i++) { int valtype = ValueMeta.getType(meta.getFieldType()[i]); if (meta.getFieldName()[i] != null) { ValueMetaInterface valueMeta = new ValueMeta(meta.getFieldName()[i], valtype); // build a value! valueMeta.setLength(meta.getFieldLength()[i]); valueMeta.setPrecision(meta.getFieldPrecision()[i]); valueMeta.setConversionMask(meta.getFieldFormat()[i]); valueMeta.setGroupingSymbol(meta.getGroup()[i]); valueMeta.setDecimalSymbol(meta.getDecimal()[i]); valueMeta.setOrigin(origin); ValueMetaInterface stringMeta = valueMeta.clone(); stringMeta.setType(ValueMetaInterface.TYPE_STRING); String stringValue = meta.getValue()[i]; // If the value is empty: consider it to be NULL. if (Const.isEmpty(stringValue)) { rowData[i] = null; if (valueMeta.getType() == ValueMetaInterface.TYPE_NONE) { String message = BaseMessages.getString( PKG, "RowGenerator.CheckResult.SpecifyTypeError", valueMeta.getName(), stringValue); remarks.add(new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, message, null)); } } else { // Convert the data from String to the specified type ... // try { rowData[i] = valueMeta.convertData(stringMeta, stringValue); } catch (KettleValueException e) { switch (valueMeta.getType()) { case ValueMetaInterface.TYPE_NUMBER: { String message = BaseMessages.getString( PKG, "RowGenerator.BuildRow.Error.Parsing.Number", valueMeta.getName(), stringValue, e.toString()); remarks.add( new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, message, null)); } break; case ValueMetaInterface.TYPE_DATE: { String message = BaseMessages.getString( PKG, "RowGenerator.BuildRow.Error.Parsing.Date", valueMeta.getName(), stringValue, e.toString()); remarks.add( new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, message, null)); } break; case ValueMetaInterface.TYPE_INTEGER: { String message = BaseMessages.getString( PKG, "RowGenerator.BuildRow.Error.Parsing.Integer", valueMeta.getName(), stringValue, e.toString()); remarks.add( new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, message, null)); } break; case ValueMetaInterface.TYPE_BIGNUMBER: { String message = BaseMessages.getString( PKG, "RowGenerator.BuildRow.Error.Parsing.BigNumber", valueMeta.getName(), stringValue, e.toString()); remarks.add( new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, message, null)); } break; default: // Boolean and binary don't throw errors normally, so it's probably an unspecified // error problem... { String message = BaseMessages.getString( PKG, "RowGenerator.CheckResult.SpecifyTypeError", valueMeta.getName(), stringValue); remarks.add( new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, message, null)); } break; } } } // Now add value to the row! // This is in fact a copy from the fields row, but now with data. rowMeta.addValueMeta(valueMeta); } } return new RowMetaAndData(rowMeta, rowData); }
private void readData(Node stepnode, List<? extends SharedObjectInterface> databases) throws KettleXMLException { try { String dtype; String csize; String con = XMLHandler.getTagValue(stepnode, "connection"); // $NON-NLS-1$ databaseMeta = DatabaseMeta.findDatabase(databases, con); cached = "Y" .equalsIgnoreCase( XMLHandler.getTagValue(stepnode, "cache")); // $NON-NLS-1$ //$NON-NLS-2$ loadingAllDataInCache = "Y" .equalsIgnoreCase( XMLHandler.getTagValue(stepnode, "cache_load_all")); // $NON-NLS-1$ //$NON-NLS-2$ csize = XMLHandler.getTagValue(stepnode, "cache_size"); // $NON-NLS-1$ cacheSize = Const.toInt(csize, 0); schemaName = XMLHandler.getTagValue(stepnode, "lookup", "schema"); // $NON-NLS-1$ //$NON-NLS-2$ tablename = XMLHandler.getTagValue(stepnode, "lookup", "table"); // $NON-NLS-1$ //$NON-NLS-2$ Node lookup = XMLHandler.getSubNode(stepnode, "lookup"); // $NON-NLS-1$ int nrkeys = XMLHandler.countNodes(lookup, "key"); // $NON-NLS-1$ int nrvalues = XMLHandler.countNodes(lookup, "value"); // $NON-NLS-1$ allocate(nrkeys, nrvalues); for (int i = 0; i < nrkeys; i++) { Node knode = XMLHandler.getSubNodeByNr(lookup, "key", i); // $NON-NLS-1$ streamKeyField1[i] = XMLHandler.getTagValue(knode, "name"); // $NON-NLS-1$ tableKeyField[i] = XMLHandler.getTagValue(knode, "field"); // $NON-NLS-1$ keyCondition[i] = XMLHandler.getTagValue(knode, "condition"); // $NON-NLS-1$ if (keyCondition[i] == null) keyCondition[i] = "="; // $NON-NLS-1$ streamKeyField2[i] = XMLHandler.getTagValue(knode, "name2"); // $NON-NLS-1$ } for (int i = 0; i < nrvalues; i++) { Node vnode = XMLHandler.getSubNodeByNr(lookup, "value", i); // $NON-NLS-1$ returnValueField[i] = XMLHandler.getTagValue(vnode, "name"); // $NON-NLS-1$ returnValueNewName[i] = XMLHandler.getTagValue(vnode, "rename"); // $NON-NLS-1$ if (returnValueNewName[i] == null) returnValueNewName[i] = returnValueField[i]; // default: the same name! returnValueDefault[i] = XMLHandler.getTagValue(vnode, "default"); // $NON-NLS-1$ dtype = XMLHandler.getTagValue(vnode, "type"); // $NON-NLS-1$ returnValueDefaultType[i] = ValueMeta.getType(dtype); if (returnValueDefaultType[i] < 0) { // logError("unknown default value type: "+dtype+" for value "+value[i]+", default to // type: String!"); returnValueDefaultType[i] = ValueMetaInterface.TYPE_STRING; } } orderByClause = XMLHandler.getTagValue(lookup, "orderby"); // Optional, can by null //$NON-NLS-1$ failingOnMultipleResults = "Y" .equalsIgnoreCase( XMLHandler.getTagValue(lookup, "fail_on_multiple")); // $NON-NLS-1$ //$NON-NLS-2$ eatingRowOnLookupFailure = "Y" .equalsIgnoreCase( XMLHandler.getTagValue( lookup, "eat_row_on_failure")); // $NON-NLS-1$ //$NON-NLS-2$ } catch (Exception e) { throw new KettleXMLException( Messages.getString("DatabaseLookupMeta.ERROR0001.UnableToLoadStepFromXML"), e); //$NON-NLS-1$ } }