From ae76cbf971bfc9e47ef21e87606dacc7c0e3ddc6 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Mon, 31 Jul 2017 14:08:36 +0500 Subject: Implement SQL requests construction --- setup/default.xml | 406 +----------------------------------------------------- 1 file changed, 1 insertion(+), 405 deletions(-) (limited to 'setup') diff --git a/setup/default.xml b/setup/default.xml index f0f9ef4a3..ea8c32fbd 100644 --- a/setup/default.xml +++ b/setup/default.xml @@ -29,163 +29,16 @@ true ./schema/changelog-master.xml - - - SELECT * FROM server - - - - UPDATE server SET - registration = :registration, - readonly = :readonly, - deviceReadonly = :deviceReadonly, - map = :map, - bingKey = :bingKey, - mapUrl = :mapUrl, - distanceUnit = :distanceUnit, - speedUnit = :speedUnit, - latitude = :latitude, - longitude = :longitude, - zoom = :zoom, - twelveHourFormat = :twelveHourFormat, - coordinateFormat = :coordinateFormat, - forceSettings = :forceSettings, - timezone = :timezone, - attributes = :attributes - WHERE id = :id - - + SELECT * FROM users WHERE email = :email - - SELECT * FROM users - - - - INSERT INTO users (name, email, phone, hashedPassword, salt, readonly, admin, map, distanceUnit, speedUnit, latitude, longitude, zoom, twelveHourFormat, coordinateFormat, disabled, expirationTime, deviceLimit, userLimit, deviceReadonly, token, timezone, attributes) - VALUES (:name, :email, :phone, :hashedPassword, :salt, :readonly, :admin, :map, :distanceUnit, :speedUnit, :latitude, :longitude, :zoom, :twelveHourFormat, :coordinateFormat, :disabled, :expirationTime, :deviceLimit, :userLimit, :deviceReadonly, :token, :timezone, :attributes) - - - - UPDATE users SET - name = :name, - email = :email, - phone = :phone, - readonly = :readonly, - admin = :admin, - map = :map, - distanceUnit = :distanceUnit, - speedUnit = :speedUnit, - latitude = :latitude, - longitude = :longitude, - zoom = :zoom, - twelveHourFormat = :twelveHourFormat, - coordinateFormat = :coordinateFormat, - disabled = :disabled, - expirationTime = :expirationTime, - deviceLimit = :deviceLimit, - userLimit = :userLimit, - deviceReadonly = :deviceReadonly, - token = :token, - timezone = :timezone, - attributes = :attributes - WHERE id = :id - - - - UPDATE users SET hashedPassword = :hashedPassword, salt = :salt WHERE id = :id - - - - DELETE FROM users WHERE id = :id - - - - SELECT userId, deviceId FROM user_device - - - - SELECT userId, groupId FROM user_group - - - - SELECT * FROM devices - - - - INSERT INTO devices (name, uniqueId, groupId, attributes, phone, model, contact, category) - VALUES (:name, :uniqueId, :groupId, :attributes, :phone, :model, :contact, :category) - - - - UPDATE devices SET - name = :name, - uniqueId = :uniqueId, - groupId = :groupId, - attributes = :attributes, - phone = :phone, - model = :model, - contact = :contact, - category = :category - WHERE id = :id - - - - UPDATE devices SET lastUpdate = :lastUpdate WHERE id = :id - - - - DELETE FROM devices WHERE id = :id - - - - INSERT INTO user_device (userId, deviceId) VALUES (:userId, :deviceId) - - - - DELETE FROM user_device WHERE userId = :userId AND deviceId = :deviceId - - - - SELECT * FROM groups - - - - INSERT INTO groups (name, groupId, attributes) VALUES (:name, :groupId, :attributes) - - - - UPDATE groups SET name = :name, groupId = :groupId, attributes = :attributes WHERE id = :id - - - - DELETE FROM groups WHERE id = :id - - - - INSERT INTO user_group (userId, groupId) VALUES (:userId, :groupId) - - - - DELETE FROM user_group WHERE userId = :userId AND groupId = :groupId - - SELECT * FROM positions WHERE deviceId = :deviceId AND fixTime BETWEEN :from AND :to ORDER BY fixTime - - SELECT * FROM positions WHERE id = :id - - - - INSERT INTO positions (deviceId, protocol, serverTime, deviceTime, fixTime, valid, latitude, longitude, altitude, speed, course, address, attributes, accuracy, network) - VALUES (:deviceId, :protocol, :now, :deviceTime, :fixTime, :valid, :latitude, :longitude, :altitude, :speed, :course, :address, :attributes, :accuracy, :network) - - SELECT positions.* FROM positions INNER JOIN devices ON positions.id = devices.positionid; @@ -194,102 +47,10 @@ UPDATE devices SET positionId = :id WHERE id = :deviceId - - SELECT * FROM events WHERE id = :id - - - - INSERT INTO events (type, serverTime, deviceId, positionId, geofenceId, attributes) - VALUES (:type, :serverTime, :deviceId, :positionId, :geofenceId, :attributes) - - SELECT * FROM events WHERE deviceId = :deviceId AND serverTime BETWEEN :from AND :to ORDER BY serverTime - - SELECT * FROM geofences - - - - INSERT INTO geofences (name, description, calendarid, area, attributes) - VALUES (:name, :description, :calendarid, :area, :attributes) - - - - UPDATE geofences SET - name = :name, - description = :description, - calendarid = :calendarid, - area = :area, - attributes = :attributes - WHERE id = :id - - - - DELETE FROM geofences WHERE id = :id - - - - SELECT userId, geofenceId FROM user_geofence - - - - INSERT INTO user_geofence (userId, geofenceId) VALUES (:userId, :geofenceId) - - - - DELETE FROM user_geofence WHERE userId = :userId AND geofenceId = :geofenceId - - - - SELECT groupId, geofenceId FROM group_geofence - - - - INSERT INTO group_geofence (groupId, geofenceId) VALUES (:groupId, :geofenceId) - - - - DELETE FROM group_geofence WHERE groupId = :groupId AND geofenceId = :geofenceId - - - - SELECT deviceId, geofenceId FROM device_geofence - - - - INSERT INTO device_geofence (deviceId, geofenceId) VALUES (:deviceId, :geofenceId) - - - - DELETE FROM device_geofence WHERE deviceId = :deviceId AND geofenceId = :geofenceId - - - - SELECT * FROM notifications - - - - INSERT INTO notifications (userId, type, web, mail, sms, attributes) - VALUES (:userId, :type, :web, :mail, :sms, :attributes) - - - - UPDATE notifications SET - userId = :userId, - type = :type, - web = :web, - mail = :mail, - sms = :sms, - attributes = :attributes - WHERE id = :id - - - - DELETE FROM notifications WHERE id = :id - - DELETE FROM positions WHERE serverTime < :serverTime AND id NOT IN (SELECT positionId FROM devices) @@ -323,171 +84,6 @@ SELECT * FROM statistics WHERE captureTime BETWEEN :from AND :to ORDER BY captureTime - - INSERT INTO statistics (captureTime, activeUsers, activeDevices, requests, messagesReceived, messagesStored, mailSent, smsSent, geocoderRequests, geolocationRequests, attributes) - VALUES (:captureTime, :activeUsers, :activeDevices, :requests, :messagesReceived, :messagesStored, :mailSent, :smsSent, :geocoderRequests, :geolocationRequests, :attributes) - - - - SELECT * FROM calendars - - - - INSERT INTO calendars (name, data, attributes) - VALUES (:name, :data, :attributes) - - - - UPDATE calendars SET - name = :name, - data = :data, - attributes = :attributes - WHERE id = :id - - - - DELETE FROM calendars WHERE id = :id - - - - SELECT userId, calendarId FROM user_calendar - - - - INSERT INTO user_calendar (userId, calendarId) VALUES (:userId, :calendarId) - - - - DELETE FROM user_calendar WHERE userId = :userId AND calendarId = :calendarId - - - - SELECT userId, managedUserId FROM user_user - - - - INSERT INTO user_user (userId, managedUserId) VALUES (:userId, :managedUserId) - - - - DELETE FROM user_user WHERE userId = :userId AND managedUserId = :managedUserId - - - - SELECT * FROM attributes - - - - INSERT INTO attributes (description, type, attribute, expression) - VALUES (:description, :type, :attribute, :expression) - - - - UPDATE attributes SET - description = :description, - type = :type, - attribute = :attribute, - expression = :expression - WHERE id = :id - - - - DELETE FROM attributes WHERE id = :id - - - - SELECT userId, attributeId FROM user_attribute - - - - INSERT INTO user_attribute (userId, attributeId) VALUES (:userId, :attributeId) - - - - DELETE FROM user_attribute WHERE userId = :userId AND attributeId = :attributeId - - - - SELECT groupId, attributeId FROM group_attribute - - - - INSERT INTO group_attribute (groupId, attributeId) VALUES (:groupId, :attributeId) - - - - DELETE FROM group_attribute WHERE groupId = :groupId AND attributeId = :attributeId - - - - SELECT deviceId, attributeId FROM device_attribute - - - - INSERT INTO device_attribute (deviceId, attributeId) VALUES (:deviceId, :attributeId) - - - - DELETE FROM device_attribute WHERE deviceId = :deviceId AND attributeId = :attributeId - - - - SELECT * FROM drivers - - - - INSERT INTO drivers (name, uniqueId, attributes) - VALUES (:name, :uniqueId, :attributes) - - - - UPDATE drivers SET - name = :name, - uniqueId = :uniqueId, - attributes = :attributes - WHERE id = :id - - - - DELETE FROM drivers WHERE id = :id - - - - SELECT userId, driverId FROM user_driver - - - - INSERT INTO user_driver (userId, driverId) VALUES (:userId, :driverId) - - - - DELETE FROM user_driver WHERE userId = :userId AND driverId = :driverId - - - - SELECT groupId, driverId FROM group_driver - - - - INSERT INTO group_driver (groupId, driverId) VALUES (:groupId, :driverId) - - - - DELETE FROM group_driver WHERE groupId = :groupId AND driverId = :driverId - - - - SELECT deviceId, driverId FROM device_driver - - - - INSERT INTO device_driver (deviceId, driverId) VALUES (:deviceId, :driverId) - - - - DELETE FROM device_driver WHERE deviceId = :deviceId AND driverId = :driverId - - 5001 -- cgit v1.2.3