use of org.pentaho.di.trans.steps.salesforceupsert.SalesforceUpsertMeta in project pentaho-kettle by pentaho.
the class SalesforceUpsertDialog method getModulesList.
private void getModulesList() {
if (!gotModule) {
SalesforceConnection connection = null;
try {
SalesforceUpsertMeta meta = new SalesforceUpsertMeta();
getInfo(meta);
String url = transMeta.environmentSubstitute(meta.getTargetURL());
String selectedField = wModule.getText();
wModule.removeAll();
// Define a new Salesforce connection
connection = new SalesforceConnection(log, url, transMeta.environmentSubstitute(meta.getUsername()), Utils.resolvePassword(transMeta, meta.getPassword()));
// connect to Salesforce
connection.connect();
// 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, "SalesforceUpsertDialog.ErrorRetrieveModules.DialogTitle"), BaseMessages.getString(PKG, "SalesforceUpsertDialog.ErrorRetrieveData.ErrorRetrieveModules"), e);
getModulesListError = true;
} finally {
if (connection != null) {
try {
connection.close();
} catch (Exception e) {
/* Ignore */
}
}
}
}
}
use of org.pentaho.di.trans.steps.salesforceupsert.SalesforceUpsertMeta in project pentaho-kettle by pentaho.
the class SalesforceUpsertDialog method getModuleFields.
private String[] getModuleFields() throws KettleException {
if (moduleFields != null) {
return moduleFields;
} else if (skipFetchModules() || Utils.isEmpty(wModule.getText())) {
getModulesListError = false;
return new String[0];
}
getModulesListError = true;
SalesforceUpsertMeta meta = new SalesforceUpsertMeta();
getInfo(meta);
String url = transMeta.environmentSubstitute(meta.getTargetURL());
String selectedModule = transMeta.environmentSubstitute(meta.getModule());
// Define a new Salesforce connection
SalesforceConnection 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);
Cursor busy = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
try {
shell.setCursor(busy);
// connect to Salesforce
connection.connect();
moduleFields = connection.getFields(selectedModule, excludeNonUpdatableFields);
getModulesListError = false;
return moduleFields;
} finally {
if (connection != null) {
try {
connection.close();
} catch (Exception e) {
/* Ignore */
}
}
shell.setCursor(null);
busy.dispose();
}
}
use of org.pentaho.di.trans.steps.salesforceupsert.SalesforceUpsertMeta in project pentaho-kettle by pentaho.
the class SalesforceUpsertDialog method getInfo.
@Override
protected void getInfo(SalesforceStepMeta in) throws KettleException {
SalesforceUpsertMeta meta = (SalesforceUpsertMeta) in;
// return value
stepname = wStepname.getText();
// copy info to SalesforceUpsertMeta class (input)
meta.setTargetURL(Const.NVL(wURL.getText(), SalesforceConnectionUtils.TARGET_DEFAULT_URL));
meta.setUsername(wUserName.getText());
meta.setPassword(wPassword.getText());
meta.setModule(Const.NVL(wModule.getText(), "Account"));
meta.setUpsertField(Const.NVL(wUpsertField.getText(), "Id"));
meta.setSalesforceIDFieldName(wSalesforceIDFieldName.getText());
meta.setBatchSize(wBatchSize.getText());
int nrfields = wReturn.nrNonEmpty();
meta.allocate(nrfields);
// CHECKSTYLE:Indentation:OFF
for (int i = 0; i < nrfields; i++) {
TableItem item = wReturn.getNonEmpty(i);
meta.getUpdateLookup()[i] = item.getText(1);
meta.getUpdateStream()[i] = item.getText(2);
meta.getUseExternalId()[i] = Boolean.valueOf("Y".equals(item.getText(3)));
}
meta.setCompression(wUseCompression.getSelection());
meta.setTimeout(Const.NVL(wTimeOut.getText(), "0"));
meta.setRollbackAllChangesOnError(wRollbackAllChangesOnError.getSelection());
}
Aggregations