diff app/query.service.ts @ 8:fa646ee46c19

more query generation.
author casties
date Mon, 18 Jan 2016 09:52:46 +0100
parents 6cd6c09032aa
children 402c7229dc7c
line wrap: on
line diff
--- a/app/query.service.ts	Fri Jan 15 20:00:47 2016 +0100
+++ b/app/query.service.ts	Mon Jan 18 09:52:46 2016 +0100
@@ -10,9 +10,9 @@
 @Injectable()
 export class QueryService {
         
+    public neo4jBaseUrl = 'http://localhost:7474/db/data/cypher/';
     public state: QueryState;
-    
-    public ismiObjectTypes;
+    public ismiObjectTypes: any;
     
     public QUERY_MODES: QueryMode[] = [
         {id: 'type_is', label:'Object type is'},
@@ -29,6 +29,10 @@
         };
     }
     
+    setup() {
+        this.setupIsmiObjectTypes();
+    }
+    
     getState() {
         return this.state;
     }
@@ -73,12 +77,13 @@
     createCypherQuery() {
         var cypher = '';
         var returnType = '';
-        var step = this.state.steps[0];
-        if (step.mode.id === 'type_is') {
-            cypher = `MATCH (e:${step.objectType}) return e`;
-            returnType = 'node';
+        for (var i=0; i < this.state.steps.length; ++i) {
+            var step = this.state.steps[i];
+            if (step.mode.id === 'type_is') {
+                cypher = `MATCH (e:${step.objectType}) return e`;
+                returnType = 'node';
+            }
         }
-        
         this.state.cypherQuery = cypher;
         this.state.resultTypes = returnType;
     }
@@ -109,7 +114,7 @@
         // create POST data from query
         var data = JSON.stringify({'query': query, 'params': params});
         // make post request asynchronously
-        var resp = this._http.post('http://localhost:7474/db/data/cypher/', data, opts)
+        var resp = this._http.post(this.neo4jBaseUrl, data, opts)
         // filter result as JSON
         .map(res => res.json());
         // return Observable