mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
ADD Operation Code to core operation table
This commit is contained in:
parent
cf247128b3
commit
32b86c7ff1
@ -77,7 +77,6 @@ public class OperationManagementDAOFactory {
|
||||
public static Connection getConnection() throws OperationManagementDAOException {
|
||||
if (currentConnection.get() == null) {
|
||||
synchronized (LOCK) {
|
||||
|
||||
try {
|
||||
currentConnection.set(dataSource.getConnection());
|
||||
} catch (SQLException e) {
|
||||
|
||||
@ -39,11 +39,13 @@ public class OperationDAOImpl implements OperationDAO {
|
||||
try {
|
||||
Connection connection = OperationManagementDAOFactory.getConnection();
|
||||
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.setTimestamp(2, new Timestamp(new Date().getTime()));
|
||||
stmt.setTimestamp(3, null);
|
||||
stmt.setString(4, Operation.Status.PENDING.toString());
|
||||
stmt.setString(5, operation.getCode());
|
||||
stmt.executeUpdate();
|
||||
|
||||
rs = stmt.getGeneratedKeys();
|
||||
@ -117,7 +119,7 @@ public class OperationDAOImpl implements OperationDAO {
|
||||
try {
|
||||
Connection conn = OperationManagementDAOFactory.getConnection();
|
||||
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 " +
|
||||
"JOIN " +
|
||||
"DM_DEVICE_TYPE dm ON d.DEVICE_TYPE_ID = dm.ID AND dm.NAME = ? AND d" +
|
||||
@ -133,6 +135,15 @@ public class OperationDAOImpl implements OperationDAO {
|
||||
while (rs.next()) {
|
||||
Operation 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("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) {
|
||||
throw new OperationManagementDAOException("Error occurred while retrieving the operation list " +
|
||||
@ -161,7 +172,8 @@ public class OperationDAOImpl implements OperationDAO {
|
||||
try {
|
||||
Connection connection = OperationManagementDAOFactory.getConnection();
|
||||
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 " +
|
||||
"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 " +
|
||||
@ -173,10 +185,18 @@ public class OperationDAOImpl implements OperationDAO {
|
||||
|
||||
Operation operation = null;
|
||||
if (rs.next()) {
|
||||
|
||||
operation = new Operation();
|
||||
operation.setType(this.getType(rs.getString("TYPE")));
|
||||
operation.setStatus(this.getStatus(rs.getString("STATUS")));
|
||||
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;
|
||||
} catch (SQLException e) {
|
||||
|
||||
@ -135,15 +135,16 @@ public class ProfileOperationDAOImpl extends OperationDAOImpl {
|
||||
int operationId = 0;
|
||||
|
||||
String operationType = "";
|
||||
String createdTime;
|
||||
String receivedTime;
|
||||
String createdTime = "";
|
||||
String receivedTime = "";
|
||||
String operationStatus = "";
|
||||
String operationCode = "";
|
||||
|
||||
try {
|
||||
Connection connection = OperationManagementDAOFactory.getConnection();
|
||||
stmt = connection.prepareStatement(
|
||||
"SELECT o.ID AS OPERATION_ID, o.CREATED_TIMESTAMP AS CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP AS " +
|
||||
"RECEIVED_TIMESTAMP, po.PAYLOAD AS PAYLOAD,o.TYPE AS TYPE,o.STATUS as STATUS " +
|
||||
"RECEIVED_TIMESTAMP, po.PAYLOAD AS PAYLOAD,o.TYPE AS TYPE,o.STATUS as STATUS,o.OPERATIONCODE " +
|
||||
"FROM DM_OPERATION o " +
|
||||
"INNER JOIN DM_PROFILE_OPERATION po ON o.ID = po.OPERATION_ID AND o.ID IN (" +
|
||||
"SELECT dom.OPERATION_ID FROM (SELECT d.ID FROM DM_DEVICE d INNER JOIN " +
|
||||
@ -162,6 +163,7 @@ public class ProfileOperationDAOImpl extends OperationDAOImpl {
|
||||
payload = rs.getBytes("PAYLOAD");
|
||||
operationType = rs.getString("TYPE");
|
||||
operationStatus = rs.getString("STATUS");
|
||||
operationCode = rs.getString("OPERATIONCODE");
|
||||
}
|
||||
bais = new ByteArrayInputStream(payload);
|
||||
ois = new ObjectInputStream(bais);
|
||||
@ -170,6 +172,9 @@ public class ProfileOperationDAOImpl extends OperationDAOImpl {
|
||||
profileOperation.setId(operationId);
|
||||
profileOperation.setType(Operation.Type.valueOf(operationType));
|
||||
profileOperation.setStatus(Operation.Status.valueOf(operationStatus));
|
||||
profileOperation.setCreatedTimeStamp(createdTime);
|
||||
profileOperation.setReceivedTimeStamp(receivedTime);
|
||||
profileOperation.setCode(operationCode);
|
||||
return profileOperation;
|
||||
|
||||
} catch (SQLException e) {
|
||||
|
||||
@ -65,6 +65,7 @@ public class DeviceOperationManagementTests extends DeviceManagementBaseTest {
|
||||
CommandOperation op = new CommandOperation();
|
||||
op.setEnabled(true);
|
||||
op.setType(Operation.Type.COMMAND);
|
||||
op.setCode("OPCODE1");
|
||||
|
||||
List<DeviceIdentifier> deviceIds = new ArrayList<DeviceIdentifier>();
|
||||
DeviceIdentifier deviceId = new DeviceIdentifier();
|
||||
|
||||
@ -27,6 +27,7 @@ CREATE TABLE IF NOT EXISTS DM_OPERATION (
|
||||
CREATED_TIMESTAMP TIMESTAMP NOT NULL,
|
||||
RECEIVED_TIMESTAMP TIMESTAMP NULL,
|
||||
STATUS VARCHAR(50) NULL,
|
||||
OPERATIONCODE VARCHAR(25) NOT NULL,
|
||||
PRIMARY KEY (ID)
|
||||
);
|
||||
|
||||
|
||||
@ -28,6 +28,7 @@ CREATE TABLE IF NOT EXISTS DM_OPERATION (
|
||||
RECEIVED_TIMESTAMP TIMESTAMP NULL,
|
||||
STATUS VARCHAR(50) NULL,
|
||||
PAYLOAD CLOB NULL,
|
||||
OPERATIONCODE VARCHAR(25) NOT NULL,
|
||||
PRIMARY KEY (ID)
|
||||
);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user