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

Commit

Permalink
TTOOLS-465 Addition of projected columns editor
Browse files Browse the repository at this point in the history
  • Loading branch information
mdrillin committed Oct 15, 2018
1 parent 18a29e3 commit 125a6f3
Show file tree
Hide file tree
Showing 26 changed files with 1,126 additions and 64 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { async, ComponentFixture, TestBed } from "@angular/core/testing";

import { CreateViewsDialogComponent } from "./create-views-dialog.component";
import { ConnectionTreeSelectorComponent } from "@dataservices/virtualization/view-editor/connection-table-dialog/connection-tree-selector/connection-tree-selector.component";
import { HttpModule } from "@angular/http";
import {
ActionModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
EmptyStateConfig,
ListConfig,
ListEvent,
NgxDataTableConfig,
NotificationType,
TableConfig
} from "patternfly-ng";
Expand Down
4 changes: 3 additions & 1 deletion ngapp/src/app/dataservices/dataservices.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ import { CreateViewDialogComponent } from './virtualization/view-editor/create-v
import { CreateViewsDialogComponent } from './create-views-dialog/create-views-dialog.component';
import { SetDescriptionDialogComponent } from "@dataservices/set-description-dialog/set-description-dialog.component";
import { PropertyEditorComponent } from './virtualization/view-editor/view-property-editors/property-editor/property-editor.component';
import { ProjectedColumnsEditorComponent } from './virtualization/view-editor/view-property-editors/projected-columns-editor/projected-columns-editor.component';

