|
|
|
@ -22,6 +22,7 @@ import org.apache.commons.logging.Log;
|
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
|
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory;
|
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileFeatureDAO;
|
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
|
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.dto.MobileFeature;
|
|
|
|
@ -38,11 +39,9 @@ import java.util.List;
|
|
|
|
|
|
|
|
|
|
public class AndroidFeatureDAOImpl implements MobileFeatureDAO {
|
|
|
|
|
|
|
|
|
|
private DataSource dataSource;
|
|
|
|
|
private static final Log log = LogFactory.getLog(AndroidFeatureDAOImpl.class);
|
|
|
|
|
|
|
|
|
|
public AndroidFeatureDAOImpl(DataSource dataSource) {
|
|
|
|
|
this.dataSource = dataSource;
|
|
|
|
|
public AndroidFeatureDAOImpl() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -52,7 +51,7 @@ public class AndroidFeatureDAOImpl implements MobileFeatureDAO {
|
|
|
|
|
Connection conn = null;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
conn = this.getConnection();
|
|
|
|
|
conn = MobileDeviceManagementDAOFactory.getConnection();
|
|
|
|
|
String sql = "INSERT INTO AD_FEATURE(CODE, NAME, DESCRIPTION) VALUES (?, ?, ?)";
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
|
stmt.setString(1, mobileFeature.getCode());
|
|
|
|
@ -77,7 +76,7 @@ public class AndroidFeatureDAOImpl implements MobileFeatureDAO {
|
|
|
|
|
Connection conn = null;
|
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
|
try {
|
|
|
|
|
conn = this.getConnection();
|
|
|
|
|
conn = MobileDeviceManagementDAOFactory.getConnection();
|
|
|
|
|
String updateDBQuery =
|
|
|
|
|
"UPDATE AD_FEATURE SET NAME = ?, DESCRIPTION = ?" +
|
|
|
|
|
"WHERE CODE = ?";
|
|
|
|
@ -112,7 +111,7 @@ public class AndroidFeatureDAOImpl implements MobileFeatureDAO {
|
|
|
|
|
boolean status = false;
|
|
|
|
|
Connection conn = null;
|
|
|
|
|
try {
|
|
|
|
|
conn = this.getConnection();
|
|
|
|
|
conn = MobileDeviceManagementDAOFactory.getConnection();
|
|
|
|
|
String sql = "DELETE FROM AD_FEATURE WHERE ID = ?";
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
|
stmt.setInt(1, mblFeatureId);
|
|
|
|
@ -135,7 +134,7 @@ public class AndroidFeatureDAOImpl implements MobileFeatureDAO {
|
|
|
|
|
boolean status = false;
|
|
|
|
|
Connection conn = null;
|
|
|
|
|
try {
|
|
|
|
|
conn = this.getConnection();
|
|
|
|
|
conn = MobileDeviceManagementDAOFactory.getConnection();
|
|
|
|
|
String sql = "DELETE FROM AD_FEATURE WHERE CODE = ?";
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
|
stmt.setString(1, mblFeatureCode);
|
|
|
|
@ -158,7 +157,7 @@ public class AndroidFeatureDAOImpl implements MobileFeatureDAO {
|
|
|
|
|
ResultSet rs = null;
|
|
|
|
|
Connection conn = null;
|
|
|
|
|
try {
|
|
|
|
|
conn = this.getConnection();
|
|
|
|
|
conn = MobileDeviceManagementDAOFactory.getConnection();
|
|
|
|
|
String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM AD_FEATURE WHERE ID = ?";
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
|
stmt.setInt(1, mblFeatureId);
|
|
|
|
@ -193,7 +192,7 @@ public class AndroidFeatureDAOImpl implements MobileFeatureDAO {
|
|
|
|
|
Connection conn = null;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
conn = this.getConnection();
|
|
|
|
|
conn = MobileDeviceManagementDAOFactory.getConnection();
|
|
|
|
|
String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM AD_FEATURE WHERE CODE = ?";
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
|
stmt.setString(1, mblFeatureCode);
|
|
|
|
@ -234,7 +233,7 @@ public class AndroidFeatureDAOImpl implements MobileFeatureDAO {
|
|
|
|
|
List<MobileFeature> features = new ArrayList<MobileFeature>();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
conn = this.getConnection();
|
|
|
|
|
conn = MobileDeviceManagementDAOFactory.getConnection();
|
|
|
|
|
String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM AD_FEATURE";
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
@ -259,15 +258,4 @@ public class AndroidFeatureDAOImpl implements MobileFeatureDAO {
|
|
|
|
|
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, rs);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Connection getConnection() throws MobileDeviceManagementDAOException {
|
|
|
|
|
try {
|
|
|
|
|
return dataSource.getConnection();
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
String msg = "Error occurred while obtaining a connection from the Android mobile device " +
|
|
|
|
|
"management metadata repository datasource";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new MobileDeviceManagementDAOException(msg, e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|