Fix missing properties in subscription data bean

pull/459/head
Rajitha Kumara 4 months ago
parent 359c052251
commit d2317e47e0

@ -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;
}

@ -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());

@ -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);
}

Loading…
Cancel
Save