|
|
@ -198,7 +198,7 @@ public class GenericOperationDAOImpl implements OperationDAO {
|
|
|
|
throw new OperationManagementDAOException(
|
|
|
|
throw new OperationManagementDAOException(
|
|
|
|
"Error occurred while update device mapping operation status " + "metadata", e);
|
|
|
|
"Error occurred while update device mapping operation status " + "metadata", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
OperationManagementDAOUtil.cleanupResources(stmt);
|
|
|
|
OperationManagementDAOUtil.cleanupResources(stmt, rs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -209,18 +209,31 @@ public class GenericOperationDAOImpl implements OperationDAO {
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
ByteArrayOutputStream bao = null;
|
|
|
|
ByteArrayOutputStream bao = null;
|
|
|
|
ObjectOutputStream oos = null;
|
|
|
|
ObjectOutputStream oos = null;
|
|
|
|
|
|
|
|
ResultSet rs = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Connection connection = OperationManagementDAOFactory.getConnection();
|
|
|
|
Connection connection = OperationManagementDAOFactory.getConnection();
|
|
|
|
stmt = connection.prepareStatement("INSERT INTO DM_DEVICE_OPERATION_RESPONSE(OPERATION_ID,ENROLMENT_ID," +
|
|
|
|
|
|
|
|
"OPERATION_RESPONSE, RECEIVED_TIMESTAMP) VALUES(?, ?, ?, ?)");
|
|
|
|
stmt = connection.prepareStatement("SELECT ID FROM DM_ENROLMENT_OP_MAPPING WHERE ENROLMENT_ID = ? " +
|
|
|
|
|
|
|
|
"AND OPERATION_ID = ?");
|
|
|
|
|
|
|
|
stmt.setInt(1, enrolmentId);
|
|
|
|
|
|
|
|
stmt.setInt(2, operationId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
|
|
|
|
int enPrimaryId = 0;
|
|
|
|
|
|
|
|
if(rs.next()){
|
|
|
|
|
|
|
|
enPrimaryId = rs.getInt("ID");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
stmt = connection.prepareStatement("INSERT INTO DM_DEVICE_OPERATION_RESPONSE(OPERATION_ID, ENROLMENT_ID, " +
|
|
|
|
|
|
|
|
"EN_OP_MAP_ID, OPERATION_RESPONSE, RECEIVED_TIMESTAMP) VALUES(?, ?, ?, ?, ?)");
|
|
|
|
bao = new ByteArrayOutputStream();
|
|
|
|
bao = new ByteArrayOutputStream();
|
|
|
|
oos = new ObjectOutputStream(bao);
|
|
|
|
oos = new ObjectOutputStream(bao);
|
|
|
|
oos.writeObject(operationResponse);
|
|
|
|
oos.writeObject(operationResponse);
|
|
|
|
|
|
|
|
|
|
|
|
stmt.setInt(1, operationId);
|
|
|
|
stmt.setInt(1, operationId);
|
|
|
|
stmt.setInt(2, enrolmentId);
|
|
|
|
stmt.setInt(2, enrolmentId);
|
|
|
|
stmt.setBytes(3, bao.toByteArray());
|
|
|
|
stmt.setInt(3, enPrimaryId);
|
|
|
|
stmt.setTimestamp(4, new Timestamp(new Date().getTime()));
|
|
|
|
stmt.setBytes(4, bao.toByteArray());
|
|
|
|
|
|
|
|
stmt.setTimestamp(5, new Timestamp(new Date().getTime()));
|
|
|
|
stmt.executeUpdate();
|
|
|
|
stmt.executeUpdate();
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new OperationManagementDAOException("Error occurred while inserting operation response", e);
|
|
|
|
throw new OperationManagementDAOException("Error occurred while inserting operation response", e);
|
|
|
@ -241,7 +254,7 @@ public class GenericOperationDAOImpl implements OperationDAO {
|
|
|
|
log.warn("Error occurred while closing ObjectOutputStream", e);
|
|
|
|
log.warn("Error occurred while closing ObjectOutputStream", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
OperationManagementDAOUtil.cleanupResources(stmt);
|
|
|
|
OperationManagementDAOUtil.cleanupResources(stmt, rs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -474,27 +487,8 @@ public class GenericOperationDAOImpl implements OperationDAO {
|
|
|
|
List<Activity> activities = new ArrayList<>();
|
|
|
|
List<Activity> activities = new ArrayList<>();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Connection conn = OperationManagementDAOFactory.getConnection();
|
|
|
|
Connection conn = OperationManagementDAOFactory.getConnection();
|
|
|
|
// String sql = "SELECT eom.ENROLMENT_ID, eom.OPERATION_ID, eom.ID AS EOM_MAPPING_ID, dor.ID AS OP_RES_ID,\n" +
|
|
|
|
|
|
|
|
// "de.DEVICE_ID, d.DEVICE_IDENTIFICATION, \n" +
|
|
|
|
|
|
|
|
// "d.DEVICE_TYPE_ID, dt.NAME AS DEVICE_TYPE_NAME, eom.STATUS, eom.CREATED_TIMESTAMP, \n" +
|
|
|
|
|
|
|
|
// "eom.UPDATED_TIMESTAMP, op.OPERATION_CODE, op.TYPE AS OPERATION_TYPE, dor.OPERATION_RESPONSE, \n" +
|
|
|
|
|
|
|
|
// "dor.RECEIVED_TIMESTAMP FROM DM_ENROLMENT_OP_MAPPING AS eom \n" +
|
|
|
|
|
|
|
|
// "INNER JOIN DM_OPERATION AS op ON op.ID=eom.OPERATION_ID\n" +
|
|
|
|
|
|
|
|
// "INNER JOIN DM_ENROLMENT AS de ON de.ID=eom.ENROLMENT_ID\n" +
|
|
|
|
|
|
|
|
// "INNER JOIN DM_DEVICE AS d ON d.ID=de.DEVICE_ID \n" +
|
|
|
|
|
|
|
|
// "INNER JOIN DM_DEVICE_TYPE AS dt ON dt.ID=d.DEVICE_TYPE_ID\n" +
|
|
|
|
|
|
|
|
// "LEFT JOIN DM_DEVICE_OPERATION_RESPONSE AS dor ON dor.ENROLMENT_ID=de.id \n" +
|
|
|
|
|
|
|
|
// "AND dor.OPERATION_ID=eom.OPERATION_ID\n" +
|
|
|
|
|
|
|
|
// "WHERE eom.UPDATED_TIMESTAMP > ? AND de.TENANT_ID = ? ORDER BY eom.OPERATION_ID";
|
|
|
|
|
|
|
|
// if(limit > 0) {
|
|
|
|
|
|
|
|
// sql = sql + " LIMIT ?";
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// if(offset > 0) {
|
|
|
|
|
|
|
|
// sql = sql + " OFFSET ?";
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
String sql = "SELECT opm.ENROLMENT_ID, opm.CREATED_TIMESTAMP, opm.UPDATED_TIMESTAMP, opm.OPERATION_ID,\n" +
|
|
|
|
String sql = "SELECT opm.ENROLMENT_ID, opm.CREATED_TIMESTAMP, opm.UPDATED_TIMESTAMP, opm.OPERATION_ID,\n" +
|
|
|
|
"op.OPERATION_CODE, op.TYPE as OPERATION_TYPE, opm.STATUS, en.DEVICE_ID,\n" +
|
|
|
|
"op.OPERATION_CODE, op.TYPE as OPERATION_TYPE, opm.STATUS, en.DEVICE_ID,\n" +
|
|
|
|
"ops.RECEIVED_TIMESTAMP, ops.ID as OP_RES_ID, ops.OPERATION_RESPONSE,\n" +
|
|
|
|
"ops.RECEIVED_TIMESTAMP, ops.ID as OP_RES_ID, ops.OPERATION_RESPONSE,\n" +
|
|
|
@ -514,15 +508,60 @@ public class GenericOperationDAOImpl implements OperationDAO {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
sql += "ORDER BY opm.UPDATED_TIMESTAMP asc LIMIT ? OFFSET ?";
|
|
|
|
sql += "ORDER BY opm.UPDATED_TIMESTAMP asc LIMIT ? OFFSET ?";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
|
|
|
|
String sql = "SELECT " +
|
|
|
|
|
|
|
|
" opr.ENROLMENT_ID, " +
|
|
|
|
|
|
|
|
" opr.CREATED_TIMESTAMP, " +
|
|
|
|
|
|
|
|
" opr.UPDATED_TIMESTAMP, " +
|
|
|
|
|
|
|
|
" opr.OPERATION_ID, " +
|
|
|
|
|
|
|
|
" opr.OPERATION_CODE, " +
|
|
|
|
|
|
|
|
" opr.OPERATION_TYPE, " +
|
|
|
|
|
|
|
|
" opr.STATUS, " +
|
|
|
|
|
|
|
|
" opr.DEVICE_ID, " +
|
|
|
|
|
|
|
|
" opr.DEVICE_IDENTIFICATION, " +
|
|
|
|
|
|
|
|
" opr.DEVICE_TYPE, " +
|
|
|
|
|
|
|
|
" ops.RECEIVED_TIMESTAMP, " +
|
|
|
|
|
|
|
|
" ops.ID OP_RES_ID, " +
|
|
|
|
|
|
|
|
" ops.OPERATION_RESPONSE " +
|
|
|
|
|
|
|
|
" FROM " +
|
|
|
|
|
|
|
|
" (SELECT " +
|
|
|
|
|
|
|
|
" opm.ID MAPPING_ID, " +
|
|
|
|
|
|
|
|
" opm.ENROLMENT_ID, " +
|
|
|
|
|
|
|
|
" opm.CREATED_TIMESTAMP, " +
|
|
|
|
|
|
|
|
" opm.UPDATED_TIMESTAMP, " +
|
|
|
|
|
|
|
|
" opm.OPERATION_ID, " +
|
|
|
|
|
|
|
|
" op.OPERATION_CODE, " +
|
|
|
|
|
|
|
|
" op.TYPE OPERATION_TYPE, " +
|
|
|
|
|
|
|
|
" opm.STATUS, " +
|
|
|
|
|
|
|
|
" en.DEVICE_ID, " +
|
|
|
|
|
|
|
|
" de.DEVICE_IDENTIFICATION, " +
|
|
|
|
|
|
|
|
" dt.NAME DEVICE_TYPE, " +
|
|
|
|
|
|
|
|
" de.TENANT_ID " +
|
|
|
|
|
|
|
|
" FROM" +
|
|
|
|
|
|
|
|
" DM_ENROLMENT_OP_MAPPING opm " +
|
|
|
|
|
|
|
|
" INNER JOIN DM_OPERATION op ON opm.OPERATION_ID = op.ID " +
|
|
|
|
|
|
|
|
" INNER JOIN DM_ENROLMENT en ON opm.ENROLMENT_ID = en.ID " +
|
|
|
|
|
|
|
|
" INNER JOIN DM_DEVICE de ON en.DEVICE_ID = de.ID " +
|
|
|
|
|
|
|
|
" INNER JOIN DM_DEVICE_TYPE dt ON dt.ID = de.DEVICE_TYPE_ID " +
|
|
|
|
|
|
|
|
" WHERE " +
|
|
|
|
|
|
|
|
" opm.UPDATED_TIMESTAMP > ? " +
|
|
|
|
|
|
|
|
" AND de.TENANT_ID = ? " +
|
|
|
|
|
|
|
|
" ORDER BY opm.UPDATED_TIMESTAMP " +
|
|
|
|
|
|
|
|
" LIMIT ? OFFSET ?) opr " +
|
|
|
|
|
|
|
|
" LEFT JOIN DM_DEVICE_OPERATION_RESPONSE ops ON opr.MAPPING_ID = ops.EN_OP_MAP_ID " +
|
|
|
|
|
|
|
|
" WHERE " +
|
|
|
|
|
|
|
|
" opr.UPDATED_TIMESTAMP > ? " +
|
|
|
|
|
|
|
|
" AND opr.TENANT_ID = ? ";
|
|
|
|
|
|
|
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
|
|
|
|
|
|
|
|
stmt.setLong(1, timestamp);
|
|
|
|
stmt.setLong(1, timestamp);
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
|
|
|
|
stmt.setInt(2, tenantId);
|
|
|
|
stmt.setInt(2, tenantId);
|
|
|
|
stmt.setInt(3, limit);
|
|
|
|
stmt.setInt(3, limit);
|
|
|
|
stmt.setInt(4, offset);
|
|
|
|
stmt.setInt(4, offset);
|
|
|
|
|
|
|
|
stmt.setLong(5, timestamp);
|
|
|
|
|
|
|
|
stmt.setInt(6, tenantId);
|
|
|
|
|
|
|
|
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
|
|
|
|
|
|
|
|