Example #1
0
  private void updateData() {
    Map<Integer, Speed> speeds = m_config.getSpeeds();
    Map<String, Speed> tmp = new ConcurrentHashMap<String, Speed>();

    for (Entry<Integer, Speed> entry : speeds.entrySet()) {
      Speed s = entry.getValue();

      tmp.put(s.getPage() + "-" + s.getStep(), s);
    }
    m_speeds = tmp;
  }
Example #2
0
  private boolean storeConfig() {
    try {
      Config config = m_configDao.createLocal();

      config.setId(m_configId);
      config.setKeyId(m_configId);
      config.setName(CONFIG_NAME);
      config.setContent(m_config.toString());
      m_configDao.updateByPK(config, ConfigEntity.UPDATESET_FULL);

      updateData();
    } catch (Exception e) {
      Cat.logError(e);
      return false;
    }
    return true;
  }
Example #3
0
  public int generateId() {
    List<Integer> ids = new ArrayList<Integer>();

    for (Speed s : m_config.getSpeeds().values()) {
      ids.add(s.getId());
    }
    int max = 0;

    if (!ids.isEmpty()) {
      Collections.sort(ids);
      max = ids.get(ids.size() - 1);
    }

    if (ids.size() < max) {
      for (int i = 1; i <= max; i++) {
        if (!ids.contains(i)) {
          return i;
        }
      }
    }
    return max + 1;
  }
Example #4
0
 public Set<Integer> querySpeedIds() {
   return m_config.getSpeeds().keySet();
 }
Example #5
0
 public boolean updateConfig(Speed speed) {
   m_config.addSpeed(speed);
   return storeConfig();
 }
Example #6
0
 public boolean deleteSpeed(int id) {
   m_config.removeSpeed(id);
   return storeConfig();
 }