Search in sources :

Example 1 with DeletedResult

use of org.teiid.translator.salesforce.execution.DeletedResult in project teiid by teiid.

the class SalesforceConnectionImpl method getDeleted.

public DeletedResult getDeleted(String objectName, Calendar startCalendar, Calendar endCalendar) throws ResourceException {
    GetDeletedResult deleted;
    try {
        deleted = partnerConnection.getDeleted(objectName, startCalendar, endCalendar);
    } catch (InvalidSObjectFault e) {
        throw new ResourceException(e);
    } catch (UnexpectedErrorFault e) {
        throw new ResourceException(e);
    } catch (ConnectionException e) {
        throw new ResourceException(e);
    }
    DeletedResult result = new DeletedResult();
    result.setLatestDateCovered(deleted.getLatestDateCovered());
    result.setEarliestDateAvailable(deleted.getEarliestDateAvailable());
    DeletedRecord[] records = deleted.getDeletedRecords();
    List<DeletedObject> resultRecords = new ArrayList<DeletedObject>();
    if (records != null) {
        for (DeletedRecord record : records) {
            DeletedObject object = new DeletedObject();
            object.setID(record.getId());
            object.setDeletedDate(record.getDeletedDate());
            resultRecords.add(object);
        }
    }
    result.setResultRecords(resultRecords);
    return result;
}
Also used : InvalidSObjectFault(com.sforce.soap.partner.fault.InvalidSObjectFault) DeletedResult(org.teiid.translator.salesforce.execution.DeletedResult) ArrayList(java.util.ArrayList) ResourceException(javax.resource.ResourceException) UnexpectedErrorFault(com.sforce.soap.partner.fault.UnexpectedErrorFault) ConnectionException(com.sforce.ws.ConnectionException) DeletedObject(org.teiid.translator.salesforce.execution.DeletedObject)

Example 2 with DeletedResult

use of org.teiid.translator.salesforce.execution.DeletedResult in project teiid by teiid.

the class TestSalesforceConnectionImpl method testGetDeleted.

@Test
public void testGetDeleted() throws Exception {
    PartnerConnection pc = Mockito.mock(PartnerConnection.class);
    GetDeletedResult gdr = new GetDeletedResult();
    Calendar c = Calendar.getInstance();
    gdr.setEarliestDateAvailable(c);
    gdr.setLatestDateCovered(c);
    DeletedRecord dr = new DeletedRecord();
    dr.setDeletedDate(c);
    dr.setId("id");
    gdr.setDeletedRecords(new DeletedRecord[] { dr });
    Mockito.stub(pc.getDeleted("x", null, null)).toReturn(gdr);
    SalesforceConnectionImpl sfci = new SalesforceConnectionImpl(pc);
    DeletedResult result = sfci.getDeleted("x", null, null);
    assertEquals(1, result.getResultRecords().size());
}
Also used : GetDeletedResult(com.sforce.soap.partner.GetDeletedResult) DeletedResult(org.teiid.translator.salesforce.execution.DeletedResult) PartnerConnection(com.sforce.soap.partner.PartnerConnection) DeletedRecord(com.sforce.soap.partner.DeletedRecord) Calendar(java.util.Calendar) GetDeletedResult(com.sforce.soap.partner.GetDeletedResult) Test(org.junit.Test)

Aggregations

DeletedResult (org.teiid.translator.salesforce.execution.DeletedResult)2 DeletedRecord (com.sforce.soap.partner.DeletedRecord)1 GetDeletedResult (com.sforce.soap.partner.GetDeletedResult)1 PartnerConnection (com.sforce.soap.partner.PartnerConnection)1 InvalidSObjectFault (com.sforce.soap.partner.fault.InvalidSObjectFault)1 UnexpectedErrorFault (com.sforce.soap.partner.fault.UnexpectedErrorFault)1 ConnectionException (com.sforce.ws.ConnectionException)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 ResourceException (javax.resource.ResourceException)1 Test (org.junit.Test)1 DeletedObject (org.teiid.translator.salesforce.execution.DeletedObject)1