diff app/query.service.ts @ 15:f84ff6781e57

added att_num_range query type.
author Robert Casties <casties@mpiwg-berlin.mpg.de>
date Thu, 21 Jan 2016 17:26:22 +0100
parents 7dc7ea95ca26
children 7d82ca32833c
line wrap: on
line diff
--- a/app/query.service.ts	Thu Jan 21 16:49:55 2016 +0100
+++ b/app/query.service.ts	Thu Jan 21 17:26:22 2016 +0100
@@ -44,7 +44,7 @@
     }
     
     getQueryOptions(queryMode: QueryMode) {
-        var options = ['a1', 'b1', 'c1'];
+        var options = [];
         if (queryMode.id === 'type_is') {
             options = this.ismiObjectTypes;
         } else if (queryMode.id === 'relation_is') {
@@ -53,6 +53,8 @@
             options = this.state.nextQueryAttributes;
         } else if (queryMode.id === 'att_contains_norm') {
             options = this.state.nextQueryAttributes;
+        } else if (queryMode.id === 'att_num_range') {
+            options = this.state.nextQueryAttributes;
         }
         console.debug("getQueryOptions returns: ", options);
         return options;
@@ -136,9 +138,25 @@
                 }
             }
             
+            /*
+             * step: attribute number range
+             */
+            if (step.mode.id === 'att_num_range') {
+                if (!queryWhere) {
+                    queryWhere = 'WHERE ';
+                } else {
+                    queryWhere += ' AND ';
+                }
+                queryWhere += `toint(n${nIdx}.${step.attribute}) >= toint({att_nlo${stepIdx}})`
+                    + ` AND toint(n${nIdx}.${step.attribute}) <= toint({att_nhi${stepIdx}})`;
+                queryParams[`att_nlo${stepIdx}`] = step.numLo;
+                queryParams[`att_nhi${stepIdx}`] = step.numHi;
+            }
+            
         });
         resultQuery = queryMatch + '\n' + queryWhere + '\n' + queryReturn;
-        attributesQuery = queryMatch + ' ' + queryWhere + ` WITH DISTINCT keys(n${nIdx}) AS atts UNWIND atts AS att RETURN DISTINCT att ORDER BY att`;
+        attributesQuery = queryMatch + ' ' + queryWhere + ` WITH DISTINCT keys(n${nIdx}) AS atts`
+            + ` UNWIND atts AS att RETURN DISTINCT att ORDER BY att`;
         relationsQuery = queryMatch + '-[r]-() ' + queryWhere + ' RETURN DISTINCT type(r)';
         this.state.resultCypherQuery = resultQuery;
         this.state.cypherQueryParams = queryParams;