Search in sources :

Example 1 with Typed

use of org.traccar.model.Typed in project traccar by tananaev.

the class CommandsManager method getCommandTypes.

public Collection<Typed> getCommandTypes(long deviceId, boolean textChannel) {
    List<Typed> result = new ArrayList<>();
    Position lastPosition = Context.getIdentityManager().getLastPosition(deviceId);
    if (lastPosition != null) {
        BaseProtocol protocol = Context.getServerManager().getProtocol(lastPosition.getProtocol());
        Collection<String> commands;
        commands = textChannel ? protocol.getSupportedTextCommands() : protocol.getSupportedDataCommands();
        for (String commandKey : commands) {
            result.add(new Typed(commandKey));
        }
    } else {
        result.add(new Typed(Command.TYPE_CUSTOM));
    }
    return result;
}
Also used : Typed(org.traccar.model.Typed) Position(org.traccar.model.Position) ArrayList(java.util.ArrayList) BaseProtocol(org.traccar.BaseProtocol)

Example 2 with Typed

use of org.traccar.model.Typed in project traccar by traccar.

the class CommandsManager method getAllCommandTypes.

public Collection<Typed> getAllCommandTypes() {
    List<Typed> result = new ArrayList<>();
    Field[] fields = Command.class.getDeclaredFields();
    for (Field field : fields) {
        if (Modifier.isStatic(field.getModifiers()) && field.getName().startsWith("TYPE_")) {
            try {
                result.add(new Typed(field.get(null).toString()));
            } catch (IllegalArgumentException | IllegalAccessException error) {
                Log.warning(error);
            }
        }
    }
    return result;
}
Also used : Field(java.lang.reflect.Field) Typed(org.traccar.model.Typed) ArrayList(java.util.ArrayList)

Example 3 with Typed

use of org.traccar.model.Typed in project traccar by tananaev.

the class NotificationManager method getAllNotificationTypes.

public Set<Typed> getAllNotificationTypes() {
    Set<Typed> types = new HashSet<>();
    Field[] fields = Event.class.getDeclaredFields();
    for (Field field : fields) {
        if (Modifier.isStatic(field.getModifiers()) && field.getName().startsWith("TYPE_")) {
            try {
                types.add(new Typed(field.get(null).toString()));
            } catch (IllegalArgumentException | IllegalAccessException error) {
                LOGGER.warn("Get event types error", error);
            }
        }
    }
    return types;
}
Also used : Field(java.lang.reflect.Field) Typed(org.traccar.model.Typed) HashSet(java.util.HashSet)

Example 4 with Typed

use of org.traccar.model.Typed in project traccar by tananaev.

the class CommandsManager method getCommandTypes.

public Collection<Typed> getCommandTypes(String protocolName, boolean textChannel) {
    List<Typed> result = new ArrayList<>();
    BaseProtocol protocol = Context.getServerManager().getProtocol(protocolName);
    Collection<String> commands;
    commands = textChannel ? protocol.getSupportedTextCommands() : protocol.getSupportedDataCommands();
    for (String commandKey : commands) {
        result.add(new Typed(commandKey));
    }
    return result;
}
Also used : Typed(org.traccar.model.Typed) ArrayList(java.util.ArrayList) BaseProtocol(org.traccar.BaseProtocol)

Example 5 with Typed

use of org.traccar.model.Typed in project traccar by traccar.

the class CommandsManager method getCommandTypes.

public Collection<Typed> getCommandTypes(long deviceId, boolean textChannel) {
    List<Typed> result = new ArrayList<>();
    Position lastPosition = Context.getIdentityManager().getLastPosition(deviceId);
    if (lastPosition != null) {
        BaseProtocol protocol = Context.getServerManager().getProtocol(lastPosition.getProtocol());
        Collection<String> commands;
        commands = textChannel ? protocol.getSupportedTextCommands() : protocol.getSupportedDataCommands();
        for (String commandKey : commands) {
            result.add(new Typed(commandKey));
        }
    } else {
        result.add(new Typed(Command.TYPE_CUSTOM));
    }
    return result;
}
Also used : Typed(org.traccar.model.Typed) Position(org.traccar.model.Position) ArrayList(java.util.ArrayList) BaseProtocol(org.traccar.BaseProtocol)

Aggregations

Typed (org.traccar.model.Typed)7 ArrayList (java.util.ArrayList)5 Field (java.lang.reflect.Field)4 BaseProtocol (org.traccar.BaseProtocol)3 HashSet (java.util.HashSet)2 Position (org.traccar.model.Position)2