# HG changeset patch # User casties # Date 1455206800 -3600 # Node ID e8dc6a4c67732bfa3531106f81fdd78662b2a040 # Parent b47614a9d23dcc5e19d269040bdf019d825e3fe6 only show possible incoming/outgoing relation types. diff -r b47614a9d23d -r e8dc6a4c6773 app/query-state.ts --- a/app/query-state.ts Wed Feb 03 18:40:30 2016 +0100 +++ b/app/query-state.ts Thu Feb 11 17:06:40 2016 +0100 @@ -5,7 +5,8 @@ public resultCypherQuery: string; public attributesCypherQuery: string; - public relationsCypherQuery: string; + public outRelsCypherQuery: string; + public inRelsCypherQuery: string; public cypherQueryParams: any; public results: any[]; diff -r b47614a9d23d -r e8dc6a4c6773 app/query.service.ts --- a/app/query.service.ts Wed Feb 03 18:40:30 2016 +0100 +++ b/app/query.service.ts Thu Feb 11 17:06:40 2016 +0100 @@ -103,7 +103,8 @@ var queryParams = {}; var resultQuery = ''; var attributesQuery = ''; - var relationsQuery = ''; + var outRelsQuery = ''; + var inRelsQuery = ''; var returnType = ''; var nIdx = 1; this.state.steps.forEach((step, stepIdx) => { @@ -207,11 +208,13 @@ attributesQuery = queryMatch + ' ' + queryWhere + ` WITH DISTINCT keys(n${nIdx}) AS atts` + ` UNWIND atts AS att RETURN DISTINCT att ORDER BY att`; // compose query for relations of result - relationsQuery = queryMatch + '-[r]-() ' + queryWhere + ' RETURN DISTINCT type(r)'; + outRelsQuery = queryMatch + '-[r]->() ' + queryWhere + ' RETURN DISTINCT type(r)'; + inRelsQuery = queryMatch + '<-[r]-() ' + queryWhere + ' RETURN DISTINCT type(r)'; this.state.resultCypherQuery = resultQuery; this.state.cypherQueryParams = queryParams; this.state.attributesCypherQuery = attributesQuery; - this.state.relationsCypherQuery = relationsQuery; + this.state.outRelsCypherQuery = outRelsQuery; + this.state.inRelsCypherQuery = inRelsQuery; this.state.resultTypes = returnType; } @@ -232,8 +235,12 @@ queries.push(this.state.attributesCypherQuery); params.push(this.state.cypherQueryParams); } - if (this.state.relationsCypherQuery) { - queries.push(this.state.relationsCypherQuery); + if (this.state.outRelsCypherQuery) { + queries.push(this.state.outRelsCypherQuery); + params.push(this.state.cypherQueryParams); + } + if (this.state.inRelsCypherQuery) { + queries.push(this.state.inRelsCypherQuery); params.push(this.state.cypherQueryParams); } var res = this.fetchCypherResults(queries, params); @@ -281,13 +288,20 @@ /* * results for relations list */ - if (this.state.relationsCypherQuery) { + if (this.state.outRelsCypherQuery) { + // outgoing aka forward relations resIdx += 1; - var rels = data.results[resIdx].data.map(elem => elem.row[0]) - .filter(elem => elem[0] != "_"); - // add inverse relations - var invrels = rels.concat(rels.map((r) => this.invRelPrefix + r)); - this.state.resultRelations = invrels; + let rels = data.results[resIdx].data.map(elem => elem.row[0]) + .filter(elem => elem[0] != "_"); + this.state.resultRelations = rels; + } + if (this.state.inRelsCypherQuery) { + // incoming aka reverse relations + resIdx += 1; + let rels = data.results[resIdx].data.map(elem => elem.row[0]) + .filter(elem => elem[0] != "_") + .map((r) => this.invRelPrefix + r); + this.state.resultRelations = this.state.resultRelations.concat(rels); } }, err => console.error("neo4j result error=", err),