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

Commit

Permalink
mods to dataservice creation process
Browse files Browse the repository at this point in the history
  • Loading branch information
mdrillin committed Nov 16, 2017
1 parent 2cea7d5 commit e9e867d
Show file tree
Hide file tree
Showing 56 changed files with 3,075 additions and 179 deletions.
1 change: 1 addition & 0 deletions ngapp/src/app/activities/activities.component.ts
Expand Up @@ -101,6 +101,7 @@ export class ActivitiesComponent extends AbstractPageComponent {
this.confirmDeleteDialog.open();
}

// noinspection JSMethodCanBeStatic
public onStart(activityName: string): void {
alert("Start activity " + activityName);
}
Expand Down
5 changes: 3 additions & 2 deletions ngapp/src/app/activities/shared/activity.service.spec.ts
@@ -1,17 +1,18 @@
import { ActivityService } from "@activities/shared/activity.service";
import { inject, TestBed } from "@angular/core/testing";
import { HttpModule } from "@angular/http";
import { AppSettingsService } from "@core/app-settings.service";
import { LoggerService } from "@core/logger.service";

describe("ActivityService", () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [ HttpModule ],
providers: [ActivityService, LoggerService]
providers: [ActivityService, AppSettingsService, LoggerService]
});
});

it("should be created", inject([ActivityService, LoggerService],
it("should be created", inject([ActivityService, AppSettingsService, LoggerService],
(service: ActivityService, logger: LoggerService) => {
expect(service).toBeTruthy();
}));
Expand Down
5 changes: 3 additions & 2 deletions ngapp/src/app/activities/shared/activity.service.ts
Expand Up @@ -20,6 +20,7 @@ import { NewActivity } from "@activities/shared/new-activity.model";
import { Injectable } from "@angular/core";
import { Http } from "@angular/http";
import { ApiService } from "@core/api.service";
import { AppSettingsService } from "@core/app-settings.service";
import { LoggerService } from "@core/logger.service";
import "rxjs/add/observable/of";
import { Observable } from "rxjs/Observable";
Expand All @@ -29,8 +30,8 @@ export class ActivityService extends ApiService {

private http: Http;

constructor( http: Http, logger: LoggerService ) {
super( logger );
constructor( http: Http, appSettings: AppSettingsService, logger: LoggerService ) {
super( appSettings, logger );
this.http = http;
}

Expand Down
22 changes: 20 additions & 2 deletions ngapp/src/app/activities/shared/mock-activity.service.ts
@@ -1,9 +1,27 @@
/**
* @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.
*/

import { Activity } from "@activities/shared/activity.model";
import { ActivityService } from "@activities/shared/activity.service";
import { NewActivity } from "@activities/shared/new-activity.model";
import { Injectable } from "@angular/core";
import { Http } from "@angular/http";
import { NewConnection } from "@connections/shared/new-connection.model";
import { AppSettingsService } from "@core/app-settings.service";
import { LoggerService } from "@core/logger.service";
import "rxjs/add/observable/of";
import "rxjs/add/observable/throw";
Expand All @@ -20,8 +38,8 @@ export class MockActivityService extends ActivityService {
private acts: Activity[] = [this.act1, this.act2, this.act3];
private newAct1 = new NewActivity();

constructor( http: Http, logger: LoggerService ) {
super(http, logger);
constructor( http: Http, appSettings: AppSettingsService, logger: LoggerService ) {
super(http, appSettings, logger);
this.act1.setId("activity1");
this.act1.setSourceConnection("activity1SrcConn");
this.act1.setTargetConnection("activity1TgtConn");
Expand Down
Expand Up @@ -356,7 +356,15 @@ export class AddConnectionWizardComponent implements OnInit {
* @returns {boolean} 'true' if connection is JDBC
*/
public get isJdbc(): boolean {
return true;
const driver = this.connectionDriverName;
let jdbc = true;
// TODO: this needs to be a hooked up to komodo call instead
if (driver === null || driver === "cassandra" || driver === "file" || driver === "google"
|| driver === "ldap" || driver === "mongodb" || driver === "salesforce"
|| driver === "salesforce-34" || driver === "solr" || driver === "webservice") {
jdbc = false;
}
return jdbc;
}

// ----------------
Expand Down
15 changes: 15 additions & 0 deletions ngapp/src/app/connections/shared/connection.model.ts
Expand Up @@ -23,6 +23,7 @@ export class Connection implements Identifiable< string > {
private keng__id: string;
private dv__jndiName: string;
private dv__driverName: string;
private dv__type: boolean;
private keng__properties: Map< string, string > = new Map< string, string >();

/**
Expand Down Expand Up @@ -99,6 +100,13 @@ export class Connection implements Identifiable< string > {
return this.dv__jndiName;
}

/**
* @returns {boolean} the jdbc status (true == jdbc)
*/
public isJdbc(): boolean {
return this.dv__type;
}

/**
* @returns {Map<string, string>} the connection properties (never null)
*/
Expand Down Expand Up @@ -127,6 +135,13 @@ export class Connection implements Identifiable< string > {
this.dv__jndiName = jndiName ? jndiName : null;
}

/**
* @param {boolean} jdbc the jdbc state
*/
public setJdbc( jdbc: boolean ): void {
this.dv__type = jdbc;
}

/**
* @param {Map<string, string>} props the connection properties (optional)
*/
Expand Down
5 changes: 3 additions & 2 deletions ngapp/src/app/connections/shared/connection.service.spec.ts
@@ -1,17 +1,18 @@
import { inject, TestBed } from "@angular/core/testing";
import { HttpModule } from "@angular/http";
import { ConnectionService } from "@connections/shared/connection.service";
import { AppSettingsService } from "@core/app-settings.service";
import { LoggerService } from "@core/logger.service";

describe("ConnectionService", () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [ HttpModule ],
providers: [ConnectionService, LoggerService]
providers: [AppSettingsService, ConnectionService, LoggerService]
});
});

it("should be created", inject([ConnectionService, LoggerService],
it("should be created", inject([ConnectionService, AppSettingsService, LoggerService],
(service: ConnectionService ) => {
expect(service).toBeTruthy();
}));
Expand Down
49 changes: 46 additions & 3 deletions ngapp/src/app/connections/shared/connection.service.ts
Expand Up @@ -19,9 +19,12 @@ import { Injectable } from "@angular/core";
import { Http } from "@angular/http";
import { Connection } from "@connections/shared/connection.model";
import { ConnectionsConstants } from "@connections/shared/connections-constants";
import { JdbcTableFilter } from "@connections/shared/jdbc-table-filter.model";
import { NewConnection } from "@connections/shared/new-connection.model";
import { SchemaInfo } from "@connections/shared/schema-info.model";
import { TemplateDefinition } from "@connections/shared/template-definition.model";
import { ApiService } from "@core/api.service";
import { AppSettingsService } from "@core/app-settings.service";
import { LoggerService } from "@core/logger.service";
import { environment } from "@environments/environment";
import { PropertyDefinition } from "@shared/property-form/property-definition.model";
Expand All @@ -32,8 +35,8 @@ export class ConnectionService extends ApiService {

private http: Http;

constructor( http: Http, logger: LoggerService ) {
super( logger );
constructor( http: Http, appSettings: AppSettingsService, logger: LoggerService ) {
super( appSettings, logger );
this.http = http;
}

Expand Down Expand Up @@ -83,7 +86,7 @@ export class ConnectionService extends ApiService {

/**
* Get the connection templates from the komodo rest interface
* @returns {Observable<Array<TemplateDefinition<any>>>}
* @returns {Observable<TemplateDefinition[]>}
*/
public getConnectionTemplates(): Observable<TemplateDefinition[]> {
return this.http
Expand All @@ -110,4 +113,44 @@ export class ConnectionService extends ApiService {
.catch( ( error ) => this.handleError( error ) );
}

/**
* Get the schema infos for a Jdbc Connection
* @param {string} connectionId
* @returns {Observable<SchemaInfo[]>}
*/
public getConnectionSchemaInfos(connectionId: string): Observable<SchemaInfo[]> {
return this.http
.get( environment.komodoTeiidUrl + "/connections/" + connectionId + "/JdbcCatalogSchema", this.getAuthRequestOptions())
.map((response) => {
const infos = response.json();
return infos.map((info) => SchemaInfo.create( info ));
})
.catch( ( error ) => this.handleError( error ) );
}

/**
* Get the tables for the specified input (connection and filters) for a Jdbc Connection
* @param {JdbcTableFilter} tableFilter
* @returns {Observable<string>}
*/
public getJdbcConnectionTables(tableFilter: JdbcTableFilter): Observable<string[]> {
return this.http
.post( environment.komodoTeiidUrl + "/connections/Tables", tableFilter, this.getAuthRequestOptions())
.map((response) => {
const info = response.json();
const tableNames = [];
let i = 1;
let tableKey = "Table" + i;
let tableName = info.Information[tableKey];
while ( tableName && tableName.length > 0 ) {
tableNames.push(tableName);
i++;
tableKey = "Table" + i;
tableName = info.Information[tableKey];
}
return tableNames;
})
.catch( ( error ) => this.handleError( error ) );
}

}
105 changes: 105 additions & 0 deletions ngapp/src/app/connections/shared/jdbc-table-filter.model.ts
@@ -0,0 +1,105 @@
/**
* @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.
*/

/**
* The JDBC table filter model.
*/
export class JdbcTableFilter {
private dataSourceName: string;
private catalogFilter = "%";
private schemaFilter = "%";
private tableFilter = "%";

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

constructor() {
// nothing to do
}

/**
* @returns {string} the connection name
*/
public getConnectionName(): string {
return this.dataSourceName;
}

/**
* @returns {string} the catalog filter
*/
public getCatalogFilter(): string {
return this.catalogFilter;
}

/**
* @returns {string} the schema filter
*/
public getSchemaFilter(): string {
return this.schemaFilter;
}

/**
* @returns {string} the table filter
*/
public getTableFilter(): string {
return this.tableFilter;
}

/**
* @param {string} name the connection name
*/
public setConnectionName( name: string ): void {
this.dataSourceName = name;
}

/**
* @param {string} filter the catalog filter
*/
public setCatalogFilter( filter?: string ): void {
this.catalogFilter = filter ? filter : "%";
}

/**
* @param {string} filter the schema filter
*/
public setSchemaFilter( filter?: string ): void {
this.schemaFilter = filter ? filter : "%";
}

/**
* @param {string} filter the table filter
*/
public setTableFilter( filter?: string ): void {
this.tableFilter = filter ? filter : "%";
}

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

}
22 changes: 20 additions & 2 deletions ngapp/src/app/connections/shared/mock-connection.service.ts
@@ -1,9 +1,27 @@
/**
* @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.
*/

import { Injectable } from "@angular/core";
import { Http } from "@angular/http";
import { Connection } from "@connections/shared/connection.model";
import { ConnectionService } from "@connections/shared/connection.service";
import { NewConnection } from "@connections/shared/new-connection.model";
import { TemplateDefinition } from "@connections/shared/template-definition.model";
import { AppSettingsService } from "@core/app-settings.service";
import { LoggerService } from "@core/logger.service";
import "rxjs/add/observable/of";
import "rxjs/add/observable/throw";
Expand All @@ -24,8 +42,8 @@ export class MockConnectionService extends ConnectionService {
private templ3 = new TemplateDefinition();
private templs: TemplateDefinition[] = [this.templ1, this.templ2, this.templ3];

constructor( http: Http, logger: LoggerService ) {
super(http, logger);
constructor( http: Http, appSettings: AppSettingsService, logger: LoggerService ) {
super(http, appSettings, logger);
this.conn1.setId("conn1");
this.conn2.setId("conn2");
this.conn3.setId("conn3");
Expand Down
6 changes: 3 additions & 3 deletions ngapp/src/app/connections/shared/new-connection.model.ts
Expand Up @@ -87,10 +87,10 @@ export class NewConnection {
}

/**
* @param {boolean} isJdbc the jdbc status (optional)
* @param {boolean} isJdbc the jdbc state
*/
public setJdbc( isJdbc?: boolean ): void {
this.jdbc = isJdbc ? isJdbc : true;
public setJdbc( isJdbc ): void {
this.jdbc = isJdbc;
}

/**
Expand Down

0 comments on commit e9e867d

Please sign in to comment.