From f03cb69ffffc4e27158c55d9114fa15612c8eb4a Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Mon, 29 Oct 2018 10:27:17 +0100
Subject: [PATCH] submodel connection type mapping changed to string

---
 .../mapviewer/model/map/model/SubmodelConnection.java     | 3 +++
 ...12.2.0.20181024.5__submodel_type_changed_to_string.sql | 8 ++++++++
 2 files changed, 11 insertions(+)
 create mode 100644 persist/src/main/resources/db/migration/12.2.0~alpha.0/V12.2.0.20181024.5__submodel_type_changed_to_string.sql

diff --git a/model/src/main/java/lcsb/mapviewer/model/map/model/SubmodelConnection.java b/model/src/main/java/lcsb/mapviewer/model/map/model/SubmodelConnection.java
index d8b581c8c0..d3fbc2027f 100644
--- a/model/src/main/java/lcsb/mapviewer/model/map/model/SubmodelConnection.java
+++ b/model/src/main/java/lcsb/mapviewer/model/map/model/SubmodelConnection.java
@@ -6,6 +6,8 @@ import javax.persistence.DiscriminatorColumn;
 import javax.persistence.DiscriminatorType;
 import javax.persistence.DiscriminatorValue;
 import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
 import javax.persistence.FetchType;
 import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
@@ -63,6 +65,7 @@ public abstract class SubmodelConnection implements Serializable {
   /**
    * Type of the connection.
    */
+  @Enumerated(EnumType.STRING)
   private SubmodelType type;
 
   /**
diff --git a/persist/src/main/resources/db/migration/12.2.0~alpha.0/V12.2.0.20181024.5__submodel_type_changed_to_string.sql b/persist/src/main/resources/db/migration/12.2.0~alpha.0/V12.2.0.20181024.5__submodel_type_changed_to_string.sql
new file mode 100644
index 0000000000..e1de1b2d33
--- /dev/null
+++ b/persist/src/main/resources/db/migration/12.2.0~alpha.0/V12.2.0.20181024.5__submodel_type_changed_to_string.sql
@@ -0,0 +1,8 @@
+-- change in layout
+alter table submodel_connection_table add column type_string varchar(31);
+update submodel_connection_table set type_string='DOWNSTREAM_TARGETS' where type=0;
+update submodel_connection_table set type_string='PATHWAY' where type=1;
+update submodel_connection_table set type_string='UNKNOWN' where type=2;
+
+alter table submodel_connection_table drop column type;
+alter table submodel_connection_table rename column type_string to type;
-- 
GitLab