public SearchResult<CommunityPositionInfo> searchCommunityPositionInfo( int pnCommunityPositionID, String paCommunityPositionDesc, String paSortOrder, int pnPageNumber, byte pnRowPerPage) throws Exception { SearchResult<CommunityPositionInfo> voCommunityPositionList = null; CommunityPositionInfoDAO voCommunityPositionInfoDAO = new CommunityPositionInfoDAO(); try { voCommunityPositionList = voCommunityPositionInfoDAO.searchCommunityPositionInfo( em, pnCommunityPositionID, paCommunityPositionDesc, paSortOrder, pnPageNumber, pnRowPerPage); } catch (Exception e) { throw new Exception( new StringBuffer("CommunityPositionInfoDAO.searchCommunityPositionInfo : ") .append(e.getMessage()) .toString()); } return voCommunityPositionList; }
public void insertCommunityPositionInfo(CommunityPositionInfo poCmtPstInf) throws ApplicationException, Exception { CommunityPositionInfoDAO voCommunityPositionInfoDAO = new CommunityPositionInfoDAO(); try { context.getUserTransaction().begin(); if (voCommunityPositionInfoDAO.validateCommunityPositionForInsert( em, poCmtPstInf.getCommunityPositionDesc()) == false) { voCommunityPositionInfoDAO.insertCommunityPositionInfo(em, poCmtPstInf); } else { String vaTmp = (String) em.createQuery( "select (o.communityPositionID) from CommunityPositionInfo o where FUNC('REPLACE', UPPER(o.communityPositionDesc), ' ', '') = FUNC('REPLACE', UPPER('" + poCmtPstInf.getCommunityPositionDesc() + "'), ' ', '')") .getSingleResult() .toString(); throw new ApplicationException( "มีรหัสตำแหน่ง <b>" + vaTmp + " - " + poCmtPstInf.getCommunityPositionDesc() + "</b> อยู่แล้ว"); } context.getUserTransaction().commit(); } catch (ApplicationException ae) { try { context.getUserTransaction().rollback(); } catch (Exception ee) { System.out.println(); } throw new ApplicationException(ae.getMessage()); } catch (Exception e) { try { context.getUserTransaction().rollback(); } catch (Exception ee) { System.out.println(); } throw new Exception( new StringBuffer("CommunityPositionInfoEJBServBean.insertCommunityPositionInfo : ") .append(e.getMessage()) .toString()); } }
public List<CommunityPositionInfo> getListOfCommunityPositionInfo( int pnCommunityPositionID, String paCommunityPositionDesc) throws Exception { List<CommunityPositionInfo> voCommunityPositionInfoList = null; CommunityPositionInfoDAO voCommunityPositionInfoDAO = new CommunityPositionInfoDAO(); try { voCommunityPositionInfoList = voCommunityPositionInfoDAO.getListOfCommunityPositionInfo( em, pnCommunityPositionID, paCommunityPositionDesc); } catch (Exception e) { throw new Exception( new StringBuffer("CommunityPositionInfoEJBServBean.getListOfCommunityPositionInfo : ") .append(e.getMessage()) .toString()); } return voCommunityPositionInfoList; }
public void deleteCommunityPositionInfo(CommunityPositionInfo poCmtPstInf) throws Exception { CommunityPositionInfoDAO voCommunityPositionInfoDAO = new CommunityPositionInfoDAO(); try { context.getUserTransaction().begin(); voCommunityPositionInfoDAO.deleteCommunityPositionInfo(em, poCmtPstInf); context.getUserTransaction().commit(); } catch (Exception e) { try { context.getUserTransaction().rollback(); } catch (Exception ee) { System.out.println(); } throw new Exception( new StringBuffer("CommunityPositionInfoEJBServBean.deleteCommunityPositionInfo : ") .append(e.getMessage()) .toString()); } }