From c5297a1dced8912c088cd92052fb9fd7edad0ffd Mon Sep 17 00:00:00 2001 From: Nils Christian Ehmke <nie@informatik.uni-kiel.de> Date: Sun, 9 Dec 2012 16:07:57 +0100 Subject: [PATCH] Code comments; Refactoring and code quality within the CurrentAnalysisEditorGraphBean; Solved a minor bug by escaping the names of the components --- .../service/impl/GraphLayoutServiceImpl.java | 11 + .../view/CurrentAnalysisEditorGraphBean.java | 298 ++++++++---------- .../webapp/WEB-INF/spring-database-config.xml | 1 + 3 files changed, 141 insertions(+), 169 deletions(-) diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/GraphLayoutServiceImpl.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/GraphLayoutServiceImpl.java index 49ea5c40..5c8e409b 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/GraphLayoutServiceImpl.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/GraphLayoutServiceImpl.java @@ -213,6 +213,13 @@ public final class GraphLayoutServiceImpl implements IGraphLayoutService { } } + /** + * This simple method "corrects" an array containing only an empty string. + * + * @param arr + * The array to be corrected. + * @return An corrected version of the array. + */ private static String[] correctEmptyArray(final String[] arr) { return ((arr.length == 1) && arr[0].isEmpty()) ? new String[0] : arr; } @@ -225,6 +232,10 @@ public final class GraphLayoutServiceImpl implements IGraphLayoutService { * @param edgesStr * The string containing the information about the edges. * @return An object containing the layout information for the graph. + * @throws UninitializedGraphException + * If the graph has not been initialized yet. + * @throws InvalidInputSizeException + * IF the input size of the graph is somehow invalid. */ private static LayoutInformation assembleLayoutInformation(final String nodesStr, final String edgesStr) throws UninitializedGraphException, InvalidInputSizeException { diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentAnalysisEditorGraphBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentAnalysisEditorGraphBean.java index 9bc11cda..84dc7506 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentAnalysisEditorGraphBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentAnalysisEditorGraphBean.java @@ -56,124 +56,68 @@ import org.eclipse.emf.ecore.EObject; @Component @Scope("view") public final class CurrentAnalysisEditorGraphBean { - /** - * This is the log for errors, exceptions etc. - */ + private static final Log LOG = LogFactory.getLog(CurrentAnalysisEditorGraphBean.class); - /** - * This is the javascript code to declare the visual graph variable. - */ - private static final String JS_CMD_CREATE_GRAPH_VAR = "var graph = GraphFlow();"; - /** - * This is the javascript code to add edge constraints to the graph. + + private static final String PARAM_NAME_ID = "ID"; + private static final String PARAM_NAME_NODES = "nodes"; + private static final String PARAM_NAME_EDGES = "edges"; + private static final String PARAM_NAME_TARGET_PORT_ID = "targetPortID"; + private static final String PARAM_NAME_SOURCE_PORT_ID = "sourcePortID"; + + /* + * The following are a lot of code fragments which are used for the interaction with the flow editor. For details look at the API description of the flow editor + * itself. */ + private static final String JS_CMD_CREATE_GRAPH_VAR = "var graph = GraphFlow()"; private static final String JS_CMD_ADD_EDGE_CONSTRAINTS = "graph.addEdgeConstraints()"; - /** - * This is the javasscript code to add the click listener to the graph. - */ - private static final String JS_CMD_ADD_CLICK_LISTENER = "graph.addListener(\"onClick\", nodeClickListener);"; - /** - * This is the javasscript code to add the remove node listener to the graph. - */ - private static final String JS_CMD_ADD_REMOVE_NODE_LISTENER = "graph.addListener('onRemoveNode', nodeRemoveListener);"; - /** - * This is the javasscript code to add the create edge listener to the graph. - */ - private static final String JS_CMD_ADD_CREATE_EDGE_LISTENER = "graph.addListener('onCreateEdge', edgeCreateListener);"; - /** - * This is the javasscript code to add the remove edge listener to the graph. - */ - private static final String JS_CMD_ADD_REMOVE_EDGE_LISTENER = "graph.addListener('onRemoveEdge', edgeRemoveListener);"; - private static final String JS_CMD_ADD_ERROR_LISTENER = "graph.addListener('onError', function(e){Log.write(e);});"; + private static final String JS_CMD_SET_FILTER_ICON = "graph.setNodeIcon('Filter', '../img/graphIcons/FilterIcon.png')"; + private static final String JS_CMD_SET_READER_ICON = "graph.setNodeIcon('Reader', '../img/graphIcons/ReaderIcon.png')"; + private static final String JS_CMD_SET_REPOSITORY_ICON = "graph.setNodeIcon('Repository', '../img/graphIcons/RepositoryIcon.png')"; + + private static final String JS_CMD_ADD_CLICK_NODE_LISTENER = "graph.addListener('onClick', nodeClickListener)"; + private static final String JS_CMD_ADD_REMOVE_NODE_LISTENER = "graph.addListener('onRemoveNode', nodeRemoveListener)"; + private static final String JS_CMD_ADD_CREATE_EDGE_LISTENER = "graph.addListener('onCreateEdge', edgeCreateListener)"; + private static final String JS_CMD_ADD_REMOVE_EDGE_LISTENER = "graph.addListener('onRemoveEdge', edgeRemoveListener)"; + private static final String JS_CMD_ADD_AUTO_LAYOUT_LISTENER = "graph.addListener('autoLayout', autoLayoutListener)"; + + private static final String JS_CMD_NODE = "{'id':'%s', 'name':'%s', 'nodeClass':'%s', 'tooltip':'%s'}"; + private static final String JS_CMD_PORT = "{'name':'%s','id':'%s', 'tooltip':'%s'}"; - private static final String JS_CMD_ADD_AUTO_LAYOUT_LISTENER = "graph.addListener('autoLayout', autoLayoutListener);"; - /** - * This is the javascript code for a node object. - */ - private static final String JS_CMD_NODE = "{\"id\":\"%s\", \"name\":\"%s\", \"nodeClass\":\"%s\", \"tooltip\":\"%s\"}"; - /** - * This is the javascript code for a port object. - */ - private static final String JS_CMD_PORT = "{\"name\":\"%s\",\"id\":\"%s\", \"tooltip\":\"%s\"}"; - /** - * This is the javascript type name for an input port. - */ private static final String JS_CMD_PORT_TYPE_INPUT = "inputPort"; - /** - * This is the javascript code to add a filter to the graph. - */ - private static final String JS_CMD_ADD_FILTER = "graph.addNode(%d, %d, %s,[%s],[%s],[%s],'Filter', false);"; - /** - * This is the javascript code to add a reader to the graph. - */ - private static final String JS_CMD_ADD_READER = "graph.addNode(%d, %d, %s,[%s],null,[%s], 'Reader', false);"; - /** - * This is the javascript code to add a repository to the graph. - */ - private static final String JS_CMD_ADD_REPOSITORY = "graph.addNode(%d, %d, %s, null, [%s], null, 'Repository',false);"; - /** - * This is the javascript code to add an edge to the graph. - */ - private static final String JS_CMD_ADD_EDGE = "graph.addEdge(\"%s\", \"%s\", \"%s\", false, false);"; - /** - * This is the javascript code to redraw the command. - */ - private static final String JS_CMD_REFRESH_GRAPH = "graph.refresh();"; - private static final String JS_CMD_START_AUTO_LAYOUT = "graph.autoLayout();"; - private static final String JS_CMD_LOAD_FROM_LAYOUT = "graph.loadPositionsFromLayout('%s');"; - /** - * This is the javascript code to rename a node within the graph. - */ - private static final String JS_CMD_RENAME_NODE = "graph.getNode('%s').name = '%s';"; - /** - * This is the javascript code to enable the grid within the graph. - */ - private static final String JS_CMD_ENABLE_GRID = "graph.setGridVisible(true, false);"; - /** - * This is the javascript code to disable the grid within the graph. - */ - private static final String JS_CMD_DISABLE_GRID = "graph.setGridVisible(false, false);"; - /** - * This is the javascript code to enable the grid snap within the graph. - */ - private static final String JS_CMD_ENABLE_SNAP = "graph.setGridSnap(true);"; - /** - * This is the javascript code to disable the grid snap within the graph. - */ - private static final String JS_CMD_DISABLE_SNAP = "graph.setGridSnap(false);"; - /** - * This is the javascript code to use the scale-to-fit-function. - */ - private static final String JS_CMD_SCALE_TO_FIT = "graph.scaleToFit();"; - /** - * This is the javascript code the set the color of the grid. - */ - private static final String JS_CMD_SET_GRID_COLOR = "graph.setGridColor('%s', false);"; - /** - * This is the javascript code the set the size of the grid. - */ - private static final String JS_CMD_SET_GRID_SIZE = "graph.setGridSize(%d, false);"; - /** - * This is the name of the (only) input port of every repository. - */ + private static final String JS_CMD_ADD_EDGE = "graph.addEdge('%s', '%s', '%s', false, false)"; + private static final String JS_CMD_ADD_FILTER = "graph.addNode(%d, %d, %s,[%s],[%s],[%s],'Filter', false)"; + private static final String JS_CMD_ADD_READER = "graph.addNode(%d, %d, %s,[%s],null,[%s], 'Reader', false)"; + private static final String JS_CMD_ADD_REPOSITORY = "graph.addNode(%d, %d, %s, null, [%s], null, 'Repository',false)"; + + private static final String JS_CMD_ENABLE_GRID = "graph.setGridVisible(true, false)"; + private static final String JS_CMD_DISABLE_GRID = "graph.setGridVisible(false, false)"; + private static final String JS_CMD_ENABLE_SNAP = "graph.setGridSnap(true)"; + private static final String JS_CMD_DISABLE_SNAP = "graph.setGridSnap(false)"; + private static final String JS_CMD_SET_GRID_COLOR = "graph.setGridColor('%s', false)"; + private static final String JS_CMD_SET_GRID_SIZE = "graph.setGridSize(%d, false)"; + private static final String JS_CMD_SET_READ_ONLY = "graph.setReadOnly(false, true)"; + private static final String JS_CMD_SCALE_TO_FIT = "graph.scaleToFit()"; + + private static final String JS_CMD_REFRESH_GRAPH = "graph.refresh()"; + private static final String JS_CMD_START_AUTO_LAYOUT = "graph.autoLayout()"; + private static final String JS_CMD_LOAD_FROM_LAYOUT = "graph.loadPositionsFromLayout('%s')"; + private static final String JS_CMD_RENAME_NODE = "graph.getNode('%s').name = '%s'"; + private static final Object REPOSITORY_INPUT_PORT = "R"; - private boolean gridEnabled = false; // NOPMD (The field IS accessed later) - private boolean snapEnabled = false; // NOPMD (The field IS accessed later) + private final Registry<EObject> componentMap = new Registry<EObject>(); + + private CurrentAnalysisEditorBean currentAnalysisEditorBean; + private boolean gridEnabled = false; + private boolean snapEnabled = false; @Autowired private IGraphLayoutService layouter; @Autowired private UserBean userBean; - /** - * This map contains all components (plugins, repositories and ports) within the graph to identify them with a unique ID. - */ - private final Registry<EObject> componentMap = new Registry<EObject>(); - - private CurrentAnalysisEditorBean currentAnalysisEditorBean; - /** * Creates a new instance of this class. <b>Do not call this constructor manually. It will only be accessed by Spring.</b> */ @@ -186,17 +130,17 @@ public final class CurrentAnalysisEditorGraphBean { */ public synchronized void declareGraph() { RequestContext.getCurrentInstance().execute(CurrentAnalysisEditorGraphBean.JS_CMD_CREATE_GRAPH_VAR); - RequestContext.getCurrentInstance().execute("graph.setNodeIcon('Filter', '../img/graphIcons/FilterIcon.png');"); - RequestContext.getCurrentInstance().execute("graph.setNodeIcon('Reader', '../img/graphIcons/ReaderIcon.png');"); - RequestContext.getCurrentInstance().execute("graph.setNodeIcon('Repository', '../img/graphIcons/RepositoryIcon.png');"); + + RequestContext.getCurrentInstance().execute(CurrentAnalysisEditorGraphBean.JS_CMD_SET_FILTER_ICON); + RequestContext.getCurrentInstance().execute(CurrentAnalysisEditorGraphBean.JS_CMD_SET_REPOSITORY_ICON); + RequestContext.getCurrentInstance().execute(CurrentAnalysisEditorGraphBean.JS_CMD_SET_READER_ICON); } /** * Initializes the listeners for the graph. */ public synchronized void initListeners() { - RequestContext.getCurrentInstance().execute(CurrentAnalysisEditorGraphBean.JS_CMD_ADD_CLICK_LISTENER); - RequestContext.getCurrentInstance().execute(CurrentAnalysisEditorGraphBean.JS_CMD_ADD_ERROR_LISTENER); + RequestContext.getCurrentInstance().execute(CurrentAnalysisEditorGraphBean.JS_CMD_ADD_CLICK_NODE_LISTENER); RequestContext.getCurrentInstance().execute(CurrentAnalysisEditorGraphBean.JS_CMD_ADD_AUTO_LAYOUT_LISTENER); RequestContext.getCurrentInstance().execute(CurrentAnalysisEditorGraphBean.JS_CMD_ADD_REMOVE_NODE_LISTENER); RequestContext.getCurrentInstance().execute(CurrentAnalysisEditorGraphBean.JS_CMD_ADD_CREATE_EDGE_LISTENER); @@ -218,8 +162,8 @@ public final class CurrentAnalysisEditorGraphBean { // Get the parameters final Map<String, String> paramMap = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap(); - final String nodes = paramMap.get("nodes"); - final String edges = paramMap.get("edges"); + final String nodes = paramMap.get(CurrentAnalysisEditorGraphBean.PARAM_NAME_NODES); + final String edges = paramMap.get(CurrentAnalysisEditorGraphBean.PARAM_NAME_EDGES); // Calculate the layout final String newLayout = this.layouter.layoutGraph(nodes, edges); @@ -282,8 +226,7 @@ public final class CurrentAnalysisEditorGraphBean { final String repoPort = String.format(CurrentAnalysisEditorGraphBean.JS_CMD_PORT, CurrentAnalysisEditorGraphBean.JS_CMD_PORT_TYPE_INPUT, CurrentAnalysisEditorGraphBean.REPOSITORY_INPUT_PORT, "N/A"); RequestContext.getCurrentInstance().execute(String.format(CurrentAnalysisEditorGraphBean.JS_CMD_ADD_REPOSITORY, 0, 0, - this.assembleGraphString(repository), - repoPort)); + this.assembleGraphString(repository), repoPort)); } /** @@ -326,7 +269,6 @@ public final class CurrentAnalysisEditorGraphBean { * @return A string containing the JS commands to create the ports. */ private synchronized String assembleGraphPortString(final EList<? extends MIPort> ports) { - final StringBuilder builder = new StringBuilder(); final int len = ports.size(); @@ -337,7 +279,8 @@ public final class CurrentAnalysisEditorGraphBean { builder.append(','); } - builder.append(String.format(CurrentAnalysisEditorGraphBean.JS_CMD_PORT, port.getName(), this.componentMap.get(port), port.getName())); + builder.append(String.format(CurrentAnalysisEditorGraphBean.JS_CMD_PORT, CurrentAnalysisEditorGraphBean.simpleEscape(port.getName()), + this.componentMap.get(port), CurrentAnalysisEditorGraphBean.simpleEscape(port.getName()))); } return builder.toString(); @@ -352,7 +295,6 @@ public final class CurrentAnalysisEditorGraphBean { * @return A string containing the JS commands to create the repository ports. */ private synchronized String assembleGraphRepositoryPortString(final EList<MIRepositoryConnector> ports) { - final StringBuilder builder = new StringBuilder(); final int len = ports.size(); @@ -363,7 +305,8 @@ public final class CurrentAnalysisEditorGraphBean { builder.append(','); } - builder.append(String.format(CurrentAnalysisEditorGraphBean.JS_CMD_PORT, port.getName(), this.componentMap.get(port), port.getName())); + builder.append(String.format(CurrentAnalysisEditorGraphBean.JS_CMD_PORT, CurrentAnalysisEditorGraphBean.simpleEscape(port.getName()), + this.componentMap.get(port), CurrentAnalysisEditorGraphBean.simpleEscape(port.getName()))); } return builder.toString(); @@ -429,29 +372,33 @@ public final class CurrentAnalysisEditorGraphBean { } /** - * Assembles a human-readable string of the given repository, which can also be used as a graph ID. + * Assembles a human-readable string of the given repository or plugin, which can also be used as a graph ID. * - * @param repository - * The repository whose ID should be delivered. + * @param component + * The component whose ID should be delivered. * @return A human readable ID. */ - private synchronized String assembleGraphString(final MIRepository repository) { - final String className = repository.getClassname(); - final String shortName = className.substring(className.lastIndexOf('.') + 1); - return String.format(CurrentAnalysisEditorGraphBean.JS_CMD_NODE, this.componentMap.get(repository), repository.getName(), shortName, className); - } + private synchronized String assembleGraphString(final EObject component) { + final String name; + final String className; + final String shortName; + + // Extract the names + if (component instanceof MIPlugin) { + className = ((MIPlugin) component).getClassname(); + name = ((MIPlugin) component).getName(); + } else if (component instanceof MIRepository) { + className = ((MIRepository) component).getClassname(); + name = ((MIRepository) component).getName(); + } else { + // This should not happen + return ""; + } + shortName = className.substring(className.lastIndexOf('.') + 1); - /** - * Assembles a human-readable string of the given plugin, which can also be used as a graph ID. - * - * @param plugin - * The plugin whose ID should be delivered. - * @return A human readable ID. - */ - private synchronized String assembleGraphString(final MIPlugin plugin) { - final String className = plugin.getClassname(); - final String shortName = className.substring(className.lastIndexOf('.') + 1); - return String.format(CurrentAnalysisEditorGraphBean.JS_CMD_NODE, this.componentMap.get(plugin), plugin.getName(), shortName, className); + return String.format(CurrentAnalysisEditorGraphBean.JS_CMD_NODE, this.componentMap.get(component), + CurrentAnalysisEditorGraphBean.simpleEscape(name), CurrentAnalysisEditorGraphBean.simpleEscape(shortName), + CurrentAnalysisEditorGraphBean.simpleEscape(className)); } /** @@ -461,7 +408,7 @@ public final class CurrentAnalysisEditorGraphBean { public synchronized void nodeClicked() { // Get the parameters final Map<String, String> paramMap = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap(); - final String clickedNodeID = paramMap.get("ID"); + final String clickedNodeID = paramMap.get(CurrentAnalysisEditorGraphBean.PARAM_NAME_ID); // Now search the correct node try { @@ -471,7 +418,7 @@ public final class CurrentAnalysisEditorGraphBean { } } catch (final NumberFormatException ex) { // Ignore an invalid ID, but log it. - CurrentAnalysisEditorGraphBean.LOG.warn("Invalid ID", ex); + CurrentAnalysisEditorGraphBean.LOG.info("Invalid ID", ex); } } @@ -482,7 +429,7 @@ public final class CurrentAnalysisEditorGraphBean { public synchronized void nodeRemoved() { // Get the parameters final Map<String, String> paramMap = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap(); - final String clickedNodeID = paramMap.get("ID"); + final String clickedNodeID = paramMap.get(CurrentAnalysisEditorGraphBean.PARAM_NAME_ID); // Now search the correct node try { final EObject selectedNode = this.componentMap.get(Integer.parseInt(clickedNodeID)); @@ -503,15 +450,15 @@ public final class CurrentAnalysisEditorGraphBean { // Get the parameters final Map<String, String> paramMap = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap(); - final String sourcePortID = paramMap.get("sourcePortID").split("\\.")[1]; - final String targetPortID = paramMap.get("targetPortID").split("\\.")[1]; + final String sourcePortID = paramMap.get(CurrentAnalysisEditorGraphBean.PARAM_NAME_SOURCE_PORT_ID).split("\\.")[1]; + final String targetPortID = paramMap.get(CurrentAnalysisEditorGraphBean.PARAM_NAME_TARGET_PORT_ID).split("\\.")[1]; // Now search the correct components try { final EObject sourcePort = this.componentMap.get(Integer.parseInt(sourcePortID)); if (CurrentAnalysisEditorGraphBean.REPOSITORY_INPUT_PORT.equals(targetPortID)) { // This is a special case: An edge between a filter and a repository - final String targetID = paramMap.get("targetPortID").split("\\.")[0]; + final String targetID = paramMap.get(CurrentAnalysisEditorGraphBean.PARAM_NAME_TARGET_PORT_ID).split("\\.")[0]; final EObject targetRepo = this.componentMap.get(Integer.parseInt(targetID)); if ((sourcePort instanceof MIRepositoryConnector) && (targetRepo instanceof MIRepository) && (this.currentAnalysisEditorBean != null)) { @@ -539,15 +486,15 @@ public final class CurrentAnalysisEditorGraphBean { // Get the parameters final Map<String, String> paramMap = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap(); - final String sourcePortID = paramMap.get("sourcePortID").split("\\.")[1]; - final String targetPortID = paramMap.get("targetPortID").split("\\.")[1]; + final String sourcePortID = paramMap.get(CurrentAnalysisEditorGraphBean.PARAM_NAME_SOURCE_PORT_ID).split("\\.")[1]; + final String targetPortID = paramMap.get(CurrentAnalysisEditorGraphBean.PARAM_NAME_TARGET_PORT_ID).split("\\.")[1]; // Now search the correct components try { final EObject sourcePort = this.componentMap.get(Integer.parseInt(sourcePortID)); if (CurrentAnalysisEditorGraphBean.REPOSITORY_INPUT_PORT.equals(targetPortID)) { // This is a special case: An edge between a filter and a repository - final String targetID = paramMap.get("targetPortID").split("\\.")[0]; + final String targetID = paramMap.get(CurrentAnalysisEditorGraphBean.PARAM_NAME_TARGET_PORT_ID).split("\\.")[0]; final EObject targetRepo = this.componentMap.get(Integer.parseInt(targetID)); if ((sourcePort instanceof MIRepositoryConnector) && (targetRepo instanceof MIRepository) && (this.currentAnalysisEditorBean != null)) { this.currentAnalysisEditorBean.edgeRemoved((MIRepositoryConnector) sourcePort, (MIRepository) targetRepo); @@ -605,7 +552,7 @@ public final class CurrentAnalysisEditorGraphBean { RequestContext.getCurrentInstance().execute(CurrentAnalysisEditorGraphBean.JS_CMD_ENABLE_GRID); } - this.gridEnabled ^= true; // this.gridEnabled = !this.gridEnabled; + this.gridEnabled = this.gridEnabled ^ true; // this.gridEnabled = !this.gridEnabled; } /** @@ -618,7 +565,42 @@ public final class CurrentAnalysisEditorGraphBean { RequestContext.getCurrentInstance().execute(CurrentAnalysisEditorGraphBean.JS_CMD_ENABLE_SNAP); } - this.snapEnabled ^= true; // this.snapEnabled = !this.snapEnabled; + this.snapEnabled = this.snapEnabled ^ true; // this.snapEnabled = !this.snapEnabled; + } + + /** + * Renames a given node and repaints the graph. + * + * @param node + * The node to rename. + * @param newName + * The new name of the node. + */ + public synchronized void renameNode(final EObject node, final String newName) { + final String cmd = String.format(CurrentAnalysisEditorGraphBean.JS_CMD_RENAME_NODE, this.componentMap.get(node), + CurrentAnalysisEditorGraphBean.simpleEscape(newName)); + RequestContext.getCurrentInstance().execute(cmd); + this.refreshGraph(); + } + + /** + * This method checks whether the current user is a guest and activates the read only mode if necessary. + */ + public synchronized void checkReadOnlyForGuests() { + if ("Guest".equals(this.userBean.getUserrole())) { + RequestContext.getCurrentInstance().execute(CurrentAnalysisEditorGraphBean.JS_CMD_SET_READ_ONLY); + } + } + + /** + * This method escapes the given string by removing the character ' from the string. This is necessary as the character could destroy the flow editor. + * + * @param str + * The string to be escaped. + * @return The escaped string. + */ + private static final String simpleEscape(final String str) { + return str.replaceAll("\'", ""); } /** @@ -649,26 +631,4 @@ public final class CurrentAnalysisEditorGraphBean { this.currentAnalysisEditorBean = currentAnalysisEditorBean; } - /** - * Renames a given node and repaints the graph. - * - * @param node - * The node to rename. - * @param newName - * The new name of the node. - */ - public synchronized void renameNode(final EObject node, final String newName) { - RequestContext.getCurrentInstance().execute(String.format(CurrentAnalysisEditorGraphBean.JS_CMD_RENAME_NODE, this.componentMap.get(node), newName)); - this.refreshGraph(); - } - - /** - * This method checks whether the current user is a guest and activates the read only mode if necessary. - */ - public void checkReadOnlyForGuests() { - if ("Guest".equals(this.userBean.getUserrole())) { - RequestContext.getCurrentInstance().execute("graph.setReadOnly('false', 'true');"); - } - } - } diff --git a/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-database-config.xml b/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-database-config.xml index 7eb459b5..1f0127a8 100644 --- a/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-database-config.xml +++ b/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-database-config.xml @@ -15,4 +15,5 @@ <jdbc:script location="classpath:sql/tables.sql"/> <jdbc:script location="classpath:sql/test-data.sql"/> </jdbc:initialize-database> + </beans> -- GitLab