Skip to content
This repository has been archived by the owner on Mar 2, 2020. It is now read-only.

Commit

Permalink
Prepare Specmate version 0.2.14 (#398)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
junkerm authored Feb 22, 2019
1 parent df249bd commit 12273f0
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 103 deletions.
14 changes: 7 additions & 7 deletions bundles/specmate-config/config/specmate-config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [email protected]
project.jira.connector.jira.password = ***REMOVED***
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



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]");
}
Expand All @@ -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.");
}
}
}
Expand All @@ -112,22 +113,23 @@ private void startMonitoringThread() {

private void registerConfiguration() throws SpecmateException {
Dictionary<String, Object> 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.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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++) {
Expand All @@ -176,7 +174,7 @@ export class GraphicalEditor {
dynamicHeight = nodeY;
}
}
return {width: dynamicWidth, height: dynamicHeight};
return { width: dynamicWidth, height: dynamicHeight };
}

public get gridSize(): number {
Expand All @@ -199,8 +197,8 @@ export class GraphicalEditor {

private isVisibleConnection(connection: IContainer): boolean {
let nodes = this.nodes;
let start = <any>nodes.find( node => node.url === (<any>connection).source.url);
let end = <any>nodes.find( node => node.url === (<any>connection).target.url);
let start = <any>nodes.find(node => node.url === (<any>connection).source.url);
let end = <any>nodes.find(node => node.url === (<any>connection).target.url);
if (!start || !end) {
return false;
}
Expand All @@ -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;
}

Expand All @@ -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( (<any>node).x, (<any>node).y)));
let visibleNodes = this.nodes.filter(node => Area.checkPointInArea(this.visibleArea, new Point((<any>node).x, (<any>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 {
Expand All @@ -261,18 +259,18 @@ export class GraphicalEditor {
}

public onScroll(event: UIEvent): void {
let target = <any> event.target;
let target = <any>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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
public async deleteElementAndDeselect(element: IContainer, compoundId: string): Promise<void> {
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<void> {
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<void> {
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<void> {
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<void> {
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<void> {
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<void> {
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<void> {
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<void> {
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);
}

/**
Expand Down Expand Up @@ -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<ISpecmatePositionableModelObject> {
if (!createNode) {
return Promise.resolve(<ISpecmatePositionableModelObject>Objects.clone(template));
return <ISpecmatePositionableModelObject>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<IModelConnection> {
if (!createEdge) {
return Promise.resolve(<IModelConnection>Objects.clone(template));
return <IModelConnection>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<void> {
return this.dataService.updateElement(element, true, compoundId);
private async updateElement(element: IContainer, compoundId: string): Promise<void> {
await this.dataService.updateElement(element, true, compoundId);
}

private transferData(from: IContainer, to: IContainer) {
Expand Down
Loading

0 comments on commit 12273f0

Please sign in to comment.