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.leadModule.crmLeadCommonController.java
public ModelAndView convertLeads(HttpServletRequest request, HttpServletResponse response) throws ServletException { JSONObject myjobj = null;/*from w ww .j a v a 2 s.c o m*/ boolean refNotFoundFlag = false; String refNotFoundStr = ""; KwlReturnObject kmsg = null; CrmLead lead = null; CrmAccount acc = null; CrmOpportunity opp = null; String contactid = null; boolean b = 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); JSONObject accModulejObj = new JSONObject(); JSONObject oppModulejObj = new JSONObject(); JSONObject contactModulejObj = new JSONObject(); JSONObject resJson = new JSONObject(); try { Map<String, Object> moduleFields = new HashMap<String, Object>(); Map<String, Object> columnMappedList = new HashMap<String, Object>(); JSONArray moduleCustomfieldArray; myjobj = new JSONObject(); myjobj.put("success", false); String timeZoneDiff = sessionHandlerImpl.getTimeZoneDifference(request); String timeFormatId = sessionHandlerImpl.getUserTimeFormat(request); boolean convertedflag = true; boolean companyNotifyFlag = sessionHandlerImpl.getCompanyNotifyOnFlag(request); // extract ip address String ipAddress = SystemUtil.getIpAddress(request); String companyid = sessionHandlerImpl.getCompanyid(request); if (StringUtil.bNull(request.getParameter("jsondata"))) { String userid = sessionHandlerImpl.getUserid(request); String conversiontype = " "; String jsondata = request.getParameter("jsondata"); JSONArray jarr = new JSONArray("[" + jsondata + "]"); JSONObject jobj = jarr.getJSONObject(0); String leadid = jobj.getString("leadid"); CrmLead CrmLeadObj = crmLeadDAOObj.getLead(leadid); if (CrmLeadObj == null || CrmLeadObj.getIsconverted().equals("1")) { convertedflag = false; refNotFoundStr = " Selected lead already converted successfully."; } if (convertedflag) { String accflag = jobj.getString("accflag"); String conflag = jobj.optString("conflag"); String oppflag = jobj.getString("oppflag"); String taskflag = jobj.getString("taskflag"); Long closingdate = jobj.getLong("closingdate"); String lastname = jobj.getString("lastname"); String accountname = jobj.getString("accountname"); String oppParentaccountid = jobj.getString("oppparentaccountid"); String oppname = jobj.getString("oppname"); String oppstageid = jobj.getString("oppstageid"); String validflag = jobj.getString("validflag"); String leadType = jobj.getString("type"); boolean transfer = false; String details = ""; String accid = java.util.UUID.randomUUID().toString(); // check all mandatory column mapped resJson.put("success", true); if (accflag.equals("1")) { accModulejObj = getModuleRecord(request, Constants.MODULE_ACCOUNT, companyid, jobj, moduleFields, columnMappedList); checkManadatoryColumnMapped(resJson, Constants.MODULE_ACCOUNT, companyid, moduleFields, columnMappedList); } if (oppflag.equals("1")) { oppModulejObj = getModuleRecord(request, Constants.MODULE_OPPORTUNITY, companyid, jobj, moduleFields, columnMappedList); // check all mandatory column mapped checkManadatoryColumnMapped(resJson, Constants.MODULE_OPPORTUNITY, companyid, moduleFields, columnMappedList); } if (conflag.equals("1")) { contactModulejObj = getModuleRecord(request, Constants.MODULE_CONTACT, companyid, jobj, moduleFields, columnMappedList); // check all mandatory column mapped checkManadatoryColumnMapped(resJson, Constants.MODULE_CONTACT, companyid, moduleFields, columnMappedList); } if (!resJson.getBoolean("success")) { refNotFoundFlag = true; refNotFoundStr = resJson.getString("msg"); } if (!refNotFoundFlag) { // Convert into Account if (accflag.equals("1")) { conversiontype = "1"; refNotFoundStr = ""; if (accModulejObj.getBoolean("success")) { accModulejObj.put("accountname", accountname); accModulejObj.put("leadid", leadid); accModulejObj.put("companyid", companyid); accModulejObj.put("userid", userid); accModulejObj.put("updatedon", new Date()); accModulejObj.put("accountid", accid); accModulejObj.put("validflag", "0"); accModulejObj.put("tzdiff", timeZoneDiff); kmsg = crmAccountDAOObj.addAccounts(accModulejObj); moduleCustomfieldArray = accModulejObj.getJSONArray("customfield"); if (moduleCustomfieldArray.length() > 0) { KwlReturnObject customDataresult = fieldDataManagercntrl.setcustomdata( moduleCustomfieldArray, Constants.Crm_account_moduleid, accid, companyid, true); if (customDataresult != null && customDataresult.getEntityList().size() > 0) { JSONObject accJObj = new JSONObject(); accJObj.put("accountid", accid); accJObj.put("CrmAccountCustomDataobj", accid); accJObj.put("tzdiff", timeZoneDiff); kmsg = crmAccountDAOObj.editAccounts(accJObj); } // fieldManager.storeCustomFields(moduleCustomfieldArray,"account",true,accid,"1"); } crmCommentDAOObj.CreateDuplicateComments(leadid, accid); documentConversion(leadid, accid, "4"); auditTrailDAOObj.insertAuditLog(AuditAction.ACCOUNT_CREATE, accountname + " - Account created from Lead - " + lastname, request, accid); acc = (CrmAccount) kmsg.getEntityList().get(0); //Save Account Owner saveAccOwnersFromLead(leadid, accid); details += " Account - [ " + accountname + " ], "; if (oppflag.equals("1")) { transfer = false; } else { transfer = true; } if (leadType.equals("1")) { // checked for Lead Type - if Company then associated contacts must be linked with newly added Account linkLeadsContactsToAccount(leadid, accid, userid, companyid, timeZoneDiff, ipAddress); } } else { myjobj.put("success", false); refNotFoundStr += "Data not found in Account module for following fields - <BR /> " + accModulejObj.getString("msg") + "<BR /><BR />"; refNotFoundFlag = true; } // Add Activity if (taskflag.equals("1")) { if (StringUtil.bNull(request.getParameter("activitydata"))) { String activityjson = request.getParameter("activitydata"); JSONObject activityJSON = new JSONObject(activityjson); activityJSON.put("relatedtoid", Constants.MODULE_ACCOUNT); activityJSON.put("relatedtonameid", accid); String loginURL = URLUtil.getRequestPageURL(request, Links.loginpageFull); String partnerName = sessionHandlerImpl.getPartnerName(request); activityManagementService.saveActivity(companyid, userid, timeFormatId, timeZoneDiff, ipAddress, activityJSON, companyNotifyFlag, loginURL, partnerName); } } } String oppid = java.util.UUID.randomUUID().toString(); // Convert into Opportunity if (oppflag.equals("1")) { conversiontype = "2"; if (oppModulejObj.getBoolean("success")) { oppModulejObj.put("oppid", oppid); oppModulejObj.put("companyid", companyid); oppModulejObj.put("userid", userid); oppModulejObj.put("updatedon", new Date().getTime()); oppModulejObj.put("tzdiff", timeZoneDiff); // oppJObj.put("createdon", new Date()); oppModulejObj.put("leadid", leadid); if (accflag.equals("1")) { oppModulejObj.put("accountnameid", accid); } else { oppModulejObj.put("accountnameid", oppParentaccountid); } // String timeFormatId = sessionHandlerImpl.getUserTimeFormat(request); // String timeZoneDiff = sessionHandlerImpl.getTimeZoneDifference(request); if (jobj.has("closingdate")) { oppModulejObj.put("closingdate", jobj.getLong("closingdate")); } oppModulejObj.put("validflag", "0"); oppModulejObj.put("oppstageid", oppstageid); oppModulejObj.put("currencyid", "0"); oppModulejObj.put("oppname", oppname); kmsg = crmOpportunityDAOObj.addOpportunities(oppModulejObj); moduleCustomfieldArray = oppModulejObj.getJSONArray("customfield"); if (moduleCustomfieldArray.length() > 0) { // fieldManager.storeCustomFields(moduleCustomfieldArray,"opportunity",true,oppid,"5"); KwlReturnObject customDataresult = fieldDataManagercntrl.setcustomdata( moduleCustomfieldArray, Constants.Crm_opportunity_moduleid, oppid, companyid, true); if (customDataresult != null && customDataresult.getEntityList().size() > 0) { JSONObject oppJObj = new JSONObject(); oppJObj.put("oppid", oppid); oppJObj.put("CrmOpportunityCustomDataobj", oppid); oppJObj.put("tzdiff", timeZoneDiff); kmsg = crmOpportunityDAOObj.editOpportunities(oppJObj); } } opp = (CrmOpportunity) kmsg.getEntityList().get(0); //Save Opportunity Owner saveOppOwnersFromLead(leadid, oppid); crmCommentDAOObj.CreateDuplicateComments(leadid, oppid); documentConversion(leadid, oppid, "5"); auditTrailDAOObj.insertAuditLog(AuditAction.OPPORTUNITY_CREATE, oppname + " - Opportunity created from Lead - " + lastname, request, oppid); details += "Opportunity [ " + oppname + " ], "; if (accflag.equals("1")) { // transfer = true; } b = true; } else { myjobj.put("success", false); refNotFoundStr += "Data not found in Opportunity module for following fields - <BR /> " + oppModulejObj.getString("msg") + "<BR /><BR />"; refNotFoundFlag = true; } } // Convert into Contact if (conflag.equals("1")) { if (leadType.equals("0")) { // checked for Lead Type - if Company then don't convert to contact if (contactModulejObj.getBoolean("success")) { // conversiontype="3"; contactModulejObj.put("leadid", leadid); if (accflag.equals("1")) { contactModulejObj.put("accountid", accid); } else if (oppflag.equals("1")) { contactModulejObj.put("accountid", oppParentaccountid); } contactModulejObj.put("validflag", "0"); // add new contact JSONObject contactJson = contactManagementService.saveContact(companyid, userid, timeZoneDiff, ipAddress, contactModulejObj); contactid = contactJson.getString("ID"); moduleCustomfieldArray = contactModulejObj.getJSONArray("customfield"); if (moduleCustomfieldArray.length() > 0) { // fieldManager.storeCustomFields(moduleCustomfieldArray,"contact",true,conid,"6"); KwlReturnObject customDataresult = fieldDataManagercntrl.setcustomdata( moduleCustomfieldArray, Constants.Crm_contact_moduleid, contactid, companyid, true); if (customDataresult != null && customDataresult.getEntityList().size() > 0) { JSONObject contactJObj = new JSONObject(); contactJObj.put("contactid", contactid); contactJObj.put("CrmContactCustomDataobj", contactid); contactJObj.put("tzdiff", timeZoneDiff); contactJson = contactManagementService.saveContact(companyid, userid, timeZoneDiff, ipAddress, contactJObj); } } //Save Contact Owner saveContactOwnersFromLead(leadid, contactid); // auditTrailDAOObj.insertAuditLog(AuditAction.CONTACT_CREATE, // firstname + " " + lastname + " - Contact created from Lead - "+kmsg.getEntityList().getFirstname()+" "+leadd.getLastname(), // request, conid); String firstname = ""; String contactName = ""; String lName = ""; if (contactModulejObj.has("firstname")) { firstname = contactModulejObj.get("firstname").toString().trim(); } if (contactModulejObj.has("lastname")) { lName = contactModulejObj.get("lastname").toString().trim(); } contactName = (firstname + " " + lName).trim(); crmCommentDAOObj.CreateDuplicateComments(leadid, contactid); documentConversion(leadid, contactid, "2"); auditTrailDAOObj.insertAuditLog(AuditAction.CONTACT_CREATE, contactName + " - Contact created from Lead - " + lastname, request, contactid); if (oppflag.equals("1")) { transfer = false; } else { transfer = true; } b = true; } else { myjobj.put("success", false); refNotFoundStr += "Data not found in Contact module for following fields - <BR /> " + contactModulejObj.getString("msg") + "<BR /><BR />"; refNotFoundFlag = true; } } else { if (accflag.equals("1")) { accid = acc.getAccountid(); } else if (oppflag.equals("1")) { if (opp.getCrmAccount() != null) accid = opp.getCrmAccount().getAccountid(); else accid = ""; } else { accid = ""; } updateContacts(leadid, accid, timeZoneDiff, ipAddress); } } } if (!refNotFoundFlag) { kmsg = crmManagerDAOObj.getMasterIDCompany(companyid, Constants.LEADSTATUSID_QUALIFIED); DefaultMasterItem obj = (DefaultMasterItem) kmsg.getEntityList().get(0); JSONObject leadJObj = new JSONObject(); if (transfer) { leadJObj.put("istransfered", "1"); } leadJObj.put("leadid", leadid); leadJObj.put("leadstatusid", obj.getID()); leadJObj.put("conversiontype", conversiontype); leadJObj.put("leadconversiondate", conversiontype); leadJObj.put("isconverted", "1"); leadJObj.put("updatedon", new Date()); leadJObj.put("tzdiff", timeZoneDiff); kmsg = crmLeadDAOObj.editLeads(leadJObj); lead = (CrmLead) kmsg.getEntityList().get(0); auditTrailDAOObj.insertAuditLog(AuditAction.LEAD_CONVERT, details + " created by converting Lead - " + lead.getLastname(), request, leadid); b = true; myjobj.put("success", b); } } // end of if } if (!refNotFoundFlag && convertedflag) { txnManager.commit(status); if (acc != null) crmCommonDAOObj.validaterecorsingledHB("Account", acc.getAccountid(), companyid); if (opp != null) crmCommonDAOObj.validaterecorsingledHB("Opportunity", opp.getOppid(), companyid); if (contactid != null) crmCommonDAOObj.validaterecorsingledHB("Contact", contactid, companyid); } else { myjobj.put("msg", refNotFoundStr); txnManager.rollback(status); } } catch (JSONException e) { txnManager.rollback(status); logger.warn(e.getMessage(), e); } catch (Exception e) { txnManager.rollback(status); logger.warn(e.getMessage(), e); } return new ModelAndView(successView, "model", myjobj.toString()); }
From source file:com.krawler.spring.crm.leadModule.crmLeadCommonController.java
public ModelAndView saveEditWTLForm(HttpServletRequest request, HttpServletResponse response) throws ServletException { JSONObject jobj = new JSONObject(); //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 {/*from w ww . j av a2s. co m*/ String formfields = request.getParameter("formfields"); String formname = request.getParameter("formname"); String formdomain = request.getParameter("formdomain"); String redirecturl = request.getParameter("redirectURL"); String leadowner = request.getParameter("leadowner"); String companyid = sessionHandlerImpl.getCompanyid(request); String formid = request.getParameter("formid"); jobj = webtoLeadFormHandlerObj.saveEditWTLForm(formname, formdomain, redirecturl, formfields, companyid, formid, leadowner); txnManager.commit(status); } catch (Exception e) { txnManager.rollback(status); logger.warn(e.getMessage(), e); } return new ModelAndView(successView, "model", jobj.toString()); }
From source file:com.krawler.spring.crm.leadModule.crmLeadCommonController.java
public ModelAndView deleteWTLForm(HttpServletRequest request, HttpServletResponse response) throws ServletException { JSONObject jobj = new JSONObject(); //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 {//from w w w. ja v a 2 s .c o m String formid = request.getParameter("formid"); jobj = webtoLeadFormHandlerObj.deleteWTLForm(formid); txnManager.commit(status); } catch (Exception e) { txnManager.rollback(status); logger.warn(e.getMessage(), e); } return new ModelAndView(successView, "model", jobj.toString()); }
From source file:com.krawler.spring.crm.leadModule.crmLeadCommonController.java
public ModelAndView getWebtoleadFormlist(HttpServletRequest request, HttpServletResponse response) throws ServletException { JSONObject jobjresult = new JSONObject(); //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); KwlReturnObject kmsg = null;// ww w . j a va 2 s . c o m try { String dateFormatId = sessionHandlerImpl.getDateFormatID(request); String timeFormatId = sessionHandlerImpl.getUserTimeFormat(request); String timeZoneDiff = sessionHandlerImpl.getTimeZoneDifference(request); String companyid = sessionHandlerImpl.getCompanyid(request); HashMap<String, Object> requestParams = new HashMap<String, Object>(); requestParams.put("companyid", companyid); if (request.getParameter("ss") != null && !StringUtil.isNullOrEmpty(request.getParameter("ss"))) { requestParams.put("ss", request.getParameter("ss")); } requestParams.put("start", StringUtil.checkForNull(request.getParameter("start"))); requestParams.put("limit", StringUtil.checkForNull(request.getParameter("limit"))); kmsg = webtoLeadFormHandlerObj.getWebtoleadFormlist(requestParams); Iterator itr = kmsg.getEntityList().iterator(); while (itr.hasNext()) { JSONObject jobj = new JSONObject(); webtoleadform wtlformObj = (webtoleadform) itr.next(); jobj.accumulate("formname", wtlformObj.getFormname()); jobj.accumulate("formdomain", wtlformObj.getFormdomain()); jobj.accumulate("redirecturl", wtlformObj.getRedirecturl()); jobj.accumulate("formid", wtlformObj.getFormid()); jobj.accumulate("lastupdatedon", kwlCommonTablesDAOObj.getUserDateFormatter(dateFormatId, timeFormatId, timeZoneDiff) .format(wtlformObj.getLastupdatedon())); jobj.accumulate("formfields", wtlformObj.getFormfield()); jobj.accumulate("leadowner", ((User) wtlformObj.getLeadowner()).getUserID()); jobjresult.append("data", jobj); } if (!jobjresult.has("data")) { jobjresult.put("data", ""); } jobjresult.accumulate("totalCount", kmsg.getRecordTotalCount()); jobjresult.accumulate("success", true); txnManager.commit(status); } catch (Exception e) { txnManager.rollback(status); logger.warn(e.getMessage(), e); } return new ModelAndView(successView, "model", jobjresult.toString()); }
From source file:com.krawler.spring.crm.leadModule.crmLeadCommonController.java
public ModelAndView storeLead(HttpServletRequest request, HttpServletResponse response) throws ServletException { String result = "Problem while submitting your form."; HashMap model = new HashMap(); Map paramMap1 = (java.util.Map) request.getParameterMap(); HashMap paramMap = new HashMap(); User user = null;//www . j ava 2 s. c om User sender = 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 { model.put("successFlag", "1"); model.put("redirectFlag", "0"); String successMsg = "Thank you for submitting your information."; String val = ""; int mtyfieldCntr = 0; Set arrayKeys = paramMap1.keySet(); HashMap fieldMap = new HashMap(); JSONObject fieldJSON = null; if (!StringUtil.isNullOrEmpty(request.getParameter("fieldJSON"))) { try { fieldJSON = new JSONObject(request.getParameter("fieldJSON")); } catch (JSONException je) { logger.warn("crmLeadCommonController.storeLead :- " + je.getMessage()); } finally { fieldJSON = null; } } HashMap<String, Object> mailFieldsMap = new HashMap<String, Object>(); HashMap<String, Object> mailValueMap = new HashMap<String, Object>(); for (Object key : arrayKeys) { if (((String) key).startsWith("wl_")) { fieldMap.put(key, paramMap1.get((String) key) != null ? new String[] { StringUtil.serverHTMLStripper(((String[]) paramMap1.get((String) key))[0]) } : null); if (paramMap1.get((String) key) != null) { val = StringUtil.serverHTMLStripper(((String[]) paramMap1.get((String) key))[0]); if (val.trim().equals("")) { mtyfieldCntr++; } } } } if (mtyfieldCntr != fieldMap.size()) { paramMap.putAll(paramMap1); paramMap.putAll(fieldMap); String subdomain = URLUtil.getDomainName(request); String companyid = companyDetailsDAOObj.getCompanyid(subdomain); Company company = (Company) kwlCommonTablesDAOObj.getClassObject("com.krawler.common.admin.Company", companyid); sender = company.getCreator(); String acceptURL = URLUtil.getRequestPageURL(request, Links.UnprotectedLoginPageFull) + "crm/common/acceptweblead.do"; int leadRoutingUser = 0; CompanyPreferences cmpPref = (CompanyPreferences) kwlCommonTablesDAOObj .getClassObject("com.krawler.crm.database.tables.CompanyPreferences", companyid); JSONObject companyPrefObj = crmManagerCommon.getCompanyPreferencesJSON(cmpPref, new JSONObject()); user = (User) kwlCommonTablesDAOObj.getClassObject("com.krawler.common.admin.User", ((String[]) paramMap.get("leadOwner"))[0]); if (companyPrefObj.getInt( com.krawler.common.util.Constants.SESSION_LEADROUTING) == LeadRoutingUsers.ROUNDROBIN) { user = crmManagerDAOObj.getNextLeadRoutingUsers(companyid).get(0); leadRoutingUser = LeadRoutingUsers.ROUNDROBIN; } if (companyPrefObj .getInt(com.krawler.common.util.Constants.SESSION_LEADROUTING) == LeadRoutingUsers.FCFS) { leadRoutingUser = LeadRoutingUsers.FCFS; } JSONObject resultObj = webtoLeadFormHandlerObj.storeLead(paramMap, companyid, user.getUserID(), acceptURL, leadRoutingUser); result = resultObj.optString("msg", result); if (!result.equals("Success")) { successMsg = result; model.put("successFlag", "0"); txnManager.rollback(status); } else { CrmLead l = (CrmLead) hibernateTemplate.get(CrmLead.class, resultObj.getString("leadid")); if (fieldJSON != null) { Iterator itr = fieldJSON.keys(); String keyStr = ""; String tmp = ""; String str = ""; String tmpAr = ""; int xtype = 999; String[] valuesArr = null; DefaultMasterItem defItem = null; FieldComboData fieldCombodata = null; Object invoker = null; Class cl = null; CrmLeadCustomData lcdata = null; Method setter = null; List<String> tmpProductlist = new ArrayList<String>(); while (itr.hasNext()) { keyStr = (String) itr.next(); mailFieldsMap.put(keyStr, fieldJSON.get(keyStr)); } for (String tmpStr : mailFieldsMap.keySet()) { if (tmpStr.endsWith("_DROPDOWN#")) { str = tmpStr; str = str.replace("_DROPDOWN#", ""); if (tmpStr.startsWith("custom_field")) { str = str.replace("custom_field", ""); if (paramMap.get("wl_custom_field" + str) != null) { fieldCombodata = (FieldComboData) kwlCommonTablesDAOObj.getClassObject( "com.krawler.common.admin.FieldComboData", ((String[]) paramMap.get("wl_custom_field" + str))[0]); if (fieldCombodata == null) { //Custom reference combo check- Since some custom column may have reference of default combos. defItem = (DefaultMasterItem) kwlCommonTablesDAOObj.getClassObject( "com.krawler.crm.database.tables.DefaultMasterItem", ((String[]) paramMap.get("wl_custom_field" + str))[0]); if (defItem != null) { mailValueMap.put(tmpStr, defItem.getValue()); } } else { FieldParams fieldParamObj = fieldCombodata.getField(); xtype = fieldParamObj.getFieldtype(); if (xtype == 7) { // for Multi select dropdown if (request.getParameterValues("wl_custom_field" + str) != null) { valuesArr = request.getParameterValues("wl_custom_field" + str); tmp = ""; tmpAr = ""; for (int i = 0; i < valuesArr.length; i++) { fieldCombodata = (FieldComboData) kwlCommonTablesDAOObj .getClassObject( "com.krawler.common.admin.FieldComboData", valuesArr[i]); if (i == valuesArr.length - 1) { tmp += fieldCombodata.getValue(); tmpAr += valuesArr[i]; } else { tmp += fieldCombodata.getValue() + ","; tmpAr += valuesArr[i] + ","; } } mailValueMap.put(tmpStr, tmp); //Since multiselect combo list has not been saved becoz parammap contains only single value as there are multiple values selected if (((String[]) paramMap.get( "wl_custom_field" + str)).length < valuesArr.length) { try { lcdata = l.getCrmLeadCustomDataobj(); cl = Class.forName( "com.krawler.crm.database.tables.CrmCustomData"); invoker = (Object) lcdata; setter = cl.getMethod( "setCol" + fieldParamObj.getColnum(), String.class); setter.invoke(invoker, tmpAr); l.setCrmLeadCustomDataobj((CrmLeadCustomData) invoker); } catch (Exception e) { logger.warn(e.getMessage()); } } } else mailValueMap.put(tmpStr, ""); } else { fieldCombodata = (FieldComboData) kwlCommonTablesDAOObj .getClassObject("com.krawler.common.admin.FieldComboData", ((String[]) paramMap .get("wl_custom_field" + str))[0]); mailValueMap.put(tmpStr, fieldCombodata.getValue()); } } } else { mailValueMap.put(tmpStr, ""); } } else if (tmpStr.startsWith("productid")) { if (request.getParameterValues("wl_" + str) != null) { valuesArr = request.getParameterValues("wl_" + str); tmp = ""; for (int n = 0; n < valuesArr.length; n++) { if (!tmpProductlist.isEmpty()) { tmpProductlist.remove(0); } tmpProductlist.add(valuesArr[n]); tmp += ((crmProductDAOObj.getProducts(tmpProductlist)).get(0)) .getProductname() + ","; } tmp = tmp.substring(0, tmp.lastIndexOf(',')); mailValueMap.put(tmpStr, tmp); if (((String[]) paramMap.get("wl_productid")).length < valuesArr.length) { //Since products list has not been saved becoz parammap contains only single value as there are multiple values selected try { crmLeadDAOObj.saveLeadProducts(new String[] { l.getLeadid() }, valuesArr); } catch (Exception ex) { logger.warn(ex.getMessage()); } } } else mailValueMap.put(tmpStr, ""); } else if (tmpStr.startsWith("type")) { tmp = ((String[]) paramMap.get("wl_" + str))[0]; if (tmp == "1") mailValueMap.put(tmpStr, "Company"); else mailValueMap.put(tmpStr, "Individual"); } else { defItem = (DefaultMasterItem) kwlCommonTablesDAOObj.getClassObject( "com.krawler.crm.database.tables.DefaultMasterItem", ((String[]) paramMap.get("wl_" + str))[0]); if (defItem != null) mailValueMap.put(tmpStr, defItem.getValue()); else mailValueMap.put(tmpStr, ""); } } else mailValueMap.put(tmpStr, ((String[]) paramMap.get("wl_" + tmpStr))[0] != null ? ((String[]) paramMap.get("wl_" + tmpStr))[0] : ""); } } String id = java.util.UUID.randomUUID().toString(); String ipaddr = null; if (StringUtil.isNullOrEmpty(request.getHeader("x-real-ip"))) { ipaddr = request.getRemoteAddr(); } else { ipaddr = request.getHeader("x-real-ip"); } auditTrailDAOObj .insertAuditLog(AuditAction.LEAD_CREATE, ((l.getLastname() == null) ? "" : l.getLastname()) + " - Lead created through Web to Lead Form ", ipaddr, user.getUserID(), id); crmCommonDAOObj.validaterecorsingledHB(Constants.MODULE_LEAD, l.getLeadid(), companyid); txnManager.commit(status); if (resultObj.has("leadid")) { String leadid = resultObj.getString("leadid"); if (leadRoutingUser == LeadRoutingUsers.ROUNDROBIN) { crmManagerDAOObj.setLastUsedFlagForLeadRouting(user.getUserID(), companyid); if (fieldJSON != null) sendMailToLeadOwner(user, leadid, mailFieldsMap, mailValueMap); else sendMailToLeadOwner(user, leadid, null, null); } else if (leadRoutingUser == LeadRoutingUsers.FCFS) { List<String> recepients = new ArrayList(); KwlReturnObject kmsg = crmManagerDAOObj.getAssignedLeadRoutingUsers(companyid, new HashMap<String, Object>()); List<User> userlist = kmsg.getEntityList(); for (User userObj : userlist) { recepients.add(userObj.getUserID()); } Map refTypeMap = new HashMap(); Map refIdMap = new HashMap(); refIdMap.put("refid1", leadid); refTypeMap.put("reftype1", Constants.Crm_lead_classpath); HashMap<String, Object> extraParams = new HashMap<String, Object>(); extraParams.put(NotificationConstants.LOGINURL, acceptURL); if (recepients.size() > 0) { String platformUrl = ConfigReader.getinstance().get("platformURL"); if (platformUrl != null) { getPartnerURL(platformUrl, company, CHANNEL.EMAIL, NOTIFICATIONSTATUS.REQUEST, company.getCreator().getUserID(), recepients, refIdMap, refTypeMap, extraParams); } else { extraParams.put(NotificationConstants.PARTNERNAME, company.getCompanyName()); sendMailToAssignedLeadRoutingUsers(CHANNEL.EMAIL, NOTIFICATIONSTATUS.REQUEST, company.getCreator().getUserID(), recepients, refIdMap, refTypeMap, extraParams); } } } else { if (fieldJSON != null) sendMailToLeadOwner(user, leadid, mailFieldsMap, mailValueMap); else sendMailToLeadOwner(user, leadid, null, null); } } } model.put("successMsg", successMsg); String returnurl = request.getParameter("returnurl"); if (!StringUtil.isNullOrEmpty(returnurl)) { model.put("redirectFlag", "1"); model.put("returnurl", returnurl); } } else { model.put("successMsg", "Form should not be empty"); model.put("successFlag", "0"); txnManager.rollback(status); } } catch (Exception e) { txnManager.rollback(status); logger.warn(e.getMessage(), e); if (user != null) { sender = user; } if (sender != null) { sendMailToLeadOwner(sender, paramMap1); } } return new ModelAndView("captureLead", "model", model); }
From source file:com.krawler.spring.crm.leadModule.crmLeadCommonController.java
public ModelAndView acceptweblead(HttpServletRequest request, HttpServletResponse response) throws ServletException { String result = "Problem while handling your request."; //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 {//w w w . j ava 2s. c o m String userid = request.getParameter("userid"); String leadid = request.getParameter("leadid"); boolean isAlreadyAssigned = crmLeadDAOObj.checkWebLeadAssignedOwner(leadid); String replaceStr = "<p id='unsubContent'><p>Lead has been successfully allocated to you and can be viewed in your lead list.</p>"; String headerContent = "<head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'>" + "<title>New Web Lead</title>" + "<style type='text/css'>" + "body {font-family: 'trebuchet MS', tahoma, verdana, arial, helvetica, sans-serif;" + "background-color: #eee;margin: 0;} " + "#content {width: 100%;position:absolute;padding:20px;top:5%;}" + ".content {width: 600px;margin:auto;padding:20px;border:10px solid #ccc;background-color: white;}" + ".alert {font-size:20px;line-height:200%;font-family:Arial;font-weight:bold;}" + "p, label, .formText {line-height:150%;font-family:Arial;font-size: 14px;color: #333333;}" + "</style>" + "</head>"; if (isAlreadyAssigned) { replaceStr = "<p id='unsubContent'><p>Sorry, lead cannot be allocated as it has been already allocated to a different team member.</p>"; } else { String oldOwnerId = crmLeadDAOObj.confirmWebLeadOwner(leadid, userid); if (!StringUtil.isNullOrEmpty(oldOwnerId) && !oldOwnerId.equals(userid)) { User oldOwner = (User) kwlCommonTablesDAOObj.getClassObject("com.krawler.common.admin.User", oldOwnerId); User newOwner = (User) kwlCommonTablesDAOObj.getClassObject("com.krawler.common.admin.User", userid); CrmLead lead = (CrmLead) kwlCommonTablesDAOObj .getClassObject("com.krawler.crm.database.tables.CrmLead", leadid); String recipients = oldOwner.getEmailID(); String subject = oldOwner.getCompany().getCompanyName() + " CRM - Web lead has been allocated to " + StringUtil.getFullName(newOwner); String mailbodyContent = "Hi %s,<p>Following web lead has been allocated to %s</p><p>Lead Name: %s</p><p>Phone Number: %s</p>" + "<p>Email Address: %s</p><p>Please Note that lead will not be displayed in your list.</p>" + "<p></p><p>- Thanks,</p><p>Administrator</p>"; String mailbody = String.format(mailbodyContent, StringUtil.getFullName(oldOwner), StringUtil.getFullName(newOwner), (lead.getFirstname() + " " + lead.getLastname()).trim(), lead.getPhone(), lead.getEmail()); String htmlmsg = "<html><head><link rel='shortcut icon' href='../../images/deskera/deskera.png'/><title>New Web Lead</title></head><style type='text/css'>" + "a:link, a:visited, a:active {\n" + " color: #03C;" + "}\n" + "body {\n" + " font-family: Arial, Helvetica, sans-serif;" + " color: #000;" + " font-size: 13px;" + "}\n" + "</style><body>" + " <div>" + mailbody + " </div></body></html>"; String pmsg = htmlmsg; String fromAddress = newOwner.getCompany().getCreator().getEmailID(); SendMailHandler.postMail(new String[] { recipients }, subject, htmlmsg, pmsg, fromAddress, ""); } } String bodyContent = "<body>" + "<div id='content'><div id=unsubThankYouPage class='content'>" + "<div class='alert' id='unsubTitle'>New Web Lead</div>" + replaceStr + "</p></div></div>" + "</div>" + "</body>"; result = "<html><link rel='shortcut icon' href='../../images/deskera/deskera.png'/>" + headerContent + bodyContent + "</html>"; txnManager.commit(status); } catch (Exception e) { txnManager.rollback(status); logger.warn(e.getMessage(), e); e.printStackTrace(); } return new ModelAndView("chartView", "model", result); }
From source file:com.krawler.spring.crm.spreadSheet.spreadSheetController.java
public ModelAndView saveModuleRecordStyle(HttpServletRequest request, HttpServletResponse response) throws ServletException { boolean success = 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 {/*from w w w.j a va2 s .c o m*/ if (StringUtil.bNull(request.getParameter("jsondata"))) { String jsondata = request.getParameter("jsondata"); JSONArray jarr = new JSONArray(jsondata); String classname = "com.krawler.crm.database.tables.Crm" + request.getParameter("module"); for (int i = 0; i < jarr.length(); i++) { JSONObject jo = jarr.getJSONObject(i); spreadsheetService.saveModuleRecordStyle(jo.getString("id"), classname, jo.getString("cellStyle")); } } txnManager.commit(status); success = true; } catch (Exception e) { LOG.warn(e.getMessage()); txnManager.rollback(status); } return new ModelAndView("jsonView", "model", "{success:" + success + "}"); }
From source file:com.krawler.spring.hrms.common.hrmsCommonController.java
public ModelAndView approveprofile(HttpServletRequest request, HttpServletResponse response) { HashMap<String, Object> requestParams = new HashMap<String, Object>(); KwlReturnObject result = null;/*from w w w . j ava 2s.co m*/ JSONObject jobj = new JSONObject(); JSONObject jobj1 = new JSONObject(); //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[] ids = request.getParameterValues("emp_ids"); for (int i = 0; i < ids.length; i++) { requestParams.put("userid", ids[i]); requestParams.put("status", "Approved"); requestParams.put("updated_by", sessionHandlerImplObj.getUserid(request)); requestParams.put("updated_on", new Date()); result = hrmsCommonDAOObj.addEmpprofile(requestParams); jobj.put("success", "true"); jobj1.put("valid", true); jobj1.put("data", jobj.toString()); } txnManager.commit(status); } catch (Exception ex) { ex.printStackTrace(); txnManager.rollback(status); } finally { return new ModelAndView("jsonView", "model", jobj1.toString()); } }
From source file:com.krawler.spring.hrms.common.hrmsCommonController.java
public ModelAndView terminateEmp(HttpServletRequest request, HttpServletResponse response) { String hql = ""; SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf = new SimpleDateFormat("dd-mm-yyyy"); JSONObject msg = new JSONObject(); //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 {/*w ww. j a va 2 s .c o m*/ boolean isCompanySuperAdmin = false; Empprofile e = null; String ids[] = request.getParameterValues("ids"); String masterid = request.getParameter("tercause"); String desc = ((StringUtil.isNullOrEmpty(request.getParameter("terdesc"))) ? "" : request.getParameter("terdesc")); String reldate = request.getParameter("relievedate"); Date rvdate = fmt.parse(reldate); Empprofile emp = null; UserLogin usl = null; User usr = null; Date now = new Date(); // User updatedby=(User)session.get(User.class,sessionHandlerImplObj.getUserid(request)); // User updatedby=(User)kwlCommonTablesDAOObj.getObject("com.krawler.common.admin.User", sessionHandlerImplObj.getUserid(request)); String updatedby = sessionHandlerImplObj.getUserid(request); String companyid = sessionHandlerImplObj.getCompanyid(request); for (int i = 0; i < ids.length; i++) { if (hrmsCommonDAOObj.isCompanySuperAdmin(ids[i], companyid)) { isCompanySuperAdmin = true; break; } } if (isCompanySuperAdmin) { msg.put("msg", "adminerror"); msg.put("success", true); txnManager.commit(status); return new ModelAndView("jsonView", "model", msg.toString()); } for (int i = 0; i < ids.length; i++) { e = (Empprofile) kwlCommonTablesDAOObj.getObject("com.krawler.hrms.ess.Empprofile", ids[i]); if (e != null) { if (e.getJoindate() != null) { if (e.getJoindate().after(rvdate)) { msg.put("msg", "invalidterminatedate"); msg.put("success", true); txnManager.commit(status); return new ModelAndView("jsonView", "model", msg.toString()); } } } // hql = "from Empprofile where userLogin.userID=?"; // List lst = HibernateUtil.executeQuery(session, hql, new Object[]{ids[i]}); //// usl=(UserLogin)session.get(UserLogin.class,ids[i]); // usl=(UserLogin)HibernateUtil.getPrimary("com.krawler.common.admin.UserLogin", "userID"); //// usr=(User)session.get(User.class,ids[i]); // usr=(User)HibernateUtil.getPrimary("com.krawler.common.admin.User", "userID"); // if(lst.isEmpty()){ // emp=new Empprofile(); // emp.setUserLogin(usl); // }else{ // emp=(Empprofile)session.get(Empprofile.class,ids[i]); // } // Emphistory ehst=new Emphistory(); // ehst.setUserid(usr); // ehst.setDepartment(usr.getDepartment()); // ehst.setDesignation(usr.getDesignationid()); // ehst.setSalary(usr.getSalary()); // ehst.setEmpid(usr.getEmployeeid()); // ehst.setUpdatedon(rvdate); // ehst.setJoindate(emp.getJoindate()); // ehst.setEnddate(rvdate); // ehst.setUpdatedby(updatedby); // ehst.setCategory(Emphistory.Emp_Desg_change); // emp.setTerminatedby(updatedby); // emp.setTercause((MasterData)session.get(MasterData.class,masterid)); // emp.setRelievedate(rvdate); // emp.setTerReason(desc); // emp.setTermnd(true); // usr.setDeleted(true); // session.saveOrUpdate(ehst); // session.saveOrUpdate(emp); // session.saveOrUpdate(usr); // //@@ProfileHandler.insertAuditLog(session, AuditAction.EMPLOYEE_TERMINATED, "Employee " + sessionHandlerImplObj.getFullName(usr) + " terminated by " + sessionHandlerImplObj.getFullName(session, sessionHandlerImplObj.getUserid(request)),request); HashMap<String, Object> requestParams = new HashMap<String, Object>(); if (rvdate.before(now) || rvdate.equals(now)) { requestParams.put("termnd", true); } requestParams.put("userid", ids[i]); requestParams.put("terminatedby", updatedby); requestParams.put("tercause", masterid); requestParams.put("terReason", desc); requestParams.put("relievedate", reldate); KwlReturnObject result = hrmsCommonDAOObj.addEmpprofile(requestParams); HashMap<String, Object> deleteJobj = organizationService.deleteNode(ids[i]); if (rvdate.before(now) || rvdate.equals(now)) { requestParams.clear(); requestParams.put("UserID", ids[i]); requestParams.put("Deleteflag", 1); hrmsCommonDAOObj.adduser(requestParams); } } msg.put("success", true); txnManager.commit(status); } catch (Exception e) { e.printStackTrace(); txnManager.rollback(status); } finally { return new ModelAndView("jsonView", "model", msg.toString()); } }
From source file:com.krawler.spring.hrms.common.hrmsCommonController.java
public ModelAndView saveUser(HttpServletRequest request, HttpServletResponse response) { JSONObject jobj = new JSONObject(); Integer codeid2 = null;/* w w w . j a va2 s.c om*/ KwlReturnObject result = null; String msg = ""; int roleflag = 0; String employeeIdFormat = ""; boolean isStadardEmpFormatWithIdAvilable = 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 { HashMap<String, Object> requestParams = new HashMap<String, Object>(); ArrayList filter_names = new ArrayList(), filter_values = new ArrayList(); HashMap newhm = new FileUploadHandler().getItems(request); HashMap<String, String> hm = new HashMap<String, String>(); for (Object key : newhm.keySet()) { hm.put(key.toString(), new String(newhm.get(key.toString()).toString().getBytes("iso-8859-1"), "UTF-8")); } String id = (String) hm.get("userid"); //String lastname = (String) hm.get("lastname"); //lastname = new String (lastname.getBytes ("iso-8859-1"), "UTF-8"); if (!StringUtil.isNullOrEmpty((String) hm.get("employeeid"))) { String[] codeid = ((String) hm.get("employeeid")).split("-"); for (int x = 0; x < codeid.length; x++) { if (codeid[x].matches("[0-9]*") == true) { codeid2 = Integer.parseInt(codeid[x]); } else { employeeIdFormat += (codeid[x] + "-"); } } if (employeeIdFormat.length() > 0) { employeeIdFormat = employeeIdFormat.substring(0, employeeIdFormat.length() - 1); } } if (StringUtil.isNullOrEmpty(employeeIdFormat)) employeeIdFormat = null; String companyid = sessionHandlerImplObj.getCompanyid(request); String pwd = null; if (!StringUtil.isNullOrEmpty(id)) { requestParams.clear(); // filter_names.add("employeeid"); // filter_values.add(codeid2); // // filter_names.add("userID"); // filter_values.add(id); // // filter_names.add("company.companyID"); // filter_values.add(companyid); // // requestParams.put("filter_names", filter_names); // requestParams.put("filter_values", filter_values); // // result = hrmsCommonDAOObj.getUsers(requestParams); // if (result.getEntityList().isEmpty()) { requestParams.put("employeeIdFormat", employeeIdFormat); requestParams.put("userID", id); requestParams.put("employeeid", codeid2); requestParams.put("request", request); isStadardEmpFormatWithIdAvilable = isStadardEmpFormatWithIdAvilable(requestParams); String standardEmpId = getStadardEmpFormat(requestParams); if (standardEmpId != null && employeeIdFormat != null && standardEmpId.equals(employeeIdFormat)) { employeeIdFormat = null; } requestParams.clear(); filter_names.clear(); filter_values.clear(); filter_names.add("employeeid"); filter_values.add(codeid2); if (employeeIdFormat == null) { filter_names.add("IS employeeIdFormat"); } else { filter_names.add("employeeIdFormat"); filter_values.add(employeeIdFormat); } filter_names.add("!userID"); filter_values.add(id); filter_names.add("user.company.companyID"); filter_values.add(companyid); requestParams.put("filter_names", filter_names); requestParams.put("filter_values", filter_values); result = hrmsCommonDAOObj.getUseraccount(requestParams); if (!result.getEntityList().isEmpty() || isStadardEmpFormatWithIdAvilable) { throw new Exception("Employee ID already present."); } // } requestParams.clear(); requestParams.put("id", id); if (((String) hm.get("formname")).equals("user")) { if (!StringUtil.isNullOrEmpty((String) hm.get("templateid"))) { requestParams.put("templateid", (String) hm.get("templateid")); } else { requestParams.put("templateid", " "); } } } else { requestParams.clear(); filter_names.clear(); filter_values.clear(); filter_names.add("userLogin.userName"); filter_values.add(hm.get("username")); requestParams.put("filter_names", filter_names); requestParams.put("filter_values", filter_values); result = hrmsCommonDAOObj.getUsers(requestParams); if (!result.getEntityList().isEmpty()) { throw new Exception("User name not available."); } requestParams.clear(); filter_names.clear(); filter_values.clear(); filter_names.add("employeeid"); filter_values.add(codeid2); filter_names.add("company.companyID"); filter_values.add(companyid); requestParams.put("filter_names", filter_names); requestParams.put("filter_values", filter_values); result = hrmsCommonDAOObj.getUsers(requestParams); if (!result.getEntityList().isEmpty()) { throw new Exception("Employee ID already present."); } requestParams.clear(); requestParams.put("username", hm.get("username")); pwd = AuthHandler.generateNewPassword(); requestParams.put("pwd", AuthHandler.getSHA1(pwd)); requestParams.put("companyid", companyid); } requestParams.put("fname", hm.get("firstname")); requestParams.put("lname", hm.get("lastname")); requestParams.put("emailid", hm.get("emailid")); requestParams.put("address", hm.get("address")); requestParams.put("contactno", hm.get("contactnumber")); requestParams.put("empid", codeid2); requestParams.put("employeeIdFormat", employeeIdFormat); requestParams.put("companyid", companyid); int histsave = 0; String histdept = ""; String histdesig = ""; String histsal = ""; Date saveDate = new Date(); SimpleDateFormat fmt = new SimpleDateFormat("yyyy/MM/dd"); saveDate = new Date(fmt.format(saveDate)); String updatedby = sessionHandlerImplObj.getUserid(request); Useraccount ua = (Useraccount) kwlCommonTablesDAOObj.getObject("com.krawler.common.admin.Useraccount", id); if (!StringUtil.isNullOrEmpty((String) hm.get("roleid")) && !hm.get("roleid").equals(ua.getRole().getID())) { if (ua.getRole().getID().equals("1") && hrmsCommonDAOObj.isCompanySuperAdmin(id, companyid)) {//Can't Edit role for super admin roleflag = 1; } else { String newRoleId = hm.get("roleid").toString(); if (StringUtil.equal(newRoleId, Role.COMPANY_USER)) { // Check whether new Role is Company User/ Company Employee List<Empprofile> childList = organizationChartDAOObj.getChildNode(id); // Check for child list before changing its role to Employee. if (childList.size() > 0) { roleflag = 2; } else { requestParams.put("roleid", newRoleId); } } else { requestParams.put("roleid", newRoleId); } } } if (!StringUtil.isNullOrEmpty((String) hm.get("designationid"))) { if ((MasterData) kwlCommonTablesDAOObj.getObject("com.krawler.hrms.master.MasterData", (String) hm.get("designationid")) != ua.getDesignationid()) { histdesig = (ua.getDesignationid() == null) ? "" : ua.getDesignationid().getId(); histsave = 1; } requestParams.put("designationid", hm.get("designationid")); } if (!StringUtil.isNullOrEmpty((String) hm.get("department"))) { if ((MasterData) kwlCommonTablesDAOObj.getObject("com.krawler.hrms.master.MasterData", (String) hm.get("department")) != ua.getDepartment()) { histdept = (ua.getDepartment() == null) ? "" : ua.getDepartment().getId(); if (histsave == 0) { histdesig = (ua.getDesignationid() == null) ? "" : ua.getDesignationid().getId(); } histsave = 2; } requestParams.put("department", hm.get("department")); } if (!StringUtil.isNullOrEmpty((String) hm.get("salary"))) { String tempsal = "0"; if (((String) hm.get("salary")).length() > 0) { tempsal = hm.get("salary").toString(); } if (!tempsal.equals(ua.getSalary())) { if (ua.getSalary() != null) { histsal = ua.getSalary(); } } requestParams.put("salary", tempsal); } if (!StringUtil.isNullOrEmpty((String) hm.get("accno"))) { if (((String) hm.get("accno")).length() > 0) { requestParams.put("accno", hm.get("accno")); } else { requestParams.put("accno", "0"); } } if (!StringUtil.isNullOrEmpty((String) hm.get("formatid"))) { requestParams.put("formatid", hm.get("formatid")); } String diff = null; if (!StringUtil.isNullOrEmpty((String) hm.get("tzid"))) { KWLTimeZone timeZone = (KWLTimeZone) kwlCommonTablesDAOObj .getObject("com.krawler.common.admin.KWLTimeZone", (String) hm.get("tzid")); diff = timeZone.getDifference(); requestParams.put("tzid", hm.get("tzid")); } if (!StringUtil.isNullOrEmpty((String) hm.get("aboutuser"))) { requestParams.put("aboutuser", hm.get("aboutuser")); } String imageName = ""; if (newhm.get("userimage") != null) { imageName = ((FileItem) (newhm.get("userimage"))).getName(); if (!StringUtil.isNullOrEmpty(imageName)) { requestParams.put("userimage", hm.get("userimage")); } } result = hrmsCommonDAOObj.saveUser(requestParams, RequestContextUtils.getLocale(request)); if (!StringUtil.isNullOrEmpty(imageName)) { User user = (User) result.getEntityList().get(0); String fileName = user.getImage().substring(user.getImage().lastIndexOf("/") + 1, user.getImage().length()); new FileUploadHandler().uploadImage((FileItem) (newhm.get("userimage")), fileName, StorageHandler.GetProfileImgStorePath(), 100, 100, false, false); } msg = result.getMsg(); requestParams.clear(); if (histsave == 1) { histdept = ua.getDepartment().getId(); } if (histsave == 1 || histsave == 2) { String latestUpdate = ""; HashMap<String, Object> requestParams2 = new HashMap<String, Object>(); requestParams2.put("id", id); requestParams2.put("cat", Emphistory.Emp_Desg_change); result = hrmsCommonDAOObj.getLastUpdatedHistory(requestParams2); latestUpdate = result.getEntityList().get(0).toString(); if (!latestUpdate.equals("")) { latestUpdate = latestUpdate.replace("-", "/"); requestParams.put("Joindate", fmt.parse(latestUpdate)); } requestParams.put("Department", histdept); requestParams.put("Designation", histdesig); requestParams.put("Userid", id); requestParams.put("Empid", ua.getEmployeeid()); requestParams.put("Updatedon", saveDate); requestParams.put("Updatedby", updatedby); requestParams.put("Category", Emphistory.Emp_Desg_change); result = hrmsCommonDAOObj.addEmphistory(requestParams); } if (!histsal.equals("")) { requestParams.clear(); requestParams.put("Userid", id); requestParams.put("Salary", histsal); requestParams.put("Updatedon", saveDate); requestParams.put("Updatedby", updatedby); requestParams.put("Category", Emphistory.Emp_Salary); result = hrmsCommonDAOObj.addEmphistory(requestParams); } sessionHandlerImplObj.updatePreferences(request, null, (StringUtil.isNullOrEmpty((String) hm.get("formatid")) ? null : (String) hm.get("formatid")), (StringUtil.isNullOrEmpty((String) hm.get("tzid")) ? null : (String) hm.get("tzid")), diff); if (roleflag == 1) { msg = msg + " " + messageSource.getMessage("hrms.common.Rolecannotbechangedforsuperadministrator", null, "Role cannot be changed for Super Administrator.", RequestContextUtils.getLocale(request)); jobj.put("roleflag", roleflag); } if (roleflag == 2) { msg = msg + " <br><br><br>" + messageSource.getMessage( "hrms.common.rolecannotbechangedtocompanyemployee", null, "Note : Role cannot be changed to Company Employee. Please re-assign or remove its child node in Organization Chart before changing its role to Company Employee.", RequestContextUtils.getLocale(request)); jobj.put("roleflag", roleflag); } jobj.put("msg", msg); jobj.put("success", true); txnManager.commit(status); } catch (Exception e) { try { if (e.getMessage().equals("Employee ID already present.")) { jobj.put("msg", e.getMessage()); } } catch (Exception ex) { e.printStackTrace(); } e.printStackTrace(); txnManager.rollback(status); } return new ModelAndView("jsonView", "model", jobj.toString()); }