diff options
author | Magnusen, Drew (dm741q) <dm741q@att.com> | 2017-08-09 14:09:59 -0500 |
---|---|---|
committer | Magnusen, Drew (dm741q) <dm741q@att.com> | 2017-08-11 10:30:41 -0500 |
commit | 8e9b3d288bc5b51f691183715d5862489f09d95d (patch) | |
tree | 097f6f624b4bae9b19637c989f3d94d51580c017 /integrity-audit/src/main/java/org/onap/policy/common/ia/DbDAO.java | |
parent | 96bca95f4610edfdabf1fddb981416235158312d (diff) |
Sonar cleanup for integrity-audit
Modified classes in integrity-audit module to resolve major sonar issues.
Issue-ID: [POLICY-96]
Change-Id: I5ef0abb8d2a3ea1ae93edc00363c4d2bea1747e2
Signed-off-by: Magnusen, Drew (dm741q) <dm741q@att.com>
Diffstat (limited to 'integrity-audit/src/main/java/org/onap/policy/common/ia/DbDAO.java')
-rw-r--r-- | integrity-audit/src/main/java/org/onap/policy/common/ia/DbDAO.java | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDAO.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDAO.java index 0db43bbc..20132ae1 100644 --- a/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDAO.java +++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDAO.java @@ -40,7 +40,6 @@ import javax.persistence.criteria.Root; import javax.persistence.metamodel.ManagedType; import javax.persistence.metamodel.Metamodel; -//import org.apache.log4j.Logger; import org.onap.policy.common.ia.jpa.IntegrityAuditEntity; import org.onap.policy.common.logging.flexlogger.FlexLogger; @@ -125,7 +124,7 @@ public class DbDAO { public HashMap<Object, Object> getAllMyEntries(String className) { logger.debug("getAllMyEntries: Entering, className=" + className); - HashMap<Object, Object> resultMap = new HashMap<Object,Object>(); + HashMap<Object, Object> resultMap = new HashMap<>(); EntityManager em = emf.createEntityManager(); try{ CriteriaBuilder cb = em.getCriteriaBuilder(); @@ -162,7 +161,7 @@ public class DbDAO { logger.debug("getAllMyEntries: Entering, className=" + className + ",\n keySet=" + keySet); - HashMap<Object, Object> resultMap = new HashMap<Object,Object>(); + HashMap<Object, Object> resultMap = new HashMap<>(); EntityManager em = emf.createEntityManager(); try{ Class<?> clazz = Class.forName(className); @@ -193,7 +192,7 @@ public class DbDAO { logger.debug("getAllEntries: Entering, persistenceUnit=" + persistenceUnit + ",\n className=" + className); - HashMap<Object, Object> resultMap = new HashMap<Object,Object>(); + HashMap<Object, Object> resultMap = new HashMap<>(); EntityManagerFactory theEmf = Persistence.createEntityManagerFactory(persistenceUnit, properties); EntityManager em = theEmf.createEntityManager(); @@ -238,7 +237,7 @@ public class DbDAO { + persistenceUnit + ",\n properties= " + properties + ",\n className=" + className + ",\n keySet= " + keySet); EntityManagerFactory theEmf = Persistence.createEntityManagerFactory(persistenceUnit, properties); EntityManager em = theEmf.createEntityManager(); - HashMap<Object, Object> resultMap = new HashMap<Object,Object>(); + HashMap<Object, Object> resultMap = new HashMap<>(); try{ Class<?> clazz = Class.forName(className); for(Object key : keySet){ @@ -386,7 +385,7 @@ public class DbDAO { */ public HashSet<String> getPersistenceClassNames(){ logger.debug("DbDAO: getPersistenceClassNames() entry"); - HashSet<String> returnList = new HashSet<String>(); + HashSet<String> returnList = new HashSet<>(); final Metamodel mm = emf.getMetamodel(); logger.debug("\n" + persistenceUnit +" persistence unit classes:"); for (final ManagedType<?> managedType : mm.getManagedTypes()) { @@ -417,7 +416,7 @@ public class DbDAO { @SuppressWarnings("rawtypes") List iaeList = iaequery.getResultList(); - IntegrityAuditEntity iae = null; + IntegrityAuditEntity iae; //If it already exists, we just want to update the properties and lastUpdated date if(!iaeList.isEmpty()){ @@ -453,7 +452,7 @@ public class DbDAO { et.commit(); em.close(); }catch (Exception e){ - String msg = "DbDAO: " + "register() " + "ecountered a problem in execution: "; + String msg = "DbDAO: " + "register() " + "encountered a problem in execution: "; logger.error(msg + e); System.out.println(new Date()); e.printStackTrace(); @@ -486,7 +485,7 @@ public class DbDAO { @SuppressWarnings("rawtypes") List iaeList = iaequery.getResultList(); - IntegrityAuditEntity iae = null; + IntegrityAuditEntity iae; if(!iaeList.isEmpty()){ //ignores multiple results @@ -539,7 +538,7 @@ public class DbDAO { @SuppressWarnings("rawtypes") List iaeList = iaequery.getResultList(); - IntegrityAuditEntity iae = null; + IntegrityAuditEntity iae; if(!iaeList.isEmpty()){ //ignores multiple results @@ -582,7 +581,7 @@ public class DbDAO { try{ - if (!IntegrityAudit.isUnitTesting) { + if (!IntegrityAudit.isUnitTesting()) { String msg = "DbDAO: " + "deleteAllIntegrityAuditEntities() " + "should only be invoked during JUnit testing"; logger.error(msg); throw new DbDaoTransactionException(msg); |