use of com.servoy.j2db.persistence.IServer in project servoy-client by Servoy.
the class FlattenedSolution method combineServerProxies.
private void combineServerProxies(ConcurrentMap<String, IServer> orgs, ConcurrentMap<String, IServer> additional) throws RemoteException {
Iterator<IServer> it = additional.values().iterator();
while (it.hasNext()) {
IServer addObject = it.next();
IServer orgObject = orgs.get(addObject.getName());
if (addObject instanceof ServerProxy) {
ServerProxy add = (ServerProxy) addObject;
if (orgObject == null) {
orgs.put(add.getName(), add);
} else if (orgObject instanceof ServerProxy) {
ServerProxy org = (ServerProxy) orgObject;
org.combineTables(add);
}
}
}
}
use of com.servoy.j2db.persistence.IServer in project servoy-client by Servoy.
the class Messages method deleteKey.
public static boolean deleteKey(String key, String i18nDatasource, String clientId, Properties settings, IDataServer dataServer, IRepository repository, IFoundSetManagerInternal fm) {
String[] names = getServerTableNames(i18nDatasource, settings);
String serverName = names[0];
String tableName = names[1];
if (serverName != null && tableName != null) {
try {
IServer server = repository.getServer(serverName);
if (server == null) {
return false;
}
Table table = (Table) server.getTable(tableName);
if (table == null) {
return false;
}
QueryTable messagesTable = new QueryTable(table.getSQLName(), table.getDataSource(), table.getCatalog(), table.getSchema());
// $NON-NLS-1$
QueryColumn msgKey = new QueryColumn(messagesTable, -1, "message_key", Types.VARCHAR, 150, 0, null, 0);
QueryDelete delete = new QueryDelete(messagesTable);
delete.addCondition(new CompareCondition(IBaseSQLCondition.EQUALS_OPERATOR, msgKey, key));
ISQLStatement sqlStatement = new SQLStatement(ISQLActionTypes.DELETE_ACTION, serverName, tableName, null, null, delete, fm != null ? fm.getTableFilterParams(serverName, delete) : null);
dataServer.performUpdates(clientId, new ISQLStatement[] { sqlStatement });
} catch (Exception e) {
return false;
}
}
return true;
}
use of com.servoy.j2db.persistence.IServer 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;
}
}
use of com.servoy.j2db.persistence.IServer in project servoy-client by Servoy.
the class FoundSetManager method getSortOptions.
@Override
public SortOptions getSortOptions(IColumn column) {
boolean ignoreCase = false;
SortingNullprecedence sortingNullprecedence = SortingNullprecedence.databaseDefault;
if (column != null) {
try {
// First defined at server level
IServer server = application.getSolution().getServer(column.getTable().getServerName());
if (server != null) {
ignoreCase = server.getSettings().isSortIgnorecase();
sortingNullprecedence = server.getSettings().getSortingNullprecedence();
}
} catch (RepositoryException | RemoteException e) {
Debug.error("Exception getting server settings", e);
}
ColumnInfo columnInfo = column.getColumnInfo();
if (columnInfo != null) {
// Can be overridden at column level
if (columnInfo.getSortIgnorecase() != null) {
ignoreCase = columnInfo.getSortIgnorecase().booleanValue();
}
if (columnInfo.getSortingNullprecedence() != null && columnInfo.getSortingNullprecedence() != SortingNullprecedence.databaseDefault) {
sortingNullprecedence = columnInfo.getSortingNullprecedence();
}
}
}
return SortOptions.NONE.withIgnoreCase(ignoreCase).withNullprecedence(sortingNullprecedence);
}
use of com.servoy.j2db.persistence.IServer in project servoy-client by Servoy.
the class SQLSheet method processCopyValues.
void processCopyValues(IRecordInternal s) {
SQLDescription desc = getSQLDescription(SELECT);
if (desc == null) {
return;
}
List<?> list = desc.getDataProviderIDsDilivery();
for (int i = 0; i < list.size(); i++) {
try {
String id = (String) list.get(i);
Column c = table.getColumn(id);
if (c != null) {
ColumnInfo ci = c.getColumnInfo();
if (ci != null && ci.getAutoEnterType() == ColumnInfo.LOOKUP_VALUE_AUTO_ENTER) {
String lookupDataProviderID = ci.getLookupValue();
Object obj = s.getValue(lookupDataProviderID);
if (ScopesUtils.isVariableScope(lookupDataProviderID) && !s.has(lookupDataProviderID)) {
ScriptMethod globalScriptMethod = application.getFlattenedSolution().getScriptMethod(null, lookupDataProviderID);
if (globalScriptMethod != null) {
try {
IServer server = application.getSolution().getServer(table.getServerName());
obj = application.getScriptEngine().getScopesScope().executeGlobalFunction(globalScriptMethod.getScopeName(), globalScriptMethod.getName(), new Object[] { new JSColumn(c, server, table) }, false, false);
} catch (Exception e) {
Debug.error(e);
}
}
}
// Protect to writing null to null-protected columns. An exception gets written in the log.
if (!((obj == null) && !c.getAllowNull()))
s.setValue(id, obj, false);
}
}
} catch (Exception ex) {
Debug.error(ex);
}
}
}
Aggregations