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.common.hrmsCommonController.java

public ModelAndView rehireEmp(HttpServletRequest request, HttpServletResponse response) {
    SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
    SimpleDateFormat sdf = new SimpleDateFormat("dd-mm-yyyy");
    JSONObject msg = new JSONObject();

    //Create transaction
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setName("JE_Tx");
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    def.setIsolationLevel(TransactionDefinition.ISOLATION_READ_UNCOMMITTED);
    TransactionStatus status = txnManager.getTransaction(def);
    try {//from  w  w  w .  ja  va 2 s  .c  o  m
        Empprofile e = null;
        String ids[] = request.getParameterValues("ids");
        String deptid = request.getParameter("dept");
        String desgid = request.getParameter("desg");
        String salary = (request.getParameter("salary"));
        String reldate = request.getParameter("joindate");
        String tempid = request.getParameter("templateid");
        Date rvdate = fmt.parse(reldate);
        Date now = new Date();
        for (int i = 0; i < ids.length; i++) {
            e = (Empprofile) kwlCommonTablesDAOObj.getObject("com.krawler.hrms.ess.Empprofile", ids[i]);
            if (e != null) {
                if (e.getRelievedate() != null) {
                    if (e.getRelievedate().after(rvdate)) {
                        msg.put("msg", "invalidjoindate");
                        msg.put("success", true);
                        txnManager.commit(status);
                        return new ModelAndView("jsonView", "model", msg.toString());
                    }
                }
            }
            HashMap<String, Object> requestParams = new HashMap<String, Object>();
            if (rvdate.before(now) || rvdate.equals(now)) {
                requestParams.put("termnd", false);
            }
            requestParams.put("userid", ids[i]);
            requestParams.put("joindate", request.getParameter("joindate"));
            requestParams.put("confirmdate", null);
            requestParams.put("relievedate", null);
            hrmsCommonDAOObj.addEmpprofile(requestParams);

            requestParams.clear();
            requestParams.put("UserID", ids[i]);
            requestParams.put("Department", deptid);
            requestParams.put("Designationid", desgid);
            requestParams.put("Salary", salary);
            requestParams.put("Templateid", tempid);
            hrmsCommonDAOObj.addUseraccount(requestParams);

            if (rvdate.before(now) || rvdate.equals(now)) {
                requestParams.clear();
                requestParams.put("UserID", ids[i]);
                requestParams.put("Deleteflag", 0);
                hrmsCommonDAOObj.adduser(requestParams);
            }

            //                User u=(User)session.get(User.class,ids[i]);
            //                Empprofile emp=(Empprofile)session.get(Empprofile.class,ids[i]);
            //                Useraccount ua = (Useraccount) session.get(Useraccount.class, u.getUserID());
            //                ua.setDepartment((dept));
            //                ua.setDesignationid(desg);
            //                ua.setSalary(salary);
            //                u.setDeleteflag(0);
            //                if (StringUtil.isNullOrEmpty(tempid) == false) {
            //                     ua.setTemplateid(tempid);
            //                }
            //                emp.setJoindate(rvdate);
            //                emp.setTermnd(false);
            //                emp.setRelievedate(null);
            //                session.saveOrUpdate(emp);
            //                session.saveOrUpdate(u);
            //                session.saveOrUpdate(ua);
            //@@ProfileHandler.insertAuditLog(session, AuditAction.REHIRE_EMPLOYEE, "User " + AuthHandler.getFullName(session, AuthHandler.getUserid(request)) + " has rehired employee " + AuthHandler.getFullName(u) ,request);
        }
        msg.put("success", true);
        txnManager.commit(status);
    } catch (Exception e) {
        e.printStackTrace();
        txnManager.rollback(status);
    } finally {
        //return  new ModelAndView("jsonView","model","{\"success\":\"true\"}");
        return new ModelAndView("jsonView", "model", msg.toString());
    }
}

From source file:com.krawler.crm.hrmsintegration.bizservice.GoalManagementServiceImpl.java

