From 5359ebdb7ef4b4c3c44018ed4add71210b92c5e1 Mon Sep 17 00:00:00 2001
From: Daniel <daniel@harvey>
Date: Mon, 5 Aug 2019 17:05:40 +0200
Subject: [PATCH] MAINT: Refactoring for new upstream repository

---
 .gitlab-ci.yml                        |  6 +++---
 README.md                             |  2 +-
 doc/multipurpose_subdomains.md        | 22 ----------------------
 patches/patch20170825-2.0.30/test.sql | 25 ++++++++++++++++++++-----
 procedures/insertIsaCache.sql         | 26 ++++++++++++++++++++++++--
 5 files changed, 48 insertions(+), 33 deletions(-)
 delete mode 100644 doc/multipurpose_subdomains.md

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 62aa449..f7e5f2d 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -23,7 +23,7 @@
 #
 
 variables:
-  CI_REGISTRY_IMAGE: $CI_REGISTRY/caosdb-mysqlbackend-testenv:latest
+  CI_REGISTRY_IMAGE: $CI_REGISTRY/caosdb-sqlbackend-testenv:latest
   # With dind the docker deamon is available on the network 
   DOCKER_HOST: tcp://docker:2375/
   # When using dind, it's wise to use the overlayfs driver for
@@ -45,8 +45,8 @@ trigger_build:
   script:
     - /usr/bin/curl -X POST
       -F token=8f29e5eeb7db2123d9c2bb84634da2
-      -F "variables[MYSQLBACKEND]=$CI_COMMIT_REF_NAME"
-      -F "variables[TriggerdBy]=MYSQLBACKEND"
+      -F "variables[SQLBACKEND]=$CI_COMMIT_REF_NAME"
+      -F "variables[TriggerdBy]=SQLBACKEND"
       -F "variables[TriggerdByHash]=$CI_COMMIT_SHORT_SHA"
       -F ref=master https://gitlab.indiscale.com/api/v4/projects/14/trigger/pipeline
 
