From cfceba4f5e1e84fb1690ee95eb3c7172771e9e30 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 18 Dec 2015 22:04:13 +1300 Subject: Add user creation to database changelog --- database/db.changelog-3.0.xml | 8 +++++ debug.xml | 1 - src/org/traccar/database/DataManager.java | 58 ------------------------------- 3 files changed, 8 insertions(+), 59 deletions(-) diff --git a/database/db.changelog-3.0.xml b/database/db.changelog-3.0.xml index 4f94494b4..fd400ff3d 100644 --- a/database/db.changelog-3.0.xml +++ b/database/db.changelog-3.0.xml @@ -190,5 +190,13 @@ + + + + + + + + diff --git a/debug.xml b/debug.xml index ccfb5579e..2b9d84faa 100644 --- a/debug.xml +++ b/debug.xml @@ -47,7 +47,6 @@ jdbc:h2:./target/database sa - true false ./database/db.changelog-master.xml diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java index 37cbac35d..e2e1d9f18 100644 --- a/src/org/traccar/database/DataManager.java +++ b/src/org/traccar/database/DataManager.java @@ -30,9 +30,7 @@ import javax.naming.InitialContext; import javax.sql.DataSource; import liquibase.Contexts; -import liquibase.LabelExpression; import liquibase.Liquibase; -import liquibase.changelog.ChangeSetStatus; import liquibase.database.Database; import liquibase.database.DatabaseFactory; import liquibase.exception.LiquibaseException; @@ -48,7 +46,6 @@ import org.traccar.model.Position; import org.traccar.model.Server; import org.traccar.model.User; import org.traccar.web.AsyncServlet; -import org.traccar.web.JsonConverter; public class DataManager implements IdentityManager { @@ -169,62 +166,7 @@ public class DataManager implements IdentityManager { Liquibase liquibase = new Liquibase( config.getString("database.changelog"), resourceAccessor, database); - boolean first = true; - for (ChangeSetStatus status : liquibase.getChangeSetStatuses(null, new LabelExpression())) { - if (!status.getWillRun()) { - first = false; - break; - } - } - liquibase.update(new Contexts()); - - if (first) { - User admin = new User(); - admin.setName("admin"); - admin.setEmail("admin"); - admin.setAdmin(true); - admin.setPassword("admin"); - addUser(admin); - - mockData(admin.getId()); - } - } - } - - private void mockData(long userId) { - if (config.getBoolean("database.mock")) { - try { - - Device device = new Device(); - device.setName("test1"); - device.setUniqueId("123456789012345"); - addDevice(device); - linkDevice(userId, device.getId()); - - Position position = new Position(); - position.setDeviceId(device.getId()); - - position.setTime(JsonConverter.parseDate("2015-05-22T12:00:01.000Z")); - position.setLatitude(-36.8785803); - position.setLongitude(174.7281713); - addPosition(position); - - position.setTime(JsonConverter.parseDate("2015-05-22T12:00:02.000Z")); - position.setLatitude(-36.8870932); - position.setLongitude(174.7473116); - addPosition(position); - - position.setTime(JsonConverter.parseDate("2015-05-22T12:00:03.000Z")); - position.setLatitude(-36.8932371); - position.setLongitude(174.7743053); - addPosition(position); - - updateLatestPosition(position); - - } catch (SQLException error) { - Log.warning(error); - } } } -- cgit v1.2.3