From e72569af7f8e4ca57a37f9ec2990cf7ec083e794 Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Tue, 2 Apr 2019 16:45:49 +0200
Subject: [PATCH] map model contains information about creation and
 modification dates

---
 frontend-js/src/main/js/map/data/MapModel.js  | 50 ++++++++++++++++++-
 .../src/test/js/map/data/MapModel-test.js     |  3 +-
 2 files changed, 51 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 851a82f0cd..0149eed1f9 100644
--- a/frontend-js/src/main/js/map/data/MapModel.js
+++ b/frontend-js/src/main/js/map/data/MapModel.js
@@ -34,6 +34,8 @@ var Reaction = require('./Reaction');
  * @property {number} defaultZoomLevel
  * @property {Annotation[]|AnnotationOptions[]} references
  * @property {Author[]} authors
+ * @property {string[]} modificationDates
+ * @property {string} creationDate
  */
 
 /**
@@ -68,7 +70,8 @@ function MapModel(configuration) {
   this._sbmlParameters = [];
   this._references = [];
   this._authors = [];
-
+  this._modificationDates = [];
+  this._creationDate = undefined;
 
   if (configuration !== undefined) {
     if (configuration instanceof MapModel) {
@@ -85,6 +88,8 @@ function MapModel(configuration) {
       this.setDefaultZoomLevel(configuration.getDefaultZoomLevel());
       this.setReferences(configuration.getReferences());
       this.setAuthors(configuration.getAuthors());
+      this.setModificationDates(configuration.getModificationDates());
+      this.setCreationDate(configuration.getCreationDate());
     } else {
       this.setId(configuration.idObject);
       this.setName(configuration.name);
@@ -99,6 +104,8 @@ function MapModel(configuration) {
       this.setDefaultZoomLevel(configuration.defaultZoomLevel);
       this.setReferences(configuration.references);
       this.setAuthors(configuration.authors);
+      this.setModificationDates(configuration.modificationDates);
+      this.setCreationDate(configuration.creationDate);
     }
   }
 }
@@ -932,4 +939,45 @@ MapModel.prototype.setAuthors = function (authors) {
   }
 };
 
+/**
+ *
+ * @returns {string[]}
+ */
+MapModel.prototype.getModificationDates = function () {
+  return this._modificationDates;
+};
+
+/**
+ *
+ * @param {string[]} modificationDates
+ */
+MapModel.prototype.setModificationDates = function (modificationDates) {
+  if (modificationDates === undefined) {
+    throw new Error("modification dates must be defined");
+  }
+  this._modificationDates = [];
+  for (var i = 0; i < modificationDates.length; i++) {
+    this._modificationDates.push(modificationDates[i]);
+  }
+};
+
+/**
+ *
+ * @returns {string}
+ */
+MapModel.prototype.getCreationDate = function () {
+  return this._creationDate;
+};
+
+/**
+ *
+ * @param {string|null} creationDate
+ */
+MapModel.prototype.setCreationDate = function (creationDate) {
+  if (creationDate === null) {
+    creationDate = undefined;
+  }
+  this._creationDate = creationDate;
+};
+
 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 102a312eb9..3c1c86c52f 100644
--- a/frontend-js/src/test/js/map/data/MapModel-test.js
+++ b/frontend-js/src/test/js/map/data/MapModel-test.js
@@ -19,7 +19,8 @@ describe('MapModel', function () {
   var emptyData = {
     idObject: 123,
     references: [],
-    authors: []
+    authors: [],
+    modificationDates: []
   };
 
   it("constructor", function () {
-- 
GitLab