public JSONObject completedGoalReport(String userid, String companyid, DateFormat dateFormat, int relatedTo,
        int leadPerm, int accountPerm, int oppPerm, Long fromDate, Long toDate, String searchStr,
        String startStr, String limitStr, boolean exportall, Locale locale, String timeZoneDiff)
        throws ServiceException {
    JSONObject jobj = new JSONObject();
    KwlReturnObject kmsg = null;/*from w w w .  j  a  v  a 2s.  co m*/
    JSONArray jarr = new JSONArray();
    int count = 0;
    int start = 0;
    int limit = 25;
    int offSet = TimeZone.getTimeZone("GMT" + timeZoneDiff).getOffset(System.currentTimeMillis());
    try {
        HashMap<String, Object> requestParams = new HashMap<String, Object>();

        ArrayList filter_names = new ArrayList();
        ArrayList filter_params = new ArrayList();

        filter_names.add("c.userID.userID");
        filter_names.add("c.userID.company.companyID");
        filter_names.add("c.deleted");
        filter_params.add(userid);
        filter_params.add(companyid);
        filter_params.add(false);
        if (relatedTo > 0) {
            filter_names.add("c.relatedto");
            filter_params.add(relatedTo);
        } else if (relatedTo == 0) { // Kuldeep Singh : When user select view 'All' goals then fetch goal data according to module's permission
            StringBuffer relatedlist = new StringBuffer();
            if ((leadPerm & 1) == 1) {
                relatedlist.append("" + 1 + ",");
                relatedlist.append("" + 2 + ",");
            }
            if ((accountPerm & 1) == 1) {
                relatedlist.append("" + 3 + ",");
                relatedlist.append("" + 4 + ",");
            }
            if ((oppPerm & 1) == 1) {
                relatedlist.append("" + 5 + ",");
                relatedlist.append("" + 6 + ",");
            }
            String rltedlist = "0";
            if (relatedlist.length() > 0) {
                rltedlist = relatedlist.substring(0, (relatedlist.length() - 1));
            }
            filter_names.add("INc.relatedto");
            filter_params.add(rltedlist);
        }
        if (toDate != null && fromDate != null) {
            Date fmDate = new Date(fromDate);
            Date tDate = new Date(toDate);
            filter_names.add(">=c.startdate");
            filter_names.add("<=c.startdate");
            filter_params.add(dateOnlyFormat.parse(dateOnlyFormat.format(fmDate)).getTime());
            filter_params.add(dateOnlyFormat.parse(dateOnlyFormat.format(tDate)).getTime());
        }

        filter_names.add("<=c.enddate");
        Date now = new Date();
        now = dateOnlyFormat.parse(dateOnlyFormat.format(now));
        filter_params.add(now.getTime());

        requestParams.clear();
        if (startStr != null) {
            start = Integer.parseInt(startStr);
            limit = Integer.parseInt(limitStr);
        }
        if (!StringUtil.isNullOrEmpty(searchStr)) {
            requestParams.put("ss", searchStr);
        }
        if (!exportall) {
            requestParams.put("start", start);
            requestParams.put("limit", limit);
        }
        kmsg = hrmsIntDAOObj.getFinalGoals(requestParams, filter_names, filter_params);
        count = kmsg.getRecordTotalCount();
        if (count > 0) {
            User empuser = profileHandlerDAOObj.getUserObject(userid);
            List<Finalgoalmanagement> finalGoalmanagementList = kmsg.getEntityList();
            for (Finalgoalmanagement fgmt : finalGoalmanagementList) {
                JSONObject tmpObj = new JSONObject();
                double dl = 0;
                String relatedName = "";
                double percentageTarget = 0;
                filter_names.clear();
                filter_params.clear();
                requestParams.clear();
                requestParams.put("distinctFlag", true);

                dl = getAchievedTarget(fgmt, companyid, empuser);
                percentageTarget = getPercentageTarget(fgmt, dl);
                int reltTo = fgmt.getRelatedto() == null ? 0 : fgmt.getRelatedto();
                relatedName = getGoalName(reltTo);
                String gid = fgmt.getId();
                int pastGoals = getPastGoal(fgmt, percentageTarget);
                DecimalFormat decimalFormat = new DecimalFormat("#0");
                String percentAchvd = decimalFormat.format(percentageTarget) + " %";

                tmpObj.put("gid", gid);
                tmpObj.put("gname", fgmt.getGoalname());
                tmpObj.put("empname", empuser.getFirstName() + " " + empuser.getLastName());
                tmpObj.put("empid", empuser.getUserID());
                tmpObj.put("gdescription", fgmt.getGoaldesc());
                tmpObj.put("targeted", fgmt.getTargeted());
                tmpObj.put("relatedto", reltTo);
                tmpObj.put("relatedName", relatedName);
                tmpObj.put("achieved", dl != 0.0 ? dl : "0");
                tmpObj.put("percentageachieved", percentageTarget != 0.0 ? percentAchvd : "0");
                tmpObj.put("pastgoals", pastGoals);
                tmpObj.put("gstartdate", dateFormat.format(fgmt.getStartdate() + offSet));
                tmpObj.put("genddate", dateFormat.format(fgmt.getEnddate() + offSet));
                tmpObj.put("gassignedby", fgmt.getManager().getFirstName() + " "
                        + (fgmt.getManager().getLastName() == null ? "" : fgmt.getManager().getLastName()));
                jarr.put(tmpObj);
            }
        }
        jobj.put("coldata", jarr);
        jobj.put("data", jarr);
        jobj.put("totalCount", count);

        JSONObject jobjTemp = new JSONObject();
        JSONArray jarrColumns = new JSONArray();
        JSONArray jarrRecords = new JSONArray();
        JSONObject jMeta = new JSONObject();

        jobjTemp = new JSONObject();
        jobjTemp.put("header", messageSource.getMessage("crm.goalsettings.header.empname", null, locale));//"Employee Name");
        jobjTemp.put("tip", messageSource.getMessage("crm.goalsettings.header.empname", null, locale));//"Employee Name");
        jobjTemp.put("pdfwidth", 60);
        jobjTemp.put("dataIndex", "empname");
        jarrColumns.put(jobjTemp);

        jobjTemp = new JSONObject();
        jobjTemp.put("header", messageSource.getMessage("crm.goals.header.goaltype", null, locale));//"Goal Type");
        jobjTemp.put("tip", messageSource.getMessage("crm.goals.header.goaltype", null, locale));//"Goal Type");
        jobjTemp.put("pdfwidth", 60);
        jobjTemp.put("dataIndex", "relatedName");
        jarrColumns.put(jobjTemp);

        jobjTemp = new JSONObject();
        jobjTemp.put("header", messageSource.getMessage("crm.goals.header.target", null, locale));//"Target");
        jobjTemp.put("tip", messageSource.getMessage("crm.goals.header.target", null, locale));//"Target");
        jobjTemp.put("pdfwidth", 60);
        jobjTemp.put("align", "right");
        jobjTemp.put("dataIndex", "targeted");
        jarrColumns.put(jobjTemp);

        jobjTemp = new JSONObject();
        jobjTemp.put("header", messageSource.getMessage("crm.goals.header.achieved", null, locale));//"Achieved");
        jobjTemp.put("tip", messageSource.getMessage("crm.goals.header.achieved", null, locale));//"Achieved");
        jobjTemp.put("pdfwidth", 60);
        jobjTemp.put("align", "right");
        jobjTemp.put("dataIndex", "achieved");
        jarrColumns.put(jobjTemp);

        jobjTemp = new JSONObject();
        jobjTemp.put("header", messageSource.getMessage("crm.goals.header.percentageachieved", null, locale));//"Percentage Achieved");
        jobjTemp.put("tip", messageSource.getMessage("crm.goals.header.percentageachieved", null, locale));//"Percentage Achieved");
        jobjTemp.put("pdfwidth", 60);
        jobjTemp.put("align", "right");
        jobjTemp.put("dataIndex", "percentageachieved");
        jarrColumns.put(jobjTemp);

        jobjTemp = new JSONObject();
        jobjTemp.put("header", messageSource.getMessage("crm.goals.header.fromdate", null, locale));//"From Date");
        jobjTemp.put("tip", messageSource.getMessage("crm.goals.header.fromdate", null, locale));//"From Date");
        jobjTemp.put("pdfwidth", 60);
        jobjTemp.put("title", "gstartdate");
        jobjTemp.put("dataIndex", "gstartdate");
        jobjTemp.put("align", "center");
        jobjTemp.put("renderer", crmManagerCommon.dateRendererReport());
        jarrColumns.put(jobjTemp);

        jobjTemp = new JSONObject();
        jobjTemp.put("header", messageSource.getMessage("crm.goals.header.todate", null, locale));//"To Date");
        jobjTemp.put("tip", messageSource.getMessage("crm.goals.header.todate", null, locale));//"To Date");
        jobjTemp.put("pdfwidth", 60);
        jobjTemp.put("title", "gstartdate");
        jobjTemp.put("dataIndex", "genddate");
        jobjTemp.put("align", "center");
        jobjTemp.put("renderer", crmManagerCommon.dateRendererReport());
        jarrColumns.put(jobjTemp);

        jobjTemp = new JSONObject();
        jobjTemp.put("header", messageSource.getMessage("crm.goals.header.assignedby", null, locale));//"Assigned By");
        jobjTemp.put("tip", messageSource.getMessage("crm.goals.header.assignedby", null, locale));//"Assigned By");
        jobjTemp.put("pdfwidth", 60);
        jobjTemp.put("dataIndex", "gassignedby");
        jarrColumns.put(jobjTemp);

        jobjTemp = new JSONObject();
        jobjTemp.put("name", "empname");
        jarrRecords.put(jobjTemp);
        jobjTemp = new JSONObject();
        jobjTemp.put("name", "relatedName");
        jarrRecords.put(jobjTemp);
        jobjTemp = new JSONObject();
        jobjTemp.put("name", "targeted");
        jarrRecords.put(jobjTemp);
        jobjTemp = new JSONObject();
        jobjTemp.put("name", "achieved");
        jarrRecords.put(jobjTemp);
        jobjTemp = new JSONObject();
        jobjTemp.put("name", "percentageachieved");
        jarrRecords.put(jobjTemp);
        jobjTemp = new JSONObject();
        jobjTemp.put("name", "gassignedby");
        jarrRecords.put(jobjTemp);
        jobjTemp = new JSONObject();
        jobjTemp.put("name", "gstartdate");
        jobjTemp.put("type", "date");
        jarrRecords.put(jobjTemp);
        jobjTemp = new JSONObject();
        jobjTemp.put("name", "genddate");
        jobjTemp.put("type", "date");
        jarrRecords.put(jobjTemp);
        jobj.put("columns", jarrColumns);

        jMeta.put("totalProperty", "totalCount");
        jMeta.put("root", "coldata");
        jMeta.put("fields", jarrRecords);
        jMeta.put("id", "asd");
        jobj.put("metaData", jMeta);

    } catch (JSONException e) {
        logger.warn("JSONException exception in completedGoalReport()", e);
        throw ServiceException.FAILURE("GoalManagementServiceImpl.assignedgoalsdelete", e);
    } catch (ServiceException e) {
        logger.warn("ServiceException exception in completedGoalReport()", e);
        throw ServiceException.FAILURE("GoalManagementServiceImpl.assignedgoalsdelete", e);
    } catch (Exception e) {
        logger.warn("General exception in completedGoalReport()", e);
        throw ServiceException.FAILURE("GoalManagementServiceImpl.assignedgoalsdelete", e);
    }
    return jobj;
}

