aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/main/java/com/vaadin/data/provider
diff options
context:
space:
mode:
authorIlia Motornyi <elmot@vaadin.com>2018-09-07 10:19:00 +0300
committerGitHub <noreply@github.com>2018-09-07 10:19:00 +0300
commit78c6a7fbfb31101bb1d8e1fa42685d187e1a1e81 (patch)
treed9658e176fcc3ca5c7a1f30d61a1f8a5a61d33f4 /server/src/main/java/com/vaadin/data/provider
parent78b1dc143983ddf25fae2cfda1c7705c2d40b2e4 (diff)
downloadvaadin-framework-78c6a7fbfb31101bb1d8e1fa42685d187e1a1e81.tar.gz
vaadin-framework-78c6a7fbfb31101bb1d8e1fa42685d187e1a1e81.zip
Remove objects from ActiveDataHandler that are no longer available in used DataProvider (#11167)
Remove objects from DataCommunicator.ActiveDataHandler that are no longer available in used DataProvider.
Diffstat (limited to 'server/src/main/java/com/vaadin/data/provider')
-rw-r--r--server/src/main/java/com/vaadin/data/provider/DataCommunicator.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/server/src/main/java/com/vaadin/data/provider/DataCommunicator.java b/server/src/main/java/com/vaadin/data/provider/DataCommunicator.java
index 5a99cacfb9..74818f9f42 100644
--- a/server/src/main/java/com/vaadin/data/provider/DataCommunicator.java
+++ b/server/src/main/java/com/vaadin/data/provider/DataCommunicator.java
@@ -140,6 +140,15 @@ public class DataCommunicator<T> extends AbstractExtension {
}
/**
+ * Marks all currently active data objects to be dropped.
+ *
+ * @since
+ */
+ public void dropAllActiveData() {
+ activeData.forEach(this::dropActiveData);
+ }
+
+ /**
* Marks a data object identified by given key string to be dropped.
*
* @param key
@@ -152,6 +161,19 @@ public class DataCommunicator<T> extends AbstractExtension {
}
/**
+ * Returns all dropped data mapped by their id from DataProvider.
+ *
+ * @return map of ids to dropped data objects
+ *
+ * @since
+ */
+ protected Map<Object, T> getDroppedData() {
+ Function<T, Object> getId = getDataProvider()::getId;
+ return droppedData.stream().map(getKeyMapper()::get)
+ .collect(Collectors.toMap(getId, i -> i));
+ }
+
+ /**
* Returns all currently active data mapped by their id from
* DataProvider.
*
@@ -329,6 +351,10 @@ public class DataCommunicator<T> extends AbstractExtension {
}
if (initial || reset) {
+ if (reset) {
+ handler.dropAllActiveData();
+ }
+
rpc.reset(getDataProviderSize());
}