From df9cf598972851d0ab9cf53bc576aefa1d5a2627 Mon Sep 17 00:00:00 2001 From: junkerm Date: Fri, 22 Feb 2019 17:35:27 +0100 Subject: [PATCH] Prepare Specmate version 0.2.14 (#398) * small fixes in run config und web config * fix run cofnig * fix run config * Fix/connection without target or source (#389) * Remormatting and cleanup * Restructuring and refactoring * Fixing bug where connections are not deleted * Fix/connection without target or source (#389) * Remormatting and cleanup * Restructuring and refactoring * Fixing bug where connections are not deleted * change config * change config * fix nullpointer exception when no hostandport parameter is given * version bump to 0.2.14 --- .../config/specmate-config.properties | 14 +-- .../internal/CDOPersistencyServiceConfig.java | 46 +++++----- .../services/service-interface.ts | 6 -- .../components/graphical-editor.component.ts | 40 ++++----- .../tool-pallette/util/graph-transformer.ts | 88 +++++++++---------- web/webpack/webpack.common.js | 2 +- 6 files changed, 93 insertions(+), 103 deletions(-) diff --git a/bundles/specmate-config/config/specmate-config.properties b/bundles/specmate-config/config/specmate-config.properties index 9eca59cd4..1d87cb957 100644 --- a/bundles/specmate-config/config/specmate-config.properties +++ b/bundles/specmate-config/config/specmate-config.properties @@ -55,13 +55,13 @@ search.maxResults = 100 ## Config for project jira -project.projects = jira -project.jira.connector.pid = com.specmate.connectors.jira.JiraConnector -project.jira.connector.jira.url = https://qualicen.atlassian.net -project.jira.connector.jira.project = SPEM -project.jira.connector.jira.username = maximilian.junker@qualicen.de -project.jira.connector.jira.password = H0v438bvkY5JE10ybLhW -project.jira.connector.connectorID = jira +#project.projects = jira +#project.jira.connector.pid = com.specmate.connectors.jira.JiraConnector +#project.jira.connector.jira.url = +#project.jira.connector.jira.project = SPEM +#project.jira.connector.jira.username = +#project.jira.connector.jira.password = +#project.jira.connector.connectorID = jira diff --git a/bundles/specmate-persistency-cdo/src/com/specmate/persistency/cdo/internal/CDOPersistencyServiceConfig.java b/bundles/specmate-persistency-cdo/src/com/specmate/persistency/cdo/internal/CDOPersistencyServiceConfig.java index b711086fd..50b92e386 100644 --- a/bundles/specmate-persistency-cdo/src/com/specmate/persistency/cdo/internal/CDOPersistencyServiceConfig.java +++ b/bundles/specmate-persistency-cdo/src/com/specmate/persistency/cdo/internal/CDOPersistencyServiceConfig.java @@ -55,14 +55,14 @@ public class CDOPersistencyServiceConfig { */ @Activate private void activate() throws SpecmateException { - this.specmateRepository = configService.getConfigurationProperty(KEY_REPOSITORY_NAME); - this.specmateResource = configService.getConfigurationProperty(KEY_RESOURCE_NAME); - this.cdoUser = configService.getConfigurationProperty(KEY_CDO_USER); - this.cdoPassword = configService.getConfigurationProperty(KEY_CDO_PASSWORD); - this.host = configService.getConfigurationProperty(KEY_SERVER_HOST_PORT); + this.specmateRepository = this.configService.getConfigurationProperty(KEY_REPOSITORY_NAME); + this.specmateResource = this.configService.getConfigurationProperty(KEY_RESOURCE_NAME); + this.cdoUser = this.configService.getConfigurationProperty(KEY_CDO_USER); + this.cdoPassword = this.configService.getConfigurationProperty(KEY_CDO_PASSWORD); + this.host = this.configService.getConfigurationProperty(KEY_SERVER_HOST_PORT); this.connected = false; String[] hostport = StringUtils.split(this.host, ":"); - if (!(hostport.length == 2)) { + if (hostport == null || !(hostport.length == 2)) { throw new SpecmateInternalException(ErrorCode.CONFIGURATION, "Invalid format for CDO host: " + this.host + ". The expected format is [hostName]:[port]"); } @@ -77,31 +77,32 @@ private void deactivate() { } /** - * Starts a thread that periodically checks if the CDO server is still reachable + * Starts a thread that periodically checks if the CDO server is still + * reachable */ private void startMonitoringThread() { this.checkConnectionEexcutor = Executors.newScheduledThreadPool(1); - checkConnectionEexcutor.scheduleWithFixedDelay(() -> { + this.checkConnectionEexcutor.scheduleWithFixedDelay(() -> { if (this.connected) { if (!checkConnection()) { try { removeConfiguration(); this.connected = false; - logService.log(LogService.LOG_WARNING, "Lost connection to CDO server."); + this.logService.log(LogService.LOG_WARNING, "Lost connection to CDO server."); } catch (SpecmateException e) { - logService.log(LogService.LOG_ERROR, "Could not stop persistency."); + this.logService.log(LogService.LOG_ERROR, "Could not stop persistency."); } } } else { if (checkConnection()) { try { - logService.log(LogService.LOG_INFO, "Connection to CDO server established."); + this.logService.log(LogService.LOG_INFO, "Connection to CDO server established."); registerConfiguration(); this.connected = true; } catch (SpecmateException e) { - logService.log(LogService.LOG_ERROR, "Could not restart persistency."); + this.logService.log(LogService.LOG_ERROR, "Could not restart persistency."); } } } @@ -112,22 +113,23 @@ private void startMonitoringThread() { private void registerConfiguration() throws SpecmateException { Dictionary properties = new Hashtable<>(); - if (!StringUtil.isEmpty(specmateRepository) && !StringUtil.isEmpty(specmateResource) - && !StringUtil.isEmpty(host) && !StringUtil.isEmpty(cdoUser) && !StringUtil.isEmpty(cdoPassword)) { - properties.put(KEY_REPOSITORY_NAME, specmateRepository); - properties.put(KEY_RESOURCE_NAME, specmateResource); - properties.put(KEY_SERVER_HOST_PORT, host); - properties.put(KEY_CDO_USER, cdoUser); - properties.put(KEY_CDO_PASSWORD, cdoPassword); - logService.log(LogService.LOG_DEBUG, + if (!StringUtil.isEmpty(this.specmateRepository) && !StringUtil.isEmpty(this.specmateResource) + && !StringUtil.isEmpty(this.host) && !StringUtil.isEmpty(this.cdoUser) + && !StringUtil.isEmpty(this.cdoPassword)) { + properties.put(KEY_REPOSITORY_NAME, this.specmateRepository); + properties.put(KEY_RESOURCE_NAME, this.specmateResource); + properties.put(KEY_SERVER_HOST_PORT, this.host); + properties.put(KEY_CDO_USER, this.cdoUser); + properties.put(KEY_CDO_PASSWORD, this.cdoPassword); + this.logService.log(LogService.LOG_DEBUG, "Configuring CDO with:\n" + OSGiUtil.configDictionaryToString(properties)); - this.configuration = OSGiUtil.configureService(configurationAdmin, PID, properties); + this.configuration = OSGiUtil.configureService(this.configurationAdmin, PID, properties); } } private void removeConfiguration() throws SpecmateException { try { - configuration.delete(); + this.configuration.delete(); } catch (IOException e) { throw new SpecmateInternalException(ErrorCode.CONFIGURATION, "Could not delete configuration."); } diff --git a/web/src/app/modules/data/modules/data-service/services/service-interface.ts b/web/src/app/modules/data/modules/data-service/services/service-interface.ts index 82324f6d2..aed2d6897 100644 --- a/web/src/app/modules/data/modules/data-service/services/service-interface.ts +++ b/web/src/app/modules/data/modules/data-service/services/service-interface.ts @@ -2,8 +2,6 @@ import { HttpClient, HttpParams, HttpHeaders, HttpErrorResponse } from '@angular import { Url } from '../../../../../util/url'; import { IContainer } from '../../../../../model/IContainer'; import { Objects } from '../../../../../util/objects'; -import { CEGConnection } from '../../../../../model/CEGConnection'; -import { Type } from '../../../../../util/type'; import 'rxjs/add/observable/of'; import { _throw } from 'rxjs/observable/throw'; import { UserToken } from '../../../../views/main/authentication/base/user-token'; @@ -131,10 +129,6 @@ export class ServiceInterface { let payload: any = Objects.clone(element); payload.url = undefined; delete payload.url; - if (Type.is(element, CEGConnection)) { - payload.source.___proxy = 'true'; - payload.target.___proxy = 'true'; - } if (!element.id) { payload['___proxy'] = 'true'; } diff --git a/web/src/app/modules/views/main/editors/modules/graphical-editor/components/graphical-editor.component.ts b/web/src/app/modules/views/main/editors/modules/graphical-editor/components/graphical-editor.component.ts index 7f433895e..5bdf7ae55 100644 --- a/web/src/app/modules/views/main/editors/modules/graphical-editor/components/graphical-editor.component.ts +++ b/web/src/app/modules/views/main/editors/modules/graphical-editor/components/graphical-editor.component.ts @@ -61,15 +61,13 @@ export class GraphicalEditor { constructor( private dataService: SpecmateDataService, - private modal: ConfirmationModal, protected editorToolsService: EditorToolsService, private selectedElementService: SelectedElementService, private validationService: ValidationService, - private viewController: ViewControllerService, private translate: TranslateService, public multiselectionService: MultiselectionService, private clipboardService: ClipboardService, - private renderer: Renderer ) { } + private renderer: Renderer) { } public get model(): IContainer { return this._model; @@ -156,13 +154,13 @@ export class GraphicalEditor { this.isGridShown = false; } - public get editorDimensions(): {width: number, height: number} { + public get editorDimensions(): { width: number, height: number } { let dynamicWidth: number = Config.GRAPHICAL_EDITOR_WIDTH; let dynamicHeight: number = Config.GRAPHICAL_EDITOR_HEIGHT; let nodes: ISpecmatePositionableModelObject[] = this.contents.filter((element: IContainer) => { return (element as ISpecmatePositionableModelObject).x !== undefined && - (element as ISpecmatePositionableModelObject).y !== undefined ; + (element as ISpecmatePositionableModelObject).y !== undefined; }) as ISpecmatePositionableModelObject[]; for (let i = 0; i < nodes.length; i++) { @@ -176,7 +174,7 @@ export class GraphicalEditor { dynamicHeight = nodeY; } } - return {width: dynamicWidth, height: dynamicHeight}; + return { width: dynamicWidth, height: dynamicHeight }; } public get gridSize(): number { @@ -199,8 +197,8 @@ export class GraphicalEditor { private isVisibleConnection(connection: IContainer): boolean { let nodes = this.nodes; - let start = nodes.find( node => node.url === (connection).source.url); - let end = nodes.find( node => node.url === (connection).target.url); + let start = nodes.find(node => node.url === (connection).source.url); + let end = nodes.find(node => node.url === (connection).target.url); if (!start || !end) { return false; } @@ -223,9 +221,9 @@ export class GraphicalEditor { * we sort the list so that all selected elements are drawn last (i.e. on top of the others). */ public get visibleConnections(): IContainer[] { - let selectedConnections = this.connections.filter( connection => this.isVisibleConnection(connection)); + let selectedConnections = this.connections.filter(connection => this.isVisibleConnection(connection)); // Sort the elements - selectedConnections.sort( (a: IContainer, b: IContainer) => this.isSelectedComparator(a, b)); + selectedConnections.sort((a: IContainer, b: IContainer) => this.isSelectedComparator(a, b)); return selectedConnections; } @@ -235,10 +233,10 @@ export class GraphicalEditor { * we sort the list so that all selected elements are drawn last (i.e. on top of the others). */ public get visibleNodes(): IContainer[] { - let visibleNodes = this.nodes.filter( node => Area.checkPointInArea(this.visibleArea, new Point( (node).x, (node).y))); + let visibleNodes = this.nodes.filter(node => Area.checkPointInArea(this.visibleArea, new Point((node).x, (node).y))); // Sort the elements - visibleNodes.sort( (a: IContainer, b: IContainer) => this.isSelectedComparator(a, b)); - return visibleNodes; + visibleNodes.sort((a: IContainer, b: IContainer) => this.isSelectedComparator(a, b)); + return this.nodes; } public get name(): string { @@ -261,18 +259,18 @@ export class GraphicalEditor { } public onScroll(event: UIEvent): void { - let target = event.target; + let target = event.target; this.setVisibleArea(target); } private setVisibleArea(target: any) { - let eWidth = this.editorDimensions.width; + let eWidth = this.editorDimensions.width; let eHeight = this.editorDimensions.height; - let xMin = eWidth * (target.scrollLeft / target.scrollWidth); - let xMax = xMin + (target.clientWidth / this.zoom); + let xMin = eWidth * (target.scrollLeft / target.scrollWidth); + let xMax = xMin + (target.clientWidth / this.zoom); let yMin = eHeight * (target.scrollTop / target.scrollHeight); - let yMax = yMin + (target.clientHeight / this.zoom); + let yMax = yMin + (target.clientHeight / this.zoom); xMin -= Config.GRAPHICAL_EDITOR_VISIBILITY_HORIZONTAL; yMin -= Config.GRAPHICAL_EDITOR_VISIBILITY_VERTICAL; @@ -282,7 +280,7 @@ export class GraphicalEditor { this.visibleArea = new Square(xMin, yMin, xMax, yMax); } - private checkAndReset(evt: MouseEvent|KeyboardEvent) { + private checkAndReset(evt: MouseEvent | KeyboardEvent) { if (this.editorToolsService.activeTool.done) { this.toolUseLock = evt.shiftKey; if (!this.toolUseLock && !this.editorToolsService.activeTool.sticky) { @@ -333,7 +331,7 @@ export class GraphicalEditor { private isDragDropTool(tool: ToolBase): boolean { let iTool = tool as IDragAndDropTool; let down = iTool.mouseDown !== undefined; - let up = iTool.mouseUp !== undefined; + let up = iTool.mouseUp !== undefined; let move = iTool.mouseDrag !== undefined; return down && up && move; } @@ -351,7 +349,7 @@ export class GraphicalEditor { private mousemove(evt: MouseEvent): void { // We only care about mousemovement when a button is pressed (i.e. drag & drop) - if (evt.buttons <= 0) { + if (evt.buttons <= 0) { return; } diff --git a/web/src/app/modules/views/main/editors/modules/tool-pallette/util/graph-transformer.ts b/web/src/app/modules/views/main/editors/modules/tool-pallette/util/graph-transformer.ts index 0d2920ca0..13dc7ca0b 100644 --- a/web/src/app/modules/views/main/editors/modules/tool-pallette/util/graph-transformer.ts +++ b/web/src/app/modules/views/main/editors/modules/tool-pallette/util/graph-transformer.ts @@ -45,60 +45,56 @@ export class GraphTransformer { } if (this.elementProvider.isNode(element)) { - return this.deleteNode(element as IModelNode, compoundId); + await this.deleteNode(element as IModelNode, compoundId); } else if (this.elementProvider.isConnection(element)) { - return this.deleteConnection(element as IModelConnection, compoundId); + await this.deleteConnection(element as IModelConnection, compoundId); } // Tried to delete element with type element.className. This type is not supported. } - public deleteElementAndDeselect(element: IContainer, compoundId: string): Promise { + public async deleteElementAndDeselect(element: IContainer, compoundId: string): Promise { if (this.selectionService !== undefined && this.selectionService !== null) { this.selectionService.deselectElement(element); } - return this.deleteElement(element, compoundId); + await this.deleteElement(element, compoundId); } - private deleteNode(node: IModelNode, compoundId: string): Promise { - return this.dataService.readContents(this.parent.url, true).then( (content: IContainer[]) => { - // Delete Connections - let chain = Promise.resolve(); - content.forEach(elem => { - if (this.elementProvider.isConnection(elem)) { - let currentConnection: IModelConnection = elem as IModelConnection; - if (currentConnection.source.url === node.url || currentConnection.target.url === node.url) { - chain = chain.then(() => this.deleteConnection(currentConnection, compoundId)); - } - } - }); - return chain; - }).then(() => this.dataService.deleteElement(node.url, true, compoundId)); + private async deleteNode(node: IModelNode, compoundId: string): Promise { + const contents: IContainer[] = await this.dataService.readContents(this.parent.url, true); + const connections = contents + .filter((element: IContainer) => this.elementProvider.isConnection(element)) + .map((element: IContainer) => element as IModelConnection) + .filter((connection: IModelConnection) => connection.source.url === node.url || connection.target.url === node.url); + for (let i = 0 ; i < connections.length; i++) { + await this.deleteConnection(connections[i], compoundId); + } + await this.dataService.deleteElement(node.url, true, compoundId); } - private deleteConnection(connection: IModelConnection, compoundId: string): Promise { - return this.removeConnectionFromSource(connection, compoundId) - .then(() => this.removeConnectionFromTarget(connection, compoundId)) - .then(() => this.dataService.deleteElement(connection.url, true, compoundId)); + private async deleteConnection(connection: IModelConnection, compoundId: string): Promise { + await this.removeConnectionFromSource(connection, compoundId); + await this.removeConnectionFromTarget(connection, compoundId); + await this.dataService.deleteElement(connection.url, true, compoundId); } - private removeConnectionFromSource(connection: IModelConnection, compoundId: string): Promise { - return this.dataService.readElement(connection.source.url, true) - .then((source: IModelNode) => { - let proxyToDelete: Proxy = source.outgoingConnections.find((proxy: Proxy) => proxy.url === connection.url); - Arrays.remove(source.outgoingConnections, proxyToDelete); - return source; - }) - .then((source: IContainer) => this.dataService.updateElement(source, true, compoundId)); + private async removeConnectionFromSource(connection: IModelConnection, compoundId: string): Promise { + const source = await this.dataService.readElement(connection.source.url, true) as IModelNode; + if (!source.outgoingConnections) { + return; + } + const proxy = source.outgoingConnections.find(proxy => proxy.url === connection.url); + Arrays.remove(source.outgoingConnections, proxy); + await this.dataService.updateElement(source, true, compoundId); } - private removeConnectionFromTarget(connection: IModelConnection, compoundId: string): Promise { - return this.dataService.readElement(connection.target.url, true) - .then((target: IModelNode) => { - let proxyToDelete: Proxy = target.incomingConnections.find((proxy: Proxy) => proxy.url === connection.url); - Arrays.remove(target.incomingConnections, proxyToDelete); - return target; - }) - .then((target: IContainer) => this.dataService.updateElement(target, true, compoundId)); + private async removeConnectionFromTarget(connection: IModelConnection, compoundId: string): Promise { + const target = await this.dataService.readElement(connection.target.url, true) as IModelNode; + if (!target.incomingConnections) { + return; + } + const proxy = target.incomingConnections.find(proxy => proxy.url === connection.url); + Arrays.remove(target.incomingConnections, proxy); + await this.dataService.updateElement(target, true, compoundId); } /** @@ -152,26 +148,26 @@ export class GraphTransformer { return Promise.resolve(out); } - private cloneNode(template: IModelNode, coords: Coords, compoundId: string, createNode: boolean): + private async cloneNode(template: IModelNode, coords: Coords, compoundId: string, createNode: boolean): Promise { if (!createNode) { - return Promise.resolve(Objects.clone(template)); + return Objects.clone(template); } let factory = GraphElementFactorySelector.getNodeFactory(template, coords, this.dataService); - return factory.create(this.parent, false, compoundId); + return await factory.create(this.parent, false, compoundId); } - private cloneEdge(template: IContainer, newSource: IModelNode, newTarget: IModelNode, compoundId: string, createEdge: boolean): + private async cloneEdge(template: IContainer, newSource: IModelNode, newTarget: IModelNode, compoundId: string, createEdge: boolean): Promise { if (!createEdge) { - return Promise.resolve(Objects.clone(template)); + return Objects.clone(template); } let factory = GraphElementFactorySelector.getConnectionFactory(template, newSource, newTarget, this.dataService); - return factory.create(this.parent, false, compoundId); + return await factory.create(this.parent, false, compoundId); } - private updateElement(element: IContainer, compoundId: string): Promise { - return this.dataService.updateElement(element, true, compoundId); + private async updateElement(element: IContainer, compoundId: string): Promise { + await this.dataService.updateElement(element, true, compoundId); } private transferData(from: IContainer, to: IContainer) { diff --git a/web/webpack/webpack.common.js b/web/webpack/webpack.common.js index 5f661fbd8..25ae5cbc2 100644 --- a/web/webpack/webpack.common.js +++ b/web/webpack/webpack.common.js @@ -1,4 +1,4 @@ -const SPECMATE_VERSION = '0.2.13' +const SPECMATE_VERSION = '0.2.14' const webpack = require('webpack'); const HtmlWebpackPlugin = require('html-webpack-plugin');