@Override public boolean updateFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException { boolean status = false; Connection conn = null; PreparedStatement stmt = null; try { conn = AndroidDAOFactory.getConnection(); String updateDBQuery = "UPDATE AD_FEATURE SET NAME = ?, DESCRIPTION = ?" + "WHERE CODE = ?"; stmt = conn.prepareStatement(updateDBQuery); stmt.setString(1, mobileFeature.getName()); stmt.setString(2, mobileFeature.getDescription()); stmt.setString(3, mobileFeature.getCode()); int rows = stmt.executeUpdate(); if (rows > 0) { status = true; if (log.isDebugEnabled()) { log.debug("Android Feature " + mobileFeature.getCode() + " data has been " + "modified."); } } } catch (SQLException e) { String msg = "Error occurred while updating the Android Feature '" + mobileFeature.getCode() + "' to the Android db."; log.error(msg, e); throw new AndroidFeatureManagementDAOException(msg, e); } finally { MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); } return status; }
@Override public boolean addFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException { PreparedStatement stmt = null; boolean status = false; Connection conn = null; try { conn = AndroidDAOFactory.getConnection(); String sql = "INSERT INTO AD_FEATURE(CODE, NAME, DESCRIPTION) VALUES (?, ?, ?)"; stmt = conn.prepareStatement(sql); stmt.setString(1, mobileFeature.getCode()); stmt.setString(2, mobileFeature.getName()); stmt.setString(3, mobileFeature.getDescription()); stmt.executeUpdate(); status = true; status = true; } catch (SQLException e) { throw new AndroidFeatureManagementDAOException( "Error occurred while adding android feature '" + mobileFeature.getName() + "' into the metadata repository", e); } finally { MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); } return status; }
public static Feature convertToFeature(MobileFeature mobileFeature) { Feature feature = new Feature(); feature.setDescription(mobileFeature.getDescription()); feature.setDeviceType(mobileFeature.getDeviceType()); feature.setCode(mobileFeature.getCode()); feature.setName(mobileFeature.getName()); return feature; }