aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar')
-rw-r--r--src/main/java/org/traccar/api/resource/AttributeResource.java16
-rw-r--r--src/main/java/org/traccar/database/CommandsManager.java2
2 files changed, 4 insertions, 14 deletions
diff --git a/src/main/java/org/traccar/api/resource/AttributeResource.java b/src/main/java/org/traccar/api/resource/AttributeResource.java
index fdd0d4f6f..ab7e43add 100644
--- a/src/main/java/org/traccar/api/resource/AttributeResource.java
+++ b/src/main/java/org/traccar/api/resource/AttributeResource.java
@@ -53,22 +53,12 @@ public class AttributeResource extends ExtendedObjectResource<Attribute> {
permissionsService.checkAdmin(getUserId());
permissionsService.checkPermission(Device.class, getUserId(), deviceId);
- Device device = storage.getObject(Device.class, new Request(
+ Position position = storage.getObject(Position.class, new Request(
new Columns.All(),
- new Condition.Equals("id", "id", deviceId)));
- if (device == null) {
- throw new IllegalArgumentException("Device not found");
- }
-
- Position last = storage.getObject(Position.class, new Request(
- new Columns.All(),
- new Condition.Equals("id", "id", device.getPositionId())));
- if (last == null) {
- throw new IllegalArgumentException("Device has no last position");
- }
+ new Condition.LatestPositions(deviceId)));
Object result = new ComputedAttributesHandler(Context.getConfig(), Context.getIdentityManager(), null)
- .computeAttribute(entity, last);
+ .computeAttribute(entity, position);
if (result != null) {
switch (entity.getType()) {
case "number":
diff --git a/src/main/java/org/traccar/database/CommandsManager.java b/src/main/java/org/traccar/database/CommandsManager.java
index 8dd2ba8b7..2967b8abd 100644
--- a/src/main/java/org/traccar/database/CommandsManager.java
+++ b/src/main/java/org/traccar/database/CommandsManager.java
@@ -72,7 +72,7 @@ public class CommandsManager {
long deviceId = command.getDeviceId();
if (command.getTextChannel()) {
Device device = storage.getObject(Device.class, new Request(
- new Columns.All(), new Condition.Equals("id", "id", deviceId)));
+ new Columns.Include("positionId", "phone"), new Condition.Equals("id", "id", deviceId)));
Position position = storage.getObject(Position.class, new Request(
new Columns.All(), new Condition.Equals("id", "id", device.getPositionId())));
if (position != null) {