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