/**
  * Returns the jobs count with the specified status code.
  *
  * @param status the status code
  * @return
  */
 public int getJobsCount(StatusCode status) {
   if (jobs == null) {
     return 0;
   }
   int res = 0;
   for (ExperimentResult j : jobs) {
     if (j.getStatus().equals(status)) {
       res++;
     }
   }
   return res;
 }
 @Override
 public Object getValueAt(int rowIndex, int columnIndex) {
   if (rowIndex < 0 || rowIndex >= getRowCount()) {
     return null;
   }
   ExperimentResult j = jobs.get(rowIndex);
   switch (columnIndex) {
     case COL_ID:
       return j.getId();
     case COL_PRIORITY:
       return j.getPriority();
     case COL_COMPUTEQUEUE:
       GridQueue q = gridQueues == null ? null : gridQueues.get(j.getComputeQueue());
       return q == null ? "none" : q.getName();
     case COL_COMPUTENODE:
       return j.getComputeNode() == null ? "none" : j.getComputeNode();
     case COL_COMPUTENODEIP:
       return j.getComputeNodeIP() == null ? "none" : j.getComputeNodeIP();
     case COL_SOLVER:
       Solver solver = getSolver(rowIndex);
       return solver == null ? "" : solver.getName();
     case COL_SOLVERCONFIGURATION:
       try {
         return SolverConfigurationDAO.getSolverConfigurationById(j.getSolverConfigId()).getName();
       } catch (SQLException ex) {
         return "-";
       }
     case COL_PARAMETERS:
       solver = getSolver(rowIndex);
       if (solver == null) return "";
       String params = parameters.get(j.getSolverConfigId());
       if (params == null) {
         params = Util.getSolverParameterString(getParameters(rowIndex), solver);
         parameters.put(j.getSolverConfigId(), params);
       }
       return params;
     case COL_INSTANCE:
       Instance instance = getInstance(rowIndex);
       return instance == null ? "" : instance.getName();
     case COL_INSTANCE_MD5:
       instance = getInstance(rowIndex);
       return instance == null ? "" : instance.getMd5();
     case COL_RUN:
       return j.getRun();
     case COL_TIME:
       return j.getResultTime();
     case COL_WALLTIME:
       return j.getWallTime();
     case COL_COST:
       return j.getCost();
     case COL_SEED:
       return j.getSeed();
     case COL_STATUS:
       return j.getStatus().toString();
     case COL_RUNTIME:
       if (j.getStatus() == StatusCode.RUNNING) {
         int hours = j.getRunningTime() / 3600;
         int minutes = (j.getRunningTime() / 60) % 60;
         int seconds = j.getRunningTime() % 60;
         return new Formatter().format("%02d:%02d:%02d", hours, minutes, seconds);
       }
       return null;
     case COL_RESULTCODE:
       return j.getResultCode().toString();
     case COL_CPUTIMELIMIT:
       return j.getCPUTimeLimit();
     case COL_WALLCLOCKLIMIT:
       return j.getWallClockTimeLimit();
     case COL_MEMORYLIMIT:
       return j.getMemoryLimit();
     case COL_STACKSIZELIMIT:
       return j.getStackSizeLimit();
     case COL_SOLVER_OUTPUT:
       return "view";
     case COL_LAUNCHER_OUTPUT:
       return "view";
     case COL_WATCHER_OUTPUT:
       return "view";
     case COL_VERIFIER_OUTPUT:
       return "view";
     default:
       int propertyIdx = columnIndex - COL_PROPERTY;
       if (properties.size() <= propertyIdx) {
         return null;
       }
       Property prop = properties.get(propertyIdx);
       if (prop.getType().equals(PropertyType.ResultProperty)) {
         ExperimentResultHasProperty erp = j.getPropertyValues().get(prop.getId());
         if (erp != null && !erp.getValue().isEmpty()) {
           try {
             if (prop.getPropertyValueType() == null) {
               return erp.getValue().get(0);
             }
             return prop.getPropertyValueType().getJavaTypeRepresentation(erp.getValue().get(0));
           } catch (ConvertException ex) {
             return null;
           }
         } else {
           return null;
         }
       } else if (prop.getType().equals(PropertyType.InstanceProperty)) {
         InstanceHasProperty ihp = null;
         try {
           ihp = InstanceDAO.getById(j.getInstanceId()).getPropertyValues().get(prop.getId());
         } catch (Exception e) {
         }
         if (ihp == null) {
           return null;
         } else {
           try {
             return prop.getPropertyValueType().getJavaTypeRepresentation(ihp.getValue());
           } catch (ConvertException ex) {
             return null;
           }
         }
       } else {
         return null;
       }
   }
 }