Search in sources :

Example 1 with CommandsManager

use of org.traccar.database.CommandsManager in project traccar by tananaev.

the class Context method init.

public static void init(String[] arguments) throws Exception {
    config = new Config();
    if (arguments.length <= 0) {
        throw new RuntimeException("Configuration file is not provided");
    }
    config.load(arguments[0]);
    loggerEnabled = config.getBoolean("logger.enable");
    if (loggerEnabled) {
        Log.setupLogger(config);
    }
    objectMapper = new ObjectMapper();
    objectMapper.setConfig(objectMapper.getSerializationConfig().without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS));
    if (Context.getConfig().getBoolean("mapper.prettyPrintedJson")) {
        objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
    }
    if (config.hasKey("database.url")) {
        dataManager = new DataManager(config);
    }
    if (config.getBoolean("ldap.enable")) {
        ldapProvider = new LdapProvider(config);
    }
    mediaManager = new MediaManager(config.getString("media.path"));
    if (dataManager != null) {
        usersManager = new UsersManager(dataManager);
        groupsManager = new GroupsManager(dataManager);
        deviceManager = new DeviceManager(dataManager);
    }
    identityManager = deviceManager;
    if (config.getBoolean("geocoder.enable")) {
        geocoder = initGeocoder();
    }
    if (config.getBoolean("geolocation.enable")) {
        initGeolocationModule();
    }
    if (config.getBoolean("web.enable")) {
        webServer = new WebServer(config, dataManager.getDataSource());
    }
    permissionsManager = new PermissionsManager(dataManager, usersManager);
    connectionManager = new ConnectionManager();
    tripsConfig = initTripsConfig();
    if (config.getBoolean("event.enable")) {
        initEventsModule();
    }
    serverManager = new ServerManager();
    if (config.getBoolean("event.forward.enable")) {
        if (Context.getConfig().getBoolean("event.forward.payloadAsParamMode")) {
            eventForwarder = new MultiPartEventForwarder();
        } else {
            eventForwarder = new JsonTypeEventForwarder();
        }
    }
    attributesManager = new AttributesManager(dataManager);
    driversManager = new DriversManager(dataManager);
    commandsManager = new CommandsManager(dataManager);
    statisticsManager = new StatisticsManager();
    if (config.getBoolean("sms.smpp.enable")) {
        smppClient = new SmppClient();
    }
}
Also used : MultiPartEventForwarder(org.traccar.notification.MultiPartEventForwarder) TripsConfig(org.traccar.reports.model.TripsConfig) DriversManager(org.traccar.database.DriversManager) AttributesManager(org.traccar.database.AttributesManager) DataManager(org.traccar.database.DataManager) DeviceManager(org.traccar.database.DeviceManager) LdapProvider(org.traccar.database.LdapProvider) SmppClient(org.traccar.smpp.SmppClient) JsonTypeEventForwarder(org.traccar.notification.JsonTypeEventForwarder) UsersManager(org.traccar.database.UsersManager) ConnectionManager(org.traccar.database.ConnectionManager) StatisticsManager(org.traccar.database.StatisticsManager) WebServer(org.traccar.web.WebServer) MediaManager(org.traccar.database.MediaManager) PermissionsManager(org.traccar.database.PermissionsManager) CommandsManager(org.traccar.database.CommandsManager) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) GroupsManager(org.traccar.database.GroupsManager)

Example 2 with CommandsManager

use of org.traccar.database.CommandsManager in project traccar by tananaev.

the class CommandResource method get.

@GET
@Path("send")
public Collection<Command> get(@QueryParam("deviceId") long deviceId) throws SQLException {
    Context.getPermissionsManager().checkDevice(getUserId(), deviceId);
    CommandsManager commandsManager = Context.getCommandsManager();
    Set<Long> result = new HashSet<>(commandsManager.getUserItems(getUserId()));
    result.retainAll(commandsManager.getSupportedCommands(deviceId));
    return commandsManager.getItems(result);
}
Also used : CommandsManager(org.traccar.database.CommandsManager) HashSet(java.util.HashSet) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Aggregations

CommandsManager (org.traccar.database.CommandsManager)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 HashSet (java.util.HashSet)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 AttributesManager (org.traccar.database.AttributesManager)1 ConnectionManager (org.traccar.database.ConnectionManager)1 DataManager (org.traccar.database.DataManager)1 DeviceManager (org.traccar.database.DeviceManager)1 DriversManager (org.traccar.database.DriversManager)1 GroupsManager (org.traccar.database.GroupsManager)1 LdapProvider (org.traccar.database.LdapProvider)1 MediaManager (org.traccar.database.MediaManager)1 PermissionsManager (org.traccar.database.PermissionsManager)1 StatisticsManager (org.traccar.database.StatisticsManager)1 UsersManager (org.traccar.database.UsersManager)1 JsonTypeEventForwarder (org.traccar.notification.JsonTypeEventForwarder)1 MultiPartEventForwarder (org.traccar.notification.MultiPartEventForwarder)1 TripsConfig (org.traccar.reports.model.TripsConfig)1 SmppClient (org.traccar.smpp.SmppClient)1