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 getEmpidFormat(HttpServletRequest request, HttpServletResponse response) {
    KwlReturnObject result = null;//from  ww  w . j a  va2s  . c o  m
    JSONObject jobj = new JSONObject();
    JSONObject jobj1 = new JSONObject();
    JSONArray jarr = new JSONArray();
    JSONObject obj = new JSONObject();
    int count = 0;
    String mainstr = "";
    Integer maxcount = null;
    try {

        HashMap<String, Object> requestParams = new HashMap<String, Object>();
        ArrayList filter_names = new ArrayList(), filter_values = new ArrayList(), select = new ArrayList();

        String cmpnyid = sessionHandlerImplObj.getCompanyid(request);
        filter_names.add("user.company.companyID");
        filter_values.add(cmpnyid);
        select.add("max(employeeid)");

        requestParams.put("filter_names", filter_names);
        requestParams.put("filter_values", filter_values);
        requestParams.put("select", select);

        result = hrmsCommonDAOObj.getUseraccount(requestParams);
        maxcount = (Integer) result.getEntityList().iterator().next() + 1;

        requestParams.clear();
        requestParams.put("empid", maxcount);
        requestParams.put("companyid", cmpnyid);

        result = hrmsCommonDAOObj.getEmpidFormatEdit(requestParams);
        mainstr = result.getEntityList().get(0).toString();

        obj.put("maxempid", mainstr);
        jarr.put(obj);
        jobj.put("data", jarr);
        jobj.put("count", count);
        jobj1.put("data", jobj.toString());
        jobj1.put("valid", true);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        return new ModelAndView("jsonView", "model", jobj1.toString());
    }
}

From source file:org.ossmeter.metricprovider.trans.newsgroups.threads.Threader.java

/**
 *  If any two members of the root set have the same subject, merge them. This is to attempt to accomodate messages without References: headers.
 *//*from  w ww.  j  ava 2 s.  co m*/
private void gatherSubjects() {

    int count = 0;

    for (ThreadContainer c = root.child; c != null; c = c.next) {
        count++;
    }

    // TODO verify this will avoid rehashing
    HashMap<String, ThreadContainer> subjectTable = new HashMap<String, ThreadContainer>((int) (count * 1.2),
            (float) 0.9);
    count = 0;

    for (ThreadContainer c = root.child; c != null; c = c.next) {
        Threadable threadable = c.threadable;

        // No threadable? If so, it is a dummy node in the root set.
        // Only root set members may be dummies, and they alway have at least 2 kids
        // Take the first kid as representative of the subject
        if (threadable == null) {
            threadable = c.child.threadable;
        }

        String subj = threadable.simplifiedSubject();

        if (subj == null || subj.length() == 0) {
            continue;
        }

        ThreadContainer old = subjectTable.get(subj);

        // Add this container to the table iff:
        // - There exists no container with this subject
        // - or this is a dummy container and the old one is not - the dummy one is
        // more interesting as a root, so put it in the table instead
        // - The container in the table has a "Re:" version of this subject, and
        // this container has a non-"Re:" version of this subject. The non-"Re:" version
        // is the more interesting of the two.
        if (old == null || (c.threadable == null && old.threadable != null) || (old.threadable != null
                && old.threadable.subjectIsReply() && c.threadable != null && !c.threadable.subjectIsReply())) {
            subjectTable.put(subj, c);
            count++;
        }
    }

    // If the table is empty, we're done
    if (count == 0) {
        return;
    }

    // subjectTable is now populated with one entry for each subject which occurs in the
    // root set. Iterate over the root set, and gather together the difference.
    ThreadContainer prev, c, rest;
    for (prev = null, c = root.child, rest = c.next; c != null; prev = c, c = rest, rest = (rest == null ? null
            : rest.next)) {
        Threadable threadable = c.threadable;

        // is it a dummy node?
        if (threadable == null) {
            threadable = c.child.threadable;
        }

        String subj = threadable.simplifiedSubject();

        // Dont thread together all subjectless messages
        if (subj == null || subj.length() == 0) {
            continue;
        }

        ThreadContainer old = subjectTable.get(subj);

        if (old == c) { // That's us
            continue;
        }

        // We have now found another container in the root set with the same subject
        // Remove the "second" message from the root set
        if (prev == null) {
            root.child = c.next;
        } else {
            prev.next = c.next;
        }
        c.next = null;

        if (old.threadable == null && c.threadable == null) {
            // both dummies - merge them
            ThreadContainer tail;
            for (tail = old.child; tail != null && tail.next != null; tail = tail.next) {
                // do nothing
            }

            if (tail != null) { // protect against possible NPE
                tail.next = c.child;
            }

            for (tail = c.child; tail != null; tail = tail.next) {
                tail.parent = old;
            }

            c.child = null;
        } else if (old.threadable == null || (c.threadable != null && c.threadable.subjectIsReply()
                && !old.threadable.subjectIsReply())) {
            // Else if old is empty, or c has "Re:" and old does not  ==> make this message a child of old
            c.parent = old;
            c.next = old.child;
            old.child = c;
        } else {
            // else make the old and new messages be children of a new dummy container.
            // We create a new container object for old.msg and empty the old container
            ThreadContainer newc = new ThreadContainer();
            newc.threadable = old.threadable;
            newc.child = old.child;

            for (ThreadContainer tail = newc.child; tail != null; tail = tail.next) {
                tail.parent = newc;
            }

            old.threadable = null;
            old.child = null;

            c.parent = old;
            newc.parent = old;

            // Old is now a dummy- give it 2 kids , c and newc
            old.child = c;
            c.next = newc;
        }
        // We've done a merge, so keep the same prev
        c = prev;
    }

    subjectTable.clear();
    subjectTable = null;

}

