From 51704590a835057bf4850a5eaf8c5037d20f648a Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 28 Dec 2020 17:02:23 -0800 Subject: Migrate long config keys --- src/main/java/org/traccar/config/Config.java | 22 +++---- src/main/java/org/traccar/config/Keys.java | 86 ++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+), 11 deletions(-) (limited to 'src/main/java/org/traccar/config') diff --git a/src/main/java/org/traccar/config/Config.java b/src/main/java/org/traccar/config/Config.java index 6cc21cbeb..713f5c607 100644 --- a/src/main/java/org/traccar/config/Config.java +++ b/src/main/java/org/traccar/config/Config.java @@ -117,17 +117,17 @@ public class Config { } public long getLong(ConfigKey key) { - return getLong(key.getKey()); - } - - @Deprecated - public long getLong(String key) { - return getLong(key, 0); - } - - @Deprecated - public long getLong(String key, long defaultValue) { - return hasKey(key) ? Long.parseLong(getString(key)) : defaultValue; + String value = getString(key.getKey()); + if (value != null) { + return Long.parseLong(value); + } else { + Long defaultValue = key.getDefaultValue(); + if (defaultValue != null) { + return defaultValue; + } else { + return 0; + } + } } public double getDouble(ConfigKey key) { diff --git a/src/main/java/org/traccar/config/Keys.java b/src/main/java/org/traccar/config/Keys.java index 3a42a66a1..ea3176afd 100644 --- a/src/main/java/org/traccar/config/Keys.java +++ b/src/main/java/org/traccar/config/Keys.java @@ -161,6 +161,45 @@ public final class Keys { "database.saveOriginal", Collections.singletonList(KeyType.GLOBAL)); + /** + * Default category for auto-registered devices. + */ + public static final ConfigKey DATABASE_REGISTER_UNKNOWN_DEFAULT_CATEGORY = new ConfigKey<>( + "database.registerUnknown.defaultCategory", + Collections.singletonList(KeyType.GLOBAL)); + + /** + * The group id assigned to auto-registered devices. + */ + public static final ConfigKey DATABASE_REGISTER_UNKNOWN_DEFAULT_GROUP_ID = new ConfigKey<>( + "database.registerUnknown.defaultGroupId", + Collections.singletonList(KeyType.GLOBAL)); + + /** + * Minimum device refresh timeout in seconds. Default timeout is 5 minutes. + */ + public static final ConfigKey DATABASE_REFRESH_DELAY = new ConfigKey<>( + "database.refreshDelay", + Collections.singletonList(KeyType.GLOBAL), + 300L); + + /** + * If no data is reported by a device for the given amount of time, status changes from online to unknown. Value is + * in seconds. Default timeout is 10 minutes. + */ + public static final ConfigKey STATUS_TIMEOUT = new ConfigKey<>( + "status.timeout", + Collections.singletonList(KeyType.GLOBAL), + 600L); + + /** + * WebSocket connection timeout in milliseconds. Default timeout is 10 minutes. + */ + public static final ConfigKey WEB_TIMEOUT = new ConfigKey<>( + "web.timeout", + Collections.singletonList(KeyType.GLOBAL), + 60000L); + /** * Enable positions forwarding to other web server. */ @@ -233,6 +272,53 @@ public final class Keys { "forward.retry.limit", Collections.singletonList(KeyType.GLOBAL)); + /** + * Maximum time period for reports in seconds. Can be useful to prevent users to request unreasonably long reports. + * By default there is no limit. + */ + public static final ConfigKey REPORT_PERIOD_LIMIT = new ConfigKey<>( + "report.periodLimit", + Collections.singletonList(KeyType.GLOBAL)); + + /** + * Trips less than minimal duration and minimal distance are ignored. 300 seconds and 500 meters are default. + */ + public static final ConfigKey REPORT_TRIP_MINIMAL_TRIP_DISTANCE = new ConfigKey<>( + "report.trip.minimalTripDistance", + Collections.singletonList(KeyType.GLOBAL), + 500L); + + /** + * Trips less than minimal duration and minimal distance are ignored. 300 seconds and 500 meters are default. + */ + public static final ConfigKey REPORT_TRIP_MINIMAL_TRIP_DURATION = new ConfigKey<>( + "report.trip.minimalTripDuration", + Collections.singletonList(KeyType.GLOBAL), + 300L); + + /** + * Parking less than minimal duration does not cut trip. Default 300 seconds. + */ + public static final ConfigKey REPORT_TRIP_MINIMAL_PARKING_DURATION = new ConfigKey<>( + "report.trip.minimalParkingDuration", + Collections.singletonList(KeyType.GLOBAL), + 300L); + + /** + * Gaps of more than specified time are counted as stops. Default value is one hour. + */ + public static final ConfigKey REPORT_TRIP_MINIMAL_NO_DATA_DURATION = new ConfigKey<>( + "report.trip.minimalNoDataDuration", + Collections.singletonList(KeyType.GLOBAL), + 3600L); + + /** + * Flag to enable ignition use for trips calculation. + */ + public static final ConfigKey REPORT_TRIP_USE_IGNITION = new ConfigKey<>( + "report.trip.useIgnition", + Collections.singletonList(KeyType.GLOBAL)); + /** * Boolean flag to enable or disable position filtering. */ -- cgit v1.2.3