Class SalesForceAPITool


  • public class SalesForceAPITool
    extends java.lang.Object
    SalesForce API toolbox
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String DATA_PATH  
      static java.lang.String LOGIN_URL  
      static java.lang.String METADATA_PATH  
      static java.lang.String SOQL_PATH  
    • Method Summary

      Modifier and Type Method Description
      org.json.JSONObject getConfig()
      Get configuration
      static java.lang.String getFieldDefault​(org.json.JSONObject fmd)
      Get default value from field metadata and type
      static java.lang.String getFieldHelp​(org.json.JSONObject fmd)
      Get help from field metadata and type
      static java.lang.String getFieldLabel​(org.json.JSONObject fmd)
      Get label from field metadata and type
      static ListOfValuesData getFieldListOfValues​(org.json.JSONObject fmd)
      Get list of values from field metadata and type
      static java.lang.String getFieldName​(org.json.JSONObject fmd)
      Get name from field metadata
      static java.lang.String getFieldReferencedObjectName​(org.json.JSONObject fmd)
      Get reference to object name from field metadata
      static java.lang.String getFieldRendering​(org.json.JSONObject fmd, int type)
      Get rendering from field metadata and type
      static int getFieldSearch​(org.json.JSONObject fmd, int type)
      Get search mode from field metadata and type
      static int getFieldSearchReq​(org.json.JSONObject fmd, int type, int search)
      Get search required from field metadata and type
      static int getFieldSize​(org.json.JSONObject fmd, int type)
      Get size from field metadata and type
      static int getFieldType​(org.json.JSONObject fmd)
      Get type from field metadata
      static java.lang.String getObjectName​(org.json.JSONObject md)
      Get object name from metadata
      static boolean isRequired​(org.json.JSONObject fmd, int type)
      Is required from field metadata and type
      org.json.JSONObject metadata​(java.lang.String name)
      Get object metadata
      org.json.JSONObject search​(java.lang.String query)
      Run a search query
      org.json.JSONObject select​(java.lang.String name, java.lang.String rowId)
      Run a select
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SalesForceAPITool

        public SalesForceAPITool​(Grant g,
                                 java.lang.String c)
                          throws java.lang.Exception
        SalesForce tools
        Parameters:
        g - Grant
        c - Configuration as JSON string
        Throws:
        java.lang.Exception
      • SalesForceAPITool

        public SalesForceAPITool​(Grant g,
                                 org.json.JSONObject c)
                          throws java.lang.Exception
        SalesForce tools
        Parameters:
        g - Grant
        c - Configuration as JSON object
        Throws:
        java.lang.Exception
    • Method Detail

      • getConfig

        public org.json.JSONObject getConfig()
        Get configuration
        Returns:
        Configuration as JSON object
      • metadata

        public org.json.JSONObject metadata​(java.lang.String name)
                                     throws java.lang.Exception
        Get object metadata
        Parameters:
        name - Object name
        Returns:
        Object metadata as JSON object
        Throws:
        java.lang.Exception
      • getObjectName

        public static java.lang.String getObjectName​(org.json.JSONObject md)
        Get object name from metadata
        Parameters:
        md - Metadata
        Returns:
        Field name
      • getFieldName

        public static java.lang.String getFieldName​(org.json.JSONObject fmd)
        Get name from field metadata
        Parameters:
        fmd - Field metadata
        Returns:
        Field name
      • getFieldLabel

        public static java.lang.String getFieldLabel​(org.json.JSONObject fmd)
        Get label from field metadata and type
        Parameters:
        fmd - Field metadata
        Returns:
        Field label
      • getFieldHelp

        public static java.lang.String getFieldHelp​(org.json.JSONObject fmd)
        Get help from field metadata and type
        Parameters:
        fmd - Field metadata
        Returns:
        Field help
      • getFieldType

        public static int getFieldType​(org.json.JSONObject fmd)
        Get type from field metadata
        Parameters:
        fmd - Field metadata
        Returns:
        Field type (ObjectField.TYPE_*)
      • getFieldSize

        public static int getFieldSize​(org.json.JSONObject fmd,
                                       int type)
        Get size from field metadata and type
        Parameters:
        fmd - Field metadata
        type - Optional type (obtained from getFieldType), or -1
        Returns:
        Field size
      • getFieldDefault

        public static java.lang.String getFieldDefault​(org.json.JSONObject fmd)
        Get default value from field metadata and type
        Parameters:
        fmd - Field metadata
        Returns:
        Field size
      • getFieldRendering

        public static java.lang.String getFieldRendering​(org.json.JSONObject fmd,
                                                         int type)
        Get rendering from field metadata and type
        Parameters:
        fmd - Field metadata
        type - Optional type (obtained from getFieldType), or -1
        Returns:
        Field rendering
      • getFieldReferencedObjectName

        public static java.lang.String getFieldReferencedObjectName​(org.json.JSONObject fmd)
        Get reference to object name from field metadata
        Parameters:
        fmd - Field metadata
        Returns:
        Reference to object name or null
      • getFieldListOfValues

        public static ListOfValuesData getFieldListOfValues​(org.json.JSONObject fmd)
        Get list of values from field metadata and type
        Parameters:
        fmd - Field metadata
        Returns:
        Field size
      • getFieldSearch

        public static int getFieldSearch​(org.json.JSONObject fmd,
                                         int type)
        Get search mode from field metadata and type
        Parameters:
        fmd - Field metadata
        type - Optional type (obtained from getFieldType), or -1
        Returns:
        Field size
      • getFieldSearchReq

        public static int getFieldSearchReq​(org.json.JSONObject fmd,
                                            int type,
                                            int search)
        Get search required from field metadata and type
        Parameters:
        fmd - Field metadata
        type - Optional type (obtained from getFieldType), or -1
        search - Optional search mode (obtained from getFieldSearch), or -1
        Returns:
        Field size
      • isRequired

        public static boolean isRequired​(org.json.JSONObject fmd,
                                         int type)
        Is required from field metadata and type
        Parameters:
        fmd - Field metadata
        type - Optional type (obtained from getFieldType), or -1
        Returns:
        Field size
      • search

        public org.json.JSONObject search​(java.lang.String query)
                                   throws java.lang.Exception
        Run a search query
        Parameters:
        query - Search query
        Returns:
        Search result as JSON object
        Throws:
        java.lang.Exception
      • select

        public org.json.JSONObject select​(java.lang.String name,
                                          java.lang.String rowId)
                                   throws java.lang.Exception
        Run a select
        Parameters:
        name - Object name
        rowId - Record row ID
        Returns:
        Select result as JSON object
        Throws:
        java.lang.Exception