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 ); } }
private void loadBatch() throws TranslatorException { if(null != resultBatch) { // if we have an old batch, then we have to get new results results = connection.queryMore(results.getQueryLocator(), context.getBatchSize()); } resultBatch = new ArrayList<List<Object>>(); topResultIndex = 0; for(SObject sObject : results.getRecords()) { if (sObject == null) { continue; } List<Object[]> result = getObjectData(sObject); for(Iterator<Object[]> i = result.iterator(); i.hasNext(); ) { resultBatch.add(Arrays.asList(i.next())); } } }
public synchronized boolean equals(java.lang.Object obj) { if (!(obj instanceof QueryResult)) return false; QueryResult other = (QueryResult) obj; if (obj == null) return false; if (this == obj) return true; if (__equalsCalc != null) { return (__equalsCalc == obj); } __equalsCalc = obj; boolean _equals; _equals = true && this.done == other.isDone() && ((this.queryLocator == null && other.getQueryLocator() == null) || (this.queryLocator != null && this.queryLocator.equals(other.getQueryLocator()))) && ((this.records == null && other.getRecords() == null) || (this.records != null && java.util.Arrays.equals(this.records, other.getRecords()))) && this.size == other.getSize(); __equalsCalc = null; return _equals; }
public synchronized int hashCode() { if (__hashCodeCalc) { return 0; } __hashCodeCalc = true; int _hashCode = 1; _hashCode += (isDone() ? Boolean.TRUE : Boolean.FALSE).hashCode(); if (getQueryLocator() != null) { _hashCode += getQueryLocator().hashCode(); } if (getRecords() != null) { for (int i = 0; i < java.lang.reflect.Array.getLength(getRecords()); i++) { java.lang.Object obj = java.lang.reflect.Array.get(getRecords(), i); if (obj != null && !obj.getClass().isArray()) { _hashCode += obj.hashCode(); } } } _hashCode += getSize(); __hashCodeCalc = false; return _hashCode; }
if(!result.isDone()) { this.results = this.connection.queryMore(results.getQueryLocator(), context.getBatchSize()); this.currentBatch = loadBatch(this.results);
@Override public boolean next() { final int index = _recordIndex.getAndIncrement(); if (index >= _records.length) { if (_queryResult.isDone()) { _record = null; return false; } // go to next page String queryLocator = _queryResult.getQueryLocator(); try { _queryResult = _connection.queryMore(queryLocator); _records = _queryResult.getRecords(); _recordIndex.set(0); return next(); } catch (ConnectionException e) { throw SalesforceUtils.wrapException(e, "Failed to invoke queryMore service"); } } _record = _records[index]; return true; }
@Override public boolean next() { final int index = _recordIndex.getAndIncrement(); if (index >= _records.length) { if (_queryResult.isDone()) { _record = null; return false; } // go to next page String queryLocator = _queryResult.getQueryLocator(); try { _queryResult = _connection.queryMore(queryLocator); _records = _queryResult.getRecords(); _recordIndex.set(0); return next(); } catch (ConnectionException e) { throw SalesforceUtils.wrapException(e, "Failed to invoke queryMore service"); } } _record = _records[index]; return true; }
@Override public boolean next() { final int index = _recordIndex.getAndIncrement(); if (index >= _records.length) { if (_queryResult.isDone()) { _record = null; return false; } // go to next page String queryLocator = _queryResult.getQueryLocator(); try { _queryResult = _connection.queryMore(queryLocator); _records = _queryResult.getRecords(); _recordIndex.set(0); return next(); } catch (ConnectionException e) { throw SalesforceUtils.wrapException(e, "Failed to invoke queryMore service"); } } _record = _records[index]; return true; }
@Override public boolean advance() throws IOException { inputRecordsIndex++; // Fast return conditions. if (inputRecordsIndex < inputRecords.length) { dataCount++; return true; } if (inputResult.isDone()) { return false; } try { inputResult = getConnection().queryMore(inputResult.getQueryLocator()); inputRecords = inputResult.getRecords(); inputRecordsIndex = 0; return inputResult.getSize() > 0; } catch (ConnectionException e) { // Wrap the exception in an IOException. throw new IOException(e); } }
@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; }
@Override public boolean advance() throws IOException { inputRecordsIndex++; // Fast return conditions. if (inputRecordsIndex < inputRecords.length) { dataCount++; return true; } if (inputResult.isDone()) { return false; } try { // Get a new result set based on batch size inputResult = getConnection().queryMore(inputResult.getQueryLocator()); inputRecords = inputResult.getRecords(); inputRecordsIndex = 0; boolean advance = inputResult.getSize() > 0; if (advance) { // New result set available to retrieve dataCount++; } return advance; } catch (ConnectionException e) { // Wrap the exception in an IOException. throw new IOException(e); } }
@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; }
@Override public boolean advance() throws IOException { inputRecordsIndex++; // Fast return conditions. if (inputRecordsIndex < inputRecords.length) { dataCount++; return true; } if (inputResult.isDone()) { return false; } try { // Get a new result set based on batch size inputResult = getConnection().queryMore(inputResult.getQueryLocator()); inputRecords = inputResult.getRecords(); inputRecordsIndex = 0; boolean advance = inputResult.getSize() > 0; if (advance) { // New result set available to retrieve dataCount++; } return advance; } catch (ConnectionException e) { // Wrap the exception in an IOException. throw new IOException(e); } }
@Override public boolean advance() throws IOException { inputRecordsIndex++; // Fast return conditions. if (inputRecordsIndex < inputRecords.length) { dataCount++; return true; } if ((inputResult == null || inputResult.isDone()) && queryIndex < queryStringList.size()) { try { 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; boolean isAdvanced = inputResult.getSize() > 0; if (isAdvanced) { dataCount++; } return isAdvanced; } catch (ConnectionException e) { throw new IOException(e); } } return false; }
@Override public boolean advance() throws IOException { inputRecordsIndex++; // Fast return conditions. if (inputRecordsIndex < inputRecords.length) { dataCount++; return true; } if ((inputResult == null || inputResult.isDone()) && queryIndex < queryStringList.size()) { try { 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; boolean isAdvanced = inputResult.getSize() > 0; if (isAdvanced) { dataCount++; } return isAdvanced; } catch (ConnectionException e) { throw new IOException(e); } } return false; }
break; results = connection.queryMore(results.getQueryLocator(), batchSize);
@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); } }
qr = c.queryMore(qr.getQueryLocator()); firstBatch = false;