|
|
|
@ -1893,12 +1893,12 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<DeviceSubscriptionDTO> getAppReleaseDevicesByActionType(String uuid, int tenantId)
|
|
|
|
|
public List<DeviceSubscriptionDTO> getSubscriptionDetailsForActionTypes(String uuid, int tenantId)
|
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
log.debug("Getting device details for app UUID: " + uuid + " for tenant ID: " + tenantId);
|
|
|
|
|
log.debug("Getting subscription count details for app UUID: " + uuid + " for tenant ID: " + tenantId);
|
|
|
|
|
}
|
|
|
|
|
String sql = "SELECT "
|
|
|
|
|
String allDeviceSql = "SELECT "
|
|
|
|
|
+ "DS.ACTION_TRIGGERED_FROM AS ACTION_TRIGGERED_FROM, "
|
|
|
|
|
+ "DS.DM_DEVICE_ID AS DEVICE_ID, "
|
|
|
|
|
+ "DS.UNSUBSCRIBED AS UNSUBSCRIBED "
|
|
|
|
@ -1906,34 +1906,117 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|
|
|
|
+ "INNER JOIN AP_DEVICE_SUBSCRIPTION DS ON AR.ID = DS.AP_APP_RELEASE_ID "
|
|
|
|
|
+ "WHERE AR.UUID = ? AND DS.TENANT_ID = ?";
|
|
|
|
|
|
|
|
|
|
String deviceSql = "SELECT "
|
|
|
|
|
+ "DS.ACTION_TRIGGERED_FROM AS ACTION_TRIGGERED_FROM, "
|
|
|
|
|
+ "DS.DM_DEVICE_ID AS DEVICE_ID, "
|
|
|
|
|
+ "DS.UNSUBSCRIBED AS UNSUBSCRIBED "
|
|
|
|
|
+ "FROM AP_APP_RELEASE AR "
|
|
|
|
|
+ "INNER JOIN AP_DEVICE_SUBSCRIPTION DS ON AR.ID = DS.AP_APP_RELEASE_ID "
|
|
|
|
|
+ "WHERE AR.UUID = ? AND DS.TENANT_ID = ? AND DS.ACTION_TRIGGERED_FROM = 'DEVICE'";
|
|
|
|
|
|
|
|
|
|
String groupSql = "SELECT "
|
|
|
|
|
+ "DS.UNSUBSCRIBED AS UNSUBSCRIBED "
|
|
|
|
|
+ "FROM AP_APP_RELEASE AR "
|
|
|
|
|
+ "INNER JOIN AP_GROUP_SUBSCRIPTION DS ON AR.ID = DS.AP_APP_RELEASE_ID "
|
|
|
|
|
+ "WHERE AR.UUID = ? AND DS.TENANT_ID = ?";
|
|
|
|
|
|
|
|
|
|
String roleSql = "SELECT "
|
|
|
|
|
+ "DS.UNSUBSCRIBED AS UNSUBSCRIBED "
|
|
|
|
|
+ "FROM AP_APP_RELEASE AR "
|
|
|
|
|
+ "INNER JOIN AP_ROLE_SUBSCRIPTION DS ON AR.ID = DS.AP_APP_RELEASE_ID "
|
|
|
|
|
+ "WHERE AR.UUID = ? AND DS.TENANT_ID = ?";
|
|
|
|
|
|
|
|
|
|
String userSql = "SELECT "
|
|
|
|
|
+ "DS.UNSUBSCRIBED AS UNSUBSCRIBED "
|
|
|
|
|
+ "FROM AP_APP_RELEASE AR "
|
|
|
|
|
+ "INNER JOIN AP_USER_SUBSCRIPTION DS ON AR.ID = DS.AP_APP_RELEASE_ID "
|
|
|
|
|
+ "WHERE AR.UUID = ? AND DS.TENANT_ID = ?";
|
|
|
|
|
|
|
|
|
|
try (Connection conn = this.getDBConnection();
|
|
|
|
|
PreparedStatement ps = conn.prepareStatement(sql)) {
|
|
|
|
|
PreparedStatement allDevicePs = conn.prepareStatement(allDeviceSql);
|
|
|
|
|
PreparedStatement devicePs = conn.prepareStatement(deviceSql);
|
|
|
|
|
PreparedStatement groupPs = conn.prepareStatement(groupSql);
|
|
|
|
|
PreparedStatement rolePs = conn.prepareStatement(roleSql);
|
|
|
|
|
PreparedStatement userPs = conn.prepareStatement(userSql)) {
|
|
|
|
|
|
|
|
|
|
allDevicePs.setString(1, uuid);
|
|
|
|
|
allDevicePs.setInt(2, tenantId);
|
|
|
|
|
devicePs.setString(1, uuid);
|
|
|
|
|
devicePs.setInt(2, tenantId);
|
|
|
|
|
groupPs.setString(1, uuid);
|
|
|
|
|
groupPs.setInt(2, tenantId);
|
|
|
|
|
rolePs.setString(1, uuid);
|
|
|
|
|
rolePs.setInt(2, tenantId);
|
|
|
|
|
userPs.setString(1, uuid);
|
|
|
|
|
userPs.setInt(2, tenantId);
|
|
|
|
|
|
|
|
|
|
List<DeviceSubscriptionDTO> allDeviceSubscriptions = new ArrayList<>();
|
|
|
|
|
List<DeviceSubscriptionDTO> deviceSubscriptions = new ArrayList<>();
|
|
|
|
|
List<DeviceSubscriptionDTO> groupSubscriptions = new ArrayList<>();
|
|
|
|
|
List<DeviceSubscriptionDTO> roleSubscriptions = new ArrayList<>();
|
|
|
|
|
List<DeviceSubscriptionDTO> userSubscriptions = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
ps.setString(1, uuid);
|
|
|
|
|
ps.setInt(2, tenantId);
|
|
|
|
|
try (ResultSet allDeviceRs = allDevicePs.executeQuery()) {
|
|
|
|
|
while (allDeviceRs.next()) {
|
|
|
|
|
DeviceSubscriptionDTO details = new DeviceSubscriptionDTO();
|
|
|
|
|
details.setActionTriggeredFrom("ALL");
|
|
|
|
|
details.setUnsubscribed(allDeviceRs.getBoolean("UNSUBSCRIBED"));
|
|
|
|
|
allDeviceSubscriptions.add(details);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try (ResultSet rs = ps.executeQuery()) {
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
log.debug("Successfully retrieved device details for app UUID: " + uuid + " for tenant ID: " + tenantId);
|
|
|
|
|
try (ResultSet deviceRs = devicePs.executeQuery()) {
|
|
|
|
|
while (deviceRs.next()) {
|
|
|
|
|
DeviceSubscriptionDTO details = new DeviceSubscriptionDTO();
|
|
|
|
|
details.setActionTriggeredFrom("DEVICE");
|
|
|
|
|
details.setUnsubscribed(deviceRs.getBoolean("UNSUBSCRIBED"));
|
|
|
|
|
deviceSubscriptions.add(details);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
List<DeviceSubscriptionDTO> deviceSubscriptionList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
try (ResultSet groupRs = groupPs.executeQuery()) {
|
|
|
|
|
while (groupRs.next()) {
|
|
|
|
|
DeviceSubscriptionDTO details = new DeviceSubscriptionDTO();
|
|
|
|
|
details.setActionTriggeredFrom("GROUP");
|
|
|
|
|
details.setUnsubscribed(groupRs.getBoolean("UNSUBSCRIBED"));
|
|
|
|
|
groupSubscriptions.add(details);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try (ResultSet roleRs = rolePs.executeQuery()) {
|
|
|
|
|
while (roleRs.next()) {
|
|
|
|
|
DeviceSubscriptionDTO details = new DeviceSubscriptionDTO();
|
|
|
|
|
details.setActionTriggeredFrom("ROLE");
|
|
|
|
|
details.setUnsubscribed(roleRs.getBoolean("UNSUBSCRIBED"));
|
|
|
|
|
roleSubscriptions.add(details);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try (ResultSet userRs = userPs.executeQuery()) {
|
|
|
|
|
while (userRs.next()) {
|
|
|
|
|
DeviceSubscriptionDTO details = new DeviceSubscriptionDTO();
|
|
|
|
|
details.setActionTriggeredFrom(rs.getString("ACTION_TRIGGERED_FROM"));
|
|
|
|
|
details.setDeviceId(rs.getInt("DEVICE_ID"));
|
|
|
|
|
details.setUnsubscribed(rs.getBoolean("UNSUBSCRIBED"));
|
|
|
|
|
deviceSubscriptionList.add(details);
|
|
|
|
|
details.setActionTriggeredFrom("USER");
|
|
|
|
|
details.setUnsubscribed(userRs.getBoolean("UNSUBSCRIBED"));
|
|
|
|
|
userSubscriptions.add(details);
|
|
|
|
|
}
|
|
|
|
|
return deviceSubscriptionList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<DeviceSubscriptionDTO> allSubscriptions = new ArrayList<>();
|
|
|
|
|
allSubscriptions.addAll(allDeviceSubscriptions);
|
|
|
|
|
allSubscriptions.addAll(deviceSubscriptions);
|
|
|
|
|
allSubscriptions.addAll(groupSubscriptions);
|
|
|
|
|
allSubscriptions.addAll(roleSubscriptions);
|
|
|
|
|
allSubscriptions.addAll(userSubscriptions);
|
|
|
|
|
|
|
|
|
|
return allSubscriptions;
|
|
|
|
|
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
|
String msg = "Error occurred while obtaining the DB connection for getting device details for app UUID: "
|
|
|
|
|
String msg = "Error occurred while obtaining the DB connection for getting subscription count details for app UUID: "
|
|
|
|
|
+ uuid + ".";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
String msg = "Error occurred while executing SQL to get device details for app UUID: " + uuid;
|
|
|
|
|
String msg = "Error occurred while executing SQL to get subscription count details for app UUID: " + uuid;
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
|
}
|
|
|
|
|