use of com.sforce.soap.partner.DescribeGlobalResult in project components by Talend.
the class SalesforceRuntimeCommon method getSchemaNames.
public static List<NamedThing> getSchemaNames(PartnerConnection connection) throws IOException {
List<NamedThing> returnList = new ArrayList<>();
DescribeGlobalResult result = null;
try {
result = connection.describeGlobal();
} catch (ConnectionException e) {
throw new ComponentException(e);
}
DescribeGlobalSObjectResult[] objects = result.getSobjects();
for (DescribeGlobalSObjectResult obj : objects) {
LOG.debug("module label: " + obj.getLabel() + " name: " + obj.getName());
returnList.add(new SimpleNamedThing(obj.getName(), obj.getLabel()));
}
return returnList;
}
use of com.sforce.soap.partner.DescribeGlobalResult in project components by Talend.
the class SalesforceRuntimeCommonTest method testGetSchemaNames.
@Test
public void testGetSchemaNames() throws Exception {
DescribeGlobalResult result = new DescribeGlobalResult();
DescribeGlobalSObjectResult sObjectResult1 = new DescribeGlobalSObjectResult();
sObjectResult1.setName("Account");
sObjectResult1.setLabel("Account");
DescribeGlobalSObjectResult sObjectResult2 = new DescribeGlobalSObjectResult();
sObjectResult2.setName("Contact");
sObjectResult2.setLabel("Contact");
DescribeGlobalSObjectResult sObjectResult3 = new DescribeGlobalSObjectResult();
sObjectResult3.setName("Campaign");
sObjectResult3.setLabel("Campaign");
result.setSobjects(new IDescribeGlobalSObjectResult[] { sObjectResult1, sObjectResult2, sObjectResult3 });
PartnerConnection conn = mock(PartnerConnection.class);
doReturn(result).when(conn).describeGlobal();
List<NamedThing> schemaNames = SalesforceRuntimeCommon.getSchemaNames(conn);
assertThat(schemaNames, containsInAnyOrder((NamedThing) new SimpleNamedThing("Account", "Account"), new SimpleNamedThing("Contact", "Contact"), new SimpleNamedThing("Campaign", "Campaign")));
}
use of com.sforce.soap.partner.DescribeGlobalResult in project pentaho-kettle by pentaho.
the class SalesforceConnection method getAllAvailableObjects.
public String[] getAllAvailableObjects(boolean OnlyQueryableObjects) throws KettleException {
DescribeGlobalResult dgr = null;
List<String> objects = null;
DescribeGlobalSObjectResult[] sobjectResults = null;
try {
// Get object
dgr = getBinding().describeGlobal();
// let's get all objects
sobjectResults = dgr.getSobjects();
int nrObjects = dgr.getSobjects().length;
objects = new ArrayList<String>();
for (int i = 0; i < nrObjects; i++) {
DescribeGlobalSObjectResult o = dgr.getSobjects()[i];
if ((OnlyQueryableObjects && o.isQueryable()) || !OnlyQueryableObjects) {
objects.add(o.getName());
}
}
return objects.toArray(new String[objects.size()]);
} catch (Exception e) {
throw new KettleException(BaseMessages.getString(PKG, "SalesforceInput.Error.GettingModules"), e);
} finally {
if (dgr != null) {
dgr = null;
}
if (objects != null) {
objects.clear();
objects = null;
}
if (sobjectResults != null) {
sobjectResults = null;
}
}
}
use of com.sforce.soap.partner.DescribeGlobalResult in project teiid by teiid.
the class SalesForceMetadataProcessor method processMetadata.
public void processMetadata() throws TranslatorException {
try {
DescribeGlobalResult globalResult = connection.getObjects();
DescribeGlobalSObjectResult[] objects = globalResult.getSobjects();
for (DescribeGlobalSObjectResult object : objects) {
addTable(object);
}
List<String> names = new ArrayList<String>();
for (String name : this.tableMap.keySet()) {
names.add(name);
if (names.size() < 100) {
continue;
}
getColumnsAndRelationships(names);
}
if (!names.isEmpty()) {
getColumnsAndRelationships(names);
}
addRelationships();
// Mark id fields are auto increment values, as they are not allowed to be updated
for (Table table : this.metadataFactory.getSchema().getTables().values()) {
if (importStatistics) {
try {
Long val = this.connection.getCardinality(table.getNameInSource());
if (val != null) {
table.setCardinality(val);
}
} catch (Exception e) {
// $NON-NLS-1$
LogManager.logDetail(LogConstants.CTX_CONNECTOR, e, "Could not get cardinality for", table);
}
}
if (table.getPrimaryKey() == null) {
continue;
}
for (Column column : table.getPrimaryKey().getColumns()) {
if (!column.isUpdatable()) {
column.setAutoIncremented(true);
}
}
}
} catch (ResourceException e) {
throw new TranslatorException(e);
}
}
use of com.sforce.soap.partner.DescribeGlobalResult in project components by Talend.
the class SalesforceSourceOrSink method getSchemaNames.
protected List<NamedThing> getSchemaNames(PartnerConnection connection) throws IOException {
List<NamedThing> returnList = new ArrayList<>();
DescribeGlobalResult result = null;
try {
result = connection.describeGlobal();
} catch (ConnectionException e) {
throw new ComponentException(e);
}
DescribeGlobalSObjectResult[] objects = result.getSobjects();
for (DescribeGlobalSObjectResult obj : objects) {
LOG.debug("module label: " + obj.getLabel() + " name: " + obj.getName());
returnList.add(new SimpleNamedThing(obj.getName(), obj.getLabel()));
}
return returnList;
}
Aggregations