private Map listToMap(List /* ReportResult */ _src) { Map ret = new HashMap(); for (Iterator iter = _src.iterator(); iter.hasNext(); ) { ReportResult res = (ReportResult) iter.next(); ret.put(res.getName(), res.getProperty("value")); } return ret; }
public static List convertList(List _src) throws PureException { Map datas = new LinkedHashMap(); for (Iterator iter = _src.iterator(); iter.hasNext(); ) { ReportResult result = (ReportResult) iter.next(); String sName = result.getName(); if (sName == null) { sName = ReportHelper.ERROR_TYPE_NAME; } else { sName = InstituteHelper.getNameById(Integer.parseInt(sName)); } result.setName(sName); result.update(); ReportResult old = (ReportResult) datas.get(sName); if (old == null) { datas.put(sName, result); } else { old.setValue(old.getValue() + result.getValue()); old.update(); } } return Arrays.asList(datas.values().toArray()); }