From source file:org.sakaiproject.unboundid.UnboundidDirectoryProvider.java

/**
 * Similar to iterating over <code>users</code> passing
 * each element to {@link #getUser(UserEdit)}, removing the
 * {@link org.sakaiproject.user.api.UserEdit} if that method 
 * returns <code>false</code>. 
 * /*www  .  j  ava 2s  .  com*/
 * <p>Adds search retry capability if any one lookup fails 
 * with a directory error. Empties <code>users</code> and 
 * returns if a retry exits exceptionally
 * <p>
 */
public void getUsers(Collection<UserEdit> users) {
    log.debug("getUsers(): [Collection size = {}]", users.size());

    boolean abortiveSearch = false;
    int maxQuerySize = getMaxObjectsToQueryFor();
    UserEdit userEdit = null;

    HashMap<String, UserEdit> usersToSearchInLDAP = new HashMap<String, UserEdit>();
    List<UserEdit> usersToRemove = new ArrayList<UserEdit>();
    try {
        int cnt = 0;
        for (Iterator<UserEdit> userEdits = users.iterator(); userEdits.hasNext();) {
            userEdit = (UserEdit) userEdits.next();
            String eid = userEdit.getEid();

            if (!(isSearchableEid(eid))) {
                userEdits.remove();
                //proceed ahead with this (perhaps the final) iteration
                //usersToSearchInLDAP needs to be processed unless empty
            } else {
                usersToSearchInLDAP.put(eid, userEdit);
                cnt++;
            }

            // We need to make sure this query isn't larger than maxQuerySize
            if ((!userEdits.hasNext() || cnt == maxQuerySize) && !usersToSearchInLDAP.isEmpty()) {
                String filter = ldapAttributeMapper.getManyUsersInOneSearch(usersToSearchInLDAP.keySet());
                List<LdapUserData> ldapUsers = searchDirectory(filter, null, null, null, maxQuerySize);

                for (LdapUserData ldapUserData : ldapUsers) {
                    String ldapEid = ldapUserData.getEid();

                    if (StringUtils.isEmpty(ldapEid)) {
                        continue;
                    }
                    ldapEid = ldapEid.toLowerCase();

                    UserEdit ue = usersToSearchInLDAP.get(ldapEid);
                    mapUserDataOntoUserEdit(ldapUserData, ue);
                    usersToSearchInLDAP.remove(ldapEid);
                }

                // see if there are any users that we could not find in the LDAP query
                for (Map.Entry<String, UserEdit> entry : usersToSearchInLDAP.entrySet()) {
                    usersToRemove.add(entry.getValue());
                }

                // clear the HashMap and reset the counter
                usersToSearchInLDAP.clear();
                cnt = 0;
            }
        }

        // Finally clean up the original collection and remove and users we could not find
        for (UserEdit userRemove : usersToRemove) {
            log.debug("Unboundid getUsers could not find user: {}", userRemove.getEid());
            users.remove(userRemove);
        }

    } catch (LDAPException e) {
        abortiveSearch = true;
        throw new RuntimeException("getUsers(): LDAPException during search [eid = "
                + (userEdit == null ? null : userEdit.getEid()) + "][result code = " + e.errorCodeToString()
                + "][error message = " + e.getLDAPErrorMessage() + "]", e);
    } catch (Exception e) {
        abortiveSearch = true;
        throw new RuntimeException("getUsers(): RuntimeException during search eid = "
                + (userEdit == null ? null : userEdit.getEid()) + "]", e);
    } finally {
        // no sense in returning a partially complete search result
        if (abortiveSearch) {
            log.debug("getUsers(): abortive search, clearing received users collection");
            users.clear();
        }
    }

}

