diff --git a/pom.xml b/pom.xml
index e5c3a9a5..ff5a2b36 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
es.ubu.lsi
ubumonitor
- 2.10.5
+ 2.10.6
diff --git a/src/main/java/es/ubu/lsi/ubumonitor/AppInfo.java b/src/main/java/es/ubu/lsi/ubumonitor/AppInfo.java
index b29cba3f..9b263ea9 100644
--- a/src/main/java/es/ubu/lsi/ubumonitor/AppInfo.java
+++ b/src/main/java/es/ubu/lsi/ubumonitor/AppInfo.java
@@ -10,7 +10,7 @@
public class AppInfo {
- public static final String VERSION = "2.10.5";
+ public static final String VERSION = "2.10.6";
public static final String APPLICATION_VERSION = "v" + VERSION;
diff --git a/src/main/java/es/ubu/lsi/ubumonitor/clustering/chart/Scatter2DChart.java b/src/main/java/es/ubu/lsi/ubumonitor/clustering/chart/Scatter2DChart.java
index e1b30fa7..2f654212 100644
--- a/src/main/java/es/ubu/lsi/ubumonitor/clustering/chart/Scatter2DChart.java
+++ b/src/main/java/es/ubu/lsi/ubumonitor/clustering/chart/Scatter2DChart.java
@@ -62,53 +62,58 @@ public Scatter2DChart(PartitionalClusteringController clusteringController) {
*/
@Override
public void updateChart(List clusters) {
- connector.setClusters(clusters);
- LOGGER.debug("Clusters: {}", clusters);
- points = AlgorithmExecuter.clustersTo(2, clusters);
-
- Map colors = UtilMethods.getRandomColors(clusters);
-
- JSObject root = new JSObject();
- JSArray datasets = new JSArray();
- JSObject centers = new JSObject();
- centers.putWithQuote("label", I18n.get("clustering.centroids"));
- centers.putWithQuote("backgroundColor", "black");
- JSArray centersData = new JSArray();
-
- int total = clusters.stream().mapToInt(ClusterWrapper::size).sum();
-
- for (int i = 0; i < points.size(); i++) {
- JSObject group = new JSObject();
- group.putWithQuote("label", getLegend(clusters.get(i), total));
- group.put("backgroundColor", UtilMethods.colorToRGB(colors.get(clusters.get(i))));
- JSArray data = new JSArray();
- for (Map.Entry userEntry : points.get(i).entrySet()) {
- UserData user = userEntry.getKey();
- JSObject coord = new JSObject();
- double[] point = userEntry.getValue();
- coord.put("x", point[0]);
- coord.put("y", point.length == 2 ? point[1] : 0.0);
-
- if (user == null) {
- coord.putWithQuote("user", I18n.get("clustering.centroid"));
- centersData.add(coord);
- } else {
- coord.putWithQuote("user", user.getEnrolledUser().getFullName());
- data.add(coord);
+ try { // FIX #137 catch exception generating an empty dataset
+ connector.setClusters(clusters);
+ LOGGER.debug("Clusters: {}", clusters);
+ points = AlgorithmExecuter.clustersTo(2, clusters);
+
+ Map colors = UtilMethods.getRandomColors(clusters);
+
+ JSObject root = new JSObject();
+ JSArray datasets = new JSArray();
+ JSObject centers = new JSObject();
+ centers.putWithQuote("label", I18n.get("clustering.centroids"));
+ centers.putWithQuote("backgroundColor", "black");
+ JSArray centersData = new JSArray();
+
+ int total = clusters.stream().mapToInt(ClusterWrapper::size).sum();
+
+ for (int i = 0; i < points.size(); i++) {
+ JSObject group = new JSObject();
+ group.putWithQuote("label", getLegend(clusters.get(i), total));
+ group.put("backgroundColor", UtilMethods.colorToRGB(colors.get(clusters.get(i))));
+ JSArray data = new JSArray();
+ for (Map.Entry userEntry : points.get(i).entrySet()) {
+ UserData user = userEntry.getKey();
+ JSObject coord = new JSObject();
+ double[] point = userEntry.getValue();
+ coord.put("x", point[0]);
+ coord.put("y", point.length == 2 ? point[1] : 0.0);
+
+ if (user == null) {
+ coord.putWithQuote("user", I18n.get("clustering.centroid"));
+ centersData.add(coord);
+ } else {
+ coord.putWithQuote("user", user.getEnrolledUser().getFullName());
+ data.add(coord);
+ }
}
+ group.put("data", data);
+ datasets.add(group);
}
- group.put("data", data);
- datasets.add(group);
- }
- if (!centersData.isEmpty()) {
- centers.put("data", centersData);
- datasets.add(centers);
- }
- root.put("datasets", datasets);
- LOGGER.debug("2D series: {}", root);
+ if (!centersData.isEmpty()) {
+ centers.put("data", centersData);
+ datasets.add(centers);
+ }
+ root.put("datasets", datasets);
+ LOGGER.debug("2D series: {}", root);
- getWebEngine().executeScript("updateChart(" + root + ")");
+ getWebEngine().executeScript("updateChart(" + root + ")");
+ } catch (Exception e) {
+ LOGGER.error("Error updating chart", e);
+ getWebEngine().executeScript("updateChart({\"datasets\":[]})");
+ }
}
/**
diff --git a/src/main/java/es/ubu/lsi/ubumonitor/clustering/chart/Scatter3DChart.java b/src/main/java/es/ubu/lsi/ubumonitor/clustering/chart/Scatter3DChart.java
index 8d74e095..082a46b2 100644
--- a/src/main/java/es/ubu/lsi/ubumonitor/clustering/chart/Scatter3DChart.java
+++ b/src/main/java/es/ubu/lsi/ubumonitor/clustering/chart/Scatter3DChart.java
@@ -41,29 +41,34 @@ public Scatter3DChart(PartitionalClusteringController controller) {
*/
@Override
public void updateChart(List clusters) {
- points = AlgorithmExecuter.clustersTo(3, clusters);
+ try { // FIX #137 catch exception generating an empty dataset
+ points = AlgorithmExecuter.clustersTo(3, clusters);
- JSArray series = new JSArray();
- int total = clusters.stream().mapToInt(ClusterWrapper::size).sum();
- for (int i = 0; i < clusters.size(); i++) {
- ClusterWrapper cluster = clusters.get(i);
- JSObject serie = new JSObject();
- serie.putWithQuote("name", getLegend(cluster, total));
- JSArray data = new JSArray();
- for (Entry entry : points.get(i).entrySet()) {
- double[] value = entry.getValue();
- JSArray point = new JSArray();
- point.add(value[0]);
- point.add(value.length > 1 ? value[1] : 0.0);
- point.add(value.length > 2 ? value[2] : 0.0);
- data.add(point);
+ JSArray series = new JSArray();
+ int total = clusters.stream().mapToInt(ClusterWrapper::size).sum();
+ for (int i = 0; i < clusters.size(); i++) {
+ ClusterWrapper cluster = clusters.get(i);
+ JSObject serie = new JSObject();
+ serie.putWithQuote("name", getLegend(cluster, total));
+ JSArray data = new JSArray();
+ for (Entry entry : points.get(i).entrySet()) {
+ double[] value = entry.getValue();
+ JSArray point = new JSArray();
+ point.add(value[0]);
+ point.add(value.length > 1 ? value[1] : 0.0);
+ point.add(value.length > 2 ? value[2] : 0.0);
+ data.add(point);
+ }
+ serie.put("data", data);
+ series.add(serie);
}
- serie.put("data", data);
- series.add(serie);
- }
- LOGGER.debug("3D series: {}", series);
- getWebEngine().executeScript("updateChart(" + series + ")");
+ LOGGER.debug("3D series: {}", series);
+ getWebEngine().executeScript("updateChart(" + series + ")");
+ } catch (Exception e) {
+ LOGGER.error("Error updating chart 3D", e);
+ getWebEngine().executeScript("updateChart()");
+ }
}
/**
diff --git a/src/main/java/es/ubu/lsi/ubumonitor/clustering/controller/AlgorithmExecuter.java b/src/main/java/es/ubu/lsi/ubumonitor/clustering/controller/AlgorithmExecuter.java
index 66ad9dcc..abb71b3a 100644
--- a/src/main/java/es/ubu/lsi/ubumonitor/clustering/controller/AlgorithmExecuter.java
+++ b/src/main/java/es/ubu/lsi/ubumonitor/clustering/controller/AlgorithmExecuter.java
@@ -193,7 +193,7 @@ public static List