List of usage examples for java.lang StringBuffer deleteCharAt
@Override public synchronized StringBuffer deleteCharAt(int index)
From source file:org.kuali.ole.service.impl.OLEEResourceSearchServiceImpl.java
public void getAcquisitionInfoFromPOAndInvoice(String holdingsId, WorkEInstanceOlemlForm workEInstanceOlemlForm) { Map map = new HashMap(); map.put(OLEConstants.INSTANCE_ID, holdingsId); List<OleCopy> oleCopyList = (List) getBusinessObjectService().findMatching(OleCopy.class, map); StringBuffer linkedPos = new StringBuffer(); StringBuffer vendor = new StringBuffer(); StringBuffer orderType = new StringBuffer(); StringBuffer orderFormat = new StringBuffer(); StringBuffer fundCode = new StringBuffer(); List fundCodeList = new ArrayList(); List<PurApAccountingLine> accountingLines = new ArrayList<>(); KualiDecimal currentFYCost = new KualiDecimal(0); for (OleCopy oleCopy : oleCopyList) { if (oleCopy.getPoItemId() != null) { map.clear();//from w w w .j a va2 s .com map.put(OLEConstants.OLEEResourceRecord.PO_ITEM_ID, oleCopy.getPoItemId().toString()); OlePurchaseOrderItem olePurchaseOrderItem = getBusinessObjectService() .findByPrimaryKey(OlePurchaseOrderItem.class, map); if (olePurchaseOrderItem != null) { // vendor, current FY cost & order type map.clear(); map.put(OLEConstants.DOC_NUM, olePurchaseOrderItem.getDocumentNumber()); OlePurchaseOrderDocument olePurchaseOrderDocument = getBusinessObjectService() .findByPrimaryKey(OlePurchaseOrderDocument.class, map); if (olePurchaseOrderDocument != null) { // po linkedPos.append(olePurchaseOrderDocument.getPurapDocumentIdentifier()); linkedPos.append(OLEConstants.COMMA); linkedPos.append(' '); Integer poCreatedYear = olePurchaseOrderDocument.getPostingYear(); Integer currentYear = Calendar.getInstance().get(Calendar.YEAR); if (currentYear.compareTo(poCreatedYear) == 0) { currentFYCost = currentFYCost.add(olePurchaseOrderItem.getItemInvoicedTotalAmount()); } vendor.append(olePurchaseOrderDocument.getVendorName()); vendor.append(OLEConstants.COMMA); vendor.append(' '); map.clear(); map.put(OLEConstants.PURCHASE_ORDER_TYPE_ID, olePurchaseOrderDocument.getPurchaseOrderTypeId()); Collection<PurchaseOrderType> purchaseOrderTypeDocumentList = getBusinessObjectService() .findMatching(PurchaseOrderType.class, map); if (purchaseOrderTypeDocumentList != null && purchaseOrderTypeDocumentList.size() > 0) { PurchaseOrderType purchaseOrderTypeDoc = purchaseOrderTypeDocumentList.iterator() .next(); orderType.append(purchaseOrderTypeDoc.getPurchaseOrderType()); orderType.append(OLEConstants.SEMI_COLON); orderType.append(' '); } } // payment status & Fund code map.clear(); map.put(OLEConstants.OLEEResourceRecord.INV_PO_ITEM_ID, olePurchaseOrderItem.getItemIdentifier()); List<OleInvoiceItem> oleInvoiceItems = (List<OleInvoiceItem>) getBusinessObjectService() .findMatching(OleInvoiceItem.class, map); if (oleInvoiceItems != null && oleInvoiceItems.size() > 0) { for (OleInvoiceItem oleInvoiceItem : oleInvoiceItems) { map.put(OLEConstants.OLEEResourceRecord.INV_PO_ITEM_ID, oleInvoiceItem.getItemIdentifier()); OlePaymentRequestItem olePaymentRequestItem = getBusinessObjectService() .findByPrimaryKey(OlePaymentRequestItem.class, map); if (olePaymentRequestItem != null) { workEInstanceOlemlForm.getExtendedEHoldingFields() .setPaymentStatus(OLEConstants.PAID); break; } } for (OleInvoiceItem oleInvoiceItem : oleInvoiceItems) { List purApAccountingLines = oleInvoiceItem.getSourceAccountingLines(); if (purApAccountingLines != null && purApAccountingLines.size() > 0) { accountingLines.addAll(purApAccountingLines); } } } // order format if (olePurchaseOrderItem.getFormatTypeId() != null) { map.clear(); map.put(OLEConstants.FORMAT_TYPE_ID, olePurchaseOrderItem.getFormatTypeId()); OleFormatType oleFormatType = getBusinessObjectService() .findByPrimaryKey(OleFormatType.class, map); if (oleFormatType != null) { orderFormat.append(oleFormatType.getFormatTypeName()); orderFormat.append(OLEConstants.COMMA); orderFormat.append(' '); } } } } } if (linkedPos.length() > 0) { if (vendor.length() > 0) { vendor.deleteCharAt(vendor.length() - 2); workEInstanceOlemlForm.getExtendedEHoldingFields().setVendorName(vendor.toString()); } if (orderType.length() > 0) { orderType.deleteCharAt(orderType.length() - 2); workEInstanceOlemlForm.getExtendedEHoldingFields().setOrderType(orderType.toString()); } if (orderFormat.length() > 0) { orderFormat.deleteCharAt(orderFormat.length() - 2); workEInstanceOlemlForm.getExtendedEHoldingFields().setOrderFormat(orderFormat.toString()); } String pos[] = linkedPos.toString().split(","); Set set = new HashSet(); for (String po : pos) { set.add(po.trim()); } pos = (String[]) set.toArray(new String[0]); StringBuffer poLink = new StringBuffer(); for (String po : pos) { String link = null; if (StringUtils.isNotBlank(po)) { Map poMap = new HashMap(); poMap.put(org.kuali.ole.sys.OLEConstants.PUR_DOC_IDENTIFIER, po.trim()); List<OlePurchaseOrderDocument> olePurchaseOrderDocumentList = (List) getBusinessObjectService() .findMatching(OlePurchaseOrderDocument.class, poMap); if (olePurchaseOrderDocumentList != null && olePurchaseOrderDocumentList.size() > 0) { for (OlePurchaseOrderDocument olePurchaseOrderDocument : olePurchaseOrderDocumentList) { boolean validPO = olePurchaseOrderDocumentList != null ? olePurchaseOrderDocument.getPurchaseOrderCurrentIndicatorForSearching() : false; if (validPO) { link = ConfigContext.getCurrentContextConfig().getProperty("kew.url") + org.kuali.ole.sys.OLEConstants.PO_LINE_ITEM_URL + olePurchaseOrderDocument.getDocumentNumber(); poLink.append("<a href=" + link + " target='_blank'>" + po.trim() + "</a>, "); } } } } } if (poLink.length() > 0) { poLink.deleteCharAt(poLink.length() - 2); workEInstanceOlemlForm.getExtendedEHoldingFields().setPurchaseOrderId(poLink.toString()); } workEInstanceOlemlForm.getExtendedEHoldingFields().setCurrentFYCost(currentFYCost.toString()); if (org.apache.commons.lang.StringUtils .isBlank(workEInstanceOlemlForm.getExtendedEHoldingFields().getPaymentStatus())) { workEInstanceOlemlForm.getExtendedEHoldingFields().setPaymentStatus(OLEConstants.NOT_PAID); } if (accountingLines.size() > 0) { for (PurApAccountingLine accountingLine : accountingLines) { map.clear(); map.put(OLEConstants.ACCOUNT_NUMBER, accountingLine.getAccountNumber()); map.put(OLEConstants.OBJECT_CODE, accountingLine.getFinancialObjectCode()); OleVendorAccountInfo oleVendorAccountInfo = getBusinessObjectService() .findByPrimaryKey(OleVendorAccountInfo.class, map); if (oleVendorAccountInfo != null && !fundCodeList.contains(oleVendorAccountInfo.getVendorRefNumber())) { fundCodeList.add(oleVendorAccountInfo.getVendorRefNumber()); fundCode.append(oleVendorAccountInfo.getVendorRefNumber()); fundCode.append(OLEConstants.COMMA); fundCode.append(' '); } } } if (fundCode.length() > 0) { fundCode.deleteCharAt(fundCode.length() - 2); workEInstanceOlemlForm.getExtendedEHoldingFields().setFundCode(fundCode.toString()); } } }
From source file:com.jd.survey.service.util.SPSSHelperService.java
public byte[] getSurveyDefinitionSPSSData(Long surveyDefinitionId) { try {//from www .j ava 2s . c om String columnName; StringBuffer dataStringBuffer = new StringBuffer(); SurveyDefinition surveyDefinition = surveyDefinitionDAO.findById(surveyDefinitionId); List<Map<String, Object>> surveys = reportDAO.getSurveyData(surveyDefinitionId); for (Map<String, Object> record : surveys) { //dataStringBuffer.append(record.get("survey_id") == null ? "" : "\"" + record.get("survey_id").toString().replace("\"", "\"\"") +"\"," ); //dataStringBuffer.append(record.get("type_name") == null ? "" : "\"" + record.get("type_name").toString().replace("\"", "\"\"") +"\"," ); //dataStringBuffer.append(record.get("login") == null ? "" : "\"" + record.get("login").toString().replace("\"", "\"\"") +"\"," ); //dataStringBuffer.append(record.get("submission_date") == null ? "" : "\"" + record.get("creation_date").toString().replace("\"", "\"\"") +"\"," ); //dataStringBuffer.append(record.get("creation_date") == null ? "" : "\"" + record.get("last_update_date").toString().replace("\"", "\"\"") +"\"," ); //dataStringBuffer.append(record.get("last_update_date") == null ? "" : "\"" + record.get("last_update_date").toString().replace("\"", "\"\"") +"\"," ); for (SurveyDefinitionPage page : surveyDefinition.getPages()) { for (Question question : page.getQuestions()) { switch (question.getType()) { case YES_NO_DROPDOWN: //Yes No DropDown columnName = "p" + page.getOrder() + "q" + question.getOrder(); dataStringBuffer.append(record.get(columnName) == null ? "," : "\"" + ((Boolean) record.get(columnName) ? "1" : "0") + "\","); break; case SHORT_TEXT_INPUT: //Short Text Input columnName = "p" + page.getOrder() + "q" + question.getOrder(); dataStringBuffer.append(record.get(columnName) == null ? "," : "\"" + record.get(columnName).toString().replace("\"", "\"\"") + "\","); break; case LONG_TEXT_INPUT: //Long Text Input columnName = "p" + page.getOrder() + "q" + question.getOrder(); dataStringBuffer.append(record.get(columnName) == null ? "," : "\"" + record.get(columnName).toString().replace("\"", "\"\"") + "\","); break; case HUGE_TEXT_INPUT: //Huge Text Input columnName = "p" + page.getOrder() + "q" + question.getOrder(); dataStringBuffer.append(record.get(columnName) == null ? "," : "\"" + record.get(columnName).toString().replace("\"", "\"\"") + "\","); break; case INTEGER_INPUT: //Integer Input columnName = "p" + page.getOrder() + "q" + question.getOrder(); dataStringBuffer.append(record.get(columnName) == null ? "," : "\"" + record.get(columnName).toString().replace("\"", "\"\"") + "\","); break; case CURRENCY_INPUT: //Currency Input columnName = "p" + page.getOrder() + "q" + question.getOrder(); dataStringBuffer.append(record.get(columnName) == null ? "," : "\"" + record.get(columnName).toString().replace("\"", "\"\"") + "\","); break; case DECIMAL_INPUT: //Decimal Input columnName = "p" + page.getOrder() + "q" + question.getOrder(); dataStringBuffer.append(record.get(columnName) == null ? "," : "\"" + record.get(columnName).toString().replace("\"", "\"\"") + "\","); break; case DATE_INPUT: //Date Input columnName = "p" + page.getOrder() + "q" + question.getOrder(); dataStringBuffer.append(record.get(columnName) == null ? "," : "\"" + record.get(columnName).toString().replace("\"", "\"\"") + "\","); break; case SINGLE_CHOICE_DROP_DOWN: //Single choice Drop Down columnName = "p" + page.getOrder() + "q" + question.getOrder(); dataStringBuffer.append(record.get(columnName) == null ? "," : "\"" + record.get(columnName).toString().replace("\"", "\"\"") + "\","); break; case MULTIPLE_CHOICE_CHECKBOXES: //Multiple Choice Checkboxes columnName = "p" + page.getOrder() + "q" + question.getOrder(); for (QuestionOption option : question.getOptions()) { if (record.get(columnName) != null && option.getValue().equals(record.get(columnName).toString())) { dataStringBuffer.append("1,"); } else { dataStringBuffer.append("0,"); } } break; case DATASET_DROP_DOWN: //DataSet Drop Down columnName = "p" + page.getOrder() + "q" + question.getOrder(); dataStringBuffer.append(record.get(columnName) == null ? "," : "\"" + record.get(columnName).toString().replace("\"", "\"\"") + "\","); break; case SINGLE_CHOICE_RADIO_BUTTONS: //Single Choice Radio Buttons columnName = "p" + page.getOrder() + "q" + question.getOrder(); dataStringBuffer.append(record.get(columnName) == null ? "," : "\"" + record.get(columnName).toString().replace("\"", "\"\"") + "\","); break; case YES_NO_DROPDOWN_MATRIX: for (QuestionRowLabel questionRowLabel : question.getRowLabels()) { for (QuestionColumnLabel questionColumnLabel : question.getColumnLabels()) { columnName = "p" + page.getOrder() + "q" + question.getOrder() + "r" + questionRowLabel.getOrder() + "c" + questionColumnLabel.getOrder(); dataStringBuffer.append(record.get(columnName) == null ? "0," : "\"" + ((Boolean) record.get(columnName) ? "1" : "0") + "\","); } } break; case SHORT_TEXT_INPUT_MATRIX: for (QuestionRowLabel questionRowLabel : question.getRowLabels()) { for (QuestionColumnLabel questionColumnLabel : question.getColumnLabels()) { columnName = "p" + page.getOrder() + "q" + question.getOrder() + "r" + questionRowLabel.getOrder() + "c" + questionColumnLabel.getOrder(); dataStringBuffer.append(record.get(columnName) == null ? "," : "\"" + record.get(columnName).toString().replace("\"", "\"\"") + "\","); } } break; case INTEGER_INPUT_MATRIX: for (QuestionRowLabel questionRowLabel : question.getRowLabels()) { for (QuestionColumnLabel questionColumnLabel : question.getColumnLabels()) { columnName = "p" + page.getOrder() + "q" + question.getOrder() + "r" + questionRowLabel.getOrder() + "c" + questionColumnLabel.getOrder(); dataStringBuffer.append(record.get(columnName) == null ? "," : "\"" + record.get(columnName).toString().replace("\"", "\"\"") + "\","); } } break; case CURRENCY_INPUT_MATRIX: for (QuestionRowLabel questionRowLabel : question.getRowLabels()) { for (QuestionColumnLabel questionColumnLabel : question.getColumnLabels()) { columnName = "p" + page.getOrder() + "q" + question.getOrder() + "r" + questionRowLabel.getOrder() + "c" + questionColumnLabel.getOrder(); dataStringBuffer.append(record.get(columnName) == null ? "," : "\"" + record.get(columnName).toString().replace("\"", "\"\"") + "\","); } } break; case DECIMAL_INPUT_MATRIX: for (QuestionRowLabel questionRowLabel : question.getRowLabels()) { for (QuestionColumnLabel questionColumnLabel : question.getColumnLabels()) { columnName = "p" + page.getOrder() + "q" + question.getOrder() + "r" + questionRowLabel.getOrder() + "c" + questionColumnLabel.getOrder(); dataStringBuffer.append(record.get(columnName) == null ? "," : "\"" + record.get(columnName).toString().replace("\"", "\"\"") + "\","); } } break; case DATE_INPUT_MATRIX: for (QuestionRowLabel questionRowLabel : question.getRowLabels()) { for (QuestionColumnLabel questionColumnLabel : question.getColumnLabels()) { columnName = "p" + page.getOrder() + "q" + question.getOrder() + "r" + questionRowLabel.getOrder() + "c" + questionColumnLabel.getOrder(); dataStringBuffer.append(record.get(columnName) == null ? "," : "\"" + record.get(columnName).toString().replace("\"", "\"\"") + "\","); } } break; case IMAGE_DISPLAY: break; case VIDEO_DISPLAY: break; case FILE_UPLOAD: break; case STAR_RATING: columnName = "p" + page.getOrder() + "q" + question.getOrder(); dataStringBuffer.append(record.get(columnName) == null ? "," : "\"" + record.get(columnName).toString().replace("\"", "\"\"") + "\","); break; case SMILEY_FACES_RATING: columnName = "p" + page.getOrder() + "q" + question.getOrder(); dataStringBuffer.append(record.get(columnName) == null ? "," : "\"" + record.get(columnName).toString().replace("\"", "\"\"") + "\","); break; } } } dataStringBuffer.deleteCharAt(dataStringBuffer.length() - 1); //delete the last comma dataStringBuffer.append("\n"); } return dataStringBuffer.toString().getBytes("UTF-8"); } catch (Exception e) { log.error(e.getMessage(), e); throw new RuntimeException(e); } }