From source file:com.krawler.spring.hrms.common.hrmsCommonController.java

public ModelAndView assignManager(HttpServletRequest request, HttpServletResponse response) {
    KwlReturnObject result = null;/*from w  w  w  .j  a v a 2s  . c o m*/
    List tabledata = null;
    String[] userids = request.getParameterValues("userid");
    String[] reviewerids = request.getParameterValues("reviewerid");
    String[] managerids = request.getParameterValues("managerid");
    String[] availmanagerid = request.getParameterValues("availmanagerid");
    JSONObject jobj = new JSONObject();

    //Create transaction
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setName("JE_Tx");
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    def.setIsolationLevel(TransactionDefinition.ISOLATION_READ_UNCOMMITTED);
    TransactionStatus status = txnManager.getTransaction(def);

    try {
        HashMap<String, Object> requestParams = new HashMap<String, Object>();
        if (Boolean.parseBoolean(request.getParameter("isManager"))) {
            for (int i = 0; i < userids.length; i++) {
                requestParams.put("filter_names", Arrays.asList("assignemp.userID", "managerstatus"));
                requestParams.put("filter_values", Arrays.asList(userids[i], 1));
                result = hrmsCommonDAOObj.getAssignmanager(requestParams);
                tabledata = result.getEntityList();
                Iterator ite = tabledata.iterator();
                while (ite.hasNext()) {
                    Assignmanager log = (Assignmanager) ite.next();
                    requestParams.clear();
                    requestParams.put("Id", log.getId());
                    requestParams.put("Managerstatus", 0);
                    hrmsCommonDAOObj.addAssignmanager(requestParams);
                }
            }
            for (int i = 0; i < userids.length; i++) {
                for (int j = 0; j < managerids.length; j++) {
                    requestParams.clear();
                    requestParams.put("Assignemp", userids[i]);
                    requestParams.put("Assignman", managerids[j]);
                    requestParams.put("Managerstatus", 1);
                    hrmsCommonDAOObj.addAssignmanager(requestParams);
                }
            }
        } else if (Boolean.parseBoolean(request.getParameter("salaryManagerF"))) {

            hrmsCommonDAOObj.addAssignSalaryManager(managerids, availmanagerid);
        } else {
            for (int i = 0; i < userids.length; i++) {
                requestParams.clear();
                requestParams.put("filter_names", Arrays.asList("employee.userID", "reviewerstatus"));
                requestParams.put("filter_values", Arrays.asList(userids[i], 1));
                result = hrmsCommonDAOObj.getAssignreviewer(requestParams);
                tabledata = result.getEntityList();
                Iterator ite = tabledata.iterator();
                while (ite.hasNext()) {
                    Assignreviewer log = (Assignreviewer) ite.next();
                    requestParams.clear();
                    requestParams.put("Id", log.getId());
                    requestParams.put("Reviewerstatus", 0);
                    hrmsCommonDAOObj.addAssignreviewer(requestParams);

                }
            }
            for (int i = 0; i < userids.length; i++) {
                for (int j = 0; j < managerids.length; j++) {
                    requestParams.clear();
                    requestParams.put("Employee", userids[i]);
                    requestParams.put("Reviewer", managerids[j]);
                    requestParams.put("Reviewerstatus", 1);
                    hrmsCommonDAOObj.addAssignreviewer(requestParams);
                }
            }
        }
        jobj.put("valid", true);
        jobj.put("data", "");
        txnManager.commit(status);
    } catch (Exception ex) {
        ex.printStackTrace();
        txnManager.rollback(status);
    } finally {
        return new ModelAndView("jsonView", "model", jobj.toString());
    }
}

From source file:com.krawler.crm.contact.bizservice.ContactManagementServiceImpl.java

/**
 *
 * @param ll/* w w  w.  j  a  va 2  s .co m*/
 * @param totalSize
 * @param isexport
 * @param dateFormat
 * @param userid
 * @param companyid
 * @param currencyid
 * @param selectExportJson
 * @return
 * @throws com.krawler.common.session.SessionExpiredException
 */
