adds support for fields as well as local variables.
[cfb.git] / prod / net / jaekl / cfb / store / DbStore.java
index b17a419626a69e4afbb692aaf01157df9fe3c3da..dd8f77733ac2fde4e921d12028021f59e66771b4 100644 (file)
@@ -17,6 +17,7 @@ import net.jaekl.cfb.db.driver.DbDriver;
 import net.jaekl.cfb.xml.BugCollection;
 import net.jaekl.cfb.xml.BugInstance;
 import net.jaekl.cfb.xml.LocalVariable;
+import net.jaekl.cfb.xml.Variable;
 import net.jaekl.cfb.xml.messages.BugCategory;
 import net.jaekl.cfb.xml.messages.BugPattern;
 import net.jaekl.cfb.xml.messages.MessageCollection;
@@ -49,6 +50,8 @@ public class DbStore {
                        return false;
                }
                
+               assert (null != analysis.getProjectName());
+               
                // ----------------------------------
                // Add a run record for this analysis
                
@@ -215,7 +218,7 @@ public class DbStore {
                        return null;
                }
                
-               List<LocalVariable> vars = bug.getVariables();
+               List<Variable> vars = bug.getVariables();
                if ((null == vars) || (0 == vars.size())) {
                        return null;
                }
@@ -223,7 +226,7 @@ public class DbStore {
                return getVarId(vars.get(0));
        }
        
-       LocalVariable getVar(Long varId) throws SQLException, TypeMismatchException
+       LocalVariable getVar(Long varId) throws SQLException, TypeMismatchException, StoreException
        {
                if (null == varId) {
                        return null;
@@ -235,7 +238,7 @@ public class DbStore {
                
                List<Row> result = m_driver.select(m_con, columns, tables, conditions);
                if (result.size() < 1) {
-                       throw new SQLException("No variable found for ID " + varId);
+                       throw new StoreException(StoreException.Type.INVALID_VAR_ID, ""+varId);
                }
                if (result.size() > 1) {
                        throw new SQLException("Too many matches (" + result.size() + ") found for variable ID " + varId);
@@ -247,7 +250,7 @@ public class DbStore {
                return new LocalVariable(varId, varName, varRole);
        }
        
-       Long getVarId(LocalVariable var) throws SQLException, TypeMismatchException
+       Long getVarId(Variable var) throws SQLException, TypeMismatchException
        {
                if (null == var) {
                        return null;
@@ -262,7 +265,7 @@ public class DbStore {
                return storeVar(var);
        }
        
-       Long findVarId(LocalVariable var) throws SQLException, TypeMismatchException
+       Long findVarId(Variable var) throws SQLException, TypeMismatchException
        {
                Column[] columns = { CfbSchema.VARID_PK };
                Table[] tables = { CfbSchema.VARIABLES };
@@ -281,7 +284,7 @@ public class DbStore {
                return null;    // not found
        }
        
-       Long storeVar(LocalVariable var) throws SQLException
+       Long storeVar(Variable var) throws SQLException
        {
                long varId = m_driver.nextVal(m_con, CfbSchema.VARIABLE_SEQ);