OperationManagerImpl Code refactored

revert-70aa11f8
harshanl 8 years ago
parent f9ba45f439
commit 10f8b12b88

@ -141,8 +141,10 @@ public class OperationManagerImpl implements OperationManager {
} }
} else if (isNotRepeated) { } else if (isNotRepeated) {
operationDAO.updateEnrollmentOperationsStatus(enrolmentId, operationCode, operationDAO.updateEnrollmentOperationsStatus(enrolmentId, operationCode,
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status.PENDING, org.wso2.carbon.device.mgt.core.dto.operation.mgt.
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status.REPEATED); Operation.Status.PENDING,
org.wso2.carbon.device.mgt.core.dto.operation.mgt.
Operation.Status.REPEATED);
operationMappingDAO.addOperationMapping(operationId, enrolmentId); operationMappingDAO.addOperationMapping(operationId, enrolmentId);
} else { } else {
operationMappingDAO.addOperationMapping(operationId, enrolmentId); operationMappingDAO.addOperationMapping(operationId, enrolmentId);
@ -168,7 +170,8 @@ public class OperationManagerImpl implements OperationManager {
if (!isScheduledOperation) { if (!isScheduledOperation) {
//Get the device-type from 1st valid DeviceIdentifier. We know the 1st element is definitely there. //Get the device-type from 1st valid DeviceIdentifier. We know the 1st element is definitely there.
String deviceType = validDeviceIds.get(0).getType(); String deviceType = validDeviceIds.get(0).getType();
activity.setActivityStatus(this.getActivityStatus(deviceValidationResult, deviceAuthorizationResult, deviceType)); activity.setActivityStatus(this.getActivityStatus(deviceValidationResult, deviceAuthorizationResult,
deviceType));
} }
return activity; return activity;
} else { } else {
@ -484,10 +487,9 @@ public class OperationManagerImpl implements OperationManager {
boolean isUpdated = false; boolean isUpdated = false;
if (operation.getStatus() != null) { if (operation.getStatus() != null) {
isUpdated = operationDAO.updateOperationStatus(enrolmentId, operationId, isUpdated = operationDAO.updateOperationStatus(enrolmentId, operationId,
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status org.wso2.carbon.device.mgt.core.dto.operation.mgt.
. Operation.Status.valueOf(operation.getStatus().
valueOf(operation.getStatus() toString()));
.toString()));
} }
if (isUpdated && operation.getOperationResponse() != null) { if (isUpdated && operation.getOperationResponse() != null) {
operationDAO.addOperationResponse(enrolmentId, operationId, operation.getOperationResponse()); operationDAO.addOperationResponse(enrolmentId, operationId, operation.getOperationResponse());
@ -550,17 +552,13 @@ public class OperationManagerImpl implements OperationManager {
try { try {
OperationManagementDAOFactory.openConnection(); OperationManagementDAOFactory.openConnection();
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation dtoOperation = operationDAO. org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation dtoOperation = operationDAO.
getOperationByDeviceAndId( getOperationByDeviceAndId(enrolmentId, operationId);
enrolmentId,
operationId);
if (dtoOperation.getType(). if (dtoOperation.getType().
equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.COMMAND)) { equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.COMMAND)) {
org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation commandOperation; org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation commandOperation;
commandOperation = commandOperation =
(org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation) commandOperationDAO. (org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation) commandOperationDAO.
getOperation( getOperation(dtoOperation.getId());
dtoOperation
.getId());
dtoOperation.setEnabled(commandOperation.isEnabled()); dtoOperation.setEnabled(commandOperation.isEnabled());
} else if (dtoOperation.getType(). } else if (dtoOperation.getType().
equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.CONFIG)) { equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.CONFIG)) {
@ -617,11 +615,14 @@ public class OperationManagerImpl implements OperationManager {
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status.valueOf(status.toString()); org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status.valueOf(status.toString());
dtoOperationList.addAll(commandOperationDAO.getOperationsByDeviceAndStatus(enrolmentId, dtoOpStatus)); dtoOperationList.addAll(commandOperationDAO.getOperationsByDeviceAndStatus(enrolmentId, dtoOpStatus));
dtoOperationList.addAll(configOperationDAO.getOperationsByDeviceAndStatus(enrolmentId, dtoOperationList.addAll(configOperationDAO.getOperationsByDeviceAndStatus(enrolmentId,
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status.PENDING)); org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.
Status.PENDING));
dtoOperationList.addAll(profileOperationDAO.getOperationsByDeviceAndStatus(enrolmentId, dtoOperationList.addAll(profileOperationDAO.getOperationsByDeviceAndStatus(enrolmentId,
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status.PENDING)); org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.
Status.PENDING));
dtoOperationList.addAll(policyOperationDAO.getOperationsByDeviceAndStatus(enrolmentId, dtoOperationList.addAll(policyOperationDAO.getOperationsByDeviceAndStatus(enrolmentId,
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status.PENDING)); org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.
Status.PENDING));
Operation operation; Operation operation;
@ -649,8 +650,7 @@ public class OperationManagerImpl implements OperationManager {
Operation operation; Operation operation;
try { try {
OperationManagementDAOFactory.openConnection(); OperationManagementDAOFactory.openConnection();
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation dtoOperation = operationDAO. org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation dtoOperation = operationDAO.getOperation(
getOperation(
operationId); operationId);
if (dtoOperation == null) { if (dtoOperation == null) {
throw new OperationManagementException("Operation not found for given Id:" + operationId); throw new OperationManagementException("Operation not found for given Id:" + operationId);
@ -661,9 +661,7 @@ public class OperationManagerImpl implements OperationManager {
org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation commandOperation; org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation commandOperation;
commandOperation = commandOperation =
(org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation) commandOperationDAO. (org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation) commandOperationDAO.
getOperation( getOperation(dtoOperation.getId());
dtoOperation
.getId());
dtoOperation.setEnabled(commandOperation.isEnabled()); dtoOperation.setEnabled(commandOperation.isEnabled());
} else if (dtoOperation.getType(). } else if (dtoOperation.getType().
equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.CONFIG)) { equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.CONFIG)) {

Loading…
Cancel
Save