public JSONObject getContactJson(List ll, int totalSize, boolean isexport, DateFormat dateFormat, String userid,
        String companyid, String currencyid, String selectExportJson, StringBuffer usersList)
        throws SessionExpiredException {
    JSONArray jarr = new JSONArray();
    JSONObject jobj = new JSONObject();
    try {
        Object totalcomment = 0;
        HashMap<String, Object> requestParams = new HashMap<String, Object>();
        requestParams.put("isexport", isexport);
        requestParams.put("filter_names", Arrays.asList("companyid", "moduleid"));
        requestParams.put("filter_values", Arrays.asList(companyid, Constants.Crm_contact_moduleid));
        HashMap<String, String> replaceFieldMap = new HashMap<String, String>();
        HashMap<String, Integer> FieldMap = fieldDataManagercntrl.getFieldParamsMap1(requestParams,
                replaceFieldMap);

        HashMap<String, DefaultMasterItem> defaultMasterMap = crmContactHandler
                .getContactDefaultMasterItemsMap(companyid, usersList, crmCommonDAO, kwlCommonTablesDAOObj);
        HashMap<String, String> commentCountMap = crmCommentDAOObj.getNewCommentCount(userid);

        int fromIndex = 0;
        int maxNumbers = Constants.maxrecordsMapCount;
        int totalCount = ll.size();
        while (fromIndex < totalCount) {
            List<CrmContact> subList;
            if (totalCount <= maxNumbers) {
                subList = ll;
            } else {
                int toIndex = (((fromIndex + maxNumbers) < totalCount) ? (fromIndex + maxNumbers) + 1
                        : totalCount);//Add +1 as subList exclude toIndex item
                subList = ll.subList(fromIndex, toIndex);
            }

            List<String> idsList = new ArrayList<String>();
            for (CrmContact obj : subList) {
                idsList.add(obj.getContactid());
            }
            HashMap<String, String> totalCommentCountMap = crmCommentDAOObj.getTotalCommentsCount(idsList,
                    companyid);
            HashMap<String, CrmContactCustomData> contactCustomDataMap = crmContactDAOObj
                    .getContactCustomDataMap(idsList, companyid);
            Map<String, ExpressionVariables> exprVarMap = expressionVariableMap(subList, contactCustomDataMap,
                    companyid, FieldMap, replaceFieldMap, isexport, dateFormat);
            Map<String, Integer> customloginInfo = crmContactDAOObj.getLoginState(idsList);
            //get Accounts
            Map<String, CrmAccount> accountInfo = crmContactDAOObj.getContactAccount(idsList);
            // get owners
            Map<String, List<ContactOwnerInfo>> owners = crmContactDAOObj.getContactOwners(idsList);
            for (CrmContact obj : subList) {
                requestParams.clear();
                requestParams.put("recid", obj.getContactid());
                requestParams.put("companyid", companyid);
                JSONObject tmpObj = new JSONObject();
                String aid = accountInfo.containsKey(obj.getContactid())
                        ? ((CrmAccount) accountInfo.get(obj.getContactid())).getAccountid()
                        : "";
                String aname = accountInfo.containsKey(obj.getContactid())
                        ? ((CrmAccount) accountInfo.get(obj.getContactid())).getAccountname()
                        : "";
                if (StringUtil.isNullOrEmpty(aid) || aid.equals("99")) {
                    JSONObject jobjNone = new JSONObject();
                    jobjNone = crmManagerCommon.insertNone();
                    aid = jobjNone.getString("id");
                    aname = jobjNone.getString("name");
                }
                tmpObj.put("relatedname", aname);
                tmpObj.put("relatednameid", aid);
                tmpObj.put("oldrelatedname", aid);
                tmpObj.put("loginstate",
                        customloginInfo.containsKey(obj.getContactid())
                                ? customloginInfo.get(obj.getContactid())
                                : 0);
                totalcomment = 0;
                if (totalCommentCountMap.containsKey(obj.getContactid())) {
                    totalcomment = totalCommentCountMap.get(obj.getContactid());
                }
                tmpObj.put("totalcomment", totalcomment);
                tmpObj = getContactJsonObject(exprVarMap, obj, tmpObj, companyid, currencyid, FieldMap,
                        isexport, dateFormat, defaultMasterMap, contactCustomDataMap, owners);
                tmpObj.put("commentcount",
                        (commentCountMap.containsKey(obj.getContactid())
                                ? commentCountMap.get(obj.getContactid())
                                : "0"));
                jarr.put(tmpObj);
            }
            fromIndex += maxNumbers + 1;
        }
        jobj.put("success", true);
        jobj.put("data", jarr);
        jobj.put("totalCount", totalSize);
    } catch (Exception e) {
        LOGGER.warn("Exception in crmContactController.getContactJson:", e);
    }
    return jobj;
}

From source file:com.krawler.spring.hrms.common.hrmsCommonController.java

public ModelAndView terminateEmp(HttpServletRequest request, HttpServletResponse response) {
    String hql = "";
    SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
    SimpleDateFormat sdf = new SimpleDateFormat("dd-mm-yyyy");
    JSONObject msg = new JSONObject();

    //Create transaction
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setName("JE_Tx");
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    def.setIsolationLevel(TransactionDefinition.ISOLATION_READ_UNCOMMITTED);
    TransactionStatus status = txnManager.getTransaction(def);

    try {//  w  w  w. j  av  a2s  .  c  o m
        boolean isCompanySuperAdmin = false;
        Empprofile e = null;
        String ids[] = request.getParameterValues("ids");
        String masterid = request.getParameter("tercause");
        String desc = ((StringUtil.isNullOrEmpty(request.getParameter("terdesc"))) ? ""
                : request.getParameter("terdesc"));
        String reldate = request.getParameter("relievedate");
        Date rvdate = fmt.parse(reldate);
        Empprofile emp = null;
        UserLogin usl = null;
        User usr = null;
        Date now = new Date();
        //           User updatedby=(User)session.get(User.class,sessionHandlerImplObj.getUserid(request));
        // User updatedby=(User)kwlCommonTablesDAOObj.getObject("com.krawler.common.admin.User", sessionHandlerImplObj.getUserid(request));
        String updatedby = sessionHandlerImplObj.getUserid(request);

        String companyid = sessionHandlerImplObj.getCompanyid(request);
        for (int i = 0; i < ids.length; i++) {
            if (hrmsCommonDAOObj.isCompanySuperAdmin(ids[i], companyid)) {
                isCompanySuperAdmin = true;
                break;
            }
        }
        if (isCompanySuperAdmin) {
            msg.put("msg", "adminerror");
            msg.put("success", true);
            txnManager.commit(status);
            return new ModelAndView("jsonView", "model", msg.toString());
        }

        for (int i = 0; i < ids.length; i++) {
            e = (Empprofile) kwlCommonTablesDAOObj.getObject("com.krawler.hrms.ess.Empprofile", ids[i]);
            if (e != null) {
                if (e.getJoindate() != null) {
                    if (e.getJoindate().after(rvdate)) {
                        msg.put("msg", "invalidterminatedate");
                        msg.put("success", true);
                        txnManager.commit(status);
                        return new ModelAndView("jsonView", "model", msg.toString());
                    }
                }
            }
            //                hql = "from Empprofile where userLogin.userID=?";
            //                List lst = HibernateUtil.executeQuery(session, hql, new Object[]{ids[i]});
            ////                usl=(UserLogin)session.get(UserLogin.class,ids[i]);
            //                usl=(UserLogin)HibernateUtil.getPrimary("com.krawler.common.admin.UserLogin", "userID");
            ////                usr=(User)session.get(User.class,ids[i]);
            //                usr=(User)HibernateUtil.getPrimary("com.krawler.common.admin.User", "userID");
            //                if(lst.isEmpty()){
            //                          emp=new Empprofile();
            //                          emp.setUserLogin(usl);
            //                }else{
            //                  emp=(Empprofile)session.get(Empprofile.class,ids[i]);
            //                }
            //                 Emphistory ehst=new Emphistory();
            //                 ehst.setUserid(usr);
            //                 ehst.setDepartment(usr.getDepartment());
            //                 ehst.setDesignation(usr.getDesignationid());
            //                 ehst.setSalary(usr.getSalary());
            //                 ehst.setEmpid(usr.getEmployeeid());
            //                 ehst.setUpdatedon(rvdate);
            //                 ehst.setJoindate(emp.getJoindate());
            //                 ehst.setEnddate(rvdate);
            //                 ehst.setUpdatedby(updatedby);
            //                 ehst.setCategory(Emphistory.Emp_Desg_change);
            //                 emp.setTerminatedby(updatedby);
            //                 emp.setTercause((MasterData)session.get(MasterData.class,masterid));
            //                 emp.setRelievedate(rvdate);
            //                 emp.setTerReason(desc);
            //                 emp.setTermnd(true);
            //                 usr.setDeleted(true);
            //                 session.saveOrUpdate(ehst);
            //                 session.saveOrUpdate(emp);
            //                 session.saveOrUpdate(usr);
            //                 //@@ProfileHandler.insertAuditLog(session, AuditAction.EMPLOYEE_TERMINATED, "Employee " + sessionHandlerImplObj.getFullName(usr) + " terminated by " + sessionHandlerImplObj.getFullName(session, sessionHandlerImplObj.getUserid(request)),request);
            HashMap<String, Object> requestParams = new HashMap<String, Object>();
            if (rvdate.before(now) || rvdate.equals(now)) {
                requestParams.put("termnd", true);
            }
            requestParams.put("userid", ids[i]);
            requestParams.put("terminatedby", updatedby);
            requestParams.put("tercause", masterid);
            requestParams.put("terReason", desc);
            requestParams.put("relievedate", reldate);
            KwlReturnObject result = hrmsCommonDAOObj.addEmpprofile(requestParams);

            HashMap<String, Object> deleteJobj = organizationService.deleteNode(ids[i]);

            if (rvdate.before(now) || rvdate.equals(now)) {
                requestParams.clear();
                requestParams.put("UserID", ids[i]);
                requestParams.put("Deleteflag", 1);
                hrmsCommonDAOObj.adduser(requestParams);
            }
        }
        msg.put("success", true);
        txnManager.commit(status);
    } catch (Exception e) {
        e.printStackTrace();
        txnManager.rollback(status);
    } finally {
        return new ModelAndView("jsonView", "model", msg.toString());
    }
}

