mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Update Operation manager implementation
This commit is contained in:
parent
4a9a27ab7e
commit
416ef5a745
@ -58,7 +58,6 @@ public interface OperationManager {
|
|||||||
|
|
||||||
public Operation getNextPendingOperation(DeviceIdentifier deviceId) throws OperationManagementException;
|
public Operation getNextPendingOperation(DeviceIdentifier deviceId) throws OperationManagementException;
|
||||||
|
|
||||||
public Operation updateOperation(
|
public void updateOperation(int operationId, Operation.Status operationStatus) throws OperationManagementException;
|
||||||
int id, DeviceIdentifier deviceIdentifier, String payLoad) throws OperationManagementException;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -361,9 +361,8 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Operation updateOperation(int id, DeviceIdentifier deviceIdentifier,
|
public void updateOperation(int operationId, Operation.Status operationStatus)
|
||||||
String payLoad) throws OperationManagementException {
|
throws OperationManagementException {
|
||||||
return operationManager.updateOperation(id, deviceIdentifier, payLoad);
|
operationManager.updateOperation(operationId,operationStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -155,9 +155,19 @@ public class OperationManagerImpl implements OperationManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Operation updateOperation(int id, DeviceIdentifier deviceIdentifier,
|
public void updateOperation(int operationId, Operation.Status operationStatus)
|
||||||
String responsePayLoad) throws OperationManagementException {
|
throws OperationManagementException {
|
||||||
return null;
|
try {
|
||||||
|
OperationManagementDAOFactory.beginTransaction();
|
||||||
|
Operation operation = operationDAO.getOperation(operationId);
|
||||||
|
operation.setStatus(operationStatus);
|
||||||
|
operationDAO.updateOperation(operation);
|
||||||
|
OperationManagementDAOFactory.commitTransaction();
|
||||||
|
}catch(OperationManagementDAOException ex){
|
||||||
|
log.error("Error occurred while updating the operation: "+operationId);
|
||||||
|
throw new OperationManagementException("Error occurred while update operation", ex);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private OperationDAO lookupOperationDAO(Operation operation) {
|
private OperationDAO lookupOperationDAO(Operation operation) {
|
||||||
|
|||||||
@ -35,7 +35,7 @@ public interface OperationDAO {
|
|||||||
|
|
||||||
Operation getOperation(DeviceIdentifier deviceId, int operationId) throws OperationManagementDAOException;
|
Operation getOperation(DeviceIdentifier deviceId, int operationId) throws OperationManagementDAOException;
|
||||||
|
|
||||||
Operation getOperation(DeviceIdentifier deviceId, Operation.Status status) throws OperationManagementDAOException;
|
Operation getOperation(DeviceIdentifier deviceIdentifier, Operation.Status status) throws OperationManagementDAOException;
|
||||||
|
|
||||||
List<? extends Operation> getOperations(DeviceIdentifier deviceId) throws OperationManagementDAOException;
|
List<? extends Operation> getOperations(DeviceIdentifier deviceId) throws OperationManagementDAOException;
|
||||||
|
|
||||||
|
|||||||
@ -55,6 +55,44 @@ public class CommandOperationDAOImpl extends OperationDAOImpl {
|
|||||||
return operationId;
|
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,
|
public List<? extends Operation> getOperations(DeviceIdentifier deviceId,
|
||||||
Operation.Status status) throws OperationManagementDAOException {
|
Operation.Status status) throws OperationManagementDAOException {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
@ -64,8 +102,10 @@ public class CommandOperationDAOImpl extends OperationDAOImpl {
|
|||||||
try {
|
try {
|
||||||
Connection conn = OperationManagementDAOFactory.openConnection();
|
Connection conn = OperationManagementDAOFactory.openConnection();
|
||||||
String sql = "SELECT po.OPERATION_ID, po.TYPE, po.CREATED_TIMESTAMP, po.RECEIVED_TIMESTAMP, po.STATUS, " +
|
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, " +
|
"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 (" +
|
+
|
||||||
|
"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 " +
|
"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 " +
|
"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 = " +
|
"d.DEVICE_IDENTIFICATION = ?) d1 INNER JOIN DM_DEVICE_OPERATION_MAPPING dom ON d1.ID = " +
|
||||||
@ -78,12 +118,17 @@ public class CommandOperationDAOImpl extends OperationDAOImpl {
|
|||||||
stmt.setString(3, status.toString());
|
stmt.setString(3, status.toString());
|
||||||
rs = stmt.executeQuery(sql);
|
rs = stmt.executeQuery(sql);
|
||||||
|
|
||||||
while(rs.next()){
|
while (rs.next()) {
|
||||||
operation = new Operation();
|
operation = new Operation();
|
||||||
operation.setId(rs.getInt("OPERATION_ID"));
|
operation.setId(rs.getInt("OPERATION_ID"));
|
||||||
operation.setType(Operation.Type.valueOf(rs.getString("TYPE")));
|
operation.setType(Operation.Type.valueOf(rs.getString("TYPE")));
|
||||||
operation.setCreatedTimeStamp(rs.getTimestamp("CREATED_TIMESTAMP").toString());
|
operation.setCreatedTimeStamp(rs.getTimestamp("CREATED_TIMESTAMP").toString());
|
||||||
|
|
||||||
|
if (rs.getTimestamp("RECEIVED_TIMESTAMP") != null) {
|
||||||
operation.setCreatedTimeStamp(rs.getTimestamp("RECEIVED_TIMESTAMP").toString());
|
operation.setCreatedTimeStamp(rs.getTimestamp("RECEIVED_TIMESTAMP").toString());
|
||||||
|
} else {
|
||||||
|
operation.setCreatedTimeStamp(null);
|
||||||
|
}
|
||||||
operation.setStatus(Operation.Status.valueOf(rs.getString("STATUS")));
|
operation.setStatus(Operation.Status.valueOf(rs.getString("STATUS")));
|
||||||
operation.setEnabled(rs.getBoolean("ENABLED"));
|
operation.setEnabled(rs.getBoolean("ENABLED"));
|
||||||
operation.setCode(rs.getString("OPERATIONCODE"));
|
operation.setCode(rs.getString("OPERATIONCODE"));
|
||||||
@ -107,8 +152,10 @@ public class CommandOperationDAOImpl extends OperationDAOImpl {
|
|||||||
try {
|
try {
|
||||||
Connection conn = OperationManagementDAOFactory.openConnection();
|
Connection conn = OperationManagementDAOFactory.openConnection();
|
||||||
String sql = "SELECT po.OPERATION_ID, po.TYPE, po.CREATED_TIMESTAMP, po.RECEIVED_TIMESTAMP, po.STATUS, " +
|
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, " +
|
"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 (" +
|
+
|
||||||
|
"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 " +
|
"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 " +
|
"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 = " +
|
"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 = conn.prepareStatement(sql);
|
||||||
stmt.setString(1, deviceId.getType());
|
stmt.setString(1, deviceId.getType());
|
||||||
stmt.setString(1, deviceId.getId());
|
stmt.setString(2, deviceId.getId());
|
||||||
rs = stmt.executeQuery();
|
rs = stmt.executeQuery();
|
||||||
|
|
||||||
List<CommandOperation> operations = new ArrayList<CommandOperation>();
|
List<CommandOperation> operations = new ArrayList<CommandOperation>();
|
||||||
@ -125,6 +172,13 @@ public class CommandOperationDAOImpl extends OperationDAOImpl {
|
|||||||
CommandOperation operation = new CommandOperation();
|
CommandOperation operation = new CommandOperation();
|
||||||
operation.setId(rs.getInt("ID"));
|
operation.setId(rs.getInt("ID"));
|
||||||
operation.setType(Operation.Type.valueOf(rs.getString("TYPE")));
|
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.setStatus(Operation.Status.valueOf(rs.getString("STATUS")));
|
||||||
operation.setEnabled(Boolean.parseBoolean(rs.getString("ENABLED")));
|
operation.setEnabled(Boolean.parseBoolean(rs.getString("ENABLED")));
|
||||||
operation.setCode(rs.getString("OPERATIONCODE"));
|
operation.setCode(rs.getString("OPERATIONCODE"));
|
||||||
@ -149,7 +203,7 @@ public class CommandOperationDAOImpl extends OperationDAOImpl {
|
|||||||
stmt = connection.prepareStatement(
|
stmt = connection.prepareStatement(
|
||||||
"UPDATE DM_COMMAND_OPERATION O SET O.ENABLED=? WHERE O.OPERATION_ID=?");
|
"UPDATE DM_COMMAND_OPERATION O SET O.ENABLED=? WHERE O.OPERATION_ID=?");
|
||||||
|
|
||||||
stmt.setBoolean(1,operation.isEnabled());
|
stmt.setBoolean(1, operation.isEnabled());
|
||||||
stmt.setInt(2, operation.getId());
|
stmt.setInt(2, operation.getId());
|
||||||
stmt.executeUpdate();
|
stmt.executeUpdate();
|
||||||
|
|
||||||
@ -168,7 +222,7 @@ public class CommandOperationDAOImpl extends OperationDAOImpl {
|
|||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
try {
|
try {
|
||||||
Connection connection = OperationManagementDAOFactory.openConnection();
|
Connection connection = OperationManagementDAOFactory.openConnection();
|
||||||
stmt = connection.prepareStatement("DELETE DM_COMMAND_OPERATION WHERE OPERATION_ID=?") ;
|
stmt = connection.prepareStatement("DELETE DM_COMMAND_OPERATION WHERE OPERATION_ID=?");
|
||||||
stmt.setInt(1, id);
|
stmt.setInt(1, id);
|
||||||
stmt.executeUpdate();
|
stmt.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
|||||||
@ -67,8 +67,8 @@ public class OperationDAOImpl implements OperationDAO {
|
|||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
try {
|
try {
|
||||||
Connection connection = OperationManagementDAOFactory.openConnection();
|
Connection connection = OperationManagementDAOFactory.openConnection();
|
||||||
stmt = connection.prepareStatement(
|
stmt = connection.prepareStatement("UPDATE DM_OPERATION O SET O.RECEIVED_TIMESTAMP=?,O.STATUS=? " +
|
||||||
"UPDATE DM_OPERATION O SET O.RECEIVED_TIMESTAMP=?,O.STATUS=? WHERE O.ID=?");
|
"WHERE O.ID=?");
|
||||||
|
|
||||||
stmt.setTimestamp(1, new Timestamp(new Date().getTime()));
|
stmt.setTimestamp(1, new Timestamp(new Date().getTime()));
|
||||||
stmt.setString(2, operation.getStatus().toString());
|
stmt.setString(2, operation.getStatus().toString());
|
||||||
@ -84,10 +84,11 @@ public class OperationDAOImpl implements OperationDAO {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteOperation(int id) throws OperationManagementDAOException {
|
public void deleteOperation(int id) throws OperationManagementDAOException {
|
||||||
|
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
try {
|
try {
|
||||||
Connection connection = OperationManagementDAOFactory.openConnection();
|
Connection connection = OperationManagementDAOFactory.openConnection();
|
||||||
stmt = connection.prepareStatement("DELETE DM_OPERATION WHERE ID=?") ;
|
stmt = connection.prepareStatement("DELETE DM_OPERATION WHERE ID=?");
|
||||||
stmt.setInt(1, id);
|
stmt.setInt(1, id);
|
||||||
stmt.executeUpdate();
|
stmt.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@ -98,13 +99,90 @@ public class OperationDAOImpl implements OperationDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Operation getOperation(int id) throws OperationManagementDAOException {
|
public Operation getOperation(int id) throws OperationManagementDAOException {
|
||||||
return null;
|
|
||||||
|
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 FROM " +
|
||||||
|
"DM_OPERATION o 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Operation getOperation(DeviceIdentifier deviceId, int operationId) throws OperationManagementDAOException {
|
public Operation getOperation(DeviceIdentifier deviceIdentifier, int operationId)
|
||||||
|
throws OperationManagementDAOException {
|
||||||
|
|
||||||
return null;
|
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 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 WHERE o.ID=?";
|
||||||
|
stmt = conn.prepareStatement(sql);
|
||||||
|
stmt.setString(1, deviceIdentifier.getType());
|
||||||
|
stmt.setString(2, deviceIdentifier.getId());
|
||||||
|
stmt.setInt(3, operationId);
|
||||||
|
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("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 " +
|
||||||
|
"available for the '" + deviceIdentifier.getType() + "' with id '" + deviceIdentifier.getId() + "'", e);
|
||||||
|
} finally {
|
||||||
|
OperationManagementDAOUtil.cleanupResources(stmt, rs);
|
||||||
|
OperationManagementDAOFactory.closeConnection();
|
||||||
|
}
|
||||||
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -115,8 +193,8 @@ public class OperationDAOImpl implements OperationDAO {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<? extends Operation> getOperations(DeviceIdentifier deviceId) throws OperationManagementDAOException {
|
public List<? extends Operation> getOperations(DeviceIdentifier deviceId) throws OperationManagementDAOException {
|
||||||
List<Operation> operations;
|
|
||||||
|
|
||||||
|
List<Operation> operations;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try {
|
try {
|
||||||
@ -141,9 +219,9 @@ public class OperationDAOImpl implements OperationDAO {
|
|||||||
operation.setId(rs.getInt("ID"));
|
operation.setId(rs.getInt("ID"));
|
||||||
operation.setType(Operation.Type.valueOf(rs.getString("TYPE")));
|
operation.setType(Operation.Type.valueOf(rs.getString("TYPE")));
|
||||||
operation.setCreatedTimeStamp(rs.getTimestamp("CREATED_TIMESTAMP").toString());
|
operation.setCreatedTimeStamp(rs.getTimestamp("CREATED_TIMESTAMP").toString());
|
||||||
if (rs.getTimestamp("CREATED_TIMESTAMP") == null){
|
if (rs.getTimestamp("CREATED_TIMESTAMP") == null) {
|
||||||
operation.setReceivedTimeStamp("");
|
operation.setReceivedTimeStamp("");
|
||||||
}else{
|
} else {
|
||||||
operation.setReceivedTimeStamp(rs.getTimestamp("CREATED_TIMESTAMP").toString());
|
operation.setReceivedTimeStamp(rs.getTimestamp("CREATED_TIMESTAMP").toString());
|
||||||
}
|
}
|
||||||
operation.setStatus(Operation.Status.valueOf(rs.getString("STATUS")));
|
operation.setStatus(Operation.Status.valueOf(rs.getString("STATUS")));
|
||||||
@ -196,10 +274,10 @@ public class OperationDAOImpl implements OperationDAO {
|
|||||||
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());
|
operation.setCreatedTimeStamp(rs.getTimestamp("CREATED_TIMESTAMP").toString());
|
||||||
if (rs.getTimestamp("RECEIVED_TIMESTAMP") == null){
|
if (rs.getTimestamp("RECEIVED_TIMESTAMP") == null) {
|
||||||
operation.setReceivedTimeStamp("");
|
operation.setReceivedTimeStamp("");
|
||||||
}else{
|
} else {
|
||||||
operation.setReceivedTimeStamp(rs.getString("RECEIVED_TIMESTAMP").toString());
|
operation.setReceivedTimeStamp(rs.getTimestamp("RECEIVED_TIMESTAMP").toString());
|
||||||
}
|
}
|
||||||
operation.setCode(rs.getString("OPERATIONCODE"));
|
operation.setCode(rs.getString("OPERATIONCODE"));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -157,11 +157,14 @@ public class ProfileOperationDAOImpl extends OperationDAOImpl {
|
|||||||
ois = new ObjectInputStream(bais);
|
ois = new ObjectInputStream(bais);
|
||||||
return (ProfileOperation) ois.readObject();
|
return (ProfileOperation) ois.readObject();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
log.error("SQL error occurred while retrieving profile operation", e);
|
||||||
throw new OperationManagementDAOException("Error occurred while adding operation metadata", e);
|
throw new OperationManagementDAOException("Error occurred while adding operation metadata", e);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
|
log.error("Class not found error occurred while retrieving profile operation", e);
|
||||||
throw new OperationManagementDAOException("Error occurred while casting retrieved payload as a " +
|
throw new OperationManagementDAOException("Error occurred while casting retrieved payload as a " +
|
||||||
"ProfileOperation object", e);
|
"ProfileOperation object", e);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
log.error("IO error occurred while de serialize profile operation", e);
|
||||||
throw new OperationManagementDAOException("Error occurred while serializing profile operation object", e);
|
throw new OperationManagementDAOException("Error occurred while serializing profile operation object", e);
|
||||||
} finally {
|
} finally {
|
||||||
OperationManagementDAOUtil.cleanupResources(stmt, rs);
|
OperationManagementDAOUtil.cleanupResources(stmt, rs);
|
||||||
@ -178,8 +181,8 @@ public class ProfileOperationDAOImpl extends OperationDAOImpl {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
Connection connection = OperationManagementDAOFactory.openConnection();
|
Connection connection = OperationManagementDAOFactory.openConnection();
|
||||||
stmt = connection.prepareStatement(
|
stmt = connection.prepareStatement("UPDATE DM_PROFILE_OPERATION O SET O.OPERATIONDETAILS=? " +
|
||||||
"UPDATE DM_PROFILE_OPERATION O SET O.OPERATIONDETAILS=? WHERE O.OPERATION_ID=?");
|
"WHERE O.OPERATION_ID=?");
|
||||||
|
|
||||||
bao = new ByteArrayOutputStream();
|
bao = new ByteArrayOutputStream();
|
||||||
oos = new ObjectOutputStream(bao);
|
oos = new ObjectOutputStream(bao);
|
||||||
|
|||||||
@ -137,10 +137,9 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Operation updateOperation(int operationId, DeviceIdentifier deviceIdentifier,
|
public void updateOperation(int operationId, Operation.Status operationStatus) throws OperationManagementException {
|
||||||
String responsePayLoad) throws OperationManagementException {
|
DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().updateOperation(operationId,
|
||||||
return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().
|
operationStatus);
|
||||||
updateOperation(operationId, deviceIdentifier, responsePayLoad);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -150,5 +149,4 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
|||||||
.sendEnrolmentInvitation(emailMessageProperties);
|
.sendEnrolmentInvitation(emailMessageProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user