private boolean validateLabelMaster(RELabelSetupMainDetails labelTypeMaster) throws Exception { Connection con = null; MessagesUtil msgUtil = null; String scrIdChek = null; try { con = TagLibConnectionUtil.getConnection(); msgUtil = new MessagesUtil(); if ("ADD".equals(labelTypeMaster.getOperation())) { scrIdChek = "SELECT 'X' FROM SOFTWARE_SERVICES SR WHERE SR.SCREEN_ID = ?"; if (QueryBuilderUtil.isRecordExits(con, scrIdChek, labelTypeMaster.getScrnId())) { msgUtil.put( TagLibConstants.ERROR_LEVEL, "Screen Id already Exists--> " + labelTypeMaster.getScrnId()); } } if (msgUtil.isEmpty()) { return true; } else { labelTypeMaster.setErrMsgs(msgUtil.getErrMsgs()); labelTypeMaster.setSucessMsgs(msgUtil.getSucessMsgs()); return false; } } finally { TagLibConnectionUtil.closeConnection(con); msgUtil = null; scrIdChek = null; } }
public RELabelSetupMainDetails insertLabelMaster(RELabelSetupMainDetails mainDetails) throws Exception { Connection connection = null; PreparedStatement pstmt = null; String insertQuery = ""; long labelSeqId = 0; try { if (validateLabelMaster(mainDetails)) { connection = TagLibConnectionUtil.getConnection(); connection.setAutoCommit(false); labelSeqId = QueryBuilderUtil.generateSeqNo("SOFTWARE_SERVICES_ID_SEQ", connection); insertQuery = "INSERT INTO SOFTWARE_SERVICES(ID,SCREEN_ID,DESCRIPTION,JSP_NAME,VO_CLASS, " + "HANDLER_CLASS,REMARKS,STATUS) VALUES (?,?,?,?,?,?,?,?)"; pstmt = connection.prepareStatement(insertQuery); pstmt.setLong(1, labelSeqId); pstmt.setString(2, mainDetails.getScrnId()); pstmt.setString(3, mainDetails.getDesc()); pstmt.setString(4, mainDetails.getJspName()); pstmt.setString(5, mainDetails.getVoClass()); pstmt.setString(6, mainDetails.getHandlerClass()); pstmt.setString(7, mainDetails.getRemarks()); pstmt.setString(8, mainDetails.getStatus()); pstmt.executeUpdate(); insertLabelFields(mainDetails.getFieldsList(), connection, labelSeqId); insertLabelFieldLang( mainDetails.getFieldsList(), mainDetails.getLangWiseFieldDescMap(), connection, labelSeqId); connection.commit(); } } catch (Exception e) { connection.rollback(); throw e; } finally { TagLibConnectionUtil.closePreparedStatement(pstmt); TagLibConnectionUtil.closeConnection(connection); } return mainDetails; }
public RELabelSetupMainDetails updateLabelMaster(RELabelSetupMainDetails labelTypeMaster) throws Exception { Connection connection = null; PreparedStatement pstmt = null; String updateQuery = ""; try { connection = TagLibConnectionUtil.getConnection(); connection.setAutoCommit(false); updateQuery = "UPDATE SOFTWARE_SERVICES SET SCREEN_ID=?,DESCRIPTION=?,JSP_NAME=?, VO_CLASS=?,HANDLER_CLASS=?,REMARKS=?,STATUS=? WHERE ID =? "; pstmt = connection.prepareStatement(updateQuery); pstmt.setString(1, labelTypeMaster.getScrnId()); pstmt.setString(2, labelTypeMaster.getDesc()); pstmt.setString(3, labelTypeMaster.getJspName()); pstmt.setString(4, labelTypeMaster.getVoClass()); pstmt.setString(5, labelTypeMaster.getHandlerClass()); pstmt.setString(6, labelTypeMaster.getRemarks()); pstmt.setString(7, labelTypeMaster.getStatus()); pstmt.setLong(8, labelTypeMaster.getSeqId()); pstmt.executeUpdate(); insertLabelFields(labelTypeMaster.getFieldsList(), connection, labelTypeMaster.getSeqId()); insertLabelFieldLang( labelTypeMaster.getFieldsList(), labelTypeMaster.getLangWiseFieldDescMap(), connection, labelTypeMaster.getSeqId()); connection.commit(); } catch (Exception e) { connection.rollback(); e.printStackTrace(); throw e; } finally { TagLibConnectionUtil.closePreparedStatement(pstmt); TagLibConnectionUtil.closeConnection(connection); } return labelTypeMaster; }