From source file:edu.ku.brc.specify.toycode.RegPivot.java

/**
 * @param newTblName//from w  ww  .j a  v a  2s.c om
 * @param stmt
 * @param pStmt
 * @param fillSQL
 * @param secInx
 * @param dbFieldTypes
 * @param dbFieldNames
 * @param inxToName
 * @return
 * @throws SQLException
 */
private int fillRegisterTable(final String newTblName, final Statement stmt, final PreparedStatement pStmt,
        final String fillSQL, final int secInx, final Vector<Integer> dbFieldTypes,
        final Vector<String> dbFieldNames, final HashMap<Integer, String> inxToName) throws SQLException {
    System.out.println("Filling Register Table.");

    int instCnt = 0;

    System.out.println(fillSQL);

    ResultSet rs = stmt.executeQuery(fillSQL);
    ResultSetMetaData rsmd = rs.getMetaData();

    HashMap<String, Integer> nameToIndex = new HashMap<String, Integer>();
    for (int c = 1; c <= rsmd.getColumnCount(); c++) {
        nameToIndex.put(rsmd.getColumnName(c), c);
        System.out.println(c + " - " + rsmd.getColumnName(c));
    }

    //int nameInx = nameToIndex.get("i.Name");
    boolean debug = false;

    String prevRegId = null;

    HashMap<String, HashMap<String, Object>> instHash = new HashMap<String, HashMap<String, Object>>();
    HashMap<String, HashMap<String, Object>> divHash = new HashMap<String, HashMap<String, Object>>();
    HashMap<String, HashMap<String, Object>> dspHash = new HashMap<String, HashMap<String, Object>>();
    HashMap<String, HashMap<String, Object>> colHash = new HashMap<String, HashMap<String, Object>>();

    HashMap<String, Object> nameToVals = new HashMap<String, Object>();

    while (rs.next()) {
        String regId = rs.getString(1);
        if (prevRegId == null)
            prevRegId = regId;

        for (int i = 1; i < secInx; i++) {
            if (debug)
                System.out.println("Put: " + dbFieldNames.get(i - 1) + "  " + dbFieldTypes.get(i - 1) + "  = "
                        + rs.getObject(i));
            nameToVals.put(dbFieldNames.get(i - 1), rs.getObject(i));
        }
        String name = rs.getString(secInx);
        name = StringUtils.replace(name, "(", "_");
        name = StringUtils.replace(name, ")", "_");

        if (name.equals("reg_type")) {
            String strVal = (String) rs.getObject(secInx + 2);
            name = strVal + "_number";

            nameToVals.put(name, regId);
            if (debug)
                System.out.println("Put: " + name + " = " + regId);
        } else {
            Integer intVal = (Integer) rs.getObject(secInx + 1);
            String strVal = (String) rs.getObject(secInx + 2);
            nameToVals.put(name, strVal != null ? strVal : intVal);
            if (debug)
                System.out.println("Put: " + name + " = " + intVal + " / " + strVal);
        }

        if (debug)
            System.out.println("-------------------------------------------");

        if (!prevRegId.equals(regId)) {
            String instNum = (String) nameToVals.get("Institution_number");
            String divNum = (String) nameToVals.get("Division_number");
            String dspNum = (String) nameToVals.get("Discipline_number");
            String colNum = (String) nameToVals.get("Collection_number");

            if (StringUtils.isNotEmpty(instNum)) {
                copyHash(instNum, instHash, nameToVals);
            }

            if (StringUtils.isNotEmpty(divNum)) {
                copyHash(divNum, divHash, nameToVals);
            }

            if (StringUtils.isNotEmpty(dspNum)) {
                copyHash(dspNum, dspHash, nameToVals);
            }

            if (StringUtils.isNotEmpty(colNum)) {
                // 1288612353.83
                String cn = (String) nameToVals.get("Collection_number");
                copyHash(colNum, colHash, nameToVals);
            }

            /*{
            System.err.println("ID is empty:");
            for (String key : nameToVals.keySet())
            {
                System.out.println("--: "+key+" = "+nameToVals.get(key));
            }
            System.err.println("===============");
            }*/
            prevRegId = regId;
            nameToVals.clear();
        }
    }

    writeHash(instHash, 0, pStmt, dbFieldTypes, dbFieldNames, inxToName);
    writeHash(divHash, 1, pStmt, dbFieldTypes, dbFieldNames, inxToName);
    writeHash(dspHash, 2, pStmt, dbFieldTypes, dbFieldNames, inxToName);
    writeHash(colHash, 3, pStmt, dbFieldTypes, dbFieldNames, inxToName);

    String alterSQL = "ALTER TABLE " + newTblName + " ADD Lookup VARCHAR(64) AFTER IP";
    BasicSQLUtils.update(connection, alterSQL);

    alterSQL = "ALTER TABLE " + newTblName + " ADD Country VARCHAR(64) AFTER Lookup";
    BasicSQLUtils.update(connection, alterSQL);

    alterSQL = "ALTER TABLE " + newTblName + " ADD City VARCHAR(64) AFTER Country";
    BasicSQLUtils.update(connection, alterSQL);

    return instCnt;
}

