Skip to content
Snippets Groups Projects
Commit 733a7b84 authored by Nils Christian Ehmke's avatar Nils Christian Ehmke
Browse files

Modified the interpretation of the displays.

parent cc65d9b3
No related branches found
No related tags found
No related merge requests found
...@@ -53,7 +53,6 @@ public class Analysis { ...@@ -53,7 +53,6 @@ public class Analysis {
private final Object analysisControllerThread; private final Object analysisControllerThread;
private final Map<String, Map<String, Object>> displayPlugins = new HashMap<String, Map<String, Object>>(); private final Map<String, Map<String, Object>> displayPlugins = new HashMap<String, Map<String, Object>>();
private final Map<String, Map<String, Object>> displayObjects = new HashMap<String, Map<String, Object>>();
private final Map<String, Map<String, Method>> displayMethods = new HashMap<String, Map<String, Method>>(); private final Map<String, Map<String, Method>> displayMethods = new HashMap<String, Map<String, Method>>();
/** /**
...@@ -112,14 +111,10 @@ public class Analysis { ...@@ -112,14 +111,10 @@ public class Analysis {
if (!this.displayMethods.containsKey(viewName)) { if (!this.displayMethods.containsKey(viewName)) {
this.displayMethods.put(viewName, new HashMap<String, Method>()); this.displayMethods.put(viewName, new HashMap<String, Method>());
} }
if (!this.displayObjects.containsKey(viewName)) {
this.displayObjects.put(viewName, new HashMap<String, Object>());
}
if (!this.displayPlugins.containsKey(viewName)) { if (!this.displayPlugins.containsKey(viewName)) {
this.displayPlugins.put(viewName, new HashMap<String, Object>()); this.displayPlugins.put(viewName, new HashMap<String, Object>());
} }
final Map<String, Method> methodMap = this.displayMethods.get(viewName); final Map<String, Method> methodMap = this.displayMethods.get(viewName);
final Map<String, Object> displayObjectMap = this.displayObjects.get(viewName);
final Map<String, Object> displayPluginMap = this.displayPlugins.get(viewName); final Map<String, Object> displayPluginMap = this.displayPlugins.get(viewName);
for (final Object displayConnector : displayConnectors) { for (final Object displayConnector : displayConnectors) {
...@@ -136,7 +131,6 @@ public class Analysis { ...@@ -136,7 +131,6 @@ public class Analysis {
final String potentialDisplayName = (String) new Mirror().on(displayAnnoation).invoke().method("name").withoutArgs(); final String potentialDisplayName = (String) new Mirror().on(displayAnnoation).invoke().method("name").withoutArgs();
if (displayName.equals(potentialDisplayName)) { if (displayName.equals(potentialDisplayName)) {
methodMap.put(displayConnectorName, method); methodMap.put(displayConnectorName, method);
displayObjectMap.put(displayConnectorName, method.getParameterTypes()[0].newInstance());
displayPluginMap.put(displayConnectorName, plugin); displayPluginMap.put(displayConnectorName, plugin);
break; break;
} }
...@@ -212,7 +206,10 @@ public class Analysis { ...@@ -212,7 +206,10 @@ public class Analysis {
* @return A display object for the given parameters. * @return A display object for the given parameters.
*/ */
public Object getDisplay(final String viewName, final String displayName) { public Object getDisplay(final String viewName, final String displayName) {
return this.displayObjects.get(viewName).get(displayName); final Object plugin = this.displayPlugins.get(viewName).get(displayName);
final Method method = this.displayMethods.get(viewName).get(displayName);
return new Mirror().on(plugin).invoke().method(method).withoutArgs();
} }
/** /**
...@@ -233,15 +230,17 @@ public class Analysis { ...@@ -233,15 +230,17 @@ public class Analysis {
* Updates the display objects within this analysis. * Updates the display objects within this analysis.
*/ */
public void updateDisplays() { public void updateDisplays() {
for (final String view : this.displayMethods.keySet()) { /*
for (final String display : this.displayMethods.get(view).keySet()) { * for (final String view : this.displayMethods.keySet()) {
final Object obj = this.displayObjects.get(view).get(display); * for (final String display : this.displayMethods.get(view).keySet()) {
final Method method = this.displayMethods.get(view).get(display); * final Object obj = this.displayObjects.get(view).get(display);
final Object plugin = this.displayPlugins.get(view).get(display); * final Method method = this.displayMethods.get(view).get(display);
* final Object plugin = this.displayPlugins.get(view).get(display);
new Mirror().on(plugin).invoke().method(method).withArgs(obj); *
} * new Mirror().on(plugin).invoke().method(method).withArgs(obj);
} * }
* }
*/
} }
/** /**
...@@ -255,18 +254,18 @@ public class Analysis { ...@@ -255,18 +254,18 @@ public class Analysis {
* @return The type of the display connector. * @return The type of the display connector.
*/ */
public DisplayType getDisplayType(final String viewName, final String displayConnectorName) { public DisplayType getDisplayType(final String viewName, final String displayConnectorName) {
final Object parameter = this.displayObjects.get(viewName).get(displayConnectorName); final Class<?> parameter = this.displayMethods.get(viewName).get(displayConnectorName).getReturnType();
if (parameter == null) { if (parameter == null) {
return null; return null;
} else if (parameter.getClass() == this.classContainer.getImageClass()) { } else if (parameter == this.classContainer.getImageClass()) {
return DisplayType.IMAGE; return DisplayType.IMAGE;
} else if (parameter.getClass() == this.classContainer.getPlainTextClass()) { } else if (parameter == this.classContainer.getPlainTextClass()) {
return DisplayType.PLAIN_TEXT; return DisplayType.PLAIN_TEXT;
} else if (parameter.getClass() == this.classContainer.getHtmlTextClass()) { } else if (parameter == this.classContainer.getHtmlTextClass()) {
return DisplayType.HTML_TEXT; return DisplayType.HTML_TEXT;
} else if (parameter.getClass() == this.classContainer.getXYPlotClass()) { } else if (parameter == this.classContainer.getXYPlotClass()) {
return DisplayType.XY_PLOT; return DisplayType.XY_PLOT;
} else if (parameter.getClass() == this.classContainer.getMeterGaugeClass()) { } else if (parameter == this.classContainer.getMeterGaugeClass()) {
return DisplayType.METER_GAUGE; return DisplayType.METER_GAUGE;
} else { } else {
return null; return null;
......
...@@ -19,6 +19,7 @@ package kieker.webgui.web.beans.view; ...@@ -19,6 +19,7 @@ package kieker.webgui.web.beans.view;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import javax.faces.application.Application; import javax.faces.application.Application;
import javax.faces.application.FacesMessage; import javax.faces.application.FacesMessage;
...@@ -464,8 +465,13 @@ public class CurrentCockpitBean { ...@@ -464,8 +465,13 @@ public class CurrentCockpitBean {
try { try {
final Object displayObj = this.projectService.getDisplay(this.projectName, this.activeView.getName(), displayConnectorName); final Object displayObj = this.projectService.getDisplay(this.projectName, this.activeView.getName(), displayConnectorName);
final List<Number> intervals = (List<Number>) new Mirror().on(displayObj).invoke().method("getIntervals").withoutArgs(); final Set<String> keys = (Set<String>) new Mirror().on(displayObj).invoke().method("getKeys").withoutArgs();
final Number value = (Number) new Mirror().on(displayObj).invoke().method("getValue").withoutArgs(); if (keys.isEmpty()) {
meterGaugeChartModel.setIntervals(Arrays.asList((Number) 50));
meterGaugeChartModel.setValue(0);
} else {
final List<Number> intervals = (List<Number>) new Mirror().on(displayObj).invoke().method("getIntervals").withArgs(keys.iterator().next());
final Number value = (Number) new Mirror().on(displayObj).invoke().method("getValue").withArgs(keys.iterator().next());
if (intervals.isEmpty()) { if (intervals.isEmpty()) {
meterGaugeChartModel.setIntervals(Arrays.asList((Number) 50)); meterGaugeChartModel.setIntervals(Arrays.asList((Number) 50));
...@@ -481,6 +487,7 @@ public class CurrentCockpitBean { ...@@ -481,6 +487,7 @@ public class CurrentCockpitBean {
meterGaugeChartModel.setValue(maxInterval); meterGaugeChartModel.setValue(maxInterval);
} }
} }
}
} catch (final DisplayNotFoundException ex) { } catch (final DisplayNotFoundException ex) {
CurrentCockpitBean.LOG.warn("Display not found.", ex); CurrentCockpitBean.LOG.warn("Display not found.", ex);
this.updateDisplayWithDefaultContent(component); this.updateDisplayWithDefaultContent(component);
...@@ -526,13 +533,19 @@ public class CurrentCockpitBean { ...@@ -526,13 +533,19 @@ public class CurrentCockpitBean {
try { try {
final Object displayObj = this.projectService.getDisplay(this.projectName, this.activeView.getName(), displayConnectorName); final Object displayObj = this.projectService.getDisplay(this.projectName, this.activeView.getName(), displayConnectorName);
final Map<Object, Number> entries = (Map<Object, Number>) new Mirror().on(displayObj).invoke().method("getEntries").withoutArgs(); final Set<String> keys = (Set<String>) new Mirror().on(displayObj).invoke().method("getKeys").withoutArgs();
if (keys.isEmpty()) {
lineChartSeries.set(0, 0);
} else {
final Map<Object, Number> entries = (Map<Object, Number>) new Mirror().on(displayObj).invoke().method("getEntries").withArgs(keys.iterator().next());
if (entries.isEmpty()) { if (entries.isEmpty()) {
lineChartSeries.set(0, 0); lineChartSeries.set(0, 0);
} else { } else {
lineChartSeries.setData(entries); lineChartSeries.setData(entries);
} }
}
} catch (final DisplayNotFoundException ex) { } catch (final DisplayNotFoundException ex) {
CurrentCockpitBean.LOG.warn("Display not found.", ex); CurrentCockpitBean.LOG.warn("Display not found.", ex);
this.updateDisplayWithDefaultContent(component); this.updateDisplayWithDefaultContent(component);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment