diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/DeviceSubscription.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/DeviceSubscription.java index 98c76c192c..f3209c53b6 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/DeviceSubscription.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/DeviceSubscription.java @@ -19,14 +19,26 @@ package io.entgra.device.mgt.core.application.mgt.common; +import java.sql.Timestamp; + public class DeviceSubscription { + private String deviceName; private String deviceIdentifier; private String deviceStatus; private String deviceOwner; private String deviceType; private String ownershipType; + private Timestamp dateOfLastUpdate; private SubscriptionData subscriptionData; + public String getDeviceName() { + return deviceName; + } + + public void setDeviceName(String deviceName) { + this.deviceName = deviceName; + } + public String getDeviceIdentifier() { return deviceIdentifier; } @@ -67,6 +79,14 @@ public class DeviceSubscription { this.ownershipType = ownershipType; } + public Timestamp getDateOfLastUpdate() { + return dateOfLastUpdate; + } + + public void setDateOfLastUpdate(Timestamp dateOfLastUpdate) { + this.dateOfLastUpdate = dateOfLastUpdate; + } + public SubscriptionData getSubscriptionData() { return subscriptionData; } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/SubscriptionManagementHelperUtil.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/SubscriptionManagementHelperUtil.java index 93a5d6f066..d20294535c 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/SubscriptionManagementHelperUtil.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/SubscriptionManagementHelperUtil.java @@ -20,7 +20,6 @@ package io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt; import io.entgra.device.mgt.core.application.mgt.common.DeviceSubscription; -import io.entgra.device.mgt.core.application.mgt.common.DeviceSubscriptionData; import io.entgra.device.mgt.core.application.mgt.common.DeviceSubscriptionFilterCriteria; import io.entgra.device.mgt.core.application.mgt.common.SubscriptionData; import io.entgra.device.mgt.core.application.mgt.common.SubscriptionInfo; @@ -30,6 +29,7 @@ import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import java.sql.Timestamp; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @@ -56,6 +56,10 @@ public class SubscriptionManagementHelperUtil { deviceSubscription.setDeviceIdentifier(device.getDeviceIdentifier()); deviceSubscription.setDeviceOwner(device.getEnrolmentInfo().getOwner()); deviceSubscription.setDeviceType(device.getType()); + deviceSubscription.setDeviceName(device.getName()); + deviceSubscription.setDeviceStatus(device.getEnrolmentInfo().getStatus().name()); + deviceSubscription.setOwnershipType(device.getEnrolmentInfo().getOwnership().name()); + deviceSubscription.setDateOfLastUpdate(new Timestamp(device.getEnrolmentInfo().getDateOfLastUpdate())); SubscriptionData subscriptionData = new SubscriptionData(); subscriptionData.setTriggeredBy(deviceSubscriptionDTO.getActionTriggeredFrom()); subscriptionData.setTriggeredAt(deviceSubscriptionDTO.getSubscribedTimestamp()); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java index 2034bcf33c..7f77d3d3e2 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java @@ -3337,7 +3337,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { try { Connection connection = getConnection(); String sql = "SELECT e.DEVICE_ID, d.DEVICE_IDENTIFICATION, e.STATUS, e.OWNER, d.NAME AS DEVICE_NAME, " + - "e.DEVICE_TYPE FROM DM_DEVICE d INNER JOIN DM_ENROLMENT e " + + "e.DEVICE_TYPE, e.OWNERSHIP, e.DATE_OF_LAST_UPDATE FROM DM_DEVICE d INNER JOIN DM_ENROLMENT e " + "WHERE d.ID = e.DEVICE_ID AND d.TENANT_ID = ? AND e.DEVICE_ID IN (" + deviceIdStringList+ ") " + "AND e.STATUS NOT IN ('DELETED', 'REMOVED')"; @@ -3379,6 +3379,8 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { EnrolmentInfo enrolmentInfo = new EnrolmentInfo(); enrolmentInfo.setStatus(EnrolmentInfo.Status.valueOf(resultSet.getString("STATUS"))); enrolmentInfo.setOwner(resultSet.getString("OWNER")); + enrolmentInfo.setOwnership(EnrolmentInfo.OwnerShip.valueOf(resultSet.getString("OWNERSHIP"))); + enrolmentInfo.setDateOfLastUpdate(resultSet.getTimestamp("DATE_OF_LAST_UPDATE").getTime()); device.setEnrolmentInfo(enrolmentInfo); devices.add(device); }