diff options
author | Abyss777 <abyss@fox5.ru> | 2017-07-20 17:12:29 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-07-20 17:12:29 +0500 |
commit | e00fbfa466b17e94f59e6ff8fefb83f08999b3ec (patch) | |
tree | 61302b7e3535f75925a2896a358ba0bb2492ca71 /src/org/traccar/database | |
parent | 0d5a1b36c704f3a79eceb2a1f19894f0438eb1b0 (diff) | |
download | traccar-server-e00fbfa466b17e94f59e6ff8fefb83f08999b3ec.tar.gz traccar-server-e00fbfa466b17e94f59e6ff8fefb83f08999b3ec.tar.bz2 traccar-server-e00fbfa466b17e94f59e6ff8fefb83f08999b3ec.zip |
Rename Identifiable and Extensible to BaseModel and ExtendedModel
Diffstat (limited to 'src/org/traccar/database')
-rw-r--r-- | src/org/traccar/database/AttributesManager.java | 4 | ||||
-rw-r--r-- | src/org/traccar/database/DataManager.java | 8 | ||||
-rw-r--r-- | src/org/traccar/database/DriversManager.java | 8 | ||||
-rw-r--r-- | src/org/traccar/database/ExtendedObjectManager.java | 4 | ||||
-rw-r--r-- | src/org/traccar/database/SimpleObjectManager.java | 22 |
5 files changed, 23 insertions, 23 deletions
diff --git a/src/org/traccar/database/AttributesManager.java b/src/org/traccar/database/AttributesManager.java index ebfdbc9b4..6531019d1 100644 --- a/src/org/traccar/database/AttributesManager.java +++ b/src/org/traccar/database/AttributesManager.java @@ -22,7 +22,7 @@ import org.traccar.model.AttributePermission; import org.traccar.model.Attribute; import org.traccar.model.DeviceAttribute; import org.traccar.model.GroupAttribute; -import org.traccar.model.Identifiable; +import org.traccar.model.BaseModel; public class AttributesManager extends ExtendedObjectManager { @@ -33,7 +33,7 @@ public class AttributesManager extends ExtendedObjectManager { } @Override - public void updateItem(Identifiable item) throws SQLException { + public void updateItem(BaseModel item) throws SQLException { Attribute attribute = (Attribute) item; getDataManager().updateObject(attribute); Attribute cachedAttribute = (Attribute) getById(item.getId()); diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java index 6c9cca86c..7497294a1 100644 --- a/src/org/traccar/database/DataManager.java +++ b/src/org/traccar/database/DataManager.java @@ -41,7 +41,7 @@ import org.traccar.helper.Log; import org.traccar.model.AttributeAlias; import org.traccar.model.Device; import org.traccar.model.Event; -import org.traccar.model.Identifiable; +import org.traccar.model.BaseModel; import org.traccar.model.Position; import org.traccar.model.Server; import org.traccar.model.Statistics; @@ -285,21 +285,21 @@ public class DataManager { return QueryBuilder.create(dataSource, getQuery(query)).executeQuery(clazz); } - public void addObject(Identifiable entity) throws SQLException { + public void addObject(BaseModel entity) throws SQLException { String query = "database.insert" + entity.getClass().getSimpleName(); entity.setId(QueryBuilder.create(dataSource, getQuery(query), true) .setObject(entity) .executeUpdate()); } - public void updateObject(Identifiable entity) throws SQLException { + public void updateObject(BaseModel entity) throws SQLException { String query = "database.update" + entity.getClass().getSimpleName(); QueryBuilder.create(dataSource, getQuery(query)) .setObject(entity) .executeUpdate(); } - public void removeObject(Class<? extends Identifiable> clazz, long entityId) throws SQLException { + public void removeObject(Class<? extends BaseModel> clazz, long entityId) throws SQLException { String query = "database.delete" + clazz.getSimpleName(); QueryBuilder.create(dataSource, getQuery(query)) .setLong("id", entityId) diff --git a/src/org/traccar/database/DriversManager.java b/src/org/traccar/database/DriversManager.java index 9b01f1a70..dba06a37f 100644 --- a/src/org/traccar/database/DriversManager.java +++ b/src/org/traccar/database/DriversManager.java @@ -25,7 +25,7 @@ import org.traccar.model.DeviceDriver; import org.traccar.model.Driver; import org.traccar.model.DriverPermission; import org.traccar.model.GroupDriver; -import org.traccar.model.Identifiable; +import org.traccar.model.BaseModel; public class DriversManager extends ExtendedObjectManager { @@ -42,7 +42,7 @@ public class DriversManager extends ExtendedObjectManager { if (getDataManager() != null) { try { clearItems(); - for (Identifiable item : getDataManager().getObjects(getBaseClass())) { + for (BaseModel item : getDataManager().getObjects(getBaseClass())) { putItem(item.getId(), item); driversByUniqueId.put(((Driver) item).getUniqueId(), (Driver) item); } @@ -54,13 +54,13 @@ public class DriversManager extends ExtendedObjectManager { } @Override - public void addItem(Identifiable item) throws SQLException { + public void addItem(BaseModel item) throws SQLException { super.addItem(item); driversByUniqueId.put(((Driver) item).getUniqueId(), (Driver) item); } @Override - public void updateItem(Identifiable item) throws SQLException { + public void updateItem(BaseModel item) throws SQLException { Driver driver = (Driver) item; getDataManager().updateObject(driver); Driver cachedDriver = (Driver) getById(driver.getId()); diff --git a/src/org/traccar/database/ExtendedObjectManager.java b/src/org/traccar/database/ExtendedObjectManager.java index a6508f066..caad989c2 100644 --- a/src/org/traccar/database/ExtendedObjectManager.java +++ b/src/org/traccar/database/ExtendedObjectManager.java @@ -29,7 +29,7 @@ import org.traccar.model.BaseDevicePermission; import org.traccar.model.BaseGroupPermission; import org.traccar.model.BaseUserPermission; import org.traccar.model.Device; -import org.traccar.model.Identifiable; +import org.traccar.model.BaseModel; public abstract class ExtendedObjectManager extends SimpleObjectManager { @@ -41,7 +41,7 @@ public abstract class ExtendedObjectManager extends SimpleObjectManager { private Class<? extends BaseGroupPermission> groupPermissionClass; protected ExtendedObjectManager(DataManager dataManager, - Class<? extends Identifiable> baseClass, + Class<? extends BaseModel> baseClass, Class<? extends BaseUserPermission> permissionClass, Class<? extends BaseDevicePermission> devicePermissionClass, Class<? extends BaseGroupPermission> groupPermissionClass) { diff --git a/src/org/traccar/database/SimpleObjectManager.java b/src/org/traccar/database/SimpleObjectManager.java index f5f807850..aae407b56 100644 --- a/src/org/traccar/database/SimpleObjectManager.java +++ b/src/org/traccar/database/SimpleObjectManager.java @@ -27,20 +27,20 @@ import java.util.concurrent.ConcurrentHashMap; import org.traccar.Context; import org.traccar.helper.Log; import org.traccar.model.BaseUserPermission; -import org.traccar.model.Identifiable; +import org.traccar.model.BaseModel; public abstract class SimpleObjectManager { private final DataManager dataManager; - private final Map<Long, Identifiable> items = new ConcurrentHashMap<>(); + private final Map<Long, BaseModel> items = new ConcurrentHashMap<>(); private final Map<Long, Set<Long>> userItems = new ConcurrentHashMap<>(); - private Class<? extends Identifiable> baseClass; + private Class<? extends BaseModel> baseClass; private Class<? extends BaseUserPermission> permissionClass; protected SimpleObjectManager(DataManager dataManager, - Class<? extends Identifiable> baseClass, + Class<? extends BaseModel> baseClass, Class<? extends BaseUserPermission> permissionClass) { this.dataManager = dataManager; this.baseClass = baseClass; @@ -51,11 +51,11 @@ public abstract class SimpleObjectManager { return dataManager; } - protected final Class<? extends Identifiable> getBaseClass() { + protected final Class<? extends BaseModel> getBaseClass() { return baseClass; } - public final Identifiable getById(long itemId) { + public final BaseModel getById(long itemId) { return items.get(itemId); } @@ -63,7 +63,7 @@ public abstract class SimpleObjectManager { items.clear(); } - protected final void putItem(long itemId, Identifiable item) { + protected final void putItem(long itemId, BaseModel item) { items.put(itemId, item); } @@ -90,7 +90,7 @@ public abstract class SimpleObjectManager { if (dataManager != null) { try { clearItems(); - for (Identifiable item : dataManager.getObjects(this.baseClass)) { + for (BaseModel item : dataManager.getObjects(this.baseClass)) { putItem(item.getId(), item); } } catch (SQLException error) { @@ -113,18 +113,18 @@ public abstract class SimpleObjectManager { } } - public void addItem(Identifiable item) throws SQLException { + public void addItem(BaseModel item) throws SQLException { dataManager.addObject(item); putItem(item.getId(), item); } - public void updateItem(Identifiable item) throws SQLException { + public void updateItem(BaseModel item) throws SQLException { dataManager.updateObject(item); putItem(item.getId(), item); } public void removeItem(long itemId) throws SQLException { - Identifiable item = getById(itemId); + BaseModel item = getById(itemId); if (item != null) { dataManager.removeObject(item.getClass(), itemId); removeCachedItem(itemId); |