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

Commit

Permalink
adds path to schemaNodes
Browse files Browse the repository at this point in the history
  • Loading branch information
mdrillin committed Jun 25, 2018
1 parent 4ed77de commit 64aa36b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
22 changes: 22 additions & 0 deletions ngapp/src/app/connections/shared/schema-node.model.spec.ts
Expand Up @@ -13,6 +13,7 @@ describe("SchemaNode", () => {
{
"name": "restaurants",
"type": "collection",
"path": "collection=restaurants",
"connectionName": "conn1",
"queryable": true,
"children": [
Expand All @@ -21,6 +22,7 @@ describe("SchemaNode", () => {

expect(schemaNode.getName()).toEqual("restaurants");
expect(schemaNode.getType()).toEqual("collection");
expect(schemaNode.getPath()).toEqual("collection=restaurants");
expect(schemaNode.getConnectionName()).toEqual("conn1");
expect(schemaNode.isQueryable()).toEqual(true);
expect(schemaNode.getMaxLevels()).toEqual(1);
Expand All @@ -32,19 +34,22 @@ describe("SchemaNode", () => {
{
"name": "restaurants",
"type": "collection",
"path": "collection=restaurants",
"connectionName": "conn1",
"queryable": true,
"children": [
{
"name": "grades",
"type": "embedded",
"path": "collection=restaurants/embedded=grades",
"connectionName": "conn1",
"queryable": true,
"children": []
},
{
"name": "address",
"type": "embedded",
"path": "collection=restaurants/embedded=address",
"connectionName": "conn1",
"queryable": true,
"children": []
Expand All @@ -54,20 +59,23 @@ describe("SchemaNode", () => {

expect(schemaNode.getName()).toEqual("restaurants");
expect(schemaNode.getType()).toEqual("collection");
expect(schemaNode.getPath()).toEqual("collection=restaurants");
expect(schemaNode.getConnectionName()).toEqual("conn1");
expect(schemaNode.isQueryable()).toEqual(true);
expect(schemaNode.getMaxLevels()).toEqual(2);
expect(schemaNode.getChildren().length).toEqual(2);

expect(schemaNode.getChildren()[0].getName()).toEqual("grades");
expect(schemaNode.getChildren()[0].getType()).toEqual("embedded");
expect(schemaNode.getChildren()[0].getPath()).toEqual("collection=restaurants/embedded=grades");
expect(schemaNode.getChildren()[0].getConnectionName()).toEqual("conn1");
expect(schemaNode.getChildren()[0].isQueryable()).toEqual(true);
expect(schemaNode.getChildren()[0].getMaxLevels()).toEqual(1);
expect(schemaNode.getChildren()[0].getChildren().length).toEqual(0);

expect(schemaNode.getChildren()[1].getName()).toEqual("address");
expect(schemaNode.getChildren()[1].getType()).toEqual("embedded");
expect(schemaNode.getChildren()[1].getPath()).toEqual("collection=restaurants/embedded=address");
expect(schemaNode.getChildren()[1].getConnectionName()).toEqual("conn1");
expect(schemaNode.getChildren()[1].isQueryable()).toEqual(true);
expect(schemaNode.getChildren()[1].getMaxLevels()).toEqual(1);
Expand All @@ -80,25 +88,29 @@ describe("SchemaNode", () => {
{
"name": "myCatalog",
"type": "catalog",
"path": "catalog=myCatalog",
"connectionName": "conn1",
"queryable": false,
"children": [
{
"name": "mySchema1",
"type": "schema",
"path": "catalog=myCatalog/schema=mySchema1",
"connectionName": "conn1",
"queryable": false,
"children": [
{
"name": "myTable1",
"type": "table",
"path": "catalog=myCatalog/schema=mySchema1/table=myTable1",
"connectionName": "conn1",
"queryable": true,
"children": []
},
{
"name": "myTable2",
"type": "table",
"path": "catalog=myCatalog/schema=mySchema1/table=myTable2",
"connectionName": "conn1",
"queryable": true,
"children": []
Expand All @@ -108,26 +120,30 @@ describe("SchemaNode", () => {
{
"name": "mySchema2",
"type": "schema",
"path": "catalog=myCatalog/schema=mySchema2",
"connectionName": "conn1",
"queryable": false,
"children": [
{
"name": "myTableA",
"type": "table",
"path": "catalog=myCatalog/schema=mySchema2/table=myTableA",
"connectionName": "conn1",
"queryable": true,
"children": []
},
{
"name": "myTableB",
"type": "table",
"path": "catalog=myCatalog/schema=mySchema2/table=myTableB",
"connectionName": "conn1",
"queryable": true,
"children": []
},
{
"name": "myTableC",
"type": "table",
"path": "catalog=myCatalog/schema=mySchema2/table=myTableC",
"connectionName": "conn1",
"queryable": true,
"children": []
Expand All @@ -140,6 +156,7 @@ describe("SchemaNode", () => {
// Root Node (myCatalog)
expect(schemaNode.getName()).toEqual("myCatalog");
expect(schemaNode.getType()).toEqual("catalog");
expect(schemaNode.getPath()).toEqual("catalog=myCatalog");
expect(schemaNode.getConnectionName()).toEqual("conn1");
expect(schemaNode.isQueryable()).toEqual(false);
expect(schemaNode.getMaxLevels()).toEqual(3);
Expand All @@ -149,6 +166,7 @@ describe("SchemaNode", () => {
const schema1: SchemaNode = schemaNode.getChildren()[0];
expect(schema1.getName()).toEqual("mySchema1");
expect(schema1.getType()).toEqual("schema");
expect(schema1.getPath()).toEqual("catalog=myCatalog/schema=mySchema1");
expect(schema1.getConnectionName()).toEqual("conn1");
expect(schema1.isQueryable()).toEqual(false);
expect(schema1.getMaxLevels()).toEqual(2);
Expand All @@ -158,6 +176,7 @@ describe("SchemaNode", () => {
const schema2: SchemaNode = schemaNode.getChildren()[1];
expect(schema2.getName()).toEqual("mySchema2");
expect(schema2.getType()).toEqual("schema");
expect(schema2.getPath()).toEqual("catalog=myCatalog/schema=mySchema2");
expect(schema2.getConnectionName()).toEqual("conn1");
expect(schema2.isQueryable()).toEqual(false);
expect(schema2.getMaxLevels()).toEqual(2);
Expand All @@ -170,20 +189,23 @@ describe("SchemaNode", () => {

expect(tableA.getName()).toEqual("myTableA");
expect(tableA.getType()).toEqual("table");
expect(tableA.getPath()).toEqual("catalog=myCatalog/schema=mySchema2/table=myTableA");
expect(tableA.getConnectionName()).toEqual("conn1");
expect(tableA.isQueryable()).toEqual(true);
expect(tableA.getMaxLevels()).toEqual(1);
expect(tableA.getChildren().length).toEqual(0);

expect(tableB.getName()).toEqual("myTableB");
expect(tableB.getType()).toEqual("table");
expect(tableB.getPath()).toEqual("catalog=myCatalog/schema=mySchema2/table=myTableB");
expect(tableB.getConnectionName()).toEqual("conn1");
expect(tableB.isQueryable()).toEqual(true);
expect(tableB.getMaxLevels()).toEqual(1);
expect(tableB.getChildren().length).toEqual(0);

expect(tableC.getName()).toEqual("myTableC");
expect(tableC.getType()).toEqual("table");
expect(tableC.getPath()).toEqual("catalog=myCatalog/schema=mySchema2/table=myTableC");
expect(tableC.getConnectionName()).toEqual("conn1");
expect(tableC.isQueryable()).toEqual(true);
expect(tableC.getMaxLevels()).toEqual(1);
Expand Down
9 changes: 9 additions & 0 deletions ngapp/src/app/connections/shared/schema-node.model.ts
Expand Up @@ -44,6 +44,8 @@ export class SchemaNode {
schemaNode.setName(json[field]);
} else if (field === "type") {
schemaNode.setType(json[field]);
} else if (field === "path") {
schemaNode.setPath(json[field]);
} else if (field === "queryable") {
schemaNode.setQueryable(json[field]);
} else if (field === "connectionName") {
Expand Down Expand Up @@ -99,6 +101,13 @@ export class SchemaNode {
this.type = type ? type : null;
}

/**
* @param {string} path the node path
*/
public setPath( path?: string ): void {
this.path = path ? path : null;
}

/**
* @param {string} connectionName the nodes connection name
*/
Expand Down
12 changes: 12 additions & 0 deletions ngapp/src/app/shared/test-data.service.ts
Expand Up @@ -425,19 +425,22 @@ export class TestDataService {
"connectionName": "pgConn",
"name": "restaurants",
"type": "collection",
"path": "collection=restaurants",
"queryable": true,
"children": [
{
"connectionName": "pgConn",
"name": "grades",
"type": "embedded",
"path": "collection=restaurants/embedded=grades",
"queryable": true,
"children": []
},
{
"connectionName": "pgConn",
"name": "location",
"type": "embedded",
"path": "collection=restaurants/embedded=location",
"queryable": true,
"children": []
}
Expand All @@ -448,19 +451,22 @@ export class TestDataService {
"connectionName": "conn1",
"name": "public",
"type": "schema",
"path": "schema=public",
"queryable": false,
"children": [
{
"connectionName": "conn1",
"name": "customer",
"type": "table",
"path": "schema=public/table=customer",
"queryable": true,
"children": []
},
{
"connectionName": "conn1",
"name": "stuff",
"type": "table",
"path": "schema=public/table=stuff",
"queryable": true,
"children": []
}
Expand All @@ -471,19 +477,22 @@ export class TestDataService {
"connectionName": "conn2",
"name": "restaurants",
"type": "collection",
"path": "collection=restaurants",
"queryable": true,
"children": [
{
"connectionName": "conn2",
"name": "grades",
"type": "embedded",
"path": "collection=restaurants/embedded=grades",
"queryable": true,
"children": []
},
{
"connectionName": "conn2",
"name": "location",
"type": "embedded",
"path": "collection=restaurants/embedded=location",
"queryable": true,
"children": []
}
Expand All @@ -494,19 +503,22 @@ export class TestDataService {
"connectionName": "conn3",
"name": "public",
"type": "schema",
"path": "schema=public",
"queryable": false,
"children": [
{
"connectionName": "conn3",
"name": "customer",
"type": "table",
"path": "schema=public/table=customer",
"queryable": true,
"children": []
},
{
"connectionName": "conn3",
"name": "stuff",
"type": "table",
"path": "schema=public/table=stuff",
"queryable": true,
"children": []
}
Expand Down

0 comments on commit 64aa36b

Please sign in to comment.