aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database/DataManager.java
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-12-14 17:34:34 +0500
committerAbyss777 <abyss@fox5.ru>2016-12-14 18:02:17 +0500
commitfff8f0c792606daff151624479d9ae9dc54187d5 (patch)
tree97e0ab38de08aba1a7b7adf90283df82d850a3ad /src/org/traccar/database/DataManager.java
parent4557cf912fada1dc249333aa05215b0116b8ebab (diff)
downloadtrackermap-server-fff8f0c792606daff151624479d9ae9dc54187d5.tar.gz
trackermap-server-fff8f0c792606daff151624479d9ae9dc54187d5.tar.bz2
trackermap-server-fff8f0c792606daff151624479d9ae9dc54187d5.zip
Calendars implementation
Diffstat (limited to 'src/org/traccar/database/DataManager.java')
-rw-r--r--src/org/traccar/database/DataManager.java43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java
index 8be53ad7b..278109229 100644
--- a/src/org/traccar/database/DataManager.java
+++ b/src/org/traccar/database/DataManager.java
@@ -37,6 +37,8 @@ import liquibase.resource.ResourceAccessor;
import org.traccar.Config;
import org.traccar.helper.Log;
import org.traccar.model.AttributeAlias;
+import org.traccar.model.Calendar;
+import org.traccar.model.CalendarPermission;
import org.traccar.model.Device;
import org.traccar.model.DevicePermission;
import org.traccar.model.Event;
@@ -484,4 +486,45 @@ public class DataManager {
.executeUpdate());
}
+ public Collection<Calendar> getCalendars() throws SQLException {
+ return QueryBuilder.create(dataSource, getQuery("database.selectCalendarsAll"))
+ .executeQuery(Calendar.class);
+ }
+
+ public void addCalendar(Calendar calendar) throws SQLException {
+ calendar.setId(QueryBuilder.create(dataSource, getQuery("database.insertCalendar"), true)
+ .setObject(calendar)
+ .executeUpdate());
+ }
+
+ public void updateCalendar(Calendar calendar) throws SQLException {
+ QueryBuilder.create(dataSource, getQuery("database.updateCalendar"))
+ .setObject(calendar)
+ .executeUpdate();
+ }
+
+ public void removeCalendar(long calendarId) throws SQLException {
+ QueryBuilder.create(dataSource, getQuery("database.deleteCalendar"))
+ .setLong("id", calendarId)
+ .executeUpdate();
+ }
+
+ public Collection<CalendarPermission> getCalendarPermissions() throws SQLException {
+ return QueryBuilder.create(dataSource, getQuery("database.selectCalendarPermissions"))
+ .executeQuery(CalendarPermission.class);
+ }
+
+ public void linkCalendar(long userId, long calendarId) throws SQLException {
+ QueryBuilder.create(dataSource, getQuery("database.linkCalendar"))
+ .setLong("userId", userId)
+ .setLong("calendarId", calendarId)
+ .executeUpdate();
+ }
+
+ public void unlinkCalendar(long userId, long calendarId) throws SQLException {
+ QueryBuilder.create(dataSource, getQuery("database.unlinkCalendar"))
+ .setLong("userId", userId)
+ .setLong("calendarId", calendarId)
+ .executeUpdate();
+ }
}