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:ar.com.zauber.commons.spring.web.handlers.strategy.TransactionStrategyTest.java
/** before */ @Before//w w w. j ava 2 s . c o m public final void before() { defaultTemplate = new TransactionTemplate(); specialTemplate = new TransactionTemplate(); specialTemplate.setIsolationLevel(TransactionDefinition.ISOLATION_READ_UNCOMMITTED); specialTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); specialTemplate.setReadOnly(true); mockController = new MockController(); anotherMockController = new AnotherMockController(); }
From source file:com.krawler.esp.handlers.zohoRequestHandler.java
public String saveUpdateZohoContact(String username, String password, String authToken, String userid, String companyid, String ipAddress, String tzdiff) { // Session s = zohoRequestDAO.getCurrentSession(); String result = "{success:false,recCount:0,totalRecords:0}"; int recCount = 0; 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 {//from w ww. j a va 2s . c o m String Hql = "from CrmContact c where c.contactid= ?"; JSONObject jobj = getRecordJson("Contacts", username, password, authToken); //Potential , Leads, Accounts if (jobj.get("success").equals(true)) { JSONArray dataArray = jobj.getJSONArray("data"); for (int cnt = 0; cnt < dataArray.length(); cnt++) { // Transaction tx = (Transaction) s.beginTransaction(); JSONObject recObj = dataArray.getJSONObject(cnt); List existingContact = zohoRequestDAO.executeQuery(Hql, new Object[] { recObj.get("CONTACTID") }); JSONObject conJObj = new JSONObject(); String conid = recObj.get("CONTACTID").toString(); conJObj.put("contactid", conid); conJObj.put("companyid", companyid); conJObj.put("userid", userid); conJObj.put("contactownerid", userid); conJObj.put("updatedon", new Date()); conJObj.put("description", ""); conJObj.put("phone", recObj.getString("Phone").equals("null") ? "" : recObj.getString("Phone")); conJObj.put("isarchive", false); conJObj.put("deleteflag", 0); CrmAccount ca = null; try { ca = (CrmAccount) zohoRequestDAO.get(CrmAccount.class, recObj.get("ACCOUNTID").toString()); } catch (Exception e) { logger.warn(e.getMessage(), e); } if (ca != null) { conJObj.put("accountid", recObj.get("ACCOUNTID")); } conJObj.put("email", recObj.getString("Email").equals("null") ? "" : recObj.getString("Email")); conJObj.put("firstname", recObj.getString("First Name").equals("null") ? "" : recObj.getString("First Name")); conJObj.put("lastname", recObj.getString("Last Name").equals("null") ? "" : recObj.getString("Last Name")); conJObj.put("validflag", 1); if (existingContact.size() == 0) { conJObj.put("contactid", "0"); } contactManagementService.saveContact(companyid, userid, tzdiff, ipAddress, conJObj); // tx.commit(); recCount++; } txnManager.commit(status); result = "{success:true,recCount:" + recCount + ",totalRecords:" + jobj.get("recordCount") + "}"; } } catch (ServiceException ex) { logger.warn(ex.getMessage(), ex); txnManager.rollback(status); } catch (JSONException ex) { logger.warn(ex.getMessage(), ex); txnManager.rollback(status); } catch (Exception e) { logger.warn(e.getMessage(), e); } finally { // s.close(); return result; } }
From source file:com.krawler.esp.handlers.zohoRequestHandler.java
public String saveUpdateZohoLeads(String username, String password, String authToken, String userid, String companyid) {//from ww w. j ava2s.com // Session s = zohoRequestDAO.getCurrentSession(); String result = "{success:false,recCount:0,totalRecords:0}"; int recCount = 0; 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 Hql = "from CrmLead c where c.leadid= ?"; JSONObject jobj = getRecordJson("Leads", username, password, authToken); //Potential , Leads, Accounts if (jobj.get("success").equals(true)) { JSONArray dataArray = jobj.getJSONArray("data"); for (int cnt = 0; cnt < dataArray.length(); cnt++) { // Transaction tx = (Transaction) hibernateTemplate.beginTransaction(); JSONObject recObj = dataArray.getJSONObject(cnt); List existingContact = zohoRequestDAO.executeQuery(Hql, new Object[] { recObj.get("LEADID") }); JSONObject jobjret = new JSONObject(); String fname = recObj.getString("First Name"); String lname = recObj.getString("Last Name"); lname = fname.equalsIgnoreCase("null") ? lname : fname + " " + lname; lname = lname.trim(); jobjret.put("lastname", recObj.getString("Last Name").equals("null") ? "" : lname); jobjret.put("email", recObj.getString("Email").equals("null") ? "" : recObj.getString("Email")); jobjret.put("phone", recObj.getString("Phone").equals("null") ? "" : recObj.getString("Phone")); jobjret.put("validflag", 1); jobjret.put("userid", userid); jobjret.put("companyid", companyid); jobjret.put("isconverted", "0"); jobjret.put("istransfered", "0"); jobjret.put("type", "0"); jobjret.put("updatedon", new Date()); jobjret.put("leadid", recObj.getString("LEADID")); jobjret.put("leadownerid", userid); jobjret.put("isarchive", false); jobjret.put("deleteflag", 0); if (existingContact.size() > 0) { KwlReturnObject kmsg = crmLeadDAOObj.editLeads(jobjret); } else { KwlReturnObject kmsg = crmLeadDAOObj.addLeads(jobjret); } recCount++; } txnManager.commit(status); result = "{success:true,recCount:" + recCount + ",totalRecords:" + jobj.get("recordCount") + "}"; } } catch (ServiceException ex) { logger.warn(ex.getMessage(), ex); txnManager.rollback(status); } catch (JSONException ex) { logger.warn(ex.getMessage(), ex); txnManager.rollback(status); } catch (Exception ex) { logger.warn(ex.getMessage(), ex); txnManager.rollback(status); } finally { // s.close(); return result; } }
From source file:com.krawler.esp.handlers.zohoRequestHandler.java
public String saveUpdateZohoAccounts(String username, String password, String authToken, String userid, String companyid) {//from w ww.jav a 2 s . c o m // Session s = zohoRequestDAO.getCurrentSession(); String result = "{success:false,recCount:0,totalRecords:0}"; int recCount = 0; 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 Hql = "from CrmAccount c where c.accountid= ?"; JSONObject jobj = getRecordJson("Accounts", username, password, authToken); //Potential , Leads, Accounts if (jobj.get("success").equals(true)) { JSONArray dataArray = jobj.getJSONArray("data"); for (int cnt = 0; cnt < dataArray.length(); cnt++) { // Transaction tx = (Transaction) s.beginTransaction(); JSONObject recObj = dataArray.getJSONObject(cnt); List existingContact = zohoRequestDAO.executeQuery(Hql, new Object[] { recObj.get("ACCOUNTID") }); JSONObject accJObj = new JSONObject(); accJObj.put("accountid", recObj.get("ACCOUNTID")); accJObj.put("companyid", companyid); accJObj.put("userid", userid); accJObj.put("updatedon", new Date()); accJObj.put("accountname", recObj.getString("Account Name").equals("null") ? "" : recObj.getString("Account Name")); accJObj.put("description", ""); accJObj.put("email", recObj.getString("Website").equals("null") ? "" : recObj.getString("Website")); accJObj.put("phone", recObj.getString("Phone").equals("null") ? "" : recObj.getString("Phone")); accJObj.put("revenue", recObj.getString("Annual Revenue").equals("null") ? "" : recObj.getString("Annual Revenue")); accJObj.put("validflag", 1); accJObj.put("accountownerid", userid); accJObj.put("isarchive", false); accJObj.put("deleteflag", 0); if (existingContact.size() > 0) { KwlReturnObject kmsg = crmAccountDAOObj.editAccounts(accJObj); } else { // accJObj.put("createdon", new Date()); KwlReturnObject kmsg = crmAccountDAOObj.addAccounts(accJObj); } recCount++; } txnManager.commit(status); result = "{success:true,recCount:" + recCount + ",totalRecords:" + jobj.get("recordCount") + "}"; } } catch (ServiceException ex) { logger.warn(ex.getMessage(), ex); txnManager.rollback(status); } catch (JSONException ex) { logger.warn(ex.getMessage(), ex); txnManager.rollback(status); } catch (Exception e) { logger.warn(e.getMessage(), e); } finally { // s.close(); return result; } }
From source file:com.krawler.esp.handlers.zohoRequestHandler.java
public String saveUpdateZohoPotentials(String username, String password, String authToken, String userid, String companyid) {/*w w w . j a v a2 s. c o m*/ // Session s = zohoRequestDAO.getCurrentSession(); String result = "{success:false,recCount:0,totalRecords:0}"; int recCount = 0; 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 Hql = "from CrmOpportunity c where c.oppid= ?"; JSONObject jobj = getRecordJson("Potentials", username, password, authToken); //Potential , Leads, Accounts if (jobj.get("success").equals(true)) { JSONArray dataArray = jobj.getJSONArray("data"); for (int cnt = 0; cnt < dataArray.length(); cnt++) { // Transaction tx = (Transaction) s.beginTransaction(); JSONObject recObj = dataArray.getJSONObject(cnt); List existingPotential = zohoRequestDAO.executeQuery(Hql, new Object[] { recObj.get("POTENTIALID") }); String masterData = "FROM CrmCombodata c where c.crmCombomaster.masterid=?"; List masterdata = zohoRequestDAO.executeQuery(masterData, new Object[] { "d49609c2-0abc-47ce-8d5a-5850c03b7291" }); Iterator itr = masterdata.iterator(); HashMap combodata = new HashMap(); while (itr.hasNext()) { CrmCombodata cdata = (CrmCombodata) itr.next(); combodata.put(cdata.getRawvalue().toLowerCase(), cdata.getValueid()); } Object stagevalue = combodata.get(recObj.getString("Stage").toLowerCase()); DefaultMasterItem dmasterItem = null; if (stagevalue == null) { stagevalue = combodata.get("prospecting"); Company companyObj = (Company) zohoRequestDAO.get(Company.class, companyid); CrmCombomaster crmComboMasterObj = (CrmCombomaster) zohoRequestDAO.get(CrmCombomaster.class, "d49609c2-0abc-47ce-8d5a-5850c03b7291"); dmasterItem = new DefaultMasterItem(); dmasterItem.setMainID(""); dmasterItem.setCompany(companyObj); dmasterItem.setID(UUID.randomUUID().toString()); dmasterItem.setCrmCombomaster(crmComboMasterObj); dmasterItem.setValue(recObj.getString("Stage")); } else { String dmasteritemid = "from DefaultMasterItem d where d.crmCombodata.valueid = ? and d.company.companyID=?"; List templist = zohoRequestDAO.executeQuery(dmasteritemid, new Object[] { stagevalue, companyid }); itr = templist.iterator(); while (itr.hasNext()) { dmasterItem = (DefaultMasterItem) itr.next(); } } JSONObject oppJObj = new JSONObject(); oppJObj.put("oppid", recObj.get("POTENTIALID")); oppJObj.put("companyid", companyid); oppJObj.put("userid", userid); oppJObj.put("updatedon", new Date()); oppJObj.put("oppname", recObj.getString("Potential Name").equals("null") ? "" : recObj.getString("Potential Name")); oppJObj.put("oppownerid", userid); oppJObj.put("opptypeid", "0"); oppJObj.put("currencyid", "0"); oppJObj.put("oppstageid", dmasterItem.getID()); oppJObj.put("isarchive", false); oppJObj.put("deleteflag", 0); CrmAccount ca = null; try { ca = (CrmAccount) zohoRequestDAO.get(CrmAccount.class, recObj.get("ACCOUNTID").toString()); } catch (Exception e) { logger.warn(e.getMessage(), e); } if (ca != null) { oppJObj.put("accountnameid", recObj.get("ACCOUNTID")); } // String timeFormatId = sessionHandlerImpl.getUserTimeFormat(request); // String timeZoneDiff = sessionHandlerImpl.getTimeZoneDifference(request); // if(recObj.has("closedate") && ! recObj.getString("Closing Date").equals("")){ // oppJObj.put("closedate",authHandler.getDateFormatter(timeFormatId, timeZoneDiff).parse(recObj.getString("Closing Date").toString())); // } java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd"); java.util.Date closingdate = null; if (!StringUtil.isNullOrEmpty(recObj.getString("Closing Date"))) { closingdate = sdf.parse(recObj.getString("Closing Date").toString()); oppJObj.put("closingdate", closingdate.getTime()); } oppJObj.put("validflag", 1); if (existingPotential.size() > 0) { KwlReturnObject kmsg = crmOpportunityDAOObj.editOpportunities(oppJObj); } else { // oppJObj.put("createdon", new Date()); KwlReturnObject kmsg = crmOpportunityDAOObj.addOpportunities(oppJObj); } // tx.commit(); recCount++; } txnManager.commit(status); result = "{success:true,recCount:" + recCount + ",totalRecords:" + jobj.get("recordCount") + "}"; } } catch (ServiceException ex) { logger.warn(ex.getMessage(), ex); txnManager.rollback(status); } catch (JSONException ex) { logger.warn(ex.getMessage(), ex); txnManager.rollback(status); } catch (Exception ex) { logger.warn(ex.getMessage(), ex); } finally { // s.close(); return result; } }
From source file:com.krawler.esp.handlers.zohoRequestHandler.java
@Override public void run() { // new TransactionTemplate(transactionManager) // .execute(new TransactionCallbackWithoutResult() { // @Override // public void doInTransactionWithoutResult(TransactionStatus status) { // dao.lock(client, NONE); // dao.save(new Report(client, client.getTotal())); // client.setLastCreated(new Date()); // } // }); // Session session = null; try {/*w w w .ja v a 2 s . c om*/ while (!processQueue.isEmpty()) { JSONObject tempObj = (JSONObject) processQueue.get(0); try { this.isWorking = true; String username = tempObj.getString("username"); String password = tempObj.getString("password"); //String apiKey = tempObj.getString("apikey"); String authToken = tempObj.getString("authtoken"); String userid = tempObj.getString("userid"); String companyid = tempObj.getString("companyid"); String ipAddress = tempObj.getString("ipaddress"); String tzDiff = tempObj.getString("tzdiff"); String parterName = tempObj.getString(Constants.SESSION_PARTNERNAME); String sysEmailId = tempObj.getString("sysemailid"); JSONObject accountResult = null; JSONObject leadResult = null; JSONObject potentialResult = null; JSONObject contactResult = null; String result = ""; if (tempObj.getBoolean("accounts")) { result = saveUpdateZohoAccounts(username, password, authToken, userid, companyid); accountResult = new JSONObject(result); } if (tempObj.getBoolean("leads")) { result = saveUpdateZohoLeads(username, password, authToken, userid, companyid); leadResult = new JSONObject(result); } if (tempObj.getBoolean("potentials")) { result = saveUpdateZohoPotentials(username, password, authToken, userid, companyid); potentialResult = new JSONObject(result); } if (tempObj.getBoolean("contacts")) { result = saveUpdateZohoContact(username, password, authToken, userid, companyid, ipAddress, tzDiff); contactResult = new JSONObject(result); } String htmltxt = "Report for data imported from zoho.<br/>"; String plainMsg = "Report for data imported from zoho.\n"; zohoImportLog zlog = new zohoImportLog(); if (accountResult != null) { zlog.setAccounts(Integer.parseInt(accountResult.getString("recCount"))); zlog.setFailedAccounts( (accountResult.getInt("totalRecords") - accountResult.getInt("recCount"))); htmltxt += "<br/><br/>Accounts:<br/>"; htmltxt += "Total Records Imported: " + accountResult.getString("recCount"); htmltxt += "<br/>Failed Records: " + (accountResult.getInt("totalRecords") - accountResult.getInt("recCount")); plainMsg += "\nAccounts:\n"; plainMsg += "Total Records Imported: " + accountResult.getString("recCount"); plainMsg += "\nFailed Records: " + (accountResult.getInt("totalRecords") - accountResult.getInt("recCount")); } if (leadResult != null) { zlog.setLeads(Integer.parseInt(leadResult.getString("recCount"))); zlog.setFailedLeads((leadResult.getInt("totalRecords") - leadResult.getInt("recCount"))); htmltxt += "<br/><br/>Leads:<br/>"; htmltxt += "Total Records Imported: " + leadResult.getString("recCount"); htmltxt += "<br/>Failed Records: " + (leadResult.getInt("totalRecords") - leadResult.getInt("recCount")); plainMsg += "\nLeads:\n"; plainMsg += "Total Records Imported: " + leadResult.getString("recCount"); plainMsg += "\nFailed Records: " + (leadResult.getInt("totalRecords") - leadResult.getInt("recCount")); } if (potentialResult != null) { zlog.setPotentials(Integer.parseInt(potentialResult.getString("recCount"))); zlog.setFailedPotentials( (potentialResult.getInt("totalRecords") - potentialResult.getInt("recCount"))); htmltxt += "<br/><br/>Potentials:<br/>"; htmltxt += "Total Records Imported: " + potentialResult.getString("recCount"); htmltxt += "<br/>Failed Records: " + (potentialResult.getInt("totalRecords") - potentialResult.getInt("recCount")); plainMsg += "\nPotentials:\n"; plainMsg += "Total Records Imported: " + potentialResult.getString("recCount"); plainMsg += "\nFailed Records: " + (potentialResult.getInt("totalRecords") - potentialResult.getInt("recCount")); } if (contactResult != null) { zlog.setContacts(Integer.parseInt(contactResult.getString("recCount"))); zlog.setFailedContacts( (contactResult.getInt("totalRecords") - contactResult.getInt("recCount"))); htmltxt += "<br/><br/>Contacts:<br/>"; htmltxt += "Total Records Imported: " + contactResult.getString("recCount"); htmltxt += "<br/>Failed Records: " + (contactResult.getInt("totalRecords") - contactResult.getInt("recCount")); plainMsg += "\nContacts:\n"; plainMsg += "Total Records Imported: " + contactResult.getString("recCount"); plainMsg += "\nFailed Records: " + (contactResult.getInt("totalRecords") - contactResult.getInt("recCount")); } htmltxt += "<br/><br/>For queries, email us at support@deskera.com<br/>"; htmltxt += parterName + " Team"; plainMsg += "\nFor queries, email us at support@deskera.com\n"; plainMsg += parterName + " Team"; // session = zohoRequestDAO.getCurrentSession(); // Transaction tx = session.beginTransaction(); DefaultTransactionDefinition def = new DefaultTransactionDefinition(); def.setName("JE_Tx"); def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); def.setIsolationLevel(TransactionDefinition.ISOLATION_READ_UNCOMMITTED); TransactionStatus status = txnManager.getTransaction(def); User u = (User) zohoRequestDAO.get(User.class, userid); zlog.setUserid(userid); zlog.setCompanyid(companyid); zlog.setDate(new java.util.Date()); zlog.setZusername(username); zohoRequestDAO.save(zlog); txnManager.commit(status); // tx.commit(); SendMailHandler.postMail(new String[] { u.getEmailID() }, parterName + " CRM - Report for data imported from zoho", htmltxt, plainMsg, parterName + " Admin<" + sysEmailId + ">"); } catch (MessagingException ex) { logger.warn(ex.getMessage(), ex); } catch (JSONException ex) { logger.warn(ex.getMessage(), ex); } finally { // session.close(); processQueue.remove(tempObj); } } } catch (Exception e) { logger.warn(e.getMessage(), e); } finally { this.isWorking = false; } }
From source file:com.krawler.formbuilder.servlet.ModuleBuilderController.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods. * @param request servlet request/*from w ww .jav a2 s . c om*/ * @param response servlet response */ public ModelAndView form(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException { String result = ""; boolean isFormSubmit = false; boolean commit = false; //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 { int action = Integer.parseInt(request.getParameter("action")); switch (action) { case 0: commit = true; String formid = request.getParameter("formid"); String moduleid = request.getParameter("moduleid"); String formjson = request.getParameter("formjson"); String parentmodule = request.getParameter("parentmodule"); String jsondata = request.getParameter("jsondata"); String tbar = request.getParameter("tbar"); String bbar = request.getParameter("bbar"); // TODO add company id in param result = moduleDao.saveForm(formid, moduleid, formjson, parentmodule, jsondata, tbar, bbar); break; case 1: isFormSubmit = true; result = moduleDao.getAllForms(request.getParameter("moduleid")); break; // case 2: // result = getForm(session, request.getParameter("formid"),request); // break; case 3: commit = true; isFormSubmit = true; result = moduleDao.deleteForm(request.getParameter("id")); break; case 4: // TODO add company check int start = Integer.parseInt(request.getParameter("start")); int limit = Integer.parseInt(request.getParameter("limit")); result = moduleDao.getAllModules(request.getParameter("ss"), request.getParameter("sort"), request.getParameter("dir"), start, limit); break; case 5: isFormSubmit = true; commit = true; // TODO add company check result = moduleDao.createModule(request); break; /*case 6: // result = moduleBuilderGenerateTable.deleteFields(conn,request); break; */case 7: // TODO add company check result = moduleDao.getAllModulesForCombo(request); break; case 8: isFormSubmit = true; result = moduleDao.moduleData(request.getParameter("moduleid")); break; case 9: commit = true; isFormSubmit = true; result = moduleDao.deleteModule(request.getParameter("moduleid")); break; case 10: //result = moduleDao.getGridData(request); String tname = request.getParameter("tablename"); moduleid = request.getParameter("moduleid"); Object modObj = Class.forName("com.krawler.esp.hibernate.impl." + tname).newInstance(); result = moduleDao.getModuleRecords(moduleid, modObj, prepareClauses(request), DATE_FORMAT); break; case 11: result = moduleDao.getModuleConfig(request.getParameter("moduleid")); break; /*case 12: result = getSearchFieldSet(session,request); break;*/ case 13: commit = true; result = moduleDao.saveModuleGridConfig(request.getParameter("jsondata")); break; /*case 14: result = setSearchField(session,request); break;*/ case 15: result = moduleDao.getComboField(request.getParameter("moduleid")); break; case 21: result = moduleDao.getComboData(request.getParameter("moduleid"), request.getParameter("name")); break; case 22: commit = true; isFormSubmit = true; result = "{'success':false, 'msg':'Error occured at server.'}"; //this function will not be called (Parto of old modulebuilder) List fileItems = new ArrayList(); Map arrParams = prepareData(request, fileItems); List modInfo = moduleDao.getModuleInfo((String) arrParams.get("moduleid")); result = moduleDao.createNewRecord(filterData(arrParams, modInfo), fileItems, (String) arrParams.get("moduleid"));//moduleBuilderMethods.createNewRecord(session,request); break; case 23: commit = true; isFormSubmit = true; result = "{'success':false, 'msg':'Error occured at server.'}"; List fileItems1 = new ArrayList(); Map arrParams1 = prepareData(request, fileItems1); List modInfo1 = moduleDao.getModuleInfo((String) arrParams1.get("moduleid")); result = moduleDao.editRecord(filterData(arrParams1, modInfo1), fileItems1, "id", (String) arrParams1.get("moduleid"));//moduleBuilderMethods.editRecord(session,request); break; case 24: commit = true; // isFormSubmit=true; result = moduleDao.deleteRecord("id", request.getParameter("id"), request.getParameter("moduleid"));//moduleBuilderMethods.deleteRecord(session,request); break; case 25: String basemode = request.getParameter("basemode"); String mdlid = request.getParameter("moduleid"); String reportid = request.getParameter("reportid"); String taskid = request.getParameter("taskid"); result = moduleDao.openSubModules(basemode, mdlid, reportid, taskid); break; case 26: result = moduleDao.getOtherModules(request.getParameter("moduleid"), request.getParameter("mode")); break; case 27: commit = true; result = moduleDao.configSubtabModules(request.getParameter("basemodule"), request.getParameter("submodule"), request.getParameter("mode"), request.getParameter("columnname")); break; case 29: commit = true; isFormSubmit = true; result = moduleDao.uploadFile(request);//moduleBuilderMethods.uploadFile(session,request); break; case 30: result = moduleDao.getAttachment(request);//moduleBuilderMethods.getAttachment(session, request); break; case 31: result = moduleDao.getStdCongifType(request.getParameter("reportid")); break; case 32: commit = true; int configid = 0; try { configid = Integer.parseInt(request.getParameter("configid")); } catch (Exception ex) { logger.warn(ex.getMessage(), ex); } result = moduleDao.getModuleCongifType(configid, request.getParameter("add"), request.getParameter("reportid"), request.getParameter("deleteconfig")); break; case 33: String comboValueId = request.getParameter("comboValueId"); List<ModuleClause> clauses = new ArrayList<ModuleClause>(); clauses.add(new ModuleClause("id", "=", comboValueId)); result = moduleDao.getReadOnlyFields(request.getParameter("moduleid"), request.getParameterValues("appenid"), clauses, DATE_FORMAT); break; case 34: result = moduleDao.getModuleForCombo(request); break; case 35: commit = true; result = deployProject(); break; case 36: commit = true; isFormSubmit = true; result = moduleDao.editModule(request); break; case 37: // isFormSubmit=true; result = moduleDao.getAllModules1(request.getParameter("moduleid")); break; case 38: result = moduleDao.getTableColumn(request.getParameter("moduleid")); break; case 39: isFormSubmit = true; result = moduleDao.getformWithParentvalue(request.getParameter("parentmodule"), request.getParameter("childmodule"), request.getParameter("modulevar")); break; case 40: commit = true; String moduleidParam = request.getParameter("moduleid"); String tablename1 = request.getParameter(PARAM_TABLE_NAME); result = moduleDao.buildModule(moduleidParam, tablename1); break; case 45:// Not find any reference String tablename = request.getParameter(PARAM_TABLE_NAME); Object moduleObj = Class.forName("com.krawler.esp.hibernate.impl." + tablename).newInstance(); result = moduleDao.getModuleRecords(moduleObj, DATE_FORMAT); break; case 46: moduleid = request.getParameter("moduleid"); result = moduleDao.getModuleRecords(moduleid, request.getParameter("tablename"), prepareClauses(request), DATE_FORMAT); break; case 47: moduleid = request.getParameter("moduleid"); result = moduleDao.getModuleRecords(moduleid, request.getParameter("tablename"), prepareClauses(request), DATE_FORMAT); break; case 48: isFormSubmit = true; result = moduleDao.getPortletData(request); break; } if (commit) { txnManager.commit(status); } else { txnManager.rollback(status); } } catch (NumberFormatException e) { logger.warn(e.getMessage(), e); txnManager.rollback(status); } catch (ServiceException ex) { logger.warn(ex.getMessage(), ex); txnManager.rollback(status); } catch (Exception ex) { logger.warn(ex.getMessage(), ex); txnManager.rollback(status); } if (isFormSubmit) { return new ModelAndView("jsonView-ex", "model", result); } return new ModelAndView("jsonView", "model", result); }
From source file:com.krawler.spring.crm.accountModule.crmAccountController.java
public ModelAndView saveAccounts(HttpServletRequest request, HttpServletResponse response) throws ServletException { JSONObject myjobj = new JSONObject(); KwlReturnObject kmsg = null;//from w w w . j a va2 s .c om 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.ADDRECORDCODE; String companyid = sessionHandlerImpl.getCompanyid(request); for (int i = 0; i < arrayId.length; i++) { String id = arrayId[i]; jobj.put("userid", userid); jobj.put("companyid", companyid); jobj.put("updatedon", System.currentTimeMillis()); jobj.put("accountid", id); JSONArray jcustomarray = null; if (jobj.has("customfield")) { jcustomarray = jobj.getJSONArray("customfield"); } if (id.equals("0")) { if (jobj.has("accountownerid") && !jobj.getString("accountownerid").equals(userid)) { ownerChanged = true; } id = java.util.UUID.randomUUID().toString(); jobj.put("accountid", id); // if (jobj.has("customfield")) { // fieldManager.storeCustomFields(jcustomarray, "account", true, id); // } // jobj = StringUtil.setcreatedonDate(jobj, request); kmsg = crmAccountDAOObj.addAccounts(jobj); 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("modulerecid", id); customrequestParams.put("companyid", companyid); customrequestParams.put("customdataclasspath", Constants.Crm_account_custom_data_classpath); acc = (CrmAccount) kmsg.getEntityList().get(0); if (jobj.has("customfield")) { KwlReturnObject customDataresult = fieldDataManagercntrl.setCustomData(customrequestParams); if (customDataresult != null && customDataresult.getEntityList().size() > 0) { jobj.put("CrmAccountCustomDataobj", id); kmsg = crmAccountDAOObj.editAccounts(jobj); } // fieldManager.storeCustomFields(jcustomarray,"account",true,id); } // 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_account_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(Constants.AUTOCUSTOMFIELD, autoNoData); } // END logic - auto no if (acc.getValidflag() == 1) { auditTrailDAOObj.insertAuditLog(AuditAction.ACCOUNT_CREATE, ((acc.getAccountname() == null) ? "" : acc.getAccountname()) + " - Account created ", request, id); } } else { // check if account owner changed String mainownerId = crmAccountHandler.getMainAccOwner(crmAccountDAOObj, id); if (!StringUtil.isNullOrEmpty(mainownerId)) { if (!mainownerId.equals(jobj.optString("accountownerid", mainownerId))) { ownerChanged = true; } } operationCode = CrmPublisherHandler.UPDATERECORDCODE; 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("modulerecid", id); customrequestParams.put("companyid", companyid); customrequestParams.put("customdataclasspath", Constants.Crm_account_custom_data_classpath); KwlReturnObject customDataresult = fieldDataManagercntrl.setCustomData(customrequestParams); if (customDataresult != null && customDataresult.getEntityList().size() > 0) { jobj.put("CrmAccountCustomDataobj", id); } } if (jobj.has("createdon")) { jobj.put("createdon", jobj.getLong("createdon")); } kmsg = crmAccountDAOObj.editAccounts(jobj); 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"))) { if (arrayId[0].equals("0")) crmCommonService.validateMassupdate(new String[] { acc.getAccountid() }, "Account", companyid); else crmCommonService.validateMassupdate(arrayId, "Account", companyid); cometObj.put("accountid", accountIds); cometObj.put("ismassedit", true); } myjobj.put("success", true); myjobj.put("ID", acc.getAccountid()); myjobj.put("createdon", jobj.has("createdon") ? jobj.getLong("createdon") : ""); cometObj.put("createdon", acc.getCreatedon()); myjobj.put("updatedon", jobj.has("updatedon") ? jobj.getLong("updatedon") : ""); myjobj.put(Constants.AUTOCUSTOMFIELD, jobj.has(Constants.AUTOCUSTOMFIELD) ? jobj.getJSONArray(Constants.AUTOCUSTOMFIELD) : ""); cometObj.put("updatedon", acc.getUpdatedon()); cometObj.put(Constants.AUTOCUSTOMFIELD, jobj.has(Constants.AUTOCUSTOMFIELD) ? jobj.getJSONArray(Constants.AUTOCUSTOMFIELD) : ""); publishAccountModuleInformation(request, cometObj, operationCode, companyid, userid); if (sessionHandlerImpl.getCompanyNotifyOnFlag(request)) {// send Notification if set flag at company level if (ownerChanged) {// Send Notification if owner changed List<String> recepients = new ArrayList(); recepients.add(jobj.getString("accountownerid")); Map refTypeMap = new HashMap(); Map refIdMap = new HashMap(); refIdMap.put("refid1", acc.getAccountid()); refTypeMap.put("reftype1", Constants.Crm_account_classpath); refIdMap.put("refid2", userid); refTypeMap.put("reftype2", Constants.USERS_CLASSPATH); 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)); if (recepients.size() > 0) { NotificationManagementServiceDAO.sendNotificationRequest(CHANNEL.EMAIL, ACCOUNT_ASSIGNED, NOTIFICATIONSTATUS.REQUEST, userid, recepients, refIdMap, refTypeMap, extraParams); } } } } catch (Exception e) { logger.warn(e.getMessage()); txnManager.rollback(status); } return new ModelAndView("jsonView", "model", myjobj.toString()); }
From source file:com.krawler.spring.crm.accountModule.crmAccountController.java
public ModelAndView newAccount(HttpServletRequest request, HttpServletResponse response) throws ServletException { JSONObject myjobj = new JSONObject(); JSONObject jobj = new JSONObject(); KwlReturnObject kmsg = null;// ww w . j a va2 s .c o m 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 = request.getParameter("userid"); String accountname = request.getParameter("accountname"); String website = request.getParameter("website"); String description = request.getParameter("description"); String contactno = request.getParameter("contactno"); String revenue = request.getParameter("revenue"); String id = java.util.UUID.randomUUID().toString(); String companyid = sessionHandlerImpl.getCompanyid(request); jobj.put("accountid", id); jobj.put("accountownerid", userid); jobj.put("companyid", companyid); jobj.put("userid", userid); jobj.put("accountname", accountname); jobj.put("revenue", revenue); jobj.put("phone", contactno); jobj.put("description", description); jobj.put("website", website); jobj.put("validflag", 1); jobj.put("tzdiff", sessionHandlerImpl.getTimeZoneDifference(request)); // jobj.put("createdon", new Date()); kmsg = crmAccountDAOObj.addAccounts(jobj); acc = (CrmAccount) kmsg.getEntityList().get(0); myjobj.put("success", true); myjobj.put("ID", acc.getAccountid()); myjobj.put("validflag", acc.getValidflag()); myjobj.put("accountname", acc.getAccountname()); txnManager.commit(status); } 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 repAccount(HttpServletRequest request, HttpServletResponse response) throws ServletException { JSONObject myjobj = new JSONObject(); String jsondata = request.getParameter("val"); KwlReturnObject kmsg = null;/*from w w w.j a va2 s . c om*/ CrmAccount acc = null; JSONObject jobj; //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 { jobj = new JSONObject(jsondata); JSONArray jarr = new JSONArray(); jarr = jobj.getJSONArray("userdata"); for (int ctr = 0; ctr < jarr.length(); ctr++) { jobj = jarr.getJSONObject(ctr); String contactno = jobj.getString("contactno"); jobj.put("phone", contactno); jobj.put("tzdiff", sessionHandlerImpl.getTimeZoneDifference(request)); kmsg = crmAccountDAOObj.editAccounts(jobj); acc = (CrmAccount) kmsg.getEntityList().get(0); } myjobj.put("success", true); myjobj.put("ID", acc.getAccountid()); txnManager.commit(status); } 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()); }