|
|
@ -367,30 +367,30 @@ public class GenericOperationDAOImpl implements OperationDAO {
|
|
|
|
// sql = sql + " OFFSET ?";
|
|
|
|
// sql = sql + " OFFSET ?";
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
String sql = "SELECT eom.ENROLMENT_ID, eom.OPERATION_ID, eom.STATUS, eom.UPDATED_TIMESTAMP, " +
|
|
|
|
String sql = "SELECT feom.ENROLMENT_ID, feom.OPERATION_ID, feom.CREATED_TIMESTAMP, o.TYPE AS OPERATION_TYPE, " +
|
|
|
|
"foor.OPERATION_ID, foor.DEVICE_TYPE, foor.OPERATION_CODE, foor.OPERATION_TYPE, foor.OP_RES_ID, " +
|
|
|
|
"o.OPERATION_CODE, orsp.OPERATION_RESPONSE, orsp. LATEST_RECEIVED_TIMESTAMP AS RECEIVED_TIMESTAMP, " +
|
|
|
|
"foor.OPERATION_RESPONSE, foor.RECEIVED_TIMESTAMP, foor.DEVICE_IDENTIFICATION, " +
|
|
|
|
"orsp.ID AS OP_RES_ID, feom.STATUS, feom.UPDATED_TIMESTAMP, feom.DEVICE_IDENTIFICATION, " +
|
|
|
|
"foor.ENROLMENT_ID FROM (SELECT ENROLMENT_ID, OPERATION_ID, STATUS, UPDATED_TIMESTAMP FROM " +
|
|
|
|
"feom.DEVICE_TYPE FROM (SELECT eom.ENROLMENT_ID, eom.OPERATION_ID, eom.STATUS, " +
|
|
|
|
"DM_ENROLMENT_OP_MAPPING WHERE UPDATED_TIMESTAMP > ? LIMIT ? OFFSET ?) eom LEFT OUTER JOIN (SELECT oor.OPERATION_ID, " +
|
|
|
|
"eom.CREATED_TIMESTAMP, eom.UPDATED_TIMESTAMP, fe.DEVICE_IDENTIFICATION, fe.DEVICE_TYPE FROM " +
|
|
|
|
"det.DEVICE_TYPE, oor.OPERATION_CODE, oor.OPERATION_RESPONSE, oor.RECEIVED_TIMESTAMP, " +
|
|
|
|
"(SELECT ENROLMENT_ID, OPERATION_ID, STATUS, CREATED_TIMESTAMP, UPDATED_TIMESTAMP FROM " +
|
|
|
|
"oor.OP_RES_ID, oor.OPERATION_TYPE, det.DEVICE_IDENTIFICATION, det.ENROLMENT_ID FROM " +
|
|
|
|
"DM_ENROLMENT_OP_MAPPING WHERE UPDATED_TIMESTAMP > ? LIMIT ? OFFSET ?) eom LEFT OUTER JOIN (SELECT e.ID AS ENROLMENT_ID, " +
|
|
|
|
"(SELECT d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE, e.ID AS ENROLMENT_ID FROM DM_DEVICE d " +
|
|
|
|
"d.ID AS DEVICE_ID, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM DM_ENROLMENT e " +
|
|
|
|
"INNER JOIN DM_DEVICE_TYPE t ON d.DEVICE_TYPE_ID = t.ID INNER JOIN DM_ENROLMENT e ON " +
|
|
|
|
"LEFT OUTER JOIN DM_DEVICE d ON e.DEVICE_ID=d.ID LEFT OUTER JOIN DM_DEVICE_TYPE t ON " +
|
|
|
|
"d.ID = e.DEVICE_ID WHERE e.TENANT_ID = ?) det INNER JOIN (SELECT o.ID AS OPERATION_ID, " +
|
|
|
|
"d.DEVICE_TYPE_ID = t.ID WHERE d.TENANT_ID = ? AND e.TENANT_ID = ?) fe ON " +
|
|
|
|
"o.TYPE AS OPERATION_TYPE, o.OPERATION_CODE, r.OPERATION_RESPONSE, r.ID AS OP_RES_ID, " +
|
|
|
|
"fe.ENROLMENT_ID=eom.ENROLMENT_ID) feom LEFT OUTER JOIN DM_OPERATION o ON feom.OPERATION_ID = o.ID " +
|
|
|
|
"r.LATEST_RECEIVED_TIMESTAMP AS RECEIVED_TIMESTAMP, r.ENROLMENT_ID FROM DM_OPERATION o " +
|
|
|
|
"LEFT OUTER JOIN (SELECT ID, ENROLMENT_ID, OPERATION_ID, OPERATION_RESPONSE, " +
|
|
|
|
"INNER JOIN (SELECT ID, ENROLMENT_ID, OPERATION_ID, OPERATION_RESPONSE, " +
|
|
|
|
"MAX(RECEIVED_TIMESTAMP) LATEST_RECEIVED_TIMESTAMP FROM DM_DEVICE_OPERATION_RESPONSE " +
|
|
|
|
"MAX(RECEIVED_TIMESTAMP) LATEST_RECEIVED_TIMESTAMP FROM DM_DEVICE_OPERATION_RESPONSE GROUP BY " +
|
|
|
|
"GROUP BY ENROLMENT_ID, OPERATION_ID) orsp ON o.ID = orsp.OPERATION_ID AND " +
|
|
|
|
"ENROLMENT_ID, OPERATION_ID) r ON o.ID = r.OPERATION_ID) oor ON " +
|
|
|
|
"feom.ENROLMENT_ID = orsp.ENROLMENT_ID";
|
|
|
|
"det.ENROLMENT_ID = oor.ENROLMENT_ID) foor ON eom.ENROLMENT_ID=foor.ENROLMENT_ID AND " +
|
|
|
|
|
|
|
|
"eom.OPERATION_ID = foor.OPERATION_ID ORDER BY eom.OPERATION_ID ASC;";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
|
|
|
|
|
|
|
|
stmt.setLong(1, timestamp);
|
|
|
|
stmt.setLong(1, timestamp);
|
|
|
|
stmt.setInt(2, limit);
|
|
|
|
stmt.setInt(2, limit);
|
|
|
|
stmt.setInt(3, offset);
|
|
|
|
stmt.setInt(3, offset);
|
|
|
|
stmt.setInt(4, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId());
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
|
|
|
|
stmt.setInt(4, tenantId);
|
|
|
|
|
|
|
|
stmt.setInt(5, tenantId);
|
|
|
|
|
|
|
|
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
|
|
|
|
|
|
|
|