Mercurial > hg > ng2-query-ismi
annotate src/app/query-select.component.ts @ 57:d7c947909ab8 ng2-table
renamed query-app.module to app.module. loading query from url fragment works now.
author | casties |
---|---|
date | Wed, 29 Mar 2017 17:16:10 +0200 |
parents | b22e52a128a8 |
children | 6adf95d9a190 |
rev | line source |
---|---|
45 | 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 | 9 import {getRelationByName} from './ismi-relation-types'; |
20
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
15
diff
changeset
|
10 |
0 | 11 |
12 @Component({ | |
13 selector: 'query-select', | |
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"> 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 | 23 </option> |
24 </select> | |
10
66dce99cef4e
attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
8
diff
changeset
|
25 |
39 | 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 | 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 | 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 | 37 <option></option> |
45 | 38 <option *ngFor="let option of queryOptions" [value]="option.getName()"> |
39 | 39 {{option.getLabel()}} |
40 </option> | |
41 </select> | |
42 </span> | |
43 | |
32 | 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 | 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 | 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 | 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 | 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 | 70 </span> |
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 | 75 `, |
34 | 76 inputs: ['queryStep', 'index'], |
77 outputs: ['queryChanged'] | |
0 | 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 | 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 | 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 | 91 // output queryChanged |
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 | 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 | 100 setup() { |
8 | 101 console.log("query-select setup step=", this.queryStep); |
56
b22e52a128a8
query from url fragment works now somewhat (only for id_is).
casties
parents:
48
diff
changeset
|
102 var 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
|
103 if (step != null) { |
57
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
104 this.setQueryStep(step); |
14
7dc7ea95ca26
show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
13
diff
changeset
|
105 } |
1
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
106 } |
0 | 107 |
34 | 108 getQueryModes(): QueryMode[] { |
109 this.queryModes = this._queryService.getQueryModes(this.index); | |
110 return this.queryModes; | |
111 } | |
112 | |
3
c741a00d38de
first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
1
diff
changeset
|
113 onSelectMode(event: any) { |
1
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
114 var selected = event.target.value; |
5
b06a5d61afed
new query state stuff.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
4
diff
changeset
|
115 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
|
116 this.queryOptions = this._queryService.getQueryOptions(this.selectedMode); |
5
b06a5d61afed
new query state stuff.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
4
diff
changeset
|
117 } |
b06a5d61afed
new query state stuff.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
4
diff
changeset
|
118 |
b06a5d61afed
new query state stuff.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
4
diff
changeset
|
119 onSelectOption(event: any) { |
b06a5d61afed
new query state stuff.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
4
diff
changeset
|
120 var selected = event.target.value; |
b06a5d61afed
new query state stuff.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
4
diff
changeset
|
121 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
|
122 this.selectedOption = selected; |
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
123 this.onSubmit(); |
0 | 124 } |
10
66dce99cef4e
attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
8
diff
changeset
|
125 |
66dce99cef4e
attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
8
diff
changeset
|
126 onSubmit() { |
66dce99cef4e
attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
8
diff
changeset
|
127 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
|
128 |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
129 let step = this.getQueryStep(); |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
130 |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
131 /* |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
132 * 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
|
133 */ |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
134 if (step != null) { |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
135 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
|
136 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
|
137 } |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
138 return false; |
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 |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
141 /** |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
142 * 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
|
143 */ |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
144 getQueryStep(): QueryStep { |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
145 let step: QueryStep = null; |
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 if (this.selectedMode.id === 'type_is') { |
39 | 148 /* |
149 * type_is | |
150 */ | |
151 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
|
152 if (opt) { |
20
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
15
diff
changeset
|
153 step = new QueryStep(this.selectedMode, {'objectType': opt}); |
32 | 154 } |
57
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
155 } else if (this.selectedMode.id === 'relation_is') { |
39 | 156 /* |
157 * relation_is | |
158 */ | |
159 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
|
160 if (opt) { |
40 | 161 let rel = getRelationByName(opt); |
39 | 162 step = new QueryStep(this.selectedMode, {'relationType': rel}); |
163 } | |
57
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
164 } else if (this.selectedMode.id === 'id_is') { |
39 | 165 /* |
166 * id is | |
167 */ | |
168 let val = this.queryInput; | |
169 if (val) { | |
170 step = new QueryStep(this.selectedMode, {'value': val}); | |
32 | 171 } |
57
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
172 } else if (this.selectedMode.id === 'att_contains') { |
39 | 173 /* |
174 * att_contains | |
175 */ | |
176 let att = this.selectedOption; | |
177 let val = this.queryInput; | |
10
66dce99cef4e
attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
8
diff
changeset
|
178 if (att && val) { |
20
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
15
diff
changeset
|
179 step = new QueryStep(this.selectedMode, {'attribute': att, 'value': val}); |
32 | 180 } |
57
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
181 } else if (this.selectedMode.id === 'att_num_range') { |
39 | 182 /* |
183 * att_num_range | |
184 */ | |
185 let att = this.selectedOption; | |
186 let nlo = this.queryInput; | |
187 let nhi = this.queryInput2; | |
15
f84ff6781e57
added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
14
diff
changeset
|
188 if (att && nlo && nhi) { |
20
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
15
diff
changeset
|
189 step = new QueryStep(this.selectedMode, {'attribute': att, 'numLo': nlo, 'numHi': nhi}); |
32 | 190 } |
57
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
191 } else if (this.selectedMode.id === 'att_contains_norm') { |
39 | 192 /* |
193 * att_contains_norm | |
194 * | |
195 * calls normalization service and submits event in callback | |
196 */ | |
197 let att = this.selectedOption; | |
198 let val = this.queryInput; | |
13
98b435bb6c0c
more query work.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
11
diff
changeset
|
199 if (att && val) { |
14
7dc7ea95ca26
show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
13
diff
changeset
|
200 // run search term through normalizer |
20
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
15
diff
changeset
|
201 this._normService.fetchArabicTranslitNormalizedString(val) |
13
98b435bb6c0c
more query work.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
11
diff
changeset
|
202 .subscribe( |
98b435bb6c0c
more query work.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
11
diff
changeset
|
203 data => { |
98b435bb6c0c
more query work.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
11
diff
changeset
|
204 console.debug("openmind norm data=", data); |
20
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
15
diff
changeset
|
205 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
|
206 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
|
207 // query has changed now |
13
98b435bb6c0c
more query work.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
11
diff
changeset
|
208 this.queryChanged.emit(this._queryService.getState()); |
98b435bb6c0c
more query work.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
11
diff
changeset
|
209 }, |
98b435bb6c0c
more query work.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
11
diff
changeset
|
210 err => console.error("openmind norm error=", err), |
98b435bb6c0c
more query work.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
11
diff
changeset
|
211 () => console.debug("openmind norm query Complete") |
98b435bb6c0c
more query work.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
11
diff
changeset
|
212 ); |
57
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
213 // 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
|
214 return null; |
13
98b435bb6c0c
more query work.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
11
diff
changeset
|
215 } |
10
66dce99cef4e
attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
8
diff
changeset
|
216 } |
57
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
217 return step; |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
218 } |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
219 |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
220 /** |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
221 * 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
|
222 */ |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
223 setQueryStep(step: QueryStep) { |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
224 let mode = step.mode; |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
225 this.selectedMode = mode; |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
226 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
|
227 /* |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
228 * id_is |
39 | 229 */ |
57
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
230 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
|
231 |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
232 } 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
|
233 /* |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
234 * type_is |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
235 */ |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
236 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
|
237 this.queryOptions = [name]; |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
238 this.selectedOption = name; |
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 } 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
|
241 /* |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
242 * relation_is |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
243 */ |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
244 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
|
245 let rel = getRelationByName(name); |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
246 this.queryOptions = [rel]; |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
247 this.selectedOption = name; |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
248 |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
249 } 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
|
250 /* |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
251 * att_contains |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
252 */ |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
253 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
|
254 this.queryOptions = [name]; |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
255 this.selectedOption = name; |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
256 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
|
257 |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
258 } 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
|
259 /* |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
260 * att_num_range |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
261 */ |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
262 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
|
263 this.queryOptions = [name]; |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
264 this.selectedOption = name; |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
265 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
|
266 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
|
267 |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
268 } 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
|
269 /* |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
270 * att_contains_norm |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
271 */ |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
272 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
|
273 this.queryOptions = [name]; |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
274 this.selectedOption = name; |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
275 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
|
276 } |
57
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
277 // TODO: implement other modes |
d7c947909ab8
renamed query-app.module to app.module. loading query from url fragment works now.
casties
parents:
56
diff
changeset
|
278 this.resultInfo = step.resultInfo; |
10
66dce99cef4e
attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
8
diff
changeset
|
279 } |
0 | 280 } |