List of usage examples for java.lang StringBuffer substring
@Override public synchronized String substring(int start, int end)
From source file:org.egov.egf.web.actions.report.BillRegisterReportAction.java
private void getRemittancePaymentDetail(final BillRegisterReportBean billRegReport) { if (LOGGER.isDebugEnabled()) LOGGER.debug("...........Getting Remitance Payment details........"); List<EgRemittance> remittancePaymentItem = new ArrayList<EgRemittance>(); final StringBuffer remmitPaymentVoucherNumber = new StringBuffer(""); StringBuffer remittanceChequeNoAndDate = new StringBuffer(""); Long paymentVhId = null;//from w ww . j a v a 2 s . co m List<InstrumentVoucher> instrumentVoucherList = new ArrayList<InstrumentVoucher>(); if (billRegReport.getVoucherNumber() != null) { remittancePaymentItem = persistenceService.findAllBy(getRemiitPaymentVoucherQry.toString(), billRegReport.getVoucherNumber(), FinancialConstants.CANCELLEDVOUCHERSTATUS, FinancialConstants.CANCELLEDVOUCHERSTATUS); if (remittancePaymentItem.size() > 0) { paymentVhId = remittancePaymentItem.get(0).getVoucherheader().getId(); remittanceChequeNoAndDate = new StringBuffer(""); for (int i = 0; i < remittancePaymentItem.size(); i++) { // if(remittancePaymentItem.get(i).getVoucherheader().getStatus()) remmitPaymentVoucherNumber .append(remittancePaymentItem.get(i).getVoucherheader().getVoucherNumber() + "|"); final Query qry = persistenceService.getSession() .createQuery("from InstrumentVoucher iv where iv.voucherHeaderId.id=:vhId and" + " iv.instrumentHeaderId.statusId.id not in(:cancelledChequeList)"); qry.setLong("vhId", remittancePaymentItem.get(i).getVoucherheader().getId()); qry.setParameterList("cancelledChequeList", cancelledChequeStatus); instrumentVoucherList = qry.list(); if (instrumentVoucherList.size() > 0) for (final InstrumentVoucher inst : instrumentVoucherList) if (!StringUtils.isEmpty(remittanceChequeNoAndDate.toString())) { if (paymentVhId != null && paymentVhId.equals(inst.getVoucherHeaderId().getId())) remittanceChequeNoAndDate.append(chqdelimitSP) .append(inst.getInstrumentHeaderId().getInstrumentNumber()).append(" ") .append(inst.getInstrumentHeaderId().getInstrumentDate() != null ? DDMMYYYYFORMATS.format( inst.getInstrumentHeaderId().getInstrumentDate()) : ""); else remittanceChequeNoAndDate.append(chqdelimitDP) .append(inst.getInstrumentHeaderId().getInstrumentNumber()).append(" ") .append(inst.getInstrumentHeaderId().getInstrumentDate() != null ? DDMMYYYYFORMATS.format( inst.getInstrumentHeaderId().getInstrumentDate()) : ""); } else remittanceChequeNoAndDate.append(inst.getInstrumentHeaderId().getInstrumentNumber()) .append(" ").append( inst.getInstrumentHeaderId().getInstrumentDate() != null ? DDMMYYYYFORMATS.format( inst.getInstrumentHeaderId().getInstrumentDate()) : ""); paymentVhId = remittancePaymentItem.get(i).getVoucherheader().getId(); } } billRegReport.setRemittanceVoucherNumber(remmitPaymentVoucherNumber.length() > 0 ? remmitPaymentVoucherNumber.substring(0, remmitPaymentVoucherNumber.length() - 1) : " "); billRegReport.setRemittanceChequeNumberAndDate(remittanceChequeNoAndDate.toString()); } }
From source file:com.xn.interfacetest.service.impl.TestCaseServiceImpl.java
private String formatParams(TestCaseDto caseDto, String contentType, TestInterfaceDto interfaceDto) { //?,???,???//from w ww. j ava 2 s . c o m StringBuffer paramsStr = new StringBuffer(""); if (null != caseDto.getParamsType() && ParamsGroupTypeEnum.KEY.getId() == caseDto.getParamsType()) { //?? List<ParamDto> testParamsDtoList = testParamsService.listByCaseIdFromRelation(caseDto.getId()); if (contentType.equals("application/json")) { logger.info("??json" + testParamsDtoList.size() + "?"); //?json if (null != testParamsDtoList && testParamsDtoList.size() > 0) { JSONObject jsonObject = new JSONObject(); Iterator iterator = testParamsDtoList.iterator(); //---??? Date date = new Date(); while (iterator.hasNext()) { ParamDto param = (ParamDto) iterator.next(); logger.info("?" + param.toString()); String value = param.getValue(); //?? if (param.getFormatType() == ParamFormatTypeEnum.ENCRYPT.getId()) { //?,??? value = encrypt(interfaceDto.getJarPath(), interfaceDto, caseDto.getId(), param.getMethodName(), date); logger.info("????" + param.getName() + "," + value); } else if (value.equals("timestamp")) { // value = (date.getTime()) + ""; } jsonObject.put(param.getName(), value); } paramsStr = paramsStr.append(jsonObject.toString()); logger.info("??" + paramsStr); } } else { logger.info("??&?" + testParamsDtoList.size() + "?"); //? if (null != testParamsDtoList && testParamsDtoList.size() > 0) { Iterator iterator = testParamsDtoList.iterator(); //---??? Date date = new Date(); while (iterator.hasNext()) { ParamDto param = (ParamDto) iterator.next(); String value = param.getValue(); //?? if (param.getFormatType() == ParamFormatTypeEnum.ENCRYPT.getId()) { //?,??? value = encrypt(interfaceDto.getJarPath(), interfaceDto, caseDto.getId(), param.getMethodName(), date); logger.info("????" + param.getName() + "," + value); } else if (value.equals("timestamp")) { // value = (date.getTime()) + ""; } paramsStr.append(param.getName() + "=" + param.getValue()); paramsStr.append("&"); } paramsStr = new StringBuffer(paramsStr.substring(0, paramsStr.lastIndexOf("&"))); } } } else if (null != caseDto.getParamsType() && ParamsGroupTypeEnum.CUSTOM.getId() == caseDto.getParamsType()) { //?? logger.info("?" + caseDto.getCustomParams()); paramsStr = new StringBuffer(caseDto.getCustomParams()); } return paramsStr.toString(); }
From source file:com.topsec.tsm.sim.report.web.ReportController.java
/** * //w ww . ja v a 2s . c o m */ @RequestMapping("reportQuery") @SuppressWarnings("unchecked") public String reportQuery(SID sid, HttpServletRequest request, HttpServletResponse response) throws Exception { boolean fromRest = false; if (request.getParameter("fromRest") != null) { fromRest = Boolean.parseBoolean(request.getParameter("fromRest")); } JSONObject json = new JSONObject(); ReportBean bean = new ReportBean(); bean = ReportUiUtil.tidyFormBean(bean, request); String onlyByDvctype = request.getParameter("onlyByDvctype"); String[] talCategory = bean.getTalCategory(); ReportModel.setBeanPropery(bean); RptMasterTbService rptMasterTbImp = (RptMasterTbService) SpringContextServlet.springCtx .getBean(ReportUiConfig.MstBean); List<Map<String, Object>> subResult = rptMasterTbImp.queryTmpList(ReportUiConfig.MstSubSql, new Object[] { StringUtil.toInt(bean.getMstrptid(), StringUtil.toInt(bean.getTalTop(), 5)) }); StringBuffer layout = new StringBuffer(); Map<Integer, Integer> rowColumns = ReportModel.getRowColumns(subResult); Map<String, Object> params = new HashMap<String, Object>(); params.put("dvcType", bean.getDvctype()); params.put("talTop", bean.getTalTop()); params.put("mstId", bean.getMstrptid()); params.put("eTime", bean.getTalEndTime()); if ("Esm/Topsec/SimEvent".equals(bean.getDvctype()) || "Esm/Topsec/SystemLog".equals(bean.getDvctype()) || "Esm/Topsec/SystemRunLog".equals(bean.getDvctype()) || "Log/Global/Detail".equals(bean.getDvctype())) { onlyByDvctype = "onlyByDvctype"; } String sUrl = null; List<SimDatasource> simDatasources = dataSourceService.getDataSourceByDvcType(bean.getDvctype()); removeRepeatDs(simDatasources); Set<AuthUserDevice> devices = ObjectUtils.nvl(sid.getUserDevice(), Collections.<AuthUserDevice>emptySet()); List<SimDatasource> dslist = new ArrayList<SimDatasource>(); if (sid.isOperator()) { SimDatasource dsource = new SimDatasource(); dsource.setDeviceIp(""); dsource.setSecurityObjectType(bean.getDvctype()); dsource.setAuditorNodeId(""); dslist.add(0, dsource); dslist.addAll(simDatasources); } else { BeanToPropertyValueTransformer trans = new BeanToPropertyValueTransformer("ip"); Collection<String> userDeviceIPs = (Collection<String>) CollectionUtils.collect(devices, trans); for (SimDatasource simDatasource : simDatasources) { if (userDeviceIPs.contains(simDatasource.getDeviceIp())) { dslist.add(simDatasource); } } } int screenWidth = StringUtil.toInt(request.getParameter("screenWidth"), 1280) - 25 - 200; boolean flag = "onlyByDvctype".equals(onlyByDvctype); SimDatasource selectDataSource = getSelectDataSource(dslist, bean, flag, request); AssetObject assetObject = null == selectDataSource ? null : AssetFacade.getInstance().getAssetByIp(selectDataSource.getDeviceIp()); if (fromRest) { json.put("selectDataSourceId", selectDataSource == null ? 0 : selectDataSource.getResourceId()); json.put("selectDataSourceName", selectDataSource == null ? "" : assetObject.getName()); } request.setAttribute("selectDataSourceId", selectDataSource == null ? 0 : selectDataSource.getResourceId()); request.setAttribute("selectDataSourceName", selectDataSource == null ? "" : assetObject.getName()); StringBuffer subUrl = new StringBuffer(); Map layoutValue = new HashMap(); for (int i = 0, len = subResult.size(); i < len; i++) { params.remove("sTime"); Map subMap = subResult.get(i); if (i == 0) { bean.setViewItem(StringUtil.toString(subMap.get("viewItem"), "")); } Integer row = (Integer) subMap.get("subRow"); layout.append(row + ":" + subMap.get("subColumn") + ","); if (GlobalUtil.isNullOrEmpty(subMap)) { continue; } boolean qushi = StringUtil.booleanVal(subMap.get("chartProperty")); String tableSql = StringUtil.nvl((String) subMap.get("tableSql")); String subName = StringUtil.nvl((String) subMap.get("subName")); String mstName = StringUtil.nvl((String) subMap.get("mstName")); String pageSql = StringUtil.nvl((String) subMap.get("pagesql")); String chartSql = StringUtil.nvl((String) subMap.get("chartSql")); String nowTime = ReportUiUtil.getNowTime(ReportUiConfig.dFormat1); String talEndTime = bean.getTalEndTime(); if (qushi && (subName.contains("") || subName.contains("") || subName.contains("") || subName.contains("") || mstName.contains("") || mstName.contains("") || mstName.contains("") || mstName.contains(""))) { bean.setTalEndTime(nowTime); params.put("eTime", bean.getTalEndTime()); if (tableSql.indexOf("Hour") > 20 || tableSql.indexOf("_hour") > 20) { params.put("sTime", ReportUiUtil.toStartTime("hour", bean.getTalEndTime())); } else if (tableSql.indexOf("Day") > 20 || tableSql.indexOf("_day") > 20) { params.put("sTime", ReportUiUtil.toStartTime("day", bean.getTalEndTime())); } else if (tableSql.indexOf("Month") > 20 || tableSql.indexOf("_month") > 20) { params.put("sTime", ReportUiUtil.toStartTime("month", bean.getTalEndTime())); } else if (pageSql.indexOf("Hour") > 20 || pageSql.indexOf("_hour") > 20 || chartSql.indexOf("Hour") > 20) { params.put("sTime", ReportUiUtil.toStartTime("hour", bean.getTalEndTime())); } else if (pageSql.indexOf("Day") > 20 || pageSql.indexOf("_day") > 20 || chartSql.indexOf("Day") > 20) { params.put("sTime", ReportUiUtil.toStartTime("day", bean.getTalEndTime())); } else if (pageSql.indexOf("Month") > 20 || pageSql.indexOf("_month") > 20 || chartSql.indexOf("Month") > 20) { params.put("sTime", ReportUiUtil.toStartTime("month", bean.getTalEndTime())); } else { params.put("sTime", bean.getTalStartTime()); } } else if (subName.indexOf("") > 1) { bean.setTalEndTime(nowTime); params.put("eTime", bean.getTalEndTime()); if (tableSql.indexOf("Hour") > 20 || tableSql.indexOf("_hour") > 20) { params.put("sTime", ReportUiUtil.toStartTime("undefined", bean.getTalEndTime())); } else { params.put("sTime", bean.getTalStartTime()); } String startTime = params.get("sTime").toString(); String endTime = params.get("eTime").toString(); subName = subName + " " + startTime.substring(5) + " - " + endTime.substring(10) + "";//endTime.substring(10,endTime.length()-4)+"0:00"; subMap.put("subName", subName); } else { params.put("sTime", bean.getTalStartTime()); } bean.setTalEndTime(talEndTime); sUrl = getUrl(ReportUiConfig.subUrl, request, params, bean.getTalCategory()).toString(); subUrl.replace(0, subUrl.length(), sUrl); subUrl.append("&").append(ReportUiConfig.subrptid).append("=").append(subMap.get("subId")); subUrl.substring(0, subUrl.length()); int column = rowColumns.get(row); String width = String.valueOf((screenWidth - 10 * column) / column); String _column = subMap.get("subColumn").toString(); layoutValue.put(row + _column, ReportUiUtil.createSubTitle(subMap, width, subUrl.toString(), bean.getTalCategory(), StringUtil.toInt(bean.getTalTop(), 5))); } if (talCategory != null) { if (fromRest) json.put("superiorUrl", getSuperiorUrl(request, params, bean.getTalCategory()).toString()); request.setAttribute("superiorUrl", getSuperiorUrl(request, params, bean.getTalCategory()).toString()); } if (!GlobalUtil.isNullOrEmpty(subResult) && subResult.size() > 0) { if (!GlobalUtil.isNullOrEmpty(subResult.get(0).get("mstName"))) { if (fromRest) { json.put("title", subResult.get(0).get("mstName")); } request.setAttribute("title", subResult.get(0).get("mstName")); } } String htmlLayout = ReportModel.createMstTable(layout.toString(), layoutValue); StringBuffer sb = getExportUrl(request, params, talCategory); request.setAttribute("expUrl", sb.toString()); request.setAttribute("layout", htmlLayout); request.setAttribute("bean", bean); request.setAttribute("dslist", dslist); if (fromRest) { json.put("expUrl", sb.toString()); json.put("layout", htmlLayout); json.put("bean", JSONObject.toJSON(bean)); json.put("dslist", JSONObject.toJSON(dslist)); return json.toString(); } return "/page/report/base_report_detail"; }
From source file:org.etudes.mneme.impl.AttachmentServiceImpl.java
/** * Iterates through all question types, captures responses and creates export summary spreadsheet * @param workbook Workbook object//w w w.ja v a 2 s .co m * @param assessment Assessment object * @return Spreadsheet with Export summary */ HSSFSheet createResponsesSheet(HSSFWorkbook workbook, Assessment assessment) { boolean isSurvey; if (assessment.getType() == AssessmentType.survey) isSurvey = true; else isSurvey = false; Map<String, Integer> userRowMap = new HashMap(); HSSFSheet sheet = workbook.createSheet("Submission responses"); HSSFRow headerRow = sheet.createRow((short) 0); AssessmentParts part = assessment.getParts(); List<Part> parts = part.getParts(); if (parts == null || parts.size() == 0) return null; List<Question> questions = new ArrayList(); for (Iterator partIt = parts.iterator(); partIt.hasNext();) { Part partObj = (Part) partIt.next(); List<Question> questionsUsed = partObj.getQuestionsUsed(); questions.addAll(questionsUsed); } HSSFCellStyle style = workbook.createCellStyle(); HSSFFont font = workbook.createFont(); font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); style.setFont(font); // Printing header row and question text if (!isSurvey) { HSSFCell cell0 = headerRow.createCell((short) (0)); cell0.setCellStyle(style); cell0.setCellValue(this.messages.getFormattedMessage("export_lastname", null)); HSSFCell cell1 = headerRow.createCell((short) (1)); cell1.setCellStyle(style); cell1.setCellValue(this.messages.getFormattedMessage("export_firstname", null)); HSSFCell cell2 = headerRow.createCell((short) (2)); cell2.setCellStyle(style); cell2.setCellValue(this.messages.getFormattedMessage("export_username", null)); HSSFCell cell3 = headerRow.createCell((short) (3)); cell3.setCellStyle(style); cell3.setCellValue(this.messages.getFormattedMessage("export_score", null)); } else { HSSFCell cell0 = headerRow.createCell((short) (0)); cell0.setCellStyle(style); cell0.setCellValue(this.messages.getFormattedMessage("export_user", null)); } int i; if (isSurvey) i = 1; else i = 4; for (Iterator it = questions.iterator(); it.hasNext();) { Question q = (Question) it.next(); String quest_desc = null; TypeSpecificQuestion tsq = q.getTypeSpecificQuestion(); if (tsq instanceof FillBlanksQuestionImpl) { quest_desc = stripHtml(((FillBlanksQuestionImpl) tsq).getText()); } else { if (tsq instanceof EssayQuestionImpl || tsq instanceof TaskQuestionImpl) { if (tsq instanceof EssayQuestionImpl) { EssayQuestionImpl eqi = (EssayQuestionImpl) tsq; if (eqi.getSubmissionType() == SubmissionType.inline) quest_desc = stripHtml(q.getDescription()); } if (tsq instanceof TaskQuestionImpl) { TaskQuestionImpl tqi = (TaskQuestionImpl) tsq; if (tqi.getSubmissionType() == SubmissionType.inline) quest_desc = stripHtml(q.getDescription()); } } else { quest_desc = stripHtml(q.getDescription()); } } if (quest_desc != null) { HSSFCell cell = headerRow.createCell((short) (i++)); cell.setCellStyle(style); cell.setCellValue(quest_desc); } } int j; if (isSurvey) j = 1; else j = 4; boolean answersExist = false; for (Iterator it = questions.iterator(); it.hasNext();) { Question q = (Question) it.next(); TypeSpecificQuestion tsq = q.getTypeSpecificQuestion(); //Only captures inline submissions for essays and tasks if (tsq instanceof EssayQuestionImpl || tsq instanceof TaskQuestionImpl) { if (tsq instanceof EssayQuestionImpl) { EssayQuestionImpl eqi = (EssayQuestionImpl) tsq; if (eqi.getSubmissionType() != SubmissionType.inline) { continue; } } if (tsq instanceof TaskQuestionImpl) { TaskQuestionImpl tqi = (TaskQuestionImpl) tsq; if (tqi.getSubmissionType() != SubmissionType.inline) { continue; } } } List<Answer> answers = this.submissionService.findSubmissionAnswers(assessment, q, Boolean.TRUE, FindAssessmentSubmissionsSort.userName_a, null, null); if (answers == null || answers.size() == 0) continue; else answersExist = true; for (Answer answer : answers) { HSSFRow row; try { String userId = answer.getSubmission().getUserId(); String subId = answer.getSubmission().getId(); if (userRowMap == null || userRowMap.size() == 0 || (userRowMap.get(userId + subId) == null)) { int rowNum = sheet.getLastRowNum() + 1; row = sheet.createRow(rowNum); if (!isSurvey) { User user = this.userDirectoryService.getUser(userId); row.createCell((short) 0).setCellValue(user.getLastName()); row.createCell((short) 1).setCellValue(user.getFirstName()); row.createCell((short) 2).setCellValue(user.getDisplayId()); row.createCell((short) 3).setCellValue( roundTwoDecimals(answer.getSubmission().getTotalScore().floatValue())); } else { row.createCell((short) 0) .setCellValue(this.messages.getFormattedMessage("export_user", null)); } userRowMap.put(userId + subId, new Integer(rowNum)); } else { row = sheet.getRow(userRowMap.get(userId + subId).intValue()); } TypeSpecificAnswer a = answer.getTypeSpecificAnswer(); if (a instanceof EssayAnswerImpl) { EssayAnswerImpl essay = (EssayAnswerImpl) a; row.createCell((short) j).setCellValue(stripHtml(essay.getAnswerData())); } if (a instanceof TrueFalseAnswerImpl) { TrueFalseAnswerImpl tf = (TrueFalseAnswerImpl) a; if (!isSurvey && tf.getCompletelyCorrect().booleanValue()) row.createCell((short) j).setCellValue("*" + tf.getAnswer() + "*"); else row.createCell((short) j).setCellValue(tf.getAnswer()); } if (a instanceof MultipleChoiceAnswerImpl) { MultipleChoiceAnswerImpl mc = (MultipleChoiceAnswerImpl) a; List<MultipleChoiceQuestionImpl.MultipleChoiceQuestionChoice> choiceList = ((MultipleChoiceQuestionImpl) mc .getAnswerObject().getQuestion().getTypeSpecificQuestion()).getChoicesAsAuthored(); String[] ansArray = mc.getAnswers(); String[] choiceArray = new String[mc.getAnswers().length]; Set<Integer> correctAnswers = ((MultipleChoiceQuestionImpl) mc.getAnswerObject() .getQuestion().getTypeSpecificQuestion()).getCorrectAnswerSet(); int l = 0; for (Iterator chIt = choiceList.iterator(); chIt.hasNext();) { MultipleChoiceQuestionImpl.MultipleChoiceQuestionChoice mq = (MultipleChoiceQuestionImpl.MultipleChoiceQuestionChoice) chIt .next(); if (Arrays.asList(ansArray).contains(mq.getId())) { if (!isSurvey && correctAnswers.contains(Integer.parseInt(mq.getId()))) { choiceArray[l] = "*" + stripHtml(mq.getText().trim()) + "*"; } else { choiceArray[l] = stripHtml(mq.getText().trim()); } l++; } } row.createCell((short) j).setCellValue(getCommaAnswers(choiceArray)); } if (a instanceof FillBlanksAnswerImpl) { FillBlanksAnswerImpl fb = (FillBlanksAnswerImpl) a; row.createCell((short) j).setCellValue(stripHtml(getCommaAnswers(checkCorrectFill(fb)))); } if (a instanceof LikertScaleAnswerImpl) { LikertScaleAnswerImpl ls = (LikertScaleAnswerImpl) a; LikertScaleQuestionImpl lsq = (LikertScaleQuestionImpl) ls.getAnswerObject().getQuestion() .getTypeSpecificQuestion(); List<LikertScaleQuestionImpl.LikertScaleQuestionChoice> choiceList = lsq.getChoices(); for (Iterator chIt = choiceList.iterator(); chIt.hasNext();) { LikertScaleQuestionImpl.LikertScaleQuestionChoice lqc = (LikertScaleQuestionImpl.LikertScaleQuestionChoice) chIt .next(); if (lqc.getId().equals(ls.getAnswer())) { row.createCell((short) j).setCellValue(stripHtml(lqc.getText())); break; } } } if (a instanceof MatchAnswerImpl) { MatchAnswerImpl ma = (MatchAnswerImpl) a; Map matchMap = (LinkedHashMap) ma.getAnswer(); Iterator it2 = matchMap.entrySet().iterator(); StringBuffer matchStrBuf = new StringBuffer(); List choiceList = ((MatchQuestionImpl) ma.getAnswerObject().getQuestion() .getTypeSpecificQuestion()).getPairsForDelivery(); while (it2.hasNext()) { Map.Entry entry = (Map.Entry) it2.next(); String key = (String) entry.getKey(); String value = (String) ((Value) entry.getValue()).getValue(); String matchVal = fetchName(choiceList, key, true); boolean correctMatch = checkCorrectMatch(choiceList, key, value); if (!isSurvey && correctMatch) matchStrBuf.append("*"); matchStrBuf.append(stripHtml(matchVal.trim())); matchStrBuf.append("->"); String choiceVal = fetchName(choiceList, value, false); if (choiceVal == null) matchStrBuf.append(this.messages.getFormattedMessage("nosel_made", null)); else matchStrBuf.append(stripHtml(choiceVal.trim())); if (!isSurvey && correctMatch) matchStrBuf.append("*"); matchStrBuf.append(", "); } if (matchStrBuf.length() > 0 && matchStrBuf.charAt(matchStrBuf.length() - 2) == ',') { String matchStrBufTrim = matchStrBuf.substring(0, matchStrBuf.length() - 2); row.createCell((short) j).setCellValue(stripHtml(matchStrBufTrim)); } } if (a instanceof TaskAnswerImpl) { TaskAnswerImpl ta = (TaskAnswerImpl) a; row.createCell((short) j).setCellValue(stripHtml(ta.getAnswerData())); } } catch (UserNotDefinedException e) { M_log.warn("createResponsesSheet: " + e.toString()); } } j = j + 1; } if (!answersExist) return null; return sheet; }
From source file:org.etudes.component.app.melete.ModuleDB.java
public void deleteModules(List delModules, List allModules, String courseId, String userId) throws Exception { long starttime = System.currentTimeMillis(); Transaction tx = null;//from www .jav a 2 s. c om //If not all modules of the course need to be deleted if (delModules.size() != allModules.size()) { logger.debug("delete some Modules begin"); ArrayList<DelModuleInfo> DelModuleInfoList = new ArrayList<DelModuleInfo>(0); List delResourcesList; try { // Get resources for modules that need to be deleted delResourcesList = getActiveResourcesFromList(delModules); allModules.removeAll(delModules); if ((delResourcesList != null) && (delResourcesList.size() > 0)) { List<String> allActiveResources = getActiveResourcesFromList(allModules); if (allActiveResources != null && delResourcesList != null) { logger.debug("active list and all" + delResourcesList.size() + " ; " + allActiveResources.size()); delResourcesList.removeAll(allActiveResources); } } // get all module-ids and section_ids // update seq_no for each deleted_module StringBuffer allModuleIds = new StringBuffer("("); StringBuffer allSectionIds = new StringBuffer("("); ArrayList<StringBuffer> allSectionIdsArray = new ArrayList<StringBuffer>(); String delModuleIds = null; //String delSectionIds = null; int count = 1; for (Iterator dmIter = delModules.iterator(); dmIter.hasNext();) { Module dm = (Module) dmIter.next(); allModuleIds.append(dm.getModuleId().toString() + ","); Map delSections = dm.getSections(); if (delSections != null && !delSections.isEmpty()) { for (Iterator i = delSections.keySet().iterator(); i.hasNext();) { if (count % MAX_IN_CLAUSES == 0) { allSectionIds.append(i.next() + ")"); allSectionIdsArray.add(allSectionIds); allSectionIds = new StringBuffer("("); } else { allSectionIds.append(i.next() + ","); } count++; } } Map delDeletedSections = dm.getDeletedSections(); if (delDeletedSections != null && !delDeletedSections.isEmpty()) { for (Iterator i1 = delDeletedSections.keySet().iterator(); i1.hasNext();) { if (count % MAX_IN_CLAUSES == 0) { allSectionIds.append(i1.next() + ")"); allSectionIdsArray.add(allSectionIds); allSectionIds = new StringBuffer("("); } else { allSectionIds.append(i1.next() + ","); } count++; } } // record seq_no and id DelModuleInfoList .add(new DelModuleInfo(dm.getModuleId().toString(), dm.getCoursemodule().getSeqNo())); } if (allModuleIds.lastIndexOf(",") != -1) delModuleIds = allModuleIds.substring(0, allModuleIds.lastIndexOf(",")) + " )"; //if (allSectionIds.lastIndexOf(",") != -1) delSectionIds = allSectionIds.substring(0, allSectionIds.lastIndexOf(",")) + " )"; if (allSectionIds.lastIndexOf(",") != -1) { if (count % MAX_IN_CLAUSES != 0) { allSectionIds.replace(allSectionIds.lastIndexOf(","), allSectionIds.lastIndexOf(",") + 1, ")"); allSectionIdsArray.add(allSectionIds); } } Session session = hibernateUtil.currentSession(); tx = session.beginTransaction(); String delMeleteResourceStr; int deletedEntities; // delete modules and sections String updSectionResourceStr = "update SectionResource sr set sr.resource = null where sr.section in "; String delSectionResourceStr = "delete SectionResource sr where sr.section in "; String delBookmarksStr = "delete Bookmark bm where bm.sectionId in "; String delSectionStr = "delete Section s where s.moduleId in " + delModuleIds; String delCourseModuleStr = "delete CourseModule cm where cm.moduleId in " + delModuleIds; String delModuleshDatesStr = "delete ModuleShdates msh where msh.moduleId in " + delModuleIds; String delSpecialAccStr = "delete SpecialAccess sa where sa.moduleId in " + delModuleIds; String delModuleStr = "delete Module m where m.moduleId in " + delModuleIds; if (allSectionIdsArray != null) { for (int i = 0; i < allSectionIdsArray.size(); i++) { allSectionIds = allSectionIdsArray.get(i); deletedEntities = session.createQuery(updSectionResourceStr + allSectionIds.toString()) .executeUpdate(); deletedEntities = session.createQuery(delSectionResourceStr + allSectionIds.toString()) .executeUpdate(); logger.debug("section resource deleted" + deletedEntities); deletedEntities = session.createQuery(delBookmarksStr + allSectionIds.toString()) .executeUpdate(); logger.debug("Boomkarks deleted " + deletedEntities); } } if (delModuleIds != null) { deletedEntities = session.createQuery(delSectionStr).executeUpdate(); logger.debug("section deleted" + deletedEntities); deletedEntities = session.createQuery(delCourseModuleStr).executeUpdate(); logger.debug("course module deleted" + deletedEntities); deletedEntities = session.createQuery(delModuleshDatesStr).executeUpdate(); deletedEntities = session.createQuery(delSpecialAccStr).executeUpdate(); logger.debug("special access deleted" + deletedEntities); deletedEntities = session.createQuery(delModuleStr).executeUpdate(); logger.debug("module deleted" + deletedEntities); } // delete module collection logger.debug("updating seq_number now"); List<CourseModule> courseModules = new ArrayList<CourseModule>(0); for (ListIterator i = allModules.listIterator(); i.hasNext();) { Module mdbean = (Module) i.next(); courseModules.add((CourseModule) mdbean.getCoursemodule()); } assignSeqs(session, courseModules); // delete resources if ((delResourcesList != null) && (delResourcesList.size() > 0)) { StringBuffer delResourceIds = new StringBuffer("("); // delete melete resource and from content resource for (Iterator delIter = delResourcesList.listIterator(); delIter.hasNext();) { String delResourceId = (String) delIter.next(); if ((delResourceId == null) || (delResourceId.trim().length() == 0)) { logger.warn("NULL or empty resource id found in delete process "); continue; } delResourceIds.append("'" + delResourceId + "',"); } //Ensuring that there are no empty resource ids if ((delResourceIds.length() > 4) && (delResourceIds.lastIndexOf(",") != -1)) { delResourceIds = new StringBuffer( delResourceIds.substring(0, delResourceIds.lastIndexOf(",")) + " )"); delMeleteResourceStr = "delete MeleteResource mr where mr.resourceId in " + delResourceIds; deletedEntities = session.createQuery(delMeleteResourceStr).executeUpdate(); logger.debug("melete resource deleted" + deletedEntities); } } tx.commit(); } catch (HibernateException he) { if (tx != null) tx.rollback(); logger.error(he.toString()); throw he; } catch (Exception e) { if (tx != null) tx.rollback(); logger.error(e.toString()); e.printStackTrace(); throw e; } finally { try { hibernateUtil.closeSession(); } catch (HibernateException he) { logger.error(he.toString()); throw he; } } logger.debug("Successfully cleared Melete tables"); logger.debug("Removing module collections now"); Collections.reverse(DelModuleInfoList); for (DelModuleInfo dmi : DelModuleInfoList) { meleteCHService.removeCollection(courseId, "module_" + dmi.getId()); } logger.debug("Removing upload collection resources"); for (Iterator delIter = delResourcesList.listIterator(); delIter.hasNext();) { String delResourceId = (String) delIter.next(); if ((delResourceId == null) || (delResourceId.trim().length() == 0)) { logger.warn("NULL or empty resource id found in delete process "); continue; } //TypeEditor sections will have been removed already if (delResourceId.startsWith("/private/meleteDocs/" + courseId + "/uploads/")) { meleteCHService.removeResource(delResourceId); } } long endtime = System.currentTimeMillis(); logger.debug("delete some modules ends " + (endtime - starttime)); } else { logger.debug("delete all Modules begin"); try { Session session = hibernateUtil.currentSession(); tx = session.beginTransaction(); StringBuffer allModuleIds = new StringBuffer("("); String delModuleIds = null; for (Iterator dmIter = delModules.iterator(); dmIter.hasNext();) { Module dm = (Module) dmIter.next(); allModuleIds.append(dm.getModuleId().toString() + ","); } if (allModuleIds.lastIndexOf(",") != -1) delModuleIds = allModuleIds.substring(0, allModuleIds.lastIndexOf(",")) + " )"; deleteEverything(courseId, session, delModuleIds); //remove entire collection try { meleteCHService.removeCollection(courseId, null); } catch (Exception removeColl) { //do nothing } tx.commit(); } catch (HibernateException he) { if (tx != null) tx.rollback(); logger.error(he.toString()); throw he; } catch (Exception e) { if (tx != null) tx.rollback(); logger.error(e.toString()); e.printStackTrace(); throw e; } finally { try { hibernateUtil.closeSession(); } catch (HibernateException he) { logger.error(he.toString()); throw he; } } long endtime = System.currentTimeMillis(); logger.debug("delete all modules ends " + (endtime - starttime)); } }
From source file:org.ecoinformatics.datamanager.database.DelimitedReader.java
private String[] processQuoteCharacterOneRowData(String oneRowData) throws Exception { String[] elements = null;// www. ja v a 2 s . c o m Vector elementsVector = new Vector(); if (oneRowData == null) { return elements; } quoteCharacter = transferQuoteCharacter(quoteCharacter); char quote = '#'; boolean quoted = false; if (quoteCharacter != null) { quoted = true; quote = quoteCharacter.charAt(0); } char literal = '/'; boolean literaled = false; if (literalCharacter != null) { literaled = true; literal = literalCharacter.charAt(0); } if (literaled && literalCharacter.length() != 1) { throw new Exception("Literal Character length should be 1 character in EML"); } char currentChar = '2'; StringBuffer fieldData = new StringBuffer(); int length = oneRowData.length(); int priviousDelimiterIndex = -2; int currentDelimiterIndex = -2; int delimiterLength = delimiter.length(); boolean startQuote = false; boolean delimiterAtEnd = false; //this string buffer is only for deleting if hit a delimiter StringBuffer delimiterStorage = new StringBuffer(delimiter.length()); for (int i = 0; i < length; i++) { currentChar = oneRowData.charAt(i); //System.out.println("current char is "+currentChar); fieldData.append(currentChar); if (i < delimiterLength) { delimiterStorage.append(currentChar); } else { //delimiterStorage.deleteCharAt(position); delimiterStorage = shiftBuffer(delimiterStorage, currentChar); } //System.out.println("current delimiter storage content is "+delimiterStorage.toString()); //System.out.println("currnet value in the string buffer is "+fieldData.toString()); // we should check if there is quoteCharacter in the string. if (quoted && currentChar == quote) { char previousChar = '1'; boolean escapingQuote = false; // check if this quote is escaped if (literaled) { if ((i - 1) >= 0) { previousChar = oneRowData.charAt(i - 1); if (previousChar == literal) { escapingQuote = true; // delette the literal character if (!includeLiteralCharacter) { //if we don't want literal character in the data, //we should delete literal character. int fieldLength = fieldData.length(); if ((fieldLength - 1 - 1) >= 0) { fieldData.deleteCharAt(fieldLength - 1 - 1); } } } } } if (!escapingQuote) { if (!startQuote) { //System.out.println("start quote"); startQuote = true; } else { //System.out.println("end quote"); // at end of quote //put string buffers value into vector and reset string buffer startQuote = false; } } } //found a delimiter if (delimiterStorage.indexOf(delimiter) != -1 && !startQuote) { //check if there is literal character before the delimiter, //if does, this we should skip this delmiter int indexOfCharBeforeDelimiter = i - delimiterLength; boolean escapeDelimiter = false; if (literaled && indexOfCharBeforeDelimiter >= 0) { char charBeforeDelimiter = oneRowData.charAt(indexOfCharBeforeDelimiter); ////there is a literal character before delimiter we should skip this demlimiter if (charBeforeDelimiter == literal) { if (!includeLiteralCharacter) { //if we don't want literal character in the data, //we should delete literal character. int fieldLength = fieldData.length(); if ((fieldLength - delimiterLength - 1) >= 0) { fieldData.deleteCharAt(fieldLength - delimiterLength - 1); } } escapeDelimiter = true; continue; } } // check if the delimiter is in the end of the string if (i == (length - 1) && !startQuote && !escapeDelimiter) { delimiterAtEnd = true; } ////here we should treat sequential delimiter as single delimiter if (collapseDelimiters) { priviousDelimiterIndex = currentDelimiterIndex; currentDelimiterIndex = i; //there is nothing between two delimiter, should skip it. if ((currentDelimiterIndex - priviousDelimiterIndex) == delimiterLength) { //delete sequnced delimiter fieldData = new StringBuffer(); continue; } } String value = ""; int delimiterIndex = fieldData.lastIndexOf(delimiter); if (delimiterIndex == 0) { //this path means field data on has delimiter, no real data value = ""; } else { value = fieldData.substring(0, delimiterIndex); } elementsVector.add(value); //reset string buffer fieldData fieldData = new StringBuffer(); } } // if startQuote is true at the end, which means there is no close quote character in this row, // code should throw an exception if (startQuote) { throw new Exception("There is a un-closed quote in data file"); } // add last field. If this string end of delimiter, we need add a "" // else, we need to add the value in string buffer. String lastFieldValue = null; if (delimiterAtEnd == true) { //this path means field data on has delimiter, no real data lastFieldValue = ""; } else { lastFieldValue = fieldData.toString(); } elementsVector.add(lastFieldValue); //transform vector to string array int size = elementsVector.size(); elements = new String[size]; for (int i = 0; i < size; i++) { elements[i] = (String) elementsVector.elementAt(i); } return elements; }
From source file:com.pari.nm.utils.db.ReportDBHelper.java
public static void createTempTableForPagination(TableDefinition tableDef, String reportId, String sessionId, ArrayList<String> childColNamesList) throws Exception { Connection c = null;// w ww . j a v a 2 s . c o m Statement st = null; int result = -1; int childResult = -1; StringBuffer sb = new StringBuffer(); StringBuilder childTblCreateQuery = new StringBuilder(); String childTblName = null; String tblName = getTempPaginationTblName(reportId, sessionId); if (tblName == null) { throw new Exception("No Table Exist with ReportId:\t" + reportId + "and SessionId:\t" + sessionId); } System.out.println("Temporary Report Table Name:\t" + tblName); sb.append("CREATE TABLE \t" + tblName + " \t ("); ColumnDefinition[] colDefs = tableDef.getColumnDefs(); try { if (colDefs != null) { for (ColumnDefinition colDef : colDefs) { String identifier = colDef.getId(); identifier = identifier.replace(' ', '_'); String columnName = getRenderColumnName(identifier, tableDef); identifier = (null == columnName) ? identifier : columnName; if (identifier.equals("RowId")) { // ProfileRunSummary Report contains RowId, which is conflicting with Oracle RowId, so // appended // RowId with 123 sb.append(identifier + "123" + "\tvarchar2(4000),"); } else if (identifier.equals("User")) { // Unmanaged Device Report contains User, which is conflicting with Oracle User, so appended // User with 123 sb.append(identifier + "123" + "\tvarchar2(4000),"); } else if (identifier.equalsIgnoreCase("Comment")) { // Pending Approvals Report contains Comment, which is conflicting with Oracle Reserved Word // Comment, so appended // Comment with 123 sb.append(identifier + "123" + "\tvarchar2(4000),"); } else if (identifier.equals("Size")) { // Manage script repository export contains size, which is conflicting with Oracle reserved // word, and this column changed to 'size123' sb.append(identifier + "123" + "\tvarchar2(4000),"); } else if (identifier.toLowerCase().equals("timestamp")) { // Manage script repository export contains size, which is conflicting with Oracle reserved // word, and this column changed to 'size123' sb.append(identifier + "123" + "\tvarchar2(4000),"); } else if (identifier.toLowerCase().equals("violationdetails")) { // Manage script repository export contains size, which is conflicting with Oracle reserved // word, and this column changed to 'size123' sb.append(identifier + "\tBlob,"); } else { if (identifier.toLowerCase().equals("hostname") || identifier.toLowerCase().equals("ipaddress")) { continue; } sb.append(identifier + "\tvarchar2(4000),"); } } sb.append("hostname\tvarchar2(4000),"); sb.append("ipaddress\tvarchar2(4000),"); TableDefinition[] childDefArr = tableDef.getChildTables(); if (childDefArr != null && childDefArr.length > 0) { for (TableDefinition def : childDefArr) { String defName = def.getId(); sb.append(defName + "\tvarchar2(4000),"); // For Hierarchical Reports we need to create a child table // table name like reportId_sessionId_defName manipulationTempPaginationTable(reportId, sessionId, defName, null); childTblName = getTempPaginationTblName(reportId, sessionId, defName); logger.info("ChildTableName:\t" + childTblName); if (childTblName == null) { throw new Exception("No Table Exist with ReportId:\t" + reportId + "and SessionId:\t" + sessionId + "and ChildTableIdentifier:\t" + defName); } // childTblName = reportId+"_"+sessionId+"_"+defName; logger.info("ChildTableName:\t" + childTblName); childTblCreateQuery.append("CREATE TABLE \t" + childTblName + " \t ("); ColumnDefinition[] childAttrDescArr = def.getColumnDefs(); if (childAttrDescArr != null) { /* * for (AttributeDescriptor childAttrDesc : childAttrDescArr) { * logger.info("childAttrDesc.getIdentifier()====\t" + childAttrDesc.getIdentifier()); * childTblCreateQuery.append(childAttrDesc.getIdentifier() + "\tvarchar2(4000),"); } */ for (String colName : childColNamesList) { childTblCreateQuery.append(colName + "\tvarchar2(4000),"); } childTblCreateQuery.toString(); String childTblStr = childTblCreateQuery.substring(0, childTblCreateQuery.length() - 1); childTblCreateQuery = new StringBuilder(); childTblCreateQuery.append(childTblStr); childTblCreateQuery.append(")"); logger.info("create child table in stringbuilder format is----" + childTblCreateQuery.toString()); } } } // sb.append("PAGINATION_PK" + "\t NUMBER,"); String tempStr = sb.substring(0, sb.length() - 1); sb = new StringBuffer(); sb.append(tempStr); sb.append(")"); logger.info("create table in stringbuffer format is----" + sb.toString()); c = DBHelper.getConnection(); if (c == null) { logger.error("Unable to Obtain Connection to create Temporary Pagination Table."); return; } try { st = c.createStatement(); } catch (SQLException e) { logger.info("Exception Occured while Creating Statement to create Temporary Pagination Table.", e); return; } try { result = st.executeUpdate(sb.toString()); } catch (SQLException e) { logger.info("Exception Occured while executing the Query to Create Temporary Pagination Table.", e); return; } if (result > 0) { logger.info("Table:" + tblName + "\t Created Successfully."); } try { childResult = st.executeUpdate(childTblCreateQuery.toString()); } catch (SQLException e) { logger.info( "Exception Occured while executing the Child Table Query to Create Temporary Pagination Table.", e); return; } if (childResult > 0) { logger.info("Table:" + childTblName + "\t Created Successfully."); } } } finally { ReportUtil.closeAll(c, st, null); } }
From source file:com.pari.nm.utils.db.ReportDBHelper.java
public static void createTempPaginationTable(ServiceDescriptor descriptor, TableDefinition tableDef, String reportId, String sessionId, ArrayList<String> childColNamesList) throws SQLException { Connection c = null;/*from www . j a v a 2 s . c om*/ Statement st = null; int result = -1; int childResult = -1; try { if (descriptor == null) { throw new Exception("Unable to get ServiceDescriptor for ReportId:\t" + reportId + "\t SessionId:\t" + sessionId); } if (descriptor.getIdentifier().equals("extended_device_attributes_report")) { createTempTableForPagination(tableDef, reportId, sessionId, childColNamesList); } else { StringBuffer sb = new StringBuffer(); StringBuilder childTblCreateQuery = new StringBuilder(); String childTblName = null; String tblName = getTempPaginationTblName(reportId, sessionId); if (tblName == null) { throw new Exception( "No Table Exist with ReportId:\t" + reportId + "and SessionId:\t" + sessionId); } System.out.println("Temporary Report Table Name:\t" + tblName); sb.append("CREATE TABLE \t" + tblName + " \t ("); AttributeDescriptor[] attrDescArr = descriptor.getAllAttributeDescriptors(); if (attrDescArr != null) { for (AttributeDescriptor attrDesc : attrDescArr) { String identifier = attrDesc.getIdentifier(); identifier = identifier.replace(' ', '_'); String columnName = getRenderColumnName(identifier, tableDef); identifier = (null == columnName) ? identifier : columnName; logger.info("attrDesc.getIdentifier()====\t" + attrDesc.getIdentifier()); if (identifier.equals("RowId")) { // ProfileRunSummary Report contains RowId, which is conflicting with Oracle RowId, so // appended // RowId with 123 sb.append(identifier + "123" + "\tvarchar2(4000),"); } else if (identifier.equals("User")) { // Unmanaged Device Report contains User, which is conflicting with Oracle User, so appended // User with 123 sb.append(identifier + "123" + "\tvarchar2(4000),"); } else if (identifier.equalsIgnoreCase("Comment")) { // Pending Approvals Report contains Comment, which is conflicting with Oracle Reserved Word // Comment, so appended // Comment with 123 sb.append(identifier + "123" + "\tvarchar2(4000),"); } else if (identifier.equals("Size")) { // Manage script repository export contains size, which is conflicting with Oracle reserved // word, and this column changed to 'size123' sb.append(identifier + "123" + "\tvarchar2(4000),"); } else if (identifier.toLowerCase().equals("timestamp")) { // Manage script repository export contains size, which is conflicting with Oracle reserved // word, and this column changed to 'size123' sb.append(identifier + "123" + "\tvarchar2(4000),"); } else if (identifier.toLowerCase().equals("violationdetails")) { // Manage script repository export contains size, which is conflicting with Oracle reserved // word, and this column changed to 'size123' sb.append(identifier + "\tBlob,"); } else { sb.append(identifier + "\tvarchar2(4000),"); } } Def[] childDefArr = descriptor.getAllChildRefs(); List<StringBuffer> childBufferList = new ArrayList<>(); if (childDefArr != null && childDefArr.length > 0) { for (Def def : childDefArr) { String defName = def.getName(); sb.append(defName + "\tvarchar2(4000),"); // For Hierarchical Reports we need to create a child table // table name like reportId_sessionId_defName manipulationTempPaginationTable(reportId, sessionId, defName, null); childTblName = getTempPaginationTblName(reportId, sessionId, defName); logger.info("ChildTableName:\t" + childTblName); if (childTblName == null) { throw new Exception("No Table Exist with ReportId:\t" + reportId + "and SessionId:\t" + sessionId + "and ChildTableIdentifier:\t" + defName); } // childTblName = reportId+"_"+sessionId+"_"+defName; logger.info("ChildTableName:\t" + childTblName); // childTblCreateQuery.append("CREATE TABLE \t" + childTblName + " \t ("); // childTblCreateQuery.append("PAGINATION_PK" + "\t NUMBER,"); ServiceDescriptor childServiceDesc = descriptor .getContainedServiceDescriptorByName(defName); if (childServiceDesc != null) { AttributeDescriptor[] childAttrDescArr = childServiceDesc .getAllAttributeDescriptors(); if (childAttrDescArr != null) { /* * for (AttributeDescriptor childAttrDesc : childAttrDescArr) { * logger.info("childAttrDesc.getIdentifier()====\t" + * childAttrDesc.getIdentifier()); * childTblCreateQuery.append(childAttrDesc.getIdentifier() + "\tvarchar2(4000),"); * } */ // for (String colName : childColNamesList) // { // childTblCreateQuery.append(colName + "\tvarchar2(4000),"); // } // // childTblCreateQuery.toString(); // String childTblStr = childTblCreateQuery.substring(0, // childTblCreateQuery.length() - 1); // childTblCreateQuery = new StringBuilder(); // childTblCreateQuery.append(childTblStr); // childTblCreateQuery.append(")"); // logger.info("create child table in stringbuilder format is----" // + childTblCreateQuery.toString()); StringBuffer childBuffer = new StringBuffer(); childBuffer.append("CREATE TABLE " + childTblName + " ("); // Multiple children was not considered in previous implementation. Now this is // addressed and // child table for each child entry in table definition will be created. Using child // table // column ids instead of childColNamesList which was used earlier. TableDefinition childTable = tableDef.getChildTableById(defName); ColumnDefinition[] columnDefs = childTable.getColumnDefs(); for (ColumnDefinition columnDef : columnDefs) { childBuffer.append(columnDef.getId() + " varchar2(4000),"); } childBuffer.deleteCharAt(childBuffer.length() - 1); childBuffer.append(")"); logger.info("[CREATE-PAGINATION-TEMP-TABLE] Create Child Table format is " + String.valueOf(childBuffer)); childBufferList.add(childBuffer); } } } } // sb.append("PAGINATION_PK" + "\t NUMBER,"); String tempStr = sb.substring(0, sb.length() - 1); sb = new StringBuffer(); sb.append(tempStr); sb.append(")"); logger.info("create table in stringbuffer format is----" + sb.toString()); c = DBHelper.getConnection(); if (c == null) { logger.error("Unable to Obtain Connection to create Temporary Pagination Table."); return; } try { st = c.createStatement(); } catch (SQLException e) { logger.info( "Exception Occured while Creating Statement to create Temporary Pagination Table.", e); return; } try { result = st.executeUpdate(sb.toString()); } catch (SQLException e) { logger.info( "Exception Occured while executing the Query to Create Temporary Pagination Table.", e); return; } if (result > 0) { logger.info("Table:" + tblName + "\t Created Successfully."); } // try // { // childResult = st.executeUpdate(childTblCreateQuery.toString()); // } // catch (SQLException e) // { // logger.info( // "Exception Occured while executing the Child Table Query to Create Temporary Pagination Table.", // e); // return; // } if (childBufferList.size() > 0) { for (StringBuffer childBuffer : childBufferList) { if (0 != childBuffer.length()) { try { result = st.executeUpdate(childBuffer.toString()); logger.info(result <= 2 ? "[CREATE-PAGINATION-TEMP-TABLE] Child Table '" + childTblName + "' created successfully." : "[CREATE-PAGINATION-TEMP-TABLE] Failed to cretae child table '" + childTblName + "'."); } catch (SQLException e) { logger.info( "Exception Occured while executing the Child Table Query to Create Temporary Pagination Table.", e); return; } } } } if (childResult > 0) { logger.info("Table:" + childTblName + "\t Created Successfully."); } } } } catch (Exception e) { logger.error("Exception Occured while Creating Temporary Pagination Table.", e); return; } finally { if (st != null) { st.close(); } DBHelper.releaseConnection(c); } }