本文整理汇总了Java中com.sforce.soap.partner.QueryResult类的典型用法代码示例。如果您正苦于以下问题:Java QueryResult类的具体用法?Java QueryResult怎么用?Java QueryResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
QueryResult类属于com.sforce.soap.partner包,在下文中一共展示了QueryResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import com.sforce.soap.partner.QueryResult; //导入依赖的package包/类
@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());
}
}
示例2: loadBatch
import com.sforce.soap.partner.QueryResult; //导入依赖的package包/类
private List<List<Object>> loadBatch(QueryResult queryResult) {
List<List<Object>> batch = new ArrayList<List<Object>>();
for(SObject sObject : queryResult.getRecords()) {
Iterator<XmlObject> fields = sObject.getChildren();
List<Object> row = new ArrayList<Object>();
while (fields.hasNext()) {
XmlObject elem = fields.next();
if (elem.getName().getLocalPart().equals("type")) { //$NON-NLS-1$
continue;
}
Object value = elem.getValue();
row.add(value);
}
batch.add(row);
}
return batch;
}
示例3: getRow
import com.sforce.soap.partner.QueryResult; //导入依赖的package包/类
private List<Object> getRow(QueryResult result) throws TranslatorException {
List<Object> row;
if(null == resultBatch) {
loadBatch();
}
if(resultBatch.size() == topResultIndex) {
row = null;
} else {
row = resultBatch.get(topResultIndex);
topResultIndex++;
if(resultBatch.size() == topResultIndex) {
if(!result.isDone()) {
loadBatch();
}
}
}
return row;
}
示例4: helpTest
import com.sforce.soap.partner.QueryResult; //导入依赖的package包/类
private void helpTest(String sql, String expected) throws Exception {
Command command = translationUtility.parseCommand(sql);
SalesForceExecutionFactory factory = new SalesForceExecutionFactory();
ExecutionContext ec = Mockito.mock(ExecutionContext.class);
RuntimeMetadata rm = Mockito.mock(RuntimeMetadata.class);
SalesforceConnection connection = Mockito.mock(SalesforceConnection.class);
ArgumentCaptor<String> queryArgument = ArgumentCaptor.forClass(String.class);
QueryResult qr = Mockito.mock(QueryResult.class);
Mockito.stub(connection.query(queryArgument.capture(), Mockito.anyInt(), Mockito.anyBoolean())).toReturn(qr);
Execution execution = factory.createExecution(command, ec, rm, connection);
execution.execute();
Mockito.verify(connection, Mockito.times(1)).query(queryArgument.capture(), Mockito.anyInt(), Mockito.anyBoolean());
assertEquals(expected, queryArgument.getValue().trim());
}
示例5: testBatching
import com.sforce.soap.partner.QueryResult; //导入依赖的package包/类
@Test public void testBatching() throws Exception {
Select command = (Select)translationUtility.parseCommand("select Name from Account"); //$NON-NLS-1$
SalesforceConnection sfc = Mockito.mock(SalesforceConnection.class);
QueryResult qr = new QueryResult();
SObject so = new SObject();
so.setType("Account");
so.addField("Name", null);
qr.setRecords(new SObject[] {so});
qr.setDone(false);
QueryResult finalQr = new QueryResult();
so.addField("Name", null);
finalQr.setRecords(new SObject[] {so});
finalQr.setDone(true);
Mockito.stub(sfc.query("SELECT Account.Name FROM Account", 0, false)).toReturn(qr);
Mockito.stub(sfc.queryMore(null, 0)).toReturn(finalQr);
QueryExecutionImpl qei = new QueryExecutionImpl(command, sfc, Mockito.mock(RuntimeMetadata.class), Mockito.mock(ExecutionContext.class));
qei.execute();
assertNotNull(qei.next());
assertNotNull(qei.next());
assertNull(qei.next());
}
示例6: constructClassIdArrayUsingWSC
import com.sforce.soap.partner.QueryResult; //导入依赖的package包/类
public static String[] constructClassIdArrayUsingWSC(PartnerConnection connection, String soql) {
String[] classIdsAsArray = null;
QueryResult queryResult = null;
try {
queryResult = connection.query(soql);
} catch (ConnectionException e) {
ApexUnitUtils.shutDownWithDebugLog(e, ConnectionHandler
.logConnectionException(e, connection, soql));
}
if (queryResult != null) {
classIdsAsArray = fetchApexClassesAsArray(queryResult);
} else {
ApexUnitUtils.shutDownWithErrMsg("Faulty query performed using the soql Query " + soql
+ " returned incorrect result. Halting the application");
}
return classIdsAsArray;
}
示例7: fetchApexClassesAsArray
import com.sforce.soap.partner.QueryResult; //导入依赖的package包/类
private static String[] fetchApexClassesAsArray(QueryResult queryResult) {
Object[] apexClassesObjArr = null;
if (queryResult.getDone()) {
SObject[] sObjects = queryResult.getRecords();
if (sObjects != null) {
ArrayList<String> apexClasses = new ArrayList<String>();
LOG.debug("Fetched Apex classes:");
for (SObject sobject : sObjects) {
apexClasses.add(sobject.getField("Id").toString());
// crucial step. Populate apexCLassMap each time a class is
// fetched. Will be used for lot of computations
apexClassMap.put(sobject.getField("Id").toString(), sobject.getField("Name").toString());
LOG.debug("ApexClassId : " + sobject.getField("Id").toString() + " ApexClassName : "
+ sobject.getField("Name").toString());
}
apexClassesObjArr = apexClasses.toArray();
//line below only works for java 1.6 and above
return Arrays.copyOf(apexClassesObjArr, apexClassesObjArr.length, String[].class);
}
}
return null;
}
示例8: fetchAndAddToMapApexClassIdBasedOnName
import com.sforce.soap.partner.QueryResult; //导入依赖的package包/类
public static String fetchAndAddToMapApexClassIdBasedOnName(PartnerConnection connection, String soqlBasedOnName) {
String apexClassId = null;
QueryResult queryResult = null;
try {
queryResult = connection.query(soqlBasedOnName);
} catch (ConnectionException e) {
ApexUnitUtils.shutDownWithDebugLog(e, ConnectionHandler
.logConnectionException(e, connection, soqlBasedOnName));
}
if (queryResult != null && queryResult.getDone()) {
String[] classIds = fetchApexClassesAsArray(queryResult);
if(classIds!=null && classIds.length>0){
apexClassId = classIds[0];
}
}
return apexClassId;
}
示例9: fetchApexTestClassNameFromId
import com.sforce.soap.partner.QueryResult; //导入依赖的package包/类
public static String fetchApexTestClassNameFromId(PartnerConnection connection, String apexClassId) {
String apexClassName = "";
String soql = QueryConstructor.generateQueryToFetchApexClassFromId(apexClassId);
QueryResult queryResult = null;
try {
queryResult = connection.query(soql);
} catch (ConnectionException e) {
ApexUnitUtils.shutDownWithDebugLog(e, ConnectionHandler
.logConnectionException(e, connection, soql));
}
if (queryResult != null && queryResult.getDone()) {
SObject[] sObjects = queryResult.getRecords();
for (SObject sobject : sObjects) {
if (sobject != null) {
apexClassName = sobject.getField("Name").toString();
LOG.info("Fetched the Apex test class for Id: " + apexClassId + " : " + apexClassName);
if (!apexClassMap.containsKey(apexClassId)) {
apexClassMap.put(apexClassId, apexClassName);
}
}
}
}
return apexClassName;
}
示例10: fetchApexClassesAsString
import com.sforce.soap.partner.QueryResult; //导入依赖的package包/类
private String fetchApexClassesAsString(QueryResult queryResult) {
String apexClassesAsString = null;
int arrayLength = 0;
String apexClassId = "";
String apexClassName = "";
if (queryResult.getDone()) {
SObject[] sObjects = queryResult.getRecords();
if (sObjects != null) {
LOG.debug("Fetched the classes:");
for (SObject sobject : sObjects) {
apexClassName = sobject.getField("Name").toString();
apexClassesAsString += apexClassName;
apexClassesAsString += "\n";
apexClassId = sobject.getField("Id").toString();
apexClasses[arrayLength++] = apexClassId;
ApexClassFetcherUtils.apexClassMap.put(apexClassId, apexClassName);
}
return apexClassesAsString;
}
}
return null;
}
示例11: materializeMainSchemaTable
import com.sforce.soap.partner.QueryResult; //导入依赖的package包/类
@Override
protected DataSet materializeMainSchemaTable(Table table, List<Column> columns, int maxRows) {
final StringBuilder sb = new StringBuilder();
sb.append("SELECT ");
for (int i = 0; i < columns.size(); i++) {
if (i != 0) {
sb.append(',');
}
sb.append(columns.get(i).getName());
}
sb.append(" FROM ");
sb.append(table.getName());
if (maxRows > 0) {
sb.append(" LIMIT " + maxRows);
}
final QueryResult queryResult = executeSoqlQuery(sb.toString());
return new SalesforceDataSet(columns, queryResult, _connection);
}
示例12: getRecordValue
import com.sforce.soap.partner.QueryResult; //导入依赖的package包/类
public String getRecordValue( SObject con, String fieldname ) throws KettleException {
String[] fieldHierarchy = fieldname.split( "\\." );
if ( con == null ) {
return null;
} else {
XmlObject element = getMessageElementForHierarchy( con, fieldHierarchy );
if ( element != null ) {
Object object = element.getValue();
if ( object != null ) {
if ( object instanceof QueryResult ) {
return buildJsonQueryResult( (QueryResult) object );
}
return String.valueOf( object );
} else {
return (String) element.getValue();
}
}
}
return null;
}
示例13: getObjectsCount
import com.sforce.soap.partner.QueryResult; //导入依赖的package包/类
@Override
public final ScribeCommandObject getObjectsCount(final ScribeCommandObject cADCommandObject) throws Exception {
logger.debug("----Inside getObjectsCount");
/* Get Sales Force stub for the agent */
final SoapBindingStub soapBindingStub = cRMSessionManager.getSoapBindingStub(cADCommandObject.getCrmUserId(), cADCommandObject.getCrmPassword());
/* Create a string object for query */
final String cadQuery = "Select count() from " + cADCommandObject.getObjectType();
/* Query Sales Force for count of objects */
final QueryResult queryResult = soapBindingStub.query(cadQuery);
logger.debug("----Inside getObjectsCount SOQL query: " + cadQuery);
/* Iterate over records */
if (queryResult != null) {
/* Create one Object each record */
final ScribeObject cADbject = new ScribeObject();
/* Create list of elements */
final List<Element> elementList = new ArrayList<Element>();
/* Create inner tags <Field_Name> inside <Object> */
elementList.add(SalesForceMessageFormatUtils.createMessageElement("Count", queryResult.getSize()));
logger.debug("----Inside getObjectsCount objects count: " + queryResult.getSize());
/* Add all CRM fields */
cADbject.setXmlContent(elementList);
/* Set the final object in command object */
cADCommandObject.setObject(new ScribeObject[] {cADbject});
} else {
logger.debug("----Inside getObjectsCount no response from Sales Force");
throw new ScribeException(ScribeResponseCodes._1005);
}
return cADCommandObject;
}
示例14: getFolders
import com.sforce.soap.partner.QueryResult; //导入依赖的package包/类
protected SObject[] getFolders(String folderType, String folderPrefix, HashSet<String> includeFolders) {
SObject[] folders = new SObject[] {};
try {
String soql = "select Id, DeveloperName, NamespacePrefix from Folder where DeveloperName != null " +
" and Type='" + folderType + "' ";
if (!managedPackageTypes.contains(folderType)) {
soql += " AND NamespacePrefix = null ";
}
PartnerConnection connection = getPartnerConnection();
QueryResult qr = connection.query(soql);
SObject[] soqlFolders = qr.getRecords();
List<SObject> approvedFolders = new ArrayList<SObject>();
for (SObject so : soqlFolders) {
String developerName = (String) so.getField("DeveloperName");
String namespacePrefix = (String) so.getField("NamespacePrefix");
if (namespacePrefix != null && namespacePrefix.trim().length() > 0) {
developerName = namespacePrefix + "__" + developerName;
}
if (((folderPrefix == null || folderPrefix.length() == 0) && includeFolders.size() == 0) ||
includeFolders.contains(developerName) ||
(folderPrefix != null && folderPrefix.length() > 0 && developerName != null && developerName.startsWith(folderPrefix))) {
approvedFolders.add(so);
}
}
folders = approvedFolders.toArray(new SObject[0]);
} catch (Exception ex) {
ex.printStackTrace();
throw new BuildException("Exception retrieving folder list.");
}
return folders;
}
示例15: execute
import com.sforce.soap.partner.QueryResult; //导入依赖的package包/类
@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);
}
}