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
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);
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
39ec75917ef7 first checkin
casties
parents:
diff changeset
107
34
e19d4c5e10a1 restricted selectable options for first query step.
casties
parents: 32
diff changeset
108 getQueryModes(): QueryMode[] {
e19d4c5e10a1 restricted selectable options for first query step.
casties
parents: 32
diff changeset
109 this.queryModes = this._queryService.getQueryModes(this.index);
e19d4c5e10a1 restricted selectable options for first query step.
casties
parents: 32
diff changeset
110 return this.queryModes;
e19d4c5e10a1 restricted selectable options for first query step.
casties
parents: 32
diff changeset
111 }
e19d4c5e10a1 restricted selectable options for first query step.
casties
parents: 32
diff changeset
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
39ec75917ef7 first checkin
casties
parents:
diff changeset
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
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
148 /*
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
149 * type_is
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
150 */
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
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
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 20
diff changeset
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
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
156 /*
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
157 * relation_is
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
158 */
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
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
896ae7eefb33 fix relation type queries.
casties
parents: 39
diff changeset
161 let rel = getRelationByName(opt);
39
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
162 step = new QueryStep(this.selectedMode, {'relationType': rel});
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
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
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
165 /*
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
166 * id is
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
167 */
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
168 let val = this.queryInput;
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
169 if (val) {
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
170 step = new QueryStep(this.selectedMode, {'value': val});
32
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 20
diff changeset
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
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
173 /*
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
174 * att_contains
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
175 */
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
176 let att = this.selectedOption;
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
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
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 20
diff changeset
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
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
182 /*
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
183 * att_num_range
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
184 */
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
185 let att = this.selectedOption;
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
186 let nlo = this.queryInput;
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
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
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 20
diff changeset
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
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
192 /*
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
193 * att_contains_norm
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
194 *
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
195 * calls normalization service and submits event in callback
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
196 */
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
197 let att = this.selectedOption;
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
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
7578b21cdf2e make relation types configurable.
casties
parents: 37
diff changeset
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
39ec75917ef7 first checkin
casties
parents:
diff changeset
280 }