Skip to content
This repository has been archived by the owner on Nov 22, 2019. It is now read-only.

Commit

Permalink
Fixes mvn build and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mdrillin committed Jul 12, 2018
1 parent 1e02165 commit 0d7c36d
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 53 deletions.
2 changes: 1 addition & 1 deletion ngapp/src/app/connections/shared/connection.service.ts
Expand Up @@ -32,7 +32,7 @@ import { VdbService } from "@dataservices/shared/vdb.service";
import { environment } from "@environments/environment";
import { Observable } from "rxjs/Observable";
import { Subscription } from "rxjs/Subscription";
import {VdbsConstants} from "@dataservices/shared/vdbs-constants";
import { VdbsConstants } from "@dataservices/shared/vdbs-constants";

@Injectable()
export class ConnectionService extends ApiService {
Expand Down
6 changes: 3 additions & 3 deletions ngapp/src/app/dataservices/shared/path-utils.ts
Expand Up @@ -27,7 +27,7 @@ export class PathUtils {

const arrayLength = fqnArray.length;
const connectionSegment = fqnArray[0];
let parts = connectionSegment.split("=", 2);
const parts = connectionSegment.split("=", 2);
const connName = parts[1];

return connName;
Expand All @@ -43,7 +43,7 @@ export class PathUtils {

const arrayLength = fqnArray.length;
const nodeSeqment = fqnArray[arrayLength - 1];
let parts = nodeSeqment.split("=", 2);
const parts = nodeSeqment.split("=", 2);
const nodeName = parts[1];

return nodeName;
Expand All @@ -59,7 +59,7 @@ export class PathUtils {

const arrayLength = fqnArray.length;
const nodeSeqment = fqnArray[arrayLength - 1];
let parts = nodeSeqment.split("=", 2);
const parts = nodeSeqment.split("=", 2);
const nodeType = parts[0];

return nodeType;
Expand Down
Expand Up @@ -15,17 +15,19 @@ describe( "Command Factory Tests", () => {
const path2 = "table=node2";
const node1 = SchemaNode.create( { connectionName: conn1, path: path1 } );
const node2 = SchemaNode.create( { connectionName: conn2, path: path2 } );
const tempCmd = CommandFactory.createAddSourcesCommand( [ node1, node2 ] );
const tempCmd = CommandFactory.createAddSourcesCommand( [ node1, node2 ], "ident" );
expect( tempCmd instanceof AddSourcesCommand ).toBe( true );

const cmd = tempCmd as AddSourcesCommand;
expect( cmd.id ).toBe( AddSourcesCommand.id );
expect( cmd.args ).not.toBeNull();
expect( cmd.args.size ).toBe( 1 );
expect( cmd.args.size ).toBe( 2 );

const expected = "connection=" + conn1 + "/" + path1 + ", connection=" + conn2 + "/" + path2;
expect( cmd.getArg( AddSourcesCommand.addedSourcePaths ) ).toEqual( expected );
expect( cmd.toString() ).toBe( "AddSourcesCommand, addedSourcePaths=" + expected );
const expectedSrcPaths = "connection=" + conn1 + "/" + path1 + ", connection=" + conn2 + "/" + path2;
const expectedFull = expectedSrcPaths + ", ObjectId=ident";
const actual = cmd.getArg( AddSourcesCommand.addedSourcePaths );
expect( cmd.getArg( AddSourcesCommand.addedSourcePaths ) ).toEqual( expectedSrcPaths );
expect( cmd.toString() ).toBe( "AddSourcesCommand, addedSourcePaths=" + expectedFull );
expect( cmd.isUndoable() ).toBe( true );

const json = cmd.toJSON();
Expand All @@ -41,7 +43,7 @@ describe( "Command Factory Tests", () => {
it("AddSourcesCommand Undo Test", () => {
const node1 = SchemaNode.create( { connectionName: "conn1", path: "table=node1" } );
const node2 = SchemaNode.create( { connectionName: "conn2", path: "table=node2" } );
const tempCmd = CommandFactory.createAddSourcesCommand( [ node1, node2 ] );
const tempCmd = CommandFactory.createAddSourcesCommand( [ node1, node2 ], "ident" );
expect( tempCmd instanceof AddSourcesCommand ).toBe( true );

const cmd = tempCmd as AddSourcesCommand;
Expand All @@ -51,7 +53,7 @@ describe( "Command Factory Tests", () => {
const undoCmd = tempUndoCmd as RemoveSourcesCommand;
expect( undoCmd ).not.toBeNull();
expect( undoCmd.id ).toBe( RemoveSourcesCommand.id );
expect( undoCmd.args.size ).toBe( 1 );
expect( undoCmd.args.size ).toBe( 2 );
expect( undoCmd.getArg( RemoveSourcesCommand.removedSourcePaths ) ).toEqual( cmd.getArg( AddSourcesCommand.addedSourcePaths ) );
});

Expand All @@ -77,17 +79,18 @@ describe( "Command Factory Tests", () => {
const path2 = "table=node2";
const node1 = SchemaNode.create( { connectionName: "conn1", path: path1 } );
const node2 = SchemaNode.create( { connectionName: "conn2", path: path2 } );
const temp = CommandFactory.createRemoveSourcesCommand( [ node1, node2 ] );
const temp = CommandFactory.createRemoveSourcesCommand( [ node1, node2 ], "ident" );
expect( temp instanceof RemoveSourcesCommand ).toBe( true );

const cmd = temp as RemoveSourcesCommand;
expect( cmd.id ).toBe( RemoveSourcesCommand.id );
expect( cmd.args ).not.toBeNull();
expect( cmd.args.size ).toBe( 1 );
expect( cmd.args.size ).toBe( 2 );

const expected = "connection=" + conn1 + "/" + path1 + ", connection=" + conn2 + "/" + path2;
expect( cmd.getArg( RemoveSourcesCommand.removedSourcePaths ) ).toEqual( expected );
expect( cmd.toString() ).toEqual( "RemoveSourcesCommand, removedSourcePaths=" + expected );
const expectedSrcPaths = "connection=" + conn1 + "/" + path1 + ", connection=" + conn2 + "/" + path2;
const expectedFull = expectedSrcPaths + ", ObjectId=ident";
expect( cmd.getArg( RemoveSourcesCommand.removedSourcePaths ) ).toEqual( expectedSrcPaths );
expect( cmd.toString() ).toEqual( "RemoveSourcesCommand, removedSourcePaths=" + expectedFull );
expect( cmd.isUndoable() ).toBe( true );

const json = cmd.toJSON();
Expand All @@ -103,7 +106,7 @@ describe( "Command Factory Tests", () => {
it("RemoveSourcesCommand Undo Test", () => {
const node1 = SchemaNode.create( { connectionName: "conn1", path: "table=node1" } );
const node2 = SchemaNode.create( { connectionName: "conn2", path: "table=node2" } );
const tempCmd = CommandFactory.createRemoveSourcesCommand( [ node1, node2 ] );
const tempCmd = CommandFactory.createRemoveSourcesCommand( [ node1, node2 ], "ident" );
expect( tempCmd instanceof RemoveSourcesCommand ).toBe( true );

const cmd = tempCmd as RemoveSourcesCommand;
Expand All @@ -113,7 +116,7 @@ describe( "Command Factory Tests", () => {
const undoCmd = tempUndoCmd as AddSourcesCommand;
expect( undoCmd ).not.toBeNull();
expect( undoCmd.id ).toBe( AddSourcesCommand.id );
expect( undoCmd.args.size ).toBe( 1 );
expect( undoCmd.args.size ).toBe( 2 );
expect( undoCmd.getArg( AddSourcesCommand.addedSourcePaths ) ).toEqual( cmd.getArg( RemoveSourcesCommand.removedSourcePaths ) );
});

Expand Down
Expand Up @@ -42,7 +42,6 @@ export abstract class Command {
*/
public static readonly idPropJson = "id";


/**
* The identifier used for the id argument
*/
Expand Down
Expand Up @@ -40,13 +40,15 @@ export class CanvasService {
* This service will provide methods to enable user interaction with elements
* while maintaining the d3 simulations physics
*/
constructor() {}
constructor() {
// Nothing to do
}

/**
* The interactable graph.
* This method does not interact with the document, purely physical calculations with d3
*/
public newCanvasGraph(options: { width, height }, changeDetectorRef: ChangeDetectorRef): CanvasGraph {
public newCanvasGraph(options: { width: number, height: number }, changeDetectorRef: ChangeDetectorRef): CanvasGraph {
this.viewReference = changeDetectorRef;

this.canvasGraph = new CanvasGraph(this, options);
Expand Down Expand Up @@ -123,14 +125,14 @@ export class CanvasService {
this.stopPropagation();
}

private removeNodeCallback(node: CanvasNode) {
let eventType = ViewCanvasEventType.DELETE_NODE;
private removeNodeCallback(node: CanvasNode): void {
const eventType = ViewCanvasEventType.DELETE_NODE;
const args = [];
//
// Send the decoded id so that it can be parsed
// and the source path extracted from it if required
//
args.push(node.decodedId)
args.push(node.decodedId);

const event = ViewCanvasEvent.create(eventType, args);
this.canvasEvent.emit(event);
Expand Down Expand Up @@ -226,7 +228,7 @@ export class CanvasService {

const selection = d3.select('#' + elementId);
if (selection)
return (<SVGGraphicsElement>selection.node()).getBBox();
return (selection.node() as SVGGraphicsElement).getBBox();

return null;
}
Expand All @@ -235,7 +237,7 @@ export class CanvasService {
* @returns the icon for the command type provided. If depressed then
* returns the depressed version of the icon
*/
public commandIcon(cmdType: string, depressed: boolean) {
public commandIcon(cmdType: string, depressed: boolean): string {
if (depressed)
return "/assets/iconfinder/Aha-soft/" + cmdType + "-depressed.png";

Expand All @@ -256,7 +258,7 @@ export class CanvasService {
/**
* Delete the node with the given id
*/
public deleteNode(nodeId: string, refresh?: boolean) {
public deleteNode(nodeId: string, refresh?: boolean): void {
if (! this.canvasGraph)
throw new Error("A canvas graph is required before removing a node");

Expand Down
Expand Up @@ -26,22 +26,21 @@ import * as _ from "lodash";
const FORCES = {
LINKS: 0.2,
COLLISION: 1
}
};

export class CanvasGraph {

private canvasService: CanvasService;
private options: any
private options: any;
private _nodes: CanvasNode[] = [];
private _links: CanvasLink[] = [];


public ticker: EventEmitter<cola.Layout> = new EventEmitter();
public nodesSelected: EventEmitter<CanvasNode[]> = new EventEmitter();

private layout: cola.Layout;

constructor(canvasService: CanvasService, options: { width, height }) {
constructor(canvasService: CanvasService, options: { width: number, height: number }) {
this.canvasService = canvasService;
this.options = options;

Expand Down Expand Up @@ -98,7 +97,6 @@ export class CanvasGraph {
.nodes(this.nodes)
.links(this.links);


// Connecting the d3 ticker to an angular event emitter
this.layout.on('tick', function() {
ticker.emit(this);
Expand All @@ -111,7 +109,7 @@ export class CanvasGraph {
* This will stop the layout and will require an update
* to be called after it.
*/
public setOptions(options: any) {
public setOptions(options: any): void {
this.options = options;
if (this.layout) {
this.layout.stop();
Expand All @@ -122,7 +120,7 @@ export class CanvasGraph {
/**
* Callback for conducting a (de)selection of nodes
*/
public selectionCallback(node: CanvasNode) {
public selectionCallback(node: CanvasNode): void {
const append = d3.event.shiftKey;

if (! node) {
Expand Down Expand Up @@ -164,7 +162,7 @@ export class CanvasGraph {
/**
* @returns the collection of nodes
*/
public get nodes() {
public get nodes(): CanvasNode[] {
return this._nodes;
}

Expand Down Expand Up @@ -273,7 +271,7 @@ export class CanvasGraph {
this.canvasService.update(true);
}

public get links() {
public get links(): CanvasLink[] {
return this._links;
}

Expand Down
Expand Up @@ -30,11 +30,11 @@ export class CanvasNode implements cola.Node {
fx?: number | null;
fy?: number | null;

private _id: string;
private _type: string;
private readonly _id: string;
private readonly _type: string;
private _label: string;
private _selected: boolean = false;
private _root: boolean = false;
private _selected = false;
private _root = false;

public static encodeId(id: string): string {
return btoa(id);
Expand Down
Expand Up @@ -21,6 +21,8 @@ import { MockVdbService } from "@dataservices/shared/mock-vdb.service";
import { NotifierService } from "@dataservices/shared/notifier.service";
import { ViewPropertyEditorsComponent } from "@dataservices/virtualization/view-editor/view-property-editors/view-property-editors.component";
import { TabsModule } from "ngx-bootstrap";
import { GraphVisualComponent, LinkVisualComponent, NodeVisualComponent } from "@dataservices/virtualization/view-editor/view-canvas/visuals";
import { CanvasService } from "@dataservices/virtualization/view-editor/view-canvas/canvas.service";

describe('ViewCanvasComponent', () => {
let component: ViewCanvasComponent;
Expand All @@ -42,12 +44,16 @@ describe('ViewCanvasComponent', () => {
TabsModule.forRoot()
],
declarations: [
GraphVisualComponent,
LinkVisualComponent,
NodeVisualComponent,
SelectedNodeComponent,
ViewCanvasComponent,
ViewPropertyEditorsComponent
],
providers: [
{ provide: AppSettingsService, useClass: MockAppSettingsService },
CanvasService,
LoggerService,
NotifierService,
{ provide: VdbService, useClass: MockVdbService },
Expand Down
Expand Up @@ -80,7 +80,7 @@ export class ViewCanvasComponent implements OnInit, AfterViewInit, OnDestroy {
const srcPaths = cmd.getSourcePaths();
for (let i = 0; i < srcPaths.length; ++i) {
const srcPath = srcPaths[i];
const update = (i == (srcPaths.length - 1));
const update = (i === (srcPaths.length - 1));
const id = cmd.getId(srcPath);
this.canvasService.createNode(id, CanvasConstants.SOURCE_TYPE, srcPath, update);
}
Expand All @@ -89,7 +89,7 @@ export class ViewCanvasComponent implements OnInit, AfterViewInit, OnDestroy {
const srcPaths = cmd.getSourcePaths();
for (let i = 0; i < srcPaths.length; ++i) {
const srcPath = srcPaths[i];
const update = (i == (srcPaths.length - 1));
const update = (i === (srcPaths.length - 1));
const id = cmd.getId(srcPath);
this.canvasService.deleteNode(id, update);
}
Expand Down Expand Up @@ -188,7 +188,7 @@ export class ViewCanvasComponent implements OnInit, AfterViewInit, OnDestroy {
this.canvasSubscription = this.canvasService.canvasEvent.subscribe((event) => this.handleCanvasEvent(event));
}

public ngAfterViewInit() {
public ngAfterViewInit(): void {
// const labels:string[] = ['Employee', 'Admin', 'Payroll', 'EmployeeAdmin', 'EmployeePayDay'];
// const type:string[] = [
// CanvasConstants.SOURCE_TYPE,
Expand Down Expand Up @@ -216,7 +216,7 @@ export class ViewCanvasComponent implements OnInit, AfterViewInit, OnDestroy {
return;
}

for (let node of nodes) {
for (const node of nodes) {
console.log("Node " + node.label + " selected");
}
});
Expand Down
Expand Up @@ -75,31 +75,37 @@ import * as _ from "lodash";
export class GraphVisualComponent implements OnInit {

public canvasGraph: CanvasGraph;
private _options: { width, height } = { width: 800, height: 600 };
public _options: { width: number, height: number } = { width: 800, height: 600 };

private canvasService: CanvasService;
private ref: ChangeDetectorRef;

@HostListener('window:resize', ['$event'])
onResize(event) {
public onResize(event): void {
this.canvasService.update(true, this.options);
}

constructor(private canvasService: CanvasService, private ref: ChangeDetectorRef) {}
constructor(canvasService: CanvasService, ref: ChangeDetectorRef) {
this.canvasService = canvasService;
this.ref = ref;
}

public get nodes() {
public get nodes(): CanvasNode[] {
return this.canvasService.nodes();
}

public get links() {
public get links(): CanvasLink[] {
return this.canvasService.links();
}

public ngOnInit() {
public ngOnInit(): void {
console.log("graph-visual: ngOnInit");

/** Receiving an initialized simulated graph from our custom canvas.service */
this.canvasGraph = this.canvasService.newCanvasGraph(this.options, this.ref);
}

public get options() {
public get options(): any {
return this._options = {
width: window.innerWidth,
height: window.innerHeight
Expand Down

0 comments on commit 0d7c36d

Please sign in to comment.