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

Commit

Permalink
TEIIDTOOLS-469 Addition of add composition wizard
Browse files Browse the repository at this point in the history
  • Loading branch information
mdrillin committed Jul 27, 2018
1 parent 850515b commit ccf4a8c
Show file tree
Hide file tree
Showing 46 changed files with 2,195 additions and 100 deletions.
4 changes: 2 additions & 2 deletions ngapp/src/app/connections/connections.component.spec.ts
Expand Up @@ -98,12 +98,12 @@ describe("ConnectionsComponent", () => {
console.log("========== [ConnectionsComponent] should have Connections");
// Check component object
const connections = component.allConnections;
expect(connections.length).toEqual(3);
expect(connections.length).toEqual(2);

// Check html has the same number of connection cards
const cardDebugElems = fixture.debugElement.queryAll(By.css(".object-card"));
expect(cardDebugElems).toBeDefined();
expect(cardDebugElems.length).toEqual(3);
expect(cardDebugElems.length).toEqual(2);
});

it("should have initial card layout", () => {
Expand Down
29 changes: 28 additions & 1 deletion ngapp/src/app/connections/shared/connection.service.ts
Expand Up @@ -33,6 +33,7 @@ import { environment } from "@environments/environment";
import { Observable } from "rxjs/Observable";
import { Subscription } from "rxjs/Subscription";
import { VdbsConstants } from "@dataservices/shared/vdbs-constants";
import { Column } from "@dataservices/shared/column.model";

@Injectable()
export class ConnectionService extends ApiService {
Expand Down Expand Up @@ -226,14 +227,40 @@ export class ConnectionService extends ApiService {
public getConnectionSchema(connectionId: string): Observable<SchemaNode[]> {
return this.http
.get( environment.komodoWorkspaceUrl + ConnectionsConstants.connectionsRootPath
+ "/" + connectionId + "/schema", this.getAuthRequestOptions())
+ "/" + connectionId + "/schema", this.getAuthRequestOptions())
.map((response) => {
const schemaNodes = response.json();
return schemaNodes.map((schemaNode) => SchemaNode.create( schemaNode ));
})
.catch( ( error ) => this.handleError( error ) );
}

/**
* Get the columns for the specified connection and table. The connection must be ACTIVE, otherwise the schema
* will be empty.
* @param {string} connectionId the connection id
* @param {string} tableOption the table option (eg. schema=public/table=customer)
* @returns {Observable<Column[]>}
*/
public getConnectionSchemaColumns(connectionId: string, tableOption: string): Observable<Column[]> {
// setup query parameters
const tableParam = {
params: {
"tableOption": tableOption
}
};
const options = new RequestOptions( tableParam );

return this.http
.get( environment.komodoWorkspaceUrl + ConnectionsConstants.connectionsRootPath
+ "/" + connectionId + "/schema-columns", this.getAuthRequestOptions().merge(options))
.map((response) => {
const columns = response.json();
return columns.map((column) => Column.create( column ));
})
.catch( ( error ) => this.handleError( error ) );
}

/**
* Create a connection in the Komodo repo - also binds the specified serviceCatalogSource
* @param {NewConnection} connection the connection object
Expand Down
14 changes: 14 additions & 0 deletions ngapp/src/app/connections/shared/mock-connection.service.ts
Expand Up @@ -33,13 +33,15 @@ import "rxjs/add/observable/throw";
import "rxjs/add/operator/catch";
import "rxjs/add/operator/map";
import { Observable } from "rxjs/Observable";
import { Column } from "@dataservices/shared/column.model";

@Injectable()
export class MockConnectionService extends ConnectionService {

private connections: Connection[];
private readonly serviceCatalogSources: ServiceCatalogSource[];
private connectionSchemaMap = new Map<string, SchemaNode[]>();
private connectionSchemaColumnsMap = new Map<string, Column[]>();
private testDataService: TestDataService;

constructor( http: Http, vdbService: VdbService, notifierService: NotifierService,
Expand All @@ -59,6 +61,7 @@ export class MockConnectionService extends ConnectionService {
this.connections = conns;
this.serviceCatalogSources = this.testDataService.getServiceCatalogSources();
this.connectionSchemaMap = this.testDataService.getConnectionSchemaMap();
this.connectionSchemaColumnsMap = this.testDataService.getConnectionSchemaColumnsMap();
}

public isValidName( name: string ): Observable< string > {
Expand Down Expand Up @@ -128,6 +131,17 @@ export class MockConnectionService extends ConnectionService {
return Observable.of( this.connectionSchemaMap.get( connectionName ) );
}

/**
* Get the columns for the specified connection and table. The connection must be ACTIVE, otherwise the schema
* will be empty.
* @param {string} connectionName the connection id
* @param {string} tableOption the table option (eg. schema=public/table=customer)
* @returns {Observable<Column[]>}
*/
public getConnectionSchemaColumns(connectionName: string, tableOption: string): Observable<Column[]> {
return Observable.of( this.connectionSchemaColumnsMap.get( connectionName + ":" + tableOption ));
}

/**
* Create a connection in the Komodo repo - also binds the specified serviceCatalogSource
* @param {NewConnection} connection the connection object
Expand Down
4 changes: 1 addition & 3 deletions ngapp/src/app/core/api.service.ts
Expand Up @@ -86,7 +86,7 @@ export abstract class ApiService {
public tryNumberParse(jsonString: string): number {
try {
const n = parseInt(jsonString, 10);
if (n && typeof n === "number") {
if (n) {
return n;
}
} catch (e) {
Expand Down Expand Up @@ -122,8 +122,6 @@ export abstract class ApiService {
* @returns true if the item is parseable
*/
public isJSON(item: string): boolean {
item = typeof item !== "string" ? JSON.stringify(item) : item;

try {
item = JSON.parse(item);
} catch (e) {
Expand Down
6 changes: 4 additions & 2 deletions ngapp/src/app/dataservices/dataservices.module.ts
Expand Up @@ -74,6 +74,7 @@ import { ConnectionTreeSelectorComponent } from './virtualization/view-editor/co
import { ConnectionTableDialogComponent } from './virtualization/view-editor/connection-table-dialog/connection-table-dialog.component';
import { ProgressDialogComponent } from "@shared/progress-dialog/progress-dialog.component";
import { ViewPropertyEditorsComponent } from './virtualization/view-editor/view-property-editors/view-property-editors.component';
import { AddCompositionWizardComponent } from './virtualization/view-editor/add-composition-wizard/add-composition-wizard.component';

@NgModule({
imports: [
Expand Down Expand Up @@ -127,7 +128,8 @@ import { ViewPropertyEditorsComponent } from './virtualization/view-editor/view-
ViewPropertyEditorsComponent,
GraphVisualComponent,
NodeVisualComponent,
LinkVisualComponent
LinkVisualComponent,
AddCompositionWizardComponent
],
providers: [
{
Expand All @@ -149,7 +151,7 @@ import { ViewPropertyEditorsComponent } from './virtualization/view-editor/view-
],
exports: [
],
entryComponents: [ConfirmDialogComponent, ConnectionTableDialogComponent, ProgressDialogComponent]
entryComponents: [AddCompositionWizardComponent, ConfirmDialogComponent, ConnectionTableDialogComponent, ProgressDialogComponent]
})
export class DataservicesModule { }

Expand Down
Expand Up @@ -21,7 +21,6 @@ import { LoggerService } from "@core/logger.service";
import * as _ from "lodash";
import "codemirror/mode/javascript/javascript.js";
import "codemirror/mode/xml/xml.js";
import { ColumnData } from "@dataservices/shared/column-data.model";
import { DataserviceService } from "@dataservices/shared/dataservice.service";
import { Dataservice } from "@dataservices/shared/dataservice.model";
import { OdataConstants } from "@dataservices/odata-control/odata-constants";
Expand Down
45 changes: 34 additions & 11 deletions ngapp/src/app/dataservices/selected-node/selected-node.component.ts
Expand Up @@ -17,7 +17,7 @@

import { Component, EventEmitter, Input, OnInit, Output, ViewEncapsulation } from "@angular/core";
import { SchemaNode } from "@connections/shared/schema-node.model";
import { Column } from "@dataservices/selected-node/column";
import { Column } from "@dataservices/shared/column.model";
import { CardAction, CardConfig, TableConfig, TableEvent } from "patternfly-ng";

@Component({
Expand Down Expand Up @@ -49,16 +49,39 @@ export class SelectedNodeComponent implements OnInit {
];

// TODO: replace with call to get the column metadata
this.columns = [
new Column( "name", true, "string", 25 ),
new Column( "age", true, "integer", 3 ),
new Column( "street", true, "string", 30 ),
new Column( "state", true, "string", 2 ),
new Column( "zipcode", true, "string", 9 ),
new Column( "company", true, "string", 50 ),
new Column( "married", true, "boolean", 1 ),
new Column( "gender", true, "string", 1 ),
];
const c1 = new Column();
const c2 = new Column();
const c3 = new Column();
const c4 = new Column();
const c5 = new Column();
const c6 = new Column();
const c7 = new Column();
const c8 = new Column();
c1.setName("name");
c2.setName("age");
c3.setName("street");
c4.setName("state");
c5.setName("zipcode");
c6.setName("company");
c7.setName("married");
c8.setName("gender");
c1.setDatatype("string");
c2.setDatatype("integer");
c3.setDatatype("string");
c4.setDatatype("string");
c5.setDatatype("string");
c6.setDatatype("string");
c7.setDatatype("boolean");
c8.setDatatype("string");
c1.setSize(25);
c2.setSize(3);
c3.setSize(30);
c4.setSize(2);
c5.setSize(9);
c6.setSize(50);
c7.setSize(1);
c8.setSize(1);
this.columns = [ c1, c2, c3, c4, c5, c6, c7, c8 ];

this.tableConfig = {
showCheckbox: true
Expand Down
41 changes: 41 additions & 0 deletions ngapp/src/app/dataservices/shared/column.model.spec.ts
@@ -0,0 +1,41 @@
import { Column } from "@dataservices/shared/column.model";

describe("Column", () => {
let column: Column;

beforeEach(() => {
column = null;
});

it("should create", () => {
console.log("========== [Column] should create");
column = Column.create(
{
"keng__baseUri": "http://das-beetle-studio.192.168.42.67.nip.io/vdb-builder/v1/",
"keng__id": "account_id",
"keng__dataPath": "/tko:komodo/tko:workspace/admin/pgConn/pgconnschemavdb/pgconnschemamodel/account/account_id",
"keng__kType": "Column",
"keng__hasChildren": false,
"Datatype": "INTEGER",
"keng___links": [
{
"rel": "self",
"href": "http://das-beetle-studio.192.168.42.67.nip.io/vdb-builder/v1/workspace/blah/account/Columns/account_id"
},
{
"rel": "parent",
"href": "http://das-beetle-studio.192.168.42.67.nip.io/vdb-builder/v1/workspace/blah/account"
},
{
"rel": "children",
"href": "http://das-beetle-studio.192.168.42.67.nip.io/vdb-builder/v1/workspace/s"
}
]
}
);

expect(column.getName()).toEqual("account_id");
expect(column.getDatatype()).toEqual("INTEGER");
});

});
104 changes: 104 additions & 0 deletions ngapp/src/app/dataservices/shared/column.model.ts
@@ -0,0 +1,104 @@

/**
* @license
* Copyright 2017 JBoss Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export class Column {

private isSelected = false;
private keng__id: string;
private Datatype: string;
private size: number;

/**
* @param {Object} json the JSON representation of a Column
* @returns {Column} the new Column (never null)
*/
public static create( json: object = {} ): Column {
const column = new Column();
column.setValues( json );
return column;
}

constructor() {
// nothing to do
}

/**
* @returns {string} the column name
*/
public getName(): string {
return this.keng__id;
}

/**
* @param {string} name the column name
*/
public setName( name?: string ): void {
this.keng__id = name ? name : null;
}

/**
* @returns {string} the column type
*/
public getDatatype(): string {
return this.Datatype;
}

/**
* @param {string} name the column type
*/
public setDatatype( type: string ): void {
this.Datatype = type;
}

/**
* @returns {number} the column size
*/
public getSize(): number {
return this.size;
}

/**
* @param {number} size the column size
*/
public setSize( size: number ): void {
this.size = size;
}

/**
* @returns {boolean} 'true' if column isSelected
*/
public get selected(): boolean {
return this.isSelected;
}

/**
* @param {boolean} selected the column isSelected state
*/
public setSelected( selected: boolean ): void {
this.isSelected = selected;
}

/**
* Set all object values using the supplied View json
* @param {Object} values
*/
public setValues(values: object = {}): void {
Object.assign(this, values);
}

}

0 comments on commit ccf4a8c

Please sign in to comment.