• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SaveResult类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.sforce.soap.partner.SaveResult的典型用法代码示例。如果您正苦于以下问题:Java SaveResult类的具体用法?Java SaveResult怎么用?Java SaveResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SaveResult类属于com.sforce.soap.partner包,在下文中一共展示了SaveResult类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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());
        }
    }
}
 
开发者ID:forcedotcom,项目名称:scmt-server,代码行数:22,代码来源:SalesforceService.java


示例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());
      }
    }
  }
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:31,代码来源:WaveAnalyticsTarget.java


示例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);
    }
  }
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:19,代码来源:ForceSoapWriter.java


示例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);
    }
  }
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:19,代码来源:ForceSoapWriter.java


示例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;
}
 
开发者ID:forcedotcom,项目名称:scmt-server,代码行数:31,代码来源:SalesforceService.java


示例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++;
        }
    }
}
 
开发者ID:tzmfreedom,项目名称:embulk-output-salesforce,代码行数:10,代码来源:SalesforceOutputPlugin.java


示例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, ", "));
			}
		}
	}
}
 
开发者ID:eroispaziali,项目名称:ForceFlow,代码行数:14,代码来源:InsertSingleRecordTask.java


示例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;
}
 
开发者ID:forcedotcom,项目名称:ApexUnit,代码行数:41,代码来源:AsyncBulkApiHandler.java


示例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;
	}
 
开发者ID:forcedotcom,项目名称:ApexUnit,代码行数:30,代码来源:AsyncBulkApiHandler.java


示例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;
}
 
开发者ID:Talend,项目名称:components,代码行数:34,代码来源:SalesforceRuntimeTestUtil.java


示例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;
}
 
开发者ID:Talend,项目名称:components,代码行数:8,代码来源:SalesforceWriter.java


示例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;
}
 
开发者ID:Talend,项目名称:components,代码行数:33,代码来源:SalesforceWriter.java


示例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;
}
 
开发者ID:Talend,项目名称:components,代码行数:8,代码来源:SalesforceWriter.java


示例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;
}
 
开发者ID:Talend,项目名称:components,代码行数:37,代码来源:SalesforceWriter.java


示例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);
 }
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:9,代码来源:SalesforceConnection.java


示例16: update

import com.sforce.soap.partner.SaveResult; //导入依赖的package包/类
public SaveResult[] update(SObject[] sfBuffer) throws KettleException
{
 try {
  return getBinding().update(sfBuffer);
 }catch(Exception e) {
  throw new KettleException(BaseMessages.getString(PKG, "SalesforceInput.ErrorUpdate"), e);
 }
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:9,代码来源:SalesforceConnection.java


示例17: flushInserts

import com.sforce.soap.partner.SaveResult; //导入依赖的package包/类
private void flushInserts() {
    if (_pendingInserts.isEmpty()) {
        return;
    }
    final SObject[] objectsToInsert = _pendingInserts.toArray(new SObject[_pendingInserts.size()]);
    _pendingInserts.clear();
    try {
        final SaveResult[] saveResults = _connection.create(objectsToInsert);
        checkSaveResults(saveResults, "insert");
    } catch (ConnectionException e) {
        throw SalesforceUtils.wrapException(e, "Failed to insert objects in Salesforce");
    }
}
 
开发者ID:apache,项目名称:metamodel,代码行数:14,代码来源:SalesforceUpdateCallback.java


示例18: update

import com.sforce.soap.partner.SaveResult; //导入依赖的package包/类
protected void update(SObject[] sObjects) {
    flushInserts();
    try {
        SaveResult[] saveResults = _connection.update(sObjects);
        checkSaveResults(saveResults, "update");
    } catch (ConnectionException e) {
        throw SalesforceUtils.wrapException(e, "Failed to update objects in Salesforce");
    }
}
 
开发者ID:apache,项目名称:metamodel,代码行数:10,代码来源:SalesforceUpdateCallback.java


示例19: insert

import com.sforce.soap.partner.SaveResult; //导入依赖的package包/类
public SaveResult[] insert( SObject[] sfBuffer ) throws KettleException {
  try {
    List<SObject> normalizedSfBuffer = new ArrayList<>();
    for ( SObject part : sfBuffer ) {
      if ( part != null ) {
        normalizedSfBuffer.add( part );
      }
    }
    return getBinding().create( normalizedSfBuffer.toArray( new SObject[normalizedSfBuffer.size()] ) );
  } catch ( Exception e ) {
    throw new KettleException( BaseMessages.getString( PKG, "SalesforceInput.ErrorInsert", e ) );
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:14,代码来源:SalesforceConnection.java


示例20: update

import com.sforce.soap.partner.SaveResult; //导入依赖的package包/类
public SaveResult[] update( SObject[] sfBuffer ) throws KettleException {
  try {
    return getBinding().update( sfBuffer );
  } catch ( Exception e ) {
    throw new KettleException( BaseMessages.getString( PKG, "SalesforceInput.ErrorUpdate", e ) );
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:8,代码来源:SalesforceConnection.java



注:本文中的com.sforce.soap.partner.SaveResult类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Permission类代码示例发布时间:2022-05-21
下一篇:
Java TransactionManager类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap