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; }
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; }
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; }
public Set<Integer> querySpeedIds() { return m_config.getSpeeds().keySet(); }
public boolean updateConfig(Speed speed) { m_config.addSpeed(speed); return storeConfig(); }
public boolean deleteSpeed(int id) { m_config.removeSpeed(id); return storeConfig(); }