use of com.servoy.j2db.FlattenedSolution in project servoy-client by Servoy.
the class RowManager method unregister.
void unregister(IRowListener fs) {
if (fsm.config.optimizedNotifyChange() && fs instanceof RelatedFoundSet) {
FlattenedSolution flattenedSolution = getFoundsetManager().getApplication().getFlattenedSolution();
RelatedFoundSet relatedFoundSet = (RelatedFoundSet) fs;
Relation relation = flattenedSolution.getRelation(relatedFoundSet.getRelationName());
if (relation != null && Relation.isValid(relation, flattenedSolution)) {
Object[] eqArgs = relatedFoundSet.getWhereArgs(true);
if (eqArgs != null) {
ConcurrentSoftvaluesMultimap<String, RelatedFoundSet> listenersByEqualValues = listenersByRelationEqualValues.get(relation.getName());
if (listenersByEqualValues != null) {
listenersByEqualValues.remove(createPKHashKey(eqArgs), relatedFoundSet);
}
}
}
}
listeners.remove(fs);
}
use of com.servoy.j2db.FlattenedSolution 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());
}
use of com.servoy.j2db.FlattenedSolution in project servoy-client by Servoy.
the class RowManager method register.
void register(IRowListener fs) {
boolean listenersByEqualValuesAdded = false;
if (fsm.config.optimizedNotifyChange() && fs instanceof RelatedFoundSet) {
FlattenedSolution flattenedSolution = getFoundsetManager().getApplication().getFlattenedSolution();
RelatedFoundSet relatedFoundSet = (RelatedFoundSet) fs;
Relation relation = flattenedSolution.getRelation(relatedFoundSet.getRelationName());
if (relation != null && Relation.isValid(relation, flattenedSolution)) {
Object[] eqArgs = relatedFoundSet.getWhereArgs(true);
if (eqArgs != null && !stream(eqArgs).anyMatch(DbIdentValue.class::isInstance)) {
ConcurrentSoftvaluesMultimap<String, RelatedFoundSet> listenersByEqualValues = listenersByRelationEqualValues.get(relation.getName());
if (listenersByEqualValues == null) {
listenersByEqualValues = new ConcurrentSoftvaluesMultimap<String, RelatedFoundSet>();
ConcurrentSoftvaluesMultimap<String, RelatedFoundSet> prevValue = listenersByRelationEqualValues.putIfAbsent(relation.getName(), listenersByEqualValues);
if (prevValue != null)
listenersByEqualValues = prevValue;
}
listenersByEqualValues.add(createPKHashKey(eqArgs), relatedFoundSet);
listenersByEqualValuesAdded = true;
}
}
}
if (!listenersByEqualValuesAdded) {
listeners.put(fs, dummy);
}
}
use of com.servoy.j2db.FlattenedSolution in project servoy-client by Servoy.
the class DBValueList method getShowDataproviders.
public static List<String> getShowDataproviders(ValueList valueList, Table callingTable, String dataProviderID, IFoundSetManagerInternal foundSetManager) throws RepositoryException {
if (valueList == null) {
return null;
}
FlattenedSolution flattenedSolution = foundSetManager.getApplication().getFlattenedSolution();
// Find destination table in case dataProviderID is related
String[] split = dataProviderID.split("\\.");
String dataSource = callingTable.getDataSource();
for (// first parts are relation names, last part is column name
int i = 0; // first parts are relation names, last part is column name
i < split.length - 1; // first parts are relation names, last part is column name
i++) {
Relation relation = flattenedSolution.getRelation(split[i]);
if (relation == null || !relation.getPrimaryDataSource().equals(dataSource)) {
return null;
}
dataSource = relation.getForeignDataSource();
}
Table table = (Table) foundSetManager.getTable(dataSource);
String columnName = split[split.length - 1];
String prefix = dataProviderID.substring(0, dataProviderID.length() - columnName.length());
// first try fallback value list,
ValueList usedValueList = flattenedSolution.getValueList(valueList.getFallbackValueListID());
Relation valuelistSortRelation = flattenedSolution.getValuelistSortRelation(usedValueList, table, columnName, foundSetManager);
if (valuelistSortRelation == null) {
// then try regular value list
usedValueList = valueList;
valuelistSortRelation = flattenedSolution.getValuelistSortRelation(usedValueList, table, columnName, foundSetManager);
}
if (valuelistSortRelation == null) {
return null;
}
List<String> showDataproviders = new ArrayList<String>(3);
int showValues = usedValueList.getShowDataProviders();
if ((showValues & 1) != 0) {
showDataproviders.add(prefix + valuelistSortRelation.getName() + '.' + usedValueList.getDataProviderID1());
}
if ((showValues & 2) != 0) {
showDataproviders.add(prefix + valuelistSortRelation.getName() + '.' + usedValueList.getDataProviderID2());
}
if ((showValues & 4) != 0) {
showDataproviders.add(prefix + valuelistSortRelation.getName() + '.' + usedValueList.getDataProviderID3());
}
return showDataproviders;
}
Aggregations