use of com.salesforce.soap.partner.QueryOptions in project tdi-studio-se by Talend.
the class PartnerSamples method querySample.
private void querySample() {
// call the login function to do so
if (!loggedIn) {
if (!login()) {
return;
}
}
QueryResult qr = null;
QueryOptions qo = new QueryOptions();
qo.setBatchSize(new Integer(3));
binding.setHeader(new SforceServiceLocator().getServiceName().getNamespaceURI(), "QueryOptions", qo);
try {
qr = binding.query("select id, Website, Name from Account where Name = 'Golden Straw'");
ArrayList records = this.loadQueryResults(qr);
if (records.size() != 0) {
HashMap record = (HashMap) records.get(0);
System.out.println("Retrieved " + new Integer(records.size()).toString() + " account(s) using Name = 'Golden Straw', String = " + (record.containsKey("id") ? record.get("id").toString() : " ").toString() + ", website = " + (record.containsKey("website") ? record.get("website").toString() : " ").toString());
}
// if (qr.getSize() != 0) {
// SObject account = qr.getRecords()[0];
//
// System.out.println("Retrieved "
// + new Integer(qr.getSize()).toString()
// + " account(s) using Name = 'Golden Straw', String = "
// + account.getId() + ", website = "
// + account.get_any()[1]);
// }
qr = binding.query("select FirstName, LastName from Contact");
int loopCount = 0;
boolean continueLoop = true;
while (continueLoop) {
System.out.println("Results set " + new Integer(loopCount++).toString() + " - ");
// process the query results
for (int i = 0; i < qr.getRecords().length; i++) {
SObject con = qr.getRecords()[i];
String fName = "";
String lName = "";
if (con.get_any()[0].getName().toLowerCase().equals("firstname")) {
fName = con.get_any()[0].getValue();
lName = con.get_any()[1].getValue();
} else
lName = con.get_any()[0].getValue();
if (fName == null) {
System.out.println("Contact " + (i + 1) + ": " + lName);
} else {
System.out.println("Contact " + (i + 1) + ": " + fName + " " + lName);
}
}
// recent queryResult
if (qr.isDone())
continueLoop = false;
else
qr = binding.queryMore(qr.getQueryLocator());
}
System.out.println("\nQuery succesfully executed.");
getUserInput("\nHit return to continue...");
} catch (ApiFault af) {
System.out.println("\nFailed to execute query succesfully, error message was: \n" + af.getExceptionMessage());
getUserInput("\nHit return to continue...");
} catch (Exception ex) {
System.out.println("\nFailed to execute query succesfully, error message was: \n" + ex.getMessage());
getUserInput("\nHit return to continue...");
}
}
use of com.salesforce.soap.partner.QueryOptions in project tdi-studio-se by Talend.
the class SforceManagementImpl method queryAll.
@Override
public QueryResult queryAll(String soql, int batchSize) throws Exception {
QueryAll queryAll = new QueryAll();
queryAll.setQueryString(soql);
QueryOptions queryOptions = new QueryOptions();
queryOptions.setBatchSize(batchSize);
QueryResult qr = sforceConn.queryAll(queryAll, queryOptions).getResult();
return qr;
}
use of com.salesforce.soap.partner.QueryOptions in project tdi-studio-se by Talend.
the class SforceManagementImpl method queryMore.
@Override
public QueryResult queryMore(QueryLocator queryLocator, int batchSize) throws Exception {
QueryOptions queryOptions = new QueryOptions();
queryOptions.setBatchSize(batchSize);
QueryMore queryMore = new QueryMore();
queryMore.setQueryLocator(queryLocator);
QueryResult qr = sforceConn.queryMore(queryMore, queryOptions).getResult();
return qr;
}
use of com.salesforce.soap.partner.QueryOptions in project tdi-studio-se by Talend.
the class SforceManagementImpl method query.
@Override
public QueryResult query(String soql, int batchSize) throws Exception {
Query query = new Query();
query.setQueryString(soql);
QueryOptions queryOptions = new QueryOptions();
queryOptions.setBatchSize(batchSize);
QueryResult qr = sforceConn.query(query, queryOptions).getResult();
return qr;
}
Aggregations