From source file:org.lockss.plugin.PluginManager.java

/**
 * Run through the list of Registry AUs and verify and load any JARs
 * that need to be loaded./*from  w w  w .  jav a2s. c  o  m*/
 */
public synchronized void processRegistryAus(List registryAus, boolean startAus) {

    if (jarValidator == null) {
        jarValidator = new JarValidator(keystore, pluginDir);
    }
    jarValidator.allowExpired(acceptExpiredCertificates);

    // Create temporary plugin and classloader maps
    HashMap tmpMap = new HashMap();

    for (Iterator iter = registryAus.iterator(); iter.hasNext();) {
        ArchivalUnit au = (ArchivalUnit) iter.next();
        try {
            processOneRegistryAu(au, tmpMap);
        } catch (RuntimeException e) {
            log.error("Error processing plugin registry AU: " + au, e);
        }
    }

    // After the temporary plugin map has been built, install it into
    // the global maps.
    List classloaders = new ArrayList();

    // AUs running under plugins that have been replaced by new versions.
    List<ArchivalUnit> needRestartAus = new ArrayList();
    List<String> changedPluginKeys = new ArrayList<String>();

    for (Iterator pluginIter = tmpMap.entrySet().iterator(); pluginIter.hasNext();) {
        Map.Entry entry = (Map.Entry) pluginIter.next();
        String key = (String) entry.getKey();
        log.debug2("Adding to plugin map: " + key);
        PluginInfo info = (PluginInfo) entry.getValue();
        pluginfoMap.put(key, info);
        classloaders.add(info.getClassLoader());

        Plugin oldPlug = getPlugin(key);
        if (oldPlug != null && paramRestartAus) {
            Collection aus = oldPlug.getAllAus();
            if (aus != null) {
                needRestartAus.addAll(aus);
            }
        }

        Plugin newPlug = info.getPlugin();
        setPlugin(key, newPlug);
        if (startAus && newPlug != oldPlug) {
            changedPluginKeys.add(key);
        }
    }

    // Title DBs bundled with plugin jars are currently disabled.  To work
    // correctly, bundled tdb files must be removed from the config if/when
    // the containing plugin is unloaded/superseded.

    //     // Add the JAR's bundled titledb config (if any) to the ConfigManager.
    //     // Do this once at the end so as not to trigger more than one config
    //     // update & reload.
    //     configMgr.addTitleDbConfigFrom(classloaders);

    // Cleanup as a hint to GC.
    tmpMap.clear();
    tmpMap = null;

    if (!needRestartAus.isEmpty()) {
        restartAus(needRestartAus);
    }

    if (startAus && !changedPluginKeys.isEmpty()) {
        // Try to start any AUs configured for changed plugins, that didn't
        // previously start (either because the plugin didn't exist, or the
        // AU didn't successfully start with the old definition)
        configurePlugins(changedPluginKeys);
    }
}

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;/*from w ww .  ja va  2 s .  com*/
    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 getConfigRecruitmentApplyOnline(HttpServletRequest request, HttpServletResponse response) {
    KwlReturnObject result = null;/*from   w  w w .j  av a 2 s .  c  om*/
    List lstJobApplicant = null;
    JSONObject jobj = new JSONObject();
    JSONObject jobj1 = new JSONObject();
    JSONArray jarr = new JSONArray();
    ConfigRecruitmentData ConfigRecruitmentDataref = null;
    Class configrecdata = null;
    int count = 0;
    try {
        String companyid = request.getParameter("companyid");
        HashMap<String, Object> requestParams = new HashMap<String, Object>();
        if (request.getParameter("formtype") != null && request.getParameter("visible") != null) {
            requestParams.put("primary", true);
            requestParams.put("applicantid", request.getParameter("refid"));
            KwlReturnObject resultJobApplicant = hrmsRecJobDAOObj.getConfigJobApplicant(requestParams);
            lstJobApplicant = resultJobApplicant.getEntityList();
            Iterator ite = lstJobApplicant.iterator();
            while (ite.hasNext()) {
                ConfigRecruitmentDataref = (ConfigRecruitmentData) ite.next();
            }
            configrecdata = Class.forName("com.krawler.hrms.recruitment.ConfigRecruitmentData");
            requestParams.clear();

            if (request.getParameter("formtype").equals("All")) {
                requestParams.put("filter_names", Arrays.asList("company.companyID", "visible"));
                requestParams.put("filter_values",
                        Arrays.asList(companyid, Boolean.parseBoolean(request.getParameter("visible"))));
            } else {
                requestParams.put("filter_names", Arrays.asList("company.companyID", "formtype", "visible"));
                requestParams.put("filter_values", Arrays.asList(companyid, request.getParameter("formtype"),
                        Boolean.parseBoolean(request.getParameter("visible"))));
            }

        } else if (request.getParameter("configtype") != null) {
            requestParams.put("filter_names", Arrays.asList("company.companyID", "INconfigtype"));
            requestParams.put("filter_values", Arrays.asList(companyid, request.getParameter("configtype")));
        } else if (request.getParameter("visible") != null) {
            requestParams.put("filter_names", Arrays.asList("company.companyID", "visible"));
            requestParams.put("filter_values",
                    Arrays.asList(companyid, Boolean.parseBoolean(request.getParameter("visible"))));
        } else {
            requestParams.put("filter_names", Arrays.asList("company.companyID"));
            requestParams.put("filter_values", Arrays.asList(companyid));
        }

        requestParams.put("ss", request.getParameter("ss"));
        requestParams.put("searchcol", new String[] { "name" });
        if (request.getParameter("mapping") != null) {
            requestParams.put("order_by", Arrays.asList("colnum"));
            requestParams.put("order_type", Arrays.asList("asc"));
        } else {
            requestParams.put("order_by", Arrays.asList("formtype", "position"));
            requestParams.put("order_type", Arrays.asList("asc", "asc"));
        }
        result = hrmsRecJobDAOObj.getConfigRecruitment(requestParams);
        List lst = result.getEntityList();
        Iterator ite = lst.iterator();
        int i = 0;
        while (ite.hasNext()) {
            ConfigRecruitment contyp = (ConfigRecruitment) ite.next();
            JSONObject tmpObj = new JSONObject();
            tmpObj.put("index", i);
            tmpObj.put("configid", contyp.getConfigid());
            tmpObj.put("configtype", contyp.getConfigtype());
            tmpObj.put("fieldname",
                    messageSource.getMessage("hrms.recruitment." + StringUtil.mergeWithDots(contyp.getName()),
                            null, contyp.getName(), RequestContextUtils.getLocale(request)));
            tmpObj.put("formtype", contyp.getFormtype());
            tmpObj.put("position", contyp.getPosition());
            tmpObj.put("colnum", contyp.getColnum());
            tmpObj.put("issystemproperty", contyp.isIsSystemProperty());
            tmpObj.put("visible", contyp.isVisible());
            tmpObj.put("allownull", contyp.isAllownull());
            tmpObj.put("allowblank", contyp.isAllownull());
            tmpObj.put("displayname",
                    messageSource.getMessage("hrms.recruitment." + StringUtil.mergeWithDots(contyp.getName()),
                            null, contyp.getName(), RequestContextUtils.getLocale(request)) + " ("
                            + contyp.getFormtype() + ")");
            if (request.getParameter("fetchmaster") != null) {
                if (contyp.getConfigtype() == 3 || contyp.getConfigtype() == 1) {
                    requestParams.clear();
                    requestParams.put("filter_names", Arrays.asList("configid.configid"));
                    requestParams.put("filter_values", Arrays.asList(contyp.getConfigid()));
                    tmpObj.put("data", getConfigMasterdata(requestParams, request));
                }
            }
            if (request.getParameter("refid") != null && configrecdata != null) {
                JSONArray cdata = new JSONArray();
                Method getter = configrecdata.getMethod("getCol" + contyp.getColnum());
                Object obj = getter.invoke(ConfigRecruitmentDataref);
                cdata.put(obj);
                tmpObj.put("configdata", cdata);
            }
            i++;
            jarr.put(tmpObj);
        }
        jobj.put("data", jarr);
        jobj.put("count", count);
        jobj1.put("data", jobj.toString());
        jobj1.put("valid", true);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        return new ModelAndView(successView, "model", jobj1.toString());
    }
}

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

