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

Commit

Permalink
Fix issue with view creation
Browse files Browse the repository at this point in the history
  • Loading branch information
mdrillin committed Jun 28, 2018
1 parent 5407b29 commit 25c2c6c
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 40 deletions.
4 changes: 4 additions & 0 deletions ngapp/src/app/connections/shared/schema-node.model.ts
Expand Up @@ -74,6 +74,8 @@ export class SchemaNode {
}

/**
* Get the path, for example: ( schema=public/table=customer ). It is assumed that the path here does NOT include
* the connection.
* @returns {string} the node path
*/
public getPath(): string {
Expand Down Expand Up @@ -102,6 +104,8 @@ export class SchemaNode {
}

/**
* Set the path, for example: ( schema=public/table=customer ). It is assumed that the path here does NOT include
* the connection.
* @param {string} path the node path
*/
public setPath( path?: string ): void {
Expand Down
Expand Up @@ -60,7 +60,8 @@ export class AddSourcesCommand extends Command {
arg += AddSourcesCommand.delim;
}

arg += source.getPath();
// Prepend the connection to the schema node path
arg += "connection=" + source.getConnectionName() + "/" + source.getPath();
} );
}

Expand Down
Expand Up @@ -9,10 +9,12 @@ import { UpdateViewDescriptionCommand } from "@dataservices/virtualization/view-
describe( "Command Factory Tests", () => {

it("AddSourcesCommand Test", () => {
const path1 = "connection=conn1/table=node1";
const path2 = "connection=conn2/table=node2";
const node1 = SchemaNode.create( { path: path1 } );
const node2 = SchemaNode.create( { path: path2 } );
const conn1 = "conn1";
const conn2 = "conn2";
const path1 = "table=node1";
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 ] );
expect( tempCmd instanceof AddSourcesCommand ).toBe( true );

Expand All @@ -21,7 +23,7 @@ describe( "Command Factory Tests", () => {
expect( cmd.args ).not.toBeNull();
expect( cmd.args.size ).toBe( 1 );

const expected = path1 + ", " + path2;
const expected = "connection=" + conn1 + "/" + path1 + ", connection=" + conn2 + "/" + path2;
expect( cmd.getArg( AddSourcesCommand.addedSourcePaths ) ).toEqual( expected );
expect( cmd.toString() ).toBe( "AddSourcesCommand, addedSourcePaths=" + expected );
expect( cmd.isUndoable() ).toBe( true );
Expand All @@ -37,8 +39,8 @@ describe( "Command Factory Tests", () => {
});

it("AddSourcesCommand Undo Test", () => {
const node1 = SchemaNode.create( { path: "connection=conn1/table=node1" } );
const node2 = SchemaNode.create( { path: "connection=conn2/table=node2" } );
const node1 = SchemaNode.create( { connectionName: "conn1", path: "table=node1" } );
const node2 = SchemaNode.create( { connectionName: "conn2", path: "table=node2" } );
const tempCmd = CommandFactory.createAddSourcesCommand( [ node1, node2 ] );
expect( tempCmd instanceof AddSourcesCommand ).toBe( true );

Expand Down Expand Up @@ -69,10 +71,12 @@ describe( "Command Factory Tests", () => {
});

it("RemoveSourcesCommand Test", () => {
const path1 = "connection=conn1/table=node1";
const path2 = "connection=conn2/table=node2";
const node1 = SchemaNode.create( { path: path1 } );
const node2 = SchemaNode.create( { path: path2 } );
const conn1 = "conn1";
const conn2 = "conn2";
const path1 = "table=node1";
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 ] );
expect( temp instanceof RemoveSourcesCommand ).toBe( true );

Expand All @@ -81,7 +85,7 @@ describe( "Command Factory Tests", () => {
expect( cmd.args ).not.toBeNull();
expect( cmd.args.size ).toBe( 1 );

const expected = path1 + ", " + path2;
const expected = "connection=" + conn1 + "/" + path1 + ", connection=" + conn2 + "/" + path2;
expect( cmd.getArg( RemoveSourcesCommand.removedSourcePaths ) ).toEqual( expected );
expect( cmd.toString() ).toEqual( "RemoveSourcesCommand, removedSourcePaths=" + expected );
expect( cmd.isUndoable() ).toBe( true );
Expand All @@ -97,8 +101,8 @@ describe( "Command Factory Tests", () => {
});

it("RemoveSourcesCommand Undo Test", () => {
const node1 = SchemaNode.create( { path: "connection=conn1/table=node1" } );
const node2 = SchemaNode.create( { path: "connection=conn2/table=node2" } );
const node1 = SchemaNode.create( { connectionName: "conn1", path: "table=node1" } );
const node2 = SchemaNode.create( { connectionName: "conn2", path: "table=node2" } );
const tempCmd = CommandFactory.createRemoveSourcesCommand( [ node1, node2 ] );
expect( tempCmd instanceof RemoveSourcesCommand ).toBe( true );

Expand Down
Expand Up @@ -60,7 +60,8 @@ export class RemoveSourcesCommand extends Command {
arg += ", ";
}

arg += source.getPath();
// Prepend the connection to the schema node path
arg += "connection=" + source.getConnectionName() + "/" + source.getPath();
} );
}

Expand Down
Expand Up @@ -133,10 +133,18 @@ export class ViewCanvasComponent implements OnInit, OnDestroy {
const sourcePaths = view.getSourcePaths();
for (const sourcePath of sourcePaths) {
const sNode = new SchemaNode();
sNode.setPath(sourcePath);
const connName = PathUtils.getConnectionName(sourcePath);
// If path contains connection - remove it for setting SchemaNode path
if (connName && connName !== null && connName.length > 0) {
const sPath = sourcePath.substring(sourcePath.indexOf("/") + 1);
sNode.setConnectionName(connName);
sNode.setPath(sPath);
} else {
sNode.setConnectionName(null);
sNode.setPath(sourcePath);
}
sNode.setName(PathUtils.getSourceName(sourcePath));
sNode.setType(PathUtils.getSourceType(sourcePath));
sNode.setConnectionName(PathUtils.getConnectionName(sourcePath));
schemaNodes.push(sNode);
}
return schemaNodes;
Expand Down
Expand Up @@ -446,28 +446,6 @@ export class VirtualizationComponent implements OnInit {
// );
}

// private getSourceNode(nodeFqn: string): SchemaNode {
//
// const fqnArray = nodeFqn.split("/", 10);
//
// const arrayLength = fqnArray.length;
// const connectionSegment = fqnArray[0];
// let parts = connectionSegment.split("=", 2);
// const connName = parts[1];
//
// const nodeSeqment = fqnArray[arrayLength - 1];
// parts = nodeSeqment.split("=", 2);
// const nodeName = parts[1];
// const nodeType = parts[0];
//
// const schemaNode = new SchemaNode();
// schemaNode.setConnectionName(connName);
// schemaNode.setName(nodeName);
// schemaNode.setType(nodeType);
//
// return schemaNode;
// }

/*
* Set the editable state of all views.
* @param {boolean} isEditable the editable state
Expand Down

0 comments on commit 25c2c6c

Please sign in to comment.