Mercurial > hg > ng2-query-ismi
annotate app/query.service.ts @ 25:0795207f3b90
ng2-table now with pager, sorting and styling.
author | casties |
---|---|
date | Tue, 26 Jan 2016 19:19:23 +0100 |
parents | f6f4177d0a81 |
children | 193271b6b9d2 |
rev | line source |
---|---|
1
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1 import {Injectable} from 'angular2/core'; |
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
2 import {Http, Headers} from 'angular2/http'; |
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 | 5 //import 'rxjs/add/operator/map'; |
1
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
6 |
11
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
7 import {QueryMode, QUERY_MODES} from './query-mode'; |
5
b06a5d61afed
new query state stuff.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
3
diff
changeset
|
8 import {QueryState} from './query-state'; |
b06a5d61afed
new query state stuff.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
3
diff
changeset
|
9 import {QueryStep} from './query-step'; |
25 | 10 import {ResultColumn} from './result-column'; |
1
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
11 |
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
12 @Injectable() |
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
13 export class QueryService { |
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
14 |
16
7d82ca32833c
omit some attributes from list.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
15
diff
changeset
|
15 //public neo4jBaseUrl = 'https://ismi-dev.mpiwg-berlin.mpg.de/neo4j-ismi/db/data'; |
7d82ca32833c
omit some attributes from list.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
15
diff
changeset
|
16 public neo4jBaseUrl = 'http://localhost:7474/db/data'; |
20
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
17 public neo4jAuthentication = {'user': 'neo4j', 'password': 'neo5j'}; |
16
7d82ca32833c
omit some attributes from list.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
15
diff
changeset
|
18 public excludedAttributes = {'type': true}; |
18
65bb467abcc6
inverse relations are now generated on the fly.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
17
diff
changeset
|
19 public invRelPrefix = '<- '; |
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 | 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 |
8 | 28 setup() { |
20
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
29 this.setupObjectTypes(); |
8 | 30 } |
31 | |
7
6cd6c09032aa
object type query with results!
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
32 getState() { |
6cd6c09032aa
object type query with results!
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
33 return this.state; |
5
b06a5d61afed
new query state stuff.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
3
diff
changeset
|
34 } |
1
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
35 |
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
36 getQueryModes(): QueryMode[] { |
11
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
37 return QUERY_MODES; |
1
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
38 } |
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
39 |
20
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
40 /** |
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
41 * return the first set of options for the given query mode. |
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
42 */ |
3
c741a00d38de
first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
2
diff
changeset
|
43 getQueryOptions(queryMode: QueryMode) { |
15
f84ff6781e57
added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
14
diff
changeset
|
44 var options = []; |
18
65bb467abcc6
inverse relations are now generated on the fly.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
17
diff
changeset
|
45 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
|
46 if (queryMode.id === 'type_is') { |
20
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
47 options = this.objectTypes; |
11
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
48 } else if (queryMode.id === 'relation_is') { |
21 | 49 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
|
50 } else if (queryMode.id === 'att_contains') { |
21 | 51 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
|
52 } else if (queryMode.id === 'att_contains_norm') { |
21 | 53 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
|
54 } else if (queryMode.id === 'att_num_range') { |
21 | 55 options = this.filterAttributes(this.state.resultAttributes); |
1
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
56 } |
5
b06a5d61afed
new query state stuff.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
3
diff
changeset
|
57 console.debug("getQueryOptions returns: ", options); |
b06a5d61afed
new query state stuff.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
3
diff
changeset
|
58 return options; |
1
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
59 } |
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
60 |
20
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
61 /** |
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
62 * fetch all object types from Neo4j and store in this.objectTypes. |
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
63 */ |
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
64 setupObjectTypes() { |
3
c741a00d38de
first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
2
diff
changeset
|
65 var query = `MATCH (n) WITH DISTINCT labels(n) AS labels |
c741a00d38de
first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
2
diff
changeset
|
66 UNWIND labels AS label |
c741a00d38de
first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
2
diff
changeset
|
67 RETURN DISTINCT label ORDER BY label`; |
c741a00d38de
first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
2
diff
changeset
|
68 |
17
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
69 var res = this.fetchCypherResults([query]); |
3
c741a00d38de
first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
2
diff
changeset
|
70 res.subscribe( |
c741a00d38de
first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
2
diff
changeset
|
71 data => { |
c741a00d38de
first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
2
diff
changeset
|
72 console.debug("neo4j data=", data); |
20
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
73 this.objectTypes = data.results[0].data.map(elem => elem.row[0]).filter(elem => elem[0] != "_"); |
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
74 console.debug("object types=", this.objectTypes); |
3
c741a00d38de
first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
2
diff
changeset
|
75 }, |
c741a00d38de
first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
2
diff
changeset
|
76 err => console.error("neo4j error=", err), |
c741a00d38de
first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
2
diff
changeset
|
77 () => console.debug('neo4j query Complete') |
c741a00d38de
first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
2
diff
changeset
|
78 ); |
c741a00d38de
first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
2
diff
changeset
|
79 } |
c741a00d38de
first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
2
diff
changeset
|
80 |
20
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
81 /** |
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
82 * Set the query step at index. |
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
83 */ |
6 | 84 setQueryStep(index: number, step: QueryStep) { |
7
6cd6c09032aa
object type query with results!
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
85 this.state.steps[index] = step; |
6 | 86 } |
87 | |
20
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
88 /** |
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
89 * Create the cypher queries for the current query state. |
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
90 * |
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
91 * Updates the queries for results, attributes and relations. |
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
92 */ |
6 | 93 createCypherQuery() { |
10
66dce99cef4e
attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
94 var queryMatch = ''; |
66dce99cef4e
attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
95 var queryWhere = ''; |
66dce99cef4e
attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
96 var queryReturn = ''; |
11
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
97 var queryParams = {}; |
10
66dce99cef4e
attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
98 var resultQuery = ''; |
11
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
99 var attributesQuery = ''; |
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
100 var relationsQuery = ''; |
7
6cd6c09032aa
object type query with results!
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
101 var returnType = ''; |
11
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
102 var nIdx = 1; |
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
103 this.state.steps.forEach((step, stepIdx) => { |
20
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
104 var mode = step.mode.id; |
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
105 var params = step.params; |
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
106 |
14
7dc7ea95ca26
show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
13
diff
changeset
|
107 /* |
7dc7ea95ca26
show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
13
diff
changeset
|
108 * step: object type is |
7dc7ea95ca26
show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
13
diff
changeset
|
109 */ |
20
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
110 if (mode === 'type_is') { |
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
111 queryMatch = `MATCH (n${nIdx}:${params.objectType})`; |
10
66dce99cef4e
attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
112 queryWhere = ''; |
11
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
113 queryReturn = `RETURN n${nIdx}`; |
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
114 returnType = 'node'; |
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
115 } |
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
116 |
14
7dc7ea95ca26
show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
13
diff
changeset
|
117 /* |
7dc7ea95ca26
show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
13
diff
changeset
|
118 * step: relation type is |
7dc7ea95ca26
show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
13
diff
changeset
|
119 */ |
20
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
120 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
|
121 nIdx += 1; |
20
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
122 var rel = params.relationType; |
18
65bb467abcc6
inverse relations are now generated on the fly.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
17
diff
changeset
|
123 if (rel.indexOf(this.invRelPrefix) == 0) { |
65bb467abcc6
inverse relations are now generated on the fly.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
17
diff
changeset
|
124 // inverse relation |
65bb467abcc6
inverse relations are now generated on the fly.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
17
diff
changeset
|
125 rel = rel.substr(this.invRelPrefix.length); |
65bb467abcc6
inverse relations are now generated on the fly.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
17
diff
changeset
|
126 queryMatch += `<-[:${rel}]-(n${nIdx})`; |
65bb467abcc6
inverse relations are now generated on the fly.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
17
diff
changeset
|
127 } else { |
19 | 128 queryMatch += `-[:${rel}]->(n${nIdx})`; |
18
65bb467abcc6
inverse relations are now generated on the fly.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
17
diff
changeset
|
129 } |
11
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
130 queryReturn = `RETURN n${nIdx}`; |
8 | 131 returnType = 'node'; |
132 } | |
10
66dce99cef4e
attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
133 |
14
7dc7ea95ca26
show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
13
diff
changeset
|
134 /* |
7dc7ea95ca26
show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
13
diff
changeset
|
135 * step: attribute contains(_norm) |
7dc7ea95ca26
show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
13
diff
changeset
|
136 */ |
20
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
137 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
|
138 if (!queryWhere) { |
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
139 queryWhere = 'WHERE '; |
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
140 } else { |
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
141 queryWhere += ' AND '; |
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
142 } |
20
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
143 if (params.attribute === 'ismi_id') { |
14
7dc7ea95ca26
show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
13
diff
changeset
|
144 // ismi_id is integer |
7dc7ea95ca26
show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
13
diff
changeset
|
145 queryWhere += `n${nIdx}.ismi_id = {att_val${stepIdx}}`; |
20
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
146 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
|
147 } else { |
20
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
148 if (mode === 'att_contains_norm') { |
14
7dc7ea95ca26
show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
13
diff
changeset
|
149 // match _n_attribute with normValue |
20
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
150 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
|
151 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
|
152 } else { |
20
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
153 queryWhere += `lower(n${nIdx}.${params.attribute}) CONTAINS lower({att_val${stepIdx}})`; |
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
154 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
|
155 } |
11
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
156 } |
10
66dce99cef4e
attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
157 } |
66dce99cef4e
attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
158 |
15
f84ff6781e57
added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
14
diff
changeset
|
159 /* |
f84ff6781e57
added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
14
diff
changeset
|
160 * step: attribute number range |
f84ff6781e57
added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
14
diff
changeset
|
161 */ |
20
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
162 if (mode === 'att_num_range') { |
15
f84ff6781e57
added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
14
diff
changeset
|
163 if (!queryWhere) { |
f84ff6781e57
added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
14
diff
changeset
|
164 queryWhere = 'WHERE '; |
f84ff6781e57
added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
14
diff
changeset
|
165 } else { |
f84ff6781e57
added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
14
diff
changeset
|
166 queryWhere += ' AND '; |
f84ff6781e57
added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
14
diff
changeset
|
167 } |
20
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
168 queryWhere += `toint(n${nIdx}.${params.attribute}) >= toint({att_nlo${stepIdx}})` |
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
169 + ` AND toint(n${nIdx}.${params.attribute}) <= toint({att_nhi${stepIdx}})`; |
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
170 queryParams[`att_nlo${stepIdx}`] = params.numLo; |
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
171 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
|
172 } |
f84ff6781e57
added att_num_range query type.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
14
diff
changeset
|
173 |
9 | 174 }); |
18
65bb467abcc6
inverse relations are now generated on the fly.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
17
diff
changeset
|
175 // compose query |
11
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
176 resultQuery = queryMatch + '\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
|
177 // 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
|
178 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
|
179 + ` 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
|
180 // compose query for relations of result |
11
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
181 relationsQuery = queryMatch + '-[r]-() ' + queryWhere + ' RETURN DISTINCT type(r)'; |
10
66dce99cef4e
attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
182 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
|
183 this.state.cypherQueryParams = queryParams; |
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
184 this.state.attributesCypherQuery = attributesQuery; |
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
185 this.state.relationsCypherQuery = relationsQuery; |
7
6cd6c09032aa
object type query with results!
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
186 this.state.resultTypes = returnType; |
6cd6c09032aa
object type query with results!
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
187 } |
6cd6c09032aa
object type query with results!
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
188 |
20
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
189 /** |
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
190 * Create and run the cypher queries for the current query state. |
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
191 * |
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
192 * Updates the results and nextQuery attributes and relations. |
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
193 */ |
7
6cd6c09032aa
object type query with results!
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
194 updateQuery() { |
6cd6c09032aa
object type query with results!
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
195 this.createCypherQuery(); |
13
98b435bb6c0c
more query work.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
12
diff
changeset
|
196 this.state.resultInfo = 'loading...'; |
16
7d82ca32833c
omit some attributes from list.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
15
diff
changeset
|
197 /* |
7d82ca32833c
omit some attributes from list.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
15
diff
changeset
|
198 * run query for result table |
7d82ca32833c
omit some attributes from list.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
15
diff
changeset
|
199 */ |
17
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
200 var queries = [this.state.resultCypherQuery]; |
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
201 var params = [this.state.cypherQueryParams]; |
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
202 if (this.state.attributesCypherQuery) { |
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
203 queries.push(this.state.attributesCypherQuery); |
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
204 params.push(this.state.cypherQueryParams); |
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
205 } |
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
206 if (this.state.relationsCypherQuery) { |
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
207 queries.push(this.state.relationsCypherQuery); |
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
208 params.push(this.state.cypherQueryParams); |
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
209 } |
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
210 var res = this.fetchCypherResults(queries, params); |
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
211 res.subscribe( |
7
6cd6c09032aa
object type query with results!
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
212 data => { |
10
66dce99cef4e
attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
213 console.debug("neo4j result data=", data); |
17
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
214 var resIdx = 0; |
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
215 /* |
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
216 * results for result table |
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
217 */ |
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
218 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
|
219 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
|
220 // count all types |
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
221 var resTypes = {}; |
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
222 this.state.results.forEach((r) => { |
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
223 if (resTypes[r.type] == null) { |
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
224 resTypes[r.type] = 1; |
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
225 } else { |
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
226 resTypes[r.type] += 1; |
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
227 } |
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
228 }); |
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
229 var info = ''; |
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
230 for (var t in resTypes) { |
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
231 info += t + '(' + resTypes[t] + ') '; |
6989cd00e8d7
relations work now as well as longer queries.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
10
diff
changeset
|
232 } |
14
7dc7ea95ca26
show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
13
diff
changeset
|
233 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
|
234 this.state.resultInfo = info; |
7dc7ea95ca26
show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
13
diff
changeset
|
235 // save info also in last step |
7dc7ea95ca26
show result types below query steps.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
13
diff
changeset
|
236 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
|
237 /* |
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
238 * results for attribute list |
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
239 */ |
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
240 if (this.state.attributesCypherQuery) { |
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
241 resIdx += 1; |
21 | 242 var atts = data.results[resIdx].data.map(elem => elem.row[0]); |
243 this.state.resultAttributes = atts; | |
244 this.state.resultColumns = this.getColumns(atts); | |
17
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
245 } |
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
246 /* |
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
247 * results for relations list |
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
248 */ |
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
249 if (this.state.relationsCypherQuery) { |
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
250 resIdx += 1; |
18
65bb467abcc6
inverse relations are now generated on the fly.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
17
diff
changeset
|
251 var rels = data.results[resIdx].data.map(elem => elem.row[0]) |
17
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
252 .filter(elem => elem[0] != "_"); |
18
65bb467abcc6
inverse relations are now generated on the fly.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
17
diff
changeset
|
253 // add inverse relations |
65bb467abcc6
inverse relations are now generated on the fly.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
17
diff
changeset
|
254 var invrels = rels.concat(rels.map((r) => this.invRelPrefix + r)); |
21 | 255 this.state.resultRelations = invrels; |
17
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
256 } |
7
6cd6c09032aa
object type query with results!
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
257 }, |
10
66dce99cef4e
attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
258 err => console.error("neo4j result error=", err), |
66dce99cef4e
attribute contains works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
259 () => console.debug('neo4j result query Complete') |
7
6cd6c09032aa
object type query with results!
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
260 ); |
6 | 261 } |
262 | |
21 | 263 |
264 filterAttributes(attributes: string[], normalized=false) { | |
265 var atts = []; | |
266 if (normalized) { | |
267 attributes.forEach((att) => { | |
268 if (att.substr(0, 3) == "_n_") { | |
269 atts.push(att.substr(3)); | |
270 } | |
271 }); | |
272 } else { | |
273 atts = attributes.filter(elem => elem[0] != "_" && !this.excludedAttributes[elem]); | |
274 } | |
275 return atts; | |
276 } | |
277 | |
278 /** | |
279 * Return nice column objects | |
280 */ | |
281 getColumns(attributes: string[]) { | |
282 var cols = []; | |
283 if (attributes.indexOf('ismi_id') > -1) { | |
25 | 284 cols.push(new ResultColumn('ismi_id', 'ISMI ID')); |
21 | 285 } |
286 if (attributes.indexOf('label') > -1) { | |
25 | 287 cols.push(new ResultColumn('label', 'Label', 'asc')); |
21 | 288 } |
289 attributes.forEach((att) => { | |
290 if (att != 'ismi_id' && att != 'label' && att != 'type' && att[0] != '_') { | |
25 | 291 cols.push(new ResultColumn(att, att)); |
21 | 292 } |
293 }); | |
294 | |
295 return cols; | |
296 } | |
297 | |
20
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
298 /** |
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
299 * Run the given queries on the Neo4J server. |
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
300 * |
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
301 * Returns an Observable with the results. |
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
302 */ |
17
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
303 fetchCypherResults(queries: string[], params=[{}]) { |
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
304 console.debug("fetching cypher queries: ", queries); |
1
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
305 var headers = new Headers(); |
20
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
306 var auth = this.neo4jAuthentication; |
34cd764e234b
make interfaces into classes. factor out NormalizationService.
casties
parents:
19
diff
changeset
|
307 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
|
308 headers.append('Content-Type', 'application/json'); |
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
309 headers.append('Accept', 'application/json'); |
3
c741a00d38de
first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
2
diff
changeset
|
310 // put headers in options |
c741a00d38de
first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
2
diff
changeset
|
311 var opts = {'headers': headers}; |
17
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
312 // unpack queries into statements |
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
313 var statements = queries.map((q, i) => { |
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
314 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
|
315 }); |
3
c741a00d38de
first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
2
diff
changeset
|
316 // create POST data from query |
17
f6af2c8347de
send multiple cypher queries in one request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
16
diff
changeset
|
317 var data = JSON.stringify({'statements': statements}); |
3
c741a00d38de
first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
2
diff
changeset
|
318 // make post request asynchronously |
9 | 319 var resp = this._http.post(this.neo4jBaseUrl+'/transaction/commit', data, opts) |
3
c741a00d38de
first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
2
diff
changeset
|
320 // filter result as JSON |
c741a00d38de
first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
2
diff
changeset
|
321 .map(res => res.json()); |
c741a00d38de
first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
2
diff
changeset
|
322 // return Observable |
c741a00d38de
first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
2
diff
changeset
|
323 return resp; |
1
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
324 } |
13
98b435bb6c0c
more query work.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
12
diff
changeset
|
325 |
1
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
326 } |