List of usage examples for org.springframework.transaction TransactionDefinition ISOLATION_READ_UNCOMMITTED
int ISOLATION_READ_UNCOMMITTED
To view the source code for org.springframework.transaction TransactionDefinition ISOLATION_READ_UNCOMMITTED.
Click Source Link
From source file:com.krawler.spring.crm.accountModule.crmAccountController.java
public ModelAndView deleteAccount(HttpServletRequest request, HttpServletResponse response) throws ServletException { JSONObject myjobj = null;/*from w w w .jav a2 s .c o m*/ KwlReturnObject kmsg = null; CrmAccount acc = null; //Create transaction DefaultTransactionDefinition def = new DefaultTransactionDefinition(); def.setName("JE_Tx"); def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); def.setIsolationLevel(TransactionDefinition.ISOLATION_READ_UNCOMMITTED); TransactionStatus status = txnManager.getTransaction(def); try { String userid = sessionHandlerImpl.getUserid(request); String timeZoneDiff = sessionHandlerImpl.getTimeZoneDifference(request); myjobj = new JSONObject(); myjobj.put("success", false); JSONArray jarr = null; if (request.getAttribute("deletejarr") != null) { jarr = (JSONArray) request.getAttribute("deletejarr"); } else { String jsondata = request.getParameter("jsondata"); jarr = new JSONArray("[" + jsondata + "]"); } ArrayList accountids = new ArrayList(); for (int i = 0; i < jarr.length(); i++) { JSONObject jobject = jarr.getJSONObject(i); accountids.add(jobject.getString("accid").toString()); } String[] arrayid = (String[]) accountids.toArray(new String[] {}); JSONObject jobj = new JSONObject(); jobj.put("deleteflag", 1); jobj.put("accountid", arrayid); jobj.put("userid", userid); jobj.put("updatedon", new Date().getTime()); jobj.put("tzdiff", timeZoneDiff); kmsg = crmAccountDAOObj.updateMassAccount(jobj); List<CrmAccount> ll = crmAccountDAOObj.getAccounts(accountids); if (ll != null) { for (int i = 0; i < ll.size(); i++) { CrmAccount accountaudit = (CrmAccount) ll.get(i); if (accountaudit.getValidflag() == 1) { auditTrailDAOObj.insertAuditLog(AuditAction.ACCOUNT_DELETE, accountaudit.getAccountname() + " - Account deleted ", request, accountaudit.getAccountid()); } } } if (request.getAttribute("failDelete") != null) { myjobj.put("failDelete", (JSONArray) request.getAttribute("failDelete")); } myjobj.put("successDeleteArr", jarr); myjobj.put("success", true); myjobj.put("ID", accountids.toArray()); txnManager.commit(status); JSONObject cometObj = new JSONObject(); cometObj.put("ids", jarr); publishAccountModuleInformation(request, cometObj, CrmPublisherHandler.DELETERECORDCODE, sessionHandlerImpl.getCompanyid(request), userid); } catch (JSONException e) { System.out.println(e.getMessage()); txnManager.rollback(status); } catch (Exception e) { System.out.println(e.getMessage()); txnManager.rollback(status); } return new ModelAndView("jsonView", "model", myjobj.toString()); }
From source file:com.krawler.spring.crm.accountModule.crmAccountController.java
public ModelAndView saveAccOwners(HttpServletRequest request, HttpServletResponse response) throws ServletException { JSONObject myjobj = new JSONObject(); KwlReturnObject kmsg = null;// ww w . j a v a2 s . c om //Create transaction DefaultTransactionDefinition def = new DefaultTransactionDefinition(); def.setName("JE_Tx"); def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); def.setIsolationLevel(TransactionDefinition.ISOLATION_READ_UNCOMMITTED); TransactionStatus status = txnManager.getTransaction(def); try { String accid = request.getParameter("leadid"); String owners = request.getParameter("owners"); String mainowner = request.getParameter("mainOwner"); HashMap<String, Object> requestParams = new HashMap<String, Object>(); requestParams.put("accid", accid); requestParams.put("owners", owners); requestParams.put("mainOwner", mainowner); kmsg = crmAccountDAOObj.saveAccOwners(requestParams); // Fetch subowners name list List<String> idsList = new ArrayList<String>(); idsList.add(accid); Map<String, List<AccountOwnerInfo>> ownersMap = crmAccountDAOObj.getAccountOwners(idsList); String[] ownerInfo = crmAccountHandler.getAllAccOwners(ownersMap.get(accid)); myjobj.put("subowners", ownerInfo[1]); myjobj.put("success", kmsg.isSuccessFlag()); txnManager.commit(status); } catch (SessionExpiredException e) { logger.warn("SessionExpiredException while saving account owner:", e); txnManager.rollback(status); } catch (JSONException e) { logger.warn("JSONException while saving account owner:", e); txnManager.rollback(status); } catch (ServiceException e) { logger.warn("ServiceException while saving account owner:", e); txnManager.rollback(status); } catch (Exception e) { logger.warn("Exception while saving account owner:", e); txnManager.rollback(status); } return new ModelAndView("jsonView", "model", myjobj.toString()); }
From source file:com.krawler.spring.crm.accountModule.crmAccountController.java
public ModelAndView updateMassAccounts(HttpServletRequest request, HttpServletResponse response) throws ServletException { JSONObject myjobj = new JSONObject(); KwlReturnObject kmsg = null;/*www.ja v a 2s . com*/ CrmAccount acc = null; //Create transaction DefaultTransactionDefinition def = new DefaultTransactionDefinition(); def.setName("JE_Tx"); def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); def.setIsolationLevel(TransactionDefinition.ISOLATION_READ_UNCOMMITTED); TransactionStatus status = txnManager.getTransaction(def); try { boolean ownerChanged = false; JSONObject jobj = new JSONObject(request.getParameter("jsondata")); String userid = sessionHandlerImpl.getUserid(request); String accountIds = jobj.getString("accountid"); String arrayId[] = accountIds.split(","); Integer operationCode = CrmPublisherHandler.UPDATERECORDCODE; String companyid = sessionHandlerImpl.getCompanyid(request); List<CrmAccount> ownerChangedAccounts = null;//new ArrayList<Object>(); jobj.put("userid", userid); jobj.put("companyid", companyid); if (jobj.has("updatedon") && !StringUtil.isNullOrEmpty(jobj.getString("updatedon"))) { jobj.put("updatedon", jobj.getLong("updatedon")); } else { jobj.put("updatedon", new Date().getTime()); } jobj.put("accountid", arrayId); jobj.put("tzdiff", sessionHandlerImpl.getTimeZoneDifference(request)); JSONArray jcustomarray = null; if (jobj.has("customfield")) { jcustomarray = jobj.getJSONArray("customfield"); } if (jobj.optString("accountownerid", null) != null) { String newOwnerId = jobj.getString("accountownerid"); ownerChangedAccounts = crmAccountHandler.getOwnerChangedAccounts(crmAccountDAOObj, arrayId, newOwnerId); } if (jobj.has("customfield")) { HashMap<String, Object> customrequestParams = new HashMap<String, Object>(); customrequestParams.put("customarray", jcustomarray); customrequestParams.put("modulename", Constants.Crm_Account_modulename); customrequestParams.put("moduleprimarykey", Constants.Crm_Accountid); customrequestParams.put("companyid", companyid); customrequestParams.put("customdataclasspath", Constants.Crm_account_custom_data_classpath); KwlReturnObject customDataresult = null; for (String id : arrayId) { customrequestParams.put("modulerecid", id); customDataresult = fieldDataManagercntrl.setCustomData(customrequestParams); } if (customDataresult != null && customDataresult.getEntityList().size() > 0) { jobj.put("CrmAccountCustomDataobj", true); } } if (jobj.has("createdon")) { jobj.put("createdon", jobj.getLong("createdon")); } kmsg = crmAccountDAOObj.updateMassAccount(jobj); // TODO : How to insert audit log when mass update // acc = (CrmAccount) kmsg.getEntityList().get(0); // if (acc.getValidflag() == 1) { // auditTrailDAOObj.insertAuditLog(AuditAction.ACCOUNT_UPDATE, // jobj.getString("auditstr") + " Account - " + // ((acc.getAccountname() == null) ? "" : acc.getAccountname()) + // " ", // request, id); // } // } txnManager.commit(status); JSONObject cometObj = jobj; if (request.getParameter("massEdit") != null && Boolean.parseBoolean(request.getParameter("massEdit"))) { crmCommonService.validateMassupdate(arrayId, "Account", companyid); cometObj.put("accountid", accountIds); cometObj.put("ismassedit", true); } myjobj.put("success", true); myjobj.put("ID", accountIds); myjobj.put("createdon", jobj.has("createdon") ? jobj.getLong("createdon") : ""); if (!StringUtil.isNullObject(acc)) { if (!StringUtil.isNullObject(acc.getCreatedon())) { cometObj.put("createdon", acc.getCreatedonGMT()); } } publishAccountModuleInformation(request, cometObj, operationCode, companyid, userid); // TODO : send Email when owner changed if (ownerChangedAccounts != null && ownerChangedAccounts.size() > 0) {// Send Notification if owner changed List<String> recepients = new ArrayList<String>(); recepients.add(jobj.getString("accountownerid")); String loginURL = URLUtil.getRequestPageURL(request, Links.loginpageFull); HashMap<String, Object> extraParams = new HashMap<String, Object>(); extraParams.put(NotificationConstants.LOGINURL, loginURL); extraParams.put(NotificationConstants.PARTNERNAME, sessionHandlerImpl.getPartnerName(request)); StringBuffer variableData = new StringBuffer(); String accname = ""; String type = ""; int srno = 0; Map refTypeMap = new HashMap(); Map refIdMap = new HashMap(); refIdMap.put("refid1", (ownerChangedAccounts.get(0)).getAccountid()); refTypeMap.put("reftype1", Constants.Crm_account_classpath); refIdMap.put("refid2", userid); refTypeMap.put("reftype2", Constants.USERS_CLASSPATH); if (ownerChangedAccounts.size() > 1) { for (CrmAccount accountObj : ownerChangedAccounts) { srno++; accname = !StringUtil.isNullOrEmpty(accountObj.getAccountname()) ? accountObj.getAccountname() : ""; type = (!StringUtil.isNullObject(accountObj.getCrmCombodataByAccounttypeid())) ? accountObj.getCrmCombodataByAccounttypeid().getValue() : ""; variableData.append("<tr>"); variableData.append("<td> " + srno + "</td>"); variableData.append("<td> " + accname + "</td>"); variableData.append("<td> " + type + "</td>"); variableData.append("</tr>"); } extraParams.put(Constants.VARIABLEDATA, variableData); NotificationManagementServiceDAO.sendNotificationRequest(CHANNEL.EMAIL, ACCOUNT_ASSIGNED_MASS_UPDATE, NOTIFICATIONSTATUS.REQUEST, userid, recepients, refIdMap, refTypeMap, extraParams); } else { NotificationManagementServiceDAO.sendNotificationRequest(CHANNEL.EMAIL, ACCOUNT_ASSIGNED, NOTIFICATIONSTATUS.REQUEST, userid, recepients, refIdMap, refTypeMap, extraParams); } } } catch (Exception e) { logger.warn("Exception while Accoount Mass Update:", e); txnManager.rollback(status); } return new ModelAndView("jsonView", "model", myjobj.toString()); }
From source file:com.krawler.spring.crm.activityModule.crmActivityController.java
public ModelAndView deleteActivity(HttpServletRequest request, HttpServletResponse response) throws ServletException { JSONObject myjobj = null;/*w w w . j av a 2 s. c om*/ KwlReturnObject kmsg = null; CrmActivityMaster activity = null; //Create transaction DefaultTransactionDefinition def = new DefaultTransactionDefinition(); def.setName("JE_Tx"); def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); def.setIsolationLevel(TransactionDefinition.ISOLATION_READ_UNCOMMITTED); TransactionStatus status = txnManager.getTransaction(def); try { String userid = sessionHandlerImpl.getUserid(request); ArrayList activityids = new ArrayList(); String timeZoneDiff = sessionHandlerImpl.getTimeZoneDifference(request); myjobj = new JSONObject(); myjobj.put("success", false); if (StringUtil.bNull(request.getParameter("jsondata"))) { String jsondata = request.getParameter("jsondata"); JSONArray jarr = new JSONArray("[" + jsondata + "]"); for (int i = 0; i < jarr.length(); i++) { JSONObject jobject = jarr.getJSONObject(i); activityids.add(jobject.getString("activityid").toString()); } String[] arrayid = (String[]) activityids.toArray(new String[] {}); JSONObject jobj = new JSONObject(); jobj.put("deleteflag", 1); jobj.put("activityid", arrayid); jobj.put("userid", userid); jobj.put("updatedon", new Date()); jobj.put("tzdiff", timeZoneDiff); kmsg = crmActivityDAOObj.updateMassActivity(jobj); List<CrmActivityMaster> ll = crmActivityDAOObj.getActivities(activityids); if (ll != null) { for (int i = 0; i < ll.size(); i++) { CrmActivityMaster activityaudit = (CrmActivityMaster) ll.get(i); if (activityaudit.getValidflag() == 1) { auditTrailDAOObj.insertAuditLog(AuditAction.ACTIVITY_DELETE, activityaudit.getFlag() + " - Activity deleted ", request, activityaudit.getActivityid()); } } } JSONObject cometObj = new JSONObject(); cometObj.put("ids", jarr); publishActivityModuleInformation(request, cometObj, CrmPublisherHandler.DELETERECORDCODE, sessionHandlerImpl.getCompanyid(request), userid); } myjobj.put("success", true); myjobj.put("ID", activityids.toArray()); txnManager.commit(status); } catch (JSONException e) { LOGGER.warn(e.getMessage(), e); txnManager.rollback(status); } catch (Exception e) { LOGGER.warn(e.getMessage(), e); txnManager.rollback(status); } return new ModelAndView("jsonView", "model", myjobj.toString()); }
From source file:com.krawler.spring.crm.caseModule.crmCaseController.java
public ModelAndView saveCases(HttpServletRequest request, HttpServletResponse response) throws ServletException { JSONObject myjobj = new JSONObject(); KwlReturnObject kmsg = null;//w w w .j a v a2s .c o m CrmCase cases = null; //Create transaction DefaultTransactionDefinition def = new DefaultTransactionDefinition(); def.setName("JE_Tx"); def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); def.setIsolationLevel(TransactionDefinition.ISOLATION_READ_UNCOMMITTED); TransactionStatus status = txnManager.getTransaction(def); try { boolean caseClosed = false; boolean assignedUserChanged = false; JSONObject jobj = new JSONObject(request.getParameter("jsondata")); String companyid = sessionHandlerImpl.getCompanyid(request); String userid = sessionHandlerImpl.getUserid(request); Integer operationCode = CrmPublisherHandler.ADDRECORDCODE; String id = jobj.getString("caseid"); String[] arrayId = new String[] { id }; jobj.put("userid", userid); jobj.put("companyid", companyid); jobj.put("updatedon", new Date().getTime()); JSONArray jcustomarray = null; if (jobj.has("customfield")) { jcustomarray = jobj.getJSONArray("customfield"); } if (id.equals("0")) { id = java.util.UUID.randomUUID().toString(); jobj.put("caseid", id); jobj.put("casecreatedby", userid); kmsg = crmCaseDAOObj.addCases(jobj); cases = (CrmCase) kmsg.getEntityList().get(0); if (cases.getValidflag() == 1) { auditTrailDAOObj.insertAuditLog(AuditAction.CASE_CREATE, ((cases.getSubject() == null) ? "" : cases.getSubject()) + " - Case created ", request, id); } HashMap<String, Object> customrequestParams = new HashMap<String, Object>(); customrequestParams.put("customarray", jcustomarray); customrequestParams.put("modulename", Constants.Crm_Case_modulename); customrequestParams.put("moduleprimarykey", Constants.Crm_Caseid); customrequestParams.put("modulerecid", id); customrequestParams.put("companyid", companyid); customrequestParams.put("customdataclasspath", Constants.Crm_case_custom_data_classpath); if (jobj.has("customfield")) { KwlReturnObject customDataresult = fieldDataManagercntrl.setCustomData(customrequestParams); if (customDataresult != null && customDataresult.getEntityList().size() > 0) { jobj.put("CrmCaseCustomDataobj", id); kmsg = crmCaseDAOObj.editCases(jobj); } } // fetch auto-number columns only HashMap<String, Object> fieldrequestParams = new HashMap<String, Object>(); fieldrequestParams.put("isexport", true); fieldrequestParams.put("filter_names", Arrays.asList("companyid", "moduleid", "fieldtype")); fieldrequestParams.put("filter_values", Arrays.asList(companyid, Constants.Crm_case_moduleid, Constants.CUSTOM_FIELD_AUTONUMBER)); KwlReturnObject AutoNoFieldMap = fieldManagerDAOobj.getFieldParams(fieldrequestParams); // increment auto number if exist if (AutoNoFieldMap.getEntityList().size() > 0) { JSONArray autoNoData = fieldDataManagercntrl.setAutoNumberCustomData(customrequestParams, AutoNoFieldMap.getEntityList()); jobj.put(com.krawler.common.util.Constants.AUTOCUSTOMFIELD, autoNoData); } // END logic - auto no } else { operationCode = CrmPublisherHandler.UPDATERECORDCODE; // using old and new record validflag, check record becames valid or not List<String> recordIds = new ArrayList<String>(); recordIds.add(id); List<CrmCase> oldCaseRecord = crmCaseDAOObj.getCases(recordIds); String caseAssignedId = null; if (oldCaseRecord != null) { for (CrmCase caseObj : oldCaseRecord) { caseAssignedId = (caseObj.getAssignedto() != null ? caseObj.getAssignedto().getUserID() : ""); if (jobj.has("caseassignedtoid")) { if (!caseAssignedId.equals(jobj.getString("caseassignedtoid"))) { assignedUserChanged = true; } } if (caseObj.getCrmCombodataByCasestatusid() != null && caseObj .getCrmCombodataByCasestatusid().getMainID().equals(Constants.CASESTATUS_CLOSED)) { caseClosed = true; } } } if (jobj.has("customfield")) { HashMap<String, Object> customrequestParams = new HashMap<String, Object>(); customrequestParams.put("customarray", jcustomarray); customrequestParams.put("modulename", Constants.Crm_Case_modulename); customrequestParams.put("moduleprimarykey", Constants.Crm_Caseid); customrequestParams.put("modulerecid", id); customrequestParams.put("companyid", companyid); customrequestParams.put("customdataclasspath", Constants.Crm_case_custom_data_classpath); KwlReturnObject customDataresult = fieldDataManagercntrl.setCustomData(customrequestParams); if (customDataresult != null && customDataresult.getEntityList().size() > 0) { jobj.put("CrmCaseCustomDataobj", id); } } if (jobj.has("createdon")) { jobj.put("createdon", jobj.getLong("createdon")); } kmsg = crmCaseDAOObj.editCases(jobj); cases = (CrmCase) kmsg.getEntityList().get(0); if (cases.getValidflag() == 1) { auditTrailDAOObj.insertAuditLog(AuditAction.CASE_UPDATE, jobj.getString("auditstr") + " Case - " + ((cases.getSubject() == null) ? "" : cases.getSubject()) + " ", request, id); String loginURL = URLUtil.getRequestPageURL(request, Links.loginpageFull); HashMap<String, Object> extraParams = new HashMap<String, Object>(); extraParams.put(NotificationConstants.LOGINURL, loginURL); extraParams.put(NotificationConstants.PARTNERNAME, sessionHandlerImplObj.getPartnerName()); if (jobj.has("casestatusid") && !caseClosed && cases.getCrmCombodataByCasestatusid() != null && cases.getCrmCombodataByCasestatusid().getMainID() .equals(Constants.CASESTATUS_CLOSED)) { sendNotificationOnCaseClosed(cases, userid, companyid, extraParams, sessionHandlerImplObj.getSystemEmailId()); } if (assignedUserChanged && cases.getAssignedto() != null) { sendNotificationOnCaseAssigned(cases, userid, extraParams); } } } if (request.getParameter("massEdit") != null && Boolean.parseBoolean(request.getParameter("massEdit"))) { if (arrayId[0].equals("0")) crmCommonService.validateMassupdate(new String[] { cases.getCaseid() }, "Case", companyid); else crmCommonService.validateMassupdate(arrayId, "Account", companyid); } myjobj.put("success", true); myjobj.put("ID", cases.getCaseid()); myjobj.put("createdon", jobj.has("createdon") ? jobj.getLong("createdon") : ""); myjobj.put(com.krawler.common.util.Constants.AUTOCUSTOMFIELD, jobj.has(com.krawler.common.util.Constants.AUTOCUSTOMFIELD) ? jobj.getJSONArray(com.krawler.common.util.Constants.AUTOCUSTOMFIELD) : ""); txnManager.commit(status); JSONObject cometObj = jobj; if (!StringUtil.isNullObject(cases)) { if (!StringUtil.isNullObject(cases.getCreatedon())) { cometObj.put("createdon", cases.getCreatedonGMT()); } } publishCasesModuleInformation(request, cometObj, operationCode, companyid, userid); } catch (Exception e) { LOGGER.warn(e.getMessage(), e); txnManager.rollback(status); } return new ModelAndView("jsonView", "model", myjobj.toString()); }
From source file:com.krawler.spring.crm.caseModule.crmCaseController.java
public ModelAndView updateMassCases(HttpServletRequest request, HttpServletResponse response) throws ServletException { JSONObject myjobj = new JSONObject(); KwlReturnObject kmsg = null;//from w w w. j a v a2s .co m CrmCase cases = null; // Create transaction DefaultTransactionDefinition def = new DefaultTransactionDefinition(); def.setName("JE_Tx"); def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); def.setIsolationLevel(TransactionDefinition.ISOLATION_READ_UNCOMMITTED); TransactionStatus status = txnManager.getTransaction(def); try { JSONObject jobj = new JSONObject(request.getParameter("jsondata")); String companyid = sessionHandlerImpl.getCompanyid(request); String userid = sessionHandlerImpl.getUserid(request); Integer operationCode = CrmPublisherHandler.UPDATERECORDCODE; String caseIds = jobj.getString("caseid"); String arrayId[] = caseIds.split(","); jobj.put("userid", userid); jobj.put("companyid", companyid); if (jobj.has("updatedon") && !StringUtil.isNullOrEmpty(jobj.getString("updatedon"))) { jobj.put("updatedon", jobj.getLong("updatedon")); } else { jobj.put("updatedon", new Date().getTime()); } jobj.put("caseid", arrayId); jobj.put("tzdiff", sessionHandlerImpl.getTimeZoneDifference(request)); JSONArray jcustomarray = null; if (jobj.has("customfield")) { jcustomarray = jobj.getJSONArray("customfield"); } if (jobj.has("customfield")) { HashMap<String, Object> customrequestParams = new HashMap<String, Object>(); customrequestParams.put("customarray", jcustomarray); customrequestParams.put("modulename", Constants.Crm_Case_modulename); customrequestParams.put("moduleprimarykey", Constants.Crm_Caseid); customrequestParams.put("companyid", companyid); customrequestParams.put("customdataclasspath", Constants.Crm_case_custom_data_classpath); KwlReturnObject customDataresult = null; for (String id : arrayId) { customrequestParams.put("modulerecid", id); customDataresult = fieldDataManagercntrl.setCustomData(customrequestParams); } if (customDataresult != null && customDataresult.getEntityList().size() > 0) { jobj.put("CrmCaseCustomDataobj", true); } } if (jobj.has("createdon")) { jobj.put("createdon", jobj.getLong("createdon")); } kmsg = crmCaseDAOObj.updateMassCases(jobj); // TODO : How to insert audit log when mass update // cases = (CrmCase) kmsg.getEntityList().get(0); // if (cases.getValidflag() == 1) { // auditTrailDAOObj.insertAuditLog(AuditAction.CASE_UPDATE, // jobj.getString("auditstr") + " Case - " + ((acc.getCasename() == // null) ? "" : acc.getCasename()) + " ", // request, id); // } // } JSONObject cometObj = jobj; if (request.getParameter("massEdit") != null && Boolean.parseBoolean(request.getParameter("massEdit"))) { crmCommonService.validateMassupdate(arrayId, "Case", companyid); cometObj.put("caseid", caseIds); cometObj.put("ismassedit", true); } myjobj.put("success", true); myjobj.put("ID", caseIds); myjobj.put("createdon", jobj.has("createdon") ? jobj.getLong("createdon") : ""); if (!StringUtil.isNullObject(cases)) { if (cases.getCreatedOn() != null) { cometObj.put("createdon", cases.getCreatedonGMT()); } } publishCasesModuleInformation(request, cometObj, operationCode, companyid, userid); txnManager.commit(status); } catch (Exception e) { LOGGER.warn(e.getMessage(), e); txnManager.rollback(status); } return new ModelAndView("jsonView", "model", myjobj.toString()); }
From source file:com.krawler.spring.crm.caseModule.crmCaseController.java
public ModelAndView deleteCase(HttpServletRequest request, HttpServletResponse response) throws ServletException { JSONObject myjobj = null;/*from w ww . j a v a 2 s . com*/ KwlReturnObject kmsg = null; CrmCase cases = null; //Create transaction DefaultTransactionDefinition def = new DefaultTransactionDefinition(); def.setName("JE_Tx"); def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); def.setIsolationLevel(TransactionDefinition.ISOLATION_READ_UNCOMMITTED); TransactionStatus status = txnManager.getTransaction(def); JSONArray jarr = null; try { String userid = sessionHandlerImpl.getUserid(request); ArrayList caseids = new ArrayList(); myjobj = new JSONObject(); myjobj.put("success", false); if (StringUtil.bNull(request.getParameter("jsondata"))) { String jsondata = request.getParameter("jsondata"); jarr = new JSONArray("[" + jsondata + "]"); for (int i = 0; i < jarr.length(); i++) { JSONObject jobject = jarr.getJSONObject(i); caseids.add(jobject.getString("caseid").toString()); } String[] arrayid = (String[]) caseids.toArray(new String[] {}); JSONObject jobj = new JSONObject(); jobj.put("deleteflag", 1); jobj.put("caseid", arrayid); jobj.put("userid", userid); jobj.put("updatedon", new Date().getTime()); kmsg = crmCaseDAOObj.updateMassCases(jobj); List<CrmCase> ll = crmCaseDAOObj.getCases(caseids); if (ll != null) { for (int i = 0; i < ll.size(); i++) { CrmCase caseaudit = (CrmCase) ll.get(i); if (caseaudit.getValidflag() == 1) { auditTrailDAOObj.insertAuditLog(AuditAction.CASE_DELETE, caseaudit.getSubject() + " - Case deleted ", request, caseaudit.getCaseid()); } } } } myjobj.put("success", true); myjobj.put("ID", caseids.toArray()); txnManager.commit(status); if (jarr != null) { JSONObject cometObj = new JSONObject(); cometObj.put("ids", jarr); publishCasesModuleInformation(request, cometObj, CrmPublisherHandler.DELETERECORDCODE, sessionHandlerImpl.getCompanyid(request), userid); } } catch (JSONException e) { LOGGER.warn(e.getMessage(), e); txnManager.rollback(status); } catch (Exception e) { LOGGER.warn(e.getMessage(), e); txnManager.rollback(status); } return new ModelAndView("jsonView", "model", myjobj.toString()); }
From source file:com.krawler.spring.crm.caseModule.CrmCustomerCaseController.java
public ModelAndView addComment(HttpServletRequest request, HttpServletResponse response) { Map model = new HashMap(); String responseMessage = ""; DefaultTransactionDefinition def = new DefaultTransactionDefinition(); def.setName("JE_Tx"); def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); def.setIsolationLevel(TransactionDefinition.ISOLATION_READ_UNCOMMITTED); TransactionStatus status = txnManager.getTransaction(def); try {// ww w. ja v a 2s.c om if ((String) request.getSession().getAttribute(Constants.SESSION_CUSTOMER_ID) != null) { String caseId = request.getParameter("caseid"); String userId = (String) request.getSession().getAttribute("contactid"); String comment = request.getParameter("addcomment"); crmCustomerCaseService.addComment(caseId, userId, comment); txnManager.commit(status); request.setAttribute("casedetails", "true"); request.setAttribute("caseid", caseId); } else { request.setAttribute("logout", "true"); } responseMessage = "usercases/redirect"; } catch (Exception e) { logger.warn(e.getMessage(), e); txnManager.rollback(status); } return new ModelAndView(responseMessage, "model", model); }
From source file:com.krawler.spring.crm.caseModule.CrmCustomerCaseController.java
public ModelAndView saveCustomerCases(HttpServletRequest request, HttpServletResponse response) throws ServletException, ServiceException { JSONObject myjobj = new JSONObject(); KwlReturnObject kmsg = null;/*from ww w .ja va 2 s.c om*/ CrmCase cases = null; String responseMessage = ""; DefaultTransactionDefinition def = new DefaultTransactionDefinition(); def.setName("JE_Tx"); def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); def.setIsolationLevel(TransactionDefinition.ISOLATION_READ_UNCOMMITTED); TransactionStatus status = txnManager.getTransaction(def); FileUploadHandler uh = new FileUploadHandler(); HashMap hm = uh.getItems(request); Map model = new HashMap(); try { String companyid = sessionHandlerImpl.getCompanyid(request); String customerId = (String) request.getSession().getAttribute("customerid"); String contactId = (String) request.getSession().getAttribute("contactid"); String caseOwnerID = crmCustomerCaseService.getCompanyCaseDefaultOwnerID(companyid); Integer operationCode = CrmPublisherHandler.ADDRECORDCODE; JSONObject jobj = new JSONObject(); JSONObject jobj1 = new JSONObject(); String id = java.util.UUID.randomUUID().toString(); jobj.put("caseid", id); jobj.put("contactnameid", contactId); jobj.put("userid", caseOwnerID); jobj.put("caseownerid", caseOwnerID); jobj.put("subject", hm.get("subject")); jobj.put("description", hm.get("description")); jobj.put("companyid", companyid); jobj.put("createdon", System.currentTimeMillis()); jobj.put("updatedon", System.currentTimeMillis()); jobj.put("casecreatedby", contactId); jobj.put("createdbyflag", "1"); kmsg = crmCustomerCaseService.addCases(jobj); cases = (CrmCase) kmsg.getEntityList().get(0); try { FileItem fileItem = (FileItem) hm.get("attachment"); String filename = fileItem.getName(); String docID = ""; if (filename != null && filename != "") { if (fileItem.getSize() <= 10485760) { //limit 10 mb kmsg = crmCustomerCaseService.uploadFile(fileItem, null, companyid, getServletContext());//Since document is uploaded by customer ,userid is null for uploadfile function Docs doc = (Docs) kmsg.getEntityList().get(0); docID = doc.getDocid(); jobj1.put("docid", docID); jobj1.put("companyid", companyid); jobj1.put("id", id); jobj1.put("map", "6"); jobj1.put("refid", id); crmCustomerCaseService.saveDocumentMapping(jobj1); crmCustomerCaseService.saveCustomerDocs(customerId, docID, id); } } } catch (Exception e) { logger.warn("Attachment upload failed with Customer case :" + e.getMessage()); } myjobj.put("success", true); myjobj.put("ID", cases.getCaseid()); myjobj.put("createdon", jobj.optLong("createdon")); txnManager.commit(status); JSONObject cometObj = jobj; if (!StringUtil.isNullObject(cases)) { if (!StringUtil.isNullObject(cases.getCreatedon())) { cometObj.put("createdon", cases.getCreatedonGMT()); } } //publishCasesModuleInformation(request, cometObj, operationCode, companyid, caseOwnerID); request.setAttribute("caselist", "true"); responseMessage = "usercases/redirect"; } catch (Exception e) { logger.warn(e.getMessage(), e); txnManager.rollback(status); } return new ModelAndView(responseMessage, "model", model); }
From source file:com.krawler.spring.crm.caseModule.CrmCustomerCaseController.java
public ModelAndView custPassword_Change(HttpServletRequest request, HttpServletResponse response) throws ServletException { String newpass = request.getParameter("newpass"); String currentpass = request.getParameter("curpass"); String customerid = request.getParameter("customerid"); String email = request.getParameter("email"); Map model = new HashMap(); // String replaceStr=request.getParameter("cdomain"); String url = URLUtil.getRequestPageURL(request, Links.UnprotectedLoginPageFull); String loginurl = url.concat("caselogin.jsp"); String name = request.getParameter("cname"); boolean verify_pass = false; String responseMessage = ""; if ((String) request.getSession().getAttribute(Constants.SESSION_CUSTOMER_ID) != null) { DefaultTransactionDefinition def = new DefaultTransactionDefinition(); def.setName("JE_Tx"); def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); def.setIsolationLevel(TransactionDefinition.ISOLATION_READ_UNCOMMITTED); TransactionStatus status = txnManager.getTransaction(def); try {/* w w w .j av a2 s. co m*/ verify_pass = contactManagementService.verifyCurrentPass(currentpass, customerid); if (verify_pass) { contactManagementService.custPassword_Change(newpass, customerid); txnManager.commit(status); request.setAttribute("homepage", "true"); request.setAttribute("success", "true"); responseMessage = "usercases/redirect"; String partnerNames = sessionHandlerImplObj.getPartnerName(); String sysEmailId = sessionHandlerImplObj.getSystemEmailId(); String passwordString = "Username: " + email + " <br/><br/>Password: <b>" + newpass + "</b>"; String htmlmsg = "Dear <b>" + name + "</b>,<br/><br/> Your <b>password has been changed</b> for your account on " + partnerNames + " CRM. <br/><br/>" + passwordString + "<br/><br/>You can log in at:\n" + loginurl + "<br/><br/>See you on " + partnerNames + " CRM <br/><br/> -The " + partnerNames + " CRM Team"; try { SendMailHandler.postMail(new String[] { email }, "[" + partnerNames + "] Password Changed", htmlmsg, "", sysEmailId, partnerNames + " Admin"); } catch (MessagingException e) { e.printStackTrace(); } } else { request.setAttribute("changepassword", "true"); request.setAttribute("mis_pass", "true"); txnManager.commit(status); } } catch (Exception e) { logger.warn("custPassword_change Error:", e); txnManager.rollback(status); responseMessage = "../../usercases/failure"; } } else { request.setAttribute("logout", "true"); } responseMessage = "usercases/redirect"; return new ModelAndView(responseMessage, "model", model); }