Search in sources :

Example 11 with SalesforceConnection

use of org.pentaho.di.trans.steps.salesforce.SalesforceConnection in project pentaho-kettle by pentaho.

the class SalesforceInsertDialog method getModulesList.

private void getModulesList() {
    if (!gotModule) {
        SalesforceConnection connection = null;
        try {
            String selectedField = wModule.getText();
            wModule.removeAll();
            connection = getConnection();
            // return
            wModule.setItems(connection.getAllAvailableObjects(false));
            if (!Utils.isEmpty(selectedField)) {
                wModule.setText(selectedField);
            }
            gotModule = true;
            getModulesListError = false;
        } catch (Exception e) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "SalesforceInsertDialog.ErrorRetrieveModules.DialogTitle"), BaseMessages.getString(PKG, "SalesforceInsertDialog.ErrorRetrieveData.ErrorRetrieveModules"), e);
            getModulesListError = true;
        } finally {
            if (connection != null) {
                try {
                    connection.close();
                } catch (Exception e) {
                /* Ignore */
                }
            }
        }
    }
}
Also used : ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) SalesforceConnection(org.pentaho.di.trans.steps.salesforce.SalesforceConnection) KettleException(org.pentaho.di.core.exception.KettleException)

Example 12 with SalesforceConnection

use of org.pentaho.di.trans.steps.salesforce.SalesforceConnection in project pentaho-kettle by pentaho.

the class SalesforceUpdateDialog method getModuleFields.

private String[] getModuleFields() throws KettleException {
    SalesforceUpdateMeta meta = new SalesforceUpdateMeta();
    getInfo(meta);
    SalesforceConnection connection = null;
    String url = transMeta.environmentSubstitute(meta.getTargetURL());
    try {
        String selectedModule = transMeta.environmentSubstitute(meta.getModule());
        // Define a new Salesforce connection
        connection = new SalesforceConnection(log, url, transMeta.environmentSubstitute(meta.getUsername()), Utils.resolvePassword(transMeta, meta.getPassword()));
        int realTimeOut = Const.toInt(transMeta.environmentSubstitute(meta.getTimeout()), 0);
        connection.setTimeOut(realTimeOut);
        // connect to Salesforce
        connection.connect();
        // return fieldsname for the module
        return connection.getFields(selectedModule);
    } catch (Exception e) {
        throw new KettleException("Erreur getting fields from module [" + url + "]!", e);
    } finally {
        if (connection != null) {
            try {
                connection.close();
            } catch (Exception e) {
            /* Ignore */
            }
        }
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) SalesforceUpdateMeta(org.pentaho.di.trans.steps.salesforceupdate.SalesforceUpdateMeta) SalesforceConnection(org.pentaho.di.trans.steps.salesforce.SalesforceConnection) KettleException(org.pentaho.di.core.exception.KettleException)

Aggregations

SalesforceConnection (org.pentaho.di.trans.steps.salesforce.SalesforceConnection)12 KettleException (org.pentaho.di.core.exception.KettleException)11 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)8 Field (com.sforce.soap.partner.Field)2 SalesforceInputMeta (org.pentaho.di.trans.steps.salesforceinput.SalesforceInputMeta)2 SalesforceUpdateMeta (org.pentaho.di.trans.steps.salesforceupdate.SalesforceUpdateMeta)2 SalesforceUpsertMeta (org.pentaho.di.trans.steps.salesforceupsert.SalesforceUpsertMeta)2 FieldType (com.sforce.soap.partner.FieldType)1 XmlObject (com.sforce.ws.bind.XmlObject)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Cursor (org.eclipse.swt.graphics.Cursor)1 MessageBox (org.eclipse.swt.widgets.MessageBox)1 TableItem (org.eclipse.swt.widgets.TableItem)1 SourceToTargetMapping (org.pentaho.di.core.SourceToTargetMapping)1 RowMeta (org.pentaho.di.core.row.RowMeta)1 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)1 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)1 ValueMetaNone (org.pentaho.di.core.row.value.ValueMetaNone)1 SalesforceStepMeta (org.pentaho.di.trans.steps.salesforce.SalesforceStepMeta)1