# HG changeset patch
# User casties
# Date 1452788375 -3600
# Node ID 9f5473536a98dc2fd03efa9db31826620d48616b
# Parent b06a5d61afed6d1bf9d95f4b15321494d031fa06
more query generation.
diff -r b06a5d61afed -r 9f5473536a98 app/app.component.ts
--- a/app/app.component.ts Wed Jan 13 18:57:31 2016 +0100
+++ b/app/app.component.ts Thu Jan 14 17:19:35 2016 +0100
@@ -10,7 +10,7 @@
template: `
My Angular 2 Text: {{title}}
Selected option: {{selectedOption}}
-
+
`,
directives: [QuerySelectComponent, QueryResultComponent],
diff -r b06a5d61afed -r 9f5473536a98 app/query-select.component.ts
--- a/app/query-select.component.ts Wed Jan 13 18:57:31 2016 +0100
+++ b/app/query-select.component.ts Thu Jan 14 17:19:35 2016 +0100
@@ -53,6 +53,6 @@
this.selectedQuery = selected;
console.debug("selected option:", selected);
var query = {'mode': this.selectedMode, 'objectType': selected};
- this._queryService.queryState.queries.push(query);
+ this._queryService.setQueryStep(0, query);
}
}
diff -r b06a5d61afed -r 9f5473536a98 app/query-state.ts
--- a/app/query-state.ts Wed Jan 13 18:57:31 2016 +0100
+++ b/app/query-state.ts Thu Jan 14 17:19:35 2016 +0100
@@ -1,5 +1,7 @@
export interface QueryState {
- queries: QueryStep[];
+ steps: QueryStep[];
+ cypherQuery: string;
+ cypherParams: any;
results: any[];
numResults: number;
}
\ No newline at end of file
diff -r b06a5d61afed -r 9f5473536a98 app/query-step.ts
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/query-step.ts Thu Jan 14 17:19:35 2016 +0100
@@ -0,0 +1,4 @@
+export interface QueryStep {
+ mode: string;
+ objectType?: string;
+}
\ No newline at end of file
diff -r b06a5d61afed -r 9f5473536a98 app/query.service.ts
--- a/app/query.service.ts Wed Jan 13 18:57:31 2016 +0100
+++ b/app/query.service.ts Thu Jan 14 17:19:35 2016 +0100
@@ -19,7 +19,12 @@
{id: 'att_contains', label: 'Attribute contains'}];
constructor(private _http: Http) {
- this.queryState = {'queries': [], 'results': [], numResults: 0};
+ this.queryState = {
+ 'steps': [],
+ 'cypherQuery': '',
+ 'cyperParams': {},
+ 'results': [],
+ numResults: 0};
}
getQueryModes(): QueryMode[] {
@@ -54,6 +59,21 @@
);
}
+ setQueryStep(index: number, step: QueryStep) {
+ this.queryState.steps[index] = step;
+ this.createCypherQuery();
+ }
+
+ createCypherQuery() {
+ var cypher = '';
+ var step = this.queryState.steps[0];
+ if (step.mode.id === 'type_is') {
+ cypher = `MATCH (e:${step.objectType}) return e`;
+ }
+
+ this.queryState.cypherQuery = cypher;
+ }
+
fetchCypherResult(query: string, params = {}) {
var headers = new Headers();
headers.append('Authorization', 'Basic ' + btoa('neo4j' + ':' + 'neo5j'));
diff -r b06a5d61afed -r 9f5473536a98 query-step.ts
--- a/query-step.ts Wed Jan 13 18:57:31 2016 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-export interface QueryStep {
- mode: string;
- objectType?: string;
-}
\ No newline at end of file