aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database/DataManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/database/DataManager.java')
-rw-r--r--src/org/traccar/database/DataManager.java84
1 files changed, 84 insertions, 0 deletions
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java
index 0c5f458a2..acbaac17b 100644
--- a/src/org/traccar/database/DataManager.java
+++ b/src/org/traccar/database/DataManager.java
@@ -37,13 +37,17 @@ import liquibase.resource.ResourceAccessor;
import org.traccar.Config;
import org.traccar.helper.Log;
import org.traccar.model.AttributeAlias;
+import org.traccar.model.AttributePermission;
import org.traccar.model.Calendar;
import org.traccar.model.CalendarPermission;
+import org.traccar.model.Attribute;
import org.traccar.model.Device;
+import org.traccar.model.DeviceAttribute;
import org.traccar.model.DevicePermission;
import org.traccar.model.Event;
import org.traccar.model.Geofence;
import org.traccar.model.Group;
+import org.traccar.model.GroupAttribute;
import org.traccar.model.GroupGeofence;
import org.traccar.model.GroupPermission;
import org.traccar.model.Notification;
@@ -548,4 +552,84 @@ public class DataManager {
.executeUpdate();
}
+ public Collection<Attribute> getAttributes() throws SQLException {
+ return QueryBuilder.create(dataSource, getQuery("database.selectAttributes"))
+ .executeQuery(Attribute.class);
+ }
+
+ public void addAttribute(Attribute attribute) throws SQLException {
+ attribute.setId(QueryBuilder.create(dataSource, getQuery("database.insertAttribute"), true)
+ .setObject(attribute)
+ .executeUpdate());
+ }
+
+ public void updateAttribute(Attribute attribute) throws SQLException {
+ QueryBuilder.create(dataSource, getQuery("database.updateAttribute"))
+ .setObject(attribute)
+ .executeUpdate();
+ }
+
+ public void removeAttribute(long computedAttributeId) throws SQLException {
+ QueryBuilder.create(dataSource, getQuery("database.deleteAttribute"))
+ .setLong("id", computedAttributeId)
+ .executeUpdate();
+ }
+
+ public Collection<AttributePermission> getAttributePermissions() throws SQLException {
+ return QueryBuilder.create(dataSource, getQuery("database.selectAttributePermissions"))
+ .executeQuery(AttributePermission.class);
+ }
+
+ public void linkAttribute(long userId, long attributeId) throws SQLException {
+ QueryBuilder.create(dataSource, getQuery("database.linkAttribute"))
+ .setLong("userId", userId)
+ .setLong("attributeId", attributeId)
+ .executeUpdate();
+ }
+
+ public void unlinkAttribute(long userId, long attributeId) throws SQLException {
+ QueryBuilder.create(dataSource, getQuery("database.unlinkAttribute"))
+ .setLong("userId", userId)
+ .setLong("attributeId", attributeId)
+ .executeUpdate();
+ }
+
+ public Collection<GroupAttribute> getGroupAttributes() throws SQLException {
+ return QueryBuilder.create(dataSource, getQuery("database.selectGroupAttributes"))
+ .executeQuery(GroupAttribute.class);
+ }
+
+ public void linkGroupAttribute(long groupId, long attributeId) throws SQLException {
+ QueryBuilder.create(dataSource, getQuery("database.linkGroupAttribute"))
+ .setLong("groupId", groupId)
+ .setLong("attributeId", attributeId)
+ .executeUpdate();
+ }
+
+ public void unlinkGroupAttribute(long groupId, long attributeId) throws SQLException {
+ QueryBuilder.create(dataSource, getQuery("database.unlinkGroupAttribute"))
+ .setLong("groupId", groupId)
+ .setLong("attributeId", attributeId)
+ .executeUpdate();
+ }
+
+ public Collection<DeviceAttribute> getDeviceAttributes() throws SQLException {
+ return QueryBuilder.create(dataSource, getQuery("database.selectDeviceAttributes"))
+ .executeQuery(DeviceAttribute.class);
+ }
+
+ public void linkDeviceAttribute(long deviceId, long attributeId) throws SQLException {
+ QueryBuilder.create(dataSource, getQuery("database.linkDeviceAttribute"))
+ .setLong("deviceId", deviceId)
+ .setLong("attributeId", attributeId)
+ .executeUpdate();
+ }
+
+ public void unlinkDeviceAttribute(long deviceId, long attributeId) throws SQLException {
+ QueryBuilder.create(dataSource, getQuery("database.unlinkDeviceAttribute"))
+ .setLong("deviceId", deviceId)
+ .setLong("attributeId", attributeId)
+ .executeUpdate();
+ }
+
}