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,11 +77,10 @@ public class OperationManagementDAOFactory {
|
|||||||
public static Connection getConnection() throws OperationManagementDAOException {
|
public static Connection getConnection() throws OperationManagementDAOException {
|
||||||
if (currentConnection.get() == null) {
|
if (currentConnection.get() == null) {
|
||||||
synchronized (LOCK) {
|
synchronized (LOCK) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
currentConnection.set(dataSource.getConnection());
|
currentConnection.set(dataSource.getConnection());
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new OperationManagementDAOException("Error occurred while retrieving datasource connection",
|
throw new OperationManagementDAOException("Error occurred while retrieving data source connection",
|
||||||
e);
|
e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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) {
|
||||||
|
|||||||
@ -135,15 +135,16 @@ public class ProfileOperationDAOImpl extends OperationDAOImpl {
|
|||||||
int operationId = 0;
|
int operationId = 0;
|
||||||
|
|
||||||
String operationType = "";
|
String operationType = "";
|
||||||
String createdTime;
|
String createdTime = "";
|
||||||
String receivedTime;
|
String receivedTime = "";
|
||||||
String operationStatus = "";
|
String operationStatus = "";
|
||||||
|
String operationCode = "";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Connection connection = OperationManagementDAOFactory.getConnection();
|
Connection connection = OperationManagementDAOFactory.getConnection();
|
||||||
stmt = connection.prepareStatement(
|
stmt = connection.prepareStatement(
|
||||||
"SELECT o.ID AS OPERATION_ID, o.CREATED_TIMESTAMP AS CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP AS " +
|
"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 " +
|
"FROM DM_OPERATION o " +
|
||||||
"INNER JOIN DM_PROFILE_OPERATION po ON o.ID = po.OPERATION_ID AND o.ID IN (" +
|
"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 " +
|
"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");
|
payload = rs.getBytes("PAYLOAD");
|
||||||
operationType = rs.getString("TYPE");
|
operationType = rs.getString("TYPE");
|
||||||
operationStatus = rs.getString("STATUS");
|
operationStatus = rs.getString("STATUS");
|
||||||
|
operationCode = rs.getString("OPERATIONCODE");
|
||||||
}
|
}
|
||||||
bais = new ByteArrayInputStream(payload);
|
bais = new ByteArrayInputStream(payload);
|
||||||
ois = new ObjectInputStream(bais);
|
ois = new ObjectInputStream(bais);
|
||||||
@ -170,6 +172,9 @@ public class ProfileOperationDAOImpl extends OperationDAOImpl {
|
|||||||
profileOperation.setId(operationId);
|
profileOperation.setId(operationId);
|
||||||
profileOperation.setType(Operation.Type.valueOf(operationType));
|
profileOperation.setType(Operation.Type.valueOf(operationType));
|
||||||
profileOperation.setStatus(Operation.Status.valueOf(operationStatus));
|
profileOperation.setStatus(Operation.Status.valueOf(operationStatus));
|
||||||
|
profileOperation.setCreatedTimeStamp(createdTime);
|
||||||
|
profileOperation.setReceivedTimeStamp(receivedTime);
|
||||||
|
profileOperation.setCode(operationCode);
|
||||||
return profileOperation;
|
return profileOperation;
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
|||||||
@ -65,6 +65,7 @@ public class DeviceOperationManagementTests extends DeviceManagementBaseTest {
|
|||||||
CommandOperation op = new CommandOperation();
|
CommandOperation op = new CommandOperation();
|
||||||
op.setEnabled(true);
|
op.setEnabled(true);
|
||||||
op.setType(Operation.Type.COMMAND);
|
op.setType(Operation.Type.COMMAND);
|
||||||
|
op.setCode("OPCODE1");
|
||||||
|
|
||||||
List<DeviceIdentifier> deviceIds = new ArrayList<DeviceIdentifier>();
|
List<DeviceIdentifier> deviceIds = new ArrayList<DeviceIdentifier>();
|
||||||
DeviceIdentifier deviceId = new DeviceIdentifier();
|
DeviceIdentifier deviceId = new DeviceIdentifier();
|
||||||
|
|||||||
@ -27,6 +27,7 @@ CREATE TABLE IF NOT EXISTS DM_OPERATION (
|
|||||||
CREATED_TIMESTAMP TIMESTAMP NOT NULL,
|
CREATED_TIMESTAMP TIMESTAMP NOT NULL,
|
||||||
RECEIVED_TIMESTAMP TIMESTAMP NULL,
|
RECEIVED_TIMESTAMP TIMESTAMP NULL,
|
||||||
STATUS VARCHAR(50) NULL,
|
STATUS VARCHAR(50) NULL,
|
||||||
|
OPERATIONCODE VARCHAR(25) NOT NULL,
|
||||||
PRIMARY KEY (ID)
|
PRIMARY KEY (ID)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -28,6 +28,7 @@ CREATE TABLE IF NOT EXISTS DM_OPERATION (
|
|||||||
RECEIVED_TIMESTAMP TIMESTAMP NULL,
|
RECEIVED_TIMESTAMP TIMESTAMP NULL,
|
||||||
STATUS VARCHAR(50) NULL,
|
STATUS VARCHAR(50) NULL,
|
||||||
PAYLOAD CLOB NULL,
|
PAYLOAD CLOB NULL,
|
||||||
|
OPERATIONCODE VARCHAR(25) NOT NULL,
|
||||||
PRIMARY KEY (ID)
|
PRIMARY KEY (ID)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user