Mercurial > hg > ng2-query-ismi
view src/app/query-state.js @ 61:6adf95d9a190 webpack
fix missing resultInfo. add column template for WITNESS.
author | Robert Casties <casties@mpiwg-berlin.mpg.de> |
---|---|
date | Mon, 24 Apr 2017 19:39:25 +0200 |
parents | 3b4046e0cc02 |
children |
line wrap: on
line source
"use strict"; var query_step_1 = require('./query-step'); var query_mode_1 = require('./query-mode'); var QueryState = (function () { function QueryState() { this.steps = []; } /** * Sets the query state from a string. */ QueryState.prototype.setStateFromString = function (newStateString) { try { // state string is json var newState = JSON.parse(newStateString); // state should be list of steps if (!Array.isArray(newState)) return; var newSteps_1 = []; newState.forEach(function (elem) { // step is an array [mode, params] if (!Array.isArray(elem)) return; var mode = elem[0]; // get QueryMode object var qm = query_mode_1.getQueryModeById(mode); var params = elem[1]; if (qm != null && params != null) { // construct QueryStep var qs = new query_step_1.QueryStep(qm, params); newSteps_1.push(qs); } }); if (newSteps_1.length > 0) { // set new state this.steps = newSteps_1; } } catch (e) { console.error("Unable to set state from string: " + newStateString); } }; QueryState.prototype.getNumSteps = function () { return this.steps.length; }; /** * Returns the current query state as a string. */ QueryState.prototype.getStateAsString = function () { var stateList = this.steps.map(function (qs) { return [qs.mode.id, qs.params]; }); var stateStr = JSON.stringify(stateList); return stateStr; }; /** * Returns the cypher query as text for display. */ QueryState.prototype.getQueryText = function () { var text = this.resultCypherQuery; var hasParams = false; for (var k in this.cypherQueryParams) { if (!hasParams) { hasParams = true; text += '\n'; } text += "[" + k + "='" + this.cypherQueryParams[k] + "'] "; } return text; }; return QueryState; }()); exports.QueryState = QueryState; //# sourceMappingURL=query-state.js.map