public ModelAndView getConfigRecruitment(HttpServletRequest request, HttpServletResponse response) {
    KwlReturnObject result = null;//from  ww  w . ja  v  a 2 s .  c om
    List lstJobApplicant = null;
    JSONObject jobj = new JSONObject();
    JSONObject jobj1 = new JSONObject();
    JSONArray jarr = new JSONArray();
    ConfigRecruitmentData ConfigRecruitmentDataref = null;
    Class configrecdata = null;
    int count = 0;
    try {
        HashMap<String, Object> requestParams = new HashMap<String, Object>();
        if (request.getParameter("formtype") != null && request.getParameter("visible") != null) {
            requestParams.put("primary", true);
            requestParams.put("applicantid", request.getParameter("refid"));
            KwlReturnObject resultJobApplicant = hrmsRecJobDAOObj.getConfigJobApplicant(requestParams);
            lstJobApplicant = resultJobApplicant.getEntityList();
            Iterator ite = lstJobApplicant.iterator();
            while (ite.hasNext()) {
                ConfigRecruitmentDataref = (ConfigRecruitmentData) ite.next();
            }
            configrecdata = Class.forName("com.krawler.hrms.recruitment.ConfigRecruitmentData");
            requestParams.clear();

            if (request.getParameter("formtype").equals("All")) {
                requestParams.put("filter_names", Arrays.asList("company.companyID", "visible"));
                requestParams.put("filter_values", Arrays.asList(sessionHandlerImplObj.getCompanyid(request),
                        Boolean.parseBoolean(request.getParameter("visible"))));
            } else {
                requestParams.put("filter_names", Arrays.asList("company.companyID", "formtype", "visible"));
                requestParams.put("filter_values",
                        Arrays.asList(sessionHandlerImplObj.getCompanyid(request),
                                request.getParameter("formtype"),
                                Boolean.parseBoolean(request.getParameter("visible"))));
            }

        } else if (request.getParameter("configtype") != null) {
            requestParams.put("filter_names", Arrays.asList("company.companyID", "INconfigtype"));
            requestParams.put("filter_values", Arrays.asList(sessionHandlerImplObj.getCompanyid(request),
                    request.getParameter("configtype")));
        } else if (request.getParameter("visible") != null) {
            requestParams.put("filter_names", Arrays.asList("company.companyID", "visible"));
            requestParams.put("filter_values", Arrays.asList(sessionHandlerImplObj.getCompanyid(request),
                    Boolean.parseBoolean(request.getParameter("visible"))));
        } else {
            requestParams.put("filter_names", Arrays.asList("company.companyID"));
            requestParams.put("filter_values", Arrays.asList(sessionHandlerImplObj.getCompanyid(request)));
        }

        requestParams.put("ss", request.getParameter("ss"));
        requestParams.put("searchcol", new String[] { "name" });
        if (request.getParameter("mapping") != null) {
            requestParams.put("order_by", Arrays.asList("colnum"));
            requestParams.put("order_type", Arrays.asList("asc"));
        } else {
            requestParams.put("order_by", Arrays.asList("formtype", "position"));
            requestParams.put("order_type", Arrays.asList("asc", "asc"));
        }
        result = hrmsRecJobDAOObj.getConfigRecruitment(requestParams);
        List lst = result.getEntityList();
        Iterator ite = lst.iterator();
        int i = 0;
        while (ite.hasNext()) {
            ConfigRecruitment contyp = (ConfigRecruitment) ite.next();
            JSONObject tmpObj = new JSONObject();
            tmpObj.put("index", i);
            tmpObj.put("configid", contyp.getConfigid());
            tmpObj.put("configtype", contyp.getConfigtype());
            tmpObj.put("fieldname",
                    messageSource.getMessage("hrms.recruitment." + StringUtil.mergeWithDots(contyp.getName()),
                            null, contyp.getName(), RequestContextUtils.getLocale(request)));
            tmpObj.put("formtype", contyp.getFormtype());
            tmpObj.put("position", contyp.getPosition());
            tmpObj.put("colnum", contyp.getColnum());
            tmpObj.put("issystemproperty", contyp.isIsSystemProperty());
            tmpObj.put("visible", contyp.isVisible());
            tmpObj.put("allownull", contyp.isAllownull());
            tmpObj.put("allowblank", contyp.isAllownull());
            tmpObj.put("displayname",
                    messageSource.getMessage("hrms.recruitment." + StringUtil.mergeWithDots(contyp.getName()),
                            null, contyp.getName(), RequestContextUtils.getLocale(request)) + " ("
                            + contyp.getFormtype() + ")");
            if (request.getParameter("fetchmaster") != null) {
                if (contyp.getConfigtype() == 3 || contyp.getConfigtype() == 1) {
                    requestParams.clear();
                    requestParams.put("filter_names", Arrays.asList("configid.configid"));
                    requestParams.put("filter_values", Arrays.asList(contyp.getConfigid()));
                    tmpObj.put("data", getConfigMasterdataWithLocalString(requestParams, request));
                }
            }
            if (request.getParameter("refid") != null && configrecdata != null) {
                JSONArray cdata = new JSONArray();
                Method getter = configrecdata.getMethod("getCol" + contyp.getColnum());
                Object obj = getter.invoke(ConfigRecruitmentDataref);
                cdata.put(obj);
                tmpObj.put("configdata", cdata);
            }
            i++;
            jarr.put(tmpObj);
        }
        jobj.put("data", jarr);
        jobj.put("count", count);
        jobj1.put("data", jobj.toString());
        jobj1.put("valid", true);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return new ModelAndView(successView, "model", jobj1.toString());
}

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

public ModelAndView DeleteInternalJobs(HttpServletRequest request, HttpServletResponse response) {
    List tabledata = null;/*from   w w  w  . j  a va  2 s  . co m*/
    JSONObject jobj = new JSONObject();
    JSONObject jobj1 = new JSONObject();
    String hql = null;
    boolean flag = true;
    ArrayList<String> name = new ArrayList<String>();
    ArrayList<Object> value = new ArrayList<Object>();
    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);
    String title = "Success";
    try {
        String delids[] = request.getParameterValues("delid");
        for (int i = 0; i < delids.length; i++) {
            name.clear();
            value.clear();
            //                hql = "from Allapplications where position.positionid=? and company.companyID=? and delflag=0";
            //                tabledata = HibernateUtil.executeQuery(session, hql, new Object[]{delids[i], AuthHandler.getCompanyid(request)});
            name.add("position.positionid");
            value.add(delids[i]);
            name.add("company.companyID");
            value.add(sessionHandlerImplObj.getCompanyid(request));
            name.add("delflag");
            value.add(0);
            result = hrmsRecJobDAOObj.getPositionstatus(name, value);
            tabledata = result.getEntityList();
            if (tabledata.isEmpty()) {
                HashMap<String, Object> requestParams = new HashMap<String, Object>();

                requestParams.put("filter_names", Arrays.asList("applypos"));
                requestParams.put("filter_values", Arrays.asList((Positionmain) kwlCommonTablesDAOObj
                        .getObject("com.krawler.hrms.recruitment.Positionmain", delids[i])));
                result = hrmsRecAgencyDAOObj.getApplyagency(requestParams);
                if (result.getEntityList().isEmpty()) {
                    name.clear();
                    value.clear();
                    name.add("positionid");
                    value.add(delids[i]);

                    //                    hql = "from Positionmain where positionid=?";
                    //                    tabledata = HibernateUtil.executeQuery(session, hql, delids[i]);
                    requestParams.clear();
                    requestParams.put("filter_names", name);
                    requestParams.put("filter_values", value);
                    result = hrmsRecJobDAOObj.getPositionmain(requestParams);
                    tabledata = result.getEntityList();
                    if (!tabledata.isEmpty()) {
                        requestParams = new HashMap<String, Object>();
                        requestParams.put("delflag", 1);
                        requestParams.put("positionid", delids[i]);
                        result = hrmsRecJobDAOObj.updatePositionmain(requestParams);
                        //                        Positionmain log = (Positionmain) tabledata.get(0);
                        //                        log.setDelflag(1);
                        //                        session.update(log);

                    }
                } else {
                    flag = false;
                }
            } else {
                flag = false;
            }
        }
        if (flag) {
            jobj.put("message",
                    messageSource.getMessage("hrms.recruitment.SelectedJobPositionsuccessfullydeleted", null,
                            "Selected Job Position(s) successfully deleted.",
                            RequestContextUtils.getLocale(request)));
        } else {
            jobj.put("message", messageSource.getMessage("hrms.recruitment.SomejobscannotbedeletedBeacause",
                    null,
                    "Some jobs have assigned applicants or are assigned to agencies and hence cannot be deleted.",
                    RequestContextUtils.getLocale(request)));
        }
        jobj1.put("valid", true);
        jobj.put("title", title);
        jobj1.put("data", jobj.toString());
        txnManager.commit(status);
    } catch (Exception ex) {
        ex.printStackTrace();
        txnManager.rollback(status);
    } finally {
        return new ModelAndView("jsonView", "model", jobj1.toString());
    }
}

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

