Search in sources :

Example 1 with DescribeLayout

use of com.salesforce.soap.partner.DescribeLayout in project tdi-studio-se by Talend.

the class PartnerSamples method describeLayoutSample.

private void describeLayoutSample() {
    if (!loggedIn) {
        if (!login()) {
            return;
        }
    }
    String objectToDescribe = getUserInput("Enter the name of an object to describe the layout of: ");
    try {
        DescribeLayoutResult dlr = binding.describeLayout(objectToDescribe, null);
        System.out.println("There are " + dlr.getLayouts().length + " layouts for the " + objectToDescribe + " object.");
        for (int i = 0; i < dlr.getLayouts().length; i++) {
            DescribeLayout layout = dlr.getLayouts(i);
            System.out.println("    There are " + layout.getDetailLayoutSections().length + " detail layout sections");
            for (int j = 0; j < layout.getDetailLayoutSections().length; j++) {
                DescribeLayoutSection dls = layout.getDetailLayoutSections(j);
                System.out.println(new Integer(j).toString() + "        This section has a heading of " + dls.getHeading());
            }
            if (layout.getEditLayoutSections() != null) {
                System.out.println("    There are " + layout.getEditLayoutSections().length + " edit layout sections");
                for (int j = 0; j < layout.getEditLayoutSections().length; j++) {
                    DescribeLayoutSection els = layout.getEditLayoutSections(j);
                    System.out.println(new Integer(j).toString() + "        This section has a heading of " + els.getHeading());
                    System.out.println("This section has " + els.getLayoutRows().length + " layout rows.");
                    for (int k = 0; k < els.getLayoutRows().length; k++) {
                        DescribeLayoutRow lr = els.getLayoutRows(k);
                        System.out.println("            This row has " + lr.getNumItems() + " items.");
                        for (int h = 0; h < lr.getLayoutItems().length; h++) {
                            DescribeLayoutItem li = lr.getLayoutItems(h);
                            if (li.getLayoutComponents() != null) {
                                System.out.println("                " + new Integer(h).toString() + " " + li.getLayoutComponents(0).getValue());
                            } else {
                                System.out.println("                " + new Integer(h).toString());
                            }
                        }
                    }
                }
            }
        }
        if (dlr.getRecordTypeMappings() != null) {
            System.out.println("There are " + dlr.getRecordTypeMappings().length + " record type mappings for the " + objectToDescribe + " object");
        } else {
            System.out.println("There are not record type mappings for the " + objectToDescribe + " object.");
        }
        getUserInput("\nHit return to continue...");
    } catch (ApiFault af) {
        System.out.println("\nFailed to describe layout for: " + objectToDescribe + ", error message was: \n" + af.getExceptionMessage());
        getUserInput("\nHit return to continue...");
    } catch (Exception ex) {
        System.out.println("\nFailed to describe layout for: " + objectToDescribe + ", error message was: \n" + ex.getMessage());
        getUserInput("\nHit return to continue...");
    }
}
Also used : DescribeLayout(com.salesforce.soap.partner.DescribeLayout) DescribeLayoutResult(com.salesforce.soap.partner.DescribeLayoutResult) ApiFault(com.salesforce.soap.partner.fault.ApiFault) DescribeLayoutSection(com.salesforce.soap.partner.DescribeLayoutSection) DescribeLayoutItem(com.salesforce.soap.partner.DescribeLayoutItem) DescribeLayoutRow(com.salesforce.soap.partner.DescribeLayoutRow) RemoteException(java.rmi.RemoteException) ServiceException(javax.xml.rpc.ServiceException) IOException(java.io.IOException)

Aggregations

DescribeLayout (com.salesforce.soap.partner.DescribeLayout)1 DescribeLayoutItem (com.salesforce.soap.partner.DescribeLayoutItem)1 DescribeLayoutResult (com.salesforce.soap.partner.DescribeLayoutResult)1 DescribeLayoutRow (com.salesforce.soap.partner.DescribeLayoutRow)1 DescribeLayoutSection (com.salesforce.soap.partner.DescribeLayoutSection)1 ApiFault (com.salesforce.soap.partner.fault.ApiFault)1 IOException (java.io.IOException)1 RemoteException (java.rmi.RemoteException)1 ServiceException (javax.xml.rpc.ServiceException)1