com.isomorphic.tools

## Class BuiltinRPC

- java.lang.Object
- - com.isomorphic.base.Base
  - - com.isomorphic.rpc.BuiltinRPC
    - - com.isomorphic.tools.BuiltinRPC

-     public class BuiltinRPC
      extends BuiltinRPC

  This class implements an extra set of "built-in" RPC methods over and above the ones implemented in com.isomorphic.rpc.BuiltinRPC. Those are available to all applications as part of all SmartClient distributions. The methods in this class are only available to owners of the Pro or Enterprise versions of SmartClient. Most of these methods should not be callable from the client in a production setting. By default, all of these are enabled in the smartclientSDK and only the methods flagged as enabled in smartclientRuntime are enabled there by default.

  You can control which methods are enabled by listing the enabled methods under the server.properties attribute `RPCManager.enabledBuiltinMethods`.

- - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clearAttributes(javax.servlet.http.HttpSession session)` Clears any attributes previously stored by the setAttributes method.
    `static java.util.List` | `getBeanFields(java.lang.String className)` Returns a list of fields derived from the properties of the passed-in JavaBean.
    `static java.util.Map` | `getDatabaseProductNameAndVersion(java.lang.String serverType, java.lang.String dbName)` Returns the product name and version of the database connected via Hibernate or the supplied dbName configuration (the default configuration if not supplied), depending on value of serverType
    `static RPCResponse` | `getDataSourceConfigFromJavaClass(java.lang.String className)` Returns a DataSource config Map for the Java class provided.
    `static DataSource` | `getDataSourceFromHibernateMapping(java.lang.String entityName, java.lang.String ID)` Returns a DataSource derived from the Hibernate entity provided.
    `static DataSource` | `getDataSourceFromTable(java.lang.String tableName, java.lang.String serverType, java.lang.String dbName, java.lang.String ID, java.util.Map properties)` Returns a DataSource derived from the table provided.
    `static java.lang.String` | `getDataSourceJSONFromHibernateMapping(java.lang.String entityName, java.lang.String ID)` Returns the JSON representation of a DataSource derived from the entity provided.
    `static java.lang.String` | `getDataSourceJSONFromTable(java.lang.String tableName, java.lang.String serverType, java.lang.String dbName, java.lang.String ID, java.util.Map properties)` Returns the JSON representation of a DataSource derived from the table provided.
    `static java.util.List` | `getFieldsFromTable(java.lang.String tableName, java.lang.String schema, java.lang.String serverType, java.lang.String dbName)` Returns a list of fields in the passed in table, with properties such as type and length inferred from the database metadata.
    `static java.util.List` | `getHibernateBeans(java.util.List include, java.util.List exclude, boolean excludeNullMappings)` Returns a list of classes currently mapped in Hibernate.
    `static java.util.List` | `getTables(java.lang.String serverType, java.lang.String dbName, boolean includeTables, boolean includeViews, java.lang.String catalog, java.lang.String schema, java.util.List include, java.util.List exclude)` Returns a list of table and/or view names
    `static void` | `setAttributes(java.lang.String scope, java.lang.Object attributes, java.lang.String prefix, javax.servlet.http.HttpServletRequest req)` Stores the supplied attributes on the server, in either request or session scope.

    - ### Methods inherited from class com.isomorphic.rpc.BuiltinRPC

      `appendToFile, deleteFile, downloadClientContent, downloadClientExport, downloadWSDL, downloadZip, evalJava, getLogEntries, getLogNames, loadFile, loadSharedXML, ping, saveFile, saveSharedXML, uploadProgressCheck, xmlToJS`

- - ### Method Detail

    - #### getDataSourceFromTable

          public static DataSource getDataSourceFromTable(java.lang.String tableName,
                                                          java.lang.String serverType,
                                                          java.lang.String dbName,
                                                          java.lang.String ID,
                                                          java.util.Map properties)
                                                   throws java.lang.Exception

      Returns a DataSource derived from the table provided. If the serverType is "sql", dbName specifies which database configuration to use, with null meaning the default database configuration. If serverType is "hibernate", database information comes from Hibernate instead.
      Parameters:
        `tableName` - The name of the table.
        `serverType` - "sql" or "hibernate"
        `dbName` - Optionally, the name of the database - if null, uses the default
        `ID` - Optionally, the ID of the DataSource - if null, uses the tableName
        `properties` - An optional Map of properties to apply to the derived DataSource
      Returns:
        DataSource derived from the table
      Throws:
        `java.lang.Exception`

    - #### getDataSourceJSONFromTable

          public static java.lang.String getDataSourceJSONFromTable(java.lang.String tableName,
                                                                    java.lang.String serverType,
                                                                    java.lang.String dbName,
                                                                    java.lang.String ID,
                                                                    java.util.Map properties)
                                                             throws java.lang.Exception

      Returns the JSON representation of a DataSource derived from the table provided.
      Parameters:
        `tableName` - The name of the table.
        `serverType` - "sql" or "hibernate"
        `dbName` - Optionally, the name of the database - if null, uses the default
        `ID` - Optionally, the ID of the DataSource - if null, uses the tableName
        `properties` - An optional Map of properties to apply to the derived DataSource
      Returns:
        The JSON representation of the DataSource derived from the table
      Throws:
        `java.lang.Exception`

    - #### getDataSourceFromHibernateMapping

          public static DataSource getDataSourceFromHibernateMapping(java.lang.String entityName,
                                                                     java.lang.String ID)
                                                              throws java.lang.Exception

      Returns a DataSource derived from the Hibernate entity provided.
      Parameters:
        `entityName` - The name of the Hibernate mapped entity.
      Returns:
        DataSource derived from the mapped entity
      Throws:
        `java.lang.Exception`

    - #### getDataSourceJSONFromHibernateMapping

          public static java.lang.String getDataSourceJSONFromHibernateMapping(java.lang.String entityName,
                                                                               java.lang.String ID)
                                                                        throws java.lang.Exception

      Returns the JSON representation of a DataSource derived from the entity provided.
      Parameters:
        `entityName` - The name of the Hibernate mapped entity.
      Returns:
        The JSON representation of the DataSource derived from the mapped entity
      Throws:
        `java.lang.Exception`

    - #### getTables

          public static java.util.List getTables(java.lang.String serverType,
                                                 java.lang.String dbName,
                                                 boolean includeTables,
                                                 boolean includeViews,
                                                 java.lang.String catalog,
                                                 java.lang.String schema,
                                                 java.util.List include,
                                                 java.util.List exclude)
                                          throws java.lang.Exception

      Returns a list of table and/or view names
      Parameters:
        `serverType` - "sql" or "hibernate", determines the database connection strategy
        `dbName` - Optionally, the name of the database - if null, uses the default
        `includeTables` - If true, includes tables in the returned list
        `includeViews` - If true, includes views in the returned list
        `catalog` - Optionally, the catalog name to use to restrict the list. If null, searches all catalogs.
        `schema` - Optionally, the schema name to use to restrict the list. If null, searches all schemata.
        `include` - Optionally, a list of partial table names to perform substring checking against. Tables will be included where the table name matches any of the supplied substrings. The matching is not case sensitive.
        `exclude` - Optionally, a list of partial table names to perform substring checking against. Tables will be excluded where the table name matches any of the supplied substrings. The matching is not case sensitive. Note that if you specify both include and exclude criteria and they conflict (ie, according to the criteria you set, a table should be both included and excluded), exclude wins.
      Returns:
        List of table names and remarks
      Throws:
        `java.lang.Exception`

    - #### getFieldsFromTable

          public static java.util.List getFieldsFromTable(java.lang.String tableName,
                                                          java.lang.String schema,
                                                          java.lang.String serverType,
                                                          java.lang.String dbName)
                                                   throws java.lang.Exception

      Returns a list of fields in the passed in table, with properties such as type and length inferred from the database metadata.
      Parameters:
        `tableName` - The name of the table.
        `schema` - Optionally, the name of the database schema to use (not all databases require - or even recognize the concept of - a schema)
        `serverType` - "sql" or "hibernate", determines the database connection strategy
        `dbName` - Optionally, the name of the database if serverType is "sql". If null, uses the default
      Returns:
        List of fields in the supplied table
      Throws:
        `java.lang.Exception`

    - #### getBeanFields

          public static java.util.List getBeanFields(java.lang.String className)
                                              throws java.lang.Exception

      Returns a list of fields derived from the properties of the passed-in JavaBean.
      Parameters:
        `className` - The fully-qualified classname of the JavaBean
      Returns:
        List of fields derived from the properties of the supplied JavaBean class
      Throws:
        `java.lang.Exception`

    - #### getHibernateBeans

          public static java.util.List getHibernateBeans(java.util.List include,
                                                         java.util.List exclude,
                                                         boolean excludeNullMappings)
                                                  throws java.lang.Exception

      Returns a list of classes currently mapped in Hibernate. Each list item contains an entity name and a fully-qualified classname. It is possible for the classname to be null, for example, if you are using SmartClient "hibernate" DataSources to create Hibernate mappings from arbitrary Map objects on the fly. If the excludeNullMappings parameter is true, these mappings to null classnames will be excluded from the returned list.
      Parameters:
        `include` - Optionally, a list of partial entity names to perform substring checking against. Entities will be included where the entity name matches any of the supplied substrings. The matching is not case sensitive.
        `exclude` - Optionally, a list of partial entity names to perform substring checking against. Entities will be excluded where the table name matches any of the supplied substrings. The matching is not case sensitive. Note that if you specify both include and exclude criteria and they conflict (ie, according to the criteria you set, an entity should be both included and excluded), exclude wins.
        `excludeNullMappings` - Excludes mappings with a null classname from the list
      Returns:
        List of Maps, each containing an entityName and a className
      Throws:
        `java.lang.Exception`

    - #### getDatabaseProductNameAndVersion

          public static java.util.Map getDatabaseProductNameAndVersion(java.lang.String serverType,
                                                                       java.lang.String dbName)
                                                                throws java.lang.Exception

      Returns the product name and version of the database connected via Hibernate or the supplied dbName configuration (the default configuration if not supplied), depending on value of serverType
      Parameters:
        `serverType` - "sql" or "hibernate", determines the database connection strategy
        `dbName` - Optional name of the configuration to use, if serverType is "sql"
      Returns:
        String containing the database product name and version
      Throws:
        `java.lang.Exception`

    - #### setAttributes

          public static void setAttributes(java.lang.String scope,
                                           java.lang.Object attributes,
                                           java.lang.String prefix,
                                           javax.servlet.http.HttpServletRequest req)
                                    throws java.lang.Exception

      Stores the supplied attributes on the server, in either request or session scope. This method allows you to explicitly add state to your server-side.

      This method is used by the batchUploader to store uploadFormFields.

      Parameters:
        `scope` - Either "request" or "session", indicates where SmartClient should store the passed attributes
        `attributes` - A Map or List of Maps specifying the attributes. Each map should contain at least a name entry and a value entry. If you also supply a type, SmartClient will make a better attempt at storing your attributes as appropriate types (Integer, Boolean etc, rather than String)
        `prefix` - String to prepend to field names before they are stored in the request or session. This provides a basic namespace facility, allowing you to avoid name collisions with existing session attributes.

        Example usage: if you pass an attribute called "someDate" and a prefix of "myFields_", your attribute will be available as "myFields_someDate"

      Throws:
        `java.lang.Exception`

    - #### clearAttributes

          public void clearAttributes(javax.servlet.http.HttpSession session)
                               throws java.lang.Exception

      Clears any attributes previously stored by the setAttributes method. Only applicable to parameters in session scope.
      Throws:
        `java.lang.Exception`

    - #### getDataSourceConfigFromJavaClass

          public static RPCResponse getDataSourceConfigFromJavaClass(java.lang.String className)
                                                              throws java.lang.Exception

      Returns a DataSource config Map for the Java class provided.
      Parameters:
        `className` - The name of the Java class.
      Returns:
        The DataSource config Map for the passed className, or null
      Throws:
        `java.lang.Exception`