|
|
@ -39,11 +39,13 @@ public class OperationDAOImpl implements OperationDAO {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Connection connection = OperationManagementDAOFactory.getConnection();
|
|
|
|
Connection connection = OperationManagementDAOFactory.getConnection();
|
|
|
|
stmt = connection.prepareStatement(
|
|
|
|
stmt = connection.prepareStatement(
|
|
|
|
"INSERT INTO DM_OPERATION(TYPE, CREATED_TIMESTAMP, RECEIVED_TIMESTAMP, STATUS) VALUES (?, ?, ?, ?)");
|
|
|
|
"INSERT INTO DM_OPERATION(TYPE, CREATED_TIMESTAMP, RECEIVED_TIMESTAMP, STATUS,OPERATIONCODE) " +
|
|
|
|
|
|
|
|
"VALUES (?, ?, ?, ?,?)");
|
|
|
|
stmt.setString(1, operation.getType().toString());
|
|
|
|
stmt.setString(1, operation.getType().toString());
|
|
|
|
stmt.setTimestamp(2, new Timestamp(new Date().getTime()));
|
|
|
|
stmt.setTimestamp(2, new Timestamp(new Date().getTime()));
|
|
|
|
stmt.setTimestamp(3, null);
|
|
|
|
stmt.setTimestamp(3, null);
|
|
|
|
stmt.setString(4, Operation.Status.PENDING.toString());
|
|
|
|
stmt.setString(4, Operation.Status.PENDING.toString());
|
|
|
|
|
|
|
|
stmt.setString(5, operation.getCode());
|
|
|
|
stmt.executeUpdate();
|
|
|
|
stmt.executeUpdate();
|
|
|
|
|
|
|
|
|
|
|
|
rs = stmt.getGeneratedKeys();
|
|
|
|
rs = stmt.getGeneratedKeys();
|
|
|
@ -117,11 +119,11 @@ public class OperationDAOImpl implements OperationDAO {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Connection conn = OperationManagementDAOFactory.getConnection();
|
|
|
|
Connection conn = OperationManagementDAOFactory.getConnection();
|
|
|
|
String sql =
|
|
|
|
String sql =
|
|
|
|
"SELECT o.ID, o.TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, o.STATUS FROM DM_OPERATION o " +
|
|
|
|
"SELECT o.ID, o.TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, o.STATUS, o.OPERATIONCODE FROM DM_OPERATION o " +
|
|
|
|
"INNER JOIN (SELECT dom.OPERATION_ID AS OP_ID FROM (SELECT d.ID FROM DM_DEVICE d INNER " +
|
|
|
|
"INNER JOIN (SELECT dom.OPERATION_ID AS OP_ID FROM (SELECT d.ID FROM DM_DEVICE d INNER " +
|
|
|
|
"JOIN " +
|
|
|
|
"JOIN " +
|
|
|
|
"DM_DEVICE_TYPE dm ON d.DEVICE_TYPE_ID = dm.ID AND dm.NAME = ? AND d" +
|
|
|
|
"DM_DEVICE_TYPE dm ON d.DEVICE_TYPE_ID = dm.ID AND dm.NAME = ? AND d" +
|
|
|
|
".DEVICE_IDENTIFICATION = ?) d1 "+
|
|
|
|
".DEVICE_IDENTIFICATION = ?) d1 " +
|
|
|
|
"INNER JOIN DM_DEVICE_OPERATION_MAPPING dom ON d1.ID = dom.DEVICE_ID) ois " +
|
|
|
|
"INNER JOIN DM_DEVICE_OPERATION_MAPPING dom ON d1.ID = dom.DEVICE_ID) ois " +
|
|
|
|
"ON o.ID = ois.OP_ID";
|
|
|
|
"ON o.ID = ois.OP_ID";
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
@ -133,6 +135,15 @@ public class OperationDAOImpl implements OperationDAO {
|
|
|
|
while (rs.next()) {
|
|
|
|
while (rs.next()) {
|
|
|
|
Operation operation = new Operation();
|
|
|
|
Operation operation = new Operation();
|
|
|
|
operation.setId(rs.getInt("ID"));
|
|
|
|
operation.setId(rs.getInt("ID"));
|
|
|
|
|
|
|
|
operation.setType(Operation.Type.valueOf(rs.getString("TYPE")));
|
|
|
|
|
|
|
|
operation.setCreatedTimeStamp(rs.getTimestamp("CREATED_TIMESTAMP").toString());
|
|
|
|
|
|
|
|
if (rs.getTimestamp("CREATED_TIMESTAMP") == null){
|
|
|
|
|
|
|
|
operation.setReceivedTimeStamp("");
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
operation.setReceivedTimeStamp(rs.getTimestamp("CREATED_TIMESTAMP").toString());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
operation.setStatus(Operation.Status.valueOf(rs.getString("STATUS")));
|
|
|
|
|
|
|
|
operation.setCode(rs.getString("OPERATIONCODE"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new OperationManagementDAOException("Error occurred while retrieving the operation list " +
|
|
|
|
throw new OperationManagementDAOException("Error occurred while retrieving the operation list " +
|
|
|
@ -161,7 +172,8 @@ public class OperationDAOImpl implements OperationDAO {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Connection connection = OperationManagementDAOFactory.getConnection();
|
|
|
|
Connection connection = OperationManagementDAOFactory.getConnection();
|
|
|
|
stmt = connection.prepareStatement(
|
|
|
|
stmt = connection.prepareStatement(
|
|
|
|
"SELECT o.ID, o.TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, o.STATUS FROM DM_OPERATION o " +
|
|
|
|
"SELECT o.ID, o.TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, o.STATUS,o.OPERATIONCODE " +
|
|
|
|
|
|
|
|
" FROM DM_OPERATION o " +
|
|
|
|
"INNER JOIN (SELECT dom.OPERATION_ID AS OP_ID FROM (SELECT d.ID " +
|
|
|
|
"INNER JOIN (SELECT dom.OPERATION_ID AS OP_ID FROM (SELECT d.ID " +
|
|
|
|
"FROM DM_DEVICE d INNER JOIN DM_DEVICE_TYPE dm ON d.DEVICE_TYPE_ID = dm.ID AND " +
|
|
|
|
"FROM DM_DEVICE d INNER JOIN DM_DEVICE_TYPE dm ON d.DEVICE_TYPE_ID = dm.ID AND " +
|
|
|
|
"dm.NAME = ? AND d.DEVICE_IDENTIFICATION = ?) d1 INNER JOIN " +
|
|
|
|
"dm.NAME = ? AND d.DEVICE_IDENTIFICATION = ?) d1 INNER JOIN " +
|
|
|
@ -173,10 +185,18 @@ public class OperationDAOImpl implements OperationDAO {
|
|
|
|
|
|
|
|
|
|
|
|
Operation operation = null;
|
|
|
|
Operation operation = null;
|
|
|
|
if (rs.next()) {
|
|
|
|
if (rs.next()) {
|
|
|
|
|
|
|
|
|
|
|
|
operation = new Operation();
|
|
|
|
operation = new Operation();
|
|
|
|
operation.setType(this.getType(rs.getString("TYPE")));
|
|
|
|
operation.setType(this.getType(rs.getString("TYPE")));
|
|
|
|
operation.setStatus(this.getStatus(rs.getString("STATUS")));
|
|
|
|
operation.setStatus(this.getStatus(rs.getString("STATUS")));
|
|
|
|
operation.setId(rs.getInt("ID"));
|
|
|
|
operation.setId(rs.getInt("ID"));
|
|
|
|
|
|
|
|
operation.setCreatedTimeStamp(rs.getTimestamp("CREATED_TIMESTAMP").toString());
|
|
|
|
|
|
|
|
if (rs.getTimestamp("RECEIVED_TIMESTAMP") == null){
|
|
|
|
|
|
|
|
operation.setReceivedTimeStamp("");
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
operation.setReceivedTimeStamp(rs.getString("RECEIVED_TIMESTAMP").toString());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
operation.setCode(rs.getString("OPERATIONCODE"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return operation;
|
|
|
|
return operation;
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|