Commit b5612c1c authored by Piotr Gawron's avatar Piotr Gawron
Browse files

data in model API doesn't include: submodels,...

data in model API doesn't include: submodels, centerLatLng,topLeftLatLng,bottomRightLatLng + models moved to project in JS
parent aff4902e
Pipeline #4382 passed with stage
in 2 minutes and 29 seconds
......@@ -45,30 +45,38 @@
"litemol": "github:dsehnal/LiteMol#a5419c696faa84530dd93acd55b747cf8136902b"
},
"dependencies": {
"ProtVista": {
"version": "git://github.com/davidhoksza/protvista.git#4e4bb737ba1e183291505bd25f8bae2e651ce21e",
"dev": true,
"requires": {
"d3": "3.5.17",
"file-saver": "1.3.3",
"jquery": "2.2.4",
"jszip": "3.1.4",
"underscore": "1.8.3"
},
"dependencies": {
"jquery": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/jquery/-/jquery-2.2.4.tgz",
"integrity": "sha1-LInWiJterFIqfuoywUUhVZxsvwI=",
"dev": true
}
}
},
"jquery": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/jquery/-/jquery-3.3.1.tgz",
"integrity": "sha512-Ubldcmxp5np52/ENotGxlLe6aGMvmF4R8S6tZjsP6Knsaxd/xp3Zrh50cG93lR6nPXyUFwzN3ZSOQI0wRJNdGg==",
"dev": true
}
}
},
"ProtVista": {
"version": "git://github.com/davidhoksza/protvista.git#4e4bb737ba1e183291505bd25f8bae2e651ce21e",
"dev": true,
"requires": {
"d3": "3.5.17",
"file-saver": "1.3.3",
"jquery": "2.2.4",
"jszip": "3.1.4",
"underscore": "1.8.3"
},
"dependencies": {
"jquery": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/jquery/-/jquery-2.2.4.tgz",
"integrity": "sha1-LInWiJterFIqfuoywUUhVZxsvwI=",
"dev": true
},
"litemol": {
"version": "github:dsehnal/LiteMol#a5419c696faa84530dd93acd55b747cf8136902b",
"dev": true,
"requires": {
"@types/react": "15.6.14",
"@types/react-dom": "15.5.7"
}
}
}
},
......@@ -2050,14 +2058,6 @@
"immediate": "3.0.6"
}
},
"litemol": {
"version": "github:dsehnal/LiteMol#a5419c696faa84530dd93acd55b747cf8136902b",
"dev": true,
"requires": {
"@types/react": "15.6.14",
"@types/react-dom": "15.5.7"
}
},
"lodash": {
"version": "4.17.4",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz",
......
......@@ -807,7 +807,7 @@ ServerConnector.getProject = function (projectId) {
}
project = self._projectsById[projectId];
return self.getModels(projectId).then(function (models) {
project.setModel(models[0]);
project.setModels(models);
return self.getOverlays({
projectId: projectId,
publicOverlay: true
......
......@@ -7,6 +7,7 @@ var Promise = require("bluebird");
var AbstractGuiElement = require('./AbstractGuiElement');
var Alias = require('../map/data/Alias');
var Reaction = require('../map/data/Reaction');
// noinspection JSUnusedLocalSymbols
var logger = require('../logger');
var Functions = require('../Functions');
......@@ -18,7 +19,7 @@ function CommentDialog(params) {
autoOpen : false,
resizable : false,
width : window.innerWidth / 2,
height : window.innerHeight / 2,
height : window.innerHeight / 2
});
}
......
......@@ -253,12 +253,7 @@ AbstractExportPanel.prototype._getCompartmentNames = function () {
};
AbstractExportPanel.prototype.getModels = function () {
var self = this;
var models = [self.getProject().getModel()];
for (var i = 0; i < self.getProject().getModel().getSubmodels().length; i++) {
models.push(self.getProject().getModel().getSubmodels()[i]);
}
return models;
return this.getProject().getModels();
};
AbstractExportPanel.prototype._getAllCompartments = function () {
......
......@@ -10,209 +10,206 @@ var logger = require('../../logger');
var Promise = require("bluebird");
function ElementExportPanel(params) {
params.panelName = "elementExport";
AbstractExportPanel.call(this, params);
params.panelName = "elementExport";
AbstractExportPanel.call(this, params);
}
ElementExportPanel.prototype = Object.create(AbstractExportPanel.prototype);
ElementExportPanel.prototype.constructor = ElementExportPanel;
ElementExportPanel.prototype.init = function () {
var self = this;
var element = self.getElement();
var configuration;
return ServerConnector.getConfiguration().then(function (result) {
configuration = result;
var typeDiv = self._createSelectTypeDiv(configuration.getElementTypes());
element.appendChild(typeDiv);
element.appendChild(self._createSelectColumnDiv(self.getAllColumns()));
return ServerConnector.getProjectStatistics(self.getProject().getProjectId());
}).then(function (statistics) {
return self._createMiriamTypeDiv(statistics.getElementAnnotations());
}).then(function (div) {
element.appendChild(div);
return self._createSelectIncludedCompartmentDiv();
}).then(function (div) {
element.appendChild(div);
return self._createSelectExcludedCompartmentDiv();
}).then(function (div) {
element.appendChild(div);
element.appendChild(self._createDownloadButton());
}).then(function () {
$(window).trigger('resize');
});
var self = this;
var element = self.getElement();
var configuration;
return ServerConnector.getConfiguration().then(function (result) {
configuration = result;
var typeDiv = self._createSelectTypeDiv(configuration.getElementTypes());
element.appendChild(typeDiv);
element.appendChild(self._createSelectColumnDiv(self.getAllColumns()));
return ServerConnector.getProjectStatistics(self.getProject().getProjectId());
}).then(function (statistics) {
return self._createMiriamTypeDiv(statistics.getElementAnnotations());
}).then(function (div) {
element.appendChild(div);
return self._createSelectIncludedCompartmentDiv();
}).then(function (div) {
element.appendChild(div);
return self._createSelectExcludedCompartmentDiv();
}).then(function (div) {
element.appendChild(div);
element.appendChild(self._createDownloadButton());
}).then(function () {
$(window).trigger('resize');
});
};
ElementExportPanel.prototype.createResponseString = function () {
var self = this;
var types, miriamTypes;
var includedCompartmentIds = [];
var excludedCompartmentIds = [];
var models = [self.getProject().getModel()];
for (var i = 0; i < self.getProject().getModel().getSubmodels().length; i++) {
models.push(self.getProject().getModel().getSubmodels()[i]);
var self = this;
var types, miriamTypes;
var includedCompartmentIds = [];
var excludedCompartmentIds = [];
var models = self.getProject().getModels();
var elements = [];
return self.getSelectedTypes().then(function (result) {
if (result.length === 0) {
return Promise.reject(new GuiMessageError("You must select at least one type"));
}
var elements = [];
return self.getSelectedTypes().then(function (result) {
if (result.length === 0) {
return Promise.reject(new GuiMessageError("You must select at least one type"));
}
types = result;
return self.getSelectedIncludedCompartments();
}).then(function (result) {
result.forEach(function (compartment) {
includedCompartmentIds.push(compartment.getId());
});
return self.getSelectedExcludedCompartments();
}).then(function (result) {
result.forEach(function (compartment) {
excludedCompartmentIds.push(compartment.getId());
});
var promises = [];
for (var i = 0; i < models.length; i++) {
promises.push(models[i].getAliases({
type: types,
complete: true,
includedCompartmentIds: includedCompartmentIds,
excludedCompartmentIds: excludedCompartmentIds,
}));
}
return Promise.all(promises);
}).then(function (aliasesByModel) {
for (var i = 0; i < aliasesByModel.length; i++) {
for (var j = 0; j < aliasesByModel[i].length; j++) {
elements.push(aliasesByModel[i][j]);
}
}
return self.getSelectedMiriamTypes();
}).then(function (result) {
miriamTypes = result;
return self.getSelectedColumns();
}).then(function (selectedColumns) {
if (selectedColumns.length === 0) {
return Promise.reject(new GuiMessageError("You must select at least one column"));
}
var rows = [];
rows.push(self.createResponseHeader(selectedColumns, miriamTypes));
for (var i = 0; i < elements.length; i++) {
rows.push(self.createResponseRow(elements[i], selectedColumns, miriamTypes));
}
return rows.join("\n");
types = result;
return self.getSelectedIncludedCompartments();
}).then(function (result) {
result.forEach(function (compartment) {
includedCompartmentIds.push(compartment.getId());
});
return self.getSelectedExcludedCompartments();
}).then(function (result) {
result.forEach(function (compartment) {
excludedCompartmentIds.push(compartment.getId());
});
var promises = [];
for (var i = 0; i < models.length; i++) {
promises.push(models[i].getAliases({
type: types,
complete: true,
includedCompartmentIds: includedCompartmentIds,
excludedCompartmentIds: excludedCompartmentIds,
}));
}
return Promise.all(promises);
}).then(function (aliasesByModel) {
for (var i = 0; i < aliasesByModel.length; i++) {
for (var j = 0; j < aliasesByModel[i].length; j++) {
elements.push(aliasesByModel[i][j]);
}
}
return self.getSelectedMiriamTypes();
}).then(function (result) {
miriamTypes = result;
return self.getSelectedColumns();
}).then(function (selectedColumns) {
if (selectedColumns.length === 0) {
return Promise.reject(new GuiMessageError("You must select at least one column"));
}
var rows = [];
rows.push(self.createResponseHeader(selectedColumns, miriamTypes));
for (var i = 0; i < elements.length; i++) {
rows.push(self.createResponseRow(elements[i], selectedColumns, miriamTypes));
}
return rows.join("\n");
});
};
ElementExportPanel.prototype.createResponseRow = function (alias, columns, miriamTypes) {
var stringBuilder = [];
var i, value;
for (i = 0; i < columns.length; i++) {
var column = columns[i];
value = alias[column.method]();
if (column.formatFunction !== undefined) {
value = column.formatFunction(value);
}
if (value instanceof String || typeof value === "string") {
value = value.replace(/[\n\r]/g, ' ');
}
stringBuilder.push(value);
var stringBuilder = [];
var i, value;
for (i = 0; i < columns.length; i++) {
var column = columns[i];
value = alias[column.method]();
if (column.formatFunction !== undefined) {
value = column.formatFunction(value);
}
if (value instanceof String || typeof value === "string") {
value = value.replace(/[\n\r]/g, ' ');
}
for (i = 0; i < miriamTypes.length; i++) {
value = "";
var miriamType = miriamTypes[i];
var references = alias.getReferences();
for (var j = 0; j < references.length; j++) {
var reference = references[j];
if (reference.getType() === miriamType.getName()) {
value += reference.getResource() + ",";
}
}
stringBuilder.push(value);
stringBuilder.push(value);
}
for (i = 0; i < miriamTypes.length; i++) {
value = "";
var miriamType = miriamTypes[i];
var references = alias.getReferences();
for (var j = 0; j < references.length; j++) {
var reference = references[j];
if (reference.getType() === miriamType.getName()) {
value += reference.getResource() + ",";
}
}
var result = stringBuilder.join("\t");
return result;
stringBuilder.push(value);
}
var result = stringBuilder.join("\t");
return result;
};
ElementExportPanel.prototype.getAllColumns = function () {
return [{
"columnName": "id",
"method": "getId",
"name": "Id",
}, {
"columnName": "name",
"method": "getName",
"name": "Name",
}, {
"columnName": "description",
"method": "getDescription",
"name": "Description",
}, {
"columnName": "modelId",
"method": "getModelId",
"name": "Model",
}, {
"columnName": "type",
"method": "getType",
"name": "Type",
}, {
"columnName": "complexId",
"method": "getComplexId",
"name": "Complex",
}, {
"columnName": "compartmentId",
"method": "getCompartmentId",
"name": "Compartment",
}, {
"columnName": "charge",
"method": "getCharge",
"name": "Charge",
}, {
"columnName": "symbol",
"method": "getSymbol",
"name": "Symbol",
}, {
"columnName": "fullName",
"method": "getFullName",
"name": "Full name",
}, {
"columnName": "abbreviation",
"method": "getAbbreviation",
"name": "Abbreviation",
}, {
"columnName": "formula",
"method": "getFormula",
"name": "Formula",
}, {
"columnName": "synonyms",
"method": "getSynonyms",
"name": "Synonyms",
}, {
"columnName": "formerSymbols",
"method": "getFormerSymbols",
"name": "Former symbols",
}, {
"columnName": "references",
"method": "getReferences",
"name": "References",
"formatFunction": function (references) {
var stringBuilder = [];
for (var i = 0; i < references.length; i++) {
var reference = references[i];
stringBuilder.push(reference.getType() + ":" + reference.getResource());
}
return stringBuilder.join(",");
},
}, {
"columnName": "linkedSubmodelId",
"method": "getLinkedSubmodelId",
"name": "Linked submodel",
}, {
"columnName": "elementId",
"method": "getElementId",
"name": "Element external id",
},];
return [{
"columnName": "id",
"method": "getId",
"name": "Id",
}, {
"columnName": "name",
"method": "getName",
"name": "Name",
}, {
"columnName": "description",
"method": "getDescription",
"name": "Description",
}, {
"columnName": "modelId",
"method": "getModelId",
"name": "Model",
}, {
"columnName": "type",
"method": "getType",
"name": "Type",
}, {
"columnName": "complexId",
"method": "getComplexId",
"name": "Complex",
}, {
"columnName": "compartmentId",
"method": "getCompartmentId",
"name": "Compartment",
}, {
"columnName": "charge",
"method": "getCharge",
"name": "Charge",
}, {
"columnName": "symbol",
"method": "getSymbol",
"name": "Symbol",
}, {
"columnName": "fullName",
"method": "getFullName",
"name": "Full name",
}, {
"columnName": "abbreviation",
"method": "getAbbreviation",
"name": "Abbreviation",
}, {
"columnName": "formula",
"method": "getFormula",
"name": "Formula",
}, {
"columnName": "synonyms",
"method": "getSynonyms",
"name": "Synonyms",
}, {
"columnName": "formerSymbols",
"method": "getFormerSymbols",
"name": "Former symbols",
}, {
"columnName": "references",
"method": "getReferences",
"name": "References",
"formatFunction": function (references) {
var stringBuilder = [];
for (var i = 0; i < references.length; i++) {
var reference = references[i];
stringBuilder.push(reference.getType() + ":" + reference.getResource());
}
return stringBuilder.join(",");
},
}, {
"columnName": "linkedSubmodelId",
"method": "getLinkedSubmodelId",
"name": "Linked submodel",
}, {
"columnName": "elementId",
"method": "getElementId",
"name": "Element external id",
},];
};
......
......@@ -17,43 +17,43 @@ function NetworkExportPanel(params) {
NetworkExportPanel.prototype = Object.create(AbstractExportPanel.prototype);
NetworkExportPanel.prototype.constructor = NetworkExportPanel;
NetworkExportPanel.prototype.init = function() {
NetworkExportPanel.prototype.init = function () {
var self = this;
var element = self.getElement();
var configuration;
return ServerConnector.getConfiguration().then(function(result) {
return ServerConnector.getConfiguration().then(function (result) {
configuration = result;
var typeDiv = self._createSelectTypeDiv(configuration.getElementTypes());
element.appendChild(typeDiv);
element.appendChild(self._createSelectColumnDiv(self.getAllColumns()));
return ServerConnector.getProjectStatistics(self.getProject().getProjectId());
}).then(function(statistics) {
}).then(function (statistics) {
return self._createMiriamTypeDiv(statistics.getReactionAnnotations());
}).then(function(div) {
}).then(function (div) {
element.appendChild(div);
return self._createSelectIncludedCompartmentDiv();
}).then(function(div) {
}).then(function (div) {
element.appendChild(div);
return self._createSelectExcludedCompartmentDiv();
}).then(function(div) {
}).then(function (div) {
element.appendChild(div);
element.appendChild(self._createDownloadButton());
}).then(function() {
}).then(function () {
$(window).trigger('resize');
});
};
NetworkExportPanel.prototype.getAllColumns = function() {
return [ {
"columnName" : "elements",
"method" : "getElements",
"name" : "Elements",
"formatFunction" : function(elements, reaction, elementIds) {
NetworkExportPanel.prototype.getAllColumns = function () {
return [{
"columnName": "elements",
"method": "getElements",
"name": "Elements",
"formatFunction": function (elements, reaction, elementIds) {
var stringBuilder = [];
var type;
var elementFormat = function(element) {
var elementFormat = function (element) {