# HG changeset patch # User casties # Date 1455531008 -3600 # Node ID 896ae7eefb3371b66c08430ed6bfca3ce18ac237 # Parent 7578b21cdf2e52acf327199a79ef63db1b849b50 fix relation type queries. diff -r 7578b21cdf2e -r 896ae7eefb33 app/ismi-relation-types.ts --- a/app/ismi-relation-types.ts Sun Feb 14 19:40:07 2016 +0100 +++ b/app/ismi-relation-types.ts Mon Feb 15 11:10:08 2016 +0100 @@ -28,13 +28,22 @@ addRelationType('was_studied_by', 'persons studying this text', 'text studied by'); //addRelationType('', '', ''); -export function getRelationType(name: string, isOutgoing?: boolean): RelationType { +export function getRelationType(relType: string, isOutgoing: boolean): RelationType { + let name = relType; if (isOutgoing === false) { // add prefix to name name = invNamePrefix + name; } let rt = RELATION_TYPES[name]; if (rt == null) { + rt = new RelationType(relType, isOutgoing); + } + return rt; +} + +export function getRelationByName(name: string): RelationType { + let rt = RELATION_TYPES[name]; + if (rt == null) { if (name.indexOf(invNamePrefix) == 0) { // inverse relation name = name.substr(invNamePrefix.length); diff -r 7578b21cdf2e -r 896ae7eefb33 app/query-app.component.ts --- a/app/query-app.component.ts Sun Feb 14 19:40:07 2016 +0100 +++ b/app/query-app.component.ts Mon Feb 15 11:10:08 2016 +0100 @@ -59,7 +59,7 @@ onQueryChanged(event: any) { console.debug("app.onquerychanged! event=", event); - this._queryService.updateQuery(); + this._queryService.runQuery(); this.queryState = this._queryService.getState(); } } diff -r 7578b21cdf2e -r 896ae7eefb33 app/query-select.component.ts --- a/app/query-select.component.ts Sun Feb 14 19:40:07 2016 +0100 +++ b/app/query-select.component.ts Mon Feb 15 11:10:08 2016 +0100 @@ -6,7 +6,7 @@ import {QueryService} from './query.service'; import {NormalizationService} from './normalization.service'; -import {getRelationType} from './ismi-relation-types'; +import {getRelationByName} from './ismi-relation-types'; @Component({ @@ -139,7 +139,7 @@ */ let opt = this.selectedOption; if (opt) { - let rel = getRelationType(opt); + let rel = getRelationByName(opt); step = new QueryStep(this.selectedMode, {'relationType': rel}); } } else if (this.selectedMode.id == 'id_is') { diff -r 7578b21cdf2e -r 896ae7eefb33 app/query.service.ts --- a/app/query.service.ts Sun Feb 14 19:40:07 2016 +0100 +++ b/app/query.service.ts Mon Feb 15 11:10:08 2016 +0100 @@ -151,10 +151,10 @@ nIdx += 1; let rel = params.relationType; if (rel.isOutgoing()) { - queryMatch += `-[:\`${rel.getName()}\`]->(n${nIdx})`; + queryMatch += `-[:\`${rel.getRelType()}\`]->(n${nIdx})`; } else { // inverse relation - queryMatch += `<-[:\`${rel.getName()}\`]-(n${nIdx})`; + queryMatch += `<-[:\`${rel.getRelType()}\`]-(n${nIdx})`; } queryReturn = `RETURN DISTINCT n${nIdx}`; returnType = 'node'; @@ -222,7 +222,7 @@ * * Updates the results and nextQuery attributes and relations. */ - updateQuery() { + runQuery() { this.createCypherQuery(); this.state.resultInfo = 'loading...'; /* diff -r 7578b21cdf2e -r 896ae7eefb33 app/relation-type.ts --- a/app/relation-type.ts Sun Feb 14 19:40:07 2016 +0100 +++ b/app/relation-type.ts Mon Feb 15 11:10:08 2016 +0100 @@ -6,20 +6,26 @@ export class RelationType { public name: string; + public relType: string; public label: string; public outgoing: boolean; - constructor (name: string, isOutgoing: boolean, label?:string) { - this.name = name; + constructor (relType: string, isOutgoing: boolean, label?:string) { this.outgoing = isOutgoing; + this.relType = relType; + if (isOutgoing) { + this.name = relType; + } else { + this.name = invNamePrefix + relType; + } if (label != null) { this.label = label; } else { // create label using name if (isOutgoing) { - this.label = rawLabelPrefix + name + rawLabelPostfix; + this.label = rawLabelPrefix + relType + rawLabelPostfix; } else { - this.label = rawLabelPrefix + invLabelPrefix + name + rawLabelPostfix; + this.label = rawLabelPrefix + invLabelPrefix + relType + rawLabelPostfix; } } } @@ -32,6 +38,10 @@ return this.name; } + getRelType() { + return this.relType; + } + isOutgoing() { return this.outgoing; }