List of usage examples for org.springframework.transaction TransactionDefinition PROPAGATION_REQUIRED
int PROPAGATION_REQUIRED
To view the source code for org.springframework.transaction TransactionDefinition PROPAGATION_REQUIRED.
Click Source Link
From source file:com.krawler.spring.hrms.rec.job.hrmsRecJobController.java
public ModelAndView editProspect(HttpServletRequest request, HttpServletResponse response) { Date joiningdate = null;//www. jav a 2 s .co m DateFormat formatter; formatter = new SimpleDateFormat("MM/dd/yyyy"); KwlReturnObject result = null; JSONObject jobj1 = new JSONObject(); String appnames = ""; //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("ids"); String[] cnames = request.getParameterValues("cnames"); String[] positionids = request.getParameterValues("positionids"); String applicantStatus = request.getParameter("selected"); HashMap<String, Object> requestParams = new HashMap<String, Object>(); HashMap<String, Object> appParams = new HashMap<String, Object>(); for (int i = 0; i < ids.length; i++) { requestParams.clear(); requestParams.put("positionid", positionids[i]); requestParams.put("primary", true); result = hrmsRecJobDAOObj.getPositionmain(requestParams); Positionmain position = null; if (StringUtil.checkResultobjList(result)) { position = (Positionmain) result.getEntityList().get(0); } requestParams.clear(); requestParams.put("id", ids[i]); requestParams.put("primary", true); result = hrmsRecJobDAOObj.getPositionstatus(requestParams); appParams.put("id", ids[i]); Allapplications appl = null; if (StringUtil.checkResultobjList(result)) { appl = (Allapplications) result.getEntityList().get(0); } // Allapplications appl = (Allapplications) session.load(Allapplications.class, ids[i]); // Positionmain position = (Positionmain) session.load(Positionmain.class, positionids[i]); if (StringUtil.isNullOrEmpty(request.getParameter("callback")) == false) { appParams.put("callback", request.getParameter("callback")); // appl.setCallback((MasterData) session.load(MasterData.class, request.getParameter("callback"))); } if (StringUtil.isNullOrEmpty(applicantStatus)) { } else { // appl.setStatus(request.getParameter("status")); appParams.put("status", applicantStatus); if (applicantStatus.equalsIgnoreCase("Rejected")) { if (appl.getApplicationflag() == 1 && position.getPositionsfilled() > 0) { requestParams.clear(); requestParams.put("positionid", positionids[i]); requestParams.put("positionsfilled", position.getPositionsfilled() - 1); requestParams.put("delflag", 0); hrmsRecJobDAOObj.updatePositionmain(requestParams); // position.setPositionsfilled(position.getPositionsfilled()-1); // position.setDelflag(0); // session.update(position); } appParams.put("applicationflag", 2); appParams.put("rejectedbefore", 1); // appl.setApplicationflag(2); // appl.setRejectedbefore(1); } else if (applicantStatus.equalsIgnoreCase("Selected")) { joiningdate = (Date) formatter.parse(request.getParameter("joiningdate")); if (appl.getApplydate() != null && joiningdate != null && appl.getApplydate().compareTo(joiningdate) < 0) { // appl.setApplicationflag(1); appParams.put("applicationflag", 1); if (Boolean.parseBoolean(request.getParameter("changeselected"))) { requestParams.clear(); requestParams.put("positionid", positionids[i]); if (position.getNoofpos() >= position.getPositionsfilled() + 1) { if (position.getNoofpos() == position.getPositionsfilled() + 1) { requestParams.put("delflag", 3); // position.setDelflag(3); } // position.setPositionsfilled(position.getPositionsfilled() + 1); requestParams.put("positionsfilled", position.getPositionsfilled() + 1); } // session.update(position); hrmsRecJobDAOObj.updatePositionmain(requestParams); } if (!StringUtil.isNullOrEmpty(request.getParameter("joiningdate"))) { joiningdate = (Date) formatter.parse(request.getParameter("joiningdate")); // appl.setJoiningdate(joiningdate); appParams.put("joiningdate", joiningdate); } } } else { if (appl.getApplicationflag() == 1 && position.getPositionsfilled() >= 0) { requestParams.clear(); // position.setPositionsfilled(position.getPositionsfilled()-1); // position.setDelflag(0); // session.update(position); requestParams.put("positionid", positionids[i]); requestParams.put("positionsfilled", position.getPositionsfilled() - 1); requestParams.put("delflag", 0); hrmsRecJobDAOObj.updatePositionmain(requestParams); } // appl.setApplicationflag(0); appParams.put("applicationflag", 0); } } if (StringUtil.isNullOrEmpty(request.getParameter("rank")) == false) { // appl.setRank((MasterData) session.load(MasterData.class, request.getParameter("rank"))); appParams.put("rank", request.getParameter("rank")); } if (!StringUtil.isNullOrEmpty(request.getParameter("statuscomment"))) { // appl.setStatuscomment(request.getParameter("statuscomment")); appParams.put("statuscomment", request.getParameter("statuscomment")); } String usrnm; if (appl.getEmployee() != null) { usrnm = StringUtil.getFullName(appl.getEmployee()); } else { usrnm = appl.getConfigjobapplicant().getCol1() + " " + appl.getConfigjobapplicant().getCol2(); } // session.update(appl); if (request.getParameter("selected").equals("Selected")) { if (appl.getApplydate() != null && joiningdate != null && appl.getApplydate().compareTo(joiningdate) < 0) { hrmsRecJobDAOObj.addAllapplications(appParams); } else { appnames += (cnames[i] + " ,"); } } else { hrmsRecJobDAOObj.addAllapplications(appParams); } //@@ProfileHandler.insertAuditLog(session, AuditAction.PROSPECT_EDITED, "User " + AuthHandler.getFullName(session, AuthHandler.getUserid(request)) + " has edited prospect of " + usrnm,request); } txnManager.commit(status); if (!appnames.equals("")) { appnames = appnames.substring(0, appnames.length() - 1); } jobj1.put("msg", appnames); jobj1.put("success", true); jobj1.put("valid", true); } catch (Exception ex) { ex.printStackTrace(); txnManager.rollback(status); } finally { return new ModelAndView("jsonView", "model", jobj1.toString()); } }
From source file:com.krawler.spring.hrms.rec.job.hrmsRecJobController.java
public ModelAndView deleteJobapplicant(HttpServletRequest request, HttpServletResponse response) throws ServiceException, HibernateException, SessionExpiredException { 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 {/*w w w. j a v a 2 s.com*/ String[] ids = request.getParameterValues("ids"); HashMap<String, Object> requestParams = new HashMap<String, Object>(); for (int i = 0; i < ids.length; i++) { requestParams.clear(); requestParams.put("id", ids[i]); hrmsRecJobDAOObj.deleteConfigJobapplicant(requestParams); } jobj.put("data", ""); jobj.put("valid", true); txnManager.commit(status); } catch (HibernateException e) { txnManager.rollback(status); throw ServiceException.FAILURE("hrmsHandler.deleteApplicants", e); } finally { return new ModelAndView("jsonView", "model", jobj.toString()); } }
From source file:com.krawler.spring.hrms.rec.job.hrmsRecJobController.java
public ModelAndView applyforjobexternal(HttpServletRequest request, HttpServletResponse response) { String statusstr = "Pending"; Date date1;/*from w w w.j av a 2s .c o m*/ DateFormat formatter; String positions = ""; ConfigRecruitmentData applicant = null; User user = null; String applicantid; JSONObject jobj = new JSONObject(); JSONObject jobj1 = new JSONObject(); KwlReturnObject result = 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 { HashMap<String, Object> requestParams = new HashMap<String, Object>(); formatter = new SimpleDateFormat("MM/dd/yyyy"); date1 = (Date) formatter.parse(request.getParameter("applydt")); Allapplications allapl = null; if (StringUtil.isNullOrEmpty(request.getParameter("apcntid"))) { applicantid = sessionHandlerImplObj.getUserid(request); } else { applicantid = request.getParameter("apcntid"); } if (Integer.parseInt(request.getParameter("employeetype")) == 1) { user = (User) kwlCommonTablesDAOObj.getObject("com.krawler.common.admin.User", applicantid); } else { applicant = (ConfigRecruitmentData) kwlCommonTablesDAOObj .getObject("com.krawler.hrms.recruitment.ConfigRecruitmentData", applicantid); } Company cmp = (Company) kwlCommonTablesDAOObj.getObject("com.krawler.common.admin.Company", sessionHandlerImplObj.getCompanyid(request)); String[] ids = request.getParameterValues("posid"); for (int i = 0; i < ids.length; i++) { Positionmain position = (Positionmain) kwlCommonTablesDAOObj .getObject("com.krawler.hrms.recruitment.Positionmain", ids[i]); requestParams.put("status", statusstr); requestParams.put("applydate", date1); if (Integer.parseInt(request.getParameter("employeetype")) == 1) { requestParams.put("employee", user); requestParams.put("employeetype", 1); } else { requestParams.put("jobapplicant", applicant); requestParams.put("employeetype", 4); // 0 is changed to 4 for configured job application } requestParams.put("position", ids[i]); requestParams.put("company", cmp); requestParams.put("delflag", 0); requestParams.put("applicationflag", 0); requestParams.put("rejectedbefore", 0); positions += "" + position.getJobid() + ":" + position.getPosition().getValue() + ","; result = hrmsRecJobDAOObj.addAllapplications(requestParams); if (result.isSuccessFlag()) { if (Integer.parseInt(request.getParameter("employeetype")) == 1) { auditTrailDAOObj.insertAuditLog(AuditAction.APPLY_FOR_JOB, "User " + profileHandlerDAOObj .getUserFullName(sessionHandlerImplObj.getUserid(request)) + " has applied for job position " + position.getJobid(), request, "0"); //@@ProfileHandler.insertAuditLog(session, AuditAction.APPLY_FOR_JOB, "User " + AuthHandler.getFullName(session, AuthHandler.getUserid(request)) + " has applied for job position " + allapl.getPosition().getJobid(),request); } else { if (request.getSession().getAttribute("userid") != null) { //@@ProfileHandler.insertAuditLog(session, AuditAction.APPLY_FOR_JOB, "User " + AuthHandler.getFullName(session, AuthHandler.getUserid(request)) + " has applied external applicant " + allapl.getJobapplicant().getFirstname() + " " + allapl.getJobapplicant().getLastname() + " for job position " + allapl.getPosition().getJobid(),request); auditTrailDAOObj.insertAuditLog(AuditAction.APPLY_FOR_JOB, "User " + profileHandlerDAOObj .getUserFullName(sessionHandlerImplObj.getUserid(request)) + " has applied external applicant " + applicant.getCol1() + " " + applicant.getCol2() + " for job position " + position.getJobid(), request, "0"); } } } } /*if (!(Integer.parseInt(request.getParameter("employeetype")) == 1)) { String cmpname=cmp.getCompanyName(); CompanyPreferences cmppref = (CompanyPreferences) kwlCommonTablesDAOObj.getObject("com.krawler.common.admin.CompanyPreferences", cmpname); positions = positions.replace(positions.substring(positions.length() - 1), ""); String pmsg = String.format(HrmsMsgs.jobPlnmsg, (applicant.getFirstname() + " " + applicant.getLastname()),cmpname,cmpname); // String htmlmsg = String.format(HrmsMsgs.jobHTMLmsg,allapl.getPosition().getPosition().getValue()+"["+cmp.getJobidformat()+allapl.getPosition().getJobidwthformat()+"]", cmpname, cmpname); String htmlmsg = String.format(HrmsMsgs.jobHTMLmsg,positions, cmpname, cmpname); String subject=String.format(HrmsMsgs.jobSubject,cmp.getJobidformat()+allapl.getPosition().getJobidwthformat(),allapl.getPosition().getPosition().getValue()); try { SendMailHandler.postMail(new String[]{applicant.getEmail()}, subject, htmlmsg, pmsg, cmp.getEmailID()); } catch (MessagingException e) { e.printStackTrace(); } }*/ jobj.put("success", true); jobj1.put("data", jobj.toString()); jobj1.put("valid", true); txnManager.commit(status); } catch (Exception e) { e.printStackTrace(); txnManager.rollback(status); } return new ModelAndView("jsonView", "model", jobj1.toString()); }
From source file:com.krawler.spring.hrms.rec.job.hrmsRecJobController.java
public ModelAndView canceljobexternal(HttpServletRequest request, HttpServletResponse response) { 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 {/* w ww .j ava 2 s . c om*/ String[] ids = request.getParameterValues("applicationid"); for (int i = 0; i < ids.length; i++) { ArrayList<String> name = new ArrayList<String>(); ArrayList<Object> value = new ArrayList<Object>(); name.add("id"); value.add(ids[i]); hrmsRecJobDAOObj.cancelAllapplications(name, value); } /*if (!(Integer.parseInt(request.getParameter("employeetype")) == 1)) { String cmpname=cmp.getCompanyName(); CompanyPreferences cmppref = (CompanyPreferences) kwlCommonTablesDAOObj.getObject("com.krawler.common.admin.CompanyPreferences", cmpname); positions = positions.replace(positions.substring(positions.length() - 1), ""); String pmsg = String.format(HrmsMsgs.jobPlnmsg, (applicant.getFirstname() + " " + applicant.getLastname()),cmpname,cmpname); // String htmlmsg = String.format(HrmsMsgs.jobHTMLmsg,allapl.getPosition().getPosition().getValue()+"["+cmp.getJobidformat()+allapl.getPosition().getJobidwthformat()+"]", cmpname, cmpname); String htmlmsg = String.format(HrmsMsgs.jobHTMLmsg,positions, cmpname, cmpname); String subject=String.format(HrmsMsgs.jobSubject,cmp.getJobidformat()+allapl.getPosition().getJobidwthformat(),allapl.getPosition().getPosition().getValue()); try { SendMailHandler.postMail(new String[]{applicant.getEmail()}, subject, htmlmsg, pmsg, cmp.getEmailID()); } catch (MessagingException e) { e.printStackTrace(); } }*/ jobj.put("success", true); jobj1.put("data", jobj.toString()); jobj1.put("valid", true); txnManager.commit(status); } catch (Exception e) { e.printStackTrace(); txnManager.rollback(status); } return new ModelAndView("jsonView", "model", jobj1.toString()); }
From source file:com.krawler.spring.hrms.rec.job.hrmsRecJobController.java
public ModelAndView addRecruitersFunction(HttpServletRequest request, HttpServletResponse response) { //Status 0=pending,1=accepted,2=rejected,3=Not sent List tabledata = null;// w ww . j av a2 s. c om String hql = null; Recruiter pos = null; JSONObject jobj = new JSONObject(); JSONObject jobj1 = new JSONObject(); KwlReturnObject result = 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 { HashMap<String, Object> requestParams = new HashMap<String, Object>(); ArrayList filter_names = new ArrayList(), filter_values = new ArrayList(); String[] recids = null; String auditmsg = ""; Company cmpid = (Company) kwlCommonTablesDAOObj.getObject("com.krawler.common.admin.Company", sessionHandlerImplObj.getCompanyid(request)); User u = (User) kwlCommonTablesDAOObj.getObject("com.krawler.common.admin.User", sessionHandlerImplObj.getUserid(request)); if (StringUtil.isNullOrEmpty(request.getParameter("delrec"))) { recids = request.getParameterValues("jobids"); for (int i = 0; i < recids.length; i++) { requestParams.clear(); filter_names.clear(); filter_values.clear(); filter_names.add("recruit.userID"); filter_values.add(recids[i]); requestParams.put("filter_names", filter_names); requestParams.put("filter_values", filter_values); result = hrmsRecJobDAOObj.getRecruiter(requestParams); tabledata = result.getEntityList(); requestParams.clear(); if (!tabledata.isEmpty()) { pos = (Recruiter) tabledata.get(0); requestParams.put("Rid", pos.getRid()); requestParams.put("Delflag", 0); auditmsg = "User " + profileHandlerDAOObj.getUserFullName(sessionHandlerImplObj.getUserid(request)) + " has set " + StringUtil.getFullName(pos.getRecruit()) + " as interviewer"; } else { User md = (User) kwlCommonTablesDAOObj.getObject("com.krawler.common.admin.User", recids[i]); requestParams.put("Delflag", 0); //requestParams.put("Recruit",md); requestParams.put("Recruit", recids[i]); auditmsg = "User " + profileHandlerDAOObj.getUserFullName(sessionHandlerImplObj.getUserid(request)) + " has set " + StringUtil.getFullName(md) + " as interviewer"; } result = hrmsRecJobDAOObj.setRecruiters(requestParams); if (result.isSuccessFlag()) { auditTrailDAOObj.insertAuditLog(AuditAction.SET_AS_INTERVIEWER, auditmsg, request, "0"); } } } else { String[] delrecids = request.getParameterValues("appid"); for (int i = 0; i < delrecids.length; i++) { requestParams.clear(); filter_names.clear(); filter_values.clear(); filter_names.add("recruit.userID"); filter_values.add(delrecids[i]); requestParams.put("filter_names", filter_names); requestParams.put("filter_values", filter_values); result = hrmsRecJobDAOObj.getRecruiter(requestParams); tabledata = result.getEntityList(); requestParams.clear(); if (!tabledata.isEmpty()) { pos = (Recruiter) tabledata.get(0); requestParams.put("Rid", pos.getRid()); requestParams.put("Delflag", 3); auditmsg = "User " + StringUtil.getFullName(pos.getRecruit()) + " has been unassigned as interviewer by " + profileHandlerDAOObj.getUserFullName(sessionHandlerImplObj.getUserid(request)); } result = hrmsRecJobDAOObj.setRecruiters(requestParams); if (result.isSuccessFlag()) { auditTrailDAOObj.insertAuditLog(AuditAction.SET_AS_INTERVIEWER, auditmsg, request, "0"); } } } if (StringUtil.isNullOrEmpty(request.getParameter("delrec"))) { for (int i = 0; i < recids.length; i++) { User r = (User) kwlCommonTablesDAOObj.getObject("com.krawler.common.admin.User", recids[i]); Useraccount ua = (Useraccount) kwlCommonTablesDAOObj .getObject("com.krawler.common.admin.Useraccount", r.getUserID()); String fullname = StringUtil.getFullName(r); String uri = URLUtil.getPageURL(request, Links.loginpagewthFull, cmpid.getSubDomain()) + "jspfiles/Confirmation.jsp?c=" + cmpid.getCompanyID() + "&u=" + r.getUserID() + "&acpt="; String pmsg = String.format(HrmsMsgs.interviewerSelectionpln, fullname); String htmlmsg = String.format(HrmsMsgs.interviewerSelectionHTML, fullname, uri + "1", uri + "0", StringUtil.getFullName(u), cmpid.getCompanyName()); try { SendMailHandler.postMail(new String[] { r.getEmailID() }, HrmsMsgs.interviewerSubject, htmlmsg, pmsg, u.getEmailID()); } catch (MessagingException e) { e.printStackTrace(); } } } jobj.put("success", true); jobj1.put("data", jobj.toString()); jobj1.put("valid", true); txnManager.commit(status); } catch (Exception e) { e.printStackTrace(); txnManager.rollback(status); } return new ModelAndView("jsonView", "model", jobj1.toString()); }
From source file:com.krawler.spring.hrms.rec.job.hrmsRecJobController.java
public ModelAndView saveConfigRecruitment(HttpServletRequest request, HttpServletResponse response) { //Status 0=pending,1=accepted,2=rejected,3=Not sent List tabledata = null;//w w w. j a va 2 s . c o m JSONObject msg = new JSONObject(); String hql = null; Recruiter pos = null; JSONObject jobj = new JSONObject(); JSONObject jobj1 = new JSONObject(); KwlReturnObject result = 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 { HashMap<String, Object> arrParam = new HashMap<String, Object>(); HashMap<String, Object> requestParam = new HashMap<String, Object>(); ArrayList<FileItem> hm = new ArrayList<FileItem>(); boolean fileUpload = false; HashMap<Integer, String> filemap = new HashMap<Integer, String>(); hrmsRecJobDAOObj.parseRequest(request, arrParam, hm, fileUpload, filemap); String auditmsg = ""; result = hrmsRecJobDAOObj.addConfigRecruitmentData(arrParam); // if(result.isSuccessFlag()){ // auditTrailDAOObj.insertAuditLog(AuditAction.SET_AS_INTERVIEWER, "User " + profileHandlerDAOObj.getUserFullName(sessionHandlerImplObj.getUserid(request)) + " has edited " + profileHandlerDAOObj.getUserFullName(userid) + "'s profile", request, "0"); // } ConfigRecruitmentData ConfigRecruitmentDataobj = (ConfigRecruitmentData) result.getEntityList().get(0); for (int j = 0; j < filemap.size(); j++) { HrmsDocs doc = hrmsRecJobDAOObj.uploadFile(hm.get(j), ConfigRecruitmentDataobj, arrParam, false); arrParam.clear(); arrParam.put("Docid", doc.getDocid()); arrParam.put("Recid", ConfigRecruitmentDataobj.getId()); result = hrmsRecJobDAOObj.addHrmsDocmap(arrParam); requestParam.put(filemap.get(j), doc.getDocid()); requestParam.put("Id", ConfigRecruitmentDataobj.getId()); } result = hrmsRecJobDAOObj.addConfigRecruitmentData(requestParam); if (result.isSuccessFlag()) { auditTrailDAOObj.insertAuditLog(AuditAction.PROFILE_EDITED, "User " + profileHandlerDAOObj.getUserFullName(AuthHandler.getUserid(request)) + " has Edited " + ConfigRecruitmentDataobj.getCol1() + " " + ConfigRecruitmentDataobj.getCol2() + "'s profile", request, "0"); } msg.put("msg", messageSource.getMessage("hrms.Messages.calMsgBoxShow122", null, RequestContextUtils.getLocale(request))); msg.put("success", true); txnManager.commit(status); } catch (Exception e) { e.printStackTrace(); txnManager.rollback(status); } return new ModelAndView("jsonView", "model", msg.toString()); }
From source file:com.krawler.spring.hrms.rec.job.hrmsRecJobController.java
public ModelAndView createapplicantFunction(HttpServletRequest request, HttpServletResponse response) { JSONObject jobj = new JSONObject(); JSONObject jobj1 = new JSONObject(); List list = null;/*from w w w .ja v a 2 s .c o m*/ SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); KwlReturnObject result = 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 { HashMap<String, Object> requestParams = new HashMap<String, Object>(); ArrayList filter_names = new ArrayList(), filter_values = new ArrayList(); String pwd = request.getParameter("p"); String username = request.getParameter("u"); String fname = request.getParameter("fname"); String lname = request.getParameter("lname"); String cmpid = sessionHandlerImplObj.getCompanyid(request); if (StringUtil.isNullOrEmpty(request.getParameter("update"))) { filter_names.add("Col3"); filter_values.add(request.getParameter("e")); filter_names.add("deleted"); filter_values.add(false); filter_names.add("company.companyID"); filter_values.add(cmpid); requestParams.put("filter_names", filter_names); requestParams.put("filter_values", filter_values); result = hrmsRecJobDAOObj.getConfigJobApplicant(requestParams); list = result.getEntityList(); if (list.size() == 0) { Company cmp = (Company) kwlCommonTablesDAOObj.getObject("com.krawler.common.admin.Company", cmpid); requestParams.clear(); requestParams.put("Col1", fname); requestParams.put("Col2", lname); requestParams.put("Col3", request.getParameter("e")); //requestParams.put("Address1", request.getParameter("addr")); requestParams.put("Col4", request.getParameter("contact")); // requestParams.put("Username", username); // requestParams.put("Password", authHandler.getSHA1(pwd)); // requestParams.put("Status", 0); requestParams.put("Company", cmpid); result = hrmsRecJobDAOObj.addConfigRecruitmentData(requestParams); if (result.isSuccessFlag()) { /*String uri = URLUtil.getPageURL(request, Links.loginpagewthFull,cmp.getSubDomain())+"applicantLogin.html"; String pmsg = String.format(KWLErrorMsgs.msgMailInvite, fname, "Demo", username, pwd, uri, "Demo"); String htmlmsg = String.format(HrmsMsgs.msgMailInviteUsernamePassword, fname, profileHandlerDAOObj.getUserFullName( sessionHandlerImplObj.getUserid(request)), sessionHandlerImplObj.getCompanyName(request), username, pwd, uri, uri, ""); try { SendMailHandler.postMail(new String[]{request.getParameter("e")}, "["+messageSource.getMessage("hrms.common.deskera", null, RequestContextUtils.getLocale(request))+"] "+messageSource.getMessage("hrms.common.welcome.deskera.hrms", null, RequestContextUtils.getLocale(request)), htmlmsg, pmsg, "admin.hrms@mailinator.com"); } catch (MessagingException e) { e.printStackTrace(); }*/ jobj.put("msg", messageSource.getMessage("hrms.common.Applicantcreatedsuccessfully", null, RequestContextUtils.getLocale(request))); jobj.put("type", messageSource.getMessage("hrms.common.success", null, RequestContextUtils.getLocale(request))); //@@ProfileHandler.insertAuditLog(session, AuditAction.CREATE_APPLICANT, "User " + AuthHandler.getFullName(session, AuthHandler.getUserid(request)) + " has created new applicant " + jobapp.getFirstname() + " " + jobapp.getLastname(),request); auditTrailDAOObj.insertAuditLog(AuditAction.CREATE_APPLICANT, "User " + profileHandlerDAOObj .getUserFullName(sessionHandlerImplObj.getUserid(request)) + " has created new applicant " + fname + " " + lname, request, "0"); } else { jobj.put("msg", messageSource.getMessage("hrms.recruitment.error.occurred.creating.applicant", null, RequestContextUtils.getLocale(request))); jobj.put("type", messageSource.getMessage("hrms.common.error", null, RequestContextUtils.getLocale(request))); } } else { jobj.put("msg", messageSource.getMessage("hrms.common.email.already.exists", null, RequestContextUtils.getLocale(request))); jobj.put("type", messageSource.getMessage("hrms.common.warning", null, RequestContextUtils.getLocale(request))); } } else { requestParams.put("primary", true); requestParams.put("applicantid", request.getParameter("profileid")); result = hrmsRecJobDAOObj.getConfigJobApplicant(requestParams); list = result.getEntityList(); if (!list.isEmpty()) { String jsondata1 = request.getParameter("jsondata1"); String jsondata2 = request.getParameter("jsondata2"); String jsondata3 = request.getParameter("jsondata3"); String jsondata4 = request.getParameter("jsondata4"); String jsondata5 = request.getParameter("jsondata5"); requestParams.clear(); requestParams.put("Applicantid", request.getParameter("profileid")); if (jsondata1.length() > 0) { jobj = new JSONObject(jsondata1); requestParams.put("Title", jobj.getString("title")); requestParams.put("Firstname", jobj.getString("firstname")); requestParams.put("Lastname", jobj.getString("lastname")); requestParams.put("Email", jobj.getString("email")); requestParams.put("Otheremail", jobj.getString("otheremail")); requestParams.put("Birthdate", (Date) fmt.parse(jobj.getString("birthdate"))); } if (jsondata2.length() > 0) { jobj = new JSONObject(jsondata2); requestParams.put("Contactno", jobj.getString("contactno")); requestParams.put("Mobileno", jobj.getString("mobileno")); requestParams.put("City", jobj.getString("city")); requestParams.put("State", jobj.getString("state")); requestParams.put("Countryid", jobj.getString("country")); requestParams.put("Address1", jobj.getString("address1")); requestParams.put("Address2", jobj.getString("address2")); } if (jsondata3.length() > 0) { jobj = new JSONObject(jsondata3); if (StringUtil.isNullOrEmpty(jobj.getString("graddegree")) == false) { requestParams.put("Graddegree", jobj.getString("graddegree")); } if (StringUtil.isNullOrEmpty(jobj.getString("gradspecilization")) == false) { requestParams.put("Gradspecialization", jobj.getString("gradspecilization")); } if (StringUtil.isNullOrEmpty(jobj.getString("gradcollege")) == false) { requestParams.put("Gradcollege", jobj.getString("gradcollege")); } if (StringUtil.isNullOrEmpty(jobj.getString("graduniversity")) == false) { requestParams.put("Graduniversity", jobj.getString("graduniversity")); } if (StringUtil.isNullOrEmpty(jobj.getString("gradepercent")) == false) { requestParams.put("Gradpercent", jobj.getString("gradepercent")); } if (StringUtil.isNullOrEmpty(jobj.getString("gradpassdate")) == false) { requestParams.put("Gradpassdate", (Date) fmt.parse(jobj.getString("gradpassdate"))); } if (StringUtil.isNullOrEmpty(jobj.getString("pgqualification")) == false) { requestParams.put("Pgqualification", jobj.getString("pgqualification")); } if (StringUtil.isNullOrEmpty(jobj.getString("pgspecialization")) == false) { requestParams.put("Pgspecialization", jobj.getString("pgspecialization")); } if (StringUtil.isNullOrEmpty(jobj.getString("pgcollege")) == false) { requestParams.put("Pgcollege", jobj.getString("pgcollege")); } if (StringUtil.isNullOrEmpty(jobj.getString("pguniversity")) == false) { requestParams.put("Pguniversity", jobj.getString("pguniversity")); } if (StringUtil.isNullOrEmpty(jobj.getString("pgpercent")) == false) { requestParams.put("Pgpercent", jobj.getString("pgpercent")); } if (StringUtil.isNullOrEmpty(jobj.getString("pgpassdate")) == false) { requestParams.put("Pgpassdate", (Date) fmt.parse(jobj.getString("pgpassdate"))); } if (StringUtil.isNullOrEmpty(jobj.getString("othername")) == false) { requestParams.put("Othername", jobj.getString("othername")); } if (StringUtil.isNullOrEmpty(jobj.getString("otherqualification")) == false) { requestParams.put("Otherqualification", jobj.getString("otherqualification")); } if (StringUtil.isNullOrEmpty(jobj.getString("otherpercent")) == false) { requestParams.put("Otherpercent", jobj.getString("otherpercent")); } if (StringUtil.isNullOrEmpty(jobj.getString("otherdetails")) == false) { requestParams.put("Otherdetails", jobj.getString("otherdetails")); } if (StringUtil.isNullOrEmpty(jobj.getString("otherpassdate")) == false) { requestParams.put("Otherpassdate", (Date) fmt.parse(jobj.getString("otherpassdate"))); } } if (jsondata4.length() > 0) { jobj = new JSONObject(jsondata4); if (jobj.getString("experiencemonth").equals("")) { requestParams.put("Experiencemonth", 0); } else { requestParams.put("Experiencemonth", Integer.parseInt(jobj.getString("experiencemonth"))); } if (StringUtil.isNullOrEmpty(jobj.getString("experienceyear")) == false) { requestParams.put("Experienceyear", Integer.parseInt(jobj.getString("experienceyear"))); } if (StringUtil.isNullOrEmpty(jobj.getString("functionalexpertise")) == false) { requestParams.put("Functionalexpertise", jobj.getString("functionalexpertise")); } if (StringUtil.isNullOrEmpty(jobj.getString("currentindustry")) == false) { requestParams.put("Currentindustry", jobj.getString("currentindustry")); } if (StringUtil.isNullOrEmpty(jobj.getString("currentorganization")) == false) { requestParams.put("Currentorganization", jobj.getString("currentorganization")); } if (StringUtil.isNullOrEmpty(jobj.getString("currentdesignation")) == false) { requestParams.put("Currentdesignation", jobj.getString("currentdesignation")); } if (StringUtil.isNullOrEmpty(jobj.getString("grosssalary")) == false) { requestParams.put("Grosssalary", Integer.parseInt(jobj.getString("grosssalary"))); } requestParams.put("Expectedsalary", Integer.parseInt(jobj.getString("expectedsalary"))); } if (jsondata5.length() > 0) { jobj = new JSONObject(jsondata5); requestParams.put("Keyskills", jobj.getString("keyskills")); if (StringUtil.isNullOrEmpty(jobj.getString("category")) == false) { requestParams.put("Category", jobj.getString("category")); } if (StringUtil.isNullOrEmpty(jobj.getString("filepath")) == false) { requestParams.put("Filepath", jobj.getString("filepath")); } if (StringUtil.isNullOrEmpty(jobj.getString("companyrelative")) == false) { requestParams.put("Companyrelative", jobj.getString("companyrelative")); } if (StringUtil.isNullOrEmpty(jobj.getString("appearedbefore")) == false) { requestParams.put("Appearedbefore", jobj.getString("appearedbefore")); if (jobj.getString("appearedbefore").equalsIgnoreCase("yes")) { if (StringUtil.isNullOrEmpty(jobj.getString("interviewplace")) == false) { requestParams.put("Interviewplace", jobj.getString("interviewplace")); } if (StringUtil.isNullOrEmpty(jobj.getString("interviewdate")) == false) { requestParams.put("Interviewdate", (Date) fmt.parse(jobj.getString("interviewdate"))); } if (StringUtil.isNullOrEmpty(jobj.getString("interviewposition")) == false) { requestParams.put("Interviewposition", jobj.getString("interviewposition")); } } } requestParams.put("Interviewlocation", jobj.getString("interviewlocation")); result = hrmsRecJobDAOObj.setJobApplicant(requestParams); } // insertConfigData(request, "Recruitment", request.getParameter("profileid"),sessionHandlerImplObj.getCompanyid(request)); hrmsCommonDAOObj.insertConfigData(request, "Recruitment", request.getParameter("profileid"), sessionHandlerImplObj.getCompanyid(request)); } if (result.isSuccessFlag()) { jobj.put("msg", messageSource.getMessage("hrms.recruitment.applicant.updated.successfully", null, RequestContextUtils.getLocale(request))); jobj.put("type", messageSource.getMessage("hrms.common.success", null, RequestContextUtils.getLocale(request))); } else { jobj.put("msg", messageSource.getMessage("hrms.recruitment.error.occurred.updating.applicant", null, RequestContextUtils.getLocale(request))); jobj.put("type", messageSource.getMessage("hrms.common.error", null, RequestContextUtils.getLocale(request))); } } jobj1.put("data", jobj.toString()); jobj1.put("valid", true); txnManager.commit(status); } catch (Exception e) { e.printStackTrace(); txnManager.rollback(status); } finally { return new ModelAndView("jsonView", "model", jobj1.toString()); } }
From source file:com.krawler.spring.hrms.rec.job.hrmsRecJobController.java
public ModelAndView transferappdata(HttpServletRequest request, HttpServletResponse response) throws ServiceException { KwlReturnObject result = null;/*from w w w . jav a 2 s .c om*/ JSONObject jobj = new JSONObject(); JSONObject jobj1 = new JSONObject(); int dt = 0; HashMap<String, Object> requestParams = new HashMap<String, Object>(); HashMap<String, Integer> datatransfer = new HashMap<String, Integer>(); DefaultTransactionDefinition def = new DefaultTransactionDefinition(); def.setName("JE_Tx"); def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); def.setIsolationLevel(TransactionDefinition.ISOLATION_READ_UNCOMMITTED); TransactionStatus status = txnManager.getTransaction(def); datatransfer.put("count", dt); try { String appid = request.getParameter("applicantid"); String mappedHeaders = request.getParameter("mappedheader"); requestParams.put("employeetype", request.getParameter("employeetype")); requestParams.put("employeeid", request.getParameter("employeeid")); requestParams.put("appusername", request.getParameter("appusername")); requestParams.put("applicantid", appid); requestParams.put("designationid", request.getParameter("designationid")); requestParams.put("empjoindate", request.getParameter("empjoindate")); requestParams.put("departmentid", request.getParameter("departmentid")); requestParams.put("employeerectype", request.getParameter("employeerectype")); if (request.getParameter("employeerectype").toString().equalsIgnoreCase("0")) { com.krawler.utils.json.base.JSONObject headers = new com.krawler.utils.json.base.JSONObject( mappedHeaders); requestParams.put("middlename", fetchField(headers, "Middle Name", appid, false, datatransfer)); requestParams.put("dob", fetchField(headers, "Date Of Birth", appid, true, datatransfer)); requestParams.put("gender", fetchField(headers, "Gender", appid, false, datatransfer)); requestParams.put("maritalstatus", fetchField(headers, "Marital Status", appid, false, datatransfer)); requestParams.put("bloodgroup", fetchField(headers, "Blood Group", appid, false, datatransfer)); requestParams.put("fathername", fetchField(headers, "Father's Name", appid, false, datatransfer)); requestParams.put("fatherdob", fetchField(headers, "Father's DOB", appid, true, datatransfer)); requestParams.put("mothername", fetchField(headers, "Mother's Name", appid, false, datatransfer)); requestParams.put("motherdob", fetchField(headers, "Mother's DOB", appid, true, datatransfer)); requestParams.put("keyskill", fetchField(headers, "Key Skills", appid, false, datatransfer)); requestParams.put("panno", fetchField(headers, "PAN No", appid, false, datatransfer)); requestParams.put("epfno", fetchField(headers, "EPF No", appid, false, datatransfer)); requestParams.put("drivingno", fetchField(headers, "Driving License No", appid, false, datatransfer)); requestParams.put("passportno", fetchField(headers, "Passport No", appid, false, datatransfer)); requestParams.put("exdateofpassport", fetchField(headers, "Expiry Date of Passport", appid, true, datatransfer)); requestParams.put("mobileno", fetchField(headers, "Mobile no", appid, false, datatransfer)); requestParams.put("landlineno", fetchField(headers, "Landline No", appid, false, datatransfer)); requestParams.put("otheremail", fetchField(headers, "Other Email", appid, false, datatransfer)); requestParams.put("permanentaddress", fetchField(headers, "Permanent Address", appid, false, datatransfer)); requestParams.put("presentaddress", fetchField(headers, "Present Address", appid, false, datatransfer)); requestParams.put("presentcity", fetchField(headers, "Present City", appid, false, datatransfer)); requestParams.put("presentstate", fetchField(headers, "Present State", appid, false, datatransfer)); requestParams.put("presentcountry", fetchField(headers, "Present Country", appid, false, datatransfer)); requestParams.put("Permanentcity", fetchField(headers, "Permanent City", appid, false, datatransfer)); requestParams.put("Permanentstate", fetchField(headers, "Permanent State", appid, false, datatransfer)); requestParams.put("Permanentcountry", fetchField(headers, "Permanent Country", appid, false, datatransfer)); } requestParams.put("companyid", sessionHandlerImplObj.getCompanyid(request)); requestParams.put("userid", sessionHandlerImplObj.getUserid(request)); result = hrmsRecJobDAOObj.transferappdata(requestParams); User relatedTo = ((ArrayList<User>) result.getEntityList()).get(0); if (request.getParameter("employeerectype").toString().equalsIgnoreCase("0")) {//For External Applicant Only(Uploaded Documents transfer to Employee data.) KwlReturnObject kwlReturnObject1 = null; KwlReturnObject kwlReturnObject2 = null; KwlReturnObject kwlReturnObject3 = null; String userid = request.getParameter("applicantid"); ArrayList<String> filter_names = new ArrayList<String>(); ArrayList<Object> filter_values = new ArrayList<Object>(); filter_names.add("recid"); filter_values.add(userid); filter_names.add("docid.deleted"); filter_values.add(false); filter_names.add("docid.referenceid"); filter_values.add(userid); requestParams.put("filter_names", filter_names); requestParams.put("filter_values", filter_values); kwlReturnObject1 = hrmsExtApplDocsDAOObj.getDocs(requestParams); ArrayList<HrmsDocmap> hrmsDocmaps = (ArrayList<HrmsDocmap>) kwlReturnObject1.getEntityList(); kwlReturnObject2 = hrmsRecJobDAOObj.transferExternalAppDocs(hrmsDocmaps, relatedTo); kwlReturnObject3 = hrmsRecJobDAOObj.transferExternalAppDocMaps(hrmsDocmaps, (ArrayList<Docs>) kwlReturnObject2.getEntityList(), relatedTo); } jobj.put("success", result.isSuccessFlag()); if (result.isSuccessFlag()) auditTrailDAOObj.insertAuditLog(AuditAction.TRANSFER_APPLICANT, "User " + profileHandlerDAOObj.getUserFullName(sessionHandlerImplObj.getUserid(request)) + " has transfered " + request.getParameter("appusername") + "'s applicants data", request, "0"); if (datatransfer.get("count") > 0 && result.getMsg().equals("Applicant data trasfered successfully.")) { jobj.put("msg", messageSource.getMessage("hrms.recruitment.data.not.transfer.incorrect.mapping", null, RequestContextUtils.getLocale(request))); } else { jobj.put("msg", result.getMsg()); } jobj1.put("data", jobj); jobj1.put("valid", true); if (result.isSuccessFlag()) { txnManager.commit(status); } else { txnManager.rollback(status); } } catch (Exception ex) { txnManager.rollback(status); ex.printStackTrace(); } return new ModelAndView(successView, "model", jobj1.toString()); }
From source file:com.krawler.spring.hrms.rec.job.hrmsRecJobController.java
public ModelAndView sendLetters(HttpServletRequest request, HttpServletResponse response) { KwlReturnObject result = null;//from w ww .java 2 s. c o m //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 { //code for history of emails to be sent // String records = request.getParameter("records"); JSONArray recordsArr = new JSONArray(request.getParameter("userlist")); // HtmlTemplate ht = (HtmlTemplate)hibernateTemplate.get(HtmlTemplate.class, request.getParameter("templateid")); HashMap<String, Object> requestParams = new HashMap<String, Object>(); Date curDate = new Date(); for (int i = 0; i < recordsArr.length(); i++) { // User usr = (User)hibernateTemplate.get(User.class, recordsArr.getJSONObject(i).getString("uid")); // Allapplications ap = (Allapplications)hibernateTemplate.get(Allapplications.class, recordsArr.getJSONObject(i).getString("uid")); // if(usr==null)continue; // requestParams.put("user", usr); requestParams.put("appid", recordsArr.getJSONObject(i).getString("uid")); requestParams.put("emailid", recordsArr.getJSONObject(i).getString("emailid")); requestParams.put("templateid", request.getParameter("templateid")); // requestParams.put("templatename",ht.getName()); requestParams.put("savedate", curDate); Locale locale = RequestContextUtils.getLocale(request); requestParams.put("locale", locale); result = hrmsRecJobDAOObj.saveLetterHistory(requestParams); requestParams.clear(); } //txnManager.commit(status);//transaction commits here //code for sending emails start here requestParams.put("userid", sessionHandlerImplObj.getUserid(request)); List usrObj = hrmsRecJobDAOObj.getUser(requestParams).getEntityList(); String fromName = ""; String fromEmail = ""; if (usrObj.size() > 0) { User senderU = (User) usrObj.get(0); fromName = senderU.getFirstName() + " " + senderU.getLastName(); fromEmail = senderU.getEmailID(); } requestParams.clear(); requestParams.put("templateid", request.getParameter("templateid")); List htmltemplateObj = hrmsRecJobDAOObj.getHtmlTemplate(requestParams).getEntityList(); HtmlTemplate ht = (HtmlTemplate) htmltemplateObj.get(0); String mail_subject = ht.getSubject() == null ? "" : ht.getSubject(); String htmlLetter = ht.getText(); if (htmlLetter == null) htmlLetter = ""; String textLetter = URLDecoder.decode(htmlLetter, "utf-8"); htmlLetter = URLDecoder.decode(htmlLetter, "utf-8"); ArrayList<String[]> al = getPlaceHolderPairs(textLetter); ArrayList<String[]> phPaths = getPlaceHolderPathLookup(al); String cid = sessionHandlerImplObj.getCompanyid(request); String toEmail = null; ArrayList<String[]> userBasedLetterValues = null; for (int i = 0; i < recordsArr.length(); i++) {//user based code for iteration //applicant id = recordsArr.getJSONObject(i).getString("uid"); //code for getting user values remained userBasedLetterValues/*for single user*/ = getUserLetterValues( recordsArr.getJSONObject(i).getString("uid"), cid, phPaths); StringBuffer textletter_sbf = new StringBuffer(textLetter); StringBuffer htmlletter_sbf = new StringBuffer(htmlLetter); getConvertedLetter(textletter_sbf, htmlletter_sbf, userBasedLetterValues);//converting letter toEmail = recordsArr.getJSONObject(i).getString("emailid"); //String[] recipients,String subject,String htmlMsg,String plainMsg,String fromAddress,String fromName SendMailHandler.postMail(new String[] { toEmail }, mail_subject, htmlletter_sbf.toString(), textletter_sbf.toString(), fromEmail, fromName); if (result.isSuccessFlag()) auditTrailDAOObj.insertAuditLog(AuditAction.SEND_LETTERS, "User " + profileHandlerDAOObj .getUserFullName(sessionHandlerImplObj.getUserid(request)) + " has send letter to " + recordsArr.getJSONObject(i).getString("uname"), request, "0"); } txnManager.commit(status);//transaction commits here } catch (Exception e) { e.printStackTrace(); result = new KwlReturnObject(false, "{\"valid\":\"true\",\"success\":\"true\",data:{msg:\"" + e.getMessage() + "\",value:\"failed\"}}", "", null, 0); txnManager.rollback(status); } return new ModelAndView("jsonView", "model", result.getMsg()); }
From source file:com.krawler.spring.importFunctionality.ImportUtil.java
/** * @param requestParams//from w w w . j av a 2s . com * @param txnManager * @param kwlCommonTablesDAOObj * @param importDao * @return */ public static JSONObject validateFileData(HashMap<String, Object> requestParams, HibernateTransactionManager txnManager, kwlCommonTablesDAO kwlCommonTablesDAOObj, ImportDAO importDao, fieldManagerDAO fieldManagerDAOobj) { JSONObject jobj = new JSONObject(); String msg = ""; boolean issuccess = true; DefaultTransactionDefinition def = new DefaultTransactionDefinition(); def.setName("import_Tx"); def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); TransactionStatus status = txnManager.getTransaction(def); boolean commitedEx = false; int total = 0, failed = 0, fileSize = 0; String fileName = "", extn = ""; Modules module = null; String exceededLimit = "no", channelName = ""; try { String companyid = (String) requestParams.get("companyid"); String mode = (String) requestParams.get("modName"); fileName = (String) requestParams.get("filename"); extn = fileName.substring(fileName.lastIndexOf(".") + 1); channelName = "/ValidateFile/" + fileName; Object extraObj = requestParams.get("extraObj"); JSONObject extraParams = (JSONObject) requestParams.get("extraParams"); String jsondata = (String) requestParams.get("resjson"); JSONObject rootcsvjobj = new JSONObject(jsondata); JSONArray mapping = rootcsvjobj.getJSONArray("root"); String dateFormat = null, dateFormatId = (String) requestParams.get("dateFormat"); if (extn.equalsIgnoreCase("csv") && !StringUtil.isNullOrEmpty(dateFormatId)) { KWLDateFormat kdf = (KWLDateFormat) kwlCommonTablesDAOObj .getClassObject(KWLDateFormat.class.getName(), dateFormatId); dateFormat = kdf != null ? kdf.getJavaForm() : null; } String classPath = "", primaryKey = "", uniqueKeyMethodName = "", uniqueKeyHbmName = ""; try { List list = importDao.getModuleObject(mode); module = (Modules) list.get(0); //Will throw null pointer if no module entry found } catch (Exception ex) { throw new DataInvalidateException("Column config not available for module " + mode); } try { classPath = module.getPojoClassPathFull().toString(); primaryKey = module.getPrimaryKey_MethodName().toString(); } catch (Exception ex) { throw new DataInvalidateException("Please set proper properties for module " + mode); } uniqueKeyMethodName = module.getUniqueKey_MethodName(); uniqueKeyHbmName = module.getUniqueKey_HbmName(); JSONArray columnConfig = getModuleColumnConfig1(module.getId(), companyid, fieldManagerDAOobj, module.getModuleName(), false); String tableName = importDao.getTableName(fileName); KwlReturnObject kresult = importDao.getFileData(tableName, new HashMap<String, Object>()); List fileDataList = kresult.getEntityList(); Iterator itr = fileDataList.iterator(); importDao.markRecordValidation(tableName, -1, 1, "", ""); //reset all invalidation JSONArray recordJArr = new JSONArray(), columnsJArr = new JSONArray(), DataJArr = new JSONArray(); if (itr.hasNext()) { // Object[] fileData = (Object[]) itr.next(); JSONObject jtemp = new JSONObject(); jtemp.put("header", "Row No."); jtemp.put("dataIndex", "col0"); jtemp.put("width", 50); columnsJArr.put(jtemp); for (int i = 1; i < fileData.length - 3; i++) { //Discard columns, id at index 0 and isvalid,validationlog at last 2. jtemp = new JSONObject(); jtemp.put("header", fileData[i] == null ? "" : fileData[i].toString()); jtemp.put("dataIndex", "col" + i); columnsJArr.put(jtemp); } jtemp = new JSONObject(); jtemp.put("header", "Validation Log"); // jtemp.put("hidden", true); jtemp.put("dataIndex", "validateLog"); columnsJArr.put(jtemp); //Create record Obj for grid's store for (int i = 0; i < fileData.length - 1; i++) { jtemp = new JSONObject(); jtemp.put("name", "col" + i); recordJArr.put(jtemp); } jtemp = new JSONObject(); jtemp.put("name", "validateLog"); recordJArr.put(jtemp); } try { jobj.put("record", recordJArr); jobj.put("columns", columnsJArr); jobj.put("data", DataJArr); jobj.put("count", failed); jobj.put("valid", 0); jobj.put("totalrecords", total); jobj.put("isHeader", true); jobj.put("finishedValidation", false); ServerEventManager.publish(channelName, jobj.toString(), (ServletContext) requestParams.get("servletContext")); } catch (Exception ex) { throw ex; } fileSize = fileDataList.size() - 1; fileSize = fileSize >= IMPORT_LIMIT ? IMPORT_LIMIT : fileSize; // fileSize used for showing progress bar[Client Side] jobj.put("isHeader", false); int recIndex = 0; Session session = txnManager.getSessionFactory().getCurrentSession(); int batchCounter = 0; while (itr.hasNext()) { Object[] fileData = (Object[]) itr.next(); tempFileData = null; tempFileData = fileData; recIndex = (Integer) fileData[0]; HashMap<String, Object> dataMap = new HashMap<String, Object>(); HashMap<String, Object> columnHeaderMap = new HashMap<String, Object>(); HashMap<String, Object> columnCSVindexMap = new HashMap<String, Object>(); JSONArray customfield = new JSONArray(); for (int k = 0; k < mapping.length(); k++) { JSONObject mappingJson = mapping.getJSONObject(k); String datakey = mappingJson.getString("columnname"); Object dataValue = cleanHTML((String) fileData[mappingJson.getInt("csvindex") + 1]); //+1 for id column at index-0 dataMap.put(datakey, dataValue); columnHeaderMap.put(datakey, mappingJson.getString("csvheader")); columnCSVindexMap.put(datakey, mappingJson.getInt("csvindex") + 1); } for (int j = 0; j < extraParams.length(); j++) { String datakey = (String) extraParams.names().get(j); Object dataValue = extraParams.get(datakey); dataMap.put(datakey, dataValue); } try { if (total >= IMPORT_LIMIT) { exceededLimit = "yes"; break; } //Update processing status at client side if (total > 0 && total % 10 == 0) { try { ServerEventManager.publish(channelName, "{parsedCount:" + total + ",invalidCount:" + failed + ", fileSize:" + fileSize + ", finishedValidation:false}", (ServletContext) requestParams.get("servletContext")); } catch (Exception ex) { throw ex; } } // CheckUniqueRecord(requestParams, dataMap, classPath, uniqueKeyMethodName, uniqueKeyHbmName); validateDataMAP2(requestParams, dataMap, columnConfig, customfield, columnHeaderMap, columnCSVindexMap, dateFormat, importDao, new HashMap<String, String>()); } catch (Exception ex) { failed++; String errorMsg = ex.getMessage(), invalidColumns = ""; try { JSONObject errorLog = new JSONObject(errorMsg); errorMsg = errorLog.getString("errorMsg"); invalidColumns = errorLog.getString("invalidColumns"); } catch (JSONException jex) { } importDao.markRecordValidation(tableName, recIndex, 0, errorMsg, invalidColumns); if (batchCounter % 30 == 0) { session.flush(); session.clear(); } batchCounter++; JSONObject jtemp = new JSONObject(); if (tempFileData != null) { for (int i = 0; i < tempFileData.length - 2; i++) { jtemp.put("col" + i, tempFileData[i] == null ? "" : tempFileData[i].toString()); } } else { for (int i = 0; i < fileData.length - 2; i++) { jtemp.put("col" + i, fileData[i] == null ? "" : fileData[i].toString()); } } jtemp.put("invalidcolumns", invalidColumns); jtemp.put("validateLog", errorMsg); DataJArr.put(jtemp); // try { // jtemp.put("count", failed); // jtemp.put("totalrecords", total+1); // jtemp.put("fileSize", fileSize); // jtemp.put("finishedValidation", false); // ServerEventManager.publish(channelName, jtemp.toString(), (ServletContext) requestParams.get("servletContext")); // } catch(Exception dex) { // throw dex; // } } total++; } int success = total - failed; if (total == 0) { msg = "Empty file."; } else if (success == 0) { msg = "All the records are invalid."; } else if (success == total) { msg = "All the records are valid."; } else { msg = "" + success + " valid record" + (success > 1 ? "s" : "") + ""; msg += (failed == 0 ? "." : " and " + failed + " invalid record" + (failed > 1 ? "s" : "") + "."); } jobj.put("record", recordJArr); jobj.put("columns", columnsJArr); jobj.put("data", DataJArr); jobj.put("count", failed); jobj.put("valid", success); jobj.put("totalrecords", total); try { ServerEventManager.publish(channelName, "{parsedCount:" + total + ",invalidCount:" + failed + ", fileSize:" + fileSize + ", finishedValidation:true}", (ServletContext) requestParams.get("servletContext")); } catch (Exception ex) { throw ex; } try { txnManager.commit(status); } catch (Exception ex) { commitedEx = true; throw ex; } } catch (Exception e) { if (!commitedEx) { //if exception occurs during commit then dont call rollback txnManager.rollback(status); } issuccess = false; msg = "" + e.getMessage(); Logger.getLogger(ImportHandler.class.getName()).log(Level.SEVERE, null, e); } finally { try { jobj.put("success", issuccess); jobj.put("msg", msg); jobj.put("exceededLimit", exceededLimit); } catch (JSONException ex) { Logger.getLogger(ImportHandler.class.getName()).log(Level.SEVERE, null, ex); } } return jobj; }