diff app/query.service.ts @ 14:7dc7ea95ca26

show result types below query steps.
author Robert Casties <casties@mpiwg-berlin.mpg.de>
date Thu, 21 Jan 2016 16:49:55 +0100
parents 98b435bb6c0c
children f84ff6781e57
line wrap: on
line diff
--- a/app/query.service.ts	Thu Jan 21 14:47:00 2016 +0100
+++ b/app/query.service.ts	Thu Jan 21 16:49:55 2016 +0100
@@ -91,7 +91,9 @@
         var returnType = '';
         var nIdx = 1;
         this.state.steps.forEach((step, stepIdx) => {
-            // object type is
+            /*
+             * step: object type is
+             */
             if (step.mode.id === 'type_is') {
                 queryMatch = `MATCH (n${nIdx}:${step.objectType})`;
                 queryWhere = '';
@@ -99,7 +101,9 @@
                 returnType = 'node';
             }
             
-            // relation type is
+            /*
+             * step: relation type is
+             */
             if (step.mode.id === 'relation_is') {
                 nIdx += 1;
                 queryMatch += `-[:\`${step.relationType}\`]->(n${nIdx})`;
@@ -107,25 +111,29 @@
                 returnType = 'node';
             }
             
-            // attribute contains
-            if (step.mode.id === 'att_contains') {
+            /*
+             * step: attribute contains(_norm)
+             */
+            if (step.mode.id === 'att_contains' || step.mode.id === 'att_contains_norm') {
                 if (!queryWhere) {
                     queryWhere = 'WHERE ';
                 } else {
                     queryWhere += ' AND ';
                 }
-                queryWhere += `lower(n${nIdx}.${step.attribute}) CONTAINS lower({att_val${stepIdx}})`;
-                queryParams[`att_val${stepIdx}`] = step.value;
-            }
-            
-            // attribute contains (normalized)
-            if (step.mode.id === 'att_contains_norm') {
-                if (!queryWhere) {
-                    queryWhere = 'WHERE ';
+                if (step.attribute === 'ismi_id') {
+                    // ismi_id is integer
+                    queryWhere += `n${nIdx}.ismi_id = {att_val${stepIdx}}`;                    
+                    queryParams[`att_val${stepIdx}`] = parseInt(step.value, 10);
                 } else {
-                    queryWhere += ' AND ';
+                    if (step.mode.id === 'att_contains_norm') {
+                        // match _n_attribute with normValue
+                        queryWhere += `lower(n${nIdx}._n_${step.attribute}) CONTAINS lower({att_val${stepIdx}})`;
+                        queryParams[`att_val${stepIdx}`] = step.normValue;                        
+                    } else {
+                        queryWhere += `lower(n${nIdx}.${step.attribute}) CONTAINS lower({att_val${stepIdx}})`;
+                        queryParams[`att_val${stepIdx}`] = step.value;
+                    }
                 }
-                queryWhere += `lower(n${nIdx}._n_${step.attribute}) CONTAINS lower('${step.value}')`;
             }
             
         });
@@ -164,7 +172,10 @@
                 for (var t in resTypes) {
                     info += t + '(' + resTypes[t] + ') ';   
                 }
-                this.state.resultInfo = info.substr(0, info.length-1);
+                info = info.substr(0, info.length-1);
+                this.state.resultInfo = info;
+                // save info also in last step
+                this.state.steps[this.state.steps.length-1].resultInfo = info;
             },
             err => console.error("neo4j result error=", err),
             () => console.debug('neo4j result query Complete')