diff --git a/README.md b/README.md
index 92c6a40..10fe96d 100644
--- a/README.md
+++ b/README.md
@@ -14,7 +14,7 @@ setup this code.
 # Further Reading
 
 Please refer to the [official gitlab repository of the CaosDB
-project](https://gitlab.gwdg.de/bmp-caosdb/caosdb) for more information.
+project](https://gitlab.com/caosdb/caosdb) for more information.
 
 # License
 
diff --git a/doc/multipurpose_subdomains.md b/doc/multipurpose_subdomains.md
deleted file mode 100644
index 28001cc..0000000
--- a/doc/multipurpose_subdomains.md
+++ /dev/null
@@ -1,22 +0,0 @@
-# Multipurpose subdomains #
-Multipurpose subdomains are generically used to work with composite
-properties. Currently implemented examples are:
-- Properties with units (if multiple Properties exist)
-- Lists
-- Name overrides
-
-## Example ##
-Let's have a look at this *Record* (simplified XML):
-
-```xml
-<R1>
-    <P1 name="Comment">Hello World</P1>
-    <P2 name="voltage" unit="V">
-        23
-    </P2>
-    <P3 comment="list of something">
-        V1, V2, V3, V4, ...
-    </P3>
-</R1>
-```
-
diff --git a/patches/patch20170825-2.0.30/test.sql b/patches/patch20170825-2.0.30/test.sql
index d303b37..3b0faef 100644
--- a/patches/patch20170825-2.0.30/test.sql
+++ b/patches/patch20170825-2.0.30/test.sql
@@ -22,6 +22,21 @@
  */
 SET @@SESSION.max_sp_recursion_depth=25;
 
+-- Inheritance:
+--
+--    0
+--    |
+--    1
+--    |
+--    2
+--   / \
+--  3   4
+--   \ /
+--    5
+--    |
+--    6
+--
+
 SET FOREIGN_KEY_CHECKS = 0;
 delete from isa_cache;
 -- simple 1->0
@@ -203,7 +218,7 @@ call isSubtype(1,2);
 call isSubtype(0,2);
 call isSubtype(0,1);
 
--- remove 2->1 
+-- remove 2->1
 CREATE TEMPORARY TABLE expected1 SELECT * from isa_cache;
 call deleteIsa(2);
 select "subtypes:";
@@ -253,7 +268,7 @@ call isSubtype(0,1);
 
 -- and add 2->1 again
 call insertIsa(2,1);
-SELECT A.*, B.* FROM isa_cache AS A LEFT JOIN expected1 AS B ON (A.child = B.child AND A.parent=B.parent AND A.rpath=B.rpath) WHERE A.child IS NULL OR B.child IS NULL; 
+SELECT A.*, B.* FROM isa_cache AS A LEFT JOIN expected1 AS B ON (A.child = B.child AND A.parent=B.parent AND A.rpath=B.rpath) WHERE A.child IS NULL OR B.child IS NULL;
 SELECT A.*, B.* FROM isa_cache AS A RIGHT JOIN expected1 AS B ON (A.child = B.child AND A.parent=B.parent AND A.rpath=B.rpath) WHERE A.child IS NULL OR B.child IS NULL;
 
 -- remove 4->2
@@ -306,7 +321,7 @@ call isSubtype(5,6);
 
 -- and add 4->2 again
 call insertIsa(4,2);
-SELECT A.*, B.* FROM isa_cache AS A LEFT JOIN expected1 AS B ON (A.child = B.child AND A.parent=B.parent AND A.rpath=B.rpath) WHERE A.child IS NULL OR B.child IS NULL; 
+SELECT A.*, B.* FROM isa_cache AS A LEFT JOIN expected1 AS B ON (A.child = B.child AND A.parent=B.parent AND A.rpath=B.rpath) WHERE A.child IS NULL OR B.child IS NULL;
 SELECT A.*, B.* FROM isa_cache AS A RIGHT JOIN expected1 AS B ON (A.child = B.child AND A.parent=B.parent AND A.rpath=B.rpath) WHERE A.child IS NULL OR B.child IS NULL;
 
 -- remove 5->4 and 5->3
@@ -407,7 +422,7 @@ call isSubtype(6,3);
 
 -- and add 5->3 again
 call insertIsa(5,3);
-SELECT A.*, B.* FROM isa_cache AS A LEFT JOIN expected1 AS B ON (A.child = B.child AND A.parent=B.parent AND A.rpath=B.rpath) WHERE A.child IS NULL OR B.child IS NULL; 
+SELECT A.*, B.* FROM isa_cache AS A LEFT JOIN expected1 AS B ON (A.child = B.child AND A.parent=B.parent AND A.rpath=B.rpath) WHERE A.child IS NULL OR B.child IS NULL;
 SELECT A.*, B.* FROM isa_cache AS A RIGHT JOIN expected1 AS B ON (A.child = B.child AND A.parent=B.parent AND A.rpath=B.rpath) WHERE A.child IS NULL OR B.child IS NULL;
 
 -- add cycle 0->3
@@ -428,7 +443,7 @@ call isSubtype(3,2);
 
 -- remove cycle 0->3
 call deleteIsa(0);
-SELECT A.*, B.* FROM isa_cache AS A LEFT JOIN expected1 AS B ON (A.child = B.child AND A.parent=B.parent AND A.rpath=B.rpath) WHERE A.child IS NULL OR B.child IS NULL; 
+SELECT A.*, B.* FROM isa_cache AS A LEFT JOIN expected1 AS B ON (A.child = B.child AND A.parent=B.parent AND A.rpath=B.rpath) WHERE A.child IS NULL OR B.child IS NULL;
 SELECT A.*, B.* FROM isa_cache AS A RIGHT JOIN expected1 AS B ON (A.child = B.child AND A.parent=B.parent AND A.rpath=B.rpath) WHERE A.child IS NULL OR B.child IS NULL;
 
 call deleteIsa(1);
diff --git a/procedures/insertIsaCache.sql b/procedures/insertIsaCache.sql
index 4ff1a46..735ba12 100644
--- a/procedures/insertIsaCache.sql
+++ b/procedures/insertIsaCache.sql
@@ -30,11 +30,33 @@ BEGIN
 	
     -- foreach supertype of p
     --     INSERT (c, supertype, p);
-    INSERT IGNORE INTO isa_cache SELECT c AS child, i.parent AS parent, IF(p=i.rpath or i.rpath=parent, p, concat(p, ">", i.rpath)) AS rpath FROM isa_cache AS i WHERE i.child = p;
+    INSERT IGNORE INTO isa_cache SELECT
+        c
+            AS child,
+        i.parent
+            AS parent,
+        IF(p=i.rpath or i.rpath=parent,
+           p,
+           concat(p, ">", i.rpath))
+            AS rpath
+        FROM isa_cache AS i WHERE i.child = p;
     
     
     -- foreach subtype of c insert each supertype of p
-    INSERT IGNORE INTO isa_cache SELECT l.child, r.parent, if(l.rpath=l.child and r.rpath=c, c, concat(if(l.rpath=l.child,c,concat(l.rpath, '>', c)), if(r.rpath=c,'',concat('>', r.rpath)))) AS rpath FROM isa_cache as l INNER JOIN isa_cache as r ON (l.parent = r.child AND l.parent=c);
+    INSERT IGNORE INTO isa_cache SELECT
+        l.child,
+        r.parent,
+        if(l.rpath=l.child and r.rpath=c,
+           c,
+           concat(if(l.rpath=l.child,
+                     c,
+                     concat(l.rpath, '>', c)),
+                  if(r.rpath=c,
+                     '',
+                     concat('>', r.rpath))))
+            AS rpath
+        FROM isa_cache as l
+            INNER JOIN isa_cache as r ON (l.parent = r.child AND l.parent=c);
 
 
 	
-- 
GitLab