public ArrayList<String[]> getUserLetterValues(String applicant_id, String company_id,
        ArrayList<String[]> placeholderNPaths) throws ServiceException {
    ArrayList<String[]> phValuePairs = new ArrayList<String[]>();
    //code for user based values
    int i = 0;/*from   w w w  .  ja  va  2 s.c o m*/
    KwlReturnObject result = null;
    HashMap<String, Object> requestParams = new HashMap<String, Object>();
    while (i < placeholderNPaths.size()) {
        requestParams.put("applicant_id", applicant_id);
        requestParams.put("getph", placeholderNPaths.get(i)[2]);
        requestParams.put("gettable", placeholderNPaths.get(i)[0]);
        requestParams.put("companyid", company_id);
        result = hrmsRecJobDAOObj.getPlaceHolderUserValue(requestParams);
        String phlStr = "";
        if (result.getEntityList().size() > 0) {
            phlStr = result.getEntityList().get(0) != null ? ((String) result.getEntityList().get(0)) : "";
        } else {
            throw ServiceException
                    .FAILURE("This Email Template is created for " + placeholderNPaths.get(i)[0] + ".", null);
        }
        phValuePairs.add(new String[] { placeholderNPaths.get(i)[0], placeholderNPaths.get(i)[1], phlStr });
        i++;
        requestParams.clear();
    }
    return phValuePairs;
}

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

