Declare SuppressFBWarnings in imports
[transportpce.git] / inventory / src / main / java / org / opendaylight / transportpce / inventory / INode.java
index f31f89da7785887f63565d8437d354a527df43dd..e1fd3cfe921fa07acc41c53c22084d85c9aa985a 100644 (file)
@@ -8,34 +8,35 @@
 
 package org.opendaylight.transportpce.inventory;
 
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import javax.sql.DataSource;
-
-import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@SuppressFBWarnings(
+    value = "SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING",
+    justification = "TODO review the SQL statement generation process")
 public class INode {
     private static final Logger LOG = LoggerFactory.getLogger(INode.class);
 
     private final DataSource dataSource;
-    private final DeviceTransactionManager deviceTransactionManager;
-    private final INode221 inode221;
+    //private final INode221 inode221;
     private final INode121 inode121;
 
-    public INode(DataSource dataSource, DeviceTransactionManager deviceTransactionManager, INode121 inode121,
-        INode221 inode221) {
+    public INode(DataSource dataSource, INode121 inode121
+        //, INode221 inode221
+    ) {
         this.dataSource = dataSource;
-        this.deviceTransactionManager = deviceTransactionManager;
         this.inode121 = inode121;
-        this.inode221 = inode221;
+        //this.inode221 = inode221;
     }
 
     public boolean addNode(String deviceId, String openROADMversion) {
-        boolean sqlResult = false;
+        //boolean sqlResult = false;
         return inode121.addNode(deviceId);
 
     }
@@ -45,7 +46,7 @@ public class INode {
         int nodeExists = 0;
         LOG.info("Checking if {} exists in DB", nodeId);
         try (Connection connection = dataSource.getConnection();
-             PreparedStatement preparedStmt = connection.prepareStatement(selectTableSQL)) {
+                PreparedStatement preparedStmt = connection.prepareStatement(selectTableSQL)) {
             preparedStmt.setString(1, nodeId);
             try (ResultSet rs = preparedStmt.executeQuery()) {
                 while (rs.next()) {
@@ -54,9 +55,9 @@ public class INode {
                 }
             }
         } catch (SQLException e) {
-            LOG.error(e.getMessage(), e);
+            LOG.error("Something wrong when fetching node in DB", e);
         }
-        return nodeExists == 0 ? false : true;
+        return nodeExists != 0;
     }
 
     public boolean dataExists(String tableName, String searchKeys) {
@@ -73,9 +74,9 @@ public class INode {
                 }
             }
         } catch (SQLException e) {
-            LOG.error(e.getMessage(), e);
+            LOG.error("Something wrong when fetching data in DB", e);
         }
-        return dataExists == 0 ? false : true;
+        return dataExists != 0;
     }
 
   /*  public void getRoadmShelves(String nodeId, String openRoadmVersion)