|
|
@ -20,7 +20,6 @@ package org.wso2.carbon.device.mgt.core.operation.mgt.dao.impl;
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation;
|
|
|
|
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOException;
|
|
|
|
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOException;
|
|
|
@ -37,6 +36,7 @@ import java.util.List;
|
|
|
|
public class CommandOperationDAOImpl extends OperationDAOImpl {
|
|
|
|
public class CommandOperationDAOImpl extends OperationDAOImpl {
|
|
|
|
|
|
|
|
|
|
|
|
private static final Log log = LogFactory.getLog(CommandOperationDAOImpl.class);
|
|
|
|
private static final Log log = LogFactory.getLog(CommandOperationDAOImpl.class);
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public int addOperation(Operation operation) throws OperationManagementDAOException {
|
|
|
|
public int addOperation(Operation operation) throws OperationManagementDAOException {
|
|
|
|
|
|
|
|
|
|
|
@ -138,13 +138,15 @@ public class CommandOperationDAOImpl extends OperationDAOImpl {
|
|
|
|
Operation operation;
|
|
|
|
Operation operation;
|
|
|
|
|
|
|
|
|
|
|
|
List<Operation> operationList = new ArrayList<Operation>();
|
|
|
|
List<Operation> operationList = new ArrayList<Operation>();
|
|
|
|
|
|
|
|
List<CommandOperation> commandOperationList = new ArrayList<CommandOperation>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CommandOperation commandOperation = null;
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Connection conn = OperationManagementDAOFactory.getConnection();
|
|
|
|
Connection conn = OperationManagementDAOFactory.getConnection();
|
|
|
|
String sql = "Select co.OPERATION_ID,ENABLED from DM_COMMAND_OPERATION co "+
|
|
|
|
String sql = "Select co.OPERATION_ID,ENABLED from DM_COMMAND_OPERATION co " +
|
|
|
|
"INNER JOIN "+
|
|
|
|
"INNER JOIN " +
|
|
|
|
"(Select * From DM_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID=? "+
|
|
|
|
"(Select * From DM_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID=? " +
|
|
|
|
"AND STATUS=? ) dm ON dm.OPERATION_ID = co.OPERATION_ID";
|
|
|
|
"AND STATUS=? ) dm ON dm.OPERATION_ID = co.OPERATION_ID";
|
|
|
|
|
|
|
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
@ -152,15 +154,19 @@ public class CommandOperationDAOImpl extends OperationDAOImpl {
|
|
|
|
stmt.setString(2, status.toString());
|
|
|
|
stmt.setString(2, status.toString());
|
|
|
|
|
|
|
|
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
int operationId;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (rs.next()) {
|
|
|
|
while (rs.next()) {
|
|
|
|
|
|
|
|
commandOperation = new CommandOperation();
|
|
|
|
|
|
|
|
commandOperation.setEnabled(rs.getInt("ENABLED") == 0 ? false : true);
|
|
|
|
|
|
|
|
commandOperation.setId(rs.getInt("OPERATION_ID"));
|
|
|
|
|
|
|
|
commandOperationList.add(commandOperation);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
operationId = rs.getInt("OPERATION_ID");
|
|
|
|
for(CommandOperation cmOperation:commandOperationList){
|
|
|
|
operation = super.getOperation(operationId);
|
|
|
|
operation = super.getOperation(cmOperation.getId());
|
|
|
|
operation.setEnabled(rs.getInt("ENABLED") == 0?false:true);
|
|
|
|
operation.setEnabled(cmOperation.isEnabled());
|
|
|
|
operationList.add(operation);
|
|
|
|
operationList.add(operation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
String errorMsg = "SQL error occurred while retrieving the operation available for the device'" + deviceId +
|
|
|
|
String errorMsg = "SQL error occurred while retrieving the operation available for the device'" + deviceId +
|
|
|
|
"' with status '" + status.toString();
|
|
|
|
"' with status '" + status.toString();
|
|
|
|