|
|
@ -29,6 +29,7 @@ import java.sql.Connection;
|
|
|
|
import java.sql.PreparedStatement;
|
|
|
|
import java.sql.PreparedStatement;
|
|
|
|
import java.sql.ResultSet;
|
|
|
|
import java.sql.ResultSet;
|
|
|
|
import java.sql.SQLException;
|
|
|
|
import java.sql.SQLException;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
public class CommandOperationDAOImpl extends OperationDAOImpl {
|
|
|
|
public class CommandOperationDAOImpl extends OperationDAOImpl {
|
|
|
@ -37,11 +38,11 @@ public class CommandOperationDAOImpl extends OperationDAOImpl {
|
|
|
|
public int addOperation(Operation operation) throws OperationManagementDAOException {
|
|
|
|
public int addOperation(Operation operation) throws OperationManagementDAOException {
|
|
|
|
int operationId = super.addOperation(operation);
|
|
|
|
int operationId = super.addOperation(operation);
|
|
|
|
CommandOperation commandOp = (CommandOperation) operation;
|
|
|
|
CommandOperation commandOp = (CommandOperation) operation;
|
|
|
|
Connection conn = OperationManagementDAOFactory.getConnection();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
ResultSet rs = null;
|
|
|
|
ResultSet rs = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Connection conn = OperationManagementDAOFactory.getConnection();
|
|
|
|
stmt = conn.prepareStatement("INSERT INTO DM_COMMAND_OPERATION(OPERATION_ID, ENABLED) VALUES(?, ?)");
|
|
|
|
stmt = conn.prepareStatement("INSERT INTO DM_COMMAND_OPERATION(OPERATION_ID, ENABLED) VALUES(?, ?)");
|
|
|
|
stmt.setInt(1, operationId);
|
|
|
|
stmt.setInt(1, operationId);
|
|
|
|
stmt.setBoolean(2, commandOp.isEnabled());
|
|
|
|
stmt.setBoolean(2, commandOp.isEnabled());
|
|
|
@ -54,39 +55,71 @@ public class CommandOperationDAOImpl extends OperationDAOImpl {
|
|
|
|
return operationId;
|
|
|
|
return operationId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<? extends Operation> getOperations(DeviceIdentifier deviceId,
|
|
|
|
public int updateOperation(Operation operation) throws OperationManagementDAOException {
|
|
|
|
Operation.Status status) throws OperationManagementDAOException {
|
|
|
|
return 0;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
}
|
|
|
|
ResultSet rs = null;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public int deleteOperation(int id) throws OperationManagementDAOException {
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
try {
|
|
|
|
public Operation getOperation(int id) throws OperationManagementDAOException {
|
|
|
|
Connection conn = OperationManagementDAOFactory.getConnection();
|
|
|
|
return null;
|
|
|
|
String sql = "SELECT po.OPERATION_ID, po.TYPE, po.CREATED_TIMESTAMP, po.RECEIVED_TIMESTAMP, po.STATUS, " +
|
|
|
|
}
|
|
|
|
"co.ENABLED FROM DM_COMMAND_OPERATION co INNER JOIN (SELECT o.ID AS OPERATION_ID, o.TYPE, " +
|
|
|
|
|
|
|
|
"o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, o.STATUS 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 = " +
|
|
|
|
|
|
|
|
"dom.DEVICE_ID) ois ON o.ID = ois.OP_ID AND o.STATUS = ? ORDER BY " +
|
|
|
|
|
|
|
|
"o.CREATED_TIMESTAMP ASC) po ON co.OPERATION_ID = po.OPERATION_ID";
|
|
|
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
|
|
|
|
stmt.setString(1, deviceId.getType());
|
|
|
|
|
|
|
|
stmt.setString(1, deviceId.getId());
|
|
|
|
|
|
|
|
stmt.setString(1, status.toString());
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementDAOException("Error occurred while retrieving the list of " +
|
|
|
|
|
|
|
|
"operations with the status '" + status + "' available for the '" + deviceId.getType() +
|
|
|
|
|
|
|
|
"' device '" + deviceId.getId() + "'");
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
OperationManagementDAOUtil.cleanupResources(stmt, rs);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public Operation getOperation(DeviceIdentifier deviceId, int operationId) throws OperationManagementDAOException {
|
|
|
|
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<? extends Operation> getOperations(DeviceIdentifier deviceId) throws OperationManagementDAOException {
|
|
|
|
public List<Operation> getOperations(DeviceIdentifier deviceId) throws OperationManagementDAOException {
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
return null;
|
|
|
|
ResultSet rs = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
try {
|
|
|
|
public List<Operation> getOperations(String status) throws OperationManagementDAOException {
|
|
|
|
Connection conn = OperationManagementDAOFactory.getConnection();
|
|
|
|
return null;
|
|
|
|
String sql = "SELECT po.OPERATION_ID, po.TYPE, po.CREATED_TIMESTAMP, po.RECEIVED_TIMESTAMP, po.STATUS, " +
|
|
|
|
}
|
|
|
|
"co.ENABLED FROM DM_COMMAND_OPERATION co INNER JOIN (SELECT o.ID AS OPERATION_ID, o.TYPE, " +
|
|
|
|
|
|
|
|
"o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, o.STATUS 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 = " +
|
|
|
|
|
|
|
|
"dom.DEVICE_ID) ois ON o.ID = ois.OP_ID ORDER BY " +
|
|
|
|
|
|
|
|
"o.CREATED_TIMESTAMP ASC) po ON co.OPERATION_ID = po.OPERATION_ID";
|
|
|
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
|
|
|
|
stmt.setString(1, deviceId.getType());
|
|
|
|
|
|
|
|
stmt.setString(1, deviceId.getId());
|
|
|
|
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
List<CommandOperation> operations = new ArrayList<CommandOperation>();
|
|
|
|
public Operation getNextOperation(DeviceIdentifier deviceId) throws OperationManagementDAOException {
|
|
|
|
while (rs.next()) {
|
|
|
|
return null;
|
|
|
|
CommandOperation operation = new CommandOperation();
|
|
|
|
|
|
|
|
operation.setId(rs.getInt("ID"));
|
|
|
|
|
|
|
|
operation.setType(Operation.Type.valueOf(rs.getString("TYPE")));
|
|
|
|
|
|
|
|
operation.setStatus(Operation.Status.valueOf(rs.getString("STATUS")));
|
|
|
|
|
|
|
|
operation.setEnabled(Boolean.parseBoolean(rs.getString("ENABLED")));
|
|
|
|
|
|
|
|
operations.add(operation);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return operations;
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementDAOException("Error occurred while retrieving the list of " +
|
|
|
|
|
|
|
|
"operations available for the '" + deviceId.getType() + "' device '" + deviceId.getId() + "'");
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
OperationManagementDAOUtil.cleanupResources(stmt, rs);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|