@SuppressWarnings("unchecked") @Override public void afterPropertiesSet() throws Exception { List<TravelPlan> categories = m_travelPlanDao.findAllTravelPlan(); for (TravelPlan travelPlan : categories) { m_travelPlans.put(travelPlan.getId(), travelPlan); } }
@Override public List<TravelPlan> queryAllTravelPlans(int traveId) { ArrayList<TravelPlan> arrayList = new ArrayList<TravelPlan>(m_travelPlans.values()); List<TravelPlan> result = new ArrayList<TravelPlan>(); for (TravelPlan temp : arrayList) { if (temp.getTravelId() == traveId || traveId == 0) { result.add(temp); } } Collections.sort(result, new TravelPlanAscCompartor()); return result; }
@Override public int updateTravelPlan(TravelPlan travelPlan) { int id = m_travelPlanDao.update(travelPlan); if (id > 0) { m_travelPlans.put(travelPlan.getId(), travelPlan); } return id; }
@Override public int insertTravelPlan(TravelPlan travelPlan) { int id = m_travelPlanDao.insert(travelPlan); if (id > 0) { m_travelPlans.put(travelPlan.getId(), travelPlan); } return id; }
@Override public int compare(TravelPlan o1, TravelPlan o2) { return o2.getId() - o1.getId(); }