(Finally) reach the point where we have some useful, if basic, functionality.
[cfb.git] / prod / net / jaekl / cfb / store / DbStore.java
index 69ea8bbafaeb405ce06ce3387e2f9caa3f490678..6c2097925f3d78a3c14fb91e6325643d66578be1 100644 (file)
@@ -119,6 +119,10 @@ public class DbStore {
        
        Location getLoc(Long locId) throws SQLException, TypeMismatchException
        {
+               if (null == locId) {
+                       return null;
+               }
+               
                Column[] columns = { CfbSchema.CLASSNAME, CfbSchema.METHODNAME, CfbSchema.METHODROLE, CfbSchema.STARTLINE, CfbSchema.ENDLINE };
                Table[] tables = { CfbSchema.LOCATIONS };
                Condition[] conditions = { new Condition(CfbSchema.LOCID, locId, Operation.EQUAL) };
@@ -128,8 +132,8 @@ public class DbStore {
                String className = row.getString(0);
                String methodName = row.getString(1);
                String methodRole = row.getString(2);
-               long startLine = row.getLong(3);
-               long endLine = row.getLong(4);
+               Integer startLine = row.getInt(3);
+               Integer endLine = row.getInt(4);
                
                Location loc = new Location(locId, className, methodName, methodRole, startLine, endLine);
                return loc;
@@ -206,6 +210,10 @@ public class DbStore {
        
        LocalVariable getVar(Long varId) throws SQLException, TypeMismatchException
        {
+               if (null == varId) {
+                       return null;
+               }
+               
                Column[] columns = { CfbSchema.NAME, CfbSchema.VARROLE };
                Table[] tables = { CfbSchema.VARIABLES };
                Condition[] conditions = { new Condition(CfbSchema.VARID_PK, varId, Operation.EQUAL) };
@@ -290,11 +298,11 @@ public class DbStore {
                return rows.get(0).getLong(0);
        }
        
-       Analysis getAnalysis(Long priorId) throws SQLException, TypeMismatchException
+       Analysis getAnalysis(Long analysisId) throws SQLException, TypeMismatchException
        {
                Column[] columns = { CfbSchema.VERSION, CfbSchema.STARTTIME, CfbSchema.ENDTIME };
                Table[] tables = { CfbSchema.RUNS };
-               Condition[] conditions = { new Condition( CfbSchema.RUNID, priorId, Operation.EQUAL ) };
+               Condition[] conditions = { new Condition( CfbSchema.RUNID, analysisId, Operation.EQUAL ) };
                
                List<Row> rows = m_driver.select(m_con, columns, tables, conditions);
                if (rows.size() < 1) {
@@ -308,11 +316,11 @@ public class DbStore {
                java.util.Date end = row.getDate(2);
                
                Analysis prior = new Analysis(version);
-               prior.setId(priorId.longValue());
+               prior.setId(analysisId.longValue());
                prior.setStart(start);
                prior.setEnd(end);
                
-               prior.setBugCollection(getBugCollection(priorId));
+               prior.setBugCollection(getBugCollection(analysisId));
                
                return prior;
        }
@@ -341,21 +349,21 @@ public class DbStore {
                
                for (Row row : rows) {
                        // long foundId = row.getLong(0);
-                       long bugId = row.getLong(1);
-                       long categoryId = row.getLong(2);
-                       long firstLocId = row.getLong(3);
-                       long secondLocId = row.getLong(4);
-                       long thirdLocId = row.getLong(5);
-                       long varId = row.getLong(6);
+                       Long bugId = row.getLong(1);
+                       Long categoryId = row.getLong(2);
+                       Long firstLocId = row.getLong(3);
+                       Long secondLocId = row.getLong(4);
+                       Long thirdLocId = row.getLong(5);
+                       Long varId = row.getLong(6);
                        
                        String bugType = getBugType(bugId);
                        String category = getCategoryName(categoryId);
                        Location[] locations = { getLoc(firstLocId), getLoc(secondLocId), getLoc(thirdLocId) };
-                       LocalVariable[] vars = { getVar(Long.valueOf(varId)) };
+                       LocalVariable[] vars = { getVar(varId) };
 
                        
                        BugInstance bug = new BugInstance(bugId, category, bugType, locations, vars);
-                       coll.getBugs().add(bug);
+                       coll.add(bug);
                }
                
                return coll;