@NgModule({
imports: [
Expand Down Expand Up @@ -131,7 +132,8 @@ import { PropertyEditorComponent } from './virtualization/view-editor/view-prope
CreateViewDialogComponent,
CreateViewsDialogComponent,
SetDescriptionDialogComponent,
PropertyEditorComponent
PropertyEditorComponent,
ProjectedColumnsEditorComponent
],
providers: [
{
Expand Down
10 changes: 2 additions & 8 deletions ngapp/src/app/dataservices/shared/composition.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,14 @@ export class Composition {
* @return {boolean} 'true' if initial source is set and on the left
*/
public get initialSourceOnLeft(): boolean {
if (this.initialSourcePath !== null && this.leftSourcePath !== null && this.initialSourcePath === this.leftSourcePath) {
return true;
}
return false;
return this.initialSourcePath !== null && this.leftSourcePath !== null && this.initialSourcePath === this.leftSourcePath;
}

/**
* @return {boolean} 'true' if initial source is set and on the right
*/
public get initialSourceOnRight(): boolean {
if (this.initialSourcePath !== null && this.rightSourcePath !== null && this.initialSourcePath === this.rightSourcePath) {
return true;
}
return false;
return this.initialSourcePath !== null && this.rightSourcePath !== null && this.initialSourcePath === this.rightSourcePath;
}

/**
Expand Down
10 changes: 4 additions & 6 deletions ngapp/src/app/dataservices/shared/mock-dataservice.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ import "rxjs/add/operator/map";
import { Observable } from "rxjs/Observable";
import { ErrorObservable } from "rxjs/observable/ErrorObservable";
import { ViewEditorState } from "@dataservices/shared/view-editor-state.model";
import { environment } from "@environments/environment";
import { DataservicesConstants } from "@dataservices/shared/dataservices-constants";

@Injectable()
export class MockDataserviceService extends DataserviceService {
Expand Down Expand Up @@ -151,10 +149,10 @@ export class MockDataserviceService extends DataserviceService {
}

/**
* @param {ViewEditorState} editorState the view editor state
* @param {ViewEditorState[]} editorStates the view editor state array
* @returns {Observable<boolean>} `true` if the editor state was successfully saved
*/
public saveViewEditorState( editorState: ViewEditorState ): Observable< boolean > {
public saveViewEditorStates( editorStates: ViewEditorState[] ): Observable< boolean > {
return Observable.of(true);
}

Expand Down Expand Up @@ -199,11 +197,11 @@ export class MockDataserviceService extends DataserviceService {
}

/**
* @param {ViewEditorState} editorState the view editor state
* @param {ViewEditorState[]} editorStates the view editor state array
* @param {string} dataserviceName the name of the dataservice
* @returns {Observable<boolean>} `true` if the editor state was successfully saved
*/
public saveViewEditorStateRefreshViews( editorState: ViewEditorState, dataserviceName: string ): Observable< boolean > {
public saveViewEditorStatesRefreshViews( editorStates: ViewEditorState[], dataserviceName: string ): Observable< boolean > {
return Observable.of(true);
}

Expand Down
38 changes: 38 additions & 0 deletions ngapp/src/app/dataservices/shared/projected-column.model.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { ProjectedColumn } from "@dataservices/shared/projected-column.model";

describe("ProjectedColumn", () => {
let projCol1: ProjectedColumn;
let projCol2: ProjectedColumn;

beforeEach(() => {
projCol1 = null;
projCol2 = null;
});

it("should create", () => {
console.log("========== [ProjectedColumn] should create");
projCol1 = ProjectedColumn.create(
{
"name": "colName1",
"type": "string",
"selected": true
}
);
projCol2 = ProjectedColumn.create(
{
"name": "colName2",
"type": "integer",
"selected": false
}
);

expect(projCol1.getName()).toEqual("colName1");
expect(projCol1.getType()).toEqual("string");
expect(projCol1.selected).toEqual(true);

expect(projCol2.getName()).toEqual("colName2");
expect(projCol2.getType()).toEqual("integer");
expect(projCol2.selected).toEqual(false);
});

});
91 changes: 91 additions & 0 deletions ngapp/src/app/dataservices/shared/projected-column.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/**
* @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.
*/

/**
* ProjectedColumn model - to hold the column info for projected view columns
*/
export class ProjectedColumn {

private name: string;
private type: string;
public selected = false;

/**
* @param {Object} json the JSON representation of ProjectedColumn
* @returns {ProjectedColumn} the new ProjectedColumn (never null)
*/
public static create( json: object = {} ): ProjectedColumn {
const projCol = new ProjectedColumn();
for (const field of Object.keys(json)) {
if (field === "name") {
projCol.setName(json[field]);
} else if (field === "type") {
projCol.setType(json[field]);
} else if (field === "selected") {
projCol.selected = json[field];
}
}
return projCol;
}

constructor() {
// nothing to do
}

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

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

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

/**
* @param {string} type the column type
*/
public setType( type?: string ): void {
this.type = type ? type : "";
}

/**
* Determine if the supplied ProjectedColumn is equal to this
* @param {ProjectedColumn} otherCol the other column
*/
public isEqual( otherCol: ProjectedColumn ): boolean {
let equal = false;
if (this.getName() === otherCol.getName() &&
this.getType() === otherCol.getType() &&
this.selected === otherCol.selected ) {
equal = true;
}
return equal;
}

}
127 changes: 105 additions & 22 deletions ngapp/src/app/dataservices/shared/view-definition.model.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,136 @@ import { CompositionOperator } from "@dataservices/shared/composition-operator.e
import { CompositionType } from "@dataservices/shared/composition-type.enum";

describe("ViewDefinition", () => {
let viewDefn: ViewDefinition;
let viewDefn1: ViewDefinition;
let viewDefn2: ViewDefinition;

beforeEach(() => {
viewDefn = null;
viewDefn1 = null;
viewDefn2 = null;
});

it("should create", () => {
console.log("========== [ViewDefinition] should create");
viewDefn = ViewDefinition.create(
viewDefn1 = ViewDefinition.create(
{
"viewName": "viewDefnName",
"keng__description": "viewDescription",
"isComplete": true,
"sourcePaths":
[
"sourcePath1",
"sourcePath2"
"connection=pgConn/schema=public/table=account",
"connection=pgConn/schema=public/table=holdings"
],
"compositions":
[
{
"name": "compositionName",
"leftSourcePath": "sourcePath1",
"rightSourcePath": "sourcePath2",
"leftSourcePath": "connection=pgConn/schema=public/table=account",
"rightSourcePath": "connection=pgConn/schema=public/table=holdings",
"leftCriteriaColumn": "leftCriteriaCol",
"rightCriteriaColumn": "rightCriteriaCol",
"type": "INNER_JOIN",
"operator": "EQ"
}
]
],
"projectedColumns": [
{
"name": "ALL",
"type": "ALL",
"selected": true
}
]
}
);

expect(viewDefn.getName()).toEqual("viewDefnName");
expect(viewDefn.getDescription()).toEqual("viewDescription");
expect(viewDefn.complete).toEqual(true);
expect(viewDefn.getSourcePaths().length).toEqual(2);
expect(viewDefn.getSourcePaths()[0]).toEqual("sourcePath1");
expect(viewDefn.getSourcePaths()[1]).toEqual("sourcePath2");
expect(viewDefn.getCompositions().length).toEqual(1);
expect(viewDefn.getCompositions()[0].getName()).toEqual("compositionName");
expect(viewDefn.getCompositions()[0].getLeftSourcePath()).toEqual("sourcePath1");
expect(viewDefn.getCompositions()[0].getRightSourcePath()).toEqual("sourcePath2");
expect(viewDefn.getCompositions()[0].getLeftCriteriaColumn()).toEqual("leftCriteriaCol");
expect(viewDefn.getCompositions()[0].getRightCriteriaColumn()).toEqual("rightCriteriaCol");
expect(viewDefn.getCompositions()[0].getType()).toEqual(CompositionType.INNER_JOIN);
expect(viewDefn.getCompositions()[0].getOperator()).toEqual(CompositionOperator.EQ);
viewDefn2 = ViewDefinition.create(
{
"viewName": "viewDefnName",
"keng__description": "viewDescription",
"isComplete": true,
"sourcePaths":
[
"connection=pgConn/schema=public/table=account",
"connection=pgConn/schema=public/table=holdings"
],
"compositions":
[
{
"name": "compositionName",
"leftSourcePath": "connection=pgConn/schema=public/table=account",
"rightSourcePath": "connection=pgConn/schema=public/table=holdings",
"leftCriteriaColumn": "leftCriteriaCol",
"rightCriteriaColumn": "rightCriteriaCol",
"type": "INNER_JOIN",
"operator": "EQ"
}
],
"projectedColumns": [
{
"name": "col1",
"type": "string",
"selected": true
},
{
"name": "col2",
"type": "integer",
"selected": false
},
{
"name": "col3",
"type": "string",
"selected": true
}
]
}
);

expect(viewDefn1.getName()).toEqual("viewDefnName");
expect(viewDefn1.getDescription()).toEqual("viewDescription");
expect(viewDefn1.complete).toEqual(true);
expect(viewDefn1.getSourcePaths().length).toEqual(2);
expect(viewDefn1.getSourcePaths()[0]).toEqual("connection=pgConn/schema=public/table=account");
expect(viewDefn1.getSourcePaths()[1]).toEqual("connection=pgConn/schema=public/table=holdings");
expect(viewDefn1.getCompositions().length).toEqual(1);
expect(viewDefn1.getCompositions()[0].getName()).toEqual("compositionName");
expect(viewDefn1.getCompositions()[0].getLeftSourcePath()).toEqual("connection=pgConn/schema=public/table=account");
expect(viewDefn1.getCompositions()[0].getRightSourcePath()).toEqual("connection=pgConn/schema=public/table=holdings");
expect(viewDefn1.getCompositions()[0].getLeftCriteriaColumn()).toEqual("leftCriteriaCol");
expect(viewDefn1.getCompositions()[0].getRightCriteriaColumn()).toEqual("rightCriteriaCol");
expect(viewDefn1.getCompositions()[0].getType()).toEqual(CompositionType.INNER_JOIN);
expect(viewDefn1.getCompositions()[0].getOperator()).toEqual(CompositionOperator.EQ);
expect(viewDefn1.getProjectedColumns().length).toEqual(1);
expect(viewDefn1.getProjectedColumns()[0].getName()).toEqual("ALL");
expect(viewDefn1.getProjectedColumns()[0].getType()).toEqual("ALL");
expect(viewDefn1.getProjectedColumns()[0].selected).toEqual(true);
expect(viewDefn1.getPreviewSql()).toEqual("SELECT * FROM pgconnschemamodel.account AS A INNER JOIN pgconnschemamodel.holdings AS B ON A.leftCriteriaCol = B.rightCriteriaCol;");

expect(viewDefn2.getName()).toEqual("viewDefnName");
expect(viewDefn2.getDescription()).toEqual("viewDescription");
expect(viewDefn2.complete).toEqual(true);
expect(viewDefn2.getSourcePaths().length).toEqual(2);
expect(viewDefn2.getSourcePaths()[0]).toEqual("connection=pgConn/schema=public/table=account");
expect(viewDefn2.getSourcePaths()[1]).toEqual("connection=pgConn/schema=public/table=holdings");
expect(viewDefn2.getCompositions().length).toEqual(1);
expect(viewDefn2.getCompositions()[0].getName()).toEqual("compositionName");
expect(viewDefn2.getCompositions()[0].getLeftSourcePath()).toEqual("connection=pgConn/schema=public/table=account");
expect(viewDefn2.getCompositions()[0].getRightSourcePath()).toEqual("connection=pgConn/schema=public/table=holdings");
expect(viewDefn2.getCompositions()[0].getLeftCriteriaColumn()).toEqual("leftCriteriaCol");
expect(viewDefn2.getCompositions()[0].getRightCriteriaColumn()).toEqual("rightCriteriaCol");
expect(viewDefn2.getCompositions()[0].getType()).toEqual(CompositionType.INNER_JOIN);
expect(viewDefn2.getCompositions()[0].getOperator()).toEqual(CompositionOperator.EQ);
expect(viewDefn2.getProjectedColumns().length).toEqual(3);
expect(viewDefn2.getProjectedColumns()[0].getName()).toEqual("col1");
expect(viewDefn2.getProjectedColumns()[0].getType()).toEqual("string");
expect(viewDefn2.getProjectedColumns()[0].selected).toEqual(true);
expect(viewDefn2.getProjectedColumns()[1].getName()).toEqual("col2");
expect(viewDefn2.getProjectedColumns()[1].getType()).toEqual("integer");
expect(viewDefn2.getProjectedColumns()[1].selected).toEqual(false);
expect(viewDefn2.getProjectedColumns()[2].getName()).toEqual("col3");
expect(viewDefn2.getProjectedColumns()[2].getType()).toEqual("string");
expect(viewDefn2.getProjectedColumns()[2].selected).toEqual(true);
expect(viewDefn2.getPreviewSql()).toEqual("SELECT col1, col3 FROM pgconnschemamodel.account AS A INNER JOIN pgconnschemamodel.holdings AS B ON A.leftCriteriaCol = B.rightCriteriaCol;");

});

});

0 comments on commit 125a6f3

Please sign in to comment.