|
|
|
@ -55,6 +55,44 @@ public class CommandOperationDAOImpl extends OperationDAOImpl {
|
|
|
|
|
return operationId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Operation getOperation(int id) throws OperationManagementDAOException {
|
|
|
|
|
|
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
|
ResultSet rs = null;
|
|
|
|
|
Operation operation = null;
|
|
|
|
|
try {
|
|
|
|
|
Connection conn = OperationManagementDAOFactory.openConnection();
|
|
|
|
|
String sql = "SELECT o.ID, o.TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, o.STATUS, o.OPERATIONCODE," +
|
|
|
|
|
"co.ENABLED FROM DM_OPERATION o INNER JOIN DM_COMMAND_OPERATION co ON " +
|
|
|
|
|
"co.OPERATION_ID = o.ID WHERE o.ID=?";
|
|
|
|
|
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
|
stmt.setInt(1, id);
|
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
|
|
|
|
|
|
if (rs.next()) {
|
|
|
|
|
operation = new Operation();
|
|
|
|
|
operation.setId(rs.getInt("ID"));
|
|
|
|
|
operation.setType(Operation.Type.valueOf(rs.getString("TYPE")));
|
|
|
|
|
operation.setCreatedTimeStamp(rs.getTimestamp("CREATED_TIMESTAMP").toString());
|
|
|
|
|
if (rs.getTimestamp("RECEIVED_TIMESTAMP") == null) {
|
|
|
|
|
operation.setReceivedTimeStamp("");
|
|
|
|
|
} else {
|
|
|
|
|
operation.setReceivedTimeStamp(rs.getTimestamp("RECEIVED_TIMESTAMP").toString());
|
|
|
|
|
}
|
|
|
|
|
operation.setStatus(Operation.Status.valueOf(rs.getString("STATUS")));
|
|
|
|
|
operation.setCode(rs.getString("OPERATIONCODE"));
|
|
|
|
|
}
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
throw new OperationManagementDAOException("Error occurred while retrieving the operation object " +
|
|
|
|
|
"available for the id '" + id + "'", e);
|
|
|
|
|
} finally {
|
|
|
|
|
OperationManagementDAOUtil.cleanupResources(stmt, rs);
|
|
|
|
|
OperationManagementDAOFactory.closeConnection();
|
|
|
|
|
}
|
|
|
|
|
return operation;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<? extends Operation> getOperations(DeviceIdentifier deviceId,
|
|
|
|
|
Operation.Status status) throws OperationManagementDAOException {
|
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
@ -64,8 +102,10 @@ public class CommandOperationDAOImpl extends OperationDAOImpl {
|
|
|
|
|
try {
|
|
|
|
|
Connection conn = OperationManagementDAOFactory.openConnection();
|
|
|
|
|
String sql = "SELECT po.OPERATION_ID, po.TYPE, po.CREATED_TIMESTAMP, po.RECEIVED_TIMESTAMP, po.STATUS, " +
|
|
|
|
|
"co.ENABLED,o.OPERATIONCODE FROM DM_COMMAND_OPERATION co INNER JOIN (SELECT o.ID AS OPERATION_ID, o.TYPE, " +
|
|
|
|
|
"o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, o.STATUS, o.OPERATIONCODE FROM DM_OPERATION o INNER JOIN (" +
|
|
|
|
|
"co.ENABLED,o.OPERATIONCODE FROM DM_COMMAND_OPERATION co INNER JOIN (SELECT o.ID AS OPERATION_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 JOIN " +
|
|
|
|
|
"DM_DEVICE_TYPE dm ON d.DEVICE_TYPE_ID = dm.ID AND dm.NAME = ? AND " +
|
|
|
|
|
"d.DEVICE_IDENTIFICATION = ?) d1 INNER JOIN DM_DEVICE_OPERATION_MAPPING dom ON d1.ID = " +
|
|
|
|
@ -83,7 +123,12 @@ public class CommandOperationDAOImpl extends OperationDAOImpl {
|
|
|
|
|
operation.setId(rs.getInt("OPERATION_ID"));
|
|
|
|
|
operation.setType(Operation.Type.valueOf(rs.getString("TYPE")));
|
|
|
|
|
operation.setCreatedTimeStamp(rs.getTimestamp("CREATED_TIMESTAMP").toString());
|
|
|
|
|
|
|
|
|
|
if (rs.getTimestamp("RECEIVED_TIMESTAMP") != null) {
|
|
|
|
|
operation.setCreatedTimeStamp(rs.getTimestamp("RECEIVED_TIMESTAMP").toString());
|
|
|
|
|
} else {
|
|
|
|
|
operation.setCreatedTimeStamp(null);
|
|
|
|
|
}
|
|
|
|
|
operation.setStatus(Operation.Status.valueOf(rs.getString("STATUS")));
|
|
|
|
|
operation.setEnabled(rs.getBoolean("ENABLED"));
|
|
|
|
|
operation.setCode(rs.getString("OPERATIONCODE"));
|
|
|
|
@ -107,8 +152,10 @@ public class CommandOperationDAOImpl extends OperationDAOImpl {
|
|
|
|
|
try {
|
|
|
|
|
Connection conn = OperationManagementDAOFactory.openConnection();
|
|
|
|
|
String sql = "SELECT po.OPERATION_ID, po.TYPE, po.CREATED_TIMESTAMP, po.RECEIVED_TIMESTAMP, po.STATUS, " +
|
|
|
|
|
"co.ENABLED.o.OPERATIONCODE FROM DM_COMMAND_OPERATION co INNER JOIN (SELECT o.ID AS OPERATION_ID, o.TYPE, " +
|
|
|
|
|
"o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, o.STATUS, o.OPERATIONCODE FROM DM_OPERATION o INNER JOIN (" +
|
|
|
|
|
"co.ENABLED.o.OPERATIONCODE FROM DM_COMMAND_OPERATION co INNER JOIN (SELECT o.ID AS OPERATION_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 JOIN " +
|
|
|
|
|
"DM_DEVICE_TYPE dm ON d.DEVICE_TYPE_ID = dm.ID AND dm.NAME = ? AND " +
|
|
|
|
|
"d.DEVICE_IDENTIFICATION = ?) d1 INNER JOIN DM_DEVICE_OPERATION_MAPPING dom ON d1.ID = " +
|
|
|
|
@ -117,7 +164,7 @@ public class CommandOperationDAOImpl extends OperationDAOImpl {
|
|
|
|
|
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
|
stmt.setString(1, deviceId.getType());
|
|
|
|
|
stmt.setString(1, deviceId.getId());
|
|
|
|
|
stmt.setString(2, deviceId.getId());
|
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
|
|
|
|
|
|
List<CommandOperation> operations = new ArrayList<CommandOperation>();
|
|
|
|
@ -125,6 +172,13 @@ public class CommandOperationDAOImpl extends OperationDAOImpl {
|
|
|
|
|
CommandOperation operation = new CommandOperation();
|
|
|
|
|
operation.setId(rs.getInt("ID"));
|
|
|
|
|
operation.setType(Operation.Type.valueOf(rs.getString("TYPE")));
|
|
|
|
|
operation.setCreatedTimeStamp(rs.getTimestamp("CREATED_TIMESTAMP").toString());
|
|
|
|
|
|
|
|
|
|
if (rs.getTimestamp("RECEIVED_TIMESTAMP") == null) {
|
|
|
|
|
operation.setReceivedTimeStamp(null);
|
|
|
|
|
} else {
|
|
|
|
|
operation.setReceivedTimeStamp(rs.getTimestamp("RECEIVED_TIMESTAMP").toString());
|
|
|
|
|
}
|
|
|
|
|
operation.setStatus(Operation.Status.valueOf(rs.getString("STATUS")));
|
|
|
|
|
operation.setEnabled(Boolean.parseBoolean(rs.getString("ENABLED")));
|
|
|
|
|
operation.setCode(rs.getString("OPERATIONCODE"));
|
|
|
|
|