annotate src/app/query-select.component.ts @ 61:6adf95d9a190 webpack

fix missing resultInfo. add column template for WITNESS.
author Robert Casties <casties@mpiwg-berlin.mpg.de>
date Mon, 24 Apr 2017 19:39:25 +0200
parents d7c947909ab8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
45
dc4f0541f04d update to angular2-rc1. mostly working ;-(
casties
parents: 40
diff changeset
1 import {Component, Output, EventEmitter, OnInit} from '@angular/core';
1
59b7c3afcc6b first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 0
diff changeset
2
59b7c3afcc6b first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 0
diff changeset
3 import {QueryMode} from './query-mode';
5
b06a5d61afed new query state stuff.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 4
diff changeset
4 import {QueryStep} from './query-step';
7
6cd6c09032aa object type query with results!
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
5 import {QueryState} from './query-state';
1
59b7c3afcc6b first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 0
diff changeset
6
20
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 15
diff changeset
7 import {QueryService} from './query.service';
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 15
diff changeset
8 import {NormalizationService} from './normalization.service';
40
896ae7eefb33 fix relation type queries.
casties
parents: 39
diff changeset
9 import {getRelationByName} from './ismi-relation-types';
20
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 15
diff changeset
10
0
39ec75917ef7 first checkin
casties
parents:
diff changeset
11
39ec75917ef7 first checkin
casties
parents:
diff changeset
12 @Component({
39ec75917ef7 first checkin
casties
parents:
diff changeset
13 selector: 'query-select',
39ec75917ef7 first checkin
casties
parents:
diff changeset
14 template: `
14
7dc7ea95ca26 show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
15 <p *ngIf="resultInfo">&nbsp;&nbsp;&nbsp;result: {{resultInfo}}</p>
11
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
16 <div>
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
17 <form (ngSubmit)="onSubmit()">
48
f8d6f8479e77 first working version with angular 2.4 (using old table w/o pager).
casties
parents: 47
diff changeset
18 <select name="mode" (change)="onSelectMode($event)">
7
6cd6c09032aa object type query with results!
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
19 <option></option>
56
b22e52a128a8 query from url fragment works now somewhat (only for id_is).
casties
parents: 48
diff changeset
20 <option *ngFor="let mode of getQueryModes()"
b22e52a128a8 query from url fragment works now somewhat (only for id_is).
casties
parents: 48
diff changeset
21 [selected]="mode.id==selectedMode?.id" [value]="mode.id">
1
59b7c3afcc6b first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 0
diff changeset
22 {{mode.label}}
0
39ec75917ef7 first checkin
casties
parents:
diff changeset
23 </option>
39ec75917ef7 first checkin
casties
parents:
diff changeset
24 </select>
10
66dce99cef4e attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 8
diff changeset
25
39
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
26 <span *ngIf="selectedMode?.id=='type_is'">
48
f8d6f8479e77 first working version with angular 2.4 (using old table w/o pager).
casties
parents: 47
diff changeset
27 <select name="option" *ngIf="queryOptions" [ngModel]="selectedOption" (change)="onSelectOption($event)">
11
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
28 <option></option>
45
dc4f0541f04d update to angular2-rc1. mostly working ;-(
casties
parents: 40
diff changeset
29 <option *ngFor="let option of queryOptions" [value]="option">
11
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
30 {{option}}
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
31 </option>
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
32 </select>
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
33 </span>
10
66dce99cef4e attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 8
diff changeset
34
39
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
35 <span *ngIf="selectedMode?.id=='relation_is'">
48
f8d6f8479e77 first working version with angular 2.4 (using old table w/o pager).
casties
parents: 47
diff changeset
36 <select name="option" *ngIf="queryOptions" [ngModel]="selectedOption" (change)="onSelectOption($event)">
39
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
37 <option></option>
45
dc4f0541f04d update to angular2-rc1. mostly working ;-(
casties
parents: 40
diff changeset
38 <option *ngFor="let option of queryOptions" [value]="option.getName()">
39
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
39 {{option.getLabel()}}
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
40 </option>
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
41 </select>
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
42 </span>
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
43
32
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 20
diff changeset
44 <span *ngIf="selectedMode?.id=='att_contains' || selectedMode?.id=='att_contains_norm'">
48
f8d6f8479e77 first working version with angular 2.4 (using old table w/o pager).
casties
parents: 47
diff changeset
45 <select name="option" [ngModel]="selectedOption" (change)="selectedOption=$event.target.value">
11
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
46 <option></option>
45
dc4f0541f04d update to angular2-rc1. mostly working ;-(
casties
parents: 40
diff changeset
47 <option *ngFor="let option of queryOptions" [value]="option">
11
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
48 {{option}}
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
49 </option>
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
50 </select>
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
51 <span>contains</span>
48
f8d6f8479e77 first working version with angular 2.4 (using old table w/o pager).
casties
parents: 47
diff changeset
52 <input type="text" name="value" [(ngModel)]="queryInput"/>
10
66dce99cef4e attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 8
diff changeset
53 </span>
15
f84ff6781e57 added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 14
diff changeset
54
32
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 20
diff changeset
55 <span *ngIf="selectedMode?.id=='att_num_range'">
48
f8d6f8479e77 first working version with angular 2.4 (using old table w/o pager).
casties
parents: 47
diff changeset
56 <select name="option" [ngModel]="selectedOption" (change)="selectedOption=$event.target.value">
15
f84ff6781e57 added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 14
diff changeset
57 <option></option>
45
dc4f0541f04d update to angular2-rc1. mostly working ;-(
casties
parents: 40
diff changeset
58 <option *ngFor="let option of queryOptions" [value]="option">
15
f84ff6781e57 added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 14
diff changeset
59 {{option}}
f84ff6781e57 added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 14
diff changeset
60 </option>
f84ff6781e57 added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 14
diff changeset
61 </select>
f84ff6781e57 added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 14
diff changeset
62 <span>is between</span>
48
f8d6f8479e77 first working version with angular 2.4 (using old table w/o pager).
casties
parents: 47
diff changeset
63 <input type="text" name="value1" [(ngModel)]="queryInput"/>
15
f84ff6781e57 added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 14
diff changeset
64 <span>and</span>
48
f8d6f8479e77 first working version with angular 2.4 (using old table w/o pager).
casties
parents: 47
diff changeset
65 <input type="text" name="value2" [(ngModel)]="queryInput2"/>
15
f84ff6781e57 added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 14
diff changeset
66 </span>
f84ff6781e57 added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 14
diff changeset
67
32
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 20
diff changeset
68 <span *ngIf="selectedMode?.id=='id_is'">
48
f8d6f8479e77 first working version with angular 2.4 (using old table w/o pager).
casties
parents: 47
diff changeset
69 <input type="text" name="value" [(ngModel)]="queryInput"/>
32
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 20
diff changeset
70 </span>
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 20
diff changeset
71
10
66dce99cef4e attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 8
diff changeset
72 <button type="submit">Submit</button>
11
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
73 </form>
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
74 </div>
8
fa646ee46c19 more query generation.
casties
parents: 7
diff changeset
75 `,
34
e19d4c5e10a1 restricted selectable options for first query step.
casties
parents: 32
diff changeset
76 inputs: ['queryStep', 'index'],
e19d4c5e10a1 restricted selectable options for first query step.
casties
parents: 32
diff changeset
77 outputs: ['queryChanged']
0
39ec75917ef7 first checkin
casties
parents:
diff changeset
78 })
1
59b7c3afcc6b first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 0
diff changeset
79
59b7c3afcc6b first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 0
diff changeset
80 export class QuerySelectComponent implements OnInit {
20
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 15
diff changeset
81 public queryStep: string;
8
fa646ee46c19 more query generation.
casties
parents: 7
diff changeset
82 public index: number;
14
7dc7ea95ca26 show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
83 public resultInfo: string;
57
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
84 public queryModes: Array<QueryMode>;
8
fa646ee46c19 more query generation.
casties
parents: 7
diff changeset
85 public selectedMode: QueryMode;
57
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
86 public queryOptions: any[];
10
66dce99cef4e attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 8
diff changeset
87 public selectedOption: string;
66dce99cef4e attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 8
diff changeset
88 public queryInput: string;
15
f84ff6781e57 added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 14
diff changeset
89 public queryInput2: string;
1
59b7c3afcc6b first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 0
diff changeset
90
34
e19d4c5e10a1 restricted selectable options for first query step.
casties
parents: 32
diff changeset
91 // output queryChanged
e19d4c5e10a1 restricted selectable options for first query step.
casties
parents: 32
diff changeset
92 public queryChanged: EventEmitter<QueryState> = new EventEmitter<QueryState>();
7
6cd6c09032aa object type query with results!
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
93
20
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 15
diff changeset
94 constructor(private _queryService: QueryService, private _normService: NormalizationService) {}
1
59b7c3afcc6b first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 0
diff changeset
95
59b7c3afcc6b first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 0
diff changeset
96 ngOnInit() {
4
351c3df28602 work on result component.
casties
parents: 3
diff changeset
97 this.setup();
1
59b7c3afcc6b first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 0
diff changeset
98 }
59b7c3afcc6b first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 0
diff changeset
99
4
351c3df28602 work on result component.
casties
parents: 3
diff changeset
100 setup() {
8
fa646ee46c19 more query generation.
casties
parents: 7
diff changeset
101 console.log("query-select setup step=", this.queryStep);
61
6adf95d9a190 fix missing resultInfo. add column template for WITNESS.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 57
diff changeset
102 // get result info from last step
6adf95d9a190 fix missing resultInfo. add column template for WITNESS.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 57
diff changeset
103 let laststep = this._queryService.state.steps[this.index-1];
6adf95d9a190 fix missing resultInfo. add column template for WITNESS.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 57
diff changeset
104 if (laststep != null) {
6adf95d9a190 fix missing resultInfo. add column template for WITNESS.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 57
diff changeset
105 this.resultInfo = laststep.resultInfo;
6adf95d9a190 fix missing resultInfo. add column template for WITNESS.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 57
diff changeset
106 }
6adf95d9a190 fix missing resultInfo. add column template for WITNESS.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 57
diff changeset
107 // set up current step
6adf95d9a190 fix missing resultInfo. add column template for WITNESS.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 57
diff changeset
108 let step = this._queryService.state.steps[this.index]; // i-1?
14
7dc7ea95ca26 show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
109 if (step != null) {
57
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
110 this.setQueryStep(step);
14
7dc7ea95ca26 show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
111 }
1
59b7c3afcc6b first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 0
diff changeset
112 }
0
39ec75917ef7 first checkin
casties
parents:
diff changeset
113
34
e19d4c5e10a1 restricted selectable options for first query step.
casties
parents: 32
diff changeset
114 getQueryModes(): QueryMode[] {
e19d4c5e10a1 restricted selectable options for first query step.
casties
parents: 32
diff changeset
115 this.queryModes = this._queryService.getQueryModes(this.index);
e19d4c5e10a1 restricted selectable options for first query step.
casties
parents: 32
diff changeset
116 return this.queryModes;
e19d4c5e10a1 restricted selectable options for first query step.
casties
parents: 32
diff changeset
117 }
e19d4c5e10a1 restricted selectable options for first query step.
casties
parents: 32
diff changeset
118
3
c741a00d38de first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
119 onSelectMode(event: any) {
1
59b7c3afcc6b first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 0
diff changeset
120 var selected = event.target.value;
5
b06a5d61afed new query state stuff.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 4
diff changeset
121 this.selectedMode = this.queryModes.find(mode => mode.id === selected);
10
66dce99cef4e attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 8
diff changeset
122 this.queryOptions = this._queryService.getQueryOptions(this.selectedMode);
5
b06a5d61afed new query state stuff.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 4
diff changeset
123 }
b06a5d61afed new query state stuff.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 4
diff changeset
124
b06a5d61afed new query state stuff.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 4
diff changeset
125 onSelectOption(event: any) {
b06a5d61afed new query state stuff.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 4
diff changeset
126 var selected = event.target.value;
b06a5d61afed new query state stuff.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 4
diff changeset
127 console.debug("selected option:", selected);
11
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
128 this.selectedOption = selected;
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
129 this.onSubmit();
0
39ec75917ef7 first checkin
casties
parents:
diff changeset
130 }
10
66dce99cef4e attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 8
diff changeset
131
66dce99cef4e attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 8
diff changeset
132 onSubmit() {
66dce99cef4e attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 8
diff changeset
133 console.debug("Submit! selectedMode=", this.selectedMode, " selectedOption=", this.selectedOption, " queryInput=", this.queryInput);
57
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
134
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
135 let step = this.getQueryStep();
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
136
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
137 /*
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
138 * set step and submit change event
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
139 */
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
140 if (step != null) {
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
141 this._queryService.setQueryStep(this.index, step);
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
142 this.queryChanged.emit(this._queryService.getState());
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
143 }
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
144 return false;
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
145 }
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
146
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
147 /**
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
148 * Returns QueryStep from current form state.
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
149 */
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
150 getQueryStep(): QueryStep {
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
151 let step: QueryStep = null;
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
152
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
153 if (this.selectedMode.id === 'type_is') {
39
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
154 /*
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
155 * type_is
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
156 */
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
157 let opt = this.selectedOption;
11
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
158 if (opt) {
20
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 15
diff changeset
159 step = new QueryStep(this.selectedMode, {'objectType': opt});
32
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 20
diff changeset
160 }
57
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
161 } else if (this.selectedMode.id === 'relation_is') {
39
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
162 /*
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
163 * relation_is
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
164 */
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
165 let opt = this.selectedOption;
11
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
166 if (opt) {
40
896ae7eefb33 fix relation type queries.
casties
parents: 39
diff changeset
167 let rel = getRelationByName(opt);
39
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
168 step = new QueryStep(this.selectedMode, {'relationType': rel});
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
169 }
57
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
170 } else if (this.selectedMode.id === 'id_is') {
39
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
171 /*
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
172 * id is
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
173 */
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
174 let val = this.queryInput;
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
175 if (val) {
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
176 step = new QueryStep(this.selectedMode, {'value': val});
32
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 20
diff changeset
177 }
57
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
178 } else if (this.selectedMode.id === 'att_contains') {
39
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
179 /*
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
180 * att_contains
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
181 */
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
182 let att = this.selectedOption;
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
183 let val = this.queryInput;
10
66dce99cef4e attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 8
diff changeset
184 if (att && val) {
20
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 15
diff changeset
185 step = new QueryStep(this.selectedMode, {'attribute': att, 'value': val});
32
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 20
diff changeset
186 }
57
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
187 } else if (this.selectedMode.id === 'att_num_range') {
39
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
188 /*
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
189 * att_num_range
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
190 */
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
191 let att = this.selectedOption;
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
192 let nlo = this.queryInput;
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
193 let nhi = this.queryInput2;
15
f84ff6781e57 added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 14
diff changeset
194 if (att && nlo && nhi) {
20
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 15
diff changeset
195 step = new QueryStep(this.selectedMode, {'attribute': att, 'numLo': nlo, 'numHi': nhi});
32
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 20
diff changeset
196 }
57
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
197 } else if (this.selectedMode.id === 'att_contains_norm') {
39
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
198 /*
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
199 * att_contains_norm
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
200 *
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
201 * calls normalization service and submits event in callback
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
202 */
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
203 let att = this.selectedOption;
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
204 let val = this.queryInput;
13
98b435bb6c0c more query work.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
205 if (att && val) {
14
7dc7ea95ca26 show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
206 // run search term through normalizer
20
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 15
diff changeset
207 this._normService.fetchArabicTranslitNormalizedString(val)
13
98b435bb6c0c more query work.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
208 .subscribe(
98b435bb6c0c more query work.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
209 data => {
98b435bb6c0c more query work.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
210 console.debug("openmind norm data=", data);
20
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 15
diff changeset
211 step = new QueryStep(this.selectedMode, {'attribute': att, 'value': val, 'normValue': data.normalized_text});
13
98b435bb6c0c more query work.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
212 this._queryService.setQueryStep(this.index, step);
14
7dc7ea95ca26 show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
213 // query has changed now
13
98b435bb6c0c more query work.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
214 this.queryChanged.emit(this._queryService.getState());
98b435bb6c0c more query work.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
215 },
98b435bb6c0c more query work.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
216 err => console.error("openmind norm error=", err),
98b435bb6c0c more query work.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
217 () => console.debug("openmind norm query Complete")
98b435bb6c0c more query work.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
218 );
57
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
219 // query has not been set yet (gets set in callback)
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
220 return null;
13
98b435bb6c0c more query work.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
221 }
10
66dce99cef4e attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 8
diff changeset
222 }
57
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
223 return step;
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
224 }
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
225
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
226 /**
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
227 * Sets form state from given QueryStep.
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
228 */
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
229 setQueryStep(step: QueryStep) {
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
230 let mode = step.mode;
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
231 this.selectedMode = mode;
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
232 if (mode.id === 'id_is') {
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
233 /*
61
6adf95d9a190 fix missing resultInfo. add column template for WITNESS.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 57
diff changeset
234 * id_is
6adf95d9a190 fix missing resultInfo. add column template for WITNESS.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 57
diff changeset
235 */
57
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
236 this.queryInput = step.params.value;
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
237
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
238 } else if (mode.id === 'type_is') {
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
239 /*
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
240 * type_is
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
241 */
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
242 let name = step.params.objectType;
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
243 this.queryOptions = [name];
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
244 this.selectedOption = name;
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
245
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
246 } else if (this.selectedMode.id === 'relation_is') {
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
247 /*
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
248 * relation_is
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
249 */
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
250 let name = step.params.relationType.name
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
251 let rel = getRelationByName(name);
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
252 this.queryOptions = [rel];
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
253 this.selectedOption = name;
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
254
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
255 } else if (this.selectedMode.id === 'att_contains') {
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
256 /*
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
257 * att_contains
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
258 */
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
259 let name = step.params.attribute
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
260 this.queryOptions = [name];
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
261 this.selectedOption = name;
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
262 this.queryInput = step.params.value;
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
263
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
264 } else if (this.selectedMode.id === 'att_num_range') {
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
265 /*
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
266 * att_num_range
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
267 */
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
268 let name = step.params.attribute
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
269 this.queryOptions = [name];
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
270 this.selectedOption = name;
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
271 this.queryInput = step.params.numLo;
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
272 this.queryInput2 = step.params.numHi;
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
273
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
274 } else if (this.selectedMode.id === 'att_contains_norm') {
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
275 /*
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
276 * att_contains_norm
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
277 */
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
278 let name = step.params.attribute
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
279 this.queryOptions = [name];
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
280 this.selectedOption = name;
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
281 this.queryInput = step.params.value;
11
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
282 }
57
d7c947909ab8 renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents: 56
diff changeset
283 // TODO: implement other modes
10
66dce99cef4e attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 8
diff changeset
284 }
0
39ec75917ef7 first checkin
casties
parents:
diff changeset
285 }