From 7435630c5c4ab650664c7a860fb734201fe607fc Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Tue, 19 Mar 2019 12:22:45 +0100
Subject: [PATCH] model contains information about references

---
 frontend-js/src/main/js/map/data/MapModel.js  | 25 +++++++++++++++++++
 .../src/test/js/map/data/MapModel-test.js     |  3 ++-
 .../models/all/token=MOCK_TOKEN_ID&           |  2 +-
 3 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/frontend-js/src/main/js/map/data/MapModel.js b/frontend-js/src/main/js/map/data/MapModel.js
index dae3008905..41931eb75a 100644
--- a/frontend-js/src/main/js/map/data/MapModel.js
+++ b/frontend-js/src/main/js/map/data/MapModel.js
@@ -23,6 +23,7 @@ var Reaction = require('./Reaction');
  * @property {number} defaultCenterX
  * @property {number} defaultCenterY
  * @property {number} defaultZoomLevel
+ * @property {Annotation[]|AnnotationOptions[]} references
  */
 
 /**
@@ -70,6 +71,7 @@ function MapModel(configuration) {
       this.setDefaultCenterX(configuration.getDefaultCenterX());
       this.setDefaultCenterY(configuration.getDefaultCenterY());
       this.setDefaultZoomLevel(configuration.getDefaultZoomLevel());
+      this.setReferences(configuration.getReferences());
     } else {
       this.setId(configuration.idObject);
       this.setName(configuration.name);
@@ -82,6 +84,7 @@ function MapModel(configuration) {
       this.setDefaultCenterX(configuration.defaultCenterX);
       this.setDefaultCenterY(configuration.defaultCenterY);
       this.setDefaultZoomLevel(configuration.defaultZoomLevel);
+      this.setReferences(configuration.references);
     }
   }
 }
@@ -871,5 +874,27 @@ MapModel.prototype.getSbmlParameterById = function (id) {
   }
 };
 
+/**
+ *
+ * @returns {Annotation[]}
+ */
+MapModel.prototype.getReferences = function () {
+  return this.references;
+};
+
+/**
+ *
+ * @param {Annotation[]} references
+ */
+MapModel.prototype.setReferences = function (references) {
+  if (references === undefined) {
+    throw new Error("references must be defined");
+  }
+  this.references = [];
+  for (var i = 0; i < references.length; i++) {
+    this.references.push(new Annotation(references[i]));
+  }
+};
+
 
 module.exports = MapModel;
diff --git a/frontend-js/src/test/js/map/data/MapModel-test.js b/frontend-js/src/test/js/map/data/MapModel-test.js
index 032cf06adf..31c2a0171b 100644
--- a/frontend-js/src/test/js/map/data/MapModel-test.js
+++ b/frontend-js/src/test/js/map/data/MapModel-test.js
@@ -18,7 +18,8 @@ describe('MapModel', function () {
 
   it("constructor", function () {
     var model = new MapModel({
-      idObject: 123
+      idObject: 123,
+      references: []
     });
 
     assert.equal(123, model.getId());
diff --git a/frontend-js/testFiles/apiCalls/projects/drug_target_sample/models/all/token=MOCK_TOKEN_ID& b/frontend-js/testFiles/apiCalls/projects/drug_target_sample/models/all/token=MOCK_TOKEN_ID&
index f1af2a5915..9cdb9611d0 100644
--- a/frontend-js/testFiles/apiCalls/projects/drug_target_sample/models/all/token=MOCK_TOKEN_ID&
+++ b/frontend-js/testFiles/apiCalls/projects/drug_target_sample/models/all/token=MOCK_TOKEN_ID&
@@ -1 +1 @@
-[{"version":null,"name":"UNKNOWN DISEASE MAP","idObject":20637,"tileSize":256,"width":1305,"height":473,"defaultCenterX":null,"defaultCenterY":null,"defaultZoomLevel":null,"minZoom":2,"maxZoom":5,"submodelType":"UNKNOWN"}]
\ No newline at end of file
+[{"version":null,"name":"UNKNOWN DISEASE MAP","idObject":20637,"tileSize":256,"width":1305,"height":473,"defaultCenterX":null,"defaultCenterY":null,"defaultZoomLevel":null,"minZoom":2,"maxZoom":5,"submodelType":"UNKNOWN","references":[]}]
\ No newline at end of file
-- 
GitLab