comparison app/query.service.ts @ 21:930fe7460f6b

result table shows all attributes now.
author casties
date Fri, 22 Jan 2016 20:33:26 +0100
parents 34cd764e234b
children 9343e43a17d1
comparison
equal deleted inserted replaced
20:34cd764e234b 21:930fe7460f6b
42 var options = []; 42 var options = [];
43 if (queryMode == null) return options; 43 if (queryMode == null) return options;
44 if (queryMode.id === 'type_is') { 44 if (queryMode.id === 'type_is') {
45 options = this.objectTypes; 45 options = this.objectTypes;
46 } else if (queryMode.id === 'relation_is') { 46 } else if (queryMode.id === 'relation_is') {
47 options = this.state.nextQueryRelations; 47 options = this.state.resultRelations;
48 } else if (queryMode.id === 'att_contains') { 48 } else if (queryMode.id === 'att_contains') {
49 options = this.state.nextQueryAttributes; 49 options = this.filterAttributes(this.state.resultAttributes);
50 } else if (queryMode.id === 'att_contains_norm') { 50 } else if (queryMode.id === 'att_contains_norm') {
51 options = this.state.nextQueryAttributes; 51 options = this.filterAttributes(this.state.resultAttributes, true);
52 } else if (queryMode.id === 'att_num_range') { 52 } else if (queryMode.id === 'att_num_range') {
53 options = this.state.nextQueryAttributes; 53 options = this.filterAttributes(this.state.resultAttributes);
54 } 54 }
55 console.debug("getQueryOptions returns: ", options); 55 console.debug("getQueryOptions returns: ", options);
56 return options; 56 return options;
57 } 57 }
58 58
235 /* 235 /*
236 * results for attribute list 236 * results for attribute list
237 */ 237 */
238 if (this.state.attributesCypherQuery) { 238 if (this.state.attributesCypherQuery) {
239 resIdx += 1; 239 resIdx += 1;
240 this.state.nextQueryAttributes = data.results[resIdx].data.map(elem => elem.row[0]) 240 var atts = data.results[resIdx].data.map(elem => elem.row[0]);
241 .filter(elem => elem[0] != "_" && !this.excludedAttributes[elem]); 241 this.state.resultAttributes = atts;
242 this.state.resultColumns = this.getColumns(atts);
242 } 243 }
243 /* 244 /*
244 * results for relations list 245 * results for relations list
245 */ 246 */
246 if (this.state.relationsCypherQuery) { 247 if (this.state.relationsCypherQuery) {
247 resIdx += 1; 248 resIdx += 1;
248 var rels = data.results[resIdx].data.map(elem => elem.row[0]) 249 var rels = data.results[resIdx].data.map(elem => elem.row[0])
249 .filter(elem => elem[0] != "_"); 250 .filter(elem => elem[0] != "_");
250 // add inverse relations 251 // add inverse relations
251 var invrels = rels.concat(rels.map((r) => this.invRelPrefix + r)); 252 var invrels = rels.concat(rels.map((r) => this.invRelPrefix + r));
252 this.state.nextQueryRelations = invrels; 253 this.state.resultRelations = invrels;
253 } 254 }
254 }, 255 },
255 err => console.error("neo4j result error=", err), 256 err => console.error("neo4j result error=", err),
256 () => console.debug('neo4j result query Complete') 257 () => console.debug('neo4j result query Complete')
257 ); 258 );
259 }
260
261
262 filterAttributes(attributes: string[], normalized=false) {
263 var atts = [];
264 if (normalized) {
265 attributes.forEach((att) => {
266 if (att.substr(0, 3) == "_n_") {
267 atts.push(att.substr(3));
268 }
269 });
270 } else {
271 atts = attributes.filter(elem => elem[0] != "_" && !this.excludedAttributes[elem]);
272 }
273 return atts;
274 }
275
276 /**
277 * Return nice column objects
278 */
279 getColumns(attributes: string[]) {
280 var cols = [];
281 if (attributes.indexOf('ismi_id') > -1) {
282 cols.push({'name': 'ismi_id', 'label': 'ISMI ID'});
283 }
284 if (attributes.indexOf('label') > -1) {
285 cols.push({'name': 'label', 'label': 'Label'});
286 }
287 attributes.forEach((att) => {
288 if (att != 'ismi_id' && att != 'label' && att != 'type' && att[0] != '_') {
289 cols.push({'name': att, 'label': att});
290 }
291 });
292
293 return cols;
258 } 294 }
259 295
260 /** 296 /**
261 * Run the given queries on the Neo4J server. 297 * Run the given queries on the Neo4J server.
262 * 298 *