Search in sources :

Example 1 with Server

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

the class DeviceManager method lookupAttribute.

private Object lookupAttribute(long deviceId, String attributeName, boolean lookupConfig) {
    Object result = null;
    Device device = getById(deviceId);
    if (device != null) {
        result = device.getAttributes().get(attributeName);
        if (result == null && lookupGroupsAttribute) {
            long groupId = device.getGroupId();
            while (groupId != 0) {
                Group group = Context.getGroupsManager().getById(groupId);
                if (group != null) {
                    result = group.getAttributes().get(attributeName);
                    if (result != null) {
                        break;
                    }
                    groupId = group.getGroupId();
                } else {
                    groupId = 0;
                }
            }
        }
        if (result == null) {
            if (lookupConfig) {
                result = Context.getConfig().getString(attributeName);
            } else {
                Server server = Context.getPermissionsManager().getServer();
                result = server.getAttributes().get(attributeName);
            }
        }
    }
    return result;
}
Also used : Group(org.traccar.model.Group) Server(org.traccar.model.Server) Device(org.traccar.model.Device)

Aggregations

Device (org.traccar.model.Device)1 Group (org.traccar.model.Group)1 Server (org.traccar.model.Server)1