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); } }
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( ValueMetaFactory.getIdForValueMeta( 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); } }
public Object clone() { RssInputMeta retval = (RssInputMeta) super.clone(); int nrFields = inputFields.length; int nrUrl = url.length; retval.allocate(nrUrl, nrFields); for (int i = 0; i < nrUrl; i++) { retval.url[i] = url[i]; } for (int i = 0; i < nrFields; i++) { if (inputFields[i] != null) { retval.inputFields[i] = (RssInputField) inputFields[i].clone(); } } return retval; }
public void setDefault() { urlInField = false; urlFieldname = ""; includeRowNumber = false; rowNumberField = ""; includeUrl = false; urlField = ""; readfrom = ""; int nrFields = 0; int nrUrl = 0; allocate(nrUrl, nrFields); for (int i = 0; i < nrUrl; i++) { url[i] = ""; } for (int i = 0; i < nrFields; i++) { inputFields[i] = new RssInputField("field" + (i + 1)); } rowLimit = 0; }