|
|
@ -20,10 +20,12 @@ package org.wso2.carbon.device.mgt.mobile.impl.android.dao.impl;
|
|
|
|
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.Feature;
|
|
|
|
import org.wso2.carbon.device.mgt.common.Feature;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
|
|
|
|
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.dao.util.MobileDeviceManagementDAOUtil;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.impl.android.dao.FeatureDAO;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.dto.MobileFeature;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.impl.android.dao.FeatureManagementDAOException;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.impl.android.dao.FeatureManagementDAOException;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.impl.android.dao.FeatureManagementDAOFactory;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil;
|
|
|
|
|
|
|
|
|
|
|
|
import java.sql.Connection;
|
|
|
|
import java.sql.Connection;
|
|
|
|
import java.sql.PreparedStatement;
|
|
|
|
import java.sql.PreparedStatement;
|
|
|
@ -32,53 +34,77 @@ import java.sql.SQLException;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
public class FeatureDAOImpl implements FeatureDAO {
|
|
|
|
public class FeatureDAOImpl implements MobileFeatureDAO {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void addFeature(Feature feature) throws FeatureManagementDAOException {
|
|
|
|
public boolean addFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException {
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
|
|
|
|
boolean status = false;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Connection conn = FeatureManagementDAOFactory.getConnection();
|
|
|
|
Connection conn = MobileDeviceManagementDAOFactory.getConnection();
|
|
|
|
String sql = "INSERT INTO AD_FEATURE(CODE, NAME, DESCRIPTION) VALUES (?, ?, ?)";
|
|
|
|
String sql = "INSERT INTO AD_FEATURE(CODE, NAME, DESCRIPTION) VALUES (?, ?, ?)";
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt.setString(1, feature.getCode());
|
|
|
|
stmt.setString(1, mobileFeature.getCode());
|
|
|
|
stmt.setString(2, feature.getName());
|
|
|
|
stmt.setString(2, mobileFeature.getName());
|
|
|
|
stmt.setString(3, feature.getDescription());
|
|
|
|
stmt.setString(3, mobileFeature.getDescription());
|
|
|
|
stmt.executeUpdate();
|
|
|
|
stmt.executeUpdate();
|
|
|
|
|
|
|
|
status = true;
|
|
|
|
|
|
|
|
status = true;
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new FeatureManagementDAOException("Error occurred while adding feature '" +
|
|
|
|
throw new org.wso2.carbon.device.mgt.mobile.impl.ios.dao.FeatureManagementDAOException(
|
|
|
|
feature.getName() + "' into the metadata repository", e);
|
|
|
|
"Error occurred while adding feature '" +
|
|
|
|
|
|
|
|
mobileFeature.getName() + "' into the metadata repository", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
MobileDeviceManagementDAOUtil.cleanupResources(stmt, null);
|
|
|
|
MobileDeviceManagementDAOUtil.cleanupResources(stmt, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void removeFeature(String code) throws FeatureManagementDAOException {
|
|
|
|
public boolean updateFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public boolean deleteFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public boolean deleteFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException {
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
|
|
|
|
boolean status = false;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Connection conn = FeatureManagementDAOFactory.getConnection();
|
|
|
|
Connection conn = MobileDeviceManagementDAOFactory.getConnection();
|
|
|
|
String sql = "DELETE FROM AD_FEATURE WHERE CODE = ?";
|
|
|
|
String sql = "DELETE FROM AD_FEATURE WHERE CODE = ?";
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt.setString(1, code);
|
|
|
|
stmt.setString(1, mblFeatureCode);
|
|
|
|
stmt.execute();
|
|
|
|
stmt.execute();
|
|
|
|
|
|
|
|
status = true;
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new FeatureManagementDAOException("Error occurred while adding feature '" +
|
|
|
|
throw new org.wso2.carbon.device.mgt.mobile.impl.ios.dao.FeatureManagementDAOException(
|
|
|
|
code + "' into the metadata repository", e);
|
|
|
|
"Error occurred while adding feature '" +
|
|
|
|
|
|
|
|
mblFeatureCode + "' into the metadata repository", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
MobileDeviceManagementDAOUtil.cleanupResources(stmt, null);
|
|
|
|
MobileDeviceManagementDAOUtil.cleanupResources(stmt, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return status;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public MobileFeature getFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException {
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Feature getFeature(String code) throws FeatureManagementDAOException {
|
|
|
|
public MobileFeature getFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException {
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
ResultSet rs = null;
|
|
|
|
ResultSet rs = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Connection conn = FeatureManagementDAOFactory.getConnection();
|
|
|
|
Connection conn = MobileDeviceManagementDAOFactory.getConnection();
|
|
|
|
String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM AD_FEATURE WHERE CODE = ?";
|
|
|
|
String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM AD_FEATURE WHERE CODE = ?";
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt.setString(1, code);
|
|
|
|
stmt.setString(1, mblFeatureCode);
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
|
|
|
|
|
|
|
|
Feature feature = null;
|
|
|
|
Feature feature = null;
|
|
|
@ -89,25 +115,35 @@ public class FeatureDAOImpl implements FeatureDAO {
|
|
|
|
feature.setName(rs.getString("NAME"));
|
|
|
|
feature.setName(rs.getString("NAME"));
|
|
|
|
feature.setDescription(rs.getString("DESCRIPTION"));
|
|
|
|
feature.setDescription(rs.getString("DESCRIPTION"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return feature;
|
|
|
|
MobileFeature mobileFeature = MobileDeviceManagementUtil.convertToMobileFeature(feature);
|
|
|
|
|
|
|
|
return mobileFeature;
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new FeatureManagementDAOException("Error occurred while retrieving feature metadata '" +
|
|
|
|
throw new org.wso2.carbon.device.mgt.mobile.impl.ios.dao.FeatureManagementDAOException(
|
|
|
|
code + "' from the feature metadata repository", e);
|
|
|
|
"Error occurred while retrieving feature metadata '" +
|
|
|
|
|
|
|
|
mblFeatureCode + "' from the feature metadata repository", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
|
|
|
MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<Feature> getFeatures() throws FeatureManagementDAOException {
|
|
|
|
public List<MobileFeature> getFeatureByDeviceType(String deviceType)
|
|
|
|
|
|
|
|
throws MobileDeviceManagementDAOException {
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public List<MobileFeature> getAllFeatures() throws MobileDeviceManagementDAOException {
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
ResultSet rs = null;
|
|
|
|
ResultSet rs = null;
|
|
|
|
List<Feature> features = new ArrayList<Feature>();
|
|
|
|
List<MobileFeature> features = new ArrayList<MobileFeature>();
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Connection conn = FeatureManagementDAOFactory.getConnection();
|
|
|
|
Connection conn = MobileDeviceManagementDAOFactory.getConnection();
|
|
|
|
String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM AD_FEATURE";
|
|
|
|
String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM AD_FEATURE";
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
|
|
|
|
MobileFeature mobileFeature;
|
|
|
|
|
|
|
|
|
|
|
|
while (rs.next()) {
|
|
|
|
while (rs.next()) {
|
|
|
|
Feature feature = new Feature();
|
|
|
|
Feature feature = new Feature();
|
|
|
@ -115,6 +151,8 @@ public class FeatureDAOImpl implements FeatureDAO {
|
|
|
|
feature.setCode(rs.getString("CODE"));
|
|
|
|
feature.setCode(rs.getString("CODE"));
|
|
|
|
feature.setName(rs.getString("NAME"));
|
|
|
|
feature.setName(rs.getString("NAME"));
|
|
|
|
feature.setDescription(rs.getString("DESCRIPTION"));
|
|
|
|
feature.setDescription(rs.getString("DESCRIPTION"));
|
|
|
|
|
|
|
|
mobileFeature = MobileDeviceManagementUtil.convertToMobileFeature(feature);
|
|
|
|
|
|
|
|
features.add(mobileFeature);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return features;
|
|
|
|
return features;
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
@ -124,5 +162,4 @@ public class FeatureDAOImpl implements FeatureDAO {
|
|
|
|
MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
|
|
|
MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|