use of com.salesforce.soap.partner.PicklistEntry in project tdi-studio-se by Talend.
the class PartnerSamples method describeSample.
private void describeSample() {
if (!loggedIn) {
if (!login()) {
return;
}
}
String objectToDescribe = getUserInput("\nType the name of the object to describe (try Account): ");
try {
DescribeSObjectResult ds;
DescribeSObjectResult describeSObjectResult = binding.describeSObject(objectToDescribe);
if (!(describeSObjectResult == null)) {
Field[] fields = describeSObjectResult.getFields();
String objectName = describeSObjectResult.getName();
boolean isActivateable = describeSObjectResult.isActivateable();
boolean isCreateable = describeSObjectResult.isCreateable();
boolean isCustom = describeSObjectResult.isCustom();
boolean isDeleteable = describeSObjectResult.isDeletable();
boolean isQueryable = describeSObjectResult.isQueryable();
boolean isReplicateable = describeSObjectResult.isReplicateable();
boolean isRetrieveable = describeSObjectResult.isRetrieveable();
boolean isSearchable = describeSObjectResult.isSearchable();
boolean isUndeleteable = describeSObjectResult.isUndeletable();
boolean isUpdateable = describeSObjectResult.isUpdateable();
System.out.println("Metadata for " + objectToDescribe + " object:\n");
System.out.println("Object name = " + objectName);
System.out.println("Number of fields = " + fields.length);
System.out.println("Object can be activated = " + isActivateable);
System.out.println("Can create rows of data = " + isCreateable);
System.out.println("Object is custom object = " + isCustom);
System.out.println("Can delete rows of data = " + isDeleteable);
System.out.println("Can query for rows of data = " + isQueryable);
System.out.println("Object can be used in replication = " + isReplicateable);
System.out.println("Can use retrieve method on object = " + isRetrieveable);
System.out.println("Can use search method on object = " + isSearchable);
System.out.println("Can un-delete rows of data = " + isUndeleteable);
System.out.println("Can update rows of data = " + isUpdateable);
System.out.println("\nField metadata for " + objectToDescribe + " object:\n");
if (!(fields == null)) {
for (int i = 0; i < fields.length; i++) {
Field field = fields[i];
int byteLength = field.getByteLength();
int digits = field.getDigits();
String label = field.getLabel();
int length = field.getLength();
String name = field.getName();
PicklistEntry[] picklistValues = field.getPicklistValues();
int precision = field.getPrecision();
String[] referenceTos = field.getReferenceTo();
int scale = field.getScale();
FieldType fieldType = field.getType();
boolean fieldIsAutoNumber = field.isAutoNumber();
boolean fieldIsCreateable = field.isCreateable();
boolean fieldIsCustom = field.isCustom();
boolean fieldIsDefaultedOnCreate = field.isDefaultedOnCreate();
boolean fieldIsFilterable = field.isFilterable();
boolean fieldIsNillable = field.isNillable();
boolean fieldIsRestrictedPicklist = field.isRestrictedPicklist();
boolean fieldIsUpdateable = field.isUpdateable();
System.out.println("************* New Field ***************");
System.out.println("Name = " + name);
System.out.println("Label = " + label);
System.out.println("Length = " + length);
System.out.println("Bytelength = " + byteLength);
System.out.println("Digits = " + digits);
System.out.println("Precision = " + precision);
System.out.println("Scale = " + scale);
System.out.println("Field type = " + fieldType);
if (picklistValues != null) {
System.out.println("Picklist values = ");
for (int j = 0; j < picklistValues.length; j++) {
if (picklistValues[j].getLabel() != null) {
System.out.println(" Item: " + picklistValues[j].getLabel());
} else {
System.out.println(" Item: " + picklistValues[j].getValue());
}
System.out.println(" value = " + picklistValues[j].getValue());
System.out.println(" is default = " + picklistValues[j].isDefaultValue());
}
}
if (referenceTos != null) {
System.out.println("Field references the following objects:");
for (int j = 0; j < referenceTos.length; j++) {
System.out.println(" " + referenceTos[j]);
}
}
System.out.println("\n");
}
getUserInput("\nDescribe " + objectToDescribe + " was successful.\n\nHit the enter key to conutinue....");
}
}
} catch (ApiFault af) {
System.out.println("\nFailed to get " + objectToDescribe + " description, error message was: \n" + af.getExceptionMessage());
getUserInput("\nHit return to continue...");
} catch (Exception ex) {
System.out.println("\nFailed to get " + objectToDescribe + " description, error message was: \n" + ex.getMessage());
getUserInput("\nHit return to continue...");
}
}
use of com.salesforce.soap.partner.PicklistEntry in project tdi-studio-se by Talend.
the class PartnerSamples method describeSObjectsSample.
private void describeSObjectsSample() {
if (!loggedIn) {
if (!login()) {
return;
}
}
try {
DescribeSObjectResult[] describeSObjectResults = binding.describeSObjects(new String[] { "account", "contact", "lead" });
for (int x = 0; x < describeSObjectResults.length; x++) {
DescribeSObjectResult describeSObjectResult = describeSObjectResults[x];
// Retrieve fields from the results
Field[] fields = describeSObjectResult.getFields();
// Get the name of the object
String objectName = describeSObjectResult.getName();
// Get some flags
boolean isActivateable = describeSObjectResult.isActivateable();
// Many other values are accessible
if (fields != null) {
// field
for (int i = 0; i < fields.length; i++) {
Field field = fields[i];
int byteLength = field.getByteLength();
int digits = field.getDigits();
String label = field.getLabel();
int length = field.getLength();
String name = field.getName();
PicklistEntry[] picklistValues = field.getPicklistValues();
int precision = field.getPrecision();
String[] referenceTos = field.getReferenceTo();
int scale = field.getScale();
FieldType fieldType = field.getType();
boolean fieldIsCreateable = field.isCreateable();
// Determine whether there are picklist values
if (picklistValues != null && picklistValues[0] != null) {
System.out.println("Picklist values = ");
for (int j = 0; j < picklistValues.length; j++) {
if (picklistValues[j].getLabel() != null) {
System.out.println(" Item: " + picklistValues[j].getLabel());
}
}
}
// Determine whether this field refers to another object
if (referenceTos != null && referenceTos[0] != null) {
System.out.println("Field references the following objects:");
for (int j = 0; j < referenceTos.length; j++) {
System.out.println(" " + referenceTos[j]);
}
}
}
}
}
getUserInput("\nHit return to continue...");
} catch (ApiFault af) {
System.out.println("\nFailed to get describe multiple objects, error message was: \n" + af.getExceptionMessage());
getUserInput("\nHit return to continue...");
} catch (Exception ex) {
System.out.println("\nFailed to get describe multiple objects, error message was: \n" + ex.getMessage());
getUserInput("\nHit return to continue...");
}
}
Aggregations