本文整理汇总了Java中com.sforce.soap.partner.SaveResult类的典型用法代码示例。如果您正苦于以下问题:Java SaveResult类的具体用法?Java SaveResult怎么用?Java SaveResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SaveResult类属于com.sforce.soap.partner包,在下文中一共展示了SaveResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createRemoteSite
import com.sforce.soap.partner.SaveResult; //导入依赖的package包/类
public void createRemoteSite(RemoteSite rs)
throws ConnectionException, DeployException, AsyncApiException, Exception {
createMetadataConnection();
RemoteSiteSetting rss = new RemoteSiteSetting();
rss.setFullName(rs.fullName);
rss.setUrl(rs.url);
rss.setDescription(rs.description);
rss.setIsActive(true);
rss.setDisableProtocolSecurity(false);
com.sforce.soap.metadata.SaveResult[] results = getMetadataConnection().createMetadata(new Metadata[] { rss });
for (com.sforce.soap.metadata.SaveResult r : results) {
if (r.isSuccess()) {
System.out.println("Created component: " + r.getFullName());
} else {
throw new Exception(r.getErrors()[0].getMessage());
}
}
}
示例2: openDataset
import com.sforce.soap.partner.SaveResult; //导入依赖的package包/类
private void openDataset() throws ConnectionException, StageException {
datasetName = conf.edgemartAliasPrefix;
if (conf.appendTimestamp) {
datasetName += "_" + System.currentTimeMillis();
}
SObject sobj = new SObject();
sobj.setType("InsightsExternalData");
sobj.setField("Format", "Csv");
sobj.setField("EdgemartAlias", datasetName);
sobj.setField("MetadataJson", conf.metadataJson.getBytes(StandardCharsets.UTF_8));
sobj.setField("Operation", conf.operation.getLabel());
sobj.setField("Action", "None");
if (!StringUtils.isEmpty(conf.edgemartContainer)) {
sobj.setField("EdgemartContainer", conf.edgemartContainer);
}
SaveResult[] results = connection.create(new SObject[]{sobj});
for (SaveResult sv : results) {
if (sv.isSuccess()) {
datasetID = sv.getId();
partNumber = 1;
LOG.info("Success creating InsightsExternalData: " + datasetID);
} else {
for (Error e : sv.getErrors()) {
throw new StageException(Errors.WAVE_01, e.getMessage());
}
}
}
}
示例3: create
import com.sforce.soap.partner.SaveResult; //导入依赖的package包/类
private void create(
SObject[] recordArray,
Map<SObject, Record> recordMap,
List<OnRecordErrorException> errorRecords
) throws ConnectionException {
LOG.info("Writing {} records to Salesforce", recordArray.length);
SaveResult[] saveResults = partnerConnection.create(recordArray);
LOG.info("{} records written to Salesforce", saveResults.length);
// check the returned results for any errors
for (int i = 0; i < saveResults.length; i++) {
if (!saveResults[i].isSuccess()) {
handleErrorRecord(recordArray[i], saveResults[i].getErrors(), recordMap, errorRecords);
}
}
}
示例4: update
import com.sforce.soap.partner.SaveResult; //导入依赖的package包/类
private void update(
SObject[] recordArray,
Map<SObject, Record> recordMap,
List<OnRecordErrorException> errorRecords
) throws ConnectionException {
LOG.info("Updating {} records in Salesforce", recordArray.length);
SaveResult[] saveResults = partnerConnection.update(recordArray);
LOG.info("{} records updated in Salesforce", saveResults.length);
// check the returned results for any errors
for (int i = 0; i < saveResults.length; i++) {
if (!saveResults[i].isSuccess()) {
handleErrorRecord(recordArray[i], saveResults[i].getErrors(), recordMap, errorRecords);
}
}
}
示例5: handleInsertResponse
import com.sforce.soap.partner.SaveResult; //导入依赖的package包/类
private static DeployResponse handleInsertResponse(DeployResponse dr, SaveResult[] results) throws DeployException
{
boolean foundErrors = false;
for (SaveResult sr : results)
{
if (sr.getSuccess())
{
// Utils.log("'insert' was successful! [" + ur.getId() + "]");
dr.incrementSuccessCount();
}
else
{
for (com.sforce.soap.partner.Error e : sr.getErrors())
{
dr.addError(String.format("Status Code: [%s]\nMessage: [%s]\n%s\n", e.getStatusCode().name(),
e.getMessage(), (e.getFields() == null || e.getFields().length == 0 ? ""
: String.format("Fields: [%s]", String.join(", ", e.getFields())))));
dr.incrementErrorCount();
}
foundErrors = true;
}
}
if (foundErrors)
{
Utils.log("'insert' resulted in errors! See log.");
}
return dr;
}
示例6: countSaveResults
import com.sforce.soap.partner.SaveResult; //导入依赖的package包/类
private void countSaveResults(SaveResult[] saveResults) {
for (SaveResult saveResult : saveResults) {
if (saveResult.isSuccess()) {
this.numOfSuccess++;
} else {
this.numOfError++;
}
}
}
示例7: processResult
import com.sforce.soap.partner.SaveResult; //导入依赖的package包/类
private void processResult(SaveResult[] results) throws BuildException {
if (results!=null) {
for (SaveResult r : results) {
if (!r.isSuccess()) {
List<String> errorMessages = new ArrayList<String>();
for (com.sforce.soap.partner.Error e : r.getErrors()) {
errorMessages.add(e.getMessage());
}
throw new BuildException(StringUtils.join(errorMessages, ", "));
}
}
}
}
示例8: checkResults
import com.sforce.soap.partner.SaveResult; //导入依赖的package包/类
/**
* Gets the results of the operation and checks for errors.
*/
public List<SaveResult> checkResults(BulkConnection bulkConnection, JobInfo job, List<BatchInfo> batchInfoList)
throws AsyncApiException, IOException {
LOG.debug("Checking Results.... ");
List<SaveResult> saveResults = new ArrayList<SaveResult>();
// batchInfoList was populated when batches were created and submitted
for (BatchInfo batchInfo : batchInfoList) {
CSVReader csvReaderForBatchResultStream = new CSVReader(
bulkConnection.getBatchResultStream(job.getId(), batchInfo.getId()));
List<String> resultHeader = csvReaderForBatchResultStream.nextRecord();
int resultCols = resultHeader.size();
List<String> batchResultStream = null;
while ((batchResultStream = csvReaderForBatchResultStream.nextRecord()) != null) {
Map<String, String> resultInfo = new HashMap<String, String>();
for (int i = 0; i < resultCols; i++) {
resultInfo.put(resultHeader.get(i), batchResultStream.get(i));
}
SaveResult sr = new SaveResult();
sr.setId(resultInfo.get("Id"));
boolean success = Boolean.valueOf(resultInfo.get("Success"));
sr.setSuccess(success);
if (!success) {
if (resultInfo.get("Error") != null && StringUtils.isNotEmpty(resultInfo.get("Error"))) {
ApexUnitUtils.shutDownWithErrMsg(
"Error while fetching results for the batch job" + resultInfo.get("Error"));
}
}
saveResults.add(sr);
}
}
return saveResults;
}
示例9: getParentJobIdForTestQueueItems
import com.sforce.soap.partner.SaveResult; //导入依赖的package包/类
public String getParentJobIdForTestQueueItems(List<SaveResult> bulkResults, PartnerConnection conn) {
String parentJobId = null;
if (bulkResults != null && bulkResults.size() > 0) {
SaveResult sr = bulkResults.get(0);
String testQueueItemId = sr.getId();
String soql = QueryConstructor.fetchParentJobIdForApexTestQueueItem(testQueueItemId);
LOG.debug("Query used for fetching parent job ID for bulk results: " + soql);
QueryResult queryResult = null;
try{
queryResult = conn.query(soql);
}catch (ConnectionException e) {
ApexUnitUtils.shutDownWithDebugLog(e, ConnectionHandler
.logConnectionException(e, conn, soql));
}
if (queryResult.isDone()) {
// TODO: We need to verify what's the limit of records that the
// bulk api can insert in one transaction. multiple transactions
// mean multiple parent job ids
parentJobId = fetchParentJobId(queryResult);
LOG.info("Async test parent job Id : " + parentJobId);
}
} else {
ApexUnitUtils.shutDownWithErrMsg("Invalid bulk results. No bulk results returned.");
}
return parentJobId;
}
示例10: createTestData
import com.sforce.soap.partner.SaveResult; //导入依赖的package包/类
public List<String> createTestData() throws ConnectionException {
this.login(SalesforceConnectionProperties.URL);
List<String> ids = new ArrayList<String>();
try {
List<SObject> contacts = new ArrayList<SObject>();
for (Map<String, String> row : testData) {
SObject contact = new SObject();
contact.setType(module);
contact.setField("FirstName", row.get("FirstName"));
contact.setField("LastName", row.get("LastName"));
contact.setField("Phone", row.get("Phone"));
contacts.add(contact);
}
SaveResult[] results = partnerConnection.create(contacts.toArray(new SObject[0]));
for (SaveResult result : results) {
if (result.isSuccess()) {
ids.add(result.getId());
} else {
for (int i = 0; i < result.getErrors().length; i++) {
com.sforce.soap.partner.Error err = result.getErrors()[i];
Assert.fail(err.getMessage());
}
}
}
} catch (ConnectionException ce) {
Assert.fail(ce.getMessage());
}
return ids;
}
示例11: insert
import com.sforce.soap.partner.SaveResult; //导入依赖的package包/类
private SaveResult[] insert(IndexedRecord input) throws IOException {
insertItems.add(input);
if (insertItems.size() >= commitLevel) {
return doInsert();
}
return null;
}
示例12: doInsert
import com.sforce.soap.partner.SaveResult; //导入依赖的package包/类
private SaveResult[] doInsert() throws IOException {
if (insertItems.size() > 0) {
// Clean the feedback records at each batch write.
cleanWrites();
SObject[] accs = new SObject[insertItems.size()];
for (int i = 0; i < insertItems.size(); i++) {
accs[i] = createSObject(insertItems.get(i));
}
String[] changedItemKeys = new String[accs.length];
SaveResult[] saveResults;
try {
saveResults = connection.create(accs);
if (saveResults != null && saveResults.length != 0) {
int batch_idx = -1;
for (int i = 0; i < saveResults.length; i++) {
++batch_idx;
if (saveResults[i].getSuccess()) {
handleSuccess(insertItems.get(i), saveResults[i].getId(), null);
} else {
handleReject(insertItems.get(i), saveResults[i].getErrors(), changedItemKeys, batch_idx);
}
}
}
insertItems.clear();
return saveResults;
} catch (ConnectionException e) {
throw new IOException(e);
}
}
return null;
}
示例13: update
import com.sforce.soap.partner.SaveResult; //导入依赖的package包/类
private SaveResult[] update(IndexedRecord input) throws IOException {
updateItems.add(input);
if (updateItems.size() >= commitLevel) {
return doUpdate();
}
return null;
}
示例14: doUpdate
import com.sforce.soap.partner.SaveResult; //导入依赖的package包/类
private SaveResult[] doUpdate() throws IOException {
if (updateItems.size() > 0) {
// Clean the feedback records at each batch write.
cleanWrites();
SObject[] upds = new SObject[updateItems.size()];
for (int i = 0; i < updateItems.size(); i++) {
upds[i] = createSObject(updateItems.get(i));
}
String[] changedItemKeys = new String[upds.length];
for (int ix = 0; ix < upds.length; ++ix) {
changedItemKeys[ix] = upds[ix].getId();
}
SaveResult[] saveResults;
try {
saveResults = connection.update(upds);
upds = null;
if (saveResults != null && saveResults.length != 0) {
int batch_idx = -1;
for (int i = 0; i < saveResults.length; i++) {
++batch_idx;
if (saveResults[i].getSuccess()) {
handleSuccess(updateItems.get(i), saveResults[i].getId(), null);
} else {
handleReject(updateItems.get(i), saveResults[i].getErrors(), changedItemKeys, batch_idx);
}
}
}
updateItems.clear();
return saveResults;
} catch (ConnectionException e) {
throw new IOException(e);
}
}
return null;
}
示例15: insert
import com.sforce.soap.partner.SaveResult; //导入依赖的package包/类
public SaveResult[] insert(SObject[] sfBuffer) throws KettleException
{
try {
return getBinding().create(sfBuffer);
}catch(Exception e) {
throw new KettleException(BaseMessages.getString(PKG, "SalesforceInput.ErrorInsert"), e);
}
}