diff app/query.service.ts @ 6:9f5473536a98

more query generation.
author casties
date Thu, 14 Jan 2016 17:19:35 +0100
parents b06a5d61afed
children 6cd6c09032aa
line wrap: on
line diff
--- a/app/query.service.ts	Wed Jan 13 18:57:31 2016 +0100
+++ b/app/query.service.ts	Thu Jan 14 17:19:35 2016 +0100
@@ -19,7 +19,12 @@
         {id: 'att_contains', label: 'Attribute contains'}];
         
     constructor(private _http: Http) {
-        this.queryState = {'queries': [], 'results': [], numResults: 0};
+        this.queryState = {
+            'steps': [],
+            'cypherQuery': '',
+            'cyperParams': {}, 
+            'results': [], 
+            numResults: 0};
     }
     
     getQueryModes(): QueryMode[] {
@@ -54,6 +59,21 @@
         );
     }
     
+    setQueryStep(index: number, step: QueryStep) {
+        this.queryState.steps[index] = step;
+        this.createCypherQuery();
+    }
+    
+    createCypherQuery() {
+        var cypher = '';
+        var step = this.queryState.steps[0];
+        if (step.mode.id === 'type_is') {
+            cypher = `MATCH (e:${step.objectType}) return e`;
+        }
+        
+        this.queryState.cypherQuery = cypher;
+    }
+    
     fetchCypherResult(query: string, params = {}) {
         var headers = new Headers();
         headers.append('Authorization', 'Basic ' + btoa('neo4j' + ':' + 'neo5j'));