Skip to content

Commit

Permalink
Merge pull request #97 from polypheny/query-interface-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vogti authored Aug 5, 2024
2 parents b63d3b8 + 66bbc78 commit b7bf0bc
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 28 deletions.
4 changes: 2 additions & 2 deletions src/app/services/crud.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import {
import {ForeignKey, Uml} from '../views/uml/uml.model';
import {Validators} from '@angular/forms';
import {AdapterModel} from '../views/adapters/adapter.model';
import {QueryInterface, QueryInterfaceInformation} from '../views/query-interfaces/query-interfaces.model';
import {QueryInterface, QueryInterfaceTemplate} from '../views/query-interfaces/query-interfaces.model';
import {AlgNodeModel, Node} from '../views/querying/algebra/algebra.model';
import {WebSocket} from './webSocket';
import {Observable} from 'rxjs';
Expand Down Expand Up @@ -559,7 +559,7 @@ export class CrudService {
}

getAvailableQueryInterfaces() {
return this._http.get<QueryInterfaceInformation[]>(`${this.httpUrl}/getAvailableQueryInterfaces`);
return this._http.get<QueryInterfaceTemplate[]>(`${this.httpUrl}/getAvailableQueryInterfaces`);
}

createQueryInterface(request: any) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h2>Available Query Interfaces</h2>
</thead>
<tbody>
<tr *ngFor="let aQI of availableQueryInterfaces">
<td><strong>{{ aQI.interfaceName }}</strong></td>
<td><strong>{{ aQI.interfaceType }}</strong></td>
<td>{{aQI.description}}</td>
<td class="center">
<button cButton color="primary" size="sm" (click)="initAvailableQISettings(aQI)">Add</button>
Expand Down
33 changes: 14 additions & 19 deletions src/app/views/query-interfaces/query-interfaces.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {ToasterService} from '../../components/toast-exposer/toaster.service';
import {RelationalResult} from '../../components/data-view/models/result-set.model';
import {
QueryInterface,
QueryInterfaceInformation,
QueryInterfaceInformationRequest,
QueryInterfaceTemplate,
QueryInterfaceCreateRequest,
QueryInterfaceSetting
} from './query-interfaces.model';
import {LeftSidebarService} from '../../components/left-sidebar/left-sidebar.service';
Expand All @@ -28,7 +28,7 @@ export class QueryInterfacesComponent implements OnInit, OnDestroy {
private readonly _sidebar = inject(LeftSidebarService);

queryInterfaces: QueryInterface[];
availableQueryInterfaces: QueryInterfaceInformation[];
availableQueryInterfaces: QueryInterfaceTemplate[];
route: String;
routeListener;
private subscriptions = new Subscription();
Expand All @@ -37,7 +37,7 @@ export class QueryInterfacesComponent implements OnInit, OnDestroy {
editingQIForm: UntypedFormGroup;
deletingQI;

editingAvailableQI: QueryInterfaceInformation;
editingAvailableQI: QueryInterfaceTemplate;
editingAvailableQIForm: UntypedFormGroup;
availableQIUniqueNameForm: UntypedFormGroup;

Expand Down Expand Up @@ -85,8 +85,8 @@ export class QueryInterfacesComponent implements OnInit, OnDestroy {
getAvailableQueryInterfaces() {
this._crud.getAvailableQueryInterfaces().subscribe({
next: availableQIs => {
availableQIs.sort((a, b) => (a.interfaceName > b.interfaceName) ? 1 : -1);
this.availableQueryInterfaces = <QueryInterfaceInformation[]>availableQIs;
availableQIs.sort((a, b) => (a.interfaceType > b.interfaceType) ? 1 : -1);
this.availableQueryInterfaces = availableQIs;
}, error: err => {
console.log(err);
}
Expand Down Expand Up @@ -143,7 +143,7 @@ export class QueryInterfacesComponent implements OnInit, OnDestroy {
});
}

initAvailableQISettings(availableQI: QueryInterfaceInformation) {
initAvailableQISettings(availableQI: QueryInterfaceTemplate) {
this.editingAvailableQI = availableQI;
const fc = {};
for (const [k, v] of Object.entries(this.editingAvailableQI.availableSettings)) {
Expand Down Expand Up @@ -189,23 +189,18 @@ export class QueryInterfacesComponent implements OnInit, OnDestroy {
if (!this.availableQIUniqueNameForm.valid) {
return;
}
const deploy: QueryInterfaceInformationRequest = {
const deploy: QueryInterfaceCreateRequest = {
interfaceType: this.editingAvailableQI.interfaceType,
uniqueName: this.availableQIUniqueNameForm.controls['uniqueName'].value,
clazzName: this.editingAvailableQI.clazz,
currentSettings: {}
settings: new Map()
};
for (const [k, v] of Object.entries(this.editingAvailableQIForm.controls)) {
deploy.currentSettings[k] = v.value;
deploy.settings[k] = v.value;
}
this._crud.createQueryInterface(deploy).subscribe({
next: res => {
const result = <RelationalResult>res;
if (!result.error) {
this._toast.success('Added query interface: ' + deploy.uniqueName, result.query);
this._router.navigate(['./../'], {relativeTo: this._route});
} else {
this._toast.exception(result);
}
next: _ => {
this._toast.success('Added query interface: ' + deploy.uniqueName);
this._router.navigate(['./../'], {relativeTo: this._route});
this.QISettingsModal.hide();
}, error: err => {
this._toast.error('Could not add query interface: ' + deploy.uniqueName);
Expand Down
11 changes: 5 additions & 6 deletions src/app/views/query-interfaces/query-interfaces.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ export interface QueryInterface {
currentSettings: Map<string, string>;
}

export interface QueryInterfaceInformation {
interfaceName: string;
export interface QueryInterfaceTemplate {
interfaceType: string;
description: string;
clazz: string;
availableSettings: QueryInterfaceSetting[];
}

Expand All @@ -23,8 +22,8 @@ export interface QueryInterfaceSetting {
options: string[];
}

export interface QueryInterfaceInformationRequest {
clazzName: string;
export interface QueryInterfaceCreateRequest {
interfaceType: string;
uniqueName: string;
currentSettings: any;//Map<string, string>
settings: Map<string, string>;
}

0 comments on commit b7bf0bc

Please sign in to comment.