@Override public boolean saveOrUpdate(ModelAnnounce model) throws ServiceException { if (model != null) { try { announceDAO.saveOrUpdate(model); return true; } catch (DAOException e) { logger.error( "SaveOrUpdate annnounce failed with model" + model.toString() + ",caused by:" + e.getMessage()); e.printStackTrace(); } catch (Exception e) { logger.error( "SaveOrUpdate annnounce failed with model" + model.toString() + ",caused by:" + e.getMessage()); throw (new ServiceException(e)); } } logger.info("SaveOrUpdate announce failed, empty model found"); return false; }
@Override public PaginationSupport<ModelAnnounce> get( ModelAnnounce model, int pageSize, int offset, String order, Boolean isDesc) throws ServiceException { try { return announceDAO.get(model, pageSize, offset, order, isDesc); } catch (DAOException e) { logger.error("get annnounces by pager failed ,caused by:" + e.getMessage()); e.printStackTrace(); } catch (Exception e) { logger.error("get annnounces by pager failed ,caused by:" + e.getMessage()); throw (new ServiceException(e)); } return null; }
@Override public ModelAnnounce get(String id) throws ServiceException { if (UtilsString.isNotEmpty(id)) { try { return announceDAO.get(id); } catch (DAOException e) { logger.error("get annnounce by id" + id + ",caused by:" + e.getMessage()); e.printStackTrace(); } catch (Exception e) { logger.error("get annnounce by id" + id + ",caused by:" + e.getMessage()); throw (new ServiceException(e)); } } return null; }
@Override public boolean remove(String id) throws ServiceException { if (UtilsString.isNotEmpty(id)) { ModelAnnounce model = get(id); if (model != null) { try { announceDAO.remove(model); return true; } catch (DAOException e) { logger.error("Remove annnounce failed with id" + id + ",caused by:" + e.getMessage()); e.printStackTrace(); } catch (Exception e) { logger.error("Remove annnounce failed with id" + id + ",caused by:" + e.getMessage()); throw (new ServiceException(e)); } } else { logger.info("Remove announce failed, id with " + id + "not found"); } } logger.info("Remove announce failed, empty id found"); return false; }