Mercurial > hg > ng2-query-ismi
comparison app/query.service.ts @ 6:9f5473536a98
more query generation.
author | casties |
---|---|
date | Thu, 14 Jan 2016 17:19:35 +0100 |
parents | b06a5d61afed |
children | 6cd6c09032aa |
comparison
equal
deleted
inserted
replaced
5:b06a5d61afed | 6:9f5473536a98 |
---|---|
17 public QUERY_MODES: QueryMode[] = [ | 17 public QUERY_MODES: QueryMode[] = [ |
18 {id: 'type_is', label:'Object type is'}, | 18 {id: 'type_is', label:'Object type is'}, |
19 {id: 'att_contains', label: 'Attribute contains'}]; | 19 {id: 'att_contains', label: 'Attribute contains'}]; |
20 | 20 |
21 constructor(private _http: Http) { | 21 constructor(private _http: Http) { |
22 this.queryState = {'queries': [], 'results': [], numResults: 0}; | 22 this.queryState = { |
23 'steps': [], | |
24 'cypherQuery': '', | |
25 'cyperParams': {}, | |
26 'results': [], | |
27 numResults: 0}; | |
23 } | 28 } |
24 | 29 |
25 getQueryModes(): QueryMode[] { | 30 getQueryModes(): QueryMode[] { |
26 return this.QUERY_MODES; | 31 return this.QUERY_MODES; |
27 } | 32 } |
52 err => console.error("neo4j error=", err), | 57 err => console.error("neo4j error=", err), |
53 () => console.debug('neo4j query Complete') | 58 () => console.debug('neo4j query Complete') |
54 ); | 59 ); |
55 } | 60 } |
56 | 61 |
62 setQueryStep(index: number, step: QueryStep) { | |
63 this.queryState.steps[index] = step; | |
64 this.createCypherQuery(); | |
65 } | |
66 | |
67 createCypherQuery() { | |
68 var cypher = ''; | |
69 var step = this.queryState.steps[0]; | |
70 if (step.mode.id === 'type_is') { | |
71 cypher = `MATCH (e:${step.objectType}) return e`; | |
72 } | |
73 | |
74 this.queryState.cypherQuery = cypher; | |
75 } | |
76 | |
57 fetchCypherResult(query: string, params = {}) { | 77 fetchCypherResult(query: string, params = {}) { |
58 var headers = new Headers(); | 78 var headers = new Headers(); |
59 headers.append('Authorization', 'Basic ' + btoa('neo4j' + ':' + 'neo5j')); | 79 headers.append('Authorization', 'Basic ' + btoa('neo4j' + ':' + 'neo5j')); |
60 headers.append('Content-Type', 'application/json'); | 80 headers.append('Content-Type', 'application/json'); |
61 headers.append('Accept', 'application/json'); | 81 headers.append('Accept', 'application/json'); |