# HG changeset patch # User Robert Casties # Date 1453393582 -3600 # Node ID f84ff6781e57676004d6ceab175ca3eb46cebd04 # Parent 7dc7ea95ca267d0afdf1d49aabf9b70c32435bb1 added att_num_range query type. diff -r 7dc7ea95ca26 -r f84ff6781e57 app/query-mode.ts --- a/app/query-mode.ts Thu Jan 21 16:49:55 2016 +0100 +++ b/app/query-mode.ts Thu Jan 21 17:26:22 2016 +0100 @@ -5,8 +5,9 @@ export var QUERY_MODES: QueryMode[] = [ {id: 'type_is', label:'Object type is'}, - {id: 'att_contains', label: 'Attribute'}, - {id: 'att_contains_norm', label: 'Attribute (normalized)'}, + {id: 'att_contains', label: 'Attribute (contains)'}, + {id: 'att_contains_norm', label: 'Attribute (contains normalized)'}, + {id: 'att_num_range', label: 'Attribute (number range)'}, {id: 'relation_is', label: 'Relation type is'} ]; diff -r 7dc7ea95ca26 -r f84ff6781e57 app/query-select.component.ts --- a/app/query-select.component.ts Thu Jan 21 16:49:55 2016 +0100 +++ b/app/query-select.component.ts Thu Jan 21 17:26:22 2016 +0100 @@ -19,7 +19,7 @@ - + - + + + + + is between + + and + + + @@ -55,6 +69,7 @@ public queryOptions: string[]; public selectedOption: string; public queryInput: string; + public queryInput2: string; @Output('queryChanged') queryChanged = new EventEmitter(); @@ -108,6 +123,13 @@ if (att && val) { step = {'mode': this.selectedMode, 'attribute': att, 'value': val}; } + } else if (this.selectedMode.id == 'att_num_range') { + var att = this.selectedOption; + var nlo = this.queryInput; + var nhi = this.queryInput2; + if (att && nlo && nhi) { + step = {'mode': this.selectedMode, 'attribute': att, 'numLo': nlo, 'numHi': nhi}; + } } else if (this.selectedMode.id == 'att_contains_norm') { var att = this.selectedOption; var val = this.queryInput; diff -r 7dc7ea95ca26 -r f84ff6781e57 app/query.service.ts --- 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;