use of com.servoy.j2db.persistence.RepositoryException in project servoy-client by Servoy.
the class DataAdapterList method valueChanged.
/*
* _____________________________________________________________ JavaScriptModificationListner
*/
/**
* listen for global var changes via own listener and state vars(mainly columns) via state listener if via javascript any var is changed it will be noted
* here,and dispatched to refresh the displays
*/
public void valueChanged(ModificationEvent e) {
if (destroyed) {
Debug.error("Destroyed DataAdapterList " + formController + " was still attached to the record: " + e.getRecord() + ", removing it if possible, currentRecord: " + currentRecord, new RuntimeException());
if (e.getRecord() != null)
e.getRecord().removeModificationListener(this);
else if (currentRecord != null)
currentRecord.removeModificationListener(this);
return;
}
if (formController != null && formController.isDestroyed()) {
Debug.error("Destroying DataAdapterList of a destroyed " + formController, new RuntimeException());
destroy();
return;
}
FormScope formScope = getFormScope();
if (visible && (currentRecord != null || (formScope != null && formScope.has(e.getName(), formScope)))) {
for (IDataAdapter da : dataAdapters.values()) {
// dataAdapter should call state.getValue if name from event is same as its dataProviderID
da.valueChanged(e);
}
// check if a related adapter depends on he global
if (e != null && e.getName() != null) {
for (IDisplayRelatedData drd : relatedDataAdapters) {
boolean depends = false;
String[] allRelationNames = drd.getAllRelationNames();
for (int a = 0; !depends && allRelationNames != null && a < allRelationNames.length; a++) {
Relation[] relations = application.getFlattenedSolution().getRelationSequence(allRelationNames[a]);
for (int r = 0; !depends && relations != null && r < relations.length; r++) {
try {
IDataProvider[] primaryDataProviders = relations[r].getPrimaryDataProviders(application.getFlattenedSolution());
for (int p = 0; !depends && primaryDataProviders != null && p < primaryDataProviders.length; p++) {
depends = e.getName().equals(primaryDataProviders[p].getDataProviderID());
}
} catch (RepositoryException ex) {
Debug.log(ex);
}
}
}
if (depends) {
// related adapter depends on the modified global
if (drd instanceof IDisplayDependencyData)
((IDisplayDependencyData) drd).dependencyChanged(currentRecord);
else
drd.setRecord(currentRecord, true);
}
}
}
// inform servoy aware beans
for (IServoyAwareBean drd : servoyAwareBeans) {
if (drd instanceof IModificationListener) {
try {
((IModificationListener) drd).valueChanged(e);
} catch (RuntimeException ex) {
// never make the app break on faulty beans
Debug.error(ex);
}
}
}
}
}
use of com.servoy.j2db.persistence.RepositoryException in project servoy-client by Servoy.
the class I18NMessagesTable method createMessagesTable.
public static ITable createMessagesTable(IServerInternal server, String tablename, int primaryKeySequenceType) throws RepositoryException, SQLException {
// Create the table in the repository.
IValidateName validator = DummyValidator.INSTANCE;
ITable table = server.createNewTable(validator, tablename);
if (primaryKeySequenceType == ColumnInfo.UUID_GENERATOR) {
Column column = table.createNewColumn(validator, "message_id", IColumnTypes.TEXT, 36);
column.setDatabasePK(true);
column.setSequenceType(primaryKeySequenceType);
column.setFlag(IBaseColumn.UUID_COLUMN, true);
} else {
Column column = table.createNewColumn(validator, "message_id", Types.INTEGER, 0, 0, false, true);
column.setSequenceType(primaryKeySequenceType);
}
table.createNewColumn(validator, "message_key", Types.VARCHAR, 150, 0, false);
Column messageLanguage = table.createNewColumn(validator, "message_language", Types.VARCHAR, 150, 0, true);
table.createNewColumn(validator, "message_value", Types.VARCHAR, 2000, 0, true);
server.syncTableObjWithDB(table, false, false);
try {
server.createIndex(table, table.getName() + "_m_l", new Column[] { messageLanguage }, false);
} catch (Exception e) {
Debug.error("Failed to create an index on the messages table", e);
}
return table;
}
use of com.servoy.j2db.persistence.RepositoryException in project servoy-client by Servoy.
the class ViewFoundSet method loadAllRecordsImpl.
private void loadAllRecordsImpl() throws ServoyException {
String serverName = DataSourceUtils.getDataSourceServerName(select.getTable().getDataSource());
String transaction_id = manager.getTransactionID(serverName);
try {
IDataSet ds = manager.getApplication().getDataServer().performQuery(manager.getApplication().getClientID(), serverName, transaction_id, select, null, manager.getTableFilterParams(serverName, select), select.isUnique(), 0, currentChunkSize, IDataServer.FOUNDSET_LOAD_QUERY);
refresh = false;
ArrayList<IQuerySelectValue> cols = select.getColumns();
int currentSize = records.size();
List<ViewRecord> old = records;
records = new ArrayList<>(ds.getRowCount());
pkByDatasourceCache.clear();
String[] colNames = columnNames.values().toArray(new String[columnNames.size()]);
try (FireCollector fireCollector = getFireCollector()) {
for (int i = 0; i < ds.getRowCount(); i++) {
Object[] rowData = ds.getRow(i);
if (i < currentSize) {
ViewRecord current = old.get(i);
records.add(current);
current.updateValues(colNames, rowData);
} else {
records.add(new ViewRecord(colNames, rowData, this));
}
}
}
hasMore = ds.hadMoreRows();
fireDifference(currentSize, records.size());
} catch (RemoteException e) {
throw new RepositoryException(e);
}
}
use of com.servoy.j2db.persistence.RepositoryException in project servoy-client by Servoy.
the class QBJoins method getOrAddRelation.
private QBJoin getOrAddRelation(IRelation relation, String relationName, String alias) {
if (relation == null || !parent.getDataSource().equals(relation.getPrimaryDataSource())) {
if (relation == null) {
Debug.log("relation '" + relationName + "' not found");
} else {
Debug.log("relation '" + relationName + "' does not match parent data source: " + parent.getDataSource() + '/' + relation.getPrimaryDataSource());
}
return null;
}
String name = alias == null ? relationName : alias;
QBJoin join = getJoin(name);
if (join == null) {
try {
Table foreignTable = root.getTable(relation.getForeignDataSource());
if (foreignTable == null) {
Debug.log("foreign table for relation '" + relationName + "' not found");
return null;
}
join = addJoin(SQLGenerator.createJoin(root.getDataProviderHandler(), relation, parent.getQueryTable(), new QueryTable(foreignTable.getSQLName(), foreignTable.getDataSource(), foreignTable.getCatalog(), foreignTable.getSchema(), alias), true, root.getGlobalScopeProvider()), relation.getForeignDataSource(), name);
} catch (RepositoryException e) {
Debug.error("could not load relation '" + relationName + "'", e);
}
}
return join;
}
use of com.servoy.j2db.persistence.RepositoryException in project servoy-client by Servoy.
the class PartNode method getAggregatesFromRenderer.
private void getAggregatesFromRenderer(final List<AggregateVariable> aggregates, final Form f, DataRenderer a_renderer) throws RepositoryException {
Map<IPersist, IDisplay> allFields = a_renderer.getFieldComponents();
Iterator<IDisplay> it = allFields.values().iterator();
while (it.hasNext()) {
IDisplay display = it.next();
if (display instanceof IDisplayData) {
String dataProviderID = ((IDisplayData) display).getDataProviderID();
if (dataProviderID != null) {
IDataProvider dp = application.getFlattenedSolution().getDataproviderLookup(application.getFoundSetManager(), f).getDataProvider(dataProviderID);
if (dp instanceof AggregateVariable) {
if (!aggregates.contains(dp))
aggregates.add((AggregateVariable) dp);
}
} else if (display instanceof IDisplayTagText) {
String tagText = ((IDisplayTagText) display).getTagText();
Text.processTags(tagText, new ITagResolver() {
public String getStringValue(String name) {
try {
IDataProvider dp = application.getFlattenedSolution().getDataproviderLookup(application.getFoundSetManager(), f).getDataProvider(name);
if (dp instanceof AggregateVariable) {
if (!aggregates.contains(dp))
aggregates.add((AggregateVariable) dp);
}
} catch (Exception e) {
Debug.error(e);
}
return null;
}
});
}
}
}
}
Aggregations