diff --git a/application/src/main/java/com/hashmapinc/server/install/TempusInstallService.java b/application/src/main/java/com/hashmapinc/server/install/TempusInstallService.java index 1114d13c6..f1c965de1 100644 --- a/application/src/main/java/com/hashmapinc/server/install/TempusInstallService.java +++ b/application/src/main/java/com/hashmapinc/server/install/TempusInstallService.java @@ -123,12 +123,13 @@ public void performInstall() { componentDiscoveryService.discoverComponents(); + systemDataLoaderService.loadSystemThemes(); systemDataLoaderService.createSysAdmin(); systemDataLoaderService.createAdminSettings(); systemDataLoaderService.loadSystemWidgets(); systemDataLoaderService.loadSystemPlugins(); systemDataLoaderService.loadSystemRules(); - systemDataLoaderService.loadSystemThemes(); + if (loadDemo) { log.info("Loading demo data..."); diff --git a/application/src/main/java/com/hashmapinc/server/service/install/DefaultSystemDataLoaderService.java b/application/src/main/java/com/hashmapinc/server/service/install/DefaultSystemDataLoaderService.java index cd3be816e..539410a34 100644 --- a/application/src/main/java/com/hashmapinc/server/service/install/DefaultSystemDataLoaderService.java +++ b/application/src/main/java/com/hashmapinc/server/service/install/DefaultSystemDataLoaderService.java @@ -176,18 +176,24 @@ public void createAdminSettings() throws Exception { public void loadSystemThemes() throws Exception { - log.info("Loading theme data..."); - Theme theme1 = new Theme(); - theme1.setThemeName("Tempus Blue"); - theme1.setThemeValue("themeBlue"); - theme1.setThemeStatus(false); - themeService.saveTheme(theme1); - - Theme theme2 = new Theme(); - theme2.setThemeName("Tempus Dark"); - theme2.setThemeValue("themeDark"); - theme2.setThemeStatus(true); - themeService.saveTheme(theme2); + List theme = themeService.findAll(); + + if(theme.size() < 2) { + + log.info("Loading theme data..."); + Theme theme1 = new Theme(); + theme1.setThemeName("Tempus Blue"); + theme1.setThemeValue("themeBlue"); + theme1.setThemeStatus(false); + themeService.saveTheme(theme1); + + Theme theme2 = new Theme(); + theme2.setThemeName("Tempus Dark"); + theme2.setThemeValue("themeDark"); + theme2.setThemeStatus(true); + themeService.saveTheme(theme2); + + } } diff --git a/application/src/test/java/com/hashmapinc/server/controller/ControllerNoSqlTestSuite.java b/application/src/test/java/com/hashmapinc/server/controller/ControllerNoSqlTestSuite.java index 4cad94754..73744fc00 100644 --- a/application/src/test/java/com/hashmapinc/server/controller/ControllerNoSqlTestSuite.java +++ b/application/src/test/java/com/hashmapinc/server/controller/ControllerNoSqlTestSuite.java @@ -45,6 +45,11 @@ private static List getDataSetLists(){ dataSets.addAll(Arrays.asList( new ClassPathCQLDataSet("cassandra/upgrade/1.cql", false, false) )); + + dataSets.addAll(Arrays.asList( + new ClassPathCQLDataSet("cassandra/upgrade/2.cql", false, false) + )); + return dataSets; } diff --git a/application/src/test/java/com/hashmapinc/server/controller/ControllerSqlTestSuite.java b/application/src/test/java/com/hashmapinc/server/controller/ControllerSqlTestSuite.java index b6a2985df..bc70e68ed 100644 --- a/application/src/test/java/com/hashmapinc/server/controller/ControllerSqlTestSuite.java +++ b/application/src/test/java/com/hashmapinc/server/controller/ControllerSqlTestSuite.java @@ -33,6 +33,6 @@ public class ControllerSqlTestSuite { Arrays.asList("sql/schema.sql", "sql/system-data.sql"), "sql/drop-all-tables.sql", "sql-test.properties", - Arrays.asList("sql/upgrade/1.sql", "sql/upgrade/2.sql") + Arrays.asList("sql/upgrade/1.sql", "sql/upgrade/2.sql", "sql/upgrade/3.sql") ); } diff --git a/application/src/test/java/com/hashmapinc/server/mqtt/MqttSqlTestSuite.java b/application/src/test/java/com/hashmapinc/server/mqtt/MqttSqlTestSuite.java index 60957d645..9d368aaa9 100644 --- a/application/src/test/java/com/hashmapinc/server/mqtt/MqttSqlTestSuite.java +++ b/application/src/test/java/com/hashmapinc/server/mqtt/MqttSqlTestSuite.java @@ -32,5 +32,5 @@ public class MqttSqlTestSuite { Arrays.asList("sql/schema.sql", "sql/system-data.sql"), "sql/drop-all-tables.sql", "sql-test.properties", - Arrays.asList("sql/upgrade/1.sql", "sql/upgrade/2.sql")); + Arrays.asList("sql/upgrade/1.sql", "sql/upgrade/2.sql","sql/upgrade/3.sql")); } diff --git a/application/src/test/java/com/hashmapinc/server/system/SystemSqlTestSuite.java b/application/src/test/java/com/hashmapinc/server/system/SystemSqlTestSuite.java index 892c4eb3e..d33a16630 100644 --- a/application/src/test/java/com/hashmapinc/server/system/SystemSqlTestSuite.java +++ b/application/src/test/java/com/hashmapinc/server/system/SystemSqlTestSuite.java @@ -34,7 +34,7 @@ public class SystemSqlTestSuite { Arrays.asList("sql/schema.sql", "sql/system-data.sql"), "sql/drop-all-tables.sql", "sql-test.properties", - Arrays.asList("sql/upgrade/1.sql", "sql/upgrade/2.sql") + Arrays.asList("sql/upgrade/1.sql", "sql/upgrade/2.sql", "sql/upgrade/3.sql") ); diff --git a/dao/src/main/resources/cassandra/schema.cql b/dao/src/main/resources/cassandra/schema.cql index 5a1ec8aad..3752824e3 100644 --- a/dao/src/main/resources/cassandra/schema.cql +++ b/dao/src/main/resources/cassandra/schema.cql @@ -781,10 +781,3 @@ CREATE TABLE IF NOT EXISTS tempus.audit_log_by_tenant_id_partitions ( ) WITH CLUSTERING ORDER BY ( partition ASC ) AND compaction = { 'class' : 'LeveledCompactionStrategy' }; -CREATE TABLE IF NOT EXISTS tempus.theme ( - id uuid, - name text, - value text, - is_enabled boolean, - PRIMARY KEY (id,name) -); diff --git a/dao/src/main/resources/cassandra/upgrade/2.cql b/dao/src/main/resources/cassandra/upgrade/2.cql new file mode 100644 index 000000000..da073f95d --- /dev/null +++ b/dao/src/main/resources/cassandra/upgrade/2.cql @@ -0,0 +1,23 @@ +-- +-- Copyright © 2017-2018 Hashmap, Inc +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- + +CREATE TABLE IF NOT EXISTS tempus.theme ( + id uuid, + name text, + value text, + is_enabled boolean, + PRIMARY KEY (id,name) +); diff --git a/dao/src/main/resources/sql/schema.sql b/dao/src/main/resources/sql/schema.sql index c77e282b5..bbb9a9838 100644 --- a/dao/src/main/resources/sql/schema.sql +++ b/dao/src/main/resources/sql/schema.sql @@ -362,12 +362,6 @@ CREATE TABLE IF NOT EXISTS computation_job ( tenant_id varchar(31) ); -CREATE TABLE IF NOT EXISTS theme ( - id varchar (31) NOT NULL CONSTRAINT theme_pkey PRIMARY KEY, - name varchar, - value varchar, - is_enabled boolean - ); diff --git a/dao/src/main/resources/sql/upgrade/3.sql b/dao/src/main/resources/sql/upgrade/3.sql new file mode 100644 index 000000000..1ba968952 --- /dev/null +++ b/dao/src/main/resources/sql/upgrade/3.sql @@ -0,0 +1,23 @@ +-- +-- Copyright © 2017-2018 Hashmap, Inc +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- + + +CREATE TABLE IF NOT EXISTS theme ( + id varchar (31) NOT NULL CONSTRAINT theme_pkey PRIMARY KEY, + name varchar, + value varchar, + is_enabled boolean + ); diff --git a/dao/src/test/java/com/hashmapinc/server/dao/JpaDaoTestSuite.java b/dao/src/test/java/com/hashmapinc/server/dao/JpaDaoTestSuite.java index f681a2c56..227178791 100644 --- a/dao/src/test/java/com/hashmapinc/server/dao/JpaDaoTestSuite.java +++ b/dao/src/test/java/com/hashmapinc/server/dao/JpaDaoTestSuite.java @@ -33,7 +33,7 @@ public class JpaDaoTestSuite { Arrays.asList("sql/schema.sql", "sql/system-data.sql"), "sql/drop-all-tables.sql", "sql-test.properties", - Arrays.asList("sql/upgrade/1.sql", "sql/upgrade/2.sql") + Arrays.asList("sql/upgrade/1.sql", "sql/upgrade/2.sql", "sql/upgrade/3.sql") ); } diff --git a/dao/src/test/java/com/hashmapinc/server/dao/NoSqlDaoServiceTestSuite.java b/dao/src/test/java/com/hashmapinc/server/dao/NoSqlDaoServiceTestSuite.java index 986f18bea..48373ff25 100644 --- a/dao/src/test/java/com/hashmapinc/server/dao/NoSqlDaoServiceTestSuite.java +++ b/dao/src/test/java/com/hashmapinc/server/dao/NoSqlDaoServiceTestSuite.java @@ -45,6 +45,10 @@ private static List getDataSetLists(){ dataSets.addAll(Arrays.asList( new ClassPathCQLDataSet("cassandra/upgrade/1.cql", false, false) )); + dataSets.addAll(Arrays.asList( + new ClassPathCQLDataSet("cassandra/upgrade/2.cql", false, false) + )); + return dataSets; } diff --git a/dao/src/test/java/com/hashmapinc/server/dao/SqlDaoServiceTestSuite.java b/dao/src/test/java/com/hashmapinc/server/dao/SqlDaoServiceTestSuite.java index fe7ed2099..75aa456a9 100644 --- a/dao/src/test/java/com/hashmapinc/server/dao/SqlDaoServiceTestSuite.java +++ b/dao/src/test/java/com/hashmapinc/server/dao/SqlDaoServiceTestSuite.java @@ -33,6 +33,6 @@ public class SqlDaoServiceTestSuite { Arrays.asList("sql/schema.sql", "sql/system-data.sql"), "sql/drop-all-tables.sql", "sql-test.properties", - Arrays.asList("sql/upgrade/1.sql", "sql/upgrade/2.sql") + Arrays.asList("sql/upgrade/1.sql", "sql/upgrade/2.sql","sql/upgrade/3.sql") ); }