List of usage examples for java.util HashMap clear
public void clear()
From source file:org.odk.collect.android.tasks.DownloadFormListTask.java
@Override protected HashMap<String, FormDetails> doInBackground(Void... values) { SharedPreferences settings = PreferenceManager .getDefaultSharedPreferences(Collect.getInstance().getBaseContext()); String downloadListUrl = settings.getString(PreferencesActivity.KEY_SERVER_URL, Collect.getInstance().getString(R.string.default_server_url)); String downloadPath = settings.getString(PreferencesActivity.KEY_FORMLIST_URL, "/formlist"); downloadListUrl += downloadPath;/*ww w . j a v a2 s. c om*/ // We populate this with available forms from the specified server. // <formname, details> HashMap<String, FormDetails> formList = new HashMap<String, FormDetails>(); // get shared HttpContext so that authentication and cookies are retained. HttpContext localContext = Collect.getInstance().getHttpContext(); HttpClient httpclient = WebUtils.createHttpClient(WebUtils.CONNECTION_TIMEOUT); DocumentFetchResult result = WebUtils.getXmlDocument(downloadListUrl, localContext, httpclient); // If we can't get the document, return the error, cancel the task if (result.errorMessage != null) { if (result.responseCode == 401) { formList.put(DL_AUTH_REQUIRED, new FormDetails(result.errorMessage)); } else { formList.put(DL_ERROR_MSG, new FormDetails(result.errorMessage)); } return formList; } if (result.isOpenRosaResponse) { // Attempt OpenRosa 1.0 parsing Element xformsElement = result.doc.getRootElement(); if (!xformsElement.getName().equals("xforms")) { String error = "root element is not <xforms> : " + xformsElement.getName(); Log.e(t, "Parsing OpenRosa reply -- " + error); formList.put(DL_ERROR_MSG, new FormDetails( Collect.getInstance().getString(R.string.parse_openrosa_formlist_failed, error))); return formList; } String namespace = xformsElement.getNamespace(); if (!isXformsListNamespacedElement(xformsElement)) { String error = "root element namespace is incorrect:" + namespace; Log.e(t, "Parsing OpenRosa reply -- " + error); formList.put(DL_ERROR_MSG, new FormDetails( Collect.getInstance().getString(R.string.parse_openrosa_formlist_failed, error))); return formList; } int nElements = xformsElement.getChildCount(); for (int i = 0; i < nElements; ++i) { if (xformsElement.getType(i) != Element.ELEMENT) { // e.g., whitespace (text) continue; } Element xformElement = (Element) xformsElement.getElement(i); if (!isXformsListNamespacedElement(xformElement)) { // someone else's extension? continue; } String name = xformElement.getName(); if (!name.equalsIgnoreCase("xform")) { // someone else's extension? continue; } // this is something we know how to interpret String formId = null; String formName = null; String majorMinorVersion = null; String description = null; String downloadUrl = null; String manifestUrl = null; // don't process descriptionUrl int fieldCount = xformElement.getChildCount(); for (int j = 0; j < fieldCount; ++j) { if (xformElement.getType(j) != Element.ELEMENT) { // whitespace continue; } Element child = xformElement.getElement(j); if (!isXformsListNamespacedElement(child)) { // someone else's extension? continue; } String tag = child.getName(); if (tag.equals("formID")) { formId = XFormParser.getXMLText(child, true); if (formId != null && formId.length() == 0) { formId = null; } } else if (tag.equals("name")) { formName = XFormParser.getXMLText(child, true); if (formName != null && formName.length() == 0) { formName = null; } } else if (tag.equals("majorMinorVersion")) { majorMinorVersion = XFormParser.getXMLText(child, true); if (majorMinorVersion != null && majorMinorVersion.length() == 0) { majorMinorVersion = null; } } else if (tag.equals("descriptionText")) { description = XFormParser.getXMLText(child, true); if (description != null && description.length() == 0) { description = null; } } else if (tag.equals("downloadUrl")) { downloadUrl = XFormParser.getXMLText(child, true); if (downloadUrl != null && downloadUrl.length() == 0) { downloadUrl = null; } } else if (tag.equals("manifestUrl")) { manifestUrl = XFormParser.getXMLText(child, true); if (manifestUrl != null && manifestUrl.length() == 0) { manifestUrl = null; } } } if (formId == null || downloadUrl == null || formName == null) { String error = "Forms list entry " + Integer.toString(i) + " is missing one or more tags: formId, name, or downloadUrl"; Log.e(t, "Parsing OpenRosa reply -- " + error); formList.clear(); formList.put(DL_ERROR_MSG, new FormDetails( Collect.getInstance().getString(R.string.parse_openrosa_formlist_failed, error))); return formList; } /* * TODO: We currently don't care about major/minor version. maybe someday we will. */ // Integer modelVersion = null; // Integer uiVersion = null; // try { // if (majorMinorVersion == null || majorMinorVersion.length() == 0) { // modelVersion = null; // uiVersion = null; // } else { // int idx = majorMinorVersion.indexOf("."); // if (idx == -1) { // modelVersion = Integer.parseInt(majorMinorVersion); // uiVersion = null; // } else { // modelVersion = Integer.parseInt(majorMinorVersion.substring(0, idx)); // uiVersion = // (idx == majorMinorVersion.length() - 1) ? null : Integer // .parseInt(majorMinorVersion.substring(idx + 1)); // } // } // } catch (Exception e) { // e.printStackTrace(); // String error = "Forms list entry " + Integer.toString(i) + // " has an invalid majorMinorVersion: " + majorMinorVersion; // Log.e(t, "Parsing OpenRosa reply -- " + error); // formList.clear(); // formList.put(DL_ERROR_MSG, new FormDetails( // Collect.getInstance().getString(R.string.parse_openrosa_formlist_failed, // error))); // return formList; // } formList.put(formId, new FormDetails(formName, downloadUrl, manifestUrl, formId)); } } else { // Aggregate 0.9.x mode... // populate HashMap with form names and urls Element formsElement = result.doc.getRootElement(); int formsCount = formsElement.getChildCount(); for (int i = 0; i < formsCount; ++i) { if (formsElement.getType(i) != Element.ELEMENT) { // whitespace continue; } Element child = formsElement.getElement(i); String tag = child.getName(); String formId = null; if (tag.equals("formID")) { formId = XFormParser.getXMLText(child, true); if (formId != null && formId.length() == 0) { formId = null; } } if (tag.equalsIgnoreCase("form")) { String formName = XFormParser.getXMLText(child, true); if (formName != null && formName.length() == 0) { formName = null; } String downloadUrl = child.getAttributeValue(null, "url"); downloadUrl = downloadUrl.trim(); if (downloadUrl != null && downloadUrl.length() == 0) { downloadUrl = null; } if (downloadUrl == null || formName == null) { String error = "Forms list entry " + Integer.toString(i) + " is missing form name or url attribute"; Log.e(t, "Parsing OpenRosa reply -- " + error); formList.clear(); formList.put(DL_ERROR_MSG, new FormDetails( Collect.getInstance().getString(R.string.parse_legacy_formlist_failed, error))); return formList; } formList.put(formId, new FormDetails(formName, downloadUrl, null, formId)); } } } return formList; }
From source file:com.krawler.spring.hrms.rec.job.hrmsRecJobController.java
public ModelAndView createapplicantFunction(HttpServletRequest request, HttpServletResponse response) { JSONObject jobj = new JSONObject(); JSONObject jobj1 = new JSONObject(); List list = null;/*from www . ja v a 2 s . co m*/ SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); KwlReturnObject result = null; //Create transaction DefaultTransactionDefinition def = new DefaultTransactionDefinition(); def.setName("JE_Tx"); def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); def.setIsolationLevel(TransactionDefinition.ISOLATION_READ_UNCOMMITTED); TransactionStatus status = txnManager.getTransaction(def); try { HashMap<String, Object> requestParams = new HashMap<String, Object>(); ArrayList filter_names = new ArrayList(), filter_values = new ArrayList(); String pwd = request.getParameter("p"); String username = request.getParameter("u"); String fname = request.getParameter("fname"); String lname = request.getParameter("lname"); String cmpid = sessionHandlerImplObj.getCompanyid(request); if (StringUtil.isNullOrEmpty(request.getParameter("update"))) { filter_names.add("Col3"); filter_values.add(request.getParameter("e")); filter_names.add("deleted"); filter_values.add(false); filter_names.add("company.companyID"); filter_values.add(cmpid); requestParams.put("filter_names", filter_names); requestParams.put("filter_values", filter_values); result = hrmsRecJobDAOObj.getConfigJobApplicant(requestParams); list = result.getEntityList(); if (list.size() == 0) { Company cmp = (Company) kwlCommonTablesDAOObj.getObject("com.krawler.common.admin.Company", cmpid); requestParams.clear(); requestParams.put("Col1", fname); requestParams.put("Col2", lname); requestParams.put("Col3", request.getParameter("e")); //requestParams.put("Address1", request.getParameter("addr")); requestParams.put("Col4", request.getParameter("contact")); // requestParams.put("Username", username); // requestParams.put("Password", authHandler.getSHA1(pwd)); // requestParams.put("Status", 0); requestParams.put("Company", cmpid); result = hrmsRecJobDAOObj.addConfigRecruitmentData(requestParams); if (result.isSuccessFlag()) { /*String uri = URLUtil.getPageURL(request, Links.loginpagewthFull,cmp.getSubDomain())+"applicantLogin.html"; String pmsg = String.format(KWLErrorMsgs.msgMailInvite, fname, "Demo", username, pwd, uri, "Demo"); String htmlmsg = String.format(HrmsMsgs.msgMailInviteUsernamePassword, fname, profileHandlerDAOObj.getUserFullName( sessionHandlerImplObj.getUserid(request)), sessionHandlerImplObj.getCompanyName(request), username, pwd, uri, uri, ""); try { SendMailHandler.postMail(new String[]{request.getParameter("e")}, "["+messageSource.getMessage("hrms.common.deskera", null, RequestContextUtils.getLocale(request))+"] "+messageSource.getMessage("hrms.common.welcome.deskera.hrms", null, RequestContextUtils.getLocale(request)), htmlmsg, pmsg, "admin.hrms@mailinator.com"); } catch (MessagingException e) { e.printStackTrace(); }*/ jobj.put("msg", messageSource.getMessage("hrms.common.Applicantcreatedsuccessfully", null, RequestContextUtils.getLocale(request))); jobj.put("type", messageSource.getMessage("hrms.common.success", null, RequestContextUtils.getLocale(request))); //@@ProfileHandler.insertAuditLog(session, AuditAction.CREATE_APPLICANT, "User " + AuthHandler.getFullName(session, AuthHandler.getUserid(request)) + " has created new applicant " + jobapp.getFirstname() + " " + jobapp.getLastname(),request); auditTrailDAOObj.insertAuditLog(AuditAction.CREATE_APPLICANT, "User " + profileHandlerDAOObj .getUserFullName(sessionHandlerImplObj.getUserid(request)) + " has created new applicant " + fname + " " + lname, request, "0"); } else { jobj.put("msg", messageSource.getMessage("hrms.recruitment.error.occurred.creating.applicant", null, RequestContextUtils.getLocale(request))); jobj.put("type", messageSource.getMessage("hrms.common.error", null, RequestContextUtils.getLocale(request))); } } else { jobj.put("msg", messageSource.getMessage("hrms.common.email.already.exists", null, RequestContextUtils.getLocale(request))); jobj.put("type", messageSource.getMessage("hrms.common.warning", null, RequestContextUtils.getLocale(request))); } } else { requestParams.put("primary", true); requestParams.put("applicantid", request.getParameter("profileid")); result = hrmsRecJobDAOObj.getConfigJobApplicant(requestParams); list = result.getEntityList(); if (!list.isEmpty()) { String jsondata1 = request.getParameter("jsondata1"); String jsondata2 = request.getParameter("jsondata2"); String jsondata3 = request.getParameter("jsondata3"); String jsondata4 = request.getParameter("jsondata4"); String jsondata5 = request.getParameter("jsondata5"); requestParams.clear(); requestParams.put("Applicantid", request.getParameter("profileid")); if (jsondata1.length() > 0) { jobj = new JSONObject(jsondata1); requestParams.put("Title", jobj.getString("title")); requestParams.put("Firstname", jobj.getString("firstname")); requestParams.put("Lastname", jobj.getString("lastname")); requestParams.put("Email", jobj.getString("email")); requestParams.put("Otheremail", jobj.getString("otheremail")); requestParams.put("Birthdate", (Date) fmt.parse(jobj.getString("birthdate"))); } if (jsondata2.length() > 0) { jobj = new JSONObject(jsondata2); requestParams.put("Contactno", jobj.getString("contactno")); requestParams.put("Mobileno", jobj.getString("mobileno")); requestParams.put("City", jobj.getString("city")); requestParams.put("State", jobj.getString("state")); requestParams.put("Countryid", jobj.getString("country")); requestParams.put("Address1", jobj.getString("address1")); requestParams.put("Address2", jobj.getString("address2")); } if (jsondata3.length() > 0) { jobj = new JSONObject(jsondata3); if (StringUtil.isNullOrEmpty(jobj.getString("graddegree")) == false) { requestParams.put("Graddegree", jobj.getString("graddegree")); } if (StringUtil.isNullOrEmpty(jobj.getString("gradspecilization")) == false) { requestParams.put("Gradspecialization", jobj.getString("gradspecilization")); } if (StringUtil.isNullOrEmpty(jobj.getString("gradcollege")) == false) { requestParams.put("Gradcollege", jobj.getString("gradcollege")); } if (StringUtil.isNullOrEmpty(jobj.getString("graduniversity")) == false) { requestParams.put("Graduniversity", jobj.getString("graduniversity")); } if (StringUtil.isNullOrEmpty(jobj.getString("gradepercent")) == false) { requestParams.put("Gradpercent", jobj.getString("gradepercent")); } if (StringUtil.isNullOrEmpty(jobj.getString("gradpassdate")) == false) { requestParams.put("Gradpassdate", (Date) fmt.parse(jobj.getString("gradpassdate"))); } if (StringUtil.isNullOrEmpty(jobj.getString("pgqualification")) == false) { requestParams.put("Pgqualification", jobj.getString("pgqualification")); } if (StringUtil.isNullOrEmpty(jobj.getString("pgspecialization")) == false) { requestParams.put("Pgspecialization", jobj.getString("pgspecialization")); } if (StringUtil.isNullOrEmpty(jobj.getString("pgcollege")) == false) { requestParams.put("Pgcollege", jobj.getString("pgcollege")); } if (StringUtil.isNullOrEmpty(jobj.getString("pguniversity")) == false) { requestParams.put("Pguniversity", jobj.getString("pguniversity")); } if (StringUtil.isNullOrEmpty(jobj.getString("pgpercent")) == false) { requestParams.put("Pgpercent", jobj.getString("pgpercent")); } if (StringUtil.isNullOrEmpty(jobj.getString("pgpassdate")) == false) { requestParams.put("Pgpassdate", (Date) fmt.parse(jobj.getString("pgpassdate"))); } if (StringUtil.isNullOrEmpty(jobj.getString("othername")) == false) { requestParams.put("Othername", jobj.getString("othername")); } if (StringUtil.isNullOrEmpty(jobj.getString("otherqualification")) == false) { requestParams.put("Otherqualification", jobj.getString("otherqualification")); } if (StringUtil.isNullOrEmpty(jobj.getString("otherpercent")) == false) { requestParams.put("Otherpercent", jobj.getString("otherpercent")); } if (StringUtil.isNullOrEmpty(jobj.getString("otherdetails")) == false) { requestParams.put("Otherdetails", jobj.getString("otherdetails")); } if (StringUtil.isNullOrEmpty(jobj.getString("otherpassdate")) == false) { requestParams.put("Otherpassdate", (Date) fmt.parse(jobj.getString("otherpassdate"))); } } if (jsondata4.length() > 0) { jobj = new JSONObject(jsondata4); if (jobj.getString("experiencemonth").equals("")) { requestParams.put("Experiencemonth", 0); } else { requestParams.put("Experiencemonth", Integer.parseInt(jobj.getString("experiencemonth"))); } if (StringUtil.isNullOrEmpty(jobj.getString("experienceyear")) == false) { requestParams.put("Experienceyear", Integer.parseInt(jobj.getString("experienceyear"))); } if (StringUtil.isNullOrEmpty(jobj.getString("functionalexpertise")) == false) { requestParams.put("Functionalexpertise", jobj.getString("functionalexpertise")); } if (StringUtil.isNullOrEmpty(jobj.getString("currentindustry")) == false) { requestParams.put("Currentindustry", jobj.getString("currentindustry")); } if (StringUtil.isNullOrEmpty(jobj.getString("currentorganization")) == false) { requestParams.put("Currentorganization", jobj.getString("currentorganization")); } if (StringUtil.isNullOrEmpty(jobj.getString("currentdesignation")) == false) { requestParams.put("Currentdesignation", jobj.getString("currentdesignation")); } if (StringUtil.isNullOrEmpty(jobj.getString("grosssalary")) == false) { requestParams.put("Grosssalary", Integer.parseInt(jobj.getString("grosssalary"))); } requestParams.put("Expectedsalary", Integer.parseInt(jobj.getString("expectedsalary"))); } if (jsondata5.length() > 0) { jobj = new JSONObject(jsondata5); requestParams.put("Keyskills", jobj.getString("keyskills")); if (StringUtil.isNullOrEmpty(jobj.getString("category")) == false) { requestParams.put("Category", jobj.getString("category")); } if (StringUtil.isNullOrEmpty(jobj.getString("filepath")) == false) { requestParams.put("Filepath", jobj.getString("filepath")); } if (StringUtil.isNullOrEmpty(jobj.getString("companyrelative")) == false) { requestParams.put("Companyrelative", jobj.getString("companyrelative")); } if (StringUtil.isNullOrEmpty(jobj.getString("appearedbefore")) == false) { requestParams.put("Appearedbefore", jobj.getString("appearedbefore")); if (jobj.getString("appearedbefore").equalsIgnoreCase("yes")) { if (StringUtil.isNullOrEmpty(jobj.getString("interviewplace")) == false) { requestParams.put("Interviewplace", jobj.getString("interviewplace")); } if (StringUtil.isNullOrEmpty(jobj.getString("interviewdate")) == false) { requestParams.put("Interviewdate", (Date) fmt.parse(jobj.getString("interviewdate"))); } if (StringUtil.isNullOrEmpty(jobj.getString("interviewposition")) == false) { requestParams.put("Interviewposition", jobj.getString("interviewposition")); } } } requestParams.put("Interviewlocation", jobj.getString("interviewlocation")); result = hrmsRecJobDAOObj.setJobApplicant(requestParams); } // insertConfigData(request, "Recruitment", request.getParameter("profileid"),sessionHandlerImplObj.getCompanyid(request)); hrmsCommonDAOObj.insertConfigData(request, "Recruitment", request.getParameter("profileid"), sessionHandlerImplObj.getCompanyid(request)); } if (result.isSuccessFlag()) { jobj.put("msg", messageSource.getMessage("hrms.recruitment.applicant.updated.successfully", null, RequestContextUtils.getLocale(request))); jobj.put("type", messageSource.getMessage("hrms.common.success", null, RequestContextUtils.getLocale(request))); } else { jobj.put("msg", messageSource.getMessage("hrms.recruitment.error.occurred.updating.applicant", null, RequestContextUtils.getLocale(request))); jobj.put("type", messageSource.getMessage("hrms.common.error", null, RequestContextUtils.getLocale(request))); } } jobj1.put("data", jobj.toString()); jobj1.put("valid", true); txnManager.commit(status); } catch (Exception e) { e.printStackTrace(); txnManager.rollback(status); } finally { return new ModelAndView("jsonView", "model", jobj1.toString()); } }
From source file:com.mpower.mintel.android.tasks.DownloadFormListTask.java
@Override protected HashMap<String, FormDetails> doInBackground(Void... values) { SharedPreferences settings = PreferenceManager .getDefaultSharedPreferences(MIntel.getInstance().getBaseContext()); String downloadListUrl = settings.getString(PreferencesActivity.KEY_SERVER_URL, MIntel.getInstance().getString(R.string.default_server_url)); downloadListUrl += WebUtils.URL_PART_FORMLIST; String auth = ""; // We populate this with available forms from the specified server. // <formname, details> HashMap<String, FormDetails> formList = new HashMap<String, FormDetails>(); // get shared HttpContext so that authentication and cookies are // retained./*from w w w . j a va2s .co m*/ HttpContext localContext = MIntel.getInstance().getHttpContext(); HttpClient httpclient = WebUtils.createHttpClient(WebUtils.CONNECTION_TIMEOUT); DocumentFetchResult result = WebUtils.getXmlDocument(downloadListUrl, localContext, httpclient, auth); // If we can't get the document, return the error, cancel the task if (result.errorMessage != null) { if (result.responseCode == 401) { formList.put(DL_AUTH_REQUIRED, new FormDetails(result.errorMessage)); } else { formList.put(DL_ERROR_MSG, new FormDetails(result.errorMessage)); } return formList; } if (result.isOpenRosaResponse) { // Attempt OpenRosa 1.0 parsing Element xformsElement = result.doc.getRootElement(); if (!xformsElement.getName().equals("xforms")) { String error = "root element is not <xforms> : " + xformsElement.getName(); Log.e(t, "Parsing OpenRosa reply -- " + error); formList.put(DL_ERROR_MSG, new FormDetails( MIntel.getInstance().getString(R.string.parse_openrosa_formlist_failed, error))); return formList; } String namespace = xformsElement.getNamespace(); if (!isXformsListNamespacedElement(xformsElement)) { String error = "root element namespace is incorrect:" + namespace; Log.e(t, "Parsing OpenRosa reply -- " + error); formList.put(DL_ERROR_MSG, new FormDetails( MIntel.getInstance().getString(R.string.parse_openrosa_formlist_failed, error))); return formList; } int nElements = xformsElement.getChildCount(); for (int i = 0; i < nElements; ++i) { if (xformsElement.getType(i) != Element.ELEMENT) { // e.g., whitespace (text) continue; } Element xformElement = (Element) xformsElement.getElement(i); if (!isXformsListNamespacedElement(xformElement)) { // someone else's extension? continue; } String name = xformElement.getName(); if (!name.equalsIgnoreCase("xform")) { // someone else's extension? continue; } // this is something we know how to interpret String formId = null; String formName = null; String majorMinorVersion = null; String description = null; String downloadUrl = null; String manifestUrl = null; // don't process descriptionUrl int fieldCount = xformElement.getChildCount(); for (int j = 0; j < fieldCount; ++j) { if (xformElement.getType(j) != Element.ELEMENT) { // whitespace continue; } Element child = xformElement.getElement(j); if (!isXformsListNamespacedElement(child)) { // someone else's extension? continue; } String tag = child.getName(); if (tag.equals("formID")) { formId = XFormParser.getXMLText(child, true); if (formId != null && formId.length() == 0) { formId = null; } } else if (tag.equals("name")) { formName = XFormParser.getXMLText(child, true); if (formName != null && formName.length() == 0) { formName = null; } } else if (tag.equals("majorMinorVersion")) { majorMinorVersion = XFormParser.getXMLText(child, true); if (majorMinorVersion != null && majorMinorVersion.length() == 0) { majorMinorVersion = null; } } else if (tag.equals("descriptionText")) { description = XFormParser.getXMLText(child, true); if (description != null && description.length() == 0) { description = null; } } else if (tag.equals("downloadUrl")) { downloadUrl = XFormParser.getXMLText(child, true); if (downloadUrl != null && downloadUrl.length() == 0) { downloadUrl = null; } } else if (tag.equals("manifestUrl")) { manifestUrl = XFormParser.getXMLText(child, true); if (manifestUrl != null && manifestUrl.length() == 0) { manifestUrl = null; } } } if (formId == null || downloadUrl == null || formName == null) { String error = "Forms list entry " + Integer.toString(i) + " is missing one or more tags: formId, name, or downloadUrl"; Log.e(t, "Parsing OpenRosa reply -- " + error); formList.clear(); formList.put(DL_ERROR_MSG, new FormDetails( MIntel.getInstance().getString(R.string.parse_openrosa_formlist_failed, error))); return formList; } /* * TODO: We currently don't care about major/minor version. * maybe someday we will. */ // Integer modelVersion = null; // Integer uiVersion = null; // try { // if (majorMinorVersion == null || majorMinorVersion.length() // == 0) { // modelVersion = null; // uiVersion = null; // } else { // int idx = majorMinorVersion.indexOf("."); // if (idx == -1) { // modelVersion = Integer.parseInt(majorMinorVersion); // uiVersion = null; // } else { // modelVersion = // Integer.parseInt(majorMinorVersion.substring(0, idx)); // uiVersion = // (idx == majorMinorVersion.length() - 1) ? null : Integer // .parseInt(majorMinorVersion.substring(idx + 1)); // } // } // } catch (Exception e) { // e.printStackTrace(); // String error = "Forms list entry " + Integer.toString(i) + // " has an invalid majorMinorVersion: " + majorMinorVersion; // Log.e(t, "Parsing OpenRosa reply -- " + error); // formList.clear(); // formList.put(DL_ERROR_MSG, new FormDetails( // MIntel.getInstance().getString(R.string.parse_openrosa_formlist_failed, // error))); // return formList; // } formList.put(formId, new FormDetails(formName, downloadUrl, manifestUrl, formId)); } } else { // Aggregate 0.9.x mode... // populate HashMap with form names and urls Element formsElement = result.doc.getRootElement(); int formsCount = formsElement.getChildCount(); for (int i = 0; i < formsCount; ++i) { if (formsElement.getType(i) != Element.ELEMENT) { // whitespace continue; } Element child = formsElement.getElement(i); String tag = child.getName(); String formId = null; if (tag.equals("formID")) { formId = XFormParser.getXMLText(child, true); if (formId != null && formId.length() == 0) { formId = null; } } if (tag.equalsIgnoreCase("form")) { String formName = XFormParser.getXMLText(child, true); if (formName != null && formName.length() == 0) { formName = null; } String downloadUrl = child.getAttributeValue(null, "url"); downloadUrl = downloadUrl.trim(); if (downloadUrl != null && downloadUrl.length() == 0) { downloadUrl = null; } if (downloadUrl == null || formName == null) { String error = "Forms list entry " + Integer.toString(i) + " is missing form name or url attribute"; Log.e(t, "Parsing OpenRosa reply -- " + error); formList.clear(); formList.put(DL_ERROR_MSG, new FormDetails( MIntel.getInstance().getString(R.string.parse_legacy_formlist_failed, error))); return formList; } formList.put(formName, new FormDetails(formName, downloadUrl, null, formName)); } } } return formList; }
From source file:com.krawler.spring.hrms.rec.job.hrmsRecJobController.java
public ModelAndView addConfigRecruitmentType(HttpServletRequest request, HttpServletResponse response) { KwlReturnObject result = null;/*from ww w .j av a 2 s .c om*/ String companyid = ""; JSONObject jobj = new JSONObject(); JSONObject jobj1 = new JSONObject(); boolean max = false, isfieldnotexist = true, isEmailNullOrVisibleFlag = true; String title = messageSource.getMessage("hrms.common.success", null, "Success", RequestContextUtils.getLocale(request)); try { companyid = sessionHandlerImplObj.getCompanyid(request); ConfigRecruitment contyp = null; HashMap<String, Object> requestParams = new HashMap<String, Object>(); if (!request.getParameter("configid").equals("clone")) { int colcount = 0; int position = 1; if (request.getParameter("configid").equals("config")) { requestParams.put("filter_names", Arrays.asList("company.companyID")); requestParams.put("filter_values", Arrays.asList(companyid)); result = hrmsRecJobDAOObj.getConfigRecruitment(requestParams); List lst = result.getEntityList(); colcount = lst.size(); if (colcount == 70) { jobj.put("success", "msg"); jobj.put("title", messageSource.getMessage("hrms.common.alert", null, "Alert", RequestContextUtils.getLocale(request))); jobj.put("msg", messageSource.getMessage( "hrms.common.CannotaddnewfieldMaximumcustomfieldlimitreached", null, "Cannot add new field. Maximum custom field limit reached.", RequestContextUtils.getLocale(request))); max = true; } if (!max) { requestParams.clear(); requestParams.put("filter_names", Arrays.asList("formtype", "name", "company.companyID")); requestParams.put("filter_values", Arrays.asList(request.getParameter("formtype"), request.getParameter("fieldname"), companyid)); result = hrmsRecJobDAOObj.getConfigRecruitment(requestParams); List lst1 = result.getEntityList(); Iterator ite1 = lst1.iterator(); if (ite1.hasNext()) { isfieldnotexist = false; title = messageSource.getMessage("hrms.common.warning", null, RequestContextUtils.getLocale(request)); jobj.put("success", "msg"); jobj.put("title", messageSource.getMessage("hrms.common.alert", null, "Alert", RequestContextUtils.getLocale(request))); jobj.put("msg", messageSource.getMessage( "hrms.common.FieldNameexistsPleaseprovideadifferentFieldName", null, "FieldName exists. Please provide a different FieldName.", RequestContextUtils.getLocale(request))); } else { Iterator ite = lst.iterator(); int[] countchk = new int[71]; while (ite.hasNext()) { ConfigRecruitment tmpcontyp = (ConfigRecruitment) ite.next(); countchk[tmpcontyp.getColnum()] = 1; } for (int i = 1; i <= 70; i++) { if (countchk[i] == 0) { colcount = i; break; } } requestParams.clear(); requestParams.put("filter_names", Arrays.asList("formtype", "company.companyID")); requestParams.put("filter_values", Arrays.asList(request.getParameter("formtype"), companyid)); result = hrmsRecJobDAOObj.getConfigRecruitment(requestParams); position = result.getEntityList().size() + 1; jobj.put("msg", messageSource.getMessage("hrms.common.Configoptionisaddedsuccessfully", null, "Config option is added successfully.", RequestContextUtils.getLocale(request))); } requestParams.clear(); requestParams.put("Position", position); } } else { boolean visible = Boolean.parseBoolean(request.getParameter("visible")); boolean allownull = Boolean.parseBoolean(request.getParameter("allownull")); requestParams.clear(); contyp = (ConfigRecruitment) kwlCommonTablesDAOObj.getObject( "com.krawler.hrms.recruitment.ConfigRecruitment", request.getParameter("configid")); colcount = contyp.getColnum(); if (colcount == 1 || colcount == 2 || colcount == 3 || colcount == 4 || colcount == 9) { String message = ""; isEmailNullOrVisibleFlag = false; if (colcount == 1) { message = "'" + messageSource.getMessage("hrms.common.FirstName", null, RequestContextUtils.getLocale(request)) + "'"; } else { if (colcount == 2) { message = "'" + messageSource.getMessage("hrms.common.LastName", null, RequestContextUtils.getLocale(request)) + "'"; } else { if (colcount == 3) { message = "'" + messageSource.getMessage("hrms.recruitment.profile.EmailID", null, RequestContextUtils.getLocale(request)) + "'"; } else { if (colcount == 4) { message = "'" + messageSource.getMessage("hrms.recruitment.profile.ContactNo", null, RequestContextUtils.getLocale(request)) + "'"; } else { if (colcount == 9) { message = "'" + messageSource.getMessage( "hrms.recruitment.profile.AppliedDate1", null, "A", RequestContextUtils.getLocale(request)) + "'"; } } } } } title = messageSource.getMessage("hrms.common.warning", null, RequestContextUtils.getLocale(request)); jobj.put("msg", messageSource.getMessage("hrms.recruitment.you.cannot.edit.default.config", null, RequestContextUtils.getLocale(request)) + " " + message + "."); } else { jobj.put("msg", messageSource.getMessage("hrms.common.Configoptionisaddedsuccessfully", null, "Config option is added successfully.", RequestContextUtils.getLocale(request))); } requestParams.clear(); if (!contyp.getFormtype().equals(request.getParameter("formtype"))) { requestParams.put("position", contyp.getPosition()); requestParams.put("formtype", contyp.getFormtype()); hrmsRecJobDAOObj.updateConfigRecruitment(requestParams); requestParams.clear(); requestParams.put("filter_names", Arrays.asList("formtype", "company.companyID")); requestParams.put("filter_values", Arrays.asList(request.getParameter("formtype"), companyid)); result = hrmsRecJobDAOObj.getConfigRecruitment(requestParams); position = result.getEntityList().size() + 1; requestParams.clear(); requestParams.put("Position", position); } requestParams.put("Configid", request.getParameter("configid")); } if (isfieldnotexist && isEmailNullOrVisibleFlag) { requestParams.put("Company", companyid); requestParams.put("Formtype", request.getParameter("formtype")); requestParams.put("Name", request.getParameter("fieldname")); requestParams.put("Colnum", colcount); requestParams.put("Configtype", Integer.parseInt(request.getParameter("configtype"))); requestParams.put("Visible", request.getParameter("visible").equals("true")); requestParams.put("IsSystemProperty", request.getParameter("issystemproperty").equals("true")); requestParams.put("Allownull", request.getParameter("allownull").equals("true")); result = hrmsRecJobDAOObj.addConfigRecruitmentType(requestParams); } } jobj.put("success", "msg"); jobj.put("title", title); jobj1.put("data", jobj); jobj1.put("valid", true); } catch (Exception ex) { ex.printStackTrace(); } finally { return new ModelAndView(successView, "model", jobj1.toString()); } }
From source file:org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient.java
public void getTaskData(Set<String> taskIds, final TaskDataCollector collector, final TaskAttributeMapper mapper, final IProgressMonitor monitor) throws IOException, CoreException { if (repositoryConfiguration == null) { getRepositoryConfiguration(new SubProgressMonitor(monitor, 1), null); connector.addRepositoryConfiguration(repositoryConfiguration); }//from w ww. j ava 2s . co m GzipPostMethod method = null; HashMap<String, TaskData> taskDataMap = new HashMap<String, TaskData>(); // make a copy to modify set taskIds = new HashSet<String>(taskIds); int authenticationAttempt = 0; while (taskIds.size() > 0) { try { Set<String> idsToRetrieve = new HashSet<String>(); Iterator<String> itr = taskIds.iterator(); for (int x = 0; itr.hasNext() && x < MAX_RETRIEVED_PER_QUERY; x++) { String taskId = itr.next(); String taskIdOrg = taskId; // remove leading zeros boolean changed = false; while (taskId.startsWith("0")) { //$NON-NLS-1$ taskId = taskId.substring(1); changed = true; } idsToRetrieve.add(taskId); if (changed) { taskIds.remove(taskIdOrg); taskIds.add(taskId); } } NameValuePair[] formData = new NameValuePair[idsToRetrieve.size() + 2]; if (idsToRetrieve.size() == 0) { return; } itr = idsToRetrieve.iterator(); int x = 0; for (; itr.hasNext(); x++) { String taskId = itr.next(); formData[x] = new NameValuePair("id", taskId); //$NON-NLS-1$ TaskData taskData = new TaskData(mapper, getConnectorKind(), repositoryUrl.toString(), taskId); setupExistingBugAttributes(repositoryUrl.toString(), taskData); taskDataMap.put(taskId, taskData); } formData[x++] = new NameValuePair("ctype", "xml"); //$NON-NLS-1$ //$NON-NLS-2$ formData[x] = new NameValuePair("excludefield", "attachmentdata"); //$NON-NLS-1$ //$NON-NLS-2$ method = postFormData(IBugzillaConstants.URL_POST_SHOW_BUG, formData, monitor); if (method == null) { throw new IOException("Could not post form, client returned null method."); //$NON-NLS-1$ } boolean parseable = false; if (method.getResponseHeader("Content-Type") != null) { //$NON-NLS-1$ Header responseTypeHeader = method.getResponseHeader("Content-Type"); //$NON-NLS-1$ for (String type : VALID_CONFIG_CONTENT_TYPES) { if (responseTypeHeader.getValue().toLowerCase(Locale.ENGLISH).contains(type)) { InputStream input = getResponseStream(method, monitor); try { MultiBugReportFactory factory = new MultiBugReportFactory(input, getCharacterEncoding(), connector); List<BugzillaCustomField> customFields = new ArrayList<BugzillaCustomField>(); if (repositoryConfiguration != null) { customFields = repositoryConfiguration.getCustomFields(); } factory.populateReport(taskDataMap, collector, mapper, customFields); taskIds.removeAll(idsToRetrieve); taskDataMap.clear(); parseable = true; break; } finally { input.close(); } } } } if (!parseable) { // because html is not a valid config content type it is save to get the response here throw new CoreException(parseHtmlError(getResponseStream(method, monitor))); } } catch (CoreException c) { if (c.getStatus().getCode() == RepositoryStatus.ERROR_REPOSITORY_LOGIN && authenticationAttempt < 1) { loggedIn = false; authenticationAttempt++; //StatusHandler.log(c.getStatus()); } else { throw c; } } finally { if (method != null) { WebUtil.releaseConnection(method, monitor); } } } }
From source file:com.mpower.daktar.android.tasks.DownloadFormListTask.java
@Override protected HashMap<String, FormDetails> doInBackground(final Void... values) { final SharedPreferences settings = PreferenceManager .getDefaultSharedPreferences(MIntel.getInstance().getBaseContext()); String downloadListUrl = settings.getString(PreferencesActivity.KEY_SERVER_URL, MIntel.getInstance().getString(R.string.default_server_url)); downloadListUrl += WebUtils.URL_PART_FORMLIST; final String auth = ""; // We populate this with available forms from the specified server. // <formname, details> final HashMap<String, FormDetails> formList = new HashMap<String, FormDetails>(); // get shared HttpContext so that authentication and cookies are // retained./*from ww w. j a v a 2 s . c o m*/ final HttpContext localContext = MIntel.getInstance().getHttpContext(); final HttpClient httpclient = WebUtils.createHttpClient(WebUtils.CONNECTION_TIMEOUT); final DocumentFetchResult result = WebUtils.getXmlDocument(downloadListUrl, localContext, httpclient, auth); // If we can't get the document, return the error, cancel the task if (result.errorMessage != null) { if (result.responseCode == 401) { formList.put(DL_AUTH_REQUIRED, new FormDetails(result.errorMessage)); } else { formList.put(DL_ERROR_MSG, new FormDetails(result.errorMessage)); } return formList; } if (result.isOpenRosaResponse) { // Attempt OpenRosa 1.0 parsing final Element xformsElement = result.doc.getRootElement(); if (!xformsElement.getName().equals("xforms")) { final String error = "root element is not <xforms> : " + xformsElement.getName(); Log.e(t, "Parsing OpenRosa reply -- " + error); formList.put(DL_ERROR_MSG, new FormDetails( MIntel.getInstance().getString(R.string.parse_openrosa_formlist_failed, error))); return formList; } final String namespace = xformsElement.getNamespace(); if (!isXformsListNamespacedElement(xformsElement)) { final String error = "root element namespace is incorrect:" + namespace; Log.e(t, "Parsing OpenRosa reply -- " + error); formList.put(DL_ERROR_MSG, new FormDetails( MIntel.getInstance().getString(R.string.parse_openrosa_formlist_failed, error))); return formList; } final int nElements = xformsElement.getChildCount(); for (int i = 0; i < nElements; ++i) { if (xformsElement.getType(i) != Node.ELEMENT) { // e.g., whitespace (text) continue; } final Element xformElement = xformsElement.getElement(i); if (!isXformsListNamespacedElement(xformElement)) { // someone else's extension? continue; } final String name = xformElement.getName(); if (!name.equalsIgnoreCase("xform")) { // someone else's extension? continue; } // this is something we know how to interpret String formId = null; String formName = null; String majorMinorVersion = null; String description = null; String downloadUrl = null; String manifestUrl = null; // don't process descriptionUrl final int fieldCount = xformElement.getChildCount(); for (int j = 0; j < fieldCount; ++j) { if (xformElement.getType(j) != Node.ELEMENT) { // whitespace continue; } final Element child = xformElement.getElement(j); if (!isXformsListNamespacedElement(child)) { // someone else's extension? continue; } final String tag = child.getName(); if (tag.equals("formID")) { formId = XFormParser.getXMLText(child, true); if (formId != null && formId.length() == 0) { formId = null; } } else if (tag.equals("name")) { formName = XFormParser.getXMLText(child, true); if (formName != null && formName.length() == 0) { formName = null; } } else if (tag.equals("majorMinorVersion")) { majorMinorVersion = XFormParser.getXMLText(child, true); if (majorMinorVersion != null && majorMinorVersion.length() == 0) { majorMinorVersion = null; } } else if (tag.equals("descriptionText")) { description = XFormParser.getXMLText(child, true); if (description != null && description.length() == 0) { description = null; } } else if (tag.equals("downloadUrl")) { downloadUrl = XFormParser.getXMLText(child, true); if (downloadUrl != null && downloadUrl.length() == 0) { downloadUrl = null; } } else if (tag.equals("manifestUrl")) { manifestUrl = XFormParser.getXMLText(child, true); if (manifestUrl != null && manifestUrl.length() == 0) { manifestUrl = null; } } } if (formId == null || downloadUrl == null || formName == null) { final String error = "Forms list entry " + Integer.toString(i) + " is missing one or more tags: formId, name, or downloadUrl"; Log.e(t, "Parsing OpenRosa reply -- " + error); formList.clear(); formList.put(DL_ERROR_MSG, new FormDetails( MIntel.getInstance().getString(R.string.parse_openrosa_formlist_failed, error))); return formList; } /* * TODO: We currently don't care about major/minor version. * maybe someday we will. */ // Integer modelVersion = null; // Integer uiVersion = null; // try { // if (majorMinorVersion == null || majorMinorVersion.length() // == 0) { // modelVersion = null; // uiVersion = null; // } else { // int idx = majorMinorVersion.indexOf("."); // if (idx == -1) { // modelVersion = Integer.parseInt(majorMinorVersion); // uiVersion = null; // } else { // modelVersion = // Integer.parseInt(majorMinorVersion.substring(0, idx)); // uiVersion = // (idx == majorMinorVersion.length() - 1) ? null : Integer // .parseInt(majorMinorVersion.substring(idx + 1)); // } // } // } catch (Exception e) { // e.printStackTrace(); // String error = "Forms list entry " + Integer.toString(i) + // " has an invalid majorMinorVersion: " + majorMinorVersion; // Log.e(t, "Parsing OpenRosa reply -- " + error); // formList.clear(); // formList.put(DL_ERROR_MSG, new FormDetails( // MIntel.getInstance().getString(R.string.parse_openrosa_formlist_failed, // error))); // return formList; // } formList.put(formId, new FormDetails(formName, downloadUrl, manifestUrl, formId)); } } else { // Aggregate 0.9.x mode... // populate HashMap with form names and urls final Element formsElement = result.doc.getRootElement(); final int formsCount = formsElement.getChildCount(); for (int i = 0; i < formsCount; ++i) { if (formsElement.getType(i) != Node.ELEMENT) { // whitespace continue; } final Element child = formsElement.getElement(i); final String tag = child.getName(); String formId = null; if (tag.equals("formID")) { formId = XFormParser.getXMLText(child, true); if (formId != null && formId.length() == 0) { formId = null; } } if (tag.equalsIgnoreCase("form")) { String formName = XFormParser.getXMLText(child, true); if (formName != null && formName.length() == 0) { formName = null; } String downloadUrl = child.getAttributeValue(null, "url"); downloadUrl = downloadUrl.trim(); if (downloadUrl != null && downloadUrl.length() == 0) { downloadUrl = null; } if (downloadUrl == null || formName == null) { final String error = "Forms list entry " + Integer.toString(i) + " is missing form name or url attribute"; Log.e(t, "Parsing OpenRosa reply -- " + error); formList.clear(); formList.put(DL_ERROR_MSG, new FormDetails( MIntel.getInstance().getString(R.string.parse_legacy_formlist_failed, error))); return formList; } formList.put(formName, new FormDetails(formName, downloadUrl, null, formName)); } } } return formList; }
From source file:com.krawler.spring.hrms.common.hrmsCommonController.java
public ModelAndView getexEmployees(HttpServletRequest request, HttpServletResponse response) { JSONObject jobj = new JSONObject(); JSONObject jobj1 = new JSONObject(); KwlReturnObject result = null;//from ww w . j a v a 2 s . co m int count = 0; try { String Searchjson = request.getParameter("searchJson"); String appendCase = "and"; String companyid = sessionHandlerImplObj.getCompanyid(request); String lid = StringUtil.checkForNull(request.getParameter("lid")); HashMap<String, Object> requestParams = new HashMap<String, Object>(); ArrayList filter_names = new ArrayList( Arrays.asList("ua.user.company.companyID", "ua.user.deleteflag", "emp.termnd")); ArrayList filter_values = new ArrayList(Arrays.asList(companyid, 1, true)); requestParams.put("ss", StringUtil.checkForNull(request.getParameter("ss"))); requestParams.put("searchcol", new String[] { "u.firstName", "u.lastName", "ua.department.value", "ua.designationid.value", "ua.role.name", "u.emailID" }); requestParams.put("allflag", false); if (request.getParameter("combo") != null) { requestParams.put("combo", request.getParameter("combo")); } else { requestParams.put("combo", ""); } StringUtil.checkpaging(requestParams, request); SimpleDateFormat df = new SimpleDateFormat("yyyy/MM/dd"); if (!StringUtil.isNullOrEmpty(request.getParameter("startdate"))) { filter_names.add(">=emp.relievedate"); filter_values.add(new Date(df.format(new Date(request.getParameter("startdate"))))); filter_names.add("<=emp.relievedate"); filter_values.add(new Date(df.format(new Date(request.getParameter("enddate"))))); } if (!StringUtil.isNullOrEmpty(Searchjson)) { getMyAdvanceSearchparams(Searchjson, filter_names); insertParamAdvanceSearchString(filter_values, Searchjson); } requestParams.put("filter_names", filter_names); requestParams.put("filter_values", filter_values); result = hrmsCommonDAOObj.getUserDetailsHrms(requestParams); List list1 = result.getEntityList(); Iterator itr = list1.iterator(); JSONArray jArr = new JSONArray(); count = result.getRecordTotalCount(); while (itr.hasNext()) { Object[] row = (Object[]) itr.next(); JSONObject obj = new JSONObject(); Empprofile e = null; Useraccount ua = (Useraccount) kwlCommonTablesDAOObj .getObject("com.krawler.common.admin.Useraccount", row[0].toString()); User u = (User) ua.getUser(); e = (Empprofile) kwlCommonTablesDAOObj.getObject("com.krawler.hrms.ess.Empprofile", row[1].toString()); obj.put("department", (ua.getDepartment() == null ? "" : ua.getDepartment().getId())); obj.put("departmentname", (ua.getDepartment() == null ? "" : ua.getDepartment().getValue())); obj.put("userid", u.getUserID()); obj.put("fname", u.getFirstName()); obj.put("lname", u.getLastName()); obj.put("fullname", u.getFirstName() + " " + (u.getLastName() == null ? "" : u.getLastName())); obj.put("emailid", u.getEmailID()); obj.put("contactno", u.getContactNumber()); obj.put("designation", ua.getDesignationid() == null ? "" : ua.getDesignationid().getValue()); obj.put("designationid", ua.getDesignationid() == null ? "" : ua.getDesignationid().getId()); obj.put("salary", ua.getSalary()); requestParams.clear(); requestParams.put("companyid", sessionHandlerImplObj.getCompanyid(request)); requestParams.put("empid", ua.getEmployeeid()); obj.put("employeeid", ua.getEmployeeid() == null ? "" : profileHandlerDAOObj.getEmpidFormatEdit(requestParams).getEntityList().get(0)); obj.put("termdate", sessionHandlerImplObj.getDateFormatter(request).format(e.getRelievedate())); if (e.getTercause() != null) obj.put("termreason", e.getTercause().getValue()); else obj.put("termreason", ""); obj.put("termdesc", e.getTerReason()); if (e.getTerminatedby() != null) obj.put("termby", StringUtil.getFullName(e.getTerminatedby())); jArr.put(obj); } jobj.put("count", result.getRecordTotalCount()); jobj.put("data", jArr); jobj1.put("data", jobj); jobj1.put("valid", true); } catch (Exception e) { e.printStackTrace(); } finally { return new ModelAndView("jsonView", "model", jobj1.toString()); } }
From source file:base.BasePlayer.Main.java
static void search(String pos) { if (pos.equals("tati") || pos.equals("third")) { ReadNode read;//from w w w . ja v a2s . co m HashMap<String, String[]> chrs = new HashMap<String, String[]>(); HashMap<String, Integer> temp = new HashMap<String, Integer>(); for (int j = 0; j < drawCanvas.sampleList.get(0).getreadHash().get(drawCanvas.splits.get(0)).getReads() .size(); j++) { read = drawCanvas.sampleList.get(0).getreadHash().get(drawCanvas.splits.get(0)).getReads().get(j); while (read != null) { if (read.SA != null) { String[] SAs = read.SA.split(";"); temp.clear(); for (int i = 0; i < SAs.length; i++) { String[] sa = SAs[i].split(","); if (temp.containsKey(sa[0])) { continue; } else { temp.put(sa[0], 1); } if (!chrs.containsKey(sa[0])) { String[] add = { "1", sa[1] }; chrs.put(sa[0], add); } else { String[] add = chrs.get(sa[0]); String[] newString = { "" + (Integer.parseInt(add[0]) + 1), add[1] }; chrs.put(sa[0], newString); } } } read = read.getNext(); } } Iterator<Map.Entry<String, String[]>> it = chrs.entrySet().iterator(); String result = "Results for splitted reads:\n\n"; while (it.hasNext()) { Map.Entry<String, String[]> pair = it.next(); result += "chr" + pair.getKey() + ":" + MethodLibrary.formatNumber(Integer.parseInt(pair.getValue()[1])) + " = " + pair.getValue()[0] + "\n"; it.remove(); // avoids a ConcurrentModificationException } ErrorLog.addError(result); ErrorLog.frame.setLocation(frame.getLocationOnScreen().x + 10, frame.getLocationOnScreen().y + 10); ErrorLog.frame.setState(JFrame.NORMAL); ErrorLog.frame.setVisible(true); // JOptionPane.showMessageDialog(Main.chromDraw, result, "Tati's results", JOptionPane.INFORMATION_MESSAGE); read = null; return; } drawCanvas.scrollbar = false; // searchString = searchField.getText(); if (pos.toUpperCase().startsWith("S ") && pos.length() > 2) { for (int i = 0; i < Main.drawCanvas.sampleList.size(); i++) { if (Main.drawCanvas.sampleList.get(i).getName().toUpperCase() .contains(pos.toUpperCase().substring(2))) { drawCanvas.drawVariables.visiblestart = (short) i; drawCanvas.drawVariables.visiblesamples = (short) 1; drawCanvas.resizeCanvas(Main.frame.getWidth(), (int) (Main.samples * drawCanvas.drawVariables.sampleHeight)); Draw.setScrollbar((int) (i * drawCanvas.drawVariables.sampleHeight)); break; } } return; } // drawCanvas.clearReads(); if (pos.contains(";")) { searchList = pos.split(";"); for (int i = 0; i < searchList.length; i++) { returnlist = parseSearch(searchList[i]); if (returnlist != null) { if (i == 0) { FileRead.search = true; drawCanvas.gotoPos(returnlist[0], Integer.parseInt(returnlist[1]), Integer.parseInt(returnlist[2])); FileRead.search = false; } else { drawCanvas.addSplit(returnlist[0], Integer.parseInt(returnlist[1]), Integer.parseInt(returnlist[2])); } } } } else { try { returnlist = parseSearch(pos); if (returnlist != null) { if (undoPointer < undoList.size() - 1) { undoList.add(undoPointer + 1, searchField.getText()); if (undoPointer < undoList.size() - 1) { for (int i = undoPointer + 2; i < undoList.size(); i++) { undoList.remove(i); i--; } } } else { undoList.add(searchField.getText()); } undoPointer = undoList.size() - 1; forward.setEnabled(false); if (undoPointer > 0) { back.setEnabled(true); } FileRead.search = true; drawCanvas.gotoPos(returnlist[0], Integer.parseInt(returnlist[1]), Integer.parseInt(returnlist[2])); } } catch (Exception ex) { ex.printStackTrace(); } } }
From source file:SeedGenerator.MainForm.java
private void calculateIDF(int queryid, String objectName) { try {/*w ww . ja v a2s . c o m*/ try { PreparedStatement createtablepstmt = con.prepareStatement("CREATE TABLE `recommender_" + objectName + "_idf` (\n" + " `id` int(11) NOT NULL AUTO_INCREMENT,\n" + " `word` varchar(45) DEFAULT NULL,\n" + " `queryid` int(11) DEFAULT NULL,\n" + " `count` int(11) DEFAULT NULL,\n" + " `wordnetProcessed` int(11) DEFAULT NULL,\n" + " `wordnetHypernym` varchar(45) DEFAULT NULL,\n" + " PRIMARY KEY (`id`),\n" + " KEY `word` (`word`),\n" + " KEY `wordnetHypernym` (`wordnetHypernym`)\n" + ") ENGINE=InnoDB AUTO_INCREMENT=1695533 DEFAULT CHARSET=utf8;"); createtablepstmt.execute(); } catch (Exception ex) { } PreparedStatement pstmt = con.prepareStatement( "select s,p,o, endpointid from endpointtriples where queryid=? order by endpointid;"); pstmt.setInt(1, queryid); // //update recommender_comment_tf set idfid = (select id from recommender_comment_idf //where word = recommender_comment_tf.word limit 1) where id>0 and idfid is null limit 500000; // execute the query, and get a java resultset ResultSet rs = pstmt.executeQuery(); ; // iterate through the java resultset HashMap<String, Integer> wordCount = new HashMap(); HashMap<String, Integer> localwordCount = new HashMap(); int totalNumberOfWords = 0; int endpointid = 0; while (rs.next()) { int currentEndpointid = rs.getInt("endpointid"); String s = rs.getString("s"); String p = rs.getString("p"); String o = rs.getString("o"); if (endpointid != currentEndpointid) { localwordCount.clear(); endpointid = currentEndpointid; } if (o != null) { String words[] = o.split(" "); for (String word : words) { String cleanword; cleanword = word.replaceAll("[^\\p{L}\\p{Nd}]+", ""); if (!cleanword.equals("")) { if (!word.equals(cleanword)) { word = cleanword;//System.out.println(word+"--"+cleanword); } word = word.toLowerCase().replace("", "i"); if (wordCount.containsKey(word)) { if (!localwordCount.containsKey(word)) { wordCount.replace(word, wordCount.get(word) + 1); } } else { wordCount.put(word, 1); } if (!localwordCount.containsKey(word)) { localwordCount.put(word, 1); } totalNumberOfWords++; } else { // System.out.println("bos"); } } } //String firstName = rs.getString("url"); } pstmt.close(); rs.close(); Iterator it = wordCount.entrySet().iterator(); PreparedStatement insertpstmt = con.prepareStatement( "insert into recommender_" + objectName + "_idf (word,count,queryid) values(?,?,?);"); while (it.hasNext()) { Map.Entry pair = (Map.Entry) it.next(); //<> if (Integer.parseInt(pair.getValue().toString()) > 0) { if (pair.getKey().toString().length() > 44) { insertpstmt.setString(1, pair.getKey().toString().substring(0, 44)); } else { insertpstmt.setString(1, pair.getKey().toString()); } insertpstmt.setInt(2, Integer.parseInt(pair.getValue().toString())); insertpstmt.setInt(3, 24); insertpstmt.addBatch(); } it.remove(); // avoids a ConcurrentModificationException } // pstmt.close(); // rs.close(); // updatepstmt.executeBatch(); insertpstmt.executeBatch(); PreparedStatement s = con.prepareStatement( "SET SQL_SAFE_UPDATES = 0; " + "UPDATE recommender_" + objectName + "_tf as t, recommender_" + objectName + "_idf as i " + "SET t.idfid = i.id " + "where t.word=i.word;"); s.executeQuery(); } catch (Exception e) { //System.err.println("Got an exception! "); System.err.println(e.getMessage()); } }
From source file:com.krawler.spring.hrms.common.hrmsCommonController.java
public ModelAndView saveempprofile(HttpServletRequest request, HttpServletResponse reponse) { JSONObject msg = new JSONObject(); KwlReturnObject result;/* ww w. ja v a 2 s.c om*/ //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 { SimpleDateFormat fmt1 = new SimpleDateFormat("yyyy-MM-dd"); String currentuser = sessionHandlerImplObj.getUserid(request); String userid = request.getParameter("userid"); String jsondata = request.getParameter("jsondatawk"); String jsondata1 = request.getParameter("jsondatacad"); msg.put("msg", "Error in updating profile."); msg.put("success", false); HashMap<String, Object> requestParams = new HashMap<String, Object>(); requestParams.put("userid", userid); if (!StringUtil.isNullOrEmpty(request.getParameter("formname")) && request.getParameter("formname").equals("Personal")) { requestParams.put("middlename", request.getParameter("mname")); requestParams.put("bankbranch", request.getParameter("bankbranch")); requestParams.put("bankname", request.getParameter("bankname")); requestParams.put("bloodgrp", request.getParameter("bloodgrp")); if (!StringUtil.isNullOrEmpty(request.getParameter("childDoB1"))) { requestParams.put("child1dob", request.getParameter("childDoB1")); } requestParams.put("child1name", request.getParameter("child1name")); if (!StringUtil.isNullOrEmpty(request.getParameter("childDoB2"))) { requestParams.put("child2dob", request.getParameter("childDoB2")); } requestParams.put("child2name", request.getParameter("child2name")); if (!StringUtil.isNullOrEmpty(request.getParameter("DoB"))) { requestParams.put("dob", request.getParameter("DoB")); } requestParams.put("drvlicense", request.getParameter("drvlicense")); if (!StringUtil.isNullOrEmpty(request.getParameter("exppassport"))) { requestParams.put("exppassport", request.getParameter("exppassport")); } if (!StringUtil.isNullOrEmpty(request.getParameter("fatherDoB"))) { requestParams.put("fatherdob", request.getParameter("fatherDoB")); } requestParams.put("fathername", request.getParameter("fathername")); requestParams.put("gender", request.getParameter("gender")); requestParams.put("marriage", request.getParameter("marital")); if (!StringUtil.isNullOrEmpty(request.getParameter("motherDoB"))) { requestParams.put("motherdob", request.getParameter("motherDoB")); } requestParams.put("mothername", request.getParameter("mothername")); requestParams.put("panno", request.getParameter("panno")); requestParams.put("passportno", request.getParameter("passportno")); requestParams.put("pfno", request.getParameter("pfno")); if (!StringUtil.isNullOrEmpty(request.getParameter("spouseDoB"))) { requestParams.put("spousedob", request.getParameter("spouseDoB")); } requestParams.put("spousename", request.getParameter("spousename")); requestParams.put("keyskills", request.getParameter("keyskills")); requestParams.put("updated_by", currentuser); requestParams.put("updated_on", fmt1.format(new Date())); if (StringUtil.equal(userid, currentuser)) { requestParams.put("status", "Pending"); } else { requestParams.put("status", "Approved"); } result = hrmsCommonDAOObj.addEmpprofile(requestParams); if (result.isSuccessFlag()) { requestParams.clear(); requestParams.put("UserID", userid); requestParams.put("FirstName", request.getParameter("fname")); requestParams.put("LastName", request.getParameter("lname")); result = hrmsCommonDAOObj.adduser(requestParams); if (result.isSuccessFlag()) { requestParams.clear(); requestParams.put("UserID", userid); requestParams.put("Salary", request.getParameter("salarypermonth")); requestParams.put("Accno", request.getParameter("bankacc")); result = hrmsCommonDAOObj.addUseraccount(requestParams); requestParams.put("Useraccount", (Object) result.getEntityList().get(0)); if (result.getRecordTotalCount() > 0) hrmsCommonDAOObj.insertConfigData(request, "Personal", userid, sessionHandlerImplObj.getCompanyid(request), requestParams); else hrmsCommonDAOObj.insertConfigData(request, "Personal", userid, sessionHandlerImplObj.getCompanyid(request)); auditTrailDAOObj.insertAuditLog(AuditAction.PROFILE_EDITED, "User " + profileHandlerDAOObj .getUserFullName(sessionHandlerImplObj.getUserid(request)) + " has edited " + profileHandlerDAOObj.getUserFullName(userid) + "'s profile", request, "0"); msg.put("msg", "Profile updated successfully."); msg.put("success", true); } } } else if (!StringUtil.isNullOrEmpty(request.getParameter("formname")) && request.getParameter("formname").equals("Contact")) { requestParams.put("emgaddr", request.getParameter("emgaddr")); requestParams.put("emghome", request.getParameter("emghome")); requestParams.put("emgmob", request.getParameter("emgmob")); requestParams.put("emgname", request.getParameter("emgname")); requestParams.put("emgreln", request.getParameter("emgreln")); requestParams.put("emgwork", request.getParameter("emgwork")); requestParams.put("landno", request.getParameter("landno")); requestParams.put("mailaddr", request.getParameter("mailaddr")); requestParams.put("mobno", request.getParameter("mobno")); requestParams.put("permaddr", request.getParameter("permaddr")); requestParams.put("permcity", request.getParameter("permcity")); if (!StringUtil.isNullOrEmpty(request.getParameter("permcountry"))) { requestParams.put("permcountry", request.getParameter("permcountry")); } requestParams.put("permstate", request.getParameter("permstate")); requestParams.put("presentaddr", request.getParameter("presentaddr")); requestParams.put("presentcity", request.getParameter("presentcity")); if (!StringUtil.isNullOrEmpty(request.getParameter("presentcountry"))) { requestParams.put("presentcountry", request.getParameter("presentcountry")); } requestParams.put("presentstate", request.getParameter("presentstate")); requestParams.put("workno", request.getParameter("workno")); requestParams.put("workmail", request.getParameter("workmail")); requestParams.put("othermail", request.getParameter("othermail")); requestParams.put("weekoff", request.getParameter("weekoff")); requestParams.put("wkstarttime", request.getParameter("starttime")); requestParams.put("wkendtime", request.getParameter("endtime")); result = hrmsCommonDAOObj.addEmpprofile(requestParams); if (result.isSuccessFlag()) { requestParams.put("filter_names", Arrays.asList("userID")); requestParams.put("filter_values", Arrays.asList(userid)); result = hrmsCommonDAOObj.getUseraccount(requestParams); requestParams.put("Useraccount", (Object) result.getEntityList().get(0)); if (result.getRecordTotalCount() > 0) hrmsCommonDAOObj.insertConfigData(request, "Contact", userid, sessionHandlerImplObj.getCompanyid(request), requestParams); msg.put("msg", "Profile updated successfully."); msg.put("success", true); } } else if (!StringUtil.isNullOrEmpty(request.getParameter("formname")) && request.getParameter("formname").equals("Organizational")) { if (!StringUtil.isNullOrEmpty(request.getParameter("reportto"))) { requestParams.put("reportto", request.getParameter("reportto")); } requestParams.put("emptype", request.getParameter("emptype")); requestParams.put("commid", request.getParameter("commid")); requestParams.put("branchcode", request.getParameter("branchcode")); requestParams.put("branchaddr", request.getParameter("branchaddr")); requestParams.put("branchcity", request.getParameter("branchcity")); if (!StringUtil.isNullOrEmpty(request.getParameter("relievedate"))) { requestParams.put("relievedate", request.getParameter("relievedate")); } if (!StringUtil.isNullOrEmpty(request.getParameter("branchcountry"))) { requestParams.put("branchcountry", request.getParameter("branchcountry")); } if (!StringUtil.isNullOrEmpty(request.getParameter("probationmon")) && !StringUtil.isNullOrEmpty(request.getParameter("probationyr"))) { requestParams.put("probperiod", request.getParameter("probationmon") + "," + request.getParameter("probationyr")); } if (!StringUtil.isNullOrEmpty(request.getParameter("trainingmon")) && !StringUtil.isNullOrEmpty(request.getParameter("trainingyr"))) { requestParams.put("trainperiod", request.getParameter("trainingmon") + "," + request.getParameter("trainingyr")); } if (!StringUtil.isNullOrEmpty(request.getParameter("noticemon")) && !StringUtil.isNullOrEmpty(request.getParameter("noticeyr"))) { requestParams.put("noticeperiod", request.getParameter("noticemon") + "," + request.getParameter("noticeyr")); } if (!StringUtil.isNullOrEmpty(request.getParameter("confirmdate"))) { requestParams.put("confirmdate", request.getParameter("confirmdate")); } if (!StringUtil.isNullOrEmpty(request.getParameter("joindate"))) { requestParams.put("joindate", request.getParameter("joindate")); } result = hrmsCommonDAOObj.addEmpprofile(requestParams); Useraccount ua = (Useraccount) kwlCommonTablesDAOObj .getObject("com.krawler.common.admin.Useraccount", userid); int histsave = 0; Date saveDate = new Date(); SimpleDateFormat fmt = new SimpleDateFormat("yyyy/MM/dd"); saveDate = new Date(fmt.format(saveDate)); Emphistory ehst = new Emphistory(); String updatedby = sessionHandlerImplObj.getUserid(request); String histdept = ""; String histdesig = ""; requestParams.clear(); requestParams.put("UserID", userid); if (!StringUtil.isNullOrEmpty(request.getParameter("designationid"))) { if ((MasterData) kwlCommonTablesDAOObj.getObject("com.krawler.hrms.master.MasterData", (String) request.getParameter("designationid")) != ua.getDesignationid() && ua.getDesignationid() != null) { histdesig = ua.getDesignationid().getId(); histsave = 1; } requestParams.put("Designationid", request.getParameter("designationid")); } if (!StringUtil.isNullOrEmpty(request.getParameter("department"))) { if ((MasterData) kwlCommonTablesDAOObj.getObject("com.krawler.hrms.master.MasterData", (String) request.getParameter("department")) != ua.getDepartment() && ua.getDepartment() != null) { histdept = ua.getDepartment().getId(); if (histsave == 0) { histdesig = ua.getDesignationid().getId(); } histsave = 2; } requestParams.put("Department", request.getParameter("department")); } if (!StringUtil.isNullOrEmpty(request.getParameter("costcenter"))) { requestParams.put("CostCenter", request.getParameter("costcenter")); } String employeeIdFormat = ""; if (!StringUtil.isNullOrEmpty(request.getParameter("empid"))) { String[] codeid = (request.getParameter("empid")).split("-"); Integer codeid2 = null; for (int x = 0; x < codeid.length; x++) { if (codeid[x].matches("[0-9]*") == true) { codeid2 = Integer.parseInt(codeid[x]); } else { employeeIdFormat += (codeid[x] + "-"); } } if (employeeIdFormat.length() > 0) { employeeIdFormat = employeeIdFormat.substring(0, employeeIdFormat.length() - 1); } if (StringUtil.isNullOrEmpty(employeeIdFormat)) employeeIdFormat = null; HashMap<String, Object> requestParams1 = new HashMap<String, Object>(); ArrayList filter_names = new ArrayList(), filter_values = new ArrayList(); requestParams1.put("employeeIdFormat", employeeIdFormat); requestParams1.put("userID", userid); requestParams1.put("employeeid", codeid2); requestParams1.put("request", request); boolean isStadardEmpFormatWithIdAvilable = isStadardEmpFormatWithIdAvilable(requestParams1); String standardEmpId = getStadardEmpFormat(requestParams1); if (standardEmpId != null && employeeIdFormat != null && standardEmpId.equals(employeeIdFormat)) { employeeIdFormat = null; } requestParams1.clear(); filter_names.add("employeeid"); filter_values.add(codeid2); if (employeeIdFormat == null) { filter_names.add("IS employeeIdFormat"); } else { filter_names.add("employeeIdFormat"); filter_values.add(employeeIdFormat); } filter_names.add("!userID"); filter_values.add(userid); filter_names.add("user.company.companyID"); filter_values.add(sessionHandlerImplObj.getCompanyid(request)); requestParams1.put("filter_names", filter_names); requestParams1.put("filter_values", filter_values); result = hrmsCommonDAOObj.getUseraccount(requestParams1); if (!result.getEntityList().isEmpty() || isStadardEmpFormatWithIdAvilable) { msg.put("msg", "Employee ID is already assigned to another employee."); msg.put("success", false); txnManager.commit(status); return new ModelAndView(successView, "model", msg.toString()); } else { requestParams.put("Employeeid", codeid2); requestParams.put("EmployeeIdFormat", employeeIdFormat); } if (histsave == 1) { histdept = ua.getDepartment().getId(); } requestParams1.clear(); if (histsave == 1 || histsave == 2) { requestParams1.put("Department", histdept); requestParams1.put("Designation", histdesig); requestParams1.put("Userid", userid); requestParams1.put("Empid", ua.getEmployeeid()); requestParams1.put("Updatedon", saveDate); requestParams1.put("Updatedby", updatedby); requestParams1.put("Category", Emphistory.Emp_Desg_change); result = hrmsCommonDAOObj.addEmphistory(requestParams1); } result = hrmsCommonDAOObj.addUseraccount(requestParams); requestParams.put("Useraccount", (Object) result.getEntityList().get(0)); } if (result.getRecordTotalCount() > 0 && requestParams.get("Useraccount") != null) hrmsCommonDAOObj.insertConfigData(request, "Organizational", userid, sessionHandlerImplObj.getCompanyid(request), requestParams); else hrmsCommonDAOObj.insertConfigData(request, "Organizational", userid, sessionHandlerImplObj.getCompanyid(request)); msg.put("msg", "Profile updated successfully."); msg.put("success", true); } else { if (jsondata.length() > 0) { JSONArray jarr = new JSONArray("[" + jsondata + "]"); for (int i = 0; i < jarr.length(); i++) { Empexperience empexp = new Empexperience(); JSONObject jobj = jarr.getJSONObject(i); requestParams.clear(); if (!StringUtil.isNullOrEmpty(jobj.getString("id"))) { empexp.setId(jobj.getString("id")); } empexp.setUserid((UserLogin) kwlCommonTablesDAOObj .getObject("com.krawler.common.admin.UserLogin", userid)); empexp.setType(jobj.getString("type")); empexp.setOrganization(jobj.getString("organisation")); empexp.setPosition(jobj.getString("position")); empexp.setBeginyear(jobj.getString("beginyear")); empexp.setEndyear(jobj.getString("endyear")); empexp.setComment(jobj.getString("comment")); hrmsCommonDAOObj.addEmpExperience(empexp); } } if (jsondata1.length() > 0) { JSONArray jarr1 = new JSONArray("[" + jsondata1 + "]"); for (int j = 0; j < jarr1.length(); j++) { Empexperience empexp = new Empexperience(); JSONObject jobj = jarr1.getJSONObject(j); requestParams.clear(); if (!StringUtil.isNullOrEmpty(jobj.getString("id"))) { empexp.setId(jobj.getString("id")); } empexp.setUserid((UserLogin) kwlCommonTablesDAOObj .getObject("com.krawler.common.admin.UserLogin", userid)); empexp.setType(jobj.getString("type")); empexp.setQualification(jobj.getString("qualification")); empexp.setInstitution(jobj.getString("institution")); empexp.setYearofgrad(jobj.getString("gradyear")); empexp.setMarks(jobj.getString("marks")); empexp.setFrmyear(jobj.getString("yeargrdfrm")); empexp.setQaulin(jobj.getString("qualificationin")); hrmsCommonDAOObj.addEmpExperience(empexp); } } JSONObject jobj1 = new JSONObject(); jobj1.put("msg", "Profile updated successfully."); jobj1.put("success", true); msg.put("valid", true); msg.put("data", jobj1.toString()); } txnManager.commit(status); } catch (Exception e) { e.printStackTrace(); txnManager.rollback(status); } return new ModelAndView(successView, "model", msg.toString()); }