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

Commit

Permalink
TEIIDTOOLS-312 Adds support for Mongo
Browse files Browse the repository at this point in the history
  • Loading branch information
mdrillin committed Apr 20, 2018
1 parent 41ad01b commit 7afa63a
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 6 deletions.
8 changes: 4 additions & 4 deletions ngapp/src/app/connections/shared/connection.service.ts
Expand Up @@ -183,16 +183,16 @@ export class ConnectionService extends ApiService {
const connType2: ConnectionType = new ConnectionType();
connType2.setName(ConnectionsConstants.connectionType_mysql);
connType2.setDescription(ConnectionsConstants.connectionTypeDescription_mysql);
// const connType3: ConnectionType = new ConnectionType();
// connType3.setName(ConnectionsConstants.connectionType_mongodb);
// connType3.setDescription(ConnectionsConstants.connectionTypeDescription_mongodb);
const connType3: ConnectionType = new ConnectionType();
connType3.setName(ConnectionsConstants.connectionType_mongodb);
connType3.setDescription(ConnectionsConstants.connectionTypeDescription_mongodb);
// const connType4: ConnectionType = new ConnectionType();
// connType4.setName(ConnectionsConstants.connectionType_mariadb);
// connType4.setDescription(ConnectionsConstants.connectionTypeDescription_mariadb);

connectionTypes.push(connType1);
connectionTypes.push(connType2);
// connectionTypes.push(connType3);
connectionTypes.push(connType3);
// connectionTypes.push(connType4);

return connectionTypes;
Expand Down
Expand Up @@ -432,6 +432,8 @@ export class AddDataserviceWizardComponent implements OnInit, OnDestroy {
// Dataservice basic properties from step 1
const dataservice: NewDataservice = this.dataserviceService.newDataserviceInstance(this.dataserviceName, this.dataserviceDescription);

// designate with wizard service that this dataservice is newly created.
this.wizardService.setNewlyAddedDataservice(this.dataserviceName);
const self = this;
this.dataserviceService
.createDataserviceForSingleSourceTables(dataservice, this.tableSelector.getSelectedTables())
Expand Down
5 changes: 4 additions & 1 deletion ngapp/src/app/dataservices/dataservices.component.ts
Expand Up @@ -64,7 +64,6 @@ export class DataservicesComponent extends AbstractPageComponent implements OnIn
public readonly exportFailedHeader: string = "Publishing Failed: ";
public readonly connectionsLoadedTag = "connections";

public readonly downloadInProgressHeader: string = "Downloading: ";
public readonly downloadSuccessHeader: string = "Download Succeeded: ";
public readonly downloadFailedHeader: string = "Download Failed: ";

Expand Down Expand Up @@ -702,6 +701,10 @@ export class DataservicesComponent extends AbstractPageComponent implements OnIn
// For displayed dataservices, update the Deployment State using supplied services
for ( const dService of this.filteredDataservices ) {
const serviceId = dService.getId();
// For newly added services, leave state alone until wait expires
if (serviceId === this.wizardService.getNewlyAddedDataservice()) {
continue;
}
if (stateMap && stateMap.has(serviceId)) {
dService.setServiceDeploymentState(stateMap.get(serviceId));
}
Expand Down
37 changes: 37 additions & 0 deletions ngapp/src/app/dataservices/shared/wizard.service.ts
Expand Up @@ -6,12 +6,16 @@ import { Dataservice } from "@dataservices/shared/dataservice.model";
@Injectable()
export class WizardService {

private static newlyAddedServiceWaitMillis = 5000; // Wait of 5 sec

private selectedConnectionTables: ConnectionTable[] = [];
private edit = false;
private currentConnections: Connection[] = [];
private selectedDataservice: Dataservice;
private selectedConnection: Connection;
private connectionForSchemaRegen = "";
private newlyAddedDataservice = "";
private newlyAddedDataserviceCreateTime = 0;

constructor() {
// Nothing to do
Expand Down Expand Up @@ -172,6 +176,39 @@ export class WizardService {
this.connectionForSchemaRegen = connectionName !== null ? connectionName : "";
}

/**
* Get name of a newly added dataservice. If the wait time after create has been exceeded,
* it is no longer considered a new service.
* @returns {string} the name of the newly added dataservice
*/
public getNewlyAddedDataservice(): string {
// New service not set - just return
if (this.newlyAddedDataservice.length === 0) {
return this.newlyAddedDataservice;
}

// New service set - check wait time. If wait time expired, reset name.
const waitSinceCreate = Date.now() - this.newlyAddedDataserviceCreateTime;
if (waitSinceCreate > WizardService.newlyAddedServiceWaitMillis) {
this.newlyAddedDataservice = "";
}
return this.newlyAddedDataservice;
}

/**
* Set the name of a newly added service.
* @param {string} dataserviceName the name of the newly added dataservice
*/
public setNewlyAddedDataservice(dataserviceName: string): void {
// If non-empty name, set it the name and the creation time.
if (dataserviceName !== null && dataserviceName.length > 0) {
this.newlyAddedDataservice = dataserviceName;
this.newlyAddedDataserviceCreateTime = Date.now();
} else {
this.newlyAddedDataservice = "";
}
}

/**
* Find index of the connection table in the wizard selected tables list. -1 if not found
* @param {ConnectionTable} table connection table
Expand Down
16 changes: 15 additions & 1 deletion ngapp/src/app/shared/test-data.service.ts
Expand Up @@ -40,6 +40,8 @@ export class TestDataService {
private static readonly catalogSourceId1 = "postgresql-persistent-j9vqv";
private static readonly catalogSourceId2 = "postgresql-persistent-a8xrt";
private static readonly catalogSourceId3 = "mysql-persistent-t3irv";
private static readonly catalogSourceId4 = "mongodb-persistent-x9prt";
private static readonly catalogSourceId5 = "mongodb-persistent-z8amy";

// =================================================================
// VDBs
Expand Down Expand Up @@ -191,6 +193,16 @@ export class TestDataService {
TestDataService.catalogSourceId3,
"mysql",
true );
private static catalogSourceMongo1 = TestDataService.createServiceCatalogSource(
TestDataService.catalogSourceId4,
TestDataService.catalogSourceId4,
"mongodb",
true );
private static catalogSourceMongo2 = TestDataService.createServiceCatalogSource(
TestDataService.catalogSourceId5,
TestDataService.catalogSourceId5,
"mongodb",
true );

// =================================================================
// Connections
Expand Down Expand Up @@ -906,7 +918,9 @@ export class TestDataService {
TestDataService.pgConnCatalogSource,
TestDataService.catalogSource1,
TestDataService.catalogSource2,
TestDataService.catalogSource3];
TestDataService.catalogSource3,
TestDataService.catalogSourceMongo1,
TestDataService.catalogSourceMongo2];

private connections: Connection[] = [
TestDataService.pgConn,
Expand Down

0 comments on commit 7afa63a

Please sign in to comment.