Search in sources :

Example 1 with XMLInputSaxFieldRetriever

use of org.pentaho.di.trans.steps.xmlinputsax.XMLInputSaxFieldRetriever in project pentaho-kettle by pentaho.

the class XMLInputSaxDialog method get.

// 
private void get() {
    try {
        XMLInputSaxMeta meta = new XMLInputSaxMeta();
        getInfo(meta);
        // OK, let's try to walk through the complete tree
        List<XMLInputSaxField> fields = new ArrayList<XMLInputSaxField>();
        // Keep the list of positions
        String[] filePaths = meta.getFilePaths(transMeta);
        if (meta.getInputPosition().length == 0) {
            // error
            MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
            mb.setMessage(BaseMessages.getString(PKG, "XMLInputSaxDialog.Dialog.NoElements.Message"));
            mb.setText(BaseMessages.getString(PKG, "XMLInputSaxDialog.Dialog.NoElements.Title"));
            mb.open();
            return;
        }
        for (int f = 0; f < filePaths.length; f++) {
            XMLInputSaxFieldRetriever fieldRetreiver = new XMLInputSaxFieldRetriever(log, filePaths[f], meta);
            fields = fieldRetreiver.getFields();
            // add the values to the grid...
            for (int i = 0; i < fields.size(); i++) {
                XMLInputSaxField iF = fields.get(i);
                TableItem item = new TableItem(wFields.table, SWT.NONE);
                item.setText(1, iF.getName());
                item.setText(2, iF.getTypeDesc());
                item.setText(11, iF.getFieldPositionsCode(meta.getInputPosition().length));
            }
            wFields.removeEmptyRows();
            wFields.setRowNums();
            wFields.optWidth(true);
        }
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "XMLInputSaxDialog.Dialog.ErrorParsingInputData.Title"), BaseMessages.getString(PKG, "XMLInputSaxDialog.Dialog.ErrorParsingInputData.Message"), e);
        System.out.println(e.getMessage());
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) TableItem(org.eclipse.swt.widgets.TableItem) ArrayList(java.util.ArrayList) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) XMLInputSaxFieldRetriever(org.pentaho.di.trans.steps.xmlinputsax.XMLInputSaxFieldRetriever) XMLInputSaxMeta(org.pentaho.di.trans.steps.xmlinputsax.XMLInputSaxMeta) XMLInputSaxField(org.pentaho.di.trans.steps.xmlinputsax.XMLInputSaxField) MessageBox(org.eclipse.swt.widgets.MessageBox)

Aggregations

ArrayList (java.util.ArrayList)1 MessageBox (org.eclipse.swt.widgets.MessageBox)1 TableItem (org.eclipse.swt.widgets.TableItem)1 KettleException (org.pentaho.di.core.exception.KettleException)1 XMLInputSaxField (org.pentaho.di.trans.steps.xmlinputsax.XMLInputSaxField)1 XMLInputSaxFieldRetriever (org.pentaho.di.trans.steps.xmlinputsax.XMLInputSaxFieldRetriever)1 XMLInputSaxMeta (org.pentaho.di.trans.steps.xmlinputsax.XMLInputSaxMeta)1 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)1