Search in sources :

Example 1 with DataproviderTableFilterdefinition

use of com.servoy.j2db.dataprocessing.DataproviderTableFilterdefinition in project servoy-client by Servoy.

the class Messages method loadMessagesFromDatabaseRepositoryInternal.

/**
 * CURRENTLY FOR INTERNAL USE ONLY, DO NOT CALL.
 *
 * @exclude
 */
public static void loadMessagesFromDatabaseRepositoryInternal(String i18nDatasource, String clientId, Properties settings, IDataServer dataServer, IRepository repository, Properties properties, Properties localeProperties, Locale language, int loadingType, String searchKey, String searchText, String columnNameFilter, String[] columnValueFilter, IFoundSetManagerInternal fm) {
    noConnection = false;
    String[] names = getServerTableNames(i18nDatasource, settings);
    String serverName = names[0];
    String tableName = names[1];
    if (serverName == null || tableName == null || "".equals(serverName) || "".equals(tableName)) {
        noConnection = true;
        return;
    }
    try {
        // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
        Debug.trace("Loading messages from DB: Server: " + serverName + " Table: " + tableName + " Language: " + language);
        IServer server = repository.getServer(serverName);
        if (server == null) {
            noConnection = true;
            return;
        }
        Table table = (Table) server.getTable(tableName);
        if (table == null) {
            noConnection = true;
            return;
        }
        Column filterColumn = null;
        if (columnNameFilter != null) {
            // check if column exists
            filterColumn = table.getColumn(columnNameFilter);
            if (filterColumn == null) {
                return;
            }
        }
        String[] iColumnValueFilter = columnValueFilter;
        boolean isColumnValueFilterChanged = false;
        if (filterColumn == null && fm != null) {
            QueryTable messagesTable = new QueryTable(table.getSQLName(), table.getDataSource(), table.getCatalog(), table.getSchema());
            QuerySelect sql = new QuerySelect(messagesTable);
            ArrayList<TableFilter> tableFilters = fm.getTableFilterParams(serverName, sql);
            if (tableFilters != null) {
                for (TableFilter tableFilter : tableFilters) {
                    TableFilterdefinition tableFilterdefinition = tableFilter.getTableFilterdefinition();
                    if (tableFilterdefinition instanceof DataproviderTableFilterdefinition) {
                        DataproviderTableFilterdefinition dpTtableFilterdefinition = (DataproviderTableFilterdefinition) tableFilterdefinition;
                        Object value = dpTtableFilterdefinition.getValue();
                        if (value instanceof Object[]) {
                            filterColumn = table.getColumn(dpTtableFilterdefinition.getDataprovider());
                            iColumnValueFilter = new String[((Object[]) value).length];
                            for (int i = 0; i < ((Object[]) value).length; i++) {
                                iColumnValueFilter[i] = ((Object[]) value)[i] != null ? ((Object[]) value)[i].toString() : null;
                            }
                            isColumnValueFilterChanged = true;
                            break;
                        }
                    }
                }
            }
        }
        if (!isColumnValueFilterChanged) {
            loadMessagesFromDatabaseRepositorySinglefilter(server, table, clientId, dataServer, properties, localeProperties, language, loadingType, searchKey, searchText, filterColumn, null, fm);
        }
        if (iColumnValueFilter != null) {
            for (int i = iColumnValueFilter.length - 1; i >= 0; i--) {
                loadMessagesFromDatabaseRepositorySinglefilter(server, table, clientId, dataServer, properties, localeProperties, language, loadingType, searchKey, searchText, filterColumn, iColumnValueFilter[i], fm);
            }
        }
    } catch (Exception e) {
        // $NON-NLS-1$
        Debug.error("Couldn't get the default messages");
        Debug.error(e);
        invalidConnection = true;
    }
}
Also used : IServer(com.servoy.j2db.persistence.IServer) QueryTable(com.servoy.j2db.query.QueryTable) Table(com.servoy.j2db.persistence.Table) DataproviderTableFilterdefinition(com.servoy.j2db.dataprocessing.DataproviderTableFilterdefinition) QuerySelect(com.servoy.j2db.query.QuerySelect) DataproviderTableFilterdefinition(com.servoy.j2db.dataprocessing.DataproviderTableFilterdefinition) TableFilterdefinition(com.servoy.j2db.dataprocessing.TableFilterdefinition) QueryTable(com.servoy.j2db.query.QueryTable) ServoyException(com.servoy.j2db.util.ServoyException) MissingResourceException(java.util.MissingResourceException) RemoteException(java.rmi.RemoteException) QueryColumn(com.servoy.j2db.query.QueryColumn) Column(com.servoy.j2db.persistence.Column) TableFilter(com.servoy.j2db.dataprocessing.TableFilter)

Aggregations

DataproviderTableFilterdefinition (com.servoy.j2db.dataprocessing.DataproviderTableFilterdefinition)1 TableFilter (com.servoy.j2db.dataprocessing.TableFilter)1 TableFilterdefinition (com.servoy.j2db.dataprocessing.TableFilterdefinition)1 Column (com.servoy.j2db.persistence.Column)1 IServer (com.servoy.j2db.persistence.IServer)1 Table (com.servoy.j2db.persistence.Table)1 QueryColumn (com.servoy.j2db.query.QueryColumn)1 QuerySelect (com.servoy.j2db.query.QuerySelect)1 QueryTable (com.servoy.j2db.query.QueryTable)1 ServoyException (com.servoy.j2db.util.ServoyException)1 RemoteException (java.rmi.RemoteException)1 MissingResourceException (java.util.MissingResourceException)1