if ( !specifyQuery ) { DescribeSObjectResult describeSObjectResult = getBinding().describeSObject( getModule() ); if ( describeSObjectResult == null ) { throw new KettleException( BaseMessages.getString( PKG, "SalesforceInput.ErrorGettingObject" ) ); case SalesforceConnectionUtils.RECORDS_FILTER_UPDATED: GetUpdatedResult updatedRecords = getBinding().getUpdated( getModule(), this.startDate, this.endDate ); getBinding().retrieve( this.fieldsList, getModule(), list.toArray( new String[list.size()] ) ); System.arraycopy( s, 0, this.sObjects, desPos, s.length ); this.sObjects = getBinding().retrieve( this.fieldsList, getModule(), ids ); getBinding().getDeleted( getModule(), this.startDate, this.endDate ); getDeletedList.put( dr.getId(), dr.getDeletedDate().getTime() ); this.qr = getBinding().queryAll( getSQL() ); this.sObjects = getQueryResult().getRecords(); if ( this.sObjects != null ) { this.qr = isQueryAll() ? getBinding().queryAll( getSQL() ) : getBinding().query( getSQL() ); this.sObjects = getQueryResult().getRecords(); this.queryResultSize = getQueryResult().getSize();
public SaveResult[] update( SObject[] sfBuffer ) throws KettleException { try { return getBinding().update( sfBuffer ); } catch ( Exception e ) { throw new KettleException( BaseMessages.getString( PKG, "SalesforceInput.ErrorUpdate", e ) ); } }
public SaveResult[] insert( SObject[] sfBuffer ) throws KettleException { try { List<SObject> normalizedSfBuffer = new ArrayList<>(); for ( SObject part : sfBuffer ) { if ( part != null ) { normalizedSfBuffer.add( part ); } } return getBinding().create( normalizedSfBuffer.toArray( new SObject[normalizedSfBuffer.size()] ) ); } catch ( Exception e ) { throw new KettleException( BaseMessages.getString( PKG, "SalesforceInput.ErrorInsert", e ) ); } }
pConnection.setAllOrNoneHeader( true ); pConnection.login( config.getUsername(), Encr.decryptPasswordOptionallyEncrypted( config.getPassword() ) ); pConnection.setSessionHeader( loginResult.getSessionId() ); config.setServiceEndpoint( loginResult.getServerUrl() ); this.userInfo = pConnection.getUserInfo(); if ( log.isDebug() ) { log.logDebug( BaseMessages.getString( PKG, "SalesforceInput.Log.UserInfos" ) this.serverTimestamp = pConnection.getServerTimestamp().getTimestamp().getTime(); if ( log.isDebug() ) { BaseMessages.getString( PKG, "SalesforceInput.Log.ServerTimestamp", getServerTimestamp() );
protected QueryResult executeSalesforceQuery() throws IOException, ConnectionException { TSalesforceInputProperties inProperties = (TSalesforceInputProperties) properties; getConnection().setQueryOptions(inProperties.batchSize.getValue()); if (inProperties.includeDeleted.getValue()) { return getConnection().queryAll(getQueryString(inProperties)); } else { return getConnection().query(getQueryString(inProperties)); } }
@Override public void execute() throws BuildException { try { PartnerConnection pc = ConnectionFactory.getPartnerConnection(getConfig()); String soql = String.format(FORMAT_SOQL, objectApiName); QueryResult qr = pc.query(soql); Boolean done = false; log(String.format(FORMAT_DELETE_MSG, qr.getSize(), objectApiName)); if (qr.getSize() > 0) { while (!done) { com.sforce.soap.partner.sobject.SObject[] records = qr.getRecords(); String[] ids = new String[records.length]; for (int i = 0; i<records.length; ++i) { ids[i] = (String)records[i].getField("Id"); } pc.delete(ids); if (qr.isDone()) { done = true; } else { qr = pc.queryMore(qr.getQueryLocator()); } } } } catch (ConnectionException e) { handleException(e); } }
public DeleteResult[] delete( String[] id ) throws KettleException { try { return getBinding().delete( id ); } catch ( Exception e ) { throw new KettleException( BaseMessages.getString( PKG, "SalesforceInput.ErrorDelete", e ) ); } }
try { dgr = getBinding().describeGlobal();
public XmlObject[] getElements() throws Exception { // Query first this.qr = getBinding().query( getSQL() ); // and then return records SObject con = getQueryResult().getRecords()[0]; if ( con == null ) { return null; } return getChildren( con ); }
@Override public boolean start() throws IOException { try { result = getResult(); queryStringList = getQueryStringList(result); if (queryStringList.size() == 0) { return false; } inputResult = getConnection().queryAll(queryStringList.get(queryIndex++)); inputRecords = inputResult.getRecords(); while (!inputResult.isDone()) { inputResult = getConnection().queryMore(inputResult.getQueryLocator()); inputRecords = ArrayUtils.addAll(inputRecords, inputResult.getRecords()); } inputRecordsIndex = 0; } catch (ConnectionException e) { throw new IOException(e); } boolean startable = inputRecords.length > 0; if (startable) { dataCount++; } return startable; }
for (DescribeGlobalSObjectResult dgsr : conn.describeGlobal().getSobjects()) { allOrgObjectNames.add(dgsr.getName()); conn.describeSObjects(objectNameBatch.toArray(new String[objectNameBatch.size()])); GetUserInfoResult userInfo = conn.getUserInfo();
public boolean queryMore() throws KettleException { try { // check the done attribute on the QueryResult and call QueryMore // with the QueryLocator if there are more records to be retrieved if ( !getQueryResult().isDone() ) { this.qr = getBinding().queryMore( getQueryResult().getQueryLocator() ); this.sObjects = getQueryResult().getRecords(); if ( this.sObjects != null ) { this.recordsCount = this.sObjects.length; } this.queryResultSize = getQueryResult().getSize(); return true; } else { // Query is done .. we finished ! return false; } } catch ( Exception e ) { throw new KettleException( BaseMessages.getString( PKG, "SalesforceInput.Error.QueringMore" ), e ); } }
public PartnerConnection createBinding( ConnectorConfig config ) throws ConnectionException { if ( this.binding == null ) { this.binding = new PartnerConnection( config ); } return this.binding; }
public Field[] getObjectFields( String objectName ) throws KettleException { DescribeSObjectResult describeSObjectResult = null; try { // Get object describeSObjectResult = getBinding().describeSObject( objectName ); if ( describeSObjectResult == null ) { return null; } if ( !describeSObjectResult.isQueryable() ) { throw new KettleException( BaseMessages.getString( PKG, "SalesforceInputDialog.ObjectNotQueryable", this.module ) ); } else { // we can query this object return describeSObjectResult.getFields(); } } catch ( Exception e ) { throw new KettleException( BaseMessages.getString( PKG, "SalesforceInput.Error.GettingModuleFields", this.module ), e ); } finally { if ( describeSObjectResult != null ) { describeSObjectResult = null; } } }
@Override public com.sforce.soap.partner.IDescribeSObjectResult[] describeSObjects(java.lang.String[] sObjectType) throws com.sforce.ws.ConnectionException { return connection.describeSObjects( sObjectType); }
/** * {@inheritDoc} */ public void send(String message) { SObject user = new SObject(); user.setType("User"); try { user.setId(connection.getUserInfo().getUserId()); user.setField("CurrentStatus", message); SaveResult[] results = connection.update(new SObject[]{user}); if (!results[0].isSuccess()) { l.error("Error updating user status: " + results[0].getErrors()[0].getMessage()); throw new SfdcException("Error updating user status: " + results[0].getErrors()[0].getMessage()); } } catch (ConnectionException e) { l.debug("Error sending the SFDC chatter message.", e); throw new SfdcException("Error sending the SFDC chatter message.", e); } }
config.setSessionId(securityContext.getSessionId()); GetUserInfoResult userInfoResult = Connector.newConnection(config).getUserInfo(); results = Connector.newConnection(config).retrieve("Name", "Profile", new String[] {userInfoResult.getProfileId()}); } catch (ConnectionException e) {
connection.setAllOrNoneHeader(true); try { SaveResult[] results = connection.update(objects); checkForErrors(results); } finally { try { connection.setAllOrNoneHeader(false); } finally { connection.clearConditionalRequestHeader();
@Override public com.sforce.soap.partner.IGetUserInfoResult getUserInfo() throws com.sforce.ws.ConnectionException { return connection.getUserInfo(); }
public QueryResult queryMore(String queryLocator, int batchSize) throws ResourceException { if(batchSize > 2000) { batchSize = 2000; LogManager.logDetail(LogConstants.CTX_CONNECTOR, "reduced.batch.size"); //$NON-NLS-1$ } partnerConnection.setQueryOptions(batchSize); try { return partnerConnection.queryMore(queryLocator); } catch (InvalidFieldFault e) { throw new ResourceException(e); } catch (UnexpectedErrorFault e) { throw new ResourceException(e); } catch (InvalidQueryLocatorFault e) { throw new ResourceException(e); } catch (ConnectionException e) { throw new ResourceException(e); } finally { partnerConnection.clearQueryOptions(); } }