From 08e72d86b48dd6d29cf8596c29ee687dc04a216b Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Fri, 2 Nov 2018 11:25:23 +0100
Subject: [PATCH] map name column

---
 .../main/js/gui/export/ElementExportPanel.js  | 13 ++++++++-
 .../js/gui/export/ElementExportPanel-test.js  |  2 +-
 frontend-js/src/test/js/helper.js             | 28 +++++++++++--------
 3 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/frontend-js/src/main/js/gui/export/ElementExportPanel.js b/frontend-js/src/main/js/gui/export/ElementExportPanel.js
index 7a9c8489d7..4c7ddf0538 100644
--- a/frontend-js/src/main/js/gui/export/ElementExportPanel.js
+++ b/frontend-js/src/main/js/gui/export/ElementExportPanel.js
@@ -136,7 +136,7 @@ ElementExportPanel.prototype._createResponseCell = function (alias, column) {
   if (Functions.isString(column.method)) {
     valuePromise = Promise.resolve(alias[column.method]());
   } else {
-    valuePromise = Promise.resolve(column.method(alias));
+    valuePromise = Promise.resolve(column.method(alias, this.getProject()));
   }
   return valuePromise.then(function (value) {
     if (column.formatFunction !== undefined) {
@@ -199,6 +199,17 @@ ElementExportPanel.prototype.getAllColumns = function () {
     "columnName": "modelId",
     "method": "getModelId",
     "name": "Map id"
+  }, {
+    /**
+     *
+     * @param {BioEntity} bioEntity
+     * @param {Project} project
+     * @returns {string}
+     */
+    "method": function (bioEntity, project) {
+      return project.getModelById(bioEntity.getModelId()).getName();
+    },
+    "name": "Map name"
   }, {
     "columnName": "type",
     "method": "getType",
diff --git a/frontend-js/src/test/js/gui/export/ElementExportPanel-test.js b/frontend-js/src/test/js/gui/export/ElementExportPanel-test.js
index 03cddb2805..47d361373c 100644
--- a/frontend-js/src/test/js/gui/export/ElementExportPanel-test.js
+++ b/frontend-js/src/test/js/gui/export/ElementExportPanel-test.js
@@ -280,7 +280,7 @@ describe('ElementExportPanel', function () {
         project: helper.createProject(),
         configuration: helper.getConfiguration()
       });
-      var alias = helper.createAlias();
+      var alias = helper.createAlias(exportObject.getProject().getModels()[0]);
       var desc = "test\ntest2\n";
       alias.setDescription(desc);
       return exportObject.createResponseRow(alias, exportObject.getAllColumns(), []).then(function (rowString) {
diff --git a/frontend-js/src/test/js/helper.js b/frontend-js/src/test/js/helper.js
index a3ee154868..9d5029bc73 100644
--- a/frontend-js/src/test/js/helper.js
+++ b/frontend-js/src/test/js/helper.js
@@ -200,15 +200,17 @@ Helper.prototype.createUser = function () {
 
 /**
  *
- * @param {AbstractCustomMap} [map]
+ * @param {AbstractCustomMap| MapModel} [map]
  * @returns {Alias}
  */
 Helper.prototype.createAlias = function (map) {
   var mapId;
-  if (map === undefined) {
-    mapId = this.idCounter++;
-  } else {
+  if (map instanceof AbstractCustomMap) {
+    mapId = map.getId();
+  } else if (map instanceof Model) {
     mapId = map.getId();
+  } else {
+    mapId = this.idCounter++;
   }
   var result = new Alias({
     idObject: this.idCounter++,
@@ -223,8 +225,10 @@ Helper.prototype.createAlias = function (map) {
     },
     references: []
   });
-  if (map !== undefined) {
+  if (map instanceof AbstractCustomMap) {
     map.getModel().addAlias(result);
+  } else if (map instanceof Model) {
+    map.addAlias(result);
   }
   return result;
 };
@@ -462,10 +466,10 @@ Helper.prototype.createSbmlFunction = function () {
     "functionId": "fun",
     "name": "fun name",
     "definition": "<lambda>" +
-    "<bvar><ci> x </ci></bvar>" +
-    "<bvar><ci> y </ci></bvar>" +
-    "<apply><plus/><ci> x </ci><ci> y </ci><cn type=\"integer\"> 2 </cn></apply>" +
-    "</lambda>\n\n",
+      "<bvar><ci> x </ci></bvar>" +
+      "<bvar><ci> y </ci></bvar>" +
+      "<apply><plus/><ci> x </ci><ci> y </ci><cn type=\"integer\"> 2 </cn></apply>" +
+      "</lambda>\n\n",
     "arguments": ["x", "y"],
     "id": this.idCounter++
   });
@@ -486,9 +490,9 @@ Helper.prototype.createKineticLaw = function () {
   return new KineticLaw({
     "parameterIds": [],
     "definition": '<math xmlns="http://www.w3.org/1998/Math/MathML">' +
-    '<apply xmlns="http://www.w3.org/1998/Math/MathML">' +
-    '<divide/><apply><times/><ci>ca1</ci><apply><plus/><ci>sa1</ci><ci>sa2</ci></apply></apply><cn type=\"integer\"> 2 </cn>' +
-    '</apply></math>',
+      '<apply xmlns="http://www.w3.org/1998/Math/MathML">' +
+      '<divide/><apply><times/><ci>ca1</ci><apply><plus/><ci>sa1</ci><ci>sa2</ci></apply></apply><cn type=\"integer\"> 2 </cn>' +
+      '</apply></math>',
     "functionIds": []
   });
 };
-- 
GitLab