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 ); } }
this.queryResultSize = getQueryResult().getSize(); break;
@Override public boolean start() throws IOException { try { inputResult = executeSalesforceQuery(); if (inputResult.getSize() == 0) { return false; } inputRecords = inputResult.getRecords(); inputRecordsIndex = 0; boolean start = inputRecords.length > 0; if (start) { dataCount++; } return start; } catch (ConnectionException e) { // Wrap the exception in an IOException. throw new IOException(e); } }
@Override public boolean start() throws IOException { try { inputResult = executeSalesforceQuery(); if (inputResult.getSize() == 0) { return false; } inputRecords = inputResult.getRecords(); inputRecordsIndex = 0; boolean startable = inputRecords.length > 0; if (startable) { dataCount++; } return startable; } catch (ConnectionException e) { // Wrap the exception in an IOException. throw new IOException(e); } }
@Override public boolean start() throws IOException { try { inputResult = executeSalesforceQuery(); if (inputResult.getSize() == 0) { return false; } inputRecords = inputResult.getRecords(); inputRecordsIndex = 0; boolean start = inputRecords.length > 0; if (start) { dataCount++; } return start; } catch (ConnectionException e) { // Wrap the exception in an IOException. throw new IOException(e); } }
@Override protected Number executeCountQuery(Table table, List<FilterItem> whereItems, boolean functionApproximationAllowed) { final String query; try { final StringBuilder sb = new StringBuilder(); sb.append("SELECT COUNT() FROM "); sb.append(table.getName()); boolean firstWhere = true; for (FilterItem filterItem : whereItems) { if (firstWhere) { sb.append(" WHERE "); firstWhere = false; } else { sb.append(" AND "); } rewriteFilterItem(sb, filterItem); } query = sb.toString(); } catch (UnsupportedOperationException e) { logger.debug("Failed to rewrite count query, falling back to client side counting", e); // unable to rewrite to SOQL, counting will be done client side. return null; } final QueryResult queryResult = executeSoqlQuery(query); assert queryResult.isDone(); return queryResult.getSize(); }
@Override protected Number executeCountQuery(Table table, List<FilterItem> whereItems, boolean functionApproximationAllowed) { final String query; try { final StringBuilder sb = new StringBuilder(); sb.append("SELECT COUNT() FROM "); sb.append(table.getName()); boolean firstWhere = true; for (FilterItem filterItem : whereItems) { if (firstWhere) { sb.append(" WHERE "); firstWhere = false; } else { sb.append(" AND "); } rewriteFilterItem(sb, filterItem); } query = sb.toString(); } catch (UnsupportedOperationException e) { logger.debug("Failed to rewrite count query, falling back to client side counting", e); // unable to rewrite to SOQL, counting will be done client side. return null; } final QueryResult queryResult = executeSoqlQuery(query); assert queryResult.isDone(); return queryResult.getSize(); }
@Override protected Number executeCountQuery(Table table, List<FilterItem> whereItems, boolean functionApproximationAllowed) { final String query; try { final StringBuilder sb = new StringBuilder(); sb.append("SELECT COUNT() FROM "); sb.append(table.getName()); boolean firstWhere = true; for (FilterItem filterItem : whereItems) { if (firstWhere) { sb.append(" WHERE "); firstWhere = false; } else { sb.append(" AND "); } rewriteFilterItem(sb, filterItem); } query = sb.toString(); } catch (UnsupportedOperationException e) { logger.debug("Failed to rewrite count query, falling back to client side counting", e); // unable to rewrite to SOQL, counting will be done client side. return null; } final QueryResult queryResult = executeSoqlQuery(query); assert queryResult.isDone(); return queryResult.getSize(); }
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; }
@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(); inputRecordsIndex = 0; boolean isAdvanced = inputResult.getSize() > 0; if (isAdvanced) { dataCount++; } return isAdvanced; } catch (ConnectionException e) { throw new IOException(e); } } return false; }
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; }
@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 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; }
@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 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); } }
@Override public void execute() throws BuildException { try { PartnerConnection pc = ConnectionFactory.getPartnerConnection(getConfig()); QueryResult result = pc.query(SOQL_JOBS()); if (result!=null && result.getSize() > 0) { log(String.format("Clearing %d scheduled jobs...", result.getSize())); SoapConnection tc = ConnectionFactory.getToolingConnection(pc, getConfig()); for (SObject o : result.getRecords()) { String jobId = (String) o.getId(); log("Aborting Job: " + jobId); executeApex(tc, String.format(APEX_ABORT, jobId)); } } else { log("No scheduled job found"); } } catch (ConnectionException e) { handleException(e); } catch (Exception e) { log(e.getMessage()); } } }
@Override public void execute() throws BuildException { checkAttributes(); // prepare where clause try { SalesforceConfig conf = getConfig(); PartnerConnection connection = ConnectionFactory.getPartnerConnection(conf); log(String.format("Getting RecordTypeId: %s.%s", object, developerName)); QueryResult result = connection.query(getCompiledQuery()); if (result.getSize() == 1) { String value = (String) result.getRecords()[0].getField("Id"); getProject().setNewProperty(propertyRef, value); } else { throw new BuildException("Unable to find a unique result"); } } catch (ConnectionException e) { throw new BuildException(e.getLocalizedMessage()); } }
/** * Locates this object in the datastore. * * @param op The ObjectProvider for the object to be found */ @Override public void locateObject(ObjectProvider op) { ForceManagedConnection mconn = (ForceManagedConnection) storeManager.getConnection(op.getExecutionContext()); try { AbstractClassMetaData acmd = op.getClassMetaData(); TableImpl table = storeManager.getTable(acmd); QueryResult qr = ((PartnerConnection) mconn.getConnection()) .query("select count() from " + table.getTableName().getForceApiName() + " where id='" + op.provideField(op.getClassMetaData().getPKMemberPositions()[0]) + "'"); if (qr.getSize() == 0) { throw new NucleusObjectNotFoundException(); } } catch (ConnectionException x) { throw new NucleusDataStoreException(x.getMessage(), x); } finally { mconn.release(); } }
/** * Locates this object in the datastore. * * @param op The ObjectProvider for the object to be found */ @Override public void locateObject(ObjectProvider op) { ForceManagedConnection mconn = (ForceManagedConnection) storeManager.getConnection(op.getExecutionContext()); try { AbstractClassMetaData acmd = op.getClassMetaData(); TableImpl table = storeManager.getTable(acmd); QueryResult qr = ((PartnerConnection) mconn.getConnection()) .query("select count() from " + table.getTableName().getForceApiName() + " where id='" + op.provideField(op.getClassMetaData().getPKMemberPositions()[0]) + "'"); if (qr.getSize() == 0) { throw new NucleusObjectNotFoundException(); } } catch (ConnectionException x) { throw new NucleusDataStoreException(x.getMessage(), x); } finally { mconn.release(); } }