Package com.sforce.soap.partner.sobject

Examples of com.sforce.soap.partner.sobject.SObject


    }
    return results.size();
  }

  public int create(DataPayload data) throws ResourceException {
    SObject toCreate = new SObject();
    toCreate.setType(data.getType());
    toCreate.getAny().addAll(data.getMessageElements());
    List<SObject> objects = new ArrayList<SObject>();
    objects.add(toCreate);
    List<SaveResult> result;
    try {
      result = sfSoap.create(objects, sh);
View Full Code Here


  public int update(List<DataPayload> updateDataList) throws ResourceException {
    List<SObject> params = new ArrayList<SObject>(updateDataList.size());
    for(int i = 0; i < updateDataList.size(); i++) {
      DataPayload data = updateDataList.get(i);
      SObject toCreate = new SObject();
      toCreate.setType(data.getType());
      toCreate.setId(data.getID());
      toCreate.getAny().addAll(data.getMessageElements());
      params.add(i, toCreate);
    }
    List<SaveResult> result;
      try {
        result = sfSoap.update(params, sh);
View Full Code Here

  @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");
    Element elem = Mockito.mock(Element.class);
    Mockito.stub(elem.getLocalName()).toReturn("AccountName");
    so.getAny().add(elem);
    qr.getRecords().add(so);
    qr.setDone(false);
    QueryResult finalQr = new QueryResult();
    so.getAny().add(elem);
    finalQr.getRecords().add(so);
    finalQr.setDone(true);
    Mockito.stub(sfc.query("SELECT Account.AccountName 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));
View Full Code Here

        QueryResult results = getConnection().query(query, context.getBatchSize(), Boolean.FALSE);
        if (null != results && results.getSize() > 0) {
          ArrayList<String> idList = new ArrayList<String>(results
              .getRecords().size());
          for (int i = 0; i < results.getRecords().size(); i++) {
            SObject sObject = results.getRecords().get(i);
            idList.add(sObject.getId());
          }
          Ids = idList.toArray(new String[0]);
        }
      } catch (ResourceException e) {
        throw new TranslatorException(e);
View Full Code Here

        // get object info for the given reference (foreign key) relationship
        DescribeRefObject entityRefInfo = controller.getReferenceDescribes().get(relationshipName);

        // build the reference SObject
        SObject sObjRef = new SObject();
        // set entity type, has to be set before all others
        sObjRef.setType(entityRefInfo.getObjectName());
        // set external id, do type conversion as well
        Class typeClass = SforceDynaBean.getConverterClass(entityRefInfo.getFieldInfoMap().get(fieldName));
        Object extIdValue = ConvertUtils.convert(this.referenceExtIdValue.toString(), typeClass);
        sObjRef.setField(fieldName, extIdValue);
        // Add the sObject reference as a child elemetn, name set to relationshipName
        sObj.addField(relationshipName, sObjRef);
    }
View Full Code Here

        SObject[] sObjects = new SObject[dynaBeans.size()];

        for (int j = 0; j < sObjects.length; j++) {
            DynaBean dynaBean = dynaBeans.get(j);

            SObject sObj = getSObject(controller, entityName, dynaBean);

            // if we are inserting nulls, build the null array
            if (insertNulls) {
                insertNullArray(controller, sObj, dynaBean);
            }
View Full Code Here

     * @throws NoSuchMethodException
     * @throws ParameterLoadException
     */
    @SuppressWarnings("unchecked")
    public static SObject getSObject(Controller controller, String entityName, DynaBean dynaBean) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException, ParameterLoadException {
        SObject sObj = new SObject();
        sObj.setType(entityName);
        Map<String, Object> fieldMap = BeanUtils.describe(dynaBean);
        for (String fName : fieldMap.keySet()) {
            if (fieldMap.get(fName) != null) {
                // see if any entity foreign key references are embedded here
                Object value = dynaBean.get(fName);
                if (value != null && value instanceof SObjectReference) {
                    SObjectReference sObjRef = (SObjectReference)value;
                    if (!sObjRef.isNull()) sObjRef.addReferenceToSObject(controller, sObj, fName);
                } else {
                    sObj.setField(fName, dynaBean.get(fName));
                }
            }
        }
        return sObj;
    }
View Full Code Here

        return argMap;
    }

    private String createTask(String fieldToNullName, boolean isDateField) throws Exception {
        Object fieldToNullValue = isDateField ? new Date() : "asdf";
        SObject task = new SObject();
        task.setType("Task");
        task.setField("OwnerId", userId);
        task.setField("Subject", TASK_SUBJECT);
        task.setField(fieldToNullName, fieldToNullValue);
        SaveResult[] result = getController().getPartnerClient().getClient().create(new SObject[] { task });
        assertEquals(1, result.length);
        if (!result[0].getSuccess())
            Assert.fail("creation of task failed with error " + result[0].getErrors()[0].getMessage());
        return result[0].getId();
View Full Code Here

            IOUtils.closeQuietly(fis);
        }
    }

    private String insertAccount(String name) throws ConnectionException {
        final SObject account = new SObject();
        account.setType("Account");
        account.setField("Name", name);
        return getBinding().create(new SObject[]{account})[0].getId();
    }
View Full Code Here

        testValidSObjectReference("12345", "Bogus", false);
    }

    private void testValidSObjectReference(String refValue, String relationshipName, boolean expectSuccess) {
        SObjectReference ref = new SObjectReference(refValue);
        SObject sObj = new SObject();
        String fkFieldName = TestBase.DEFAULT_ACCOUNT_EXT_ID_FIELD;

        try {
            ref.addReferenceToSObject(getController(), sObj, ObjectField.formatAsString("Parent",
                    TestBase.DEFAULT_ACCOUNT_EXT_ID_FIELD));

            SObject child = (SObject)sObj.getChild(relationshipName);
            boolean succeeded = child != null && child.getField(fkFieldName) != null && child.getField(fkFieldName)
                    .equals(refValue);
            if (expectSuccess && !succeeded || !expectSuccess && succeeded) {
                Assert.fail();
            }
        } catch (Exception e) {
View Full Code Here

TOP

Related Classes of com.sforce.soap.partner.sobject.SObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.