Package com.isomorphic.tools

# Class BuiltinRPC

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

All Implemented Interfaces:
  `com.isomorphic.base.IAutoConfigurable`

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

  Modifier and Type
  Method
  Description
  `void`
  `clearAttributes(jakarta.servlet.http.HttpSession session)`
  Clears any attributes previously stored by the setAttributes method.
  `static List`
  `getBeanFields(String className)`
  Returns a list of fields derived from the properties of the passed-in JavaBean.
  `static Map`
  `getDatabaseProductNameAndVersion(String serverType, 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(String className)`
  Returns a DataSource config Map for the Java class provided.
  `static DataSource`
  `getDataSourceFromHibernateMapping(String entityName, String ID)`
  Returns a DataSource derived from the Hibernate entity provided.
  `static DataSource`
  `getDataSourceFromTable(String tableName, String serverType, String dbName, String ID, Map properties, String schema)`
  Returns a DataSource derived from the table provided.
  `static String`
  `getDataSourceJSONFromHibernateMapping(String entityName, String ID)`
  Returns the JSON representation of a DataSource derived from the entity provided.
  `static String`
  `getDataSourceJSONFromTable(String tableName, String serverType, String dbName, String ID, Map properties, String schema)`
  Returns the JSON representation of a DataSource derived from the table provided.
  `static String`
  `getDefaultDatabase()`
  Returns the "dbName" of the current default database (server type "sql"), as defined by the `server.properties` setting `sql.defaultDatabase`
  `static RPCResponse`
  `getDefinedDataSources(RequestContext context)`
  Returns an `RPCResponse`, the data member of which is a List of Maps containing information about all defined DataSources available to this application - ie, with valid DataSource descriptors defined in any declared DataSource location
  `static List`
  `getDefinedDataSourcesAsList()`
  Returns a List of Maps containing information about all defined DataSources available to this application - ie, with valid DataSource descriptors defined in any declared DataSource location
  `static List`
  `getFieldsFromTable(String tableName, String schema, String serverType, 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 List`
  `getHibernateBeans(List include, List exclude, boolean excludeNullMappings)`
  Returns a list of classes currently mapped in Hibernate.
  `static List`
  `getSchemas(String serverType, String dbName)`
  Returns a list of schemas in the parameter (or default) database.
  `static List`
  `getTables(String serverType, String dbName, boolean includeTables, boolean includeViews, String catalog, String schema, List include, List exclude)`
  Returns a list of table and/or view names
  `static void`
  `setAttributes(String scope, Object attributes, String prefix, jakarta.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, downloadMultiSheetExport, downloadWSDL, downloadZip, evalJava, getLogEntries, getLogNames, loadFile, loadSharedXML, ping, saveFile, saveSharedXML, uploadProgressCheck, xmlToJS`

- ## Method Details

  - ### getDataSourceFromTable

    public static DataSource getDataSourceFromTable(String tableName, String serverType, String dbName, String ID, Map properties, String schema) throws 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
      `schema` - The name of the schema in which the table will be found. If null, we use the schema declared in the database config block; if no such schema is declared, we use null, which means "all schemas"
    Returns:
      DataSource derived from the table
    Throws:
      `Exception`

  - ### getDataSourceJSONFromTable

    public static String getDataSourceJSONFromTable(String tableName, String serverType, String dbName, String ID, Map properties, String schema) throws 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
      `schema` - The name of the schema in which the table will be found. If null, we use the schema declared in the database config block; if no such schema is declared, we use null, which means "all schemas"
    Returns:
      The JSON representation of the DataSource derived from the table
    Throws:
      `Exception`

  - ### getDataSourceFromHibernateMapping

    public static DataSource getDataSourceFromHibernateMapping(String entityName, String ID) throws 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:
      `Exception`

  - ### getDataSourceJSONFromHibernateMapping

    public static String getDataSourceJSONFromHibernateMapping(String entityName, String ID) throws 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:
      `Exception`

  - ### getTables

    public static List getTables(String serverType, String dbName, boolean includeTables, boolean includeViews, String catalog, String schema, List include, List exclude) throws 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. Note, "catalog" is redundant in the majority of cases and is generally unsupported by SmartClient's SQL features. We discourage its use - it is only retained in this API for backwards-compatibility reasons
      `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:
      `Exception`

  - ### getSchemas

    public static List getSchemas(String serverType, String dbName) throws Exception
    Returns a list of schemas in the parameter (or default) database. Note that some database products (eg, MySQL) do not support the idea of separate schemas within a database at all; this method will always return an empty list for such databases
    Parameters:
      `serverType` - "sql" or "hibernate", determines the database connection strategy
      `dbName` - Optionally, the name of the database - if null, uses the default
    Returns:
      List of schemas
    Throws:
      `Exception`

  - ### getFieldsFromTable

    public static List getFieldsFromTable(String tableName, String schema, String serverType, String dbName) throws 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). If null, looks for the named table in all schemas, and uses the first one it finds if a table of that name exists in more than one 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:
      `Exception`

  - ### getBeanFields

    public static List getBeanFields(String className) throws 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:
      `Exception`

  - ### getHibernateBeans

    public static List getHibernateBeans(List include, List exclude, boolean excludeNullMappings) throws 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:
      `Exception`

  - ### getDatabaseProductNameAndVersion

    public static Map getDatabaseProductNameAndVersion(String serverType, String dbName) throws 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:
      `Exception`

  - ### getDefaultDatabase

    public static String getDefaultDatabase() throws Exception
    Returns the "dbName" of the current default database (server type "sql"), as defined by the `server.properties` setting `sql.defaultDatabase`
    Returns:
      String containing the default database dbName
    Throws:
      `Exception`

  - ### setAttributes

    public static void setAttributes(String scope, Object attributes, String prefix, jakarta.servlet.http.HttpServletRequest req) throws 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:
      `Exception`

  - ### clearAttributes

    public void clearAttributes(jakarta.servlet.http.HttpSession session) throws Exception
    Clears any attributes previously stored by the setAttributes method. Only applicable to parameters in session scope.
    Throws:
      `Exception`

  - ### getDataSourceConfigFromJavaClass

    public static RPCResponse getDataSourceConfigFromJavaClass(String className) throws 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:
      `Exception`

  - ### getDefinedDataSourcesAsList

    public static List getDefinedDataSourcesAsList() throws Exception
    Returns a List of Maps containing information about all defined DataSources available to this application - ie, with valid DataSource descriptors defined in any declared DataSource location
    Returns:
      List of Maps of DataSource information
    Throws:
      `Exception`

  - ### getDefinedDataSources

    public static RPCResponse getDefinedDataSources(RequestContext context) throws Exception
    Returns an `RPCResponse`, the data member of which is a List of Maps containing information about all defined DataSources available to this application - ie, with valid DataSource descriptors defined in any declared DataSource location
    Parameters:
      `context` - A `RequestContext`
    Returns:
      RPCResponse wrapping a List of Maps of DataSource information
    Throws:
      `Exception`