From source file:edu.amc.sakai.user.JLDAPDirectoryProvider.java

/**
 * Similar to iterating over <code>users</code> passing
 * each element to {@link #getUser(UserEdit)}, removing the
 * {@link org.sakaiproject.user.api.UserEdit} if that method 
 * returns <code>false</code>. 
 * //from   ww w.j  a  v  a  2s  .c  o m
 * <p>Adds search retry capability if any one lookup fails 
 * with a directory error. Empties <code>users</code> and 
 * returns if a retry exits exceptionally
 * <p>
 */
public void getUsers(Collection<UserEdit> users) {
    if (M_log.isDebugEnabled()) {
        M_log.debug("getUsers(): [Collection size = " + users.size() + "]");
    }

    LDAPConnection conn = null;
    boolean abortiveSearch = false;
    int maxQuerySize = getMaxObjectsToQueryFor();
    UserEdit userEdit = null;

    HashMap<String, UserEdit> usersToSearchInLDAP = new HashMap<String, UserEdit>();
    List<UserEdit> usersToRemove = new ArrayList<UserEdit>();
    try {
        int cnt = 0;
        for (Iterator<UserEdit> userEdits = users.iterator(); userEdits.hasNext();) {
            userEdit = (UserEdit) userEdits.next();
            String eid = userEdit.getEid();

            if (!(isSearchableEid(eid))) {
                userEdits.remove();
                //proceed ahead with this (perhaps the final) iteration
                //usersToSearchInLDAP needs to be processed unless empty
            } else {
                usersToSearchInLDAP.put(eid, userEdit);
                cnt++;
            }

            // We need to make sure this query isn't larger than maxQuerySize
            if ((!userEdits.hasNext() || cnt == maxQuerySize) && !usersToSearchInLDAP.isEmpty()) {
                if (conn == null) {
                    conn = ldapConnectionManager.getConnection();
                }

                String filter = ldapAttributeMapper.getManyUsersInOneSearch(usersToSearchInLDAP.keySet());
                List<LdapUserData> ldapUsers = searchDirectory(filter, null, null, null, null, maxQuerySize);

                for (LdapUserData ldapUserData : ldapUsers) {
                    String ldapEid = ldapUserData.getEid();

                    if (StringUtils.isEmpty(ldapEid)) {
                        continue;
                    }
                    ldapEid = ldapEid.toLowerCase();

                    UserEdit ue = usersToSearchInLDAP.get(ldapEid);
                    mapUserDataOntoUserEdit(ldapUserData, ue);
                    usersToSearchInLDAP.remove(ldapEid);
                }

                // see if there are any users that we could not find in the LDAP query
                for (Map.Entry<String, UserEdit> entry : usersToSearchInLDAP.entrySet()) {
                    usersToRemove.add(entry.getValue());
                }

                // clear the HashMap and reset the counter
                usersToSearchInLDAP.clear();
                cnt = 0;
            }
        }

        // Finally clean up the original collection and remove and users we could not find
        for (UserEdit userRemove : usersToRemove) {
            if (M_log.isDebugEnabled()) {
                M_log.debug("JLDAP getUsers could not find user: " + userRemove.getEid());
            }
            users.remove(userRemove);
        }

    } catch (LDAPException e) {
        abortiveSearch = true;
        throw new RuntimeException("getUsers(): LDAPException during search [eid = "
                + (userEdit == null ? null : userEdit.getEid()) + "][result code = " + e.resultCodeToString()
                + "][error message = " + e.getLDAPErrorMessage() + "]", e);
    } catch (Exception e) {
        abortiveSearch = true;
        throw new RuntimeException("getUsers(): RuntimeException during search eid = "
                + (userEdit == null ? null : userEdit.getEid()) + "]", e);
    } finally {

        if (conn != null) {
            if (M_log.isDebugEnabled()) {
                M_log.debug("getUsers(): returning connection to connection manager");
            }
            ldapConnectionManager.returnConnection(conn);
        }

        // no sense in returning a partially complete search result
        if (abortiveSearch) {
            if (M_log.isDebugEnabled()) {
                M_log.debug("getUsers(): abortive search, clearing received users collection");
            }
            users.clear();
        }
    }

}

From source file:org.epics.archiverappliance.config.DefaultConfigService.java

/**
 * Given a external Archiver data server URL and an archive; 
 * If this is a ChannelArchiver (archives != pbraw); 
 * this adds the PVs in the Channel Archiver so that they can be proxied.
 * @param serverURL//from  w  ww.  j  a  v  a  2  s  .  c  o  m
 * @param archive
 * @throws IOException
 * @throws SAXException
 */
private void loadExternalArchiverPVs(String serverURL, String archive) throws IOException, SAXException {
    if (archive.equals("pbraw")) {
        logger.debug(
                "We do not load PV names from external EPICS archiver appliances. These can number in the multiple millions and the respone on retrieval is fast enough anyways");
        return;
    }

    ChannelArchiverDataServerInfo serverInfo = new ChannelArchiverDataServerInfo(serverURL, archive);
    NamesHandler handler = new NamesHandler();
    logger.debug(
            "Getting list of PV's from Channel Archiver Server at " + serverURL + " using index " + archive);
    XMLRPCClient.archiverNames(serverURL, archive, handler);
    HashMap<String, List<ChannelArchiverDataServerPVInfo>> tempPVNames = new HashMap<String, List<ChannelArchiverDataServerPVInfo>>();
    long totalPVsProxied = 0;
    for (NamesHandler.ChannelDescription pvChannelDesc : handler.getChannels()) {
        String pvName = PVNames.normalizePVName(pvChannelDesc.getName());
        if (this.pv2ChannelArchiverDataServer.containsKey(pvName)) {
            List<ChannelArchiverDataServerPVInfo> alreadyExistingServers = this.pv2ChannelArchiverDataServer
                    .get(pvName);
            logger.debug("Adding new server to already existing ChannelArchiver server for " + pvName);
            addExternalCAServerToExistingList(alreadyExistingServers, serverInfo, pvChannelDesc);
            tempPVNames.put(pvName, alreadyExistingServers);
        } else if (tempPVNames.containsKey(pvName)) {
            List<ChannelArchiverDataServerPVInfo> alreadyExistingServers = tempPVNames.get(pvName);
            logger.debug("Adding new server to already existing ChannelArchiver server (in tempspace) for "
                    + pvName);
            addExternalCAServerToExistingList(alreadyExistingServers, serverInfo, pvChannelDesc);
            tempPVNames.put(pvName, alreadyExistingServers);
        } else {
            List<ChannelArchiverDataServerPVInfo> caServersForPV = new ArrayList<ChannelArchiverDataServerPVInfo>();
            caServersForPV.add(new ChannelArchiverDataServerPVInfo(serverInfo, pvChannelDesc.getStartSec(),
                    pvChannelDesc.getEndSec()));
            tempPVNames.put(pvName, caServersForPV);
        }

        if (tempPVNames.size() > 1000) {
            this.pv2ChannelArchiverDataServer.putAll(tempPVNames);
            totalPVsProxied += tempPVNames.size();
            tempPVNames.clear();
        }
    }
    if (!tempPVNames.isEmpty()) {
        this.pv2ChannelArchiverDataServer.putAll(tempPVNames);
        totalPVsProxied += tempPVNames.size();
        tempPVNames.clear();
    }
    if (logger.isDebugEnabled())
        logger.debug("Proxied a total of " + totalPVsProxied + " from server " + serverURL + " using archive "
                + archive);

}

From source file:edu.ku.brc.specify.toycode.RegPivot.java

/**
 * @param newTblName/*from  w  w  w  .  ja  va  2s .  c om*/
 * @param stmt
 * @param pStmt
 * @param fillSQL
 * @param secInx
 * @param dbFieldTypes
 * @param dbFieldNames
 * @param inxToName
 * @return
 * @throws SQLException
 */
private int fillTrackTableX(final String newTblName, final Statement stmt, final PreparedStatement pStmt,
        final String fillSQL, final int secInx, final Vector<Integer> dbFieldTypes,
        final Vector<String> dbFieldNames, final HashMap<Integer, String> inxToName) throws SQLException {
    System.out.println("Filling Track Table.");
    int instCnt = 0;

    HashMap<String, Object> nameToVals = new HashMap<String, Object>();

    System.out.println(fillSQL);

    String prevId = null;
    ResultSet rs = stmt.executeQuery(fillSQL);
    ResultSetMetaData rsmd = rs.getMetaData();

    HashMap<String, Integer> nameToIndex = new HashMap<String, Integer>();
    for (int c = 1; c <= rsmd.getColumnCount(); c++) {
        nameToIndex.put(rsmd.getColumnName(c), c);
        System.out.println(c + " - " + rsmd.getColumnName(c));
    }

    while (rs.next()) {
        String id = rs.getString(1);
        if (prevId == null)
            prevId = id;

        if (!prevId.equals(id)) {
            for (int i = 1; i < secInx; i++) {
                //System.out.println("Put: "+dbFieldNames.get(i-1)+"  "+dbFieldTypes.get(i-1));//+"  = "+rs.getObject(i));
                if (dbFieldTypes.get(i - 1) == java.sql.Types.TIMESTAMP) {
                    try {
                        String ts = rs.getString(i);
                        if (StringUtils.isNotEmpty(ts) && ts.equals("0000-00-00 00:00:00")) {
                            //nameToVals.put(dbFieldNames.get(i-1), null);
                            continue;
                        }
                    } catch (Exception ex) {
                        nameToVals.put(dbFieldNames.get(i - 1), null);//"2000-01-01 00:00:00");
                        continue;
                    }
                }
                nameToVals.put(dbFieldNames.get(i - 1), rs.getObject(i));
            }

            for (int i = 0; i < dbFieldNames.size(); i++) {
                int fInx = i + 1;
                String name = inxToName.get(i);
                Object value = nameToVals.get(name);

                pStmt.setObject(fInx, null);

                int typ = dbFieldTypes.get(i);

                if (value != null) {
                    switch (typ) {
                    case java.sql.Types.INTEGER:
                        if (value instanceof Integer) {
                            pStmt.setInt(fInx, (Integer) value);
                        }
                        break;

                    case java.sql.Types.VARCHAR:
                        if (value instanceof String) {
                            pStmt.setString(fInx, (String) value);
                        }
                        break;

                    case java.sql.Types.TIMESTAMP: {
                        if (value instanceof Timestamp) {
                            pStmt.setTimestamp(fInx, (Timestamp) value);
                        }
                        break;
                    }
                    }
                } else {
                    pStmt.setObject(fInx, null);
                }
            }
            pStmt.executeUpdate();

            prevId = id;
            nameToVals.clear();
        }

        String name = rs.getString(secInx);
        name = StringUtils.replace(name, "(", "_");
        name = StringUtils.replace(name, ")", "_");

        Integer intVal = (Integer) rs.getObject(secInx + 1);
        String strVal = (String) rs.getObject(secInx + 2);
        nameToVals.put(name, strVal != null ? strVal : intVal);
    }

    String alterSQL = "ALTER TABLE " + newTblName + " ADD Lookup VARCHAR(64) AFTER IP";
    BasicSQLUtils.update(connection, alterSQL);

    alterSQL = "ALTER TABLE " + newTblName + " ADD Country VARCHAR(64) AFTER Lookup";
    BasicSQLUtils.update(connection, alterSQL);

    alterSQL = "ALTER TABLE " + newTblName + " ADD City VARCHAR(64) AFTER Country";
    BasicSQLUtils.update(connection, alterSQL);

    return instCnt;
}