protected synchronized AbstractBaseObject insert(AbstractBaseObject obj) throws ApplicationException { PreparedStatement preStat = null; StringBuffer sqlStat = new StringBuffer(); MtmWfStepNotificationRule tmpMtmWfStepNotificationRule = (MtmWfStepNotificationRule) ((MtmWfStepNotificationRule) obj).clone(); synchronized (dbConn) { try { Integer nextID = getNextPrimaryID(); Timestamp currTime = Utility.getCurrentTimestamp(); sqlStat.append("INSERT "); sqlStat.append( "INTO MTM_WF_STEP_NOTIFY_RULE(ID, WORKFLOW_STEP_ID, NOTIFY_TRIGGER, NOTIFY_AT_FIELD, NOTIFY_AT_AMT, NOTIFY_ACK_METHOD, RECORD_STATUS, UPDATE_COUNT, CREATOR_ID, CREATE_DATE, UPDATER_ID, UPDATE_DATE) "); sqlStat.append("VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) "); preStat = dbConn.prepareStatement( sqlStat.toString(), ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); setPrepareStatement(preStat, 1, nextID); setPrepareStatement(preStat, 2, tmpMtmWfStepNotificationRule.getWorkflowStepID()); setPrepareStatement(preStat, 3, tmpMtmWfStepNotificationRule.getNotifyTrigger()); setPrepareStatement(preStat, 4, tmpMtmWfStepNotificationRule.getNotifyAtField()); setPrepareStatement(preStat, 5, tmpMtmWfStepNotificationRule.getNotifyAtAmt()); setPrepareStatement(preStat, 6, tmpMtmWfStepNotificationRule.getNotifyAckMethod()); setPrepareStatement(preStat, 7, GlobalConstant.RECORD_STATUS_ACTIVE); setPrepareStatement(preStat, 8, new Integer(0)); setPrepareStatement(preStat, 9, sessionContainer.getUserRecordID()); setPrepareStatement(preStat, 10, currTime); setPrepareStatement(preStat, 11, sessionContainer.getUserRecordID()); setPrepareStatement(preStat, 12, currTime); preStat.executeUpdate(); tmpMtmWfStepNotificationRule.setID(nextID); tmpMtmWfStepNotificationRule.setCreatorID(sessionContainer.getUserRecordID()); tmpMtmWfStepNotificationRule.setCreateDate(currTime); tmpMtmWfStepNotificationRule.setUpdaterID(sessionContainer.getUserRecordID()); tmpMtmWfStepNotificationRule.setUpdateDate(currTime); tmpMtmWfStepNotificationRule.setUpdateCount(new Integer(0)); tmpMtmWfStepNotificationRule.setCreatorName( UserInfoFactory.getUserFullName(tmpMtmWfStepNotificationRule.getCreatorID())); tmpMtmWfStepNotificationRule.setUpdaterName( UserInfoFactory.getUserFullName(tmpMtmWfStepNotificationRule.getUpdaterID())); return (tmpMtmWfStepNotificationRule); } catch (ApplicationException appEx) { throw appEx; } catch (SQLException sqle) { log.error(sqle, sqle); throw new ApplicationException(ErrorConstant.DB_GENERAL_ERROR, sqle, sqle.toString()); } catch (Exception e) { log.error(e, e); throw new ApplicationException(ErrorConstant.DB_INSERT_ERROR, e); } finally { try { preStat.close(); } catch (Exception ignore) { } finally { preStat = null; } } } }
protected synchronized AbstractBaseObject update(AbstractBaseObject obj) throws ApplicationException { PreparedStatement preStat = null; StringBuffer sqlStat = new StringBuffer(); MtmContactListObjectLink tmpMtmContactListObjectLink = (MtmContactListObjectLink) ((MtmContactListObjectLink) obj).clone(); synchronized (dbConn) { try { int updateCnt = 0; Timestamp currTime = Utility.getCurrentTimestamp(); sqlStat.append("UPDATE MTM_CONTACT_LIST_OBJECT_LINK "); sqlStat.append( "SET CONTACT_LIST_ID=?, OBJECT_TYPE=?, OBJECT_ID=?, UPDATE_COUNT=?, UPDATER_ID=?, UPDATE_DATE=? "); sqlStat.append("WHERE ID=? AND UPDATE_COUNT=? "); preStat = dbConn.prepareStatement( sqlStat.toString(), ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); setPrepareStatement(preStat, 1, tmpMtmContactListObjectLink.getContactListID()); setPrepareStatement(preStat, 2, tmpMtmContactListObjectLink.getObjectType()); setPrepareStatement(preStat, 3, tmpMtmContactListObjectLink.getObjectID()); setPrepareStatement( preStat, 4, new Integer(tmpMtmContactListObjectLink.getUpdateCount().intValue() + 1)); setPrepareStatement(preStat, 5, sessionContainer.getUserRecordID()); setPrepareStatement(preStat, 6, currTime); setPrepareStatement(preStat, 7, tmpMtmContactListObjectLink.getID()); setPrepareStatement(preStat, 8, tmpMtmContactListObjectLink.getUpdateCount()); updateCnt = preStat.executeUpdate(); if (updateCnt == 0) { throw new ApplicationException(ErrorConstant.DB_CONCURRENT_ERROR); } else { tmpMtmContactListObjectLink.setUpdaterID(sessionContainer.getUserRecordID()); tmpMtmContactListObjectLink.setUpdateDate(currTime); tmpMtmContactListObjectLink.setUpdateCount( new Integer(tmpMtmContactListObjectLink.getUpdateCount().intValue() + 1)); tmpMtmContactListObjectLink.setCreatorName( UserInfoFactory.getUserFullName(tmpMtmContactListObjectLink.getCreatorID())); tmpMtmContactListObjectLink.setUpdaterName( UserInfoFactory.getUserFullName(tmpMtmContactListObjectLink.getUpdaterID())); return (tmpMtmContactListObjectLink); } } catch (ApplicationException appEx) { throw appEx; } catch (SQLException sqle) { log.error(sqle, sqle); throw new ApplicationException(ErrorConstant.DB_GENERAL_ERROR, sqle, sqle.toString()); } catch (Exception e) { log.error(e, e); throw new ApplicationException(ErrorConstant.DB_UPDATE_ERROR, e); } finally { try { preStat.close(); } catch (Exception ignore) { } finally { preStat = null; } } } }
protected synchronized AbstractBaseObject insert(AbstractBaseObject obj) throws ApplicationException { PreparedStatement preStat = null; StringBuffer sqlStat = new StringBuffer(); MtmContactListObjectLink tmpMtmContactListObjectLink = (MtmContactListObjectLink) ((MtmContactListObjectLink) obj).clone(); synchronized (dbConn) { try { Integer nextID = getNextPrimaryID(); Timestamp currTime = Utility.getCurrentTimestamp(); sqlStat.append("INSERT "); sqlStat.append( "INTO MTM_CONTACT_LIST_OBJECT_LINK(ID, CONTACT_LIST_ID, OBJECT_TYPE, OBJECT_ID, RECORD_STATUS, UPDATE_COUNT, CREATOR_ID, CREATE_DATE, UPDATER_ID, UPDATE_DATE) "); sqlStat.append("VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) "); preStat = dbConn.prepareStatement( sqlStat.toString(), ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); setPrepareStatement(preStat, 1, nextID); setPrepareStatement(preStat, 2, tmpMtmContactListObjectLink.getContactListID()); setPrepareStatement(preStat, 3, tmpMtmContactListObjectLink.getObjectType()); setPrepareStatement(preStat, 4, tmpMtmContactListObjectLink.getObjectID()); setPrepareStatement(preStat, 5, GlobalConstant.RECORD_STATUS_ACTIVE); setPrepareStatement(preStat, 6, new Integer(0)); setPrepareStatement(preStat, 7, sessionContainer.getUserRecordID()); setPrepareStatement(preStat, 8, currTime); setPrepareStatement(preStat, 9, sessionContainer.getUserRecordID()); setPrepareStatement(preStat, 10, currTime); preStat.executeUpdate(); tmpMtmContactListObjectLink.setID(nextID); tmpMtmContactListObjectLink.setCreatorID(sessionContainer.getUserRecordID()); tmpMtmContactListObjectLink.setCreateDate(currTime); tmpMtmContactListObjectLink.setUpdaterID(sessionContainer.getUserRecordID()); tmpMtmContactListObjectLink.setUpdateDate(currTime); tmpMtmContactListObjectLink.setUpdateCount(new Integer(0)); tmpMtmContactListObjectLink.setCreatorName( UserInfoFactory.getUserFullName(tmpMtmContactListObjectLink.getCreatorID())); tmpMtmContactListObjectLink.setUpdaterName( UserInfoFactory.getUserFullName(tmpMtmContactListObjectLink.getUpdaterID())); return (tmpMtmContactListObjectLink); } catch (ApplicationException appEx) { throw appEx; } catch (SQLException sqle) { log.error(sqle, sqle); throw new ApplicationException(ErrorConstant.DB_GENERAL_ERROR, sqle, sqle.toString()); } catch (Exception e) { log.error(e, e); throw new ApplicationException(ErrorConstant.DB_INSERT_ERROR, e); } finally { try { preStat.close(); } catch (Exception ignore) { } finally { preStat = null; } } } }
protected synchronized AbstractBaseObject update(AbstractBaseObject obj) throws ApplicationException { PreparedStatement preStat = null; StringBuffer sqlStat = new StringBuffer(); MtmWfStepNotificationRule tmpMtmWfStepNotificationRule = (MtmWfStepNotificationRule) ((MtmWfStepNotificationRule) obj).clone(); synchronized (dbConn) { try { int updateCnt = 0; Timestamp currTime = Utility.getCurrentTimestamp(); sqlStat.append("UPDATE MTM_WF_STEP_NOTIFY_RULE "); sqlStat.append( "SET WORKFLOW_STEP_ID=?, NOTIFY_TRIGGER=?, NOTIFY_AT_FIELD=?, NOTIFY_AT_AMT=?, NOTIFY_ACK_METHOD=?, UPDATE_COUNT=?, UPDATER_ID=?, UPDATE_DATE=? "); sqlStat.append("WHERE ID=? AND UPDATE_COUNT=? "); preStat = dbConn.prepareStatement( sqlStat.toString(), ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); setPrepareStatement(preStat, 1, tmpMtmWfStepNotificationRule.getWorkflowStepID()); setPrepareStatement(preStat, 2, tmpMtmWfStepNotificationRule.getNotifyTrigger()); setPrepareStatement(preStat, 3, tmpMtmWfStepNotificationRule.getNotifyAtField()); setPrepareStatement(preStat, 4, tmpMtmWfStepNotificationRule.getNotifyAtAmt()); setPrepareStatement(preStat, 5, tmpMtmWfStepNotificationRule.getNotifyAckMethod()); setPrepareStatement( preStat, 6, new Integer(tmpMtmWfStepNotificationRule.getUpdateCount().intValue() + 1)); setPrepareStatement(preStat, 7, sessionContainer.getUserRecordID()); setPrepareStatement(preStat, 8, currTime); setPrepareStatement(preStat, 9, tmpMtmWfStepNotificationRule.getID()); setPrepareStatement(preStat, 10, tmpMtmWfStepNotificationRule.getUpdateCount()); updateCnt = preStat.executeUpdate(); if (updateCnt == 0) { throw new ApplicationException(ErrorConstant.DB_CONCURRENT_ERROR); } else { tmpMtmWfStepNotificationRule.setUpdaterID(sessionContainer.getUserRecordID()); tmpMtmWfStepNotificationRule.setUpdateDate(currTime); tmpMtmWfStepNotificationRule.setUpdateCount( new Integer(tmpMtmWfStepNotificationRule.getUpdateCount().intValue() + 1)); tmpMtmWfStepNotificationRule.setCreatorName( UserInfoFactory.getUserFullName(tmpMtmWfStepNotificationRule.getCreatorID())); tmpMtmWfStepNotificationRule.setUpdaterName( UserInfoFactory.getUserFullName(tmpMtmWfStepNotificationRule.getUpdaterID())); return (tmpMtmWfStepNotificationRule); } } catch (ApplicationException appEx) { throw appEx; } catch (SQLException sqle) { log.error(sqle, sqle); throw new ApplicationException(ErrorConstant.DB_GENERAL_ERROR, sqle, sqle.toString()); } catch (Exception e) { log.error(e, e); throw new ApplicationException(ErrorConstant.DB_UPDATE_ERROR, e); } finally { try { preStat.close(); } catch (Exception ignore) { } finally { preStat = null; } } } }