Example usage for java.util HashMap clear

List of usage examples for java.util HashMap clear

Introduction

In this page you can find the example usage for java.util HashMap clear.

Prototype

public void clear() 

Source Link

Document

Removes all of the mappings from this map.

Usage

From source file:com.krawler.spring.hrms.rec.job.hrmsRecJobController.java

public ModelAndView InternalJobpositions(HttpServletRequest request, HttpServletResponse response) {
    Date date = null;//from  w  w  w  . ja  va  2  s  . c o  m
    SimpleDateFormat fmt = new SimpleDateFormat("MM/dd/yyyy");
    boolean checkflag = true;
    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>();
        String companyid = sessionHandlerImplObj.getCompanyid(request);
        Company company = (Company) kwlCommonTablesDAOObj.getObject("com.krawler.common.admin.Company",
                companyid);
        if (StringUtil.isNullOrEmpty(request.getParameter("posid"))) {
            ArrayList<String> name = new ArrayList<String>();
            ArrayList<Object> value = new ArrayList<Object>();
            name.add("position.id");
            value.add(request.getParameter("position"));

            name.add("department.id");
            value.add(request.getParameter("department"));

            name.add("jobtype");
            value.add(request.getParameter("jobtype"));

            name.add("!delflag");
            value.add(1);
            requestParams.clear();
            requestParams.put("filter_names", name);
            requestParams.put("filter_values", value);
            result = hrmsRecJobDAOObj.getPositionmain(requestParams);
            if (!result.getEntityList().isEmpty())
                checkflag = false;
            if (checkflag) {

                requestParams = new HashMap<String, Object>();
                requestParams.put("masterid", request.getParameter("position"));
                requestParams.put("companyid", sessionHandlerImplObj.getCompanyid(request));
                result = hrmsCommonDAOObj.getMasterData(requestParams);
                MasterData md = null;
                if (result.getEntityList() != null && result.getEntityList().size() > 0)
                    md = (MasterData) result.getEntityList().get(0);

                requestParams = new HashMap<String, Object>();
                requestParams.put("masterid", request.getParameter("department"));
                requestParams.put("companyid", sessionHandlerImplObj.getCompanyid(request));
                result = hrmsCommonDAOObj.getMasterData(requestParams);
                MasterData dept = null;
                if (result.getEntityList() != null && result.getEntityList().size() > 0)
                    dept = (MasterData) result.getEntityList().get(0);
                requestParams = new HashMap<String, Object>();
                requestParams.put("empid", request.getParameter("manager"));
                result = hrmsCommonDAOObj.getUserDetailsbyUserid(requestParams);
                User man = null;
                if (result.getEntityList() != null && result.getEntityList().size() > 0)
                    man = (User) result.getEntityList().get(0);
                date = (Date) fmt.parse(request.getParameter("startdate"));

                requestParams = new HashMap<String, Object>();
                requestParams.put("empid", sessionHandlerImplObj.getUserid(request));
                result = hrmsCommonDAOObj.getUserDetailsbyUserid(requestParams);
                User createdby = null;
                if (result.getEntityList() != null && result.getEntityList().size() > 0)
                    createdby = (User) result.getEntityList().get(0);

                requestParams = new HashMap<String, Object>();
                requestParams.put("startdate", request.getParameter("startdate"));
                requestParams.put("enddate", request.getParameter("enddate"));
                requestParams.put("position", md);
                requestParams.put("details", request.getParameter("details"));
                requestParams.put("jobtype", request.getParameter("jobtype"));
                requestParams.put("jobidwthformat", Integer.parseInt(request.getParameter("jobid")));
                HashMap<String, Object> requestParams1 = new HashMap<String, Object>();
                requestParams1.put("companyid", sessionHandlerImplObj.getCompanyid(request));
                requestParams1.put("jobid", request.getParameter("jobid"));
                requestParams1.put("jobidformat", request.getParameter("jobidformat"));
                requestParams.put("jobid", profileHandlerDAOObj.getJobIdFormatEdit(requestParams1));
                requestParams.put("delflag", 0);
                requestParams.put("company", company);
                requestParams.put("manager", man);
                requestParams.put("departmentid", dept);
                requestParams.put("noofpos", Integer.parseInt(request.getParameter("nopos")));
                requestParams.put("createdby", createdby);
                requestParams.put("positionsfilled", 0);
                hrmsRecJobDAOObj.setPositionmain(requestParams);

                jobj.put("message", messageSource.getMessage("hrms.recruitment.Jobpositionaddedsuccessfully",
                        null, "Job position added successfully.", RequestContextUtils.getLocale(request)));
            } else {
                jobj.put("message", messageSource.getMessage("hrms.recruitment.Jobpositionalreadypresent", null,
                        "Job position already present.", RequestContextUtils.getLocale(request)));
            }
        } else {
            //Positionmain posmain = (Positionmain) session.load(Positionmain.class, request.getParameter("posid"));
            requestParams = new HashMap<String, Object>();
            requestParams.put("empid", request.getParameter("manager"));
            result = hrmsCommonDAOObj.getUserDetailsbyUserid(requestParams);
            User man = null;
            if (result.getEntityList() != null && result.getEntityList().size() > 0)
                man = (User) result.getEntityList().get(0);

            //                requestParams = new HashMap<String, Object>();
            //                requestParams.put("positionid",request.getParameter("posid"));
            ArrayList<String> name = new ArrayList<String>();
            ArrayList<Object> value = new ArrayList<Object>();

            name.add("positionid");
            value.add(request.getParameter("posid"));
            requestParams.clear();
            requestParams.put("filter_names", name);
            requestParams.put("filter_values", value);
            result = hrmsRecJobDAOObj.getPositionmain(requestParams);
            Positionmain posmain = null;
            requestParams = new HashMap<String, Object>();
            requestParams.put("positionid", request.getParameter("posid"));
            if (result.getEntityList() != null && result.getEntityList().size() > 0)
                posmain = (Positionmain) result.getEntityList().get(0);

            if (request.getParameter("details") != null) {
                requestParams.put("details", request.getParameter("details"));
            }
            if (!StringUtil.isNullOrEmpty(request.getParameter("manager"))) {
                requestParams.put("manager", man);
            }
            if (!StringUtil.isNullOrEmpty(request.getParameter("department"))) {
                requestParams.put("departmentid", request.getParameter("department"));
            }
            if (!StringUtil.isNullOrEmpty(request.getParameter("startdate"))) {
                //date = (Date) fmt.parse(request.getParameter("startdate"));
                requestParams.put("startdate", request.getParameter("startdate"));
            }
            if (!StringUtil.isNullOrEmpty(request.getParameter("enddate"))) {
                date = (Date) fmt.parse(request.getParameter("enddate"));
                if (new Date(fmt.format(new Date())).after(date)) {
                    requestParams.put("delflag", 2);
                } else {
                    requestParams.put("delflag", 0);
                }
                requestParams.put("enddate", request.getParameter("enddate"));
            }
            if (!StringUtil.isNullOrEmpty(request.getParameter("nopos"))) {
                if (posmain.getPositionsfilled() == Integer.parseInt(request.getParameter("nopos"))) {
                    requestParams.put("delflag", 3);
                }
                requestParams.put("noofpos", Integer.parseInt(request.getParameter("nopos")));
            }
            if (!StringUtil.isNullOrEmpty(request.getParameter("jobshift"))) {
                requestParams.put("jobshift", request.getParameter("jobshift"));
            }
            if (!StringUtil.isNullOrEmpty(request.getParameter("location"))) {
                requestParams.put("location", request.getParameter("location"));
            }
            if (!StringUtil.isNullOrEmpty(request.getParameter("relocation"))) {
                requestParams.put("relocation", request.getParameter("relocation"));
            }
            if (!StringUtil.isNullOrEmpty(request.getParameter("expmonth"))) {
                requestParams.put("experiencemonth", Integer.parseInt(request.getParameter("expmonth")));
            }
            if (!StringUtil.isNullOrEmpty(request.getParameter("expyear"))) {
                requestParams.put("experienceyear", Integer.parseInt(request.getParameter("expyear")));
            }
            if (!StringUtil.isNullOrEmpty(request.getParameter("travel"))) {
                requestParams.put("travel", request.getParameter("travel"));
            }
            result = hrmsRecJobDAOObj.updatePositionmain(requestParams);
            jobj.put("message", messageSource.getMessage("hrms.recruitment.Jobpositionupdatedsuccessfully",
                    null, "Job position updated successfully.", RequestContextUtils.getLocale(request)));
        }
        //            ProfileHandler.insertAuditLog(session,
        //                    ("Internal".equals(request.getParameter("jobtype")) ? AuditAction.INTERNAL_JOB_ADDED : AuditAction.EXTERNAL_JOB_ADDED),
        //                    "User " + AuthHandler.getFullName(session, AuthHandler.getUserid(request)) + " has added " + request.getParameter("jobtype") + " job", request);

        jobj1.put("valid", true);
        jobj1.put("data", jobj.toString());
        txnManager.commit(status);

    } catch (ParseException ex) {
        ex.printStackTrace();
        txnManager.rollback(status);
    } catch (SessionExpiredException ex) {
        ex.printStackTrace();
        txnManager.rollback(status);
    } catch (JSONException ex) {
        ex.printStackTrace();
        txnManager.rollback(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 scheduleinterview(HttpServletRequest request, HttpServletResponse response) {
    Date date1;//  w  w  w.jav  a  2  s.  c  o  m
    DateFormat formatter;
    JSONObject jobj = new JSONObject();
    String interviewdate = "";
    //boolean reflag=false;
    String htmlmsg = "";
    String pmsg = "";
    String interviewsub = "";
    KwlReturnObject result = null, recruitresult = 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>();
        String interviewtime = request.getParameter("interviewtime");
        String location = request.getParameter("interviewplace");
        formatter = new SimpleDateFormat("MM/dd/yyyy");
        //            Company cmp=(Company) session.get(Company.class,AuthHandler.getCompanyid(request));
        requestParams.put("companyid", sessionHandlerImplObj.getCompanyid(request));
        result = profileHandlerDAOObj.getCompanyid(requestParams);
        Company cmp = null;
        if (StringUtil.checkResultobjList(result)) {
            cmp = (Company) result.getEntityList().get(0);
        }

        date1 = (Date) formatter.parse(request.getParameter("interviewdt"));
        //interviewdate=(AuthHandler.getUserDateFormatter(request,session).format(date1));
        requestParams.clear();
        requestParams.put("request", request);
        interviewdate = request.getParameter("interviewdt");

        Allapplications allapl = null;
        String[] ids = request.getParameterValues("ids");
        String[] emailids = new String[ids.length];
        String[] Resumeids = new String[ids.length];
        String[] jobs = new String[ids.length];
        String[] applicant = new String[ids.length];
        Boolean[] reflag = new Boolean[ids.length];
        for (int i = 0; i < ids.length; i++) {
            requestParams.clear();
            requestParams.put("id", ids[i]);
            requestParams.put("primary", true);
            result = hrmsRecJobDAOObj.getPositionstatus(requestParams);
            allapl = (Allapplications) result.getEntityList().get(0);
            if (allapl.getStatus().equalsIgnoreCase("In Process")) {
                reflag[i] = true;
            } else {
                reflag[i] = false;
            }
            requestParams.clear();
            requestParams.put("id", ids[i]);
            requestParams.put("status", "In Process");
            requestParams.put("interviewdate", date1);
            requestParams.put("interviewtime", interviewtime);
            requestParams.put("interviewplace", location);
            requestParams.put("contactperson", request.getParameter("contactperson"));
            requestParams.put("interviewcomment", request.getParameter("interviewcomment"));
            //set rid to recruiter table and remove recruiter column from allapp
            requestParams.put("recruiter", request.getParameter("rid"));
            result = hrmsRecJobDAOObj.addAllapplications(requestParams);
            if (StringUtil.checkResultobjList(result)) {
                allapl = (Allapplications) result.getEntityList().get(0);
                requestParams.clear();
                String[] Recruiterids = request.getParameter("rid").split(",");
                requestParams.put("Allapplication", allapl.getId());
                boolean success = hrmsRecJobDAOObj.deleteRecruiters(requestParams);
                requestParams.put("Delflag", 0);
                for (int j = 0; j < Recruiterids.length && success; j++) {
                    requestParams.put("Recruit", Recruiterids[j]);
                    recruitresult = hrmsRecJobDAOObj.setRecruiters(requestParams);
                }
            }

            jobs[i] = (allapl.getPosition().getPosition().getValue() + " [" + allapl.getPosition().getJobid()
                    + "] ");

            if (Integer.parseInt(request.getParameter("employeetype")) == 1) {
                emailids[i] = allapl.getEmployee().getEmailID();
                applicant[i] = (allapl.getEmployee().getFirstName() + " " + allapl.getEmployee().getLastName());
            } else {
                emailids[i] = allapl.getConfigjobapplicant().getCol3();
                applicant[i] = (allapl.getConfigjobapplicant().getCol1() + " "
                        + allapl.getConfigjobapplicant().getCol2());
                Resumeids[i] = allapl.getConfigjobapplicant().getCol5();
            }
            String usrnm;
            if (allapl.getEmployee() != null) {
                usrnm = StringUtil.getFullName(allapl.getEmployee());
            } else {
                usrnm = allapl.getConfigjobapplicant().getCol1() + " "
                        + allapl.getConfigjobapplicant().getCol2();
            }
            //@@ProfileHandler.insertAuditLog(session, AuditAction.INTERVIEW_SCHEDULED, "User  " + AuthHandler.getFullName(session, AuthHandler.getUserid(request)) + " has scheduled interview for " + usrnm + " on "+ interviewdate + " at " + allapl.getInterviewplace(),request);
        }
        //             User usr=(User) session.get(User.class,AuthHandler.getUserid(request));
        Useraccount ua = (Useraccount) kwlCommonTablesDAOObj.getObject("com.krawler.common.admin.Useraccount",
                sessionHandlerImplObj.getUserid(request));
        User usr = ua.getUser();
        if (!StringUtil.isNullOrEmpty(request.getParameter("mail"))) {
            for (int j = 0; j < emailids.length; j++) {
                if (reflag[j]) {
                    pmsg = String.format(HrmsMsgs.rescheduleinterviewPlnmsg, applicant[j], jobs[j],
                            cmp.getCompanyName(), interviewdate, interviewtime, location,
                            usr.getContactNumber(), usr.getEmailID(),
                            usr.getFirstName() + " " + usr.getLastName(),
                            ua.getDesignationid() != null ? ua.getDesignationid().getValue() : " ",
                            cmp.getCompanyName());
                    htmlmsg = String.format(HrmsMsgs.rescheduleinterviewHTMLmsg, applicant[j], jobs[j],
                            cmp.getCompanyName(), interviewdate, interviewtime, location,
                            usr.getContactNumber(), usr.getEmailID(),
                            usr.getFirstName() + " " + usr.getLastName(),
                            ua.getDesignationid() != null ? ua.getDesignationid().getValue() : " ",
                            cmp.getCompanyName());
                    interviewsub = String.format(HrmsMsgs.rescheduleinterviewSubject,
                            allapl.getPosition().getJobid(), allapl.getPosition().getPosition().getValue(),
                            cmp.getCompanyName());
                    try {
                        SendMailHandler.postMail(new String[] { emailids[j] }, interviewsub, htmlmsg, pmsg,
                                usr.getEmailID());
                    } catch (MessagingException e) {
                        e.printStackTrace();
                    }
                } else {
                    pmsg = String.format(HrmsMsgs.interviewPlnmsg, jobs[j], interviewdate, interviewtime,
                            location);
                    htmlmsg = String.format(HrmsMsgs.interviewHTMLmsg, applicant[j], jobs[j],
                            cmp.getCompanyName(), interviewdate, interviewtime, location,
                            usr.getContactNumber(), usr.getEmailID(),
                            usr.getFirstName() + " " + usr.getLastName(),
                            ua.getDesignationid() != null ? ua.getDesignationid().getValue() : " ",
                            cmp.getCompanyName());
                    interviewsub = String.format(HrmsMsgs.interviewSubject, allapl.getPosition().getJobid(),
                            allapl.getPosition().getPosition().getValue(), cmp.getCompanyName());
                    try {
                        SendMailHandler.postMail(new String[] { emailids[j] }, interviewsub, htmlmsg, pmsg,
                                usr.getEmailID());
                    } catch (MessagingException e) {
                        e.printStackTrace();
                    }
                }

                ArrayList params = new ArrayList();
                params.add(allapl.getId());
                ArrayList filter_names = new ArrayList();
                filter_names.add("allapplication.id");
                requestParams.clear();
                requestParams.put("filter_names", filter_names);
                requestParams.put("filter_values", params);
                recruitresult = hrmsRecJobDAOObj.getRecruiters(requestParams);
                if (StringUtil.checkResultobjList(recruitresult)) {
                    List recruiterlist = recruitresult.getEntityList();
                    for (int k = 0; k < recruiterlist.size(); k++) {
                        Recruiter r = (Recruiter) recruiterlist.get(k);
                        String interviewer = r.getRecruit().getFirstName() + " " + r.getRecruit().getLastName();
                        String intpmsg = String.format(HrmsMsgs.interviewinvitePlnmsg, interviewer, jobs[j],
                                interviewdate, interviewtime, location);
                        String inthtmlmsg = String.format(HrmsMsgs.interviewinviteHTMLmsg, interviewer, jobs[j],
                                interviewdate, interviewtime, location,
                                usr.getFirstName() + " " + usr.getLastName(),
                                ua.getDesignationid() != null ? ua.getDesignationid().getValue() : " ",
                                cmp.getCompanyName());
                        String interviewinvitesub = String.format(HrmsMsgs.interviewinviteSubject,
                                allapl.getPosition().getJobid(), allapl.getPosition().getPosition().getValue(),
                                cmp.getCompanyName());

                        if (StringUtil.isNullOrEmpty(Resumeids[j])) {
                            try {
                                SendMailHandler.postMail(new String[] { r.getRecruit().getEmailID() },
                                        interviewinvitesub, inthtmlmsg, intpmsg, usr.getEmailID());
                            } catch (MessagingException e) {
                                e.printStackTrace();
                            }

                        } else {
                            hrmsDocumentController hdc = new hrmsDocumentController();
                            KwlReturnObject kmsg = hrmsExtApplDocsDAOObj.downloadDocument(Resumeids[j]);
                            HashMap ht = hdc.getDocInfo(kmsg, storageHandlerImplObj);
                            try {
                                if (ht != null && ht.containsKey("filename")) {
                                    SendMailHandler.postMail(new String[] { r.getRecruit().getEmailID() },
                                            interviewinvitesub, inthtmlmsg, intpmsg, usr.getEmailID(),
                                            new String[] { (String) ht.get("attachment"),
                                                    (String) ht.get("filename") });
                                } else {
                                    SendMailHandler.postMail(new String[] { r.getRecruit().getEmailID() },
                                            interviewinvitesub, inthtmlmsg, intpmsg, usr.getEmailID());
                                }
                            } catch (MessagingException e) {
                                e.printStackTrace();
                            }
                        }

                    }
                }
            }
        }
        if (result.isSuccessFlag()) {
            String interviewersname = "";
            String delimiter = ",";
            String[] temp = request.getParameter("rid").split(delimiter);
            for (int i = 0; i < temp.length; i++) {
                interviewersname += profileHandlerDAOObj.getUserFullName(temp[i]);
                if (temp.length > i + 1)
                    interviewersname += ", ";
            }
            for (int i = 0; i < ids.length; i++)
                auditTrailDAOObj.insertAuditLog(AuditAction.INTERVIEW_SCHEDULED, "User  "
                        + profileHandlerDAOObj.getUserFullName(sessionHandlerImplObj.getUserid(request))
                        + " has scheduled interview for applicant " + request.getParameterValues("cname")[i]
                        + ". Interviewers are " + interviewersname, request, "0");
        }
        jobj.put("success", "true");
        txnManager.commit(status);
    } catch (Exception ex) {
        ex.printStackTrace();
        txnManager.rollback(status);
    } finally {
        return new ModelAndView("jsonView", "model", "");
    }
}

From source file:com.krawler.spring.hrms.rec.job.hrmsRecJobController.java

public JSONArray getExtApplicantData(HttpServletRequest request, HttpServletResponse response) {
    HashMap<String, Object> requestParams = new HashMap<String, Object>();
    List<ConfigRecruitment> configRecruitments = null;
    Iterator<ConfigRecruitment> iterator1 = null;
    JSONObject jsonObject = null;/*from  w  w w .  j  a  va 2s. co  m*/
    JSONArray jsonArray = new JSONArray();
    try {
        String companyId = sessionHandlerImplObj.getCompanyid(request);
        Class configrecdata = Class.forName("com.krawler.hrms.recruitment.ConfigRecruitmentData");
        requestParams.put("filter_names", Arrays.asList("company.companyID", "visible"));
        requestParams.put("filter_values",
                Arrays.asList(companyId, Boolean.parseBoolean(request.getParameter("visible"))));
        requestParams.put("order_by", Arrays.asList("colnum"));
        requestParams.put("order_type", Arrays.asList("asc"));
        configRecruitments = hrmsRecJobDAOObj.getConfigRecruitment(requestParams).getEntityList();
        requestParams.clear();

        ArrayList<Object> filter_names = new ArrayList<Object>();
        ArrayList<Object> filter_values = new ArrayList<Object>();
        String allApplicationList = request.getParameter("allApplicationList");
        boolean isAllApplicationList = allApplicationList != null ? Boolean.parseBoolean(allApplicationList)
                : false;
        if (isAllApplicationList) {
            List<ConfigRecruitmentData> configRecruitmentDatas = null;
            Iterator<ConfigRecruitmentData> iterator2 = null;
            filter_names.add("company.companyID");
            filter_names.add("deleted");

            filter_values.add(companyId);
            filter_values.add(false);
            requestParams.put("filter_names", filter_names);
            requestParams.put("filter_values", filter_values);

            String Searchjson = request.getParameter("searchJson");
            if (!StringUtil.isNullOrEmpty(Searchjson) && !Searchjson.equals("undefined")) {
                getMyAdvanceSearchparams1(Searchjson, filter_names, 0);
                insertParamAdvanceSearchString1(filter_values, Searchjson, 0);
            }

            configRecruitmentDatas = hrmsRecJobDAOObj.getConfigJobApplicant(requestParams).getEntityList();
            iterator2 = configRecruitmentDatas.iterator();
            while (iterator2.hasNext()) {
                ConfigRecruitmentData configRecruitmentData = iterator2.next();
                jsonObject = new JSONObject();
                iterator1 = configRecruitments.iterator();
                while (iterator1.hasNext()) {
                    ConfigRecruitment configRecruitment = iterator1.next();
                    if (configRecruitment.getConfigtype() == 3) {
                        Method getter = configrecdata.getMethod("getCol" + configRecruitment.getColnum());
                        Object object = getter.invoke(configRecruitmentData);
                        requestParams.clear();
                        requestParams.put("filter_names", Arrays.asList("masterid"));
                        requestParams.put("filter_values", Arrays.asList(object));
                        List<ConfigRecruitmentMaster> configRecruitmentMasters = hrmsRecJobDAOObj
                                .getConfigMaster(requestParams).getEntityList();
                        if (!configRecruitmentMasters.isEmpty() && configRecruitmentMasters.size() > 0
                                && configRecruitmentMasters.get(0) != null) {
                            jsonObject.put(
                                    messageSource.getMessage(
                                            "hrms.recruitment."
                                                    + StringUtil.mergeWithDots(configRecruitment.getName()),
                                            null, configRecruitment.getName(),
                                            RequestContextUtils.getLocale(request)),
                                    configRecruitmentMasters.get(0).getMasterdata() != null
                                            ? configRecruitmentMasters.get(0).getMasterdata()
                                            : "");
                        } else {
                            jsonObject.put(messageSource.getMessage(
                                    "hrms.recruitment." + StringUtil.mergeWithDots(configRecruitment.getName()),
                                    null, configRecruitment.getName(), RequestContextUtils.getLocale(request)),
                                    "");
                        }
                    } else {
                        Method getter = configrecdata.getMethod("getCol" + configRecruitment.getColnum());
                        Object object = getter.invoke(configRecruitmentData);
                        if (configRecruitment.getConfigtype() == 5) {
                            jsonObject.put(
                                    messageSource.getMessage(
                                            "hrms.recruitment."
                                                    + StringUtil.mergeWithDots(configRecruitment.getName()),
                                            null, configRecruitment.getName(),
                                            RequestContextUtils.getLocale(request)),
                                    object != null ? (object.equals("") ? "No" : "Yes") : "No");
                        } else {
                            jsonObject.put(
                                    messageSource.getMessage(
                                            "hrms.recruitment."
                                                    + StringUtil.mergeWithDots(configRecruitment.getName()),
                                            null, configRecruitment.getName(),
                                            RequestContextUtils.getLocale(request)),
                                    object != null ? object : "");
                        }
                    }
                }
                jsonArray.put(jsonObject);
            }
        } else {
            String isStatusApplicable = request.getParameter("isStatusApplicable");
            boolean isStatus = isStatusApplicable != null ? Boolean.parseBoolean(isStatusApplicable) : false;
            List<Allapplications> allapplications = null;
            Iterator<Allapplications> iterator2 = null;
            filter_names.add("configjobapplicant.company.companyID");
            filter_names.add("configjobapplicant.deleted");
            filter_names.add("delflag");
            filter_names.add("applicationflag");

            filter_values.add(companyId);
            filter_values.add(false);
            filter_values.add(0);
            filter_values.add(Integer.parseInt(request.getParameter("applicationflag")));

            String Searchjson = request.getParameter("searchJson");
            if (!StringUtil.isNullOrEmpty(Searchjson) && !Searchjson.equals("undefined")) {
                getMyAdvanceSearchparams1(Searchjson, filter_names, 0);
                insertParamAdvanceSearchString1(filter_values, Searchjson, 0);
            }

            if (isStatus) {
                filter_names.add("status");
                filter_values.add(request.getParameter("status"));
            }
            requestParams.put("filter_names", filter_names);
            requestParams.put("filter_values", filter_values);
            allapplications = hrmsRecJobDAOObj.getPositionstatus(requestParams).getEntityList();
            iterator2 = allapplications.iterator();
            while (iterator2.hasNext()) {
                Allapplications allapplication = iterator2.next();
                jsonObject = new JSONObject();
                iterator1 = configRecruitments.iterator();
                while (iterator1.hasNext()) {
                    ConfigRecruitment configRecruitment = iterator1.next();
                    if (configRecruitment.getConfigtype() == 3) {
                        Method getter = configrecdata.getMethod("getCol" + configRecruitment.getColnum());
                        Object object = getter.invoke(allapplication.getConfigjobapplicant());
                        requestParams.clear();
                        requestParams.put("filter_names", Arrays.asList("masterid"));
                        requestParams.put("filter_values", Arrays.asList(object));
                        List<ConfigRecruitmentMaster> configRecruitmentMasters = hrmsRecJobDAOObj
                                .getConfigMaster(requestParams).getEntityList();
                        if (!configRecruitmentMasters.isEmpty() && configRecruitmentMasters.size() > 0
                                && configRecruitmentMasters.get(0) != null) {
                            jsonObject.put(
                                    messageSource.getMessage(
                                            "hrms.recruitment."
                                                    + StringUtil.mergeWithDots(configRecruitment.getName()),
                                            null, configRecruitment.getName(),
                                            RequestContextUtils.getLocale(request)),
                                    configRecruitmentMasters.get(0).getMasterdata() != null
                                            ? configRecruitmentMasters.get(0).getMasterdata()
                                            : "");
                        } else {
                            jsonObject.put(messageSource.getMessage(
                                    "hrms.recruitment." + StringUtil.mergeWithDots(configRecruitment.getName()),
                                    null, configRecruitment.getName(), RequestContextUtils.getLocale(request)),
                                    "");
                        }
                    } else {
                        Method getter = configrecdata.getMethod("getCol" + configRecruitment.getColnum());
                        Object object = getter.invoke(allapplication.getConfigjobapplicant());
                        if (configRecruitment.getConfigtype() == 5) {
                            jsonObject.put(
                                    messageSource.getMessage(
                                            "hrms.recruitment."
                                                    + StringUtil.mergeWithDots(configRecruitment.getName()),
                                            null, configRecruitment.getName(),
                                            RequestContextUtils.getLocale(request)),
                                    object != null ? (object.equals("") ? "No" : "Yes") : "No");
                        } else {
                            jsonObject.put(
                                    messageSource.getMessage(
                                            "hrms.recruitment."
                                                    + StringUtil.mergeWithDots(configRecruitment.getName()),
                                            null, configRecruitment.getName(),
                                            RequestContextUtils.getLocale(request)),
                                    object != null ? object : "");
                        }
                    }
                }
                jsonArray.put(jsonObject);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        return jsonArray;
    }
}

From source file:com.common.log.newproxy.BizStaticFileAppender.java

/**
 * // w w w.  ja va  2 s.  co  m
 */
private void publishOldCheckFile() {
    String statPath = LogHelper.getLogRootPath() + FILE_SEP + "log" + FILE_SEP + CHECKFILE_PATH + FILE_SEP;
    File path = new File(statPath);

    File[] checkFiles = path.listFiles();
    if (checkFiles == null) {//tat
        return;
    }
    HashMap extLogMap = new HashMap();
    HashMap chkLogMap = new HashMap();
    ArrayList keyDate = new ArrayList();
    for (int i = 0; i < checkFiles.length; i++) {
        File oldChkFile = checkFiles[i];
        String tmpfileName = oldChkFile.getName();
        String currfilename = currFile.getName();
        if (!tmpfileName.startsWith(currFile.getName())) {//?
            continue;
        }
        if (tmpfileName.endsWith(".bak")) {//??
                                           //int index=tmpfileName.indexOf(".log");
                                           //String fileDate=tmpfileName.substring(index+4,index+4+10);
                                           //String bizName=tmpfileName.substring(0,index+4);
            int index = fileName.lastIndexOf(FILE_SEP);
            //
            String bizName = fileName.substring(index + 1);
            String fileDate = getUnidateFromFileName(tmpfileName, bizName, datePattern);
            extLogMap.put(bizName + fileDate, oldChkFile);
        } else if (tmpfileName.endsWith(".999999")) {//?
            int index = fileName.lastIndexOf(FILE_SEP);
            //
            String bizName = fileName.substring(index + 1);
            String fileDate = getUnidateFromFileName(tmpfileName, bizName, stat_datepattern);
            keyDate.add(bizName + fileDate);
            //?
            //String strCurrDate = StringUtils.toString(new Date(),"yyyyMMdd");
            String yesterday = getLastDate();
            if (yesterday.equals(fileDate)) { //??,
                chkLogMap.put(bizName + fileDate, oldChkFile);
            }
        }
    }
    for (int i = 0; i < keyDate.size(); i++) {//?
        String logDay = (String) keyDate.get(i);
        if (chkLogMap.containsKey(logDay)) {//
            File checkFile = (File) chkLogMap.get(logDay);
            try {
                File targetFile = new File(currFile.getParentFile(), checkFile.getName());
                FileWriter fw = new FileWriter(checkFile, true);

                if (extLogMap.containsKey(logDay)) { //
                    File extFile = (File) extLogMap.get(logDay);
                    //?
                    fw.write(extFile.getName() + NEXT_LINE);
                    //
                    File targetExtFile = new File(currFile.getParentFile(), extFile.getName());
                    fileCopy(extFile, targetFile);

                    //?
                    File publishedExtFile = new File(extFile.getParentFile(),
                            extFile.getName() + PUBLISHED_CHECKFILE);
                    extFile.renameTo(publishedExtFile);

                }
                fw.write("999999" + NEXT_LINE);
                fw.flush();
                fw.close();
                fileCopy(checkFile, targetFile);
                //?
                File publishedCheckFile = new File(checkFile.getParentFile(),
                        checkFile.getName() + PUBLISHED_CHECKFILE);
                checkFile.renameTo(publishedCheckFile);
            } catch (IOException ex) {
                ex.printStackTrace();
            }

        }
    }
    extLogMap.clear();
    extLogMap = null;
    chkLogMap.clear();
    chkLogMap = null;
    keyDate.clear();
    keyDate = null;

}

From source file:com.krawler.spring.hrms.rec.job.hrmsRecJobController.java

public ModelAndView getjobprofileFunction(HttpServletRequest request, HttpServletResponse response) {
    KwlReturnObject result = null;/*from   w ww.jav a 2 s. c om*/
    JSONObject jobj = new JSONObject();
    JSONObject jobj1 = new JSONObject();
    String hql = "";
    int count = 0;
    List lst;
    try {
        //            Company cmp=(Company)session.get(Company.class,AuthHandler.getCompanyid(request));
        HashMap<String, Object> requestParams = new HashMap<String, Object>();
        CompanyPreferences cmp = (CompanyPreferences) kwlCommonTablesDAOObj.getObject(
                "com.krawler.common.admin.CompanyPreferences", sessionHandlerImplObj.getCompanyid(request));
        String jobidformat = (cmp.getJobidformat() == null ? "" : cmp.getJobidformat());
        //            hql = "from Positionmain where positionid=?";
        //            lst = HibernateUtil.executeQuery(session, hql, request.getParameter("position"));
        //            count = lst.size();
        //            Iterator ite = lst.iterator();
        //            requestParams = new HashMap<String, Object>();
        //            requestParams.put("positionid", request.getParameter("position"));
        //            result = hrmsRecJobDAOObj.getPositionmainbyposid(requestParams);
        ArrayList name = new ArrayList();
        ArrayList value = new ArrayList();
        name.add("positionid");
        value.add(request.getParameter("position"));
        requestParams.clear();
        requestParams.put("filter_names", name);
        requestParams.put("filter_values", value);
        result = hrmsRecJobDAOObj.getPositionmain(requestParams);
        lst = result.getEntityList();
        for (Integer ctr = 0; ctr < lst.size(); ctr++) {
            JSONObject tmpObj = new JSONObject();
            Positionmain psm = (Positionmain) lst.get(ctr);
            tmpObj.put("jobid", psm.getPositionid());
            tmpObj.put("posid", psm.getJobid());
            tmpObj.put("designation", psm.getPosition().getValue());
            tmpObj.put("details", psm.getDetails());
            tmpObj.put("department", psm.getDepartmentid().getValue());
            tmpObj.put("manager", psm.getManager().getUserID());
            tmpObj.put("startdate", psm.getStartdate());
            tmpObj.put("enddate", psm.getEnddate());
            tmpObj.put("expmonth", psm.getExperiencemonth());
            tmpObj.put("expyear", psm.getExperienceyear());
            tmpObj.put("relocation", psm.getRelocation());
            tmpObj.put("location", psm.getLocation());
            tmpObj.put("jobshift", psm.getJobshift());
            tmpObj.put("travel", psm.getTravel());
            tmpObj.put("nopos", psm.getNoofpos());
            tmpObj.put("jobmeta", getviewjobprofiledata(request, response));
            jobj.put("count", result.getRecordTotalCount());
            jobj.append("data", tmpObj);
        }

        jobj1.put("valid", true);
        jobj1.put("data", jobj.toString());
    } catch (Exception ex) {
        ex.printStackTrace();
    } finally {
        return new ModelAndView("jsonView", "model", jobj1.toString());
    }
}

From source file:com.krawler.spring.hrms.rec.job.hrmsRecJobController.java

public ModelAndView addjobprofile(HttpServletRequest request, HttpServletResponse response) {
    String id = "";
    KwlReturnObject result = null;//from  w w w  . j a  v  a  2 s  . co m
    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 jsondata1 = request.getParameter("jsondataresp");
        String jsondata2 = request.getParameter("jsondataskill");
        String jsondata3 = request.getParameter("jsondataqual");
        ArrayList name = new ArrayList();
        ArrayList value = new ArrayList();
        name.add("positionid");
        value.add(request.getParameter("position"));
        HashMap<String, Object> requestParams = new HashMap<String, Object>();
        requestParams.put("filter_names", name);
        requestParams.put("filter_values", value);
        result = hrmsRecJobDAOObj.getPositionmain(requestParams);
        Positionmain pos = null;
        if (result.getEntityList() != null && result.getEntityList().size() > 0)
            pos = (Positionmain) result.getEntityList().get(0);

        requestParams = new HashMap<String, Object>();
        JSONArray jarr = new JSONArray("[" + jsondata1 + "]");
        for (int i = 0; i < jarr.length(); i++) {
            JSONObject jobj = jarr.getJSONObject(i);
            if (!StringUtil.isNullOrEmpty(jobj.getString("id"))) {
                id = jobj.getString("id");
                requestParams.put("id", id);
            }
            requestParams.put("responsibility", jobj.getString("responsibility"));
            requestParams.put("position", pos);
            requestParams.put("type", jobj.getString("type"));
            hrmsRecJobDAOObj.addJobProfile(requestParams);
            requestParams.clear();
        }

        requestParams.clear();
        jarr = new JSONArray("[" + jsondata2 + "]");
        for (int j = 0; j < jarr.length(); j++) {
            JSONObject jobj = jarr.getJSONObject(j);
            if (!StringUtil.isNullOrEmpty(jobj.getString("id"))) {
                id = jobj.getString("id");
                requestParams.put("id", id);
            }
            requestParams.put("skill", jobj.getString("skill"));
            requestParams.put("skilldesc", jobj.getString("skilldesc"));
            requestParams.put("type", jobj.getString("type"));
            requestParams.put("position", pos);
            hrmsRecJobDAOObj.addJobProfile(requestParams);
            requestParams.clear();
        }

        requestParams.clear();
        jarr = new JSONArray("[" + jsondata3 + "]");
        for (int j = 0; j < jarr.length(); j++) {
            JSONObject jobj = jarr.getJSONObject(j);
            if (!StringUtil.isNullOrEmpty(jobj.getString("id"))) {
                id = jobj.getString("id");
                requestParams.put("id", id);
            }
            requestParams.put("qualification", jobj.getString("qualification"));
            requestParams.put("qualificationdesc", jobj.getString("qualificationdesc"));
            requestParams.put("type", jobj.getString("type"));
            requestParams.put("position", pos);
            hrmsRecJobDAOObj.addJobProfile(requestParams);
            requestParams.clear();
        }
        jobj1.put("valid", true);
        jobj1.put("data", "success");
        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.crm.caseModule.crmCaseReportController.java

public ModelAndView contactsWithCasesExport(HttpServletRequest request, HttpServletResponse response)
        throws ServletException {
    JSONObject jobj = new JSONObject();
    KwlReturnObject kmsg = null;/*  www. jav  a  2  s .c om*/
    String view = "jsonView";
    try {
        String export = request.getParameter("reportid");
        String companyid = sessionHandlerImpl.getCompanyid(request);
        StringBuffer usersList = sessionHandlerImplObj.getRecursiveUsersList(request);
        HashMap<String, Object> requestParams = new HashMap<String, Object>();
        requestParams.put("reportid", StringUtil.checkForNull(export));
        requestParams.put("ss", StringUtil.checkForNull(request.getParameter("ss")));
        requestParams.put("start", StringUtil.checkForNull(request.getParameter("start")));
        requestParams.put("limit", StringUtil.checkForNull(request.getParameter("limit")));
        requestParams.put("cd", StringUtil.checkForNull(request.getParameter("cd")));
        requestParams.put("frm", request.getParameter("frm"));
        requestParams.put("to", request.getParameter("to"));
        requestParams.put("companyid", companyid);
        boolean heirarchyPerm = crmManagerCommon.chkHeirarchyPerm(request, "Cases");
        requestParams.put("heirarchyPerm", heirarchyPerm);

        kmsg = caseReportDAOObj.contactsWithCasesReport(requestParams, usersList);
        List<CrmCase> lst = kmsg.getEntityList();
        List<String> idsList = new ArrayList<String>();
        for (CrmCase obj : lst) {
            idsList.add(obj.getCaseid());
        }
        Map<String, List<CrmProduct>> products = crmCaseDAOObj.getCaseProducts(idsList);
        Map<String, CrmAccount> accounts = crmCaseDAOObj.getCaseAccounts(idsList);
        Map<String, User> owners = crmCaseDAOObj.getCaseOwners(idsList);
        Map<String, CrmContact> contacts = crmCaseDAOObj.getCaseContacts(idsList);

        requestParams.clear();
        List filter_names = new ArrayList();
        List filter_params = new ArrayList();
        //Get ids of crmCombomaster table
        String masterIds = "'" + Constants.CASE_PRIORITYID + "',";
        masterIds += "'" + Constants.CASE_STATUSID + "',";
        masterIds += "'" + Constants.CASE_TYPEID + "'";
        filter_names.add("INc.crmCombomaster");
        filter_params.add(masterIds);
        filter_names.add("c.company.companyID");
        filter_params.add(companyid);
        requestParams.put(Constants.filter_names, filter_names);
        requestParams.put(Constants.filter_params, filter_params);
        HashMap<String, DefaultMasterItem> defaultMasterMap = crmCommonDAOObj
                .getDefaultMasterItemsMap(requestParams);

        jobj = contactsWithCasesReportJson(kmsg.getEntityList(), request, false, kmsg.getRecordTotalCount(),
                products, accounts, owners, contacts, defaultMasterMap);

        String fileType = request.getParameter("filetype");
        if (StringUtil.equal(fileType, "print")) {
            view = "jsonView-empty";
        }

        exportDAOImplObj.processRequest(request, response, jobj);
        auditTrailDAOObj.insertAuditLog(AuditAction.Contact_Cases,
                "Contacts with Cases Report exported in "
                        + StringUtil.chkExportFileTypeForAuditMsg(request.getParameter("filetype")),
                request, "0");
    } catch (Exception e) {
        LOGGER.warn(e.getMessage(), e);
    }
    return new ModelAndView(view, "model", jobj.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  .jav a2  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 sendLetters(HttpServletRequest request, HttpServletResponse response) {
    KwlReturnObject result = null;/*ww w.j a  v a 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.crm.caseModule.crmCaseReportController.java

public ModelAndView contactsWithCasesReport(HttpServletRequest request, HttpServletResponse response)
        throws ServletException {
    JSONObject jobj = new JSONObject();
    KwlReturnObject kmsg = null;/*w w w.j  ava 2s.  c  o m*/
    try {
        String export = request.getParameter("reportid");
        String companyid = sessionHandlerImpl.getCompanyid(request);
        StringBuffer usersList = sessionHandlerImplObj.getRecursiveUsersList(request);
        HashMap<String, Object> requestParams = new HashMap<String, Object>();
        requestParams.put("reportid", StringUtil.checkForNull(export));
        requestParams.put("ss", StringUtil.checkForNull(request.getParameter("ss")));
        requestParams.put("start", StringUtil.checkForNull(request.getParameter("start")));
        requestParams.put("limit", StringUtil.checkForNull(request.getParameter("limit")));
        requestParams.put("cd", StringUtil.checkForNull(request.getParameter("cd")));
        requestParams.put("frm", request.getParameter("frm"));
        requestParams.put("to", request.getParameter("to"));
        requestParams.put("companyid", companyid);
        boolean heirarchyPermCas = crmManagerCommon.chkHeirarchyPerm(request, "Cases");
        requestParams.put("heirarchyPermCas", heirarchyPermCas);
        boolean heirarchyPermCon = crmManagerCommon.chkHeirarchyPerm(request, "Contact");
        requestParams.put("heirarchyPermCon", heirarchyPermCon);

        kmsg = caseReportDAOObj.contactsWithCasesReport(requestParams, usersList);
        List<CrmCase> lst = kmsg.getEntityList();
        List<String> idsList = new ArrayList<String>();
        for (CrmCase obj : lst) {
            idsList.add(obj.getCaseid());
        }
        Map<String, List<CrmProduct>> products = crmCaseDAOObj.getCaseProducts(idsList);
        Map<String, CrmAccount> accounts = crmCaseDAOObj.getCaseAccounts(idsList);
        Map<String, User> owners = crmCaseDAOObj.getCaseOwners(idsList);
        Map<String, CrmContact> contacts = crmCaseDAOObj.getCaseContacts(idsList);

        requestParams.clear();
        List filter_names = new ArrayList();
        List filter_params = new ArrayList();
        //Get ids of crmCombomaster table
        String masterIds = "'" + Constants.CASE_PRIORITYID + "',";
        masterIds += "'" + Constants.CASE_STATUSID + "',";
        masterIds += "'" + Constants.CASE_TYPEID + "'";
        filter_names.add("INc.crmCombomaster");
        filter_params.add(masterIds);
        filter_names.add("c.company.companyID");
        filter_params.add(companyid);
        requestParams.put(Constants.filter_names, filter_names);
        requestParams.put(Constants.filter_params, filter_params);
        HashMap<String, DefaultMasterItem> defaultMasterMap = crmCommonDAOObj
                .getDefaultMasterItemsMap(requestParams);

        jobj = contactsWithCasesReportJson(kmsg.getEntityList(), request, true, kmsg.getRecordTotalCount(),
                products, accounts, owners, contacts, defaultMasterMap);
    } catch (Exception e) {
        LOGGER.warn(e.getMessage(), e);
    }
    return new ModelAndView("jsonView", "model", jobj.toString());
}