update operation status

revert-70aa11f8
manoj 10 years ago
parent 0ed9c46a64
commit 39b85a3b44

@ -59,7 +59,8 @@ public interface OperationManager {
public Operation getNextPendingOperation(DeviceIdentifier deviceId) throws OperationManagementException; public Operation getNextPendingOperation(DeviceIdentifier deviceId) throws OperationManagementException;
public void updateOperation(int operationId, Operation.Status operationStatus) throws OperationManagementException; public void updateOperation(int deviceId, int operationId, Operation.Status operationStatus) throws
OperationManagementException;
public void deleteOperation(int operationId) throws OperationManagementException; public void deleteOperation(int operationId) throws OperationManagementException;

@ -465,9 +465,10 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
} }
@Override @Override
public void updateOperation(int operationId, Operation.Status operationStatus) public void updateOperation(int deviceId, int operationId, Operation.Status operationStatus)
throws OperationManagementException { throws OperationManagementException {
DeviceManagementDataHolder.getInstance().getOperationManager().updateOperation(operationId, operationStatus); DeviceManagementDataHolder.getInstance().getOperationManager().updateOperation(deviceId,operationId,
operationStatus);
} }
@Override @Override

@ -263,7 +263,7 @@ public class OperationManagerImpl implements OperationManager {
} }
@Override @Override
public void updateOperation(int operationId, Operation.Status operationStatus) public void updateOperation(int deviceId, int operationId, Operation.Status operationStatus)
throws OperationManagementException { throws OperationManagementException {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
@ -280,7 +280,9 @@ public class OperationManagerImpl implements OperationManager {
dtoOperation.setStatus(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status.valueOf dtoOperation.setStatus(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status.valueOf
(operationStatus.toString())); (operationStatus.toString()));
OperationManagementDAOFactory.beginTransaction(); OperationManagementDAOFactory.beginTransaction();
lookupOperationDAO(dtoOperation).updateOperation(dtoOperation); operationDAO.updateOperation(dtoOperation);
operationDAO.updateOperationStatus(deviceId,operationId,
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status.valueOf(operationStatus.toString()));
OperationManagementDAOFactory.commitTransaction(); OperationManagementDAOFactory.commitTransaction();
} catch (OperationManagementDAOException ex) { } catch (OperationManagementDAOException ex) {
try { try {

@ -42,4 +42,7 @@ public interface OperationDAO {
Operation getNextOperation(int deviceId) throws OperationManagementDAOException; Operation getNextOperation(int deviceId) throws OperationManagementDAOException;
void updateOperationStatus(int deviceId, int operationId,Operation.Status status) throws
OperationManagementDAOException;
} }

@ -76,12 +76,36 @@ public class OperationDAOImpl implements OperationDAO {
stmt.executeUpdate(); stmt.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {
throw new OperationManagementDAOException("Error occurred while adding operation metadata", e); throw new OperationManagementDAOException("Error occurred while update operation metadata", e);
} finally { } finally {
OperationManagementDAOUtil.cleanupResources(stmt); OperationManagementDAOUtil.cleanupResources(stmt);
} }
} }
public void updateOperationStatus(int deviceId, int operationId,Operation.Status status)
throws OperationManagementDAOException{
PreparedStatement stmt = null;
try {
Connection connection = OperationManagementDAOFactory.getConnection();
stmt = connection.prepareStatement("UPDATE DM_DEVICE_OPERATION_MAPPING O SET O.STATUS=? " +
"WHERE O.DEVICE_ID=? and O.OPERATION_ID=?");
stmt.setString(1, status.toString());
stmt.setInt(2, deviceId);
stmt.setInt(3, operationId);
stmt.executeUpdate();
} catch (SQLException e) {
throw new OperationManagementDAOException("Error occurred while update device mapping operation status " +
"metadata",
e);
} finally {
OperationManagementDAOUtil.cleanupResources(stmt);
}
}
@Override @Override
public void deleteOperation(int id) throws OperationManagementDAOException { public void deleteOperation(int id) throws OperationManagementDAOException {

@ -149,8 +149,9 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
} }
@Override @Override
public void updateOperation(int operationId, Operation.Status operationStatus) throws OperationManagementException { public void updateOperation(int deviceId, int operationId, Operation.Status operationStatus) throws
DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().updateOperation(operationId, OperationManagementException {
DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().updateOperation(deviceId, operationId,
operationStatus); operationStatus);
} }

Loading…
Cancel
Save