use of com.salesforce.soap.partner.QueryResult in project tdi-studio-se by Talend.
the class PartnerSamples method searchSample.
private void searchSample() {
// call the login function to do so
if (!loggedIn) {
if (!login()) {
return;
}
}
SearchResult sr = null;
QueryResult qr = null;
try {
sr = binding.search("find {4159017000} in phone fields returning contact(id, phone, firstname, lastname), lead(id, phone, firstname, lastname), account(id, phone, name)");
SearchRecord[] records = sr.getSearchRecords();
Vector contacts = new Vector();
Vector leads = new Vector();
Vector accounts = new Vector();
if (records != null && records.length > 0) {
for (int i = 0; i < records.length; i++) {
SObject record = records[i].getRecord();
if (record.getType().toLowerCase().equals("contact")) {
contacts.add(record);
} else if (record.getType().toLowerCase().equals("lead")) {
leads.add(record);
} else if (record.getType().toLowerCase().equals("account")) {
accounts.add(record);
}
}
if (contacts.size() > 0) {
System.out.println("Found " + new Integer(contacts.size()).toString() + " contacts:");
for (int i = 0; i < contacts.size(); i++) {
SObject c = (SObject) contacts.get(i);
System.out.println(c.getId() + " - " + c.get_any()[1] + " " + c.get_any()[2] + " - " + c.get_any()[0]);
}
}
if (leads.size() > 0) {
System.out.println("Found " + new Integer(leads.size()).toString() + " leads:");
for (int i = 0; i < leads.size(); i++) {
SObject l = (SObject) leads.get(i);
System.out.println(l.getId() + " - " + l.get_any()[1] + " " + l.get_any()[2] + " - " + l.get_any()[0]);
}
}
if (accounts.size() > 0) {
System.out.println("Found " + new Integer(accounts.size()).toString() + " accounts:");
for (int i = 0; i < accounts.size(); i++) {
SObject a = (SObject) accounts.get(i);
System.out.println(a.getId() + " - " + a.get_any()[1] + " - " + a.get_any()[0]);
}
}
} else {
System.out.println("No records were found for the search.");
}
System.out.println("\nSearch succesfully executed.");
getUserInput("\nHit return to continue...");
} catch (ApiFault af) {
System.out.println("\nFailed to execute search succesfully, error message was: \n" + af.getExceptionMessage());
getUserInput("\nHit return to continue...");
} catch (Exception ex) {
System.out.println("\nFailed to execute search succesfully, error message was: \n" + ex.getMessage());
getUserInput("\nHit return to continue...");
}
}
use of com.salesforce.soap.partner.QueryResult 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.QueryResult 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.QueryResult in project tdi-studio-se by Talend.
the class TopRecord method processOMElement.
private void processOMElement(OMElement ome, String prefixName) throws Exception {
if (ome.getChildElements().hasNext()) {
Iterator iter = ome.getChildElements();
// delete the fixed id and type elements when find firstly
int typeCount = 0;
int idCount = 0;
while (iter.hasNext()) {
Object objectValue = iter.next();
if (objectValue != null) {
if (objectValue instanceof OMElement) {
OMElement omeElem = (OMElement) objectValue;
if ("type".equals(omeElem.getLocalName()) && typeCount == 0) {
typeCount++;
continue;
}
if ("Id".equals(omeElem.getLocalName()) && idCount == 0) {
idCount++;
continue;
}
processOMElement(omeElem, prefixName + TopConfig.COLUMNNAME_DELIMTER + ome.getLocalName());
} else if (objectValue instanceof SObject) {
SObject sobject = (SObject) objectValue;
processSObject(sobject, prefixName + TopConfig.COLUMNNAME_DELIMTER + sobject.getType());
} else if (objectValue instanceof QueryResult) {
QueryResult queryResult = (QueryResult) objectValue;
processQueryResult(queryResult, prefixName);
} else {
throw new Exception("Unexcepted case happend...");
}
}
}
} else {
if (ome.getText() == null || "".equals(ome.getText())) {
return;
}
String newPrefixName = prefixName + TopConfig.COLUMNNAME_DELIMTER + ome.getLocalName();
// add the columnName to List one by one(order is important)
if (!columnNameList.contains(newPrefixName)) {
columnNameList.add(newPrefixName);
}
if (!columnLocalNameList.contains(ome.getLocalName())) {
columnLocalNameList.add(ome.getLocalName());
}
Object value = valueMap.get(newPrefixName);
if (value != null) {
valueMap.put(newPrefixName, value + TopConfig.VALUE_DELIMITER + ome.getText());
} else {
valueMap.put(newPrefixName, ome.getText());
}
}
}
use of com.salesforce.soap.partner.QueryResult 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