comparison app/query.service.ts @ 30:193271b6b9d2

configure attributes per result type. select number of items per result page.
author casties
date Mon, 01 Feb 2016 17:29:04 +0100
parents 0795207f3b90
children 4c046f3244ec
comparison
equal deleted inserted replaced
29:52af480a843e 30:193271b6b9d2
5 //import 'rxjs/add/operator/map'; 5 //import 'rxjs/add/operator/map';
6 6
7 import {QueryMode, QUERY_MODES} from './query-mode'; 7 import {QueryMode, QUERY_MODES} from './query-mode';
8 import {QueryState} from './query-state'; 8 import {QueryState} from './query-state';
9 import {QueryStep} from './query-step'; 9 import {QueryStep} from './query-step';
10 import {ResultColumn} from './result-column'; 10 import {getResultType} from './result-type';
11 import {ISMI_RESULT_TYPES} from './ismi-result-types';
11 12
12 @Injectable() 13 @Injectable()
13 export class QueryService { 14 export class QueryService {
14 15
15 //public neo4jBaseUrl = 'https://ismi-dev.mpiwg-berlin.mpg.de/neo4j-ismi/db/data'; 16 //public neo4jBaseUrl = 'https://ismi-dev.mpiwg-berlin.mpg.de/neo4j-ismi/db/data';
237 /* 238 /*
238 * results for attribute list 239 * results for attribute list
239 */ 240 */
240 if (this.state.attributesCypherQuery) { 241 if (this.state.attributesCypherQuery) {
241 resIdx += 1; 242 resIdx += 1;
242 var atts = data.results[resIdx].data.map(elem => elem.row[0]); 243 let atts = data.results[resIdx].data.map(elem => elem.row[0]);
243 this.state.resultAttributes = atts; 244 this.state.resultAttributes = atts;
244 this.state.resultColumns = this.getColumns(atts); 245 // the following assumes only one type in the result
246 for (let t in resTypes) {
247 this.state.resultType = getResultType(t, ISMI_RESULT_TYPES);
248 break;
249 }
250 this.state.resultColumns = this.state.resultType.getColumns(atts);
245 } 251 }
246 /* 252 /*
247 * results for relations list 253 * results for relations list
248 */ 254 */
249 if (this.state.relationsCypherQuery) { 255 if (this.state.relationsCypherQuery) {
271 }); 277 });
272 } else { 278 } else {
273 atts = attributes.filter(elem => elem[0] != "_" && !this.excludedAttributes[elem]); 279 atts = attributes.filter(elem => elem[0] != "_" && !this.excludedAttributes[elem]);
274 } 280 }
275 return atts; 281 return atts;
276 }
277
278 /**
279 * Return nice column objects
280 */
281 getColumns(attributes: string[]) {
282 var cols = [];
283 if (attributes.indexOf('ismi_id') > -1) {
284 cols.push(new ResultColumn('ismi_id', 'ISMI ID'));
285 }
286 if (attributes.indexOf('label') > -1) {
287 cols.push(new ResultColumn('label', 'Label', 'asc'));
288 }
289 attributes.forEach((att) => {
290 if (att != 'ismi_id' && att != 'label' && att != 'type' && att[0] != '_') {
291 cols.push(new ResultColumn(att, att));
292 }
293 });
294
295 return cols;
296 } 282 }
297 283
298 /** 284 /**
299 * Run the given queries on the Neo4J server. 285 * Run the given queries on the Neo4J server.
300 * 286 *