Remove commented code

merge-requests/74/head
lasanthaDLPDS 6 years ago
parent 2f0f47fe92
commit 017aa7af11

@ -908,63 +908,37 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
} }
@Override @Override
public List<Integer> getTagIdsForTagNames(List<String> tagNames, int tenantId) throws ApplicationManagementDAOException { public List<Integer> getTagIdsForTagNames(List<String> tagNames, int tenantId)
throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to get tag ids for given tag names"); log.debug("Request received in DAO Layer to get tag ids for given tag names");
} }
// Connection conn;
// PreparedStatement stmt = null;
// ResultSet rs = null;
try { try {
Connection conn = this.getDBConnection(); Connection conn = this.getDBConnection();
int index = 1; int index = 1;
List<Integer> tagIds = new ArrayList<>(); List<Integer> tagIds = new ArrayList<>();
// String sql = "SELECT " StringJoiner joiner = new StringJoiner(",",
// + "AP_APP_TAG.ID AS ID " "SELECT AP_APP_TAG.ID AS ID FROM AP_APP_TAG WHERE AP_APP_TAG.TAG IN (", ") AND TENANT_ID = ?");
// + "FROM AP_APP_TAG "
// + "WHERE AP_APP_TAG..NAME IN ( ? ) AND TENANT_ID = ?";
// conn = this.getDBConnection();
//
StringJoiner joiner = new StringJoiner(",", "SELECT AP_APP_TAG.ID AS ID FROM AP_APP_TAG "
+ "WHERE AP_APP_TAG.TAG IN (", ") AND TENANT_ID = ?");
tagNames.stream().map(ignored -> "?").forEach(joiner::add); tagNames.stream().map(ignored -> "?").forEach(joiner::add);
String query = joiner.toString(); String query = joiner.toString();
try (PreparedStatement ps = conn.prepareStatement(query)) { try (PreparedStatement ps = conn.prepareStatement(query)) {
// for (int c = 0; c < tagNames.size(); c++) {
// ps.setObject(c + 1, tagNames.get(c));
// }
for (String tagName : tagNames) { for (String tagName : tagNames) {
ps.setObject(index++, tagName); ps.setObject(index++, tagName);
} }
ps.setInt(index, tenantId); ps.setInt(index, tenantId);
try (ResultSet rs = ps.executeQuery()) { try (ResultSet rs = ps.executeQuery()) {
while(rs.next()){ while (rs.next()) {
tagIds.add(rs.getInt("ID")); tagIds.add(rs.getInt("ID"));
} }
} }
} }
//
// Array array = conn.createArrayOf("VARCHAR", new List[] { tagNames });
//
// stmt = conn.prepareStatement(sql);
// stmt.setArray(1, array);
// stmt.setInt(2, tenantId);
// rs = stmt.executeQuery();
// while(rs.next()){
// tagIds.add(rs.getInt("ID"));
// }
return tagIds; return tagIds;
} } catch (DBConnectionException e) {
catch (DBConnectionException e) {
throw new ApplicationManagementDAOException( throw new ApplicationManagementDAOException(
"Error occurred while obtaining the DB connection when adding tags", e); "Error occurred while obtaining the DB connection when adding tags", e);
} catch (SQLException e) { } catch (SQLException e) {
throw new ApplicationManagementDAOException("Error occurred while adding tags", e); throw new ApplicationManagementDAOException("Error occurred while adding tags", e);
} }
// finally {
// Util.cleanupResources(stmt, rs);
// }
} }
public void addTagMapping (List<Integer> tagIds, int applicationId, int tenantId) throws ApplicationManagementDAOException { public void addTagMapping (List<Integer> tagIds, int applicationId, int tenantId) throws ApplicationManagementDAOException {

Loading…
Cancel
Save