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;
}
}
Aggregations