Search in sources :

Example 1 with ConcurrentSoftvaluesMultimap

use of com.servoy.j2db.util.ConcurrentSoftvaluesMultimap in project servoy-client by Servoy.

the class RowManager method fireNotifyChange.

void fireNotifyChange(IRowListener skip, Row row, String pkHashKey, Object[] changedColumns, int eventType, boolean isAggregateChange, boolean skipFSM) {
    List<IRowListener> toNotify = new ArrayList<>();
    if (eventType == RowEvent.INSERT && fsm.config.optimizedNotifyChange()) {
        FlattenedSolution flattenedSolution = getFoundsetManager().getApplication().getFlattenedSolution();
        listenersByRelationEqualValues.entrySet().stream().forEach(entry -> {
            Relation relation = flattenedSolution.getRelation(entry.getKey());
            List<Column> columns = relation.getForeignColumnsForEqualConditions(flattenedSolution);
            if (!columns.isEmpty()) {
                Object[] eqArgs = columns.stream().map(column -> row.getValue(column.getDataProviderID())).toArray();
                String eqHash = RowManager.createPKHashKey(eqArgs);
                toNotify.addAll(entry.getValue().get(eqHash));
            }
        });
    } else {
        // add all related foundsets
        listenersByRelationEqualValues.values().stream().map(ConcurrentSoftvaluesMultimap::allValues).forEach(toNotify::addAll);
    }
    toNotify.addAll(listeners.keySet());
    toNotify.remove(skip);
    if (!toNotify.isEmpty()) {
        RowEvent e = new RowEvent(this, row, pkHashKey, eventType, changedColumns, isAggregateChange);
        toNotify.forEach(listener -> listener.notifyChange(e));
    }
    if (!skipFSM)
        fsm.notifyChange(sheet.getTable());
}
Also used : ISQLUpdate(com.servoy.j2db.query.ISQLUpdate) Arrays(java.util.Arrays) Pair(com.servoy.j2db.util.Pair) Date(java.util.Date) QueryColumn(com.servoy.j2db.query.QueryColumn) Debug(com.servoy.j2db.util.Debug) SetCondition(com.servoy.j2db.query.SetCondition) QueryTable(com.servoy.j2db.query.QueryTable) Utils(com.servoy.j2db.util.Utils) Map(java.util.Map) IBaseSQLCondition(com.servoy.base.query.IBaseSQLCondition) AbstractBaseQuery(com.servoy.j2db.query.AbstractBaseQuery) IRepository(com.servoy.j2db.persistence.IRepository) Collection(java.util.Collection) QueryDelete(com.servoy.j2db.query.QueryDelete) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) Streams(com.google.common.collect.Streams) Table(com.servoy.j2db.persistence.Table) RemoteException(java.rmi.RemoteException) List(java.util.List) QueryColumnValue(com.servoy.j2db.query.QueryColumnValue) Entry(java.util.Map.Entry) CacheBuilder(com.google.common.cache.CacheBuilder) Arrays.stream(java.util.Arrays.stream) UUID(com.servoy.j2db.util.UUID) Types(java.sql.Types) QueryInsert(com.servoy.j2db.query.QueryInsert) DbIdentValue(com.servoy.j2db.dataprocessing.ValueFactory.DbIdentValue) FlattenedSolution(com.servoy.j2db.FlattenedSolution) IQuerySelectValue(com.servoy.j2db.query.IQuerySelectValue) HashMap(java.util.HashMap) GlobalScope(com.servoy.j2db.scripting.GlobalScope) ReferenceQueue(java.lang.ref.ReferenceQueue) ArrayList(java.util.ArrayList) ConcurrentMap(java.util.concurrent.ConcurrentMap) HashSet(java.util.HashSet) SafeArrayList(com.servoy.j2db.util.SafeArrayList) Relation(com.servoy.j2db.persistence.Relation) ServoyException(com.servoy.j2db.util.ServoyException) QueryUpdate(com.servoy.j2db.query.QueryUpdate) IBaseColumn(com.servoy.base.persistence.IBaseColumn) Iterator(java.util.Iterator) CalculationDependencyData(com.servoy.j2db.dataprocessing.RowManager.RowFireNotifyChange.CalculationDependencyData) QuerySelect(com.servoy.j2db.query.QuerySelect) SoftReferenceWithData(com.servoy.j2db.util.SoftReferenceWithData) IServer(com.servoy.j2db.persistence.IServer) Collectors.toList(java.util.stream.Collectors.toList) ConcurrentSoftvaluesMultimap(com.servoy.j2db.util.ConcurrentSoftvaluesMultimap) ColumnInfo(com.servoy.j2db.persistence.ColumnInfo) BlobMarkerValue(com.servoy.j2db.dataprocessing.ValueFactory.BlobMarkerValue) Column(com.servoy.j2db.persistence.Column) RepositoryException(com.servoy.j2db.persistence.RepositoryException) Collections(java.util.Collections) TablePlaceholderKey(com.servoy.j2db.query.TablePlaceholderKey) ArrayList(java.util.ArrayList) SafeArrayList(com.servoy.j2db.util.SafeArrayList) FlattenedSolution(com.servoy.j2db.FlattenedSolution) Relation(com.servoy.j2db.persistence.Relation) QueryColumn(com.servoy.j2db.query.QueryColumn) IBaseColumn(com.servoy.base.persistence.IBaseColumn) Column(com.servoy.j2db.persistence.Column)

Aggregations

CacheBuilder (com.google.common.cache.CacheBuilder)1 Streams (com.google.common.collect.Streams)1 IBaseColumn (com.servoy.base.persistence.IBaseColumn)1 IBaseSQLCondition (com.servoy.base.query.IBaseSQLCondition)1 FlattenedSolution (com.servoy.j2db.FlattenedSolution)1 CalculationDependencyData (com.servoy.j2db.dataprocessing.RowManager.RowFireNotifyChange.CalculationDependencyData)1 BlobMarkerValue (com.servoy.j2db.dataprocessing.ValueFactory.BlobMarkerValue)1 DbIdentValue (com.servoy.j2db.dataprocessing.ValueFactory.DbIdentValue)1 Column (com.servoy.j2db.persistence.Column)1 ColumnInfo (com.servoy.j2db.persistence.ColumnInfo)1 IRepository (com.servoy.j2db.persistence.IRepository)1 IServer (com.servoy.j2db.persistence.IServer)1 Relation (com.servoy.j2db.persistence.Relation)1 RepositoryException (com.servoy.j2db.persistence.RepositoryException)1 Table (com.servoy.j2db.persistence.Table)1 AbstractBaseQuery (com.servoy.j2db.query.AbstractBaseQuery)1 IQuerySelectValue (com.servoy.j2db.query.IQuerySelectValue)1 ISQLUpdate (com.servoy.j2db.query.ISQLUpdate)1 QueryColumn (com.servoy.j2db.query.QueryColumn)1 QueryColumnValue (com.servoy.j2db.query.QueryColumnValue)1