public JSONObject getJobs(HttpServletRequest request, Boolean export) {
    JSONObject jobj = new JSONObject();
    JSONArray jarr = new JSONArray();
    String jobtype = request.getParameter("jobtype");
    int jobstatus = Integer.parseInt(request.getParameter("jobstatus"));
    List lst;/*w  w  w  . j  a v  a2 s.com*/
    int count = 0;
    String status = "";
    Positionmain psm;
    KwlReturnObject result = null;
    try {
        String Searchjson = request.getParameter("searchJson");
        String cid = sessionHandlerImplObj.getCompanyid(request);
        String ss = request.getParameter("ss");
        HashMap<String, Object> requestParams = new HashMap<String, Object>();
        requestParams.put("companyid", cid);
        result = profileHandlerDAOObj.getCompanyid(requestParams);
        Company cmp = null;
        if (result.getEntityList() != null && result.getEntityList().size() > 0) {
            cmp = (Company) result.getEntityList().get(0);
        }
        ArrayList<String> name = new ArrayList<String>();
        ArrayList<Object> value = new ArrayList<Object>();

        if (StringUtil.isNullOrEmpty(request.getParameter("employee"))) {
            name.add("company.companyID");
            value.add(cid);

            name.add("delflag");
            value.add(0);

            name.add("<enddate");
            value.add(new Date());

            requestParams.clear();
            requestParams.put("filter_names", name);
            requestParams.put("filter_values", value);

            result = hrmsRecJobDAOObj.getPositionmain(requestParams);
            lst = result.getEntityList();
            count = result.getRecordTotalCount();
            for (Integer ctr = 0; ctr < lst.size(); ctr++) {
                Positionmain psmain = (Positionmain) lst.get(ctr);
                requestParams = new HashMap<String, Object>();
                requestParams.put("positionid", psmain.getPositionid());
                requestParams.put("delflag", 2);
                hrmsRecJobDAOObj.updatePositionmain(requestParams);
            }
            name = new ArrayList<String>();
            value = new ArrayList<Object>();
            name.add("company.companyID");
            value.add(cid);

            if (!StringUtil.isNullOrEmpty(request.getParameter("vacancy"))) {
                name.add("!(noofpos-positionsfilled)");
                value.add(0);
            }
            if (jobtype.equalsIgnoreCase("All")) {
                if (jobstatus == 4) {
                    name.add("!delflag");
                    value.add(1);
                } else {
                    name.add("delflag");
                    value.add(jobstatus);
                }
            } else {
                if (jobstatus == 4) {
                    name.add("!delflag");
                    value.add(1);

                    name.add("jobtype");
                    value.add(jobtype);
                } else {
                    name.add("delflag");
                    value.add(jobstatus);

                    name.add("jobtype");
                    value.add(jobtype);
                }
            }
        } else {
            name = new ArrayList<String>();
            value = new ArrayList<Object>();

            name.add("company.companyID");
            value.add(cid);

            name.add("!jobtype");
            value.add("External");

            name.add("delflag");
            value.add(0);

            name.add("<=startdate");
            value.add(new Date());

            name.add(">=enddate");
            value.add(new Date());

        }
        requestParams.clear();
        requestParams.put("filter_names", name);
        requestParams.put("filter_values", value);
        requestParams.put("allflag", export);
        requestParams.put("ss", ss);
        requestParams.put("searchcol", new String[] { "jobid", "details", "departmentid.value",
                "position.value", "manager.firstName", "manager.lastName" });
        if (!StringUtil.isNullOrEmpty(Searchjson)) {
            getMyAdvanceSearchparams(Searchjson, name);
            insertParamAdvanceSearchString(value, Searchjson);
        }
        StringUtil.checkpaging(requestParams, request);
        result = hrmsRecJobDAOObj.getPositionmain(requestParams);
        lst = result.getEntityList();
        count = result.getRecordTotalCount();
        for (Integer ctr = 0; ctr < lst.size(); ctr++) {
            JSONObject tmpObj = new JSONObject();
            psm = (Positionmain) lst.get(ctr);
            tmpObj.put("posid", psm.getPositionid());
            requestParams = new HashMap<String, Object>();
            requestParams.put("positionid", psm.getPositionid());
            requestParams.put("userid", sessionHandlerImplObj.getUserid(request));
            name = new ArrayList<String>();
            value = new ArrayList<Object>();

            name.add("position.positionid");
            value.add(psm.getPositionid());
            name.add("employee.userID");
            value.add(sessionHandlerImplObj.getUserid(request));
            name.add("delflag");
            value.add(0);
            result = hrmsRecJobDAOObj.getPositionstatus(name, value);
            List statusList = result.getEntityList();
            Allapplications appobj = null;
            if (statusList != null && statusList.size() > 0) {
                appobj = (Allapplications) statusList.get(0);
                status = appobj.getStatus();
            } else {
                status = "none";
            }

            if (status.equalsIgnoreCase("none")) {
                tmpObj.put("status", 0);
                tmpObj.put("selectionstatus", messageSource.getMessage("hrms.recruitment.not.applied", null,
                        RequestContextUtils.getLocale(request)));
            } else {
                tmpObj.put("status", 1);
                tmpObj.put("applicationid", appobj.getId());
                tmpObj.put("selectionstatus", status);
            }
            tmpObj.put("posmasterid", psm.getPosition().getId());
            tmpObj.put("jobid", psm.getJobid());
            tmpObj.put("posname", psm.getPosition().getValue());
            tmpObj.put("details", psm.getDetails());
            tmpObj.put("department", psm.getDepartmentid().getValue());
            tmpObj.put("manager", psm.getManager().getFirstName() + " " + psm.getManager().getLastName());
            tmpObj.put("startdate", sessionHandlerImplObj.getDateFormatter(request).format(psm.getStartdate()));
            tmpObj.put("enddate", sessionHandlerImplObj.getDateFormatter(request).format(psm.getEnddate()));
            tmpObj.put("jobtype", psm.getJobtype());
            tmpObj.put("positionstatus", psm.getDelflag());
            tmpObj.put("departmentid", psm.getDepartmentid().getId());
            tmpObj.put("managerid", psm.getManager().getUserID());
            tmpObj.put("nopos", psm.getNoofpos());
            tmpObj.put("posfilled", psm.getPositionsfilled());
            String url = URLUtil.getPageURL(request, Links.loginpagewthFull, cmp.getSubDomain())
                    + "jobs.jsp?jobid=" + psm.getPositionid() + "";
            tmpObj.put("url", url);
            jarr.put(tmpObj);
        }
        jobj.put("data", jarr);
        jobj.put("count", count);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return jobj;
}

From source file:de.ingrid.ibus.comm.Bus.java

public IngridHitDetail[] getDetails(IngridHit[] hits, IngridQuery query, String[] requestedFields)
        throws Exception {
    long startGetDetails = 0;
    if (fLogger.isDebugEnabled()) {
        startGetDetails = System.currentTimeMillis();
    }/*from w w  w  .j a va2  s. c  o  m*/
    if (requestedFields == null) {
        requestedFields = new String[0];
    }
    // collect requests for plugs
    HashMap hashMap = new HashMap();
    IngridHit hit = null;
    for (int i = 0; i < hits.length; i++) {
        hit = hits[i];
        // ignore hit if hit is "placeholder"
        if (hit.isDummyHit()) {
            if (fLogger.isDebugEnabled()) {
                fLogger.debug("getDetails: do NOT call iPlug for dummy hit: " + hit);
            }
            continue;
        }
        ArrayList requestHitList = (ArrayList) hashMap.get(hit.getPlugId());
        if (requestHitList == null) {
            requestHitList = new ArrayList();
            hashMap.put(hit.getPlugId(), requestHitList);
        }
        requestHitList.add(hit);
    }
    // send requests and collect response
    Iterator iterator = hashMap.keySet().iterator();
    IPlug plugProxy;
    ArrayList resultList = new ArrayList(hits.length);
    Random random = new Random(System.currentTimeMillis());
    long time = 0;
    while (iterator.hasNext()) {
        String plugId = (String) iterator.next();
        ArrayList requestHitList = (ArrayList) hashMap.get(plugId);
        if (requestHitList != null) {
            IngridHit[] requestHits = (IngridHit[]) requestHitList
                    .toArray(new IngridHit[requestHitList.size()]);
            plugProxy = this.fRegistry.getPlugProxy(plugId);

            /*
             * iPlugs with older base-webapp than version 5.0.0 set requested fields "title" and "summary" on detail search by default.
             * The base-webapp since version 5.0.0 set no fields by default. Requested field "title" and "summary" must set
             * by the search component like portal.
             * To make older iPlugs running with duplicate fields (default and requested fields) field "title" and "summary" must
             * be remove on requested fields.
             */
            PlugDescription pd = this.fRegistry.getPlugDescription(plugId);
            if (pd != null) {
                Metadata metadata = pd.getMetadata();
                if (metadata != null) {
                    String pdVersion = metadata.getVersion();
                    if (!IPlugVersionInspector.compareVersion(pdVersion, IPLUG_OLD_VERSION_REMOVE_FIELDS)) {
                        List<String> list = new ArrayList<String>(Arrays.asList(requestedFields));
                        list.remove("title");
                        list.remove("summary");
                        list.remove("content");
                        requestedFields = list.toArray(new String[0]);
                    }
                }
            }

            if (fLogger.isDebugEnabled()) {
                fLogger.debug("(search) details start " + plugId + " (" + requestHits.length + ") "
                        + query.hashCode());
            }
            time = System.currentTimeMillis();
            IngridHitDetail[] responseDetails = plugProxy.getDetails(requestHits, query, requestedFields);
            if (fLogger.isDebugEnabled()) {
                fLogger.debug("(search) details ends (" + responseDetails.length + ")" + plugId + " query:"
                        + query.hashCode() + " within " + (System.currentTimeMillis() - time) + " ms.");
            }
            for (int i = 0; i < responseDetails.length; i++) {
                if (responseDetails[i] == null) {
                    if (fLogger.isErrorEnabled()) {
                        fLogger.error(
                                plugId + ": responded details that are null (set a pseudo responseDetail");
                    }
                    responseDetails[i] = new IngridHitDetail(plugId, String.valueOf(random.nextInt()),
                            random.nextInt(), 0.0f, "", "");
                }
                responseDetails[i].put(IngridHitDetail.DETAIL_TIMING, (System.currentTimeMillis() - time));
            }

            resultList.addAll(Arrays.asList(responseDetails));
            // FIXME: to improve performance we can use an Array instead
            // of a list here.
        }

        if (null != requestHitList) {
            requestHitList.clear();
            requestHitList = null;
        }
    }

    hashMap.clear();
    hashMap = null;

    // int count = resultList.size();
    IngridHitDetail[] resultDetails = (IngridHitDetail[]) resultList
            .toArray(new IngridHitDetail[resultList.size()]);

    resultList.clear();
    resultList = null;

    // sort to be in the same order as the requested hits.
    IngridHitDetail[] details = new IngridHitDetail[hits.length];
    for (int i = 0; i < hits.length; i++) {
        // set dummy detail if hit is "placeholder"
        if (hits[i].isDummyHit()) {
            details[i] = new IngridHitDetail(hit, "dummy hit", "");
            details[i].setDummyHit(true);
            if (fLogger.isDebugEnabled()) {
                fLogger.debug("getDetails: dummy hit, add dummy detail: " + details[i]);
            }
            continue;
        }

        String plugId = hits[i].getPlugId();
        String documentId = getDocIdAsString(hits[i]);

        boolean found = false;

        // get the details of the hits
        for (int j = 0; j < resultDetails.length; j++) {
            IngridHitDetail detail = resultDetails[j];
            String detailDocId = getDocIdAsString(detail);
            if (documentId.equals(detailDocId) && detail.getPlugId().equals(plugId)) {
                details[i] = detail;
                pushMetaData(details[i]); // push meta data to details
                found = true;
                break;
            }
        }
        if (!found) {
            if (fLogger.isErrorEnabled()) {
                fLogger.error("unable to find details getDetails: " + hit.toString());
            }
            details[i] = new IngridHitDetail(hit, "no details found", "");
        }
    }
    if (fLogger.isDebugEnabled()) {
        fLogger.debug("TIMING: Create details for Query (" + query.hashCode() + ") in "
                + (System.currentTimeMillis() - startGetDetails) + "ms.");
    }
    return details;
}