/** * bar info query * * @param global * @return * @throws JSONException */ public String queryBarInfo(String global) throws JSONException { DetachedCriteria dc = DetachedCriteria.forClass(TNavigation.class); dc.add(Restrictions.eq("status", 1)); dc.addOrder(Order.asc("ordinal")).addOrder(Order.desc("updatetime")); List<TNavigation> list = super.findByDetachedCriteria(dc); List<TBar> rootList = new ArrayList<TBar>(); for (TNavigation navtion : list) { if ("0".equals(navtion.getObjid())) { TBar bar = new TBar(); bar.setName(ActionUtils.getLanStr(navtion.getName(), navtion.getEname(), global)); bar.setId(navtion.getOid()); bar.setObjid(navtion.getObjid()); rootList.add(bar); } } TNavigation record = new TNavigation(); record.getBarList().add(rootList); record = this.convertBar(record, rootList, list, global); // JSONArray itms = (JSONArray) JSONSerializer.toJSON(record.getBarList()); // return itms.toString(); return JSONUtil.serialize(record.getBarList(), null, null, false, false, true); }
private TNavigation convertBar( TNavigation record, List<TBar> rootList, List<TNavigation> list, String global) { List<TBar> tList = new ArrayList<TBar>(); for (TBar root : rootList) { for (TNavigation navtion : list) { if (navtion.getObjid().equals(root.getId())) { TBar bar = new TBar(); bar.setName(ActionUtils.getLanStr(navtion.getName(), navtion.getEname(), global)); bar.setId(navtion.getOid()); bar.setObjid(navtion.getObjid()); tList.add(bar); } } } if (tList.size() > 0) { record.getBarList().add(tList); this.convertBar(record, tList, list, global); } return record; }