@Override public MobileFeature getFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException { PreparedStatement stmt = null; ResultSet rs = null; Connection conn = null; try { conn = AndroidDAOFactory.getConnection(); String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM AD_FEATURE WHERE ID = ?"; stmt = conn.prepareStatement(sql); stmt.setInt(1, mblFeatureId); rs = stmt.executeQuery(); MobileFeature mobileFeature = null; if (rs.next()) { mobileFeature = new MobileFeature(); mobileFeature.setId(rs.getInt(AndroidPluginConstants.ANDROID_FEATURE_ID)); mobileFeature.setCode(rs.getString(AndroidPluginConstants.ANDROID_FEATURE_CODE)); mobileFeature.setName(rs.getString(AndroidPluginConstants.ANDROID_FEATURE_NAME)); mobileFeature.setDescription( rs.getString(AndroidPluginConstants.ANDROID_FEATURE_DESCRIPTION)); mobileFeature.setDeviceType( DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); } return mobileFeature; } catch (SQLException e) { throw new AndroidFeatureManagementDAOException( "Error occurred while retrieving android feature '" + mblFeatureId + "' from the Android database.", e); } finally { MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs); AndroidDAOFactory.closeConnection(); } }
public static MobileFeature convertToMobileFeature(Feature feature) { MobileFeature mobileFeature = new MobileFeature(); mobileFeature.setName(feature.getName()); mobileFeature.setCode(feature.getCode()); mobileFeature.setDescription(feature.getDescription()); mobileFeature.setDeviceType(feature.getDeviceType()); return mobileFeature; }