annotate src/app/query.service.ts @ 55:308c96f734c8 ng2-table

first steps to importing state from URL.
author casties
date Mon, 27 Mar 2017 14:17:55 +0200
parents b65a031c4967
children 7b9d616695d3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
45
dc4f0541f04d update to angular2-rc1. mostly working ;-(
casties
parents: 41
diff changeset
1 import {Injectable} from '@angular/core';
dc4f0541f04d update to angular2-rc1. mostly working ;-(
casties
parents: 41
diff changeset
2 import {Http, Headers} from '@angular/http';
1
59b7c3afcc6b first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff changeset
3
59b7c3afcc6b first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff changeset
4 import 'rxjs/Rx'; // import all RxJS operators
22
9343e43a17d1 build with jspm now.
casties
parents: 21
diff changeset
5 //import 'rxjs/add/operator/map';
1
59b7c3afcc6b first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff changeset
6
41
5353b2dffb0f added local configuration file app/app-config.ts.
casties
parents: 40
diff changeset
7 import {NEO4J_BASE_URL, NEO4J_AUTHENTICATION} from './app-config';
34
e19d4c5e10a1 restricted selectable options for first query step.
casties
parents: 32
diff changeset
8 import {QueryMode, QUERY_MODES, FIRST_QUERY_MODES} from './query-mode';
5
b06a5d61afed new query state stuff.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 3
diff changeset
9 import {QueryState} from './query-state';
b06a5d61afed new query state stuff.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 3
diff changeset
10 import {QueryStep} from './query-step';
30
193271b6b9d2 configure attributes per result type. select number of items per result page.
casties
parents: 25
diff changeset
11 import {getResultType} from './result-type';
193271b6b9d2 configure attributes per result type. select number of items per result page.
casties
parents: 25
diff changeset
12 import {ISMI_RESULT_TYPES} from './ismi-result-types';
39
7578b21cdf2e make relation types configurable.
casties
parents: 36
diff changeset
13 import {getRelationType} from './ismi-relation-types';
1
59b7c3afcc6b first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff changeset
14
59b7c3afcc6b first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff changeset
15 @Injectable()
59b7c3afcc6b first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff changeset
16 export class QueryService {
59b7c3afcc6b first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff changeset
17
32
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 30
diff changeset
18 public typeAttribute = '_type';
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 30
diff changeset
19 public excludedAttributes = {};
7
6cd6c09032aa object type query with results!
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
20 public state: QueryState;
20
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
21 public objectTypes: string[];
2
80270f5a5735 more tinkering.
casties
parents: 1
diff changeset
22
5
b06a5d61afed new query state stuff.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 3
diff changeset
23 constructor(private _http: Http) {
20
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
24 // init query state
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
25 this.state = new QueryState();
7
6cd6c09032aa object type query with results!
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
26 }
6cd6c09032aa object type query with results!
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
27
55
308c96f734c8 first steps to importing state from URL.
casties
parents: 47
diff changeset
28 setup(newStateString: string) {
308c96f734c8 first steps to importing state from URL.
casties
parents: 47
diff changeset
29 // get list of object types
20
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
30 this.setupObjectTypes();
55
308c96f734c8 first steps to importing state from URL.
casties
parents: 47
diff changeset
31 // get state from string
308c96f734c8 first steps to importing state from URL.
casties
parents: 47
diff changeset
32 if (newStateString) {
308c96f734c8 first steps to importing state from URL.
casties
parents: 47
diff changeset
33 this.state.setStateFromString(newStateString);
308c96f734c8 first steps to importing state from URL.
casties
parents: 47
diff changeset
34 }
8
fa646ee46c19 more query generation.
casties
parents: 7
diff changeset
35 }
fa646ee46c19 more query generation.
casties
parents: 7
diff changeset
36
7
6cd6c09032aa object type query with results!
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
37 getState() {
6cd6c09032aa object type query with results!
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
38 return this.state;
5
b06a5d61afed new query state stuff.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 3
diff changeset
39 }
1
59b7c3afcc6b first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff changeset
40
34
e19d4c5e10a1 restricted selectable options for first query step.
casties
parents: 32
diff changeset
41 getQueryModes(index: number): QueryMode[] {
e19d4c5e10a1 restricted selectable options for first query step.
casties
parents: 32
diff changeset
42 if (index == 0) {
e19d4c5e10a1 restricted selectable options for first query step.
casties
parents: 32
diff changeset
43 return FIRST_QUERY_MODES;
e19d4c5e10a1 restricted selectable options for first query step.
casties
parents: 32
diff changeset
44 } else {
e19d4c5e10a1 restricted selectable options for first query step.
casties
parents: 32
diff changeset
45 return QUERY_MODES;
e19d4c5e10a1 restricted selectable options for first query step.
casties
parents: 32
diff changeset
46 }
1
59b7c3afcc6b first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff changeset
47 }
59b7c3afcc6b first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff changeset
48
20
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
49 /**
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
50 * return the first set of options for the given query mode.
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
51 */
3
c741a00d38de first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 2
diff changeset
52 getQueryOptions(queryMode: QueryMode) {
47
b65a031c4967 first step to angular2-final (2.4) version of the query browser.
casties
parents: 45
diff changeset
53 let options: any[] = [];
18
65bb467abcc6 inverse relations are now generated on the fly.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
54 if (queryMode == null) return options;
11
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
55 if (queryMode.id === 'type_is') {
20
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
56 options = this.objectTypes;
11
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
57 } else if (queryMode.id === 'relation_is') {
21
930fe7460f6b result table shows all attributes now.
casties
parents: 20
diff changeset
58 options = this.state.resultRelations;
11
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
59 } else if (queryMode.id === 'att_contains') {
21
930fe7460f6b result table shows all attributes now.
casties
parents: 20
diff changeset
60 options = this.filterAttributes(this.state.resultAttributes);
11
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
61 } else if (queryMode.id === 'att_contains_norm') {
21
930fe7460f6b result table shows all attributes now.
casties
parents: 20
diff changeset
62 options = this.filterAttributes(this.state.resultAttributes, true);
15
f84ff6781e57 added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 14
diff changeset
63 } else if (queryMode.id === 'att_num_range') {
21
930fe7460f6b result table shows all attributes now.
casties
parents: 20
diff changeset
64 options = this.filterAttributes(this.state.resultAttributes);
1
59b7c3afcc6b first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff changeset
65 }
5
b06a5d61afed new query state stuff.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 3
diff changeset
66 console.debug("getQueryOptions returns: ", options);
b06a5d61afed new query state stuff.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 3
diff changeset
67 return options;
1
59b7c3afcc6b first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff changeset
68 }
59b7c3afcc6b first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff changeset
69
20
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
70 /**
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
71 * fetch all object types from Neo4j and store in this.objectTypes.
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
72 */
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
73 setupObjectTypes() {
41
5353b2dffb0f added local configuration file app/app-config.ts.
casties
parents: 40
diff changeset
74 let query = `MATCH (n) WITH DISTINCT labels(n) AS labels
3
c741a00d38de first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 2
diff changeset
75 UNWIND labels AS label
c741a00d38de first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 2
diff changeset
76 RETURN DISTINCT label ORDER BY label`;
c741a00d38de first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 2
diff changeset
77
41
5353b2dffb0f added local configuration file app/app-config.ts.
casties
parents: 40
diff changeset
78 let res = this.fetchCypherResults([query]);
3
c741a00d38de first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 2
diff changeset
79 res.subscribe(
c741a00d38de first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 2
diff changeset
80 data => {
c741a00d38de first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 2
diff changeset
81 console.debug("neo4j data=", data);
55
308c96f734c8 first steps to importing state from URL.
casties
parents: 47
diff changeset
82 this.objectTypes = data.results[0].data
308c96f734c8 first steps to importing state from URL.
casties
parents: 47
diff changeset
83 .map(elem => elem.row[0])
308c96f734c8 first steps to importing state from URL.
casties
parents: 47
diff changeset
84 .filter(elem => elem[0] != "_");
20
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
85 console.debug("object types=", this.objectTypes);
3
c741a00d38de first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 2
diff changeset
86 },
c741a00d38de first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 2
diff changeset
87 err => console.error("neo4j error=", err),
c741a00d38de first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 2
diff changeset
88 () => console.debug('neo4j query Complete')
c741a00d38de first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 2
diff changeset
89 );
c741a00d38de first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 2
diff changeset
90 }
c741a00d38de first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 2
diff changeset
91
20
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
92 /**
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
93 * Set the query step at index.
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
94 */
6
9f5473536a98 more query generation.
casties
parents: 5
diff changeset
95 setQueryStep(index: number, step: QueryStep) {
7
6cd6c09032aa object type query with results!
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
96 this.state.steps[index] = step;
6
9f5473536a98 more query generation.
casties
parents: 5
diff changeset
97 }
9f5473536a98 more query generation.
casties
parents: 5
diff changeset
98
20
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
99 /**
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
100 * Create the cypher queries for the current query state.
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
101 *
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
102 * Updates the queries for results, attributes and relations.
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
103 */
6
9f5473536a98 more query generation.
casties
parents: 5
diff changeset
104 createCypherQuery() {
41
5353b2dffb0f added local configuration file app/app-config.ts.
casties
parents: 40
diff changeset
105 let queryMatch = '';
5353b2dffb0f added local configuration file app/app-config.ts.
casties
parents: 40
diff changeset
106 let queryWhere = '';
5353b2dffb0f added local configuration file app/app-config.ts.
casties
parents: 40
diff changeset
107 let queryReturn = '';
5353b2dffb0f added local configuration file app/app-config.ts.
casties
parents: 40
diff changeset
108 let queryParams = {};
5353b2dffb0f added local configuration file app/app-config.ts.
casties
parents: 40
diff changeset
109 let resultQuery = '';
5353b2dffb0f added local configuration file app/app-config.ts.
casties
parents: 40
diff changeset
110 let attributesQuery = '';
5353b2dffb0f added local configuration file app/app-config.ts.
casties
parents: 40
diff changeset
111 let outRelsQuery = '';
5353b2dffb0f added local configuration file app/app-config.ts.
casties
parents: 40
diff changeset
112 let inRelsQuery = '';
5353b2dffb0f added local configuration file app/app-config.ts.
casties
parents: 40
diff changeset
113 let returnType = '';
5353b2dffb0f added local configuration file app/app-config.ts.
casties
parents: 40
diff changeset
114 let nIdx = 1;
11
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
115 this.state.steps.forEach((step, stepIdx) => {
41
5353b2dffb0f added local configuration file app/app-config.ts.
casties
parents: 40
diff changeset
116 let mode = step.mode.id;
5353b2dffb0f added local configuration file app/app-config.ts.
casties
parents: 40
diff changeset
117 let params = step.params;
20
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
118
14
7dc7ea95ca26 show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
119 /*
7dc7ea95ca26 show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
120 * step: object type is
7dc7ea95ca26 show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
121 */
20
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
122 if (mode === 'type_is') {
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
123 queryMatch = `MATCH (n${nIdx}:${params.objectType})`;
10
66dce99cef4e attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
124 queryWhere = '';
11
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
125 queryReturn = `RETURN n${nIdx}`;
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
126 returnType = 'node';
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
127 }
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
128
14
7dc7ea95ca26 show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
129 /*
32
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 30
diff changeset
130 * step: object id is
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 30
diff changeset
131 */
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 30
diff changeset
132 if (mode === 'id_is') {
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 30
diff changeset
133 if (!queryMatch) {
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 30
diff changeset
134 // first step - use match clause
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 30
diff changeset
135 queryMatch = `MATCH (n${nIdx} {ismi_id: {att_val${stepIdx}}})`;
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 30
diff changeset
136 queryParams[`att_val${stepIdx}`] = parseInt(params.value, 10);
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 30
diff changeset
137 queryWhere = '';
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 30
diff changeset
138 queryReturn = `RETURN n${nIdx}`;
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 30
diff changeset
139 returnType = 'node';
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 30
diff changeset
140 } else {
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 30
diff changeset
141 // use where clause
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 30
diff changeset
142 if (!queryWhere) {
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 30
diff changeset
143 queryWhere = 'WHERE ';
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 30
diff changeset
144 } else {
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 30
diff changeset
145 queryWhere += ' AND ';
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 30
diff changeset
146 }
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 30
diff changeset
147 queryWhere += `n${nIdx}.ismi_id = {att_val${stepIdx}}`;
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 30
diff changeset
148 queryParams[`att_val${stepIdx}`] = parseInt(params.value, 10);
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 30
diff changeset
149 }
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 30
diff changeset
150 }
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 30
diff changeset
151
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 30
diff changeset
152 /*
14
7dc7ea95ca26 show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
153 * step: relation type is
7dc7ea95ca26 show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
154 */
20
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
155 if (mode === 'relation_is') {
11
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
156 nIdx += 1;
39
7578b21cdf2e make relation types configurable.
casties
parents: 36
diff changeset
157 let rel = params.relationType;
7578b21cdf2e make relation types configurable.
casties
parents: 36
diff changeset
158 if (rel.isOutgoing()) {
40
896ae7eefb33 fix relation type queries.
casties
parents: 39
diff changeset
159 queryMatch += `-[:\`${rel.getRelType()}\`]->(n${nIdx})`;
39
7578b21cdf2e make relation types configurable.
casties
parents: 36
diff changeset
160 } else {
18
65bb467abcc6 inverse relations are now generated on the fly.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
161 // inverse relation
40
896ae7eefb33 fix relation type queries.
casties
parents: 39
diff changeset
162 queryMatch += `<-[:\`${rel.getRelType()}\`]-(n${nIdx})`;
18
65bb467abcc6 inverse relations are now generated on the fly.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
163 }
39
7578b21cdf2e make relation types configurable.
casties
parents: 36
diff changeset
164 queryReturn = `RETURN DISTINCT n${nIdx}`;
8
fa646ee46c19 more query generation.
casties
parents: 7
diff changeset
165 returnType = 'node';
fa646ee46c19 more query generation.
casties
parents: 7
diff changeset
166 }
10
66dce99cef4e attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
167
14
7dc7ea95ca26 show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
168 /*
7dc7ea95ca26 show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
169 * step: attribute contains(_norm)
7dc7ea95ca26 show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
170 */
20
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
171 if (mode === 'att_contains' || mode === 'att_contains_norm') {
11
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
172 if (!queryWhere) {
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
173 queryWhere = 'WHERE ';
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
174 } else {
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
175 queryWhere += ' AND ';
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
176 }
20
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
177 if (params.attribute === 'ismi_id') {
14
7dc7ea95ca26 show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
178 // ismi_id is integer
7dc7ea95ca26 show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
179 queryWhere += `n${nIdx}.ismi_id = {att_val${stepIdx}}`;
20
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
180 queryParams[`att_val${stepIdx}`] = parseInt(params.value, 10);
11
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
181 } else {
20
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
182 if (mode === 'att_contains_norm') {
14
7dc7ea95ca26 show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
183 // match _n_attribute with normValue
20
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
184 queryWhere += `lower(n${nIdx}._n_${params.attribute}) CONTAINS lower({att_val${stepIdx}})`;
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
185 queryParams[`att_val${stepIdx}`] = params.normValue;
14
7dc7ea95ca26 show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
186 } else {
20
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
187 queryWhere += `lower(n${nIdx}.${params.attribute}) CONTAINS lower({att_val${stepIdx}})`;
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
188 queryParams[`att_val${stepIdx}`] = params.value;
14
7dc7ea95ca26 show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
189 }
11
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
190 }
10
66dce99cef4e attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
191 }
66dce99cef4e attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
192
15
f84ff6781e57 added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 14
diff changeset
193 /*
f84ff6781e57 added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 14
diff changeset
194 * step: attribute number range
f84ff6781e57 added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 14
diff changeset
195 */
20
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
196 if (mode === 'att_num_range') {
15
f84ff6781e57 added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 14
diff changeset
197 if (!queryWhere) {
f84ff6781e57 added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 14
diff changeset
198 queryWhere = 'WHERE ';
f84ff6781e57 added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 14
diff changeset
199 } else {
f84ff6781e57 added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 14
diff changeset
200 queryWhere += ' AND ';
f84ff6781e57 added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 14
diff changeset
201 }
20
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
202 queryWhere += `toint(n${nIdx}.${params.attribute}) >= toint({att_nlo${stepIdx}})`
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
203 + ` AND toint(n${nIdx}.${params.attribute}) <= toint({att_nhi${stepIdx}})`;
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
204 queryParams[`att_nlo${stepIdx}`] = params.numLo;
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
205 queryParams[`att_nhi${stepIdx}`] = params.numHi;
15
f84ff6781e57 added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 14
diff changeset
206 }
f84ff6781e57 added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 14
diff changeset
207
9
402c7229dc7c more query generation.
casties
parents: 8
diff changeset
208 });
18
65bb467abcc6 inverse relations are now generated on the fly.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
209 // compose query
32
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 30
diff changeset
210 resultQuery = queryMatch + (queryWhere ? '\n'+queryWhere : '') + '\n' + queryReturn;
18
65bb467abcc6 inverse relations are now generated on the fly.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
211 // compose query for attributes of result
15
f84ff6781e57 added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 14
diff changeset
212 attributesQuery = queryMatch + ' ' + queryWhere + ` WITH DISTINCT keys(n${nIdx}) AS atts`
f84ff6781e57 added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 14
diff changeset
213 + ` UNWIND atts AS att RETURN DISTINCT att ORDER BY att`;
18
65bb467abcc6 inverse relations are now generated on the fly.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
214 // compose query for relations of result
36
e8dc6a4c6773 only show possible incoming/outgoing relation types.
casties
parents: 35
diff changeset
215 outRelsQuery = queryMatch + '-[r]->() ' + queryWhere + ' RETURN DISTINCT type(r)';
e8dc6a4c6773 only show possible incoming/outgoing relation types.
casties
parents: 35
diff changeset
216 inRelsQuery = queryMatch + '<-[r]-() ' + queryWhere + ' RETURN DISTINCT type(r)';
10
66dce99cef4e attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
217 this.state.resultCypherQuery = resultQuery;
11
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
218 this.state.cypherQueryParams = queryParams;
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
219 this.state.attributesCypherQuery = attributesQuery;
36
e8dc6a4c6773 only show possible incoming/outgoing relation types.
casties
parents: 35
diff changeset
220 this.state.outRelsCypherQuery = outRelsQuery;
e8dc6a4c6773 only show possible incoming/outgoing relation types.
casties
parents: 35
diff changeset
221 this.state.inRelsCypherQuery = inRelsQuery;
7
6cd6c09032aa object type query with results!
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
222 this.state.resultTypes = returnType;
6cd6c09032aa object type query with results!
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
223 }
6cd6c09032aa object type query with results!
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
224
20
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
225 /**
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
226 * Create and run the cypher queries for the current query state.
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
227 *
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
228 * Updates the results and nextQuery attributes and relations.
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
229 */
40
896ae7eefb33 fix relation type queries.
casties
parents: 39
diff changeset
230 runQuery() {
7
6cd6c09032aa object type query with results!
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
231 this.createCypherQuery();
13
98b435bb6c0c more query work.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 12
diff changeset
232 this.state.resultInfo = 'loading...';
16
7d82ca32833c omit some attributes from list.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
233 /*
7d82ca32833c omit some attributes from list.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
234 * run query for result table
7d82ca32833c omit some attributes from list.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
235 */
41
5353b2dffb0f added local configuration file app/app-config.ts.
casties
parents: 40
diff changeset
236 let queries = [this.state.resultCypherQuery];
5353b2dffb0f added local configuration file app/app-config.ts.
casties
parents: 40
diff changeset
237 let params = [this.state.cypherQueryParams];
17
f6af2c8347de send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 16
diff changeset
238 if (this.state.attributesCypherQuery) {
f6af2c8347de send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 16
diff changeset
239 queries.push(this.state.attributesCypherQuery);
f6af2c8347de send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 16
diff changeset
240 params.push(this.state.cypherQueryParams);
f6af2c8347de send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 16
diff changeset
241 }
36
e8dc6a4c6773 only show possible incoming/outgoing relation types.
casties
parents: 35
diff changeset
242 if (this.state.outRelsCypherQuery) {
e8dc6a4c6773 only show possible incoming/outgoing relation types.
casties
parents: 35
diff changeset
243 queries.push(this.state.outRelsCypherQuery);
e8dc6a4c6773 only show possible incoming/outgoing relation types.
casties
parents: 35
diff changeset
244 params.push(this.state.cypherQueryParams);
e8dc6a4c6773 only show possible incoming/outgoing relation types.
casties
parents: 35
diff changeset
245 }
e8dc6a4c6773 only show possible incoming/outgoing relation types.
casties
parents: 35
diff changeset
246 if (this.state.inRelsCypherQuery) {
e8dc6a4c6773 only show possible incoming/outgoing relation types.
casties
parents: 35
diff changeset
247 queries.push(this.state.inRelsCypherQuery);
17
f6af2c8347de send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 16
diff changeset
248 params.push(this.state.cypherQueryParams);
f6af2c8347de send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 16
diff changeset
249 }
41
5353b2dffb0f added local configuration file app/app-config.ts.
casties
parents: 40
diff changeset
250 let res = this.fetchCypherResults(queries, params);
17
f6af2c8347de send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 16
diff changeset
251 res.subscribe(
7
6cd6c09032aa object type query with results!
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
252 data => {
10
66dce99cef4e attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
253 console.debug("neo4j result data=", data);
41
5353b2dffb0f added local configuration file app/app-config.ts.
casties
parents: 40
diff changeset
254 let resIdx = 0;
17
f6af2c8347de send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 16
diff changeset
255 /*
f6af2c8347de send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 16
diff changeset
256 * results for result table
f6af2c8347de send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 16
diff changeset
257 */
f6af2c8347de send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 16
diff changeset
258 this.state.results = data.results[resIdx].data.map(elem => elem.row[0]);
7
6cd6c09032aa object type query with results!
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
259 this.state.numResults = this.state.results.length;
11
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
260 // count all types
32
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 30
diff changeset
261 let resTypes = {};
11
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
262 this.state.results.forEach((r) => {
32
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 30
diff changeset
263 let t = r[this.typeAttribute];
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 30
diff changeset
264 if (resTypes[t] == null) {
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 30
diff changeset
265 resTypes[t] = 1;
11
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
266 } else {
32
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 30
diff changeset
267 resTypes[t] += 1;
11
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
268 }
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
269 });
32
4c046f3244ec new 'id_is' query type. new '_type' attribute.
casties
parents: 30
diff changeset
270 let info = '';
41
5353b2dffb0f added local configuration file app/app-config.ts.
casties
parents: 40
diff changeset
271 for (let t in resTypes) {
11
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
272 info += t + '(' + resTypes[t] + ') ';
6989cd00e8d7 relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
273 }
14
7dc7ea95ca26 show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
274 info = info.substr(0, info.length-1);
7dc7ea95ca26 show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
275 this.state.resultInfo = info;
7dc7ea95ca26 show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
276 // save info also in last step
7dc7ea95ca26 show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
277 this.state.steps[this.state.steps.length-1].resultInfo = info;
17
f6af2c8347de send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 16
diff changeset
278 /*
f6af2c8347de send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 16
diff changeset
279 * results for attribute list
f6af2c8347de send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 16
diff changeset
280 */
f6af2c8347de send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 16
diff changeset
281 if (this.state.attributesCypherQuery) {
f6af2c8347de send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 16
diff changeset
282 resIdx += 1;
30
193271b6b9d2 configure attributes per result type. select number of items per result page.
casties
parents: 25
diff changeset
283 let atts = data.results[resIdx].data.map(elem => elem.row[0]);
193271b6b9d2 configure attributes per result type. select number of items per result page.
casties
parents: 25
diff changeset
284 this.state.resultAttributes = atts;
193271b6b9d2 configure attributes per result type. select number of items per result page.
casties
parents: 25
diff changeset
285 // the following assumes only one type in the result
193271b6b9d2 configure attributes per result type. select number of items per result page.
casties
parents: 25
diff changeset
286 for (let t in resTypes) {
193271b6b9d2 configure attributes per result type. select number of items per result page.
casties
parents: 25
diff changeset
287 this.state.resultType = getResultType(t, ISMI_RESULT_TYPES);
193271b6b9d2 configure attributes per result type. select number of items per result page.
casties
parents: 25
diff changeset
288 break;
193271b6b9d2 configure attributes per result type. select number of items per result page.
casties
parents: 25
diff changeset
289 }
193271b6b9d2 configure attributes per result type. select number of items per result page.
casties
parents: 25
diff changeset
290 this.state.resultColumns = this.state.resultType.getColumns(atts);
17
f6af2c8347de send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 16
diff changeset
291 }
f6af2c8347de send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 16
diff changeset
292 /*
f6af2c8347de send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 16
diff changeset
293 * results for relations list
f6af2c8347de send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 16
diff changeset
294 */
36
e8dc6a4c6773 only show possible incoming/outgoing relation types.
casties
parents: 35
diff changeset
295 if (this.state.outRelsCypherQuery) {
e8dc6a4c6773 only show possible incoming/outgoing relation types.
casties
parents: 35
diff changeset
296 // outgoing aka forward relations
17
f6af2c8347de send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 16
diff changeset
297 resIdx += 1;
36
e8dc6a4c6773 only show possible incoming/outgoing relation types.
casties
parents: 35
diff changeset
298 let rels = data.results[resIdx].data.map(elem => elem.row[0])
39
7578b21cdf2e make relation types configurable.
casties
parents: 36
diff changeset
299 .filter(elem => elem[0] != "_")
7578b21cdf2e make relation types configurable.
casties
parents: 36
diff changeset
300 .map(elem => getRelationType(elem, true));
36
e8dc6a4c6773 only show possible incoming/outgoing relation types.
casties
parents: 35
diff changeset
301 this.state.resultRelations = rels;
e8dc6a4c6773 only show possible incoming/outgoing relation types.
casties
parents: 35
diff changeset
302 }
e8dc6a4c6773 only show possible incoming/outgoing relation types.
casties
parents: 35
diff changeset
303 if (this.state.inRelsCypherQuery) {
e8dc6a4c6773 only show possible incoming/outgoing relation types.
casties
parents: 35
diff changeset
304 // incoming aka reverse relations
e8dc6a4c6773 only show possible incoming/outgoing relation types.
casties
parents: 35
diff changeset
305 resIdx += 1;
e8dc6a4c6773 only show possible incoming/outgoing relation types.
casties
parents: 35
diff changeset
306 let rels = data.results[resIdx].data.map(elem => elem.row[0])
e8dc6a4c6773 only show possible incoming/outgoing relation types.
casties
parents: 35
diff changeset
307 .filter(elem => elem[0] != "_")
39
7578b21cdf2e make relation types configurable.
casties
parents: 36
diff changeset
308 .map(elem => getRelationType(elem, false));
36
e8dc6a4c6773 only show possible incoming/outgoing relation types.
casties
parents: 35
diff changeset
309 this.state.resultRelations = this.state.resultRelations.concat(rels);
17
f6af2c8347de send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 16
diff changeset
310 }
7
6cd6c09032aa object type query with results!
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
311 },
10
66dce99cef4e attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
312 err => console.error("neo4j result error=", err),
66dce99cef4e attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
313 () => console.debug('neo4j result query Complete')
7
6cd6c09032aa object type query with results!
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
314 );
6
9f5473536a98 more query generation.
casties
parents: 5
diff changeset
315 }
9f5473536a98 more query generation.
casties
parents: 5
diff changeset
316
21
930fe7460f6b result table shows all attributes now.
casties
parents: 20
diff changeset
317
930fe7460f6b result table shows all attributes now.
casties
parents: 20
diff changeset
318 filterAttributes(attributes: string[], normalized=false) {
41
5353b2dffb0f added local configuration file app/app-config.ts.
casties
parents: 40
diff changeset
319 let atts = [];
21
930fe7460f6b result table shows all attributes now.
casties
parents: 20
diff changeset
320 if (normalized) {
930fe7460f6b result table shows all attributes now.
casties
parents: 20
diff changeset
321 attributes.forEach((att) => {
930fe7460f6b result table shows all attributes now.
casties
parents: 20
diff changeset
322 if (att.substr(0, 3) == "_n_") {
930fe7460f6b result table shows all attributes now.
casties
parents: 20
diff changeset
323 atts.push(att.substr(3));
930fe7460f6b result table shows all attributes now.
casties
parents: 20
diff changeset
324 }
930fe7460f6b result table shows all attributes now.
casties
parents: 20
diff changeset
325 });
930fe7460f6b result table shows all attributes now.
casties
parents: 20
diff changeset
326 } else {
930fe7460f6b result table shows all attributes now.
casties
parents: 20
diff changeset
327 atts = attributes.filter(elem => elem[0] != "_" && !this.excludedAttributes[elem]);
930fe7460f6b result table shows all attributes now.
casties
parents: 20
diff changeset
328 }
930fe7460f6b result table shows all attributes now.
casties
parents: 20
diff changeset
329 return atts;
930fe7460f6b result table shows all attributes now.
casties
parents: 20
diff changeset
330 }
930fe7460f6b result table shows all attributes now.
casties
parents: 20
diff changeset
331
930fe7460f6b result table shows all attributes now.
casties
parents: 20
diff changeset
332 /**
20
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
333 * Run the given queries on the Neo4J server.
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
334 *
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
335 * Returns an Observable with the results.
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
336 */
17
f6af2c8347de send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 16
diff changeset
337 fetchCypherResults(queries: string[], params=[{}]) {
f6af2c8347de send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 16
diff changeset
338 console.debug("fetching cypher queries: ", queries);
41
5353b2dffb0f added local configuration file app/app-config.ts.
casties
parents: 40
diff changeset
339 let headers = new Headers();
5353b2dffb0f added local configuration file app/app-config.ts.
casties
parents: 40
diff changeset
340 let auth = NEO4J_AUTHENTICATION;
20
34cd764e234b make interfaces into classes. factor out NormalizationService.
casties
parents: 19
diff changeset
341 headers.append('Authorization', 'Basic ' + btoa(`${auth.user}:${auth.password}`));
1
59b7c3afcc6b first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff changeset
342 headers.append('Content-Type', 'application/json');
59b7c3afcc6b first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff changeset
343 headers.append('Accept', 'application/json');
3
c741a00d38de first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 2
diff changeset
344 // put headers in options
41
5353b2dffb0f added local configuration file app/app-config.ts.
casties
parents: 40
diff changeset
345 let opts = {'headers': headers};
17
f6af2c8347de send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 16
diff changeset
346 // unpack queries into statements
41
5353b2dffb0f added local configuration file app/app-config.ts.
casties
parents: 40
diff changeset
347 let statements = queries.map((q, i) => {
17
f6af2c8347de send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 16
diff changeset
348 return {'statement': q, 'parameters': (params[i])?params[i]:{}};
f6af2c8347de send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 16
diff changeset
349 });
3
c741a00d38de first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 2
diff changeset
350 // create POST data from query
41
5353b2dffb0f added local configuration file app/app-config.ts.
casties
parents: 40
diff changeset
351 let data = JSON.stringify({'statements': statements});
3
c741a00d38de first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 2
diff changeset
352 // make post request asynchronously
41
5353b2dffb0f added local configuration file app/app-config.ts.
casties
parents: 40
diff changeset
353 let resp = this._http.post(NEO4J_BASE_URL+'/transaction/commit', data, opts)
3
c741a00d38de first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 2
diff changeset
354 // filter result as JSON
c741a00d38de first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 2
diff changeset
355 .map(res => res.json());
c741a00d38de first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 2
diff changeset
356 // return Observable
c741a00d38de first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 2
diff changeset
357 return resp;
1
59b7c3afcc6b first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff changeset
358 }
13
98b435bb6c0c more query work.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 12
diff changeset
359
1
59b7c3afcc